From f934181664d97229c6243b2a9f738526da3f15f9 Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Wed, 17 Jun 2026 14:42:59 -0400 Subject: [PATCH 1/5] regenerate with td only --- sdk/ai/azure-ai-agents/_metadata.json | 5 +- .../azure-ai-agents/apiview-properties.json | 440 +- .../azure/ai/agents/__init__.py | 5 +- .../azure/ai/agents/_client.py | 105 +- .../azure/ai/agents/_configuration.py | 29 +- .../azure/ai/agents/_unions.py | 13 + .../azure/ai/agents/_utils/model_base.py | 13 +- .../azure/ai/agents/_utils/serialization.py | 46 +- .../azure/ai/agents/_utils/utils.py | 44 +- .../azure/ai/agents/aio/__init__.py | 5 +- .../azure/ai/agents/aio/_client.py | 106 +- .../azure/ai/agents/aio/_configuration.py | 29 +- .../ai/agents/aio/operations/__init__.py | 32 +- .../ai/agents/aio/operations/_operations.py | 16065 +++++++++++--- .../azure/ai/agents/models/__init__.py | 527 +- .../azure/ai/agents/models/_models.py | 1 + .../azure/ai/agents/operations/__init__.py | 32 +- .../azure/ai/agents/operations/_operations.py | 17704 +++++++++++++--- .../azure-ai-agents/azure/ai/agents/types.py | 3342 +++ .../azure/ai/projects/__init__.py | 1 + .../azure/ai/projects/models/__init__.py | 21 + .../azure/ai/projects/models/_patch.py | 21 + .../azure/ai/projects/types.py | 1317 ++ sdk/ai/azure-ai-agents/pyproject.toml | 79 +- ...gents_basics_with_console_tracing_async.py | 7 +- sdk/ai/azure-ai-agents/setup.py | 80 - 26 files changed, 32605 insertions(+), 7464 deletions(-) create mode 100644 sdk/ai/azure-ai-agents/azure/ai/agents/_unions.py create mode 100644 sdk/ai/azure-ai-agents/azure/ai/agents/types.py create mode 100644 sdk/ai/azure-ai-agents/azure/ai/projects/__init__.py create mode 100644 sdk/ai/azure-ai-agents/azure/ai/projects/models/__init__.py create mode 100644 sdk/ai/azure-ai-agents/azure/ai/projects/models/_patch.py create mode 100644 sdk/ai/azure-ai-agents/azure/ai/projects/types.py delete mode 100644 sdk/ai/azure-ai-agents/setup.py diff --git a/sdk/ai/azure-ai-agents/_metadata.json b/sdk/ai/azure-ai-agents/_metadata.json index 253921f335be..3a000fe50d57 100644 --- a/sdk/ai/azure-ai-agents/_metadata.json +++ b/sdk/ai/azure-ai-agents/_metadata.json @@ -1,3 +1,6 @@ { - "apiVersion": "2025-05-15-preview" + "apiVersion": "v1", + "apiVersions": { + "Azure.AI.Projects": "v1" + } } \ No newline at end of file diff --git a/sdk/ai/azure-ai-agents/apiview-properties.json b/sdk/ai/azure-ai-agents/apiview-properties.json index 823c94f6b76f..94e4052093de 100644 --- a/sdk/ai/azure-ai-agents/apiview-properties.json +++ b/sdk/ai/azure-ai-agents/apiview-properties.json @@ -1,332 +1,114 @@ { - "CrossLanguagePackageId": "Azure.AI.Agents", + "CrossLanguagePackageId": "Azure.AI.Projects", "CrossLanguageDefinitionId": { - "azure.ai.agents.models.ActivityFunctionDefinition": "Azure.AI.Agents.ActivityFunctionDefinition", - "azure.ai.agents.models.ActivityFunctionParameters": "Azure.AI.Agents.ActivityFunctionParameters", - "azure.ai.agents.models.Agent": "Azure.AI.Agents.Agent", - "azure.ai.agents.models.AgentErrorDetail": "Azure.AI.Agents.AgentErrorDetail", - "azure.ai.agents.models.AgentsNamedToolChoice": "Azure.AI.Agents.AgentsNamedToolChoice", - "azure.ai.agents.models.AgentsResponseFormat": "Azure.AI.Agents.AgentsResponseFormat", - "azure.ai.agents.models.AgentThread": "Azure.AI.Agents.AgentThread", - "azure.ai.agents.models.AgentThreadCreationOptions": "Azure.AI.Agents.AgentThreadCreationOptions", - "azure.ai.agents.models.AgentV1Error": "Azure.AI.Agents.AgentV1Error", - "azure.ai.agents.models.AISearchIndexResource": "Azure.AI.Agents.AISearchIndexResource", - "azure.ai.agents.models.ToolDefinition": "Azure.AI.Agents.ToolDefinition", - "azure.ai.agents.models.AzureAISearchToolDefinition": "Azure.AI.Agents.AzureAISearchToolDefinition", - "azure.ai.agents.models.AzureAISearchToolResource": "Azure.AI.Agents.AzureAISearchToolResource", - "azure.ai.agents.models.AzureFunctionBinding": "Azure.AI.Agents.AzureFunctionBinding", - "azure.ai.agents.models.AzureFunctionDefinition": "Azure.AI.Agents.AzureFunctionDefinition", - "azure.ai.agents.models.AzureFunctionStorageQueue": "Azure.AI.Agents.AzureFunctionStorageQueue", - "azure.ai.agents.models.AzureFunctionToolCallDetails": "Azure.AI.Agents.AzureFunctionToolCallDetails", - "azure.ai.agents.models.AzureFunctionToolDefinition": "Azure.AI.Agents.AzureFunctionToolDefinition", - "azure.ai.agents.models.BingCustomSearchConfiguration": "Azure.AI.Agents.BingCustomSearchConfiguration", - "azure.ai.agents.models.BingCustomSearchToolDefinition": "Azure.AI.Agents.BingCustomSearchToolDefinition", - "azure.ai.agents.models.BingCustomSearchToolParameters": "Azure.AI.Agents.BingCustomSearchToolParameters", - "azure.ai.agents.models.BingGroundingSearchConfiguration": "Azure.AI.Agents.BingGroundingSearchConfiguration", - "azure.ai.agents.models.BingGroundingSearchToolParameters": "Azure.AI.Agents.BingGroundingSearchToolParameters", - "azure.ai.agents.models.BingGroundingToolDefinition": "Azure.AI.Agents.BingGroundingToolDefinition", - "azure.ai.agents.models.BrowserAutomationToolCallDetails": "Azure.AI.Agents.BrowserAutomationToolCallDetails", - "azure.ai.agents.models.BrowserAutomationToolCallStep": "Azure.AI.Agents.BrowserAutomationToolCallStep", - "azure.ai.agents.models.BrowserAutomationToolConnectionParameters": "Azure.AI.Agents.BrowserAutomationToolConnectionParameters", - "azure.ai.agents.models.BrowserAutomationToolDefinition": "Azure.AI.Agents.BrowserAutomationToolDefinition", - "azure.ai.agents.models.BrowserAutomationToolParameters": "Azure.AI.Agents.BrowserAutomationToolParameters", - "azure.ai.agents.models.ComputerUseAction": "Azure.AI.Agents.ComputerUseAction", - "azure.ai.agents.models.ClickAction": "Azure.AI.Agents.ClickAction", - "azure.ai.agents.models.CodeInterpreterToolDefinition": "Azure.AI.Agents.CodeInterpreterToolDefinition", - "azure.ai.agents.models.CodeInterpreterToolResource": "Azure.AI.Agents.CodeInterpreterToolResource", - "azure.ai.agents.models.ComputerScreenshot": "Azure.AI.Agents.ComputerScreenshot", - "azure.ai.agents.models.StructuredToolOutput": "Azure.AI.Agents.StructuredToolOutput", - "azure.ai.agents.models.ComputerToolOutput": "Azure.AI.Agents.ComputerToolOutput", - "azure.ai.agents.models.ComputerUseToolDefinition": "Azure.AI.Agents.ComputerUseToolDefinition", - "azure.ai.agents.models.ComputerUseToolParameters": "Azure.AI.Agents.ComputerUseToolParameters", - "azure.ai.agents.models.ConnectedAgentDetails": "Azure.AI.Agents.ConnectedAgentDetails", - "azure.ai.agents.models.ConnectedAgentToolDefinition": "Azure.AI.Agents.ConnectedAgentToolDefinition", - "azure.ai.agents.models.CoordinatePoint": "Azure.AI.Agents.CoordinatePoint", - "azure.ai.agents.models.DeepResearchBingGroundingConnection": "Azure.AI.Agents.DeepResearchBingGroundingConnection", - "azure.ai.agents.models.DeepResearchDetails": "Azure.AI.Agents.DeepResearchDetails", - "azure.ai.agents.models.DeepResearchToolDefinition": "Azure.AI.Agents.DeepResearchToolDefinition", - "azure.ai.agents.models.DoubleClickAction": "Azure.AI.Agents.DoubleClickAction", - "azure.ai.agents.models.DragAction": "Azure.AI.Agents.DragAction", - "azure.ai.agents.models.FabricDataAgentToolParameters": "Azure.AI.Agents.FabricDataAgentToolParameters", - "azure.ai.agents.models.FileInfo": "Azure.AI.Agents.FileInfo", - "azure.ai.agents.models.FileListResponse": "Azure.AI.Agents.FileListResponse", - "azure.ai.agents.models.FileSearchRankingOptions": "Azure.AI.Agents.FileSearchRankingOptions", - "azure.ai.agents.models.FileSearchToolCallContent": "Azure.AI.Agents.FileSearchToolCallContent", - "azure.ai.agents.models.FileSearchToolDefinition": "Azure.AI.Agents.FileSearchToolDefinition", - "azure.ai.agents.models.FileSearchToolDefinitionDetails": "Azure.AI.Agents.FileSearchToolDefinitionDetails", - "azure.ai.agents.models.FileSearchToolResource": "Azure.AI.Agents.FileSearchToolResource", - "azure.ai.agents.models.FunctionArgument": "Azure.AI.Agents.FunctionArgument", - "azure.ai.agents.models.FunctionDefinition": "Azure.AI.Agents.FunctionDefinition", - "azure.ai.agents.models.FunctionName": "Azure.AI.Agents.FunctionName", - "azure.ai.agents.models.FunctionToolDefinition": "Azure.AI.Agents.FunctionToolDefinition", - "azure.ai.agents.models.IncompleteRunDetails": "Azure.AI.Agents.IncompleteRunDetails", - "azure.ai.agents.models.KeyPressAction": "Azure.AI.Agents.KeyPressAction", - "azure.ai.agents.models.MCPApprovalPerTool": "Azure.AI.Agents.MCPApprovalPerTool", - "azure.ai.agents.models.MCPToolDefinition": "Azure.AI.Agents.MCPToolDefinition", - "azure.ai.agents.models.MCPToolList": "Azure.AI.Agents.MCPToolList", - "azure.ai.agents.models.MCPToolResource": "Azure.AI.Agents.MCPToolResource", - "azure.ai.agents.models.MessageAttachment": "Azure.AI.Agents.MessageAttachment", - "azure.ai.agents.models.MessageContent": "Azure.AI.Agents.MessageContent", - "azure.ai.agents.models.MessageDelta": "Azure.AI.Agents.MessageDelta", - "azure.ai.agents.models.MessageDeltaChunk": "Azure.AI.Agents.MessageDeltaChunk", - "azure.ai.agents.models.MessageDeltaContent": "Azure.AI.Agents.MessageDeltaContent", - "azure.ai.agents.models.MessageDeltaImageFileContent": "Azure.AI.Agents.MessageDeltaImageFileContent", - "azure.ai.agents.models.MessageDeltaImageFileContentObject": "Azure.AI.Agents.MessageDeltaImageFileContentObject", - "azure.ai.agents.models.MessageDeltaTextAnnotation": "Azure.AI.Agents.MessageDeltaTextAnnotation", - "azure.ai.agents.models.MessageDeltaTextContent": "Azure.AI.Agents.MessageDeltaTextContent", - "azure.ai.agents.models.MessageDeltaTextContentObject": "Azure.AI.Agents.MessageDeltaTextContentObject", - "azure.ai.agents.models.MessageDeltaTextFileCitationAnnotation": "Azure.AI.Agents.MessageDeltaTextFileCitationAnnotation", - "azure.ai.agents.models.MessageDeltaTextFileCitationAnnotationObject": "Azure.AI.Agents.MessageDeltaTextFileCitationAnnotationObject", - "azure.ai.agents.models.MessageDeltaTextFilePathAnnotation": "Azure.AI.Agents.MessageDeltaTextFilePathAnnotation", - "azure.ai.agents.models.MessageDeltaTextFilePathAnnotationObject": "Azure.AI.Agents.MessageDeltaTextFilePathAnnotationObject", - "azure.ai.agents.models.MessageDeltaTextUrlCitationAnnotation": "Azure.AI.Agents.MessageDeltaTextUrlCitationAnnotation", - "azure.ai.agents.models.MessageDeltaTextUrlCitationDetails": "Azure.AI.Agents.MessageDeltaTextUrlCitationDetails", - "azure.ai.agents.models.MessageImageFileContent": "Azure.AI.Agents.MessageImageFileContent", - "azure.ai.agents.models.MessageImageFileDetails": "Azure.AI.Agents.MessageImageFileDetails", - "azure.ai.agents.models.MessageImageFileParam": "Azure.AI.Agents.MessageImageFileParam", - "azure.ai.agents.models.MessageImageUrlParam": "Azure.AI.Agents.MessageImageUrlParam", - "azure.ai.agents.models.MessageIncompleteDetails": "Azure.AI.Agents.MessageIncompleteDetails", - "azure.ai.agents.models.MessageInputContentBlock": "Azure.AI.Agents.MessageInputContentBlock", - "azure.ai.agents.models.MessageInputImageFileBlock": "Azure.AI.Agents.MessageInputImageFileBlock", - "azure.ai.agents.models.MessageInputImageUrlBlock": "Azure.AI.Agents.MessageInputImageUrlBlock", - "azure.ai.agents.models.MessageInputTextBlock": "Azure.AI.Agents.MessageInputTextBlock", - "azure.ai.agents.models.MessageTextAnnotation": "Azure.AI.Agents.MessageTextAnnotation", - "azure.ai.agents.models.MessageTextContent": "Azure.AI.Agents.MessageTextContent", - "azure.ai.agents.models.MessageTextDetails": "Azure.AI.Agents.MessageTextDetails", - "azure.ai.agents.models.MessageTextFileCitationAnnotation": "Azure.AI.Agents.MessageTextFileCitationAnnotation", - "azure.ai.agents.models.MessageTextFileCitationDetails": "Azure.AI.Agents.MessageTextFileCitationDetails", - "azure.ai.agents.models.MessageTextFilePathAnnotation": "Azure.AI.Agents.MessageTextFilePathAnnotation", - "azure.ai.agents.models.MessageTextFilePathDetails": "Azure.AI.Agents.MessageTextFilePathDetails", - "azure.ai.agents.models.MessageTextUrlCitationAnnotation": "Azure.AI.Agents.MessageTextUrlCitationAnnotation", - "azure.ai.agents.models.MessageTextUrlCitationDetails": "Azure.AI.Agents.MessageTextUrlCitationDetails", - "azure.ai.agents.models.MicrosoftFabricToolDefinition": "Azure.AI.Agents.MicrosoftFabricToolDefinition", - "azure.ai.agents.models.MoveAction": "Azure.AI.Agents.MoveAction", - "azure.ai.agents.models.OpenApiAuthDetails": "Azure.AI.Agents.OpenApiAuthDetails", - "azure.ai.agents.models.OpenApiAnonymousAuthDetails": "Azure.AI.Agents.OpenApiAnonymousAuthDetails", - "azure.ai.agents.models.OpenApiConnectionAuthDetails": "Azure.AI.Agents.OpenApiConnectionAuthDetails", - "azure.ai.agents.models.OpenApiConnectionSecurityScheme": "Azure.AI.Agents.OpenApiConnectionSecurityScheme", - "azure.ai.agents.models.OpenApiFunctionDefinition": "Azure.AI.Agents.OpenApiFunctionDefinition", - "azure.ai.agents.models.OpenApiManagedAuthDetails": "Azure.AI.Agents.OpenApiManagedAuthDetails", - "azure.ai.agents.models.OpenApiManagedSecurityScheme": "Azure.AI.Agents.OpenApiManagedSecurityScheme", - "azure.ai.agents.models.OpenApiToolDefinition": "Azure.AI.Agents.OpenApiToolDefinition", - "azure.ai.agents.models.RequiredAction": "Azure.AI.Agents.RequiredAction", - "azure.ai.agents.models.RequiredToolCall": "Azure.AI.Agents.RequiredToolCall", - "azure.ai.agents.models.RequiredComputerUseToolCall": "Azure.AI.Agents.RequiredComputerUseToolCall", - "azure.ai.agents.models.RequiredComputerUseToolCallDetails": "Azure.AI.Agents.RequiredComputerUseToolCallDetails", - "azure.ai.agents.models.RequiredFunctionToolCall": "Azure.AI.Agents.RequiredFunctionToolCall", - "azure.ai.agents.models.RequiredFunctionToolCallDetails": "Azure.AI.Agents.RequiredFunctionToolCallDetails", - "azure.ai.agents.models.RequiredMcpToolCall": "Azure.AI.Agents.RequiredMcpToolCall", - "azure.ai.agents.models.ResponseFormatJsonSchema": "Azure.AI.Agents.ResponseFormatJsonSchema", - "azure.ai.agents.models.ResponseFormatJsonSchemaType": "Azure.AI.Agents.ResponseFormatJsonSchemaType", - "azure.ai.agents.models.RunCompletionUsage": "Azure.AI.Agents.RunCompletionUsage", - "azure.ai.agents.models.RunError": "Azure.AI.Agents.RunError", - "azure.ai.agents.models.RunStep": "Azure.AI.Agents.RunStep", - "azure.ai.agents.models.RunStepDetails": "Azure.AI.Agents.RunStepDetails", - "azure.ai.agents.models.RunStepActivityDetails": "Azure.AI.Agents.RunStepActivityDetails", - "azure.ai.agents.models.RunStepToolCall": "Azure.AI.Agents.RunStepToolCall", - "azure.ai.agents.models.RunStepAzureAISearchToolCall": "Azure.AI.Agents.RunStepAzureAISearchToolCall", - "azure.ai.agents.models.RunStepAzureFunctionToolCall": "Azure.AI.Agents.RunStepAzureFunctionToolCall", - "azure.ai.agents.models.RunStepBingCustomSearchToolCall": "Azure.AI.Agents.RunStepBingCustomSearchToolCall", - "azure.ai.agents.models.RunStepBingGroundingToolCall": "Azure.AI.Agents.RunStepBingGroundingToolCall", - "azure.ai.agents.models.RunStepBrowserAutomationToolCall": "Azure.AI.Agents.RunStepBrowserAutomationToolCall", - "azure.ai.agents.models.RunStepCodeInterpreterToolCallOutput": "Azure.AI.Agents.RunStepCodeInterpreterToolCallOutput", - "azure.ai.agents.models.RunStepCodeInterpreterImageOutput": "Azure.AI.Agents.RunStepCodeInterpreterImageOutput", - "azure.ai.agents.models.RunStepCodeInterpreterImageReference": "Azure.AI.Agents.RunStepCodeInterpreterImageReference", - "azure.ai.agents.models.RunStepCodeInterpreterLogOutput": "Azure.AI.Agents.RunStepCodeInterpreterLogOutput", - "azure.ai.agents.models.RunStepCodeInterpreterToolCall": "Azure.AI.Agents.RunStepCodeInterpreterToolCall", - "azure.ai.agents.models.RunStepCodeInterpreterToolCallDetails": "Azure.AI.Agents.RunStepCodeInterpreterToolCallDetails", - "azure.ai.agents.models.RunStepCompletionUsage": "Azure.AI.Agents.RunStepCompletionUsage", - "azure.ai.agents.models.RunStepComputerUseToolCall": "Azure.AI.Agents.RunStepComputerUseToolCall", - "azure.ai.agents.models.RunStepComputerUseToolCallDetails": "Azure.AI.Agents.RunStepComputerUseToolCallDetails", - "azure.ai.agents.models.RunStepConnectedAgent": "Azure.AI.Agents.RunStepConnectedAgent", - "azure.ai.agents.models.RunStepConnectedAgentToolCall": "Azure.AI.Agents.RunStepConnectedAgentToolCall", - "azure.ai.agents.models.RunStepDeepResearchToolCall": "Azure.AI.Agents.RunStepDeepResearchToolCall", - "azure.ai.agents.models.RunStepDeepResearchToolCallDetails": "Azure.AI.Agents.RunStepDeepResearchToolCallDetails", - "azure.ai.agents.models.RunStepDelta": "Azure.AI.Agents.RunStepDelta", - "azure.ai.agents.models.RunStepDeltaToolCall": "Azure.AI.Agents.RunStepDeltaToolCall", - "azure.ai.agents.models.RunStepDeltaAzureAISearchToolCall": "Azure.AI.Agents.RunStepDeltaAzureAISearchToolCall", - "azure.ai.agents.models.RunStepDeltaAzureFunctionToolCall": "Azure.AI.Agents.RunStepDeltaAzureFunctionToolCall", - "azure.ai.agents.models.RunStepDeltaBingGroundingToolCall": "Azure.AI.Agents.RunStepDeltaBingGroundingToolCall", - "azure.ai.agents.models.RunStepDeltaChunk": "Azure.AI.Agents.RunStepDeltaChunk", - "azure.ai.agents.models.RunStepDeltaCodeInterpreterDetailItemObject": "Azure.AI.Agents.RunStepDeltaCodeInterpreterDetailItemObject", - "azure.ai.agents.models.RunStepDeltaCodeInterpreterOutput": "Azure.AI.Agents.RunStepDeltaCodeInterpreterOutput", - "azure.ai.agents.models.RunStepDeltaCodeInterpreterImageOutput": "Azure.AI.Agents.RunStepDeltaCodeInterpreterImageOutput", - "azure.ai.agents.models.RunStepDeltaCodeInterpreterImageOutputObject": "Azure.AI.Agents.RunStepDeltaCodeInterpreterImageOutputObject", - "azure.ai.agents.models.RunStepDeltaCodeInterpreterLogOutput": "Azure.AI.Agents.RunStepDeltaCodeInterpreterLogOutput", - "azure.ai.agents.models.RunStepDeltaCodeInterpreterToolCall": "Azure.AI.Agents.RunStepDeltaCodeInterpreterToolCall", - "azure.ai.agents.models.RunStepDeltaComputerUseDetails": "Azure.AI.Agents.RunStepDeltaComputerUseDetails", - "azure.ai.agents.models.RunStepDeltaComputerUseToolCall": "Azure.AI.Agents.RunStepDeltaComputerUseToolCall", - "azure.ai.agents.models.RunStepDeltaConnectedAgentToolCall": "Azure.AI.Agents.RunStepDeltaConnectedAgentToolCall", - "azure.ai.agents.models.RunStepDeltaCustomBingGroundingToolCall": "Azure.AI.Agents.RunStepDeltaCustomBingGroundingToolCall", - "azure.ai.agents.models.RunStepDeltaDeepResearchToolCall": "Azure.AI.Agents.RunStepDeltaDeepResearchToolCall", - "azure.ai.agents.models.RunStepDeltaDetail": "Azure.AI.Agents.RunStepDeltaDetail", - "azure.ai.agents.models.RunStepDeltaFileSearchToolCall": "Azure.AI.Agents.RunStepDeltaFileSearchToolCall", - "azure.ai.agents.models.RunStepDeltaFunction": "Azure.AI.Agents.RunStepDeltaFunction", - "azure.ai.agents.models.RunStepDeltaFunctionToolCall": "Azure.AI.Agents.RunStepDeltaFunctionToolCall", - "azure.ai.agents.models.RunStepDeltaMCPObject": "Azure.AI.Agents.RunStepDeltaMCPObject", - "azure.ai.agents.models.RunStepDeltaMcpToolCall": "Azure.AI.Agents.RunStepDeltaMcpToolCall", - "azure.ai.agents.models.RunStepDeltaMessageCreation": "Azure.AI.Agents.RunStepDeltaMessageCreation", - "azure.ai.agents.models.RunStepDeltaMessageCreationObject": "Azure.AI.Agents.RunStepDeltaMessageCreationObject", - "azure.ai.agents.models.RunStepDeltaMicrosoftFabricToolCall": "Azure.AI.Agents.RunStepDeltaMicrosoftFabricToolCall", - "azure.ai.agents.models.RunStepDeltaOpenAPIObject": "Azure.AI.Agents.RunStepDeltaOpenAPIObject", - "azure.ai.agents.models.RunStepDeltaOpenAPIToolCall": "Azure.AI.Agents.RunStepDeltaOpenAPIToolCall", - "azure.ai.agents.models.RunStepDeltaSharepointToolCall": "Azure.AI.Agents.RunStepDeltaSharepointToolCall", - "azure.ai.agents.models.RunStepDeltaToolCallObject": "Azure.AI.Agents.RunStepDeltaToolCallObject", - "azure.ai.agents.models.RunStepDetailsActivity": "Azure.AI.Agents.RunStepDetailsActivity", - "azure.ai.agents.models.RunStepError": "Azure.AI.Agents.RunStepError", - "azure.ai.agents.models.RunStepFileSearchToolCall": "Azure.AI.Agents.RunStepFileSearchToolCall", - "azure.ai.agents.models.RunStepFileSearchToolCallResult": "Azure.AI.Agents.RunStepFileSearchToolCallResult", - "azure.ai.agents.models.RunStepFileSearchToolCallResults": "Azure.AI.Agents.RunStepFileSearchToolCallResults", - "azure.ai.agents.models.RunStepFunctionToolCall": "Azure.AI.Agents.RunStepFunctionToolCall", - "azure.ai.agents.models.RunStepFunctionToolCallDetails": "Azure.AI.Agents.RunStepFunctionToolCallDetails", - "azure.ai.agents.models.RunStepMcpToolCall": "Azure.AI.Agents.RunStepMcpToolCall", - "azure.ai.agents.models.RunStepMessageCreationDetails": "Azure.AI.Agents.RunStepMessageCreationDetails", - "azure.ai.agents.models.RunStepMessageCreationReference": "Azure.AI.Agents.RunStepMessageCreationReference", - "azure.ai.agents.models.RunStepMicrosoftFabricToolCall": "Azure.AI.Agents.RunStepMicrosoftFabricToolCall", - "azure.ai.agents.models.RunStepOpenAPIToolCall": "Azure.AI.Agents.RunStepOpenAPIToolCall", - "azure.ai.agents.models.RunStepSharepointToolCall": "Azure.AI.Agents.RunStepSharepointToolCall", - "azure.ai.agents.models.RunStepToolCallDetails": "Azure.AI.Agents.RunStepToolCallDetails", - "azure.ai.agents.models.SafetyCheck": "Azure.AI.Agents.SafetyCheck", - "azure.ai.agents.models.ScreenshotAction": "Azure.AI.Agents.ScreenshotAction", - "azure.ai.agents.models.ScrollAction": "Azure.AI.Agents.ScrollAction", - "azure.ai.agents.models.SharepointGroundingToolParameters": "Azure.AI.Agents.SharepointGroundingToolParameters", - "azure.ai.agents.models.SharepointToolDefinition": "Azure.AI.Agents.SharepointToolDefinition", - "azure.ai.agents.models.SubmitToolApprovalAction": "Azure.AI.Agents.SubmitToolApprovalAction", - "azure.ai.agents.models.SubmitToolApprovalDetails": "Azure.AI.Agents.SubmitToolApprovalDetails", - "azure.ai.agents.models.SubmitToolOutputsAction": "Azure.AI.Agents.SubmitToolOutputsAction", - "azure.ai.agents.models.SubmitToolOutputsDetails": "Azure.AI.Agents.SubmitToolOutputsDetails", - "azure.ai.agents.models.ThreadMessage": "Azure.AI.Agents.ThreadMessage", - "azure.ai.agents.models.ThreadMessageOptions": "Azure.AI.Agents.ThreadMessageOptions", - "azure.ai.agents.models.ThreadRun": "Azure.AI.Agents.ThreadRun", - "azure.ai.agents.models.ToolApproval": "Azure.AI.Agents.ToolApproval", - "azure.ai.agents.models.ToolConnection": "Azure.AI.Agents.ToolConnection", - "azure.ai.agents.models.ToolOutput": "Azure.AI.Agents.ToolOutput", - "azure.ai.agents.models.ToolResources": "Azure.AI.Agents.ToolResources", - "azure.ai.agents.models.TruncationObject": "Azure.AI.Agents.TruncationObject", - "azure.ai.agents.models.TypeAction": "Azure.AI.Agents.TypeAction", - "azure.ai.agents.models.VectorStore": "Azure.AI.Agents.VectorStore", - "azure.ai.agents.models.VectorStoreChunkingStrategyRequest": "Azure.AI.Agents.VectorStoreChunkingStrategyRequest", - "azure.ai.agents.models.VectorStoreAutoChunkingStrategyRequest": "Azure.AI.Agents.VectorStoreAutoChunkingStrategyRequest", - "azure.ai.agents.models.VectorStoreChunkingStrategyResponse": "Azure.AI.Agents.VectorStoreChunkingStrategyResponse", - "azure.ai.agents.models.VectorStoreAutoChunkingStrategyResponse": "Azure.AI.Agents.VectorStoreAutoChunkingStrategyResponse", - "azure.ai.agents.models.VectorStoreConfiguration": "Azure.AI.Agents.VectorStoreConfiguration", - "azure.ai.agents.models.VectorStoreConfigurations": "Azure.AI.Agents.VectorStoreConfigurations", - "azure.ai.agents.models.VectorStoreDataSource": "Azure.AI.Agents.VectorStoreDataSource", - "azure.ai.agents.models.VectorStoreExpirationPolicy": "Azure.AI.Agents.VectorStoreExpirationPolicy", - "azure.ai.agents.models.VectorStoreFile": "Azure.AI.Agents.VectorStoreFile", - "azure.ai.agents.models.VectorStoreFileBatch": "Azure.AI.Agents.VectorStoreFileBatch", - "azure.ai.agents.models.VectorStoreFileCount": "Azure.AI.Agents.VectorStoreFileCount", - "azure.ai.agents.models.VectorStoreFileError": "Azure.AI.Agents.VectorStoreFileError", - "azure.ai.agents.models.VectorStoreStaticChunkingStrategyOptions": "Azure.AI.Agents.VectorStoreStaticChunkingStrategyOptions", - "azure.ai.agents.models.VectorStoreStaticChunkingStrategyRequest": "Azure.AI.Agents.VectorStoreStaticChunkingStrategyRequest", - "azure.ai.agents.models.VectorStoreStaticChunkingStrategyResponse": "Azure.AI.Agents.VectorStoreStaticChunkingStrategyResponse", - "azure.ai.agents.models.WaitAction": "Azure.AI.Agents.WaitAction", - "azure.ai.agents.models.VectorStoreDataSourceAssetType": "Azure.AI.Agents.VectorStoreDataSourceAssetType", - "azure.ai.agents.models.AzureAISearchQueryType": "Azure.AI.Agents.AzureAISearchQueryType", - "azure.ai.agents.models.MessageRole": "Azure.AI.Agents.MessageRole", - "azure.ai.agents.models.MessageBlockType": "Azure.AI.Agents.MessageBlockType", - "azure.ai.agents.models.ImageDetailLevel": "Azure.AI.Agents.ImageDetailLevel", - "azure.ai.agents.models.ComputerUseEnvironment": "Azure.AI.Agents.ComputerUseEnvironment", - "azure.ai.agents.models.OpenApiAuthType": "Azure.AI.Agents.OpenApiAuthType", - "azure.ai.agents.models.ListSortOrder": "Azure.AI.Agents.ListSortOrder", - "azure.ai.agents.models.MessageStatus": "Azure.AI.Agents.MessageStatus", - "azure.ai.agents.models.MessageIncompleteDetailsReason": "Azure.AI.Agents.MessageIncompleteDetailsReason", - "azure.ai.agents.models.RunStatus": "Azure.AI.Agents.RunStatus", - "azure.ai.agents.models.MouseButton": "Azure.AI.Agents.MouseButton", - "azure.ai.agents.models.IncompleteDetailsReason": "Azure.AI.Agents.IncompleteDetailsReason", - "azure.ai.agents.models.TruncationStrategy": "Azure.AI.Agents.TruncationStrategy", - "azure.ai.agents.models.AgentsToolChoiceOptionMode": "Azure.AI.Agents.AgentsToolChoiceOptionMode", - "azure.ai.agents.models.AgentsNamedToolChoiceType": "Azure.AI.Agents.AgentsNamedToolChoiceType", - "azure.ai.agents.models.AgentsResponseFormatMode": "Azure.AI.Agents.AgentsResponseFormatMode", - "azure.ai.agents.models.ResponseFormat": "Azure.AI.Agents.ResponseFormat", - "azure.ai.agents.models.RunAdditionalFieldList": "Azure.AI.Agents.RunAdditionalFieldList", - "azure.ai.agents.models.RunStepType": "Azure.AI.Agents.RunStepType", - "azure.ai.agents.models.RunStepStatus": "Azure.AI.Agents.RunStepStatus", - "azure.ai.agents.models.RunStepErrorCode": "Azure.AI.Agents.RunStepErrorCode", - "azure.ai.agents.models.FilePurpose": "Azure.AI.Agents.FilePurpose", - "azure.ai.agents.models.FileState": "Azure.AI.Agents.FileState", - "azure.ai.agents.models.VectorStoreStatus": "Azure.AI.Agents.VectorStoreStatus", - "azure.ai.agents.models.VectorStoreExpirationPolicyAnchor": "Azure.AI.Agents.VectorStoreExpirationPolicyAnchor", - "azure.ai.agents.models.VectorStoreChunkingStrategyRequestType": "Azure.AI.Agents.VectorStoreChunkingStrategyRequestType", - "azure.ai.agents.models.VectorStoreFileStatus": "Azure.AI.Agents.VectorStoreFileStatus", - "azure.ai.agents.models.VectorStoreFileErrorCode": "Azure.AI.Agents.VectorStoreFileErrorCode", - "azure.ai.agents.models.VectorStoreChunkingStrategyResponseType": "Azure.AI.Agents.VectorStoreChunkingStrategyResponseType", - "azure.ai.agents.models.VectorStoreFileStatusFilter": "Azure.AI.Agents.VectorStoreFileStatusFilter", - "azure.ai.agents.models.VectorStoreFileBatchStatus": "Azure.AI.Agents.VectorStoreFileBatchStatus", - "azure.ai.agents.models.ThreadStreamEvent": "Azure.AI.Agents.ThreadStreamEvent", - "azure.ai.agents.models.RunStreamEvent": "Azure.AI.Agents.RunStreamEvent", - "azure.ai.agents.models.RunStepStreamEvent": "Azure.AI.Agents.RunStepStreamEvent", - "azure.ai.agents.models.MessageStreamEvent": "Azure.AI.Agents.MessageStreamEvent", - "azure.ai.agents.models.ErrorEvent": "Azure.AI.Agents.ErrorEvent", - "azure.ai.agents.models.DoneEvent": "Azure.AI.Agents.DoneEvent", - "azure.ai.agents.models.AgentStreamEvent": "Azure.AI.Agents.AgentStreamEvent", - "azure.ai.agents.operations.ThreadsOperations.create": "Azure.AI.Agents.Threads.createThread", - "azure.ai.agents.aio.operations.ThreadsOperations.create": "Azure.AI.Agents.Threads.createThread", - "azure.ai.agents.operations.ThreadsOperations.list": "Azure.AI.Agents.Threads.listThreads", - "azure.ai.agents.aio.operations.ThreadsOperations.list": "Azure.AI.Agents.Threads.listThreads", - "azure.ai.agents.operations.ThreadsOperations.get": "Azure.AI.Agents.Threads.getThread", - "azure.ai.agents.aio.operations.ThreadsOperations.get": "Azure.AI.Agents.Threads.getThread", - "azure.ai.agents.operations.ThreadsOperations.update": "Azure.AI.Agents.Threads.updateThread", - "azure.ai.agents.aio.operations.ThreadsOperations.update": "Azure.AI.Agents.Threads.updateThread", - "azure.ai.agents.operations.MessagesOperations.create": "Azure.AI.Agents.Messages.createMessage", - "azure.ai.agents.aio.operations.MessagesOperations.create": "Azure.AI.Agents.Messages.createMessage", - "azure.ai.agents.operations.MessagesOperations.list": "Azure.AI.Agents.Messages.listMessages", - "azure.ai.agents.aio.operations.MessagesOperations.list": "Azure.AI.Agents.Messages.listMessages", - "azure.ai.agents.operations.MessagesOperations.get": "Azure.AI.Agents.Messages.getMessage", - "azure.ai.agents.aio.operations.MessagesOperations.get": "Azure.AI.Agents.Messages.getMessage", - "azure.ai.agents.operations.MessagesOperations.update": "Azure.AI.Agents.Messages.updateMessage", - "azure.ai.agents.aio.operations.MessagesOperations.update": "Azure.AI.Agents.Messages.updateMessage", - "azure.ai.agents.operations.RunsOperations.create": "Azure.AI.Agents.Runs.createRun", - "azure.ai.agents.aio.operations.RunsOperations.create": "Azure.AI.Agents.Runs.createRun", - "azure.ai.agents.operations.RunsOperations.list": "Azure.AI.Agents.Runs.listRuns", - "azure.ai.agents.aio.operations.RunsOperations.list": "Azure.AI.Agents.Runs.listRuns", - "azure.ai.agents.operations.RunsOperations.get": "Azure.AI.Agents.Runs.getRun", - "azure.ai.agents.aio.operations.RunsOperations.get": "Azure.AI.Agents.Runs.getRun", - "azure.ai.agents.operations.RunsOperations.update": "Azure.AI.Agents.Runs.updateRun", - "azure.ai.agents.aio.operations.RunsOperations.update": "Azure.AI.Agents.Runs.updateRun", - "azure.ai.agents.operations.RunsOperations.submit_tool_outputs": "Azure.AI.Agents.Runs.submitToolOutputsToRun", - "azure.ai.agents.aio.operations.RunsOperations.submit_tool_outputs": "Azure.AI.Agents.Runs.submitToolOutputsToRun", - "azure.ai.agents.operations.RunsOperations.cancel": "Azure.AI.Agents.Runs.cancelRun", - "azure.ai.agents.aio.operations.RunsOperations.cancel": "Azure.AI.Agents.Runs.cancelRun", - "azure.ai.agents.operations.RunStepsOperations.get": "Azure.AI.Agents.RunSteps.getRunStep", - "azure.ai.agents.aio.operations.RunStepsOperations.get": "Azure.AI.Agents.RunSteps.getRunStep", - "azure.ai.agents.operations.RunStepsOperations.list": "Azure.AI.Agents.RunSteps.listRunSteps", - "azure.ai.agents.aio.operations.RunStepsOperations.list": "Azure.AI.Agents.RunSteps.listRunSteps", - "azure.ai.agents.operations.FilesOperations.list": "Azure.AI.Agents.Files.listFiles", - "azure.ai.agents.aio.operations.FilesOperations.list": "Azure.AI.Agents.Files.listFiles", - "azure.ai.agents.operations.FilesOperations.get": "Azure.AI.Agents.Files.getFile", - "azure.ai.agents.aio.operations.FilesOperations.get": "Azure.AI.Agents.Files.getFile", - "azure.ai.agents.operations.VectorStoresOperations.list": "Azure.AI.Agents.VectorStores.listVectorStores", - "azure.ai.agents.aio.operations.VectorStoresOperations.list": "Azure.AI.Agents.VectorStores.listVectorStores", - "azure.ai.agents.operations.VectorStoresOperations.create": "Azure.AI.Agents.VectorStores.createVectorStore", - "azure.ai.agents.aio.operations.VectorStoresOperations.create": "Azure.AI.Agents.VectorStores.createVectorStore", - "azure.ai.agents.operations.VectorStoresOperations.get": "Azure.AI.Agents.VectorStores.getVectorStore", - "azure.ai.agents.aio.operations.VectorStoresOperations.get": "Azure.AI.Agents.VectorStores.getVectorStore", - "azure.ai.agents.operations.VectorStoresOperations.modify": "Azure.AI.Agents.VectorStores.modifyVectorStore", - "azure.ai.agents.aio.operations.VectorStoresOperations.modify": "Azure.AI.Agents.VectorStores.modifyVectorStore", - "azure.ai.agents.operations.VectorStoreFilesOperations.list": "Azure.AI.Agents.VectorStoreFiles.listVectorStoreFiles", - "azure.ai.agents.aio.operations.VectorStoreFilesOperations.list": "Azure.AI.Agents.VectorStoreFiles.listVectorStoreFiles", - "azure.ai.agents.operations.VectorStoreFilesOperations.create": "Azure.AI.Agents.VectorStoreFiles.createVectorStoreFile", - "azure.ai.agents.aio.operations.VectorStoreFilesOperations.create": "Azure.AI.Agents.VectorStoreFiles.createVectorStoreFile", - "azure.ai.agents.operations.VectorStoreFilesOperations.get": "Azure.AI.Agents.VectorStoreFiles.getVectorStoreFile", - "azure.ai.agents.aio.operations.VectorStoreFilesOperations.get": "Azure.AI.Agents.VectorStoreFiles.getVectorStoreFile", - "azure.ai.agents.operations.VectorStoreFileBatchesOperations.create": "Azure.AI.Agents.VectorStoreFileBatches.createVectorStoreFileBatch", - "azure.ai.agents.aio.operations.VectorStoreFileBatchesOperations.create": "Azure.AI.Agents.VectorStoreFileBatches.createVectorStoreFileBatch", - "azure.ai.agents.operations.VectorStoreFileBatchesOperations.get": "Azure.AI.Agents.VectorStoreFileBatches.getVectorStoreFileBatch", - "azure.ai.agents.aio.operations.VectorStoreFileBatchesOperations.get": "Azure.AI.Agents.VectorStoreFileBatches.getVectorStoreFileBatch", - "azure.ai.agents.operations.VectorStoreFileBatchesOperations.cancel": "Azure.AI.Agents.VectorStoreFileBatches.cancelVectorStoreFileBatch", - "azure.ai.agents.aio.operations.VectorStoreFileBatchesOperations.cancel": "Azure.AI.Agents.VectorStoreFileBatches.cancelVectorStoreFileBatch", - "azure.ai.agents.operations.VectorStoreFileBatchesOperations.list_files": "Azure.AI.Agents.VectorStoreFileBatches.listVectorStoreFileBatchFiles", - "azure.ai.agents.aio.operations.VectorStoreFileBatchesOperations.list_files": "Azure.AI.Agents.VectorStoreFileBatches.listVectorStoreFileBatchFiles", - "azure.ai.agents.AgentsClient.create_agent": "Azure.AI.Agents.createAgent", - "azure.ai.agents.aio.AgentsClient.create_agent": "Azure.AI.Agents.createAgent", - "azure.ai.agents.AgentsClient.list_agents": "Azure.AI.Agents.listAgents", - "azure.ai.agents.aio.AgentsClient.list_agents": "Azure.AI.Agents.listAgents", - "azure.ai.agents.AgentsClient.get_agent": "Azure.AI.Agents.getAgent", - "azure.ai.agents.aio.AgentsClient.get_agent": "Azure.AI.Agents.getAgent", - "azure.ai.agents.AgentsClient.update_agent": "Azure.AI.Agents.updateAgent", - "azure.ai.agents.aio.AgentsClient.update_agent": "Azure.AI.Agents.updateAgent", - "azure.ai.agents.AgentsClient.create_thread_and_run": "Azure.AI.Agents.createThreadAndRun", - "azure.ai.agents.aio.AgentsClient.create_thread_and_run": "Azure.AI.Agents.createThreadAndRun" - } + "azure.ai.agents.models.EvaluationTaxonomyInputType": "Azure.AI.Projects.EvaluationTaxonomyInputType", + "azure.ai.agents.models.RiskCategory": "Azure.AI.Projects.RiskCategory", + "azure.ai.agents.models.FoundryFeaturesOptInKeys": "Azure.AI.Projects.FoundryFeaturesOptInKeys", + "azure.ai.agents.models.EvaluatorType": "Azure.AI.Projects.EvaluatorType", + "azure.ai.agents.models.EvaluatorCategory": "Azure.AI.Projects.EvaluatorCategory", + "azure.ai.agents.models.EvaluatorDefinitionType": "Azure.AI.Projects.EvaluatorDefinitionType", + "azure.ai.agents.models.EvaluatorMetricType": "Azure.AI.Projects.EvaluatorMetricType", + "azure.ai.agents.models.EvaluatorMetricDirection": "Azure.AI.Projects.EvaluatorMetricDirection", + "azure.ai.agents.models.OperationState": "Azure.Core.Foundations.OperationState", + "azure.ai.agents.models.InsightType": "Azure.AI.Projects.InsightType", + "azure.ai.agents.models.SampleType": "Azure.AI.Projects.SampleType", + "azure.ai.agents.models.TreatmentEffectType": "Azure.AI.Projects.TreatmentEffectType", + "azure.ai.agents.models.MemoryStoreObjectType": "Azure.AI.Projects.MemoryStoreObjectType", + "azure.ai.agents.models.MemoryStoreKind": "Azure.AI.Projects.MemoryStoreKind", + "azure.ai.agents.models.PageOrder": "Azure.AI.Projects.PageOrder", + "azure.ai.agents.models.MemoryItemKind": "Azure.AI.Projects.MemoryItemKind", + "azure.ai.agents.models.MemoryOperationKind": "Azure.AI.Projects.MemoryOperationKind", + "azure.ai.agents.models.AttackStrategy": "Azure.AI.Projects.AttackStrategy", + "azure.ai.agents.models.ScheduleProvisioningStatus": "Azure.AI.Projects.ScheduleProvisioningStatus", + "azure.ai.agents.models.TriggerType": "Azure.AI.Projects.TriggerType", + "azure.ai.agents.models.RecurrenceType": "Azure.AI.Projects.RecurrenceType", + "azure.ai.agents.models.DayOfWeek": "Azure.AI.Projects.DayOfWeek", + "azure.ai.agents.models.ScheduleTaskType": "Azure.AI.Projects.ScheduleTaskType", + "azure.ai.agents.models.AgentObjectType": "Azure.AI.Projects.AgentObjectType", + "azure.ai.agents.models.AgentKind": "Azure.AI.Projects.AgentKind", + "azure.ai.agents.models.ToolType": "OpenAI.ToolType", + "azure.ai.agents.models.AzureAISearchQueryType": "Azure.AI.Projects.AzureAISearchQueryType", + "azure.ai.agents.models.ContainerMemoryLimit": "OpenAI.ContainerMemoryLimit", + "azure.ai.agents.models.ContainerNetworkPolicyParamType": "OpenAI.ContainerNetworkPolicyParamType", + "azure.ai.agents.models.ComputerEnvironment": "OpenAI.ComputerEnvironment", + "azure.ai.agents.models.CustomToolParamFormatType": "OpenAI.CustomToolParamFormatType", + "azure.ai.agents.models.GrammarSyntax1": "OpenAI.GrammarSyntax1", + "azure.ai.agents.models.RankerVersionType": "OpenAI.RankerVersionType", + "azure.ai.agents.models.InputFidelity": "OpenAI.InputFidelity", + "azure.ai.agents.models.ImageGenAction": "OpenAI.ImageGenActionEnum", + "azure.ai.agents.models.OpenApiAuthType": "Azure.AI.Projects.OpenApiAuthType", + "azure.ai.agents.models.FunctionShellToolParamEnvironmentType": "OpenAI.FunctionShellToolParamEnvironmentType", + "azure.ai.agents.models.ContainerSkillType": "OpenAI.ContainerSkillType", + "azure.ai.agents.models.SearchContextSize": "OpenAI.SearchContextSize", + "azure.ai.agents.models.AgentProtocol": "Azure.AI.Projects.AgentProtocol", + "azure.ai.agents.models.ToolChoiceParamType": "OpenAI.ToolChoiceParamType", + "azure.ai.agents.models.TextResponseFormatConfigurationType": "OpenAI.TextResponseFormatConfigurationType", + "azure.ai.agents.models.AgentDefinitionOptInKeys": "Azure.AI.Projects.AgentDefinitionOptInKeys", + "azure.ai.agents.models.EvaluationRuleActionType": "Azure.AI.Projects.EvaluationRuleActionType", + "azure.ai.agents.models.EvaluationRuleEventType": "Azure.AI.Projects.EvaluationRuleEventType", + "azure.ai.agents.models.ConnectionType": "Azure.AI.Projects.ConnectionType", + "azure.ai.agents.models.CredentialType": "Azure.AI.Projects.CredentialType", + "azure.ai.agents.models.DatasetType": "Azure.AI.Projects.DatasetType", + "azure.ai.agents.models.PendingUploadType": "Azure.AI.Projects.PendingUploadType", + "azure.ai.agents.models.DeploymentType": "Azure.AI.Projects.DeploymentType", + "azure.ai.agents.models.IndexType": "Azure.AI.Projects.IndexType", + "azure.ai.agents.models.MemoryStoreUpdateStatus": "Azure.AI.Projects.MemoryStoreUpdateStatus", + "azure.ai.agents.operations.AgentsOperations.get": "Azure.AI.Projects.Agents.getAgent", + "azure.ai.agents.aio.operations.AgentsOperations.get": "Azure.AI.Projects.Agents.getAgent", + "azure.ai.agents.operations.AgentsOperations.delete": "Azure.AI.Projects.Agents.deleteAgent", + "azure.ai.agents.aio.operations.AgentsOperations.delete": "Azure.AI.Projects.Agents.deleteAgent", + "azure.ai.agents.operations.AgentsOperations.list": "Azure.AI.Projects.Agents.listAgents", + "azure.ai.agents.aio.operations.AgentsOperations.list": "Azure.AI.Projects.Agents.listAgents", + "azure.ai.agents.operations.AgentsOperations.create_version": "Azure.AI.Projects.Agents.createAgentVersion", + "azure.ai.agents.aio.operations.AgentsOperations.create_version": "Azure.AI.Projects.Agents.createAgentVersion", + "azure.ai.agents.operations.AgentsOperations.create_version_from_manifest": "Azure.AI.Projects.Agents.createAgentVersionFromManifest", + "azure.ai.agents.aio.operations.AgentsOperations.create_version_from_manifest": "Azure.AI.Projects.Agents.createAgentVersionFromManifest", + "azure.ai.agents.operations.AgentsOperations.get_version": "Azure.AI.Projects.Agents.getAgentVersion", + "azure.ai.agents.aio.operations.AgentsOperations.get_version": "Azure.AI.Projects.Agents.getAgentVersion", + "azure.ai.agents.operations.AgentsOperations.delete_version": "Azure.AI.Projects.Agents.deleteAgentVersion", + "azure.ai.agents.aio.operations.AgentsOperations.delete_version": "Azure.AI.Projects.Agents.deleteAgentVersion", + "azure.ai.agents.operations.AgentsOperations.list_versions": "Azure.AI.Projects.Agents.listAgentVersions", + "azure.ai.agents.aio.operations.AgentsOperations.list_versions": "Azure.AI.Projects.Agents.listAgentVersions", + "azure.ai.agents.operations.EvaluationRulesOperations.get": "Azure.AI.Projects.EvaluationRules.get", + "azure.ai.agents.aio.operations.EvaluationRulesOperations.get": "Azure.AI.Projects.EvaluationRules.get", + "azure.ai.agents.operations.EvaluationRulesOperations.delete": "Azure.AI.Projects.EvaluationRules.delete", + "azure.ai.agents.aio.operations.EvaluationRulesOperations.delete": "Azure.AI.Projects.EvaluationRules.delete", + "azure.ai.agents.operations.EvaluationRulesOperations.create_or_update": "Azure.AI.Projects.EvaluationRules.createOrUpdate", + "azure.ai.agents.aio.operations.EvaluationRulesOperations.create_or_update": "Azure.AI.Projects.EvaluationRules.createOrUpdate", + "azure.ai.agents.operations.EvaluationRulesOperations.list": "Azure.AI.Projects.EvaluationRules.list", + "azure.ai.agents.aio.operations.EvaluationRulesOperations.list": "Azure.AI.Projects.EvaluationRules.list", + "azure.ai.agents.operations.ConnectionsOperations.list": "Azure.AI.Projects.Connections.list", + "azure.ai.agents.aio.operations.ConnectionsOperations.list": "Azure.AI.Projects.Connections.list", + "azure.ai.agents.operations.DatasetsOperations.list_versions": "Azure.AI.Projects.Datasets.listVersions", + "azure.ai.agents.aio.operations.DatasetsOperations.list_versions": "Azure.AI.Projects.Datasets.listVersions", + "azure.ai.agents.operations.DatasetsOperations.list": "Azure.AI.Projects.Datasets.listLatest", + "azure.ai.agents.aio.operations.DatasetsOperations.list": "Azure.AI.Projects.Datasets.listLatest", + "azure.ai.agents.operations.DatasetsOperations.get": "Azure.AI.Projects.Datasets.getVersion", + "azure.ai.agents.aio.operations.DatasetsOperations.get": "Azure.AI.Projects.Datasets.getVersion", + "azure.ai.agents.operations.DatasetsOperations.delete": "Azure.AI.Projects.Datasets.deleteVersion", + "azure.ai.agents.aio.operations.DatasetsOperations.delete": "Azure.AI.Projects.Datasets.deleteVersion", + "azure.ai.agents.operations.DatasetsOperations.create_or_update": "Azure.AI.Projects.Datasets.createOrUpdateVersion", + "azure.ai.agents.aio.operations.DatasetsOperations.create_or_update": "Azure.AI.Projects.Datasets.createOrUpdateVersion", + "azure.ai.agents.operations.DatasetsOperations.pending_upload": "Azure.AI.Projects.Datasets.startPendingUploadVersion", + "azure.ai.agents.aio.operations.DatasetsOperations.pending_upload": "Azure.AI.Projects.Datasets.startPendingUploadVersion", + "azure.ai.agents.operations.DatasetsOperations.get_credentials": "Azure.AI.Projects.Datasets.getCredentials", + "azure.ai.agents.aio.operations.DatasetsOperations.get_credentials": "Azure.AI.Projects.Datasets.getCredentials", + "azure.ai.agents.operations.DeploymentsOperations.get": "Azure.AI.Projects.Deployments.get", + "azure.ai.agents.aio.operations.DeploymentsOperations.get": "Azure.AI.Projects.Deployments.get", + "azure.ai.agents.operations.DeploymentsOperations.list": "Azure.AI.Projects.Deployments.list", + "azure.ai.agents.aio.operations.DeploymentsOperations.list": "Azure.AI.Projects.Deployments.list", + "azure.ai.agents.operations.IndexesOperations.list_versions": "Azure.AI.Projects.Indexes.listVersions", + "azure.ai.agents.aio.operations.IndexesOperations.list_versions": "Azure.AI.Projects.Indexes.listVersions", + "azure.ai.agents.operations.IndexesOperations.list": "Azure.AI.Projects.Indexes.listLatest", + "azure.ai.agents.aio.operations.IndexesOperations.list": "Azure.AI.Projects.Indexes.listLatest", + "azure.ai.agents.operations.IndexesOperations.get": "Azure.AI.Projects.Indexes.getVersion", + "azure.ai.agents.aio.operations.IndexesOperations.get": "Azure.AI.Projects.Indexes.getVersion", + "azure.ai.agents.operations.IndexesOperations.delete": "Azure.AI.Projects.Indexes.deleteVersion", + "azure.ai.agents.aio.operations.IndexesOperations.delete": "Azure.AI.Projects.Indexes.deleteVersion", + "azure.ai.agents.operations.IndexesOperations.create_or_update": "Azure.AI.Projects.Indexes.createOrUpdateVersion", + "azure.ai.agents.aio.operations.IndexesOperations.create_or_update": "Azure.AI.Projects.Indexes.createOrUpdateVersion", + "azure.ai.agents.AIProjectClient.delete_job": "Azure.AI.Projects.deleteJob", + "azure.ai.agents.aio.AIProjectClient.delete_job": "Azure.AI.Projects.deleteJob" + }, + "CrossLanguageVersion": "57c7f7bb54d2" } \ No newline at end of file diff --git a/sdk/ai/azure-ai-agents/azure/ai/agents/__init__.py b/sdk/ai/azure-ai-agents/azure/ai/agents/__init__.py index 1be1a824dda7..36b145c29e94 100644 --- a/sdk/ai/azure-ai-agents/azure/ai/agents/__init__.py +++ b/sdk/ai/azure-ai-agents/azure/ai/agents/__init__.py @@ -12,7 +12,8 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._client import AgentsClient # type: ignore +from ._client import AIProjectClient # type: ignore +from . import types # type: ignore from ._version import VERSION __version__ = VERSION @@ -25,7 +26,7 @@ from ._patch import patch_sdk as _patch_sdk __all__ = [ - "AgentsClient", + "AIProjectClient", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore diff --git a/sdk/ai/azure-ai-agents/azure/ai/agents/_client.py b/sdk/ai/azure-ai-agents/azure/ai/agents/_client.py index 487de2156cf1..481e5bb5812f 100644 --- a/sdk/ai/azure-ai-agents/azure/ai/agents/_client.py +++ b/sdk/ai/azure-ai-agents/azure/ai/agents/_client.py @@ -7,64 +7,76 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, TYPE_CHECKING -from typing_extensions import Self +import sys +from typing import Any, Optional, TYPE_CHECKING from azure.core import PipelineClient from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse -from ._configuration import AgentsClientConfiguration +from ._configuration import AIProjectClientConfiguration from ._utils.serialization import Deserializer, Serializer from .operations import ( - FilesOperations, - MessagesOperations, - RunStepsOperations, - RunsOperations, - ThreadsOperations, - VectorStoreFileBatchesOperations, - VectorStoreFilesOperations, - VectorStoresOperations, - _AgentsClientOperationsMixin, + AgentsOperations, + BetaOperations, + ConnectionsOperations, + DatasetsOperations, + DeploymentsOperations, + EvaluationRulesOperations, + IndexesOperations, + _AIProjectClientOperationsMixin, ) +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self # type: ignore + if TYPE_CHECKING: from azure.core.credentials import TokenCredential -class AgentsClient(_AgentsClientOperationsMixin): # pylint: disable=too-many-instance-attributes - """AgentsClient. - - :ivar threads: ThreadsOperations operations - :vartype threads: azure.ai.agents.operations.ThreadsOperations - :ivar messages: MessagesOperations operations - :vartype messages: azure.ai.agents.operations.MessagesOperations - :ivar runs: RunsOperations operations - :vartype runs: azure.ai.agents.operations.RunsOperations - :ivar run_steps: RunStepsOperations operations - :vartype run_steps: azure.ai.agents.operations.RunStepsOperations - :ivar files: FilesOperations operations - :vartype files: azure.ai.agents.operations.FilesOperations - :ivar vector_stores: VectorStoresOperations operations - :vartype vector_stores: azure.ai.agents.operations.VectorStoresOperations - :ivar vector_store_files: VectorStoreFilesOperations operations - :vartype vector_store_files: azure.ai.agents.operations.VectorStoreFilesOperations - :ivar vector_store_file_batches: VectorStoreFileBatchesOperations operations - :vartype vector_store_file_batches: azure.ai.agents.operations.VectorStoreFileBatchesOperations - :param endpoint: Project endpoint in the form of: - https://.services.ai.azure.com/api/projects/. Required. +class AIProjectClient(_AIProjectClientOperationsMixin): # pylint: disable=too-many-instance-attributes + """AIProjectClient. + + :ivar beta: BetaOperations operations + :vartype beta: azure.ai.agents.operations.BetaOperations + :ivar agents: AgentsOperations operations + :vartype agents: azure.ai.agents.operations.AgentsOperations + :ivar evaluation_rules: EvaluationRulesOperations operations + :vartype evaluation_rules: azure.ai.agents.operations.EvaluationRulesOperations + :ivar connections: ConnectionsOperations operations + :vartype connections: azure.ai.agents.operations.ConnectionsOperations + :ivar datasets: DatasetsOperations operations + :vartype datasets: azure.ai.agents.operations.DatasetsOperations + :ivar deployments: DeploymentsOperations operations + :vartype deployments: azure.ai.agents.operations.DeploymentsOperations + :ivar indexes: IndexesOperations operations + :vartype indexes: azure.ai.agents.operations.IndexesOperations + :param endpoint: Foundry Project endpoint in the form + "https://{ai-services-account-name}.services.ai.azure.com/api/projects/{project-name}". If you + only have one Project in your Foundry Hub, or to target the default Project in your Hub, use + the form "https://{ai-services-account-name}.services.ai.azure.com/api/projects/_project". + Required. :type endpoint: str :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials.TokenCredential - :keyword api_version: The API version to use for this operation. Default value is - "2025-05-15-preview". Note that overriding this default value may result in unsupported - behavior. + :param allow_preview: Whether to enable preview features. Must be specified and set to True to + enable preview features. Default value is None. + :type allow_preview: bool + :keyword api_version: The API version to use for this operation. Known values are "v1" and + None. Default value is None. If not set, the operation's default API version will be used. Note + that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None: + def __init__( + self, endpoint: str, credential: "TokenCredential", allow_preview: Optional[bool] = None, **kwargs: Any + ) -> None: _endpoint = "{endpoint}" - self._config = AgentsClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) + self._config = AIProjectClientConfiguration( + endpoint=endpoint, credential=credential, allow_preview=allow_preview, **kwargs + ) _policies = kwargs.pop("policies", None) if _policies is None: @@ -88,18 +100,15 @@ def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) self._serialize = Serializer() self._deserialize = Deserializer() self._serialize.client_side_validation = False - self.threads = ThreadsOperations(self._client, self._config, self._serialize, self._deserialize) - self.messages = MessagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.runs = RunsOperations(self._client, self._config, self._serialize, self._deserialize) - self.run_steps = RunStepsOperations(self._client, self._config, self._serialize, self._deserialize) - self.files = FilesOperations(self._client, self._config, self._serialize, self._deserialize) - self.vector_stores = VectorStoresOperations(self._client, self._config, self._serialize, self._deserialize) - self.vector_store_files = VectorStoreFilesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.vector_store_file_batches = VectorStoreFileBatchesOperations( + self.beta = BetaOperations(self._client, self._config, self._serialize, self._deserialize) + self.agents = AgentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.evaluation_rules = EvaluationRulesOperations( self._client, self._config, self._serialize, self._deserialize ) + self.connections = ConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.datasets = DatasetsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.indexes = IndexesOperations(self._client, self._config, self._serialize, self._deserialize) def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/ai/azure-ai-agents/azure/ai/agents/_configuration.py b/sdk/ai/azure-ai-agents/azure/ai/agents/_configuration.py index 2df2bf2aeb78..7f07e99af21f 100644 --- a/sdk/ai/azure-ai-agents/azure/ai/agents/_configuration.py +++ b/sdk/ai/azure-ai-agents/azure/ai/agents/_configuration.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, TYPE_CHECKING +from typing import Any, Optional, TYPE_CHECKING from azure.core.pipeline import policies @@ -16,25 +16,33 @@ from azure.core.credentials import TokenCredential -class AgentsClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for AgentsClient. +class AIProjectClientConfiguration: # pylint: disable=too-many-instance-attributes + """Configuration for AIProjectClient. Note that all parameters used to create this instance are saved as instance attributes. - :param endpoint: Project endpoint in the form of: - https://.services.ai.azure.com/api/projects/. Required. + :param endpoint: Foundry Project endpoint in the form + "https://{ai-services-account-name}.services.ai.azure.com/api/projects/{project-name}". If you + only have one Project in your Foundry Hub, or to target the default Project in your Hub, use + the form "https://{ai-services-account-name}.services.ai.azure.com/api/projects/_project". + Required. :type endpoint: str :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials.TokenCredential - :keyword api_version: The API version to use for this operation. Default value is - "2025-05-15-preview". Note that overriding this default value may result in unsupported - behavior. + :param allow_preview: Whether to enable preview features. Must be specified and set to True to + enable preview features. Default value is None. + :type allow_preview: bool + :keyword api_version: The API version to use for this operation. Known values are "v1" and + None. Default value is None. If not set, the operation's default API version will be used. Note + that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2025-05-15-preview") + def __init__( + self, endpoint: str, credential: "TokenCredential", allow_preview: Optional[bool] = None, **kwargs: Any + ) -> None: + api_version: str = kwargs.pop("api_version", "v1") if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") @@ -43,6 +51,7 @@ def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) self.endpoint = endpoint self.credential = credential + self.allow_preview = allow_preview self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://ai.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "ai-agents/{}".format(VERSION)) diff --git a/sdk/ai/azure-ai-agents/azure/ai/agents/_unions.py b/sdk/ai/azure-ai-agents/azure/ai/agents/_unions.py new file mode 100644 index 000000000000..c43e76df7511 --- /dev/null +++ b/sdk/ai/azure-ai-agents/azure/ai/agents/_unions.py @@ -0,0 +1,13 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import TYPE_CHECKING, Union + +if TYPE_CHECKING: + from ..projects import types as _types_projects_models2 +Filters = Union["_types_projects_models2.ComparisonFilter", "_types_projects_models2.CompoundFilter"] diff --git a/sdk/ai/azure-ai-agents/azure/ai/agents/_utils/model_base.py b/sdk/ai/azure-ai-agents/azure/ai/agents/_utils/model_base.py index 7ec44978519b..4acca0207287 100644 --- a/sdk/ai/azure-ai-agents/azure/ai/agents/_utils/model_base.py +++ b/sdk/ai/azure-ai-agents/azure/ai/agents/_utils/model_base.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -816,16 +817,22 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-retur # is it optional? try: - if any(a for a in annotation.__args__ if a == type(None)): # pyright: ignore # pylint: disable=unidiomatic-typecheck + if any( + a for a in annotation.__args__ if a == type(None) + ): # pyright: ignore # pylint: disable=unidiomatic-typecheck if len(annotation.__args__) <= 2: # pyright: ignore if_obj_deserializer = _get_deserialize_callable_from_annotation( - next(a for a in annotation.__args__ if a != type(None)), module, rf # pyright: ignore # pylint: disable=unidiomatic-typecheck + next(a for a in annotation.__args__ if a != type(None)), + module, + rf, # pyright: ignore # pylint: disable=unidiomatic-typecheck ) return functools.partial(_deserialize_with_optional, if_obj_deserializer) # the type is Optional[Union[...]], we need to remove the None type from the Union annotation_copy = copy.copy(annotation) - annotation_copy.__args__ = [a for a in annotation_copy.__args__ if a != type(None)] # pyright: ignore # pylint: disable=unidiomatic-typecheck + annotation_copy.__args__ = [ + a for a in annotation_copy.__args__ if a != type(None) + ] # pyright: ignore # pylint: disable=unidiomatic-typecheck return _get_deserialize_callable_from_annotation(annotation_copy, module, rf) except AttributeError: pass diff --git a/sdk/ai/azure-ai-agents/azure/ai/agents/_utils/serialization.py b/sdk/ai/azure-ai-agents/azure/ai/agents/_utils/serialization.py index 45a3e44e45cb..a088671e9c51 100644 --- a/sdk/ai/azure-ai-agents/azure/ai/agents/_utils/serialization.py +++ b/sdk/ai/azure-ai-agents/azure/ai/agents/_utils/serialization.py @@ -39,11 +39,15 @@ import xml.etree.ElementTree as ET import isodate # type: ignore -from typing_extensions import Self from azure.core.exceptions import DeserializationError, SerializationError from azure.core.serialization import NULL as CoreNull +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self + _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") JSON = MutableMapping[str, Any] @@ -821,13 +825,20 @@ def serialize_basic(cls, data, data_type, **kwargs): :param str data_type: Type of object in the iterable. :rtype: str, int, float, bool :return: serialized object + :raises TypeError: raise if data_type is not one of str, int, float, bool. """ custom_serializer = cls._get_custom_serializers(data_type, **kwargs) if custom_serializer: return custom_serializer(data) if data_type == "str": return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec # pylint: disable=eval-used + if data_type == "int": + return int(data) + if data_type == "float": + return float(data) + if data_type == "bool": + return bool(data) + raise TypeError("Unknown basic data type: {}".format(data_type)) @classmethod def serialize_unicode(cls, data): @@ -1394,7 +1405,7 @@ def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: # Otherwise, result are unexpected self.additional_properties_detection = True - def __call__(self, target_obj, response_data, content_type=None): + def __call__(self, target_obj, response_data, content_type=None): # pylint: disable=too-many-return-statements """Call the deserializer to process a REST response. :param str target_obj: Target data type to deserialize to. @@ -1404,6 +1415,27 @@ def __call__(self, target_obj, response_data, content_type=None): :return: Deserialized object. :rtype: object """ + # Fast path for header deserialization: response_data is a plain str or None + # and target_obj is a simple scalar type. This avoids the expensive + # _unpack_content → _deserialize → _classify_target → deserialize_data chain. + if response_data is None: + return None + if target_obj == "str" and isinstance(response_data, str): + return response_data + if isinstance(response_data, str): + if target_obj == "int": + return int(response_data) + if target_obj == "bool": + if response_data in ("true", "1", "True"): + return True + if response_data in ("false", "0", "False"): + return False + return bool(response_data) + if target_obj == "rfc-1123": + return Deserializer.deserialize_rfc(response_data) + if target_obj == "bytearray": + return Deserializer.deserialize_bytearray(response_data) + data = self._unpack_content(response_data, content_type) return self._deserialize(target_obj, data) @@ -1757,7 +1789,7 @@ def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return :param str data_type: deserialization data type. :return: Deserialized basic type. :rtype: str, int, float or bool - :raises TypeError: if string format is not valid. + :raises TypeError: if string format is not valid or data_type is not one of str, int, float, bool. """ # If we're here, data is supposed to be a basic type. # If it's still an XML node, take the text @@ -1783,7 +1815,11 @@ def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return if data_type == "str": return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec # pylint: disable=eval-used + if data_type == "int": + return int(attr) + if data_type == "float": + return float(attr) + raise TypeError("Unknown basic data type: {}".format(data_type)) @staticmethod def deserialize_unicode(data): diff --git a/sdk/ai/azure-ai-agents/azure/ai/agents/_utils/utils.py b/sdk/ai/azure-ai-agents/azure/ai/agents/_utils/utils.py index 4c029bd3dfa5..35c9c836f85f 100644 --- a/sdk/ai/azure-ai-agents/azure/ai/agents/_utils/utils.py +++ b/sdk/ai/azure-ai-agents/azure/ai/agents/_utils/utils.py @@ -6,10 +6,7 @@ # -------------------------------------------------------------------------- from abc import ABC -import json -from typing import Any, Generic, IO, Mapping, Optional, TYPE_CHECKING, TypeVar, Union - -from .._utils.model_base import Model, SdkJSONEncoder +from typing import Generic, TYPE_CHECKING, TypeVar if TYPE_CHECKING: from .serialization import Deserializer, Serializer @@ -26,42 +23,3 @@ class ClientMixinABC(ABC, Generic[TClient, TConfig]): _config: TConfig _serialize: "Serializer" _deserialize: "Deserializer" - - -# file-like tuple could be `(filename, IO (or bytes))` or `(filename, IO (or bytes), content_type)` -FileContent = Union[str, bytes, IO[str], IO[bytes]] - -FileType = Union[ - # file (or bytes) - FileContent, - # (filename, file (or bytes)) - tuple[Optional[str], FileContent], - # (filename, file (or bytes), content_type) - tuple[Optional[str], FileContent, Optional[str]], -] - - -def serialize_multipart_data_entry(data_entry: Any) -> Any: - if isinstance(data_entry, (list, tuple, dict, Model)): - return json.dumps(data_entry, cls=SdkJSONEncoder, exclude_readonly=True) - return data_entry - - -def prepare_multipart_form_data( - body: Mapping[str, Any], multipart_fields: list[str], data_fields: list[str] -) -> tuple[list[FileType], dict[str, Any]]: - files: list[FileType] = [] - data: dict[str, Any] = {} - for multipart_field in multipart_fields: - multipart_entry = body.get(multipart_field) - if isinstance(multipart_entry, list): - files.extend([(multipart_field, e) for e in multipart_entry]) - elif multipart_entry: - files.append((multipart_field, multipart_entry)) - - for data_field in data_fields: - data_entry = body.get(data_field) - if data_entry: - data[data_field] = serialize_multipart_data_entry(data_entry) - - return files, data diff --git a/sdk/ai/azure-ai-agents/azure/ai/agents/aio/__init__.py b/sdk/ai/azure-ai-agents/azure/ai/agents/aio/__init__.py index 65a7176b2fbb..d138e250b1bc 100644 --- a/sdk/ai/azure-ai-agents/azure/ai/agents/aio/__init__.py +++ b/sdk/ai/azure-ai-agents/azure/ai/agents/aio/__init__.py @@ -12,7 +12,8 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._client import AgentsClient # type: ignore +from ._client import AIProjectClient # type: ignore +from . import types # type: ignore try: from ._patch import __all__ as _patch_all @@ -22,7 +23,7 @@ from ._patch import patch_sdk as _patch_sdk __all__ = [ - "AgentsClient", + "AIProjectClient", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore diff --git a/sdk/ai/azure-ai-agents/azure/ai/agents/aio/_client.py b/sdk/ai/azure-ai-agents/azure/ai/agents/aio/_client.py index 64180964eb5b..4b39c6e3c110 100644 --- a/sdk/ai/azure-ai-agents/azure/ai/agents/aio/_client.py +++ b/sdk/ai/azure-ai-agents/azure/ai/agents/aio/_client.py @@ -7,65 +7,76 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING -from typing_extensions import Self +import sys +from typing import Any, Awaitable, Optional, TYPE_CHECKING from azure.core import AsyncPipelineClient from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from .._utils.serialization import Deserializer, Serializer -from ._configuration import AgentsClientConfiguration +from ._configuration import AIProjectClientConfiguration from .operations import ( - FilesOperations, - MessagesOperations, - RunStepsOperations, - RunsOperations, - ThreadsOperations, - VectorStoreFileBatchesOperations, - VectorStoreFilesOperations, - VectorStoresOperations, - _AgentsClientOperationsMixin, + AgentsOperations, + BetaOperations, + ConnectionsOperations, + DatasetsOperations, + DeploymentsOperations, + EvaluationRulesOperations, + IndexesOperations, + _AIProjectClientOperationsMixin, ) +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self # type: ignore + if TYPE_CHECKING: from azure.core.credentials_async import AsyncTokenCredential -class AgentsClient(_AgentsClientOperationsMixin): # pylint: disable=too-many-instance-attributes - """AgentsClient. - - :ivar threads: ThreadsOperations operations - :vartype threads: azure.ai.agents.aio.operations.ThreadsOperations - :ivar messages: MessagesOperations operations - :vartype messages: azure.ai.agents.aio.operations.MessagesOperations - :ivar runs: RunsOperations operations - :vartype runs: azure.ai.agents.aio.operations.RunsOperations - :ivar run_steps: RunStepsOperations operations - :vartype run_steps: azure.ai.agents.aio.operations.RunStepsOperations - :ivar files: FilesOperations operations - :vartype files: azure.ai.agents.aio.operations.FilesOperations - :ivar vector_stores: VectorStoresOperations operations - :vartype vector_stores: azure.ai.agents.aio.operations.VectorStoresOperations - :ivar vector_store_files: VectorStoreFilesOperations operations - :vartype vector_store_files: azure.ai.agents.aio.operations.VectorStoreFilesOperations - :ivar vector_store_file_batches: VectorStoreFileBatchesOperations operations - :vartype vector_store_file_batches: - azure.ai.agents.aio.operations.VectorStoreFileBatchesOperations - :param endpoint: Project endpoint in the form of: - https://.services.ai.azure.com/api/projects/. Required. +class AIProjectClient(_AIProjectClientOperationsMixin): # pylint: disable=too-many-instance-attributes + """AIProjectClient. + + :ivar beta: BetaOperations operations + :vartype beta: azure.ai.agents.aio.operations.BetaOperations + :ivar agents: AgentsOperations operations + :vartype agents: azure.ai.agents.aio.operations.AgentsOperations + :ivar evaluation_rules: EvaluationRulesOperations operations + :vartype evaluation_rules: azure.ai.agents.aio.operations.EvaluationRulesOperations + :ivar connections: ConnectionsOperations operations + :vartype connections: azure.ai.agents.aio.operations.ConnectionsOperations + :ivar datasets: DatasetsOperations operations + :vartype datasets: azure.ai.agents.aio.operations.DatasetsOperations + :ivar deployments: DeploymentsOperations operations + :vartype deployments: azure.ai.agents.aio.operations.DeploymentsOperations + :ivar indexes: IndexesOperations operations + :vartype indexes: azure.ai.agents.aio.operations.IndexesOperations + :param endpoint: Foundry Project endpoint in the form + "https://{ai-services-account-name}.services.ai.azure.com/api/projects/{project-name}". If you + only have one Project in your Foundry Hub, or to target the default Project in your Hub, use + the form "https://{ai-services-account-name}.services.ai.azure.com/api/projects/_project". + Required. :type endpoint: str :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: The API version to use for this operation. Default value is - "2025-05-15-preview". Note that overriding this default value may result in unsupported - behavior. + :param allow_preview: Whether to enable preview features. Must be specified and set to True to + enable preview features. Default value is None. + :type allow_preview: bool + :keyword api_version: The API version to use for this operation. Known values are "v1" and + None. Default value is None. If not set, the operation's default API version will be used. Note + that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__(self, endpoint: str, credential: "AsyncTokenCredential", **kwargs: Any) -> None: + def __init__( + self, endpoint: str, credential: "AsyncTokenCredential", allow_preview: Optional[bool] = None, **kwargs: Any + ) -> None: _endpoint = "{endpoint}" - self._config = AgentsClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) + self._config = AIProjectClientConfiguration( + endpoint=endpoint, credential=credential, allow_preview=allow_preview, **kwargs + ) _policies = kwargs.pop("policies", None) if _policies is None: @@ -89,18 +100,15 @@ def __init__(self, endpoint: str, credential: "AsyncTokenCredential", **kwargs: self._serialize = Serializer() self._deserialize = Deserializer() self._serialize.client_side_validation = False - self.threads = ThreadsOperations(self._client, self._config, self._serialize, self._deserialize) - self.messages = MessagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.runs = RunsOperations(self._client, self._config, self._serialize, self._deserialize) - self.run_steps = RunStepsOperations(self._client, self._config, self._serialize, self._deserialize) - self.files = FilesOperations(self._client, self._config, self._serialize, self._deserialize) - self.vector_stores = VectorStoresOperations(self._client, self._config, self._serialize, self._deserialize) - self.vector_store_files = VectorStoreFilesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.vector_store_file_batches = VectorStoreFileBatchesOperations( + self.beta = BetaOperations(self._client, self._config, self._serialize, self._deserialize) + self.agents = AgentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.evaluation_rules = EvaluationRulesOperations( self._client, self._config, self._serialize, self._deserialize ) + self.connections = ConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.datasets = DatasetsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.indexes = IndexesOperations(self._client, self._config, self._serialize, self._deserialize) def send_request( self, request: HttpRequest, *, stream: bool = False, **kwargs: Any diff --git a/sdk/ai/azure-ai-agents/azure/ai/agents/aio/_configuration.py b/sdk/ai/azure-ai-agents/azure/ai/agents/aio/_configuration.py index fe400db8ca67..efb1b7ba634d 100644 --- a/sdk/ai/azure-ai-agents/azure/ai/agents/aio/_configuration.py +++ b/sdk/ai/azure-ai-agents/azure/ai/agents/aio/_configuration.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, TYPE_CHECKING +from typing import Any, Optional, TYPE_CHECKING from azure.core.pipeline import policies @@ -16,25 +16,33 @@ from azure.core.credentials_async import AsyncTokenCredential -class AgentsClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for AgentsClient. +class AIProjectClientConfiguration: # pylint: disable=too-many-instance-attributes + """Configuration for AIProjectClient. Note that all parameters used to create this instance are saved as instance attributes. - :param endpoint: Project endpoint in the form of: - https://.services.ai.azure.com/api/projects/. Required. + :param endpoint: Foundry Project endpoint in the form + "https://{ai-services-account-name}.services.ai.azure.com/api/projects/{project-name}". If you + only have one Project in your Foundry Hub, or to target the default Project in your Hub, use + the form "https://{ai-services-account-name}.services.ai.azure.com/api/projects/_project". + Required. :type endpoint: str :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: The API version to use for this operation. Default value is - "2025-05-15-preview". Note that overriding this default value may result in unsupported - behavior. + :param allow_preview: Whether to enable preview features. Must be specified and set to True to + enable preview features. Default value is None. + :type allow_preview: bool + :keyword api_version: The API version to use for this operation. Known values are "v1" and + None. Default value is None. If not set, the operation's default API version will be used. Note + that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__(self, endpoint: str, credential: "AsyncTokenCredential", **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2025-05-15-preview") + def __init__( + self, endpoint: str, credential: "AsyncTokenCredential", allow_preview: Optional[bool] = None, **kwargs: Any + ) -> None: + api_version: str = kwargs.pop("api_version", "v1") if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") @@ -43,6 +51,7 @@ def __init__(self, endpoint: str, credential: "AsyncTokenCredential", **kwargs: self.endpoint = endpoint self.credential = credential + self.allow_preview = allow_preview self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://ai.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "ai-agents/{}".format(VERSION)) diff --git a/sdk/ai/azure-ai-agents/azure/ai/agents/aio/operations/__init__.py b/sdk/ai/azure-ai-agents/azure/ai/agents/aio/operations/__init__.py index a3f2341966aa..ac09c02d32cd 100644 --- a/sdk/ai/azure-ai-agents/azure/ai/agents/aio/operations/__init__.py +++ b/sdk/ai/azure-ai-agents/azure/ai/agents/aio/operations/__init__.py @@ -12,29 +12,27 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._operations import ThreadsOperations # type: ignore -from ._operations import MessagesOperations # type: ignore -from ._operations import RunsOperations # type: ignore -from ._operations import RunStepsOperations # type: ignore -from ._operations import FilesOperations # type: ignore -from ._operations import VectorStoresOperations # type: ignore -from ._operations import VectorStoreFilesOperations # type: ignore -from ._operations import VectorStoreFileBatchesOperations # type: ignore -from ._operations import _AgentsClientOperationsMixin # type: ignore # pylint: disable=unused-import +from ._operations import BetaOperations # type: ignore +from ._operations import AgentsOperations # type: ignore +from ._operations import EvaluationRulesOperations # type: ignore +from ._operations import ConnectionsOperations # type: ignore +from ._operations import DatasetsOperations # type: ignore +from ._operations import DeploymentsOperations # type: ignore +from ._operations import IndexesOperations # type: ignore +from ._operations import _AIProjectClientOperationsMixin # type: ignore # pylint: disable=unused-import from ._patch import __all__ as _patch_all from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ - "ThreadsOperations", - "MessagesOperations", - "RunsOperations", - "RunStepsOperations", - "FilesOperations", - "VectorStoresOperations", - "VectorStoreFilesOperations", - "VectorStoreFileBatchesOperations", + "BetaOperations", + "AgentsOperations", + "EvaluationRulesOperations", + "ConnectionsOperations", + "DatasetsOperations", + "DeploymentsOperations", + "IndexesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/ai/azure-ai-agents/azure/ai/agents/aio/operations/_operations.py b/sdk/ai/azure-ai-agents/azure/ai/agents/aio/operations/_operations.py index 8151b09585e2..8d7b168ab914 100644 --- a/sdk/ai/azure-ai-agents/azure/ai/agents/aio/operations/_operations.py +++ b/sdk/ai/azure-ai-agents/azure/ai/agents/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,8 +8,7 @@ # -------------------------------------------------------------------------- from collections.abc import MutableMapping from io import IOBase -import json -from typing import Any, AsyncIterator, Callable, IO, Optional, TYPE_CHECKING, TypeVar, Union, overload +from typing import Any, AsyncIterator, Callable, IO, Literal, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core import AsyncPipelineClient @@ -24,183 +24,251 @@ map_error, ) from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.polling.async_base_polling import AsyncLROBasePolling from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict -from ... import models as _models -from ..._utils.model_base import Model as _Model, SdkJSONEncoder, _deserialize, _failsafe_deserialize +from ... import types, types as _types_models2 from ..._utils.serialization import Deserializer, Serializer -from ..._utils.utils import ClientMixinABC, prepare_multipart_form_data -from ..._validation import api_version_validation +from ..._utils.utils import ClientMixinABC +from ...models._enums import FoundryFeaturesOptInKeys from ...operations._operations import ( + build_agents_create_agent_from_manifest_request, build_agents_create_agent_request, - build_agents_create_thread_and_run_request, - build_agents_delete_agent_request, - build_agents_get_agent_request, - build_agents_list_agents_request, + build_agents_create_version_from_manifest_request, + build_agents_create_version_request, + build_agents_delete_request, + build_agents_delete_version_request, + build_agents_get_request, + build_agents_get_version_request, + build_agents_list_request, + build_agents_list_versions_request, + build_agents_update_agent_from_manifest_request, build_agents_update_agent_request, - build_files_delete_file_request, - build_files_get_file_content_request, - build_files_get_request, - build_files_list_request, - build_files_upload_file_request, - build_messages_create_request, - build_messages_delete_request, - build_messages_get_request, - build_messages_list_request, - build_messages_update_request, - build_run_steps_get_request, - build_run_steps_list_request, - build_runs_cancel_request, - build_runs_create_request, - build_runs_get_request, - build_runs_list_request, - build_runs_submit_tool_outputs_request, - build_runs_update_request, - build_threads_create_request, - build_threads_delete_thread_request, - build_threads_get_request, - build_threads_list_request, - build_threads_update_request, - build_vector_store_file_batches_cancel_request, - build_vector_store_file_batches_create_request, - build_vector_store_file_batches_get_request, - build_vector_store_file_batches_list_files_request, - build_vector_store_files_create_request, - build_vector_store_files_delete_vector_store_file_request, - build_vector_store_files_get_request, - build_vector_store_files_list_request, - build_vector_stores_create_request, - build_vector_stores_delete_vector_store_request, - build_vector_stores_get_request, - build_vector_stores_list_request, - build_vector_stores_modify_request, + build_ai_project_delete_job_request, + build_beta_evaluation_taxonomies_create_request, + build_beta_evaluation_taxonomies_delete_request, + build_beta_evaluation_taxonomies_get_request, + build_beta_evaluation_taxonomies_list_request, + build_beta_evaluation_taxonomies_update_request, + build_beta_evaluators_create_version_request, + build_beta_evaluators_delete_version_request, + build_beta_evaluators_get_version_request, + build_beta_evaluators_list_request, + build_beta_evaluators_list_versions_request, + build_beta_evaluators_update_version_request, + build_beta_insights_generate_request, + build_beta_insights_get_request, + build_beta_insights_list_request, + build_beta_memory_stores_create_request, + build_beta_memory_stores_delete_request, + build_beta_memory_stores_delete_scope_request, + build_beta_memory_stores_get_request, + build_beta_memory_stores_list_request, + build_beta_memory_stores_search_memories_request, + build_beta_memory_stores_update_memories_request, + build_beta_memory_stores_update_request, + build_beta_red_teams_create_request, + build_beta_red_teams_get_request, + build_beta_red_teams_list_request, + build_beta_schedules_create_or_update_request, + build_beta_schedules_delete_request, + build_beta_schedules_get_request, + build_beta_schedules_get_run_request, + build_beta_schedules_list_request, + build_beta_schedules_list_runs_request, + build_connections_get_request, + build_connections_get_with_credentials_request, + build_connections_list_request, + build_datasets_create_or_update_request, + build_datasets_delete_request, + build_datasets_get_credentials_request, + build_datasets_get_request, + build_datasets_list_request, + build_datasets_list_versions_request, + build_datasets_pending_upload_request, + build_deployments_get_request, + build_deployments_list_request, + build_evaluation_rules_create_or_update_request, + build_evaluation_rules_delete_request, + build_evaluation_rules_get_request, + build_evaluation_rules_list_request, + build_indexes_create_or_update_request, + build_indexes_delete_request, + build_indexes_get_request, + build_indexes_list_request, + build_indexes_list_versions_request, ) -from .._configuration import AgentsClientConfiguration +from .._configuration import AIProjectClientConfiguration -if TYPE_CHECKING: - from ... import _types -JSON = MutableMapping[str, Any] _Unset: Any = object() +JSON = MutableMapping[str, Any] T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] List = list -class ThreadsOperations: +class BetaOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.ai.agents.aio.AgentsClient`'s - :attr:`threads` attribute. + :class:`~azure.ai.agents.aio.AIProjectClient`'s + :attr:`beta` attribute. """ def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AgentsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @overload - async def create( - self, - *, - content_type: str = "application/json", - messages: Optional[List[_models.ThreadMessageOptions]] = None, - tool_resources: Optional[_models.ToolResources] = None, - metadata: Optional[dict[str, str]] = None, - **kwargs: Any - ) -> _models.AgentThread: - """Creates a new thread. Threads contain messages and can be run by agents. - - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword messages: The initial messages to associate with the new thread. Default value is - None. - :paramtype messages: list[~azure.ai.agents.models.ThreadMessageOptions] - :keyword tool_resources: 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. Default value is None. - :paramtype tool_resources: ~azure.ai.agents.models.ToolResources - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: AgentThread. The AgentThread is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.AgentThread - :raises ~azure.core.exceptions.HttpResponseError: - """ + self.evaluation_taxonomies = BetaEvaluationTaxonomiesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.evaluators = BetaEvaluatorsOperations(self._client, self._config, self._serialize, self._deserialize) + self.insights = BetaInsightsOperations(self._client, self._config, self._serialize, self._deserialize) + self.memory_stores = BetaMemoryStoresOperations(self._client, self._config, self._serialize, self._deserialize) + self.red_teams = BetaRedTeamsOperations(self._client, self._config, self._serialize, self._deserialize) + self.schedules = BetaSchedulesOperations(self._client, self._config, self._serialize, self._deserialize) - @overload - async def create(self, body: JSON, *, content_type: str = "application/json", **kwargs: Any) -> _models.AgentThread: - """Creates a new thread. Threads contain messages and can be run by agents. - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AgentThread. The AgentThread is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.AgentThread - :raises ~azure.core.exceptions.HttpResponseError: - """ +class AgentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - @overload - async def create( - self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AgentThread: - """Creates a new thread. Threads contain messages and can be run by agents. + Instead, you should access the following operations through + :class:`~azure.ai.agents.aio.AIProjectClient`'s + :attr:`agents` attribute. + """ - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: AgentThread. The AgentThread is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.AgentThread - :raises ~azure.core.exceptions.HttpResponseError: - """ + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def create( - self, - body: Union[JSON, IO[bytes]] = _Unset, - *, - messages: Optional[List[_models.ThreadMessageOptions]] = None, - tool_resources: Optional[_models.ToolResources] = None, - metadata: Optional[dict[str, str]] = None, - **kwargs: Any - ) -> _models.AgentThread: - """Creates a new thread. Threads contain messages and can be run by agents. + async def get(self, agent_name: str, **kwargs: Any) -> _types_models2.AgentDetails: + """Retrieves the agent. - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword messages: The initial messages to associate with the new thread. Default value is - None. - :paramtype messages: list[~azure.ai.agents.models.ThreadMessageOptions] - :keyword tool_resources: 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. Default value is None. - :paramtype tool_resources: ~azure.ai.agents.models.ToolResources - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: AgentThread. The AgentThread is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.AgentThread + :param agent_name: The name of the agent to retrieve. Required. + :type agent_name: str + :return: AgentDetails + :rtype: ~azure.ai.agents.types.AgentDetails :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "hosted": + agent_definition = { + "container_protocol_versions": [ + { + "protocol": "str", + "version": "str" + } + ], + "cpu": "str", + "kind": "hosted", + "memory": "str", + "environment_variables": { + "str": "str" + }, + "image": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "tools": [ + tool + ] + } + + # JSON input template for discriminator value "prompt": + agent_definition = { + "kind": "prompt", + "model": "str", + "instructions": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "structured_inputs": { + "str": { + "default_value": {}, + "description": "str", + "required": bool, + "schema": { + "str": {} + } + } + }, + "temperature": 0.0, + "text": { + "format": text_response_format + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_p": 0.0 + } + + # JSON input template for discriminator value "json_object": + text_response_format = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format = { + "name": "str", + "schema": { + "str": {} + }, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "id": "str", + "name": "str", + "object": "str", + "versions": { + "latest": { + "created_at": "2020-02-20 00:00:00", + "definition": agent_definition, + "id": "str", + "metadata": { + "str": "str" + }, + "name": "str", + "object": "str", + "version": "str", + "description": "str" + } + } + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -210,26 +278,14 @@ async def create( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AgentThread] = kwargs.pop("cls", None) - - if body is _Unset: - body = {"messages": messages, "metadata": metadata, "tool_resources": tool_resources} - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + cls: ClsType[_types_models2.AgentDetails] = kwargs.pop("cls", None) - _request = build_threads_create_request( - content_type=content_type, + _request = build_agents_get_request( + agent_name=agent_name, api_version=self._config.api_version, - content=_content, headers=_headers, params=_params, ) @@ -238,6 +294,7 @@ async def create( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -252,109 +309,294 @@ async def create( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) + error = self._deserialize.failsafe_deserialize( + _types_models2.ApiErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.AgentThread, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def list( + @overload + async def _create_agent( self, + name: str, + definition: _types_models2.AgentDefinition, + metadata: Optional[dict[str, str]] = None, + description: Optional[str] = None, *, - limit: Optional[int] = None, - order: Optional[Union[str, _models.ListSortOrder]] = None, - before: Optional[str] = None, + foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncItemPaged["_models.AgentThread"]: - """Gets a list of threads that were previously created. - - :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and - 100, and the default is 20. Default value is None. - :paramtype limit: int - :keyword order: Sort order by the created_at timestamp of the objects. asc for ascending order - and desc for descending order. Known values are: "asc" and "desc". Default value is None. - :paramtype order: str or ~azure.ai.agents.models.ListSortOrder - :keyword 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. Default value is None. - :paramtype before: str - :return: An iterator like instance of AgentThread - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.models.AgentThread] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.AgentThread]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(_continuation_token=None): - - _request = build_threads_list_request( - limit=limit, - order=order, - after=_continuation_token, - before=before, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - return _request - - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.AgentThread], deserialized.get("data", [])) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("last_id") or None, AsyncList(list_of_elem) - - async def get_next(_continuation_token=None): - _request = prepare_request(_continuation_token) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) + ) -> _types_models2.AgentDetails: ... + @overload + async def _create_agent( + self, + body: JSON, + *, + foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models2.AgentDetails: ... + @overload + async def _create_agent( + self, + body: IO[bytes], + *, + foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models2.AgentDetails: ... @distributed_trace_async - async def get(self, thread_id: str, **kwargs: Any) -> _models.AgentThread: - """Gets information about an existing thread. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :return: AgentThread. The AgentThread is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.AgentThread + async def _create_agent( + self, + name: str = _Unset, + definition: _types_models2.AgentDefinition = _Unset, + body: Union[JSON, IO[bytes]] = _Unset, + metadata: Optional[dict[str, str]] = None, + description: Optional[str] = None, + *, + foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, + **kwargs: Any + ) -> _types_models2.AgentDetails: + """Creates the agent. + + :param name: The unique name that identifies the agent. Name can be used to + retrieve/update/delete the agent. + + * Must start and end with alphanumeric characters, + * Can contain hyphens in the middle + * Must not exceed 63 characters. Required. + :type name: str + :param definition: The agent definition. This can be a workflow, hosted agent, or a simple + agent definition. Required. + :type definition: ~azure.ai.agents.types.AgentDefinition + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :param metadata: Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. Default value is None. + :type metadata: dict[str, str] + :param description: A human-readable description of the agent. Default value is None. + :type description: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. Known values are: "HostedAgents=V1Preview" and + "WorkflowAgents=V1Preview". Default value is None. + :paramtype foundry_features: str or ~azure.ai.agents.models.AgentDefinitionOptInKeys + :return: AgentDetails + :rtype: ~azure.ai.agents.types.AgentDetails :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "kind": + + # JSON input template for discriminator value "hosted": + agent_definition = { + "container_protocol_versions": [ + { + "protocol": "str", + "version": "str" + } + ], + "cpu": "str", + "kind": "hosted", + "memory": "str", + "environment_variables": { + "str": "str" + }, + "image": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "tools": [ + tool + ] + } + + # JSON input template for discriminator value "prompt": + agent_definition = { + "kind": "prompt", + "model": "str", + "instructions": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "structured_inputs": { + "str": { + "default_value": {}, + "description": "str", + "required": bool, + "schema": { + "str": {} + } + } + }, + "temperature": 0.0, + "text": { + "format": text_response_format + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_p": 0.0 + } + + # JSON input template for discriminator value "json_object": + text_response_format = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format = { + "name": "str", + "schema": { + "str": {} + }, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format = { + "type": "text" + } + + # JSON input template you can fill out and use as your body input. + body = { + "definition": agent_definition, + "name": "str", + "description": "str", + "metadata": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "hosted": + agent_definition = { + "container_protocol_versions": [ + { + "protocol": "str", + "version": "str" + } + ], + "cpu": "str", + "kind": "hosted", + "memory": "str", + "environment_variables": { + "str": "str" + }, + "image": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "tools": [ + tool + ] + } + + # JSON input template for discriminator value "prompt": + agent_definition = { + "kind": "prompt", + "model": "str", + "instructions": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "structured_inputs": { + "str": { + "default_value": {}, + "description": "str", + "required": bool, + "schema": { + "str": {} + } + } + }, + "temperature": 0.0, + "text": { + "format": text_response_format + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_p": 0.0 + } + + # JSON input template for discriminator value "json_object": + text_response_format = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format = { + "name": "str", + "schema": { + "str": {} + }, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "id": "str", + "name": "str", + "object": "str", + "versions": { + "latest": { + "created_at": "2020-02-20 00:00:00", + "definition": agent_definition, + "id": "str", + "metadata": { + "str": "str" + }, + "name": "str", + "object": "str", + "version": "str", + "description": "str" + } + } + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -364,14 +606,33 @@ async def get(self, thread_id: str, **kwargs: Any) -> _models.AgentThread: } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.AgentThread] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_types_models2.AgentDetails] = kwargs.pop("cls", None) + + if body is _Unset: + if name is _Unset: + raise TypeError("missing required argument: name") + if definition is _Unset: + raise TypeError("missing required argument: definition") + body = {"definition": definition, "description": description, "metadata": metadata, "name": name} + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body - _request = build_threads_get_request( - thread_id=thread_id, + _request = build_agents_create_agent_request( + foundry_features=foundry_features, + content_type=content_type, api_version=self._config.api_version, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -380,6 +641,7 @@ async def get(self, thread_id: str, **kwargs: Any) -> _models.AgentThread: } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -394,13 +656,19 @@ async def get(self, thread_id: str, **kwargs: Any) -> _models.AgentThread: except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) + error = self._deserialize.failsafe_deserialize( + _types_models2.ApiErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.AgentThread, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -408,104 +676,271 @@ async def get(self, thread_id: str, **kwargs: Any) -> _models.AgentThread: return deserialized # type: ignore @overload - async def update( + async def _update_agent( self, - thread_id: str, + agent_name: str, + definition: _types_models2.AgentDefinition, + metadata: Optional[dict[str, str]] = None, + description: Optional[str] = None, *, + foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, content_type: str = "application/json", - tool_resources: Optional[_models.ToolResources] = None, - metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> _models.AgentThread: - """Modifies an existing thread. - - :param thread_id: The ID of the thread to modify. Required. - :type thread_id: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword tool_resources: 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. Default value is None. - :paramtype tool_resources: ~azure.ai.agents.models.ToolResources - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: AgentThread. The AgentThread is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.AgentThread - :raises ~azure.core.exceptions.HttpResponseError: - """ - + ) -> _types_models2.AgentDetails: ... @overload - async def update( - self, thread_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AgentThread: - """Modifies an existing thread. - - :param thread_id: The ID of the thread to modify. Required. - :type thread_id: str - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AgentThread. The AgentThread is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.AgentThread - :raises ~azure.core.exceptions.HttpResponseError: - """ - + async def _update_agent( + self, + agent_name: str, + body: JSON, + *, + foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models2.AgentDetails: ... @overload - async def update( - self, thread_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AgentThread: - """Modifies an existing thread. - - :param thread_id: The ID of the thread to modify. Required. - :type thread_id: str - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: AgentThread. The AgentThread is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.AgentThread - :raises ~azure.core.exceptions.HttpResponseError: - """ + async def _update_agent( + self, + agent_name: str, + body: IO[bytes], + *, + foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models2.AgentDetails: ... @distributed_trace_async - async def update( + async def _update_agent( self, - thread_id: str, + agent_name: str, + definition: _types_models2.AgentDefinition = _Unset, body: Union[JSON, IO[bytes]] = _Unset, - *, - tool_resources: Optional[_models.ToolResources] = None, metadata: Optional[dict[str, str]] = None, + description: Optional[str] = None, + *, + foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, **kwargs: Any - ) -> _models.AgentThread: - """Modifies an existing thread. - - :param thread_id: The ID of the thread to modify. Required. - :type thread_id: str + ) -> _types_models2.AgentDetails: + """Updates the agent by adding a new version if there are any changes to the agent definition. If + no changes, returns the existing agent version. + + :param agent_name: The name of the agent to retrieve. Required. + :type agent_name: str + :param definition: The agent definition. This can be a workflow, hosted agent, or a simple + agent definition. Required. + :type definition: ~azure.ai.agents.types.AgentDefinition :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :keyword tool_resources: 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. Default value is None. - :paramtype tool_resources: ~azure.ai.agents.models.ToolResources - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: AgentThread. The AgentThread is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.AgentThread + :param metadata: Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. Default value is None. + :type metadata: dict[str, str] + :param description: A human-readable description of the agent. Default value is None. + :type description: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. Known values are: "HostedAgents=V1Preview" and + "WorkflowAgents=V1Preview". Default value is None. + :paramtype foundry_features: str or ~azure.ai.agents.models.AgentDefinitionOptInKeys + :return: AgentDetails + :rtype: ~azure.ai.agents.types.AgentDetails :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "kind": + + # JSON input template for discriminator value "hosted": + agent_definition = { + "container_protocol_versions": [ + { + "protocol": "str", + "version": "str" + } + ], + "cpu": "str", + "kind": "hosted", + "memory": "str", + "environment_variables": { + "str": "str" + }, + "image": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "tools": [ + tool + ] + } + + # JSON input template for discriminator value "prompt": + agent_definition = { + "kind": "prompt", + "model": "str", + "instructions": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "structured_inputs": { + "str": { + "default_value": {}, + "description": "str", + "required": bool, + "schema": { + "str": {} + } + } + }, + "temperature": 0.0, + "text": { + "format": text_response_format + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_p": 0.0 + } + + # JSON input template for discriminator value "json_object": + text_response_format = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format = { + "name": "str", + "schema": { + "str": {} + }, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format = { + "type": "text" + } + + # JSON input template you can fill out and use as your body input. + body = { + "definition": agent_definition, + "description": "str", + "metadata": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "hosted": + agent_definition = { + "container_protocol_versions": [ + { + "protocol": "str", + "version": "str" + } + ], + "cpu": "str", + "kind": "hosted", + "memory": "str", + "environment_variables": { + "str": "str" + }, + "image": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "tools": [ + tool + ] + } + + # JSON input template for discriminator value "prompt": + agent_definition = { + "kind": "prompt", + "model": "str", + "instructions": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "structured_inputs": { + "str": { + "default_value": {}, + "description": "str", + "required": bool, + "schema": { + "str": {} + } + } + }, + "temperature": 0.0, + "text": { + "format": text_response_format + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_p": 0.0 + } + + # JSON input template for discriminator value "json_object": + text_response_format = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format = { + "name": "str", + "schema": { + "str": {} + }, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "id": "str", + "name": "str", + "object": "str", + "versions": { + "latest": { + "created_at": "2020-02-20 00:00:00", + "definition": agent_definition, + "id": "str", + "metadata": { + "str": "str" + }, + "name": "str", + "object": "str", + "version": "str", + "description": "str" + } + } + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -519,22 +954,27 @@ async def update( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AgentThread] = kwargs.pop("cls", None) + cls: ClsType[_types_models2.AgentDetails] = kwargs.pop("cls", None) if body is _Unset: - body = {"metadata": metadata, "tool_resources": tool_resources} + if definition is _Unset: + raise TypeError("missing required argument: definition") + body = {"definition": definition, "description": description, "metadata": metadata} body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" + _json = None _content = None if isinstance(body, (IOBase, bytes)): _content = body else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _json = body - _request = build_threads_update_request( - thread_id=thread_id, + _request = build_agents_update_agent_request( + agent_name=agent_name, + foundry_features=foundry_features, content_type=content_type, api_version=self._config.api_version, + json=_json, content=_content, headers=_headers, params=_params, @@ -544,6 +984,7 @@ async def update( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -558,28 +999,203 @@ async def update( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) + error = self._deserialize.failsafe_deserialize( + _types_models2.ApiErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.AgentThread, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace_async - async def _delete_thread(self, thread_id: str, **kwargs: Any) -> _models._models.ThreadDeletionStatus: - """Deletes an existing thread. + @overload + async def _create_agent_from_manifest( + self, + name: str, + manifest_id: str, + parameter_values: dict[str, Any], + metadata: Optional[dict[str, str]] = None, + description: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models2.AgentDetails: ... + @overload + async def _create_agent_from_manifest( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _types_models2.AgentDetails: ... + @overload + async def _create_agent_from_manifest( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _types_models2.AgentDetails: ... - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :return: ThreadDeletionStatus. The ThreadDeletionStatus is compatible with MutableMapping - :rtype: ~azure.ai.agents.models._models.ThreadDeletionStatus + @distributed_trace_async + async def _create_agent_from_manifest( + self, + name: str = _Unset, + manifest_id: str = _Unset, + parameter_values: dict[str, Any] = _Unset, + body: Union[JSON, IO[bytes]] = _Unset, + metadata: Optional[dict[str, str]] = None, + description: Optional[str] = None, + **kwargs: Any + ) -> _types_models2.AgentDetails: + """Creates an agent from a manifest. + + :param name: The unique name that identifies the agent. Name can be used to + retrieve/update/delete the agent. + + * Must start and end with alphanumeric characters, + * Can contain hyphens in the middle + * Must not exceed 63 characters. Required. + :type name: str + :param manifest_id: The manifest ID to import the agent version from. Required. + :type manifest_id: str + :param parameter_values: The inputs to the manifest that will result in a fully materialized + Agent. Required. + :type parameter_values: dict[str, any] + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :param metadata: Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. Default value is None. + :type metadata: dict[str, str] + :param description: A human-readable description of the agent. Default value is None. + :type description: str + :return: AgentDetails + :rtype: ~azure.ai.agents.types.AgentDetails :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "manifest_id": "str", + "name": "str", + "parameter_values": { + "str": {} + }, + "description": "str", + "metadata": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "hosted": + agent_definition = { + "container_protocol_versions": [ + { + "protocol": "str", + "version": "str" + } + ], + "cpu": "str", + "kind": "hosted", + "memory": "str", + "environment_variables": { + "str": "str" + }, + "image": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "tools": [ + tool + ] + } + + # JSON input template for discriminator value "prompt": + agent_definition = { + "kind": "prompt", + "model": "str", + "instructions": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "structured_inputs": { + "str": { + "default_value": {}, + "description": "str", + "required": bool, + "schema": { + "str": {} + } + } + }, + "temperature": 0.0, + "text": { + "format": text_response_format + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_p": 0.0 + } + + # JSON input template for discriminator value "json_object": + text_response_format = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format = { + "name": "str", + "schema": { + "str": {} + }, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "id": "str", + "name": "str", + "object": "str", + "versions": { + "latest": { + "created_at": "2020-02-20 00:00:00", + "definition": agent_definition, + "id": "str", + "metadata": { + "str": "str" + }, + "name": "str", + "object": "str", + "version": "str", + "description": "str" + } + } + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -589,22 +1205,49 @@ async def _delete_thread(self, thread_id: str, **kwargs: Any) -> _models._models } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models._models.ThreadDeletionStatus] = kwargs.pop("cls", None) - - _request = build_threads_delete_thread_request( - thread_id=thread_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_types_models2.AgentDetails] = kwargs.pop("cls", None) + if body is _Unset: + if name is _Unset: + raise TypeError("missing required argument: name") + if manifest_id is _Unset: + raise TypeError("missing required argument: manifest_id") + if parameter_values is _Unset: + raise TypeError("missing required argument: parameter_values") + body = { + "description": description, + "manifest_id": manifest_id, + "metadata": metadata, + "name": name, + "parameter_values": parameter_values, + } + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_agents_create_agent_from_manifest_request( + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -619,158 +1262,198 @@ async def _delete_thread(self, thread_id: str, **kwargs: Any) -> _models._models except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) + error = self._deserialize.failsafe_deserialize( + _types_models2.ApiErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize( - _models._models.ThreadDeletionStatus, response.json() # pylint: disable=protected-access - ) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - -class MessagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.agents.aio.AgentsClient`'s - :attr:`messages` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AgentsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @overload - async def create( + async def _update_agent_from_manifest( self, - thread_id: str, + agent_name: str, + manifest_id: str, + parameter_values: dict[str, Any], + metadata: Optional[dict[str, str]] = None, + description: Optional[str] = None, *, - role: Union[str, _models.MessageRole], - content: "_types.MessageInputContent", content_type: str = "application/json", - attachments: Optional[List[_models.MessageAttachment]] = None, - metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> _models.ThreadMessage: - """Creates a new message on a specified thread. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :keyword 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). Known values are: "user" and "assistant". - Required. - :paramtype role: str or ~azure.ai.agents.models.MessageRole - :keyword 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). Is either a str type or a [MessageInputContentBlock] type. Required. - :paramtype content: str or list[~azure.ai.agents.models.MessageInputContentBlock] - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword attachments: A list of files attached to the message, and the tools they should be - added to. Default value is None. - :paramtype attachments: list[~azure.ai.agents.models.MessageAttachment] - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: ThreadMessage. The ThreadMessage is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadMessage - :raises ~azure.core.exceptions.HttpResponseError: - """ - + ) -> _types_models2.AgentDetails: ... @overload - async def create( - self, thread_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ThreadMessage: - """Creates a new message on a specified thread. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ThreadMessage. The ThreadMessage is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadMessage - :raises ~azure.core.exceptions.HttpResponseError: - """ - + async def _update_agent_from_manifest( + self, agent_name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _types_models2.AgentDetails: ... @overload - async def create( - self, thread_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ThreadMessage: - """Creates a new message on a specified thread. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: ThreadMessage. The ThreadMessage is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadMessage - :raises ~azure.core.exceptions.HttpResponseError: - """ + async def _update_agent_from_manifest( + self, agent_name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _types_models2.AgentDetails: ... @distributed_trace_async - async def create( + async def _update_agent_from_manifest( self, - thread_id: str, + agent_name: str, + manifest_id: str = _Unset, + parameter_values: dict[str, Any] = _Unset, body: Union[JSON, IO[bytes]] = _Unset, - *, - role: Union[str, _models.MessageRole] = _Unset, - content: "_types.MessageInputContent" = _Unset, - attachments: Optional[List[_models.MessageAttachment]] = None, metadata: Optional[dict[str, str]] = None, + description: Optional[str] = None, **kwargs: Any - ) -> _models.ThreadMessage: - """Creates a new message on a specified thread. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str + ) -> _types_models2.AgentDetails: + """Updates the agent from a manifest by adding a new version if there are any changes to the agent + definition. If no changes, returns the existing agent version. + + :param agent_name: The name of the agent to update. Required. + :type agent_name: str + :param manifest_id: The manifest ID to import the agent version from. Required. + :type manifest_id: str + :param parameter_values: The inputs to the manifest that will result in a fully materialized + Agent. Required. + :type parameter_values: dict[str, any] :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :keyword 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). Known values are: "user" and "assistant". - Required. - :paramtype role: str or ~azure.ai.agents.models.MessageRole - :keyword 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). Is either a str type or a [MessageInputContentBlock] type. Required. - :paramtype content: str or list[~azure.ai.agents.models.MessageInputContentBlock] - :keyword attachments: A list of files attached to the message, and the tools they should be - added to. Default value is None. - :paramtype attachments: list[~azure.ai.agents.models.MessageAttachment] - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: ThreadMessage. The ThreadMessage is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadMessage + :param metadata: Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. Default value is None. + :type metadata: dict[str, str] + :param description: A human-readable description of the agent. Default value is None. + :type description: str + :return: AgentDetails + :rtype: ~azure.ai.agents.types.AgentDetails :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "manifest_id": "str", + "parameter_values": { + "str": {} + }, + "description": "str", + "metadata": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "hosted": + agent_definition = { + "container_protocol_versions": [ + { + "protocol": "str", + "version": "str" + } + ], + "cpu": "str", + "kind": "hosted", + "memory": "str", + "environment_variables": { + "str": "str" + }, + "image": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "tools": [ + tool + ] + } + + # JSON input template for discriminator value "prompt": + agent_definition = { + "kind": "prompt", + "model": "str", + "instructions": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "structured_inputs": { + "str": { + "default_value": {}, + "description": "str", + "required": bool, + "schema": { + "str": {} + } + } + }, + "temperature": 0.0, + "text": { + "format": text_response_format + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_p": 0.0 + } + + # JSON input template for discriminator value "json_object": + text_response_format = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format = { + "name": "str", + "schema": { + "str": {} + }, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "id": "str", + "name": "str", + "object": "str", + "versions": { + "latest": { + "created_at": "2020-02-20 00:00:00", + "definition": agent_definition, + "id": "str", + "metadata": { + "str": "str" + }, + "name": "str", + "object": "str", + "version": "str", + "description": "str" + } + } + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -784,26 +1467,33 @@ async def create( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ThreadMessage] = kwargs.pop("cls", None) + cls: ClsType[_types_models2.AgentDetails] = kwargs.pop("cls", None) if body is _Unset: - if role is _Unset: - raise TypeError("missing required argument: role") - if content is _Unset: - raise TypeError("missing required argument: content") - body = {"attachments": attachments, "content": content, "metadata": metadata, "role": role} + if manifest_id is _Unset: + raise TypeError("missing required argument: manifest_id") + if parameter_values is _Unset: + raise TypeError("missing required argument: parameter_values") + body = { + "description": description, + "manifest_id": manifest_id, + "metadata": metadata, + "parameter_values": parameter_values, + } body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" + _json = None _content = None if isinstance(body, (IOBase, bytes)): _content = body else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _json = body - _request = build_messages_create_request( - thread_id=thread_id, + _request = build_agents_update_agent_from_manifest_request( + agent_name=agent_name, content_type=content_type, api_version=self._config.api_version, + json=_json, content=_content, headers=_headers, params=_params, @@ -813,6 +1503,85 @@ async def create( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _types_models2.ApiErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete(self, agent_name: str, **kwargs: Any) -> _types_models2.DeleteAgentResponse: + """Deletes an agent. + + :param agent_name: The name of the agent to delete. Required. + :type agent_name: str + :return: DeleteAgentResponse + :rtype: ~azure.ai.agents.types.DeleteAgentResponse + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "deleted": bool, + "name": "str", + "object": "str" + } + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_types_models2.DeleteAgentResponse] = kwargs.pop("cls", None) + + _request = build_agents_delete_request( + agent_name=agent_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -827,13 +1596,19 @@ async def create( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) + error = self._deserialize.failsafe_deserialize( + _types_models2.ApiErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.ThreadMessage, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -843,39 +1618,145 @@ async def create( @distributed_trace def list( self, - thread_id: str, *, - run_id: Optional[str] = None, + kind: Optional[types.AgentKind] = None, limit: Optional[int] = None, - order: Optional[Union[str, _models.ListSortOrder]] = None, + order: Optional[types.PageOrder] = None, before: Optional[str] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.ThreadMessage"]: - """Gets a list of messages that exist on a thread. + ) -> AsyncItemPaged["_types_models2.AgentDetails"]: + """Returns the list of all agents. - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :keyword run_id: Filter messages by the run ID that generated them. Default value is None. - :paramtype run_id: str + :keyword kind: Filter agents by kind. If not provided, all agents are returned. Known values + are: "prompt", "hosted", and "workflow". Default value is None. + :paramtype kind: str or ~azure.ai.agents.models.AgentKind :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and - 100, and the default is 20. Default value is None. + 100, and the + default is 20. Default value is None. :paramtype limit: int - :keyword order: Sort order by the created_at timestamp of the objects. asc for ascending order - and desc for descending order. Known values are: "asc" and "desc". Default value is None. - :paramtype order: str or ~azure.ai.agents.models.ListSortOrder - :keyword 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. Default value is None. + :keyword order: Sort order by the ``created_at`` timestamp of the objects. ``asc`` for + ascending order and``desc`` + for descending order. Known values are: "asc" and "desc". Default value is None. + :paramtype order: str or ~azure.ai.agents.models.PageOrder + :keyword 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. + Default value is None. :paramtype before: str - :return: An iterator like instance of ThreadMessage - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.models.ThreadMessage] + :return: An iterator like instance of AgentDetails + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.types.AgentDetails] :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "hosted": + agent_definition = { + "container_protocol_versions": [ + { + "protocol": "str", + "version": "str" + } + ], + "cpu": "str", + "kind": "hosted", + "memory": "str", + "environment_variables": { + "str": "str" + }, + "image": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "tools": [ + tool + ] + } + + # JSON input template for discriminator value "prompt": + agent_definition = { + "kind": "prompt", + "model": "str", + "instructions": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "structured_inputs": { + "str": { + "default_value": {}, + "description": "str", + "required": bool, + "schema": { + "str": {} + } + } + }, + "temperature": 0.0, + "text": { + "format": text_response_format + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_p": 0.0 + } + + # JSON input template for discriminator value "json_object": + text_response_format = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format = { + "name": "str", + "schema": { + "str": {} + }, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "id": "str", + "name": "str", + "object": "str", + "versions": { + "latest": { + "created_at": "2020-02-20 00:00:00", + "definition": agent_definition, + "id": "str", + "metadata": { + "str": "str" + }, + "name": "str", + "object": "str", + "version": "str", + "description": "str" + } + } + } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.ThreadMessage]] = kwargs.pop("cls", None) + cls: ClsType[List[_types_models2.AgentDetails]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -887,9 +1768,8 @@ def list( def prepare_request(_continuation_token=None): - _request = build_messages_list_request( - thread_id=thread_id, - run_id=run_id, + _request = build_agents_list_request( + kind=kind, limit=limit, order=order, after=_continuation_token, @@ -906,7 +1786,7 @@ def prepare_request(_continuation_token=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.ThreadMessage], deserialized.get("data", [])) + list_of_elem = deserialized.get("data", []) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("last_id") or None, AsyncList(list_of_elem) @@ -922,23 +1802,741 @@ async def get_next(_continuation_token=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = self._deserialize.failsafe_deserialize( + _types_models2.ApiErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error) return pipeline_response return AsyncItemPaged(get_next, extract_data) + @overload + async def create_version( + self, + agent_name: str, + definition: _types_models2.AgentDefinition, + metadata: Optional[dict[str, str]] = None, + description: Optional[str] = None, + *, + foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models2.AgentVersionDetails: + """Create a new agent version. + + :param agent_name: The unique name that identifies the agent. Name can be used to + retrieve/update/delete the agent. + + * Must start and end with alphanumeric characters, + * Can contain hyphens in the middle + * Must not exceed 63 characters. Required. + :type agent_name: str + :param definition: The agent definition. This can be a workflow, hosted agent, or a simple + agent definition. Required. + :type definition: ~azure.ai.agents.types.AgentDefinition + :param metadata: Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. Default value is None. + :type metadata: dict[str, str] + :param description: A human-readable description of the agent. Default value is None. + :type description: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. Known values are: "HostedAgents=V1Preview" and + "WorkflowAgents=V1Preview". Default value is None. + :paramtype foundry_features: str or ~azure.ai.agents.models.AgentDefinitionOptInKeys + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AgentVersionDetails + :rtype: ~azure.ai.agents.types.AgentVersionDetails + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "hosted": + agent_definition = { + "container_protocol_versions": [ + { + "protocol": "str", + "version": "str" + } + ], + "cpu": "str", + "kind": "hosted", + "memory": "str", + "environment_variables": { + "str": "str" + }, + "image": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "tools": [ + tool + ] + } + + # JSON input template for discriminator value "prompt": + agent_definition = { + "kind": "prompt", + "model": "str", + "instructions": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "structured_inputs": { + "str": { + "default_value": {}, + "description": "str", + "required": bool, + "schema": { + "str": {} + } + } + }, + "temperature": 0.0, + "text": { + "format": text_response_format + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_p": 0.0 + } + + # JSON input template for discriminator value "json_object": + text_response_format = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format = { + "name": "str", + "schema": { + "str": {} + }, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "definition": agent_definition, + "id": "str", + "metadata": { + "str": "str" + }, + "name": "str", + "object": "str", + "version": "str", + "description": "str" + } + """ + + @overload + async def create_version( + self, + agent_name: str, + body: JSON, + *, + foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models2.AgentVersionDetails: + """Create a new agent version. + + :param agent_name: The unique name that identifies the agent. Name can be used to + retrieve/update/delete the agent. + + * Must start and end with alphanumeric characters, + * Can contain hyphens in the middle + * Must not exceed 63 characters. Required. + :type agent_name: str + :param body: Required. + :type body: JSON + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. Known values are: "HostedAgents=V1Preview" and + "WorkflowAgents=V1Preview". Default value is None. + :paramtype foundry_features: str or ~azure.ai.agents.models.AgentDefinitionOptInKeys + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AgentVersionDetails + :rtype: ~azure.ai.agents.types.AgentVersionDetails + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "kind": + + # JSON input template for discriminator value "hosted": + agent_definition = { + "container_protocol_versions": [ + { + "protocol": "str", + "version": "str" + } + ], + "cpu": "str", + "kind": "hosted", + "memory": "str", + "environment_variables": { + "str": "str" + }, + "image": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "tools": [ + tool + ] + } + + # JSON input template for discriminator value "prompt": + agent_definition = { + "kind": "prompt", + "model": "str", + "instructions": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "structured_inputs": { + "str": { + "default_value": {}, + "description": "str", + "required": bool, + "schema": { + "str": {} + } + } + }, + "temperature": 0.0, + "text": { + "format": text_response_format + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_p": 0.0 + } + + # JSON input template for discriminator value "json_object": + text_response_format = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format = { + "name": "str", + "schema": { + "str": {} + }, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format = { + "type": "text" + } + + # JSON input template you can fill out and use as your body input. + body = { + "definition": agent_definition, + "description": "str", + "metadata": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "hosted": + agent_definition = { + "container_protocol_versions": [ + { + "protocol": "str", + "version": "str" + } + ], + "cpu": "str", + "kind": "hosted", + "memory": "str", + "environment_variables": { + "str": "str" + }, + "image": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "tools": [ + tool + ] + } + + # JSON input template for discriminator value "prompt": + agent_definition = { + "kind": "prompt", + "model": "str", + "instructions": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "structured_inputs": { + "str": { + "default_value": {}, + "description": "str", + "required": bool, + "schema": { + "str": {} + } + } + }, + "temperature": 0.0, + "text": { + "format": text_response_format + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_p": 0.0 + } + + # JSON input template for discriminator value "json_object": + text_response_format = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format = { + "name": "str", + "schema": { + "str": {} + }, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "definition": agent_definition, + "id": "str", + "metadata": { + "str": "str" + }, + "name": "str", + "object": "str", + "version": "str", + "description": "str" + } + """ + + @overload + async def create_version( + self, + agent_name: str, + body: IO[bytes], + *, + foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models2.AgentVersionDetails: + """Create a new agent version. + + :param agent_name: The unique name that identifies the agent. Name can be used to + retrieve/update/delete the agent. + + * Must start and end with alphanumeric characters, + * Can contain hyphens in the middle + * Must not exceed 63 characters. Required. + :type agent_name: str + :param body: Required. + :type body: IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. Known values are: "HostedAgents=V1Preview" and + "WorkflowAgents=V1Preview". Default value is None. + :paramtype foundry_features: str or ~azure.ai.agents.models.AgentDefinitionOptInKeys + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: AgentVersionDetails + :rtype: ~azure.ai.agents.types.AgentVersionDetails + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "hosted": + agent_definition = { + "container_protocol_versions": [ + { + "protocol": "str", + "version": "str" + } + ], + "cpu": "str", + "kind": "hosted", + "memory": "str", + "environment_variables": { + "str": "str" + }, + "image": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "tools": [ + tool + ] + } + + # JSON input template for discriminator value "prompt": + agent_definition = { + "kind": "prompt", + "model": "str", + "instructions": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "structured_inputs": { + "str": { + "default_value": {}, + "description": "str", + "required": bool, + "schema": { + "str": {} + } + } + }, + "temperature": 0.0, + "text": { + "format": text_response_format + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_p": 0.0 + } + + # JSON input template for discriminator value "json_object": + text_response_format = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format = { + "name": "str", + "schema": { + "str": {} + }, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "definition": agent_definition, + "id": "str", + "metadata": { + "str": "str" + }, + "name": "str", + "object": "str", + "version": "str", + "description": "str" + } + """ + @distributed_trace_async - async def get(self, thread_id: str, message_id: str, **kwargs: Any) -> _models.ThreadMessage: - """Retrieves an existing message. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param message_id: Identifier of the message. Required. - :type message_id: str - :return: ThreadMessage. The ThreadMessage is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadMessage + async def create_version( + self, + agent_name: str, + definition: _types_models2.AgentDefinition = _Unset, + body: Union[JSON, IO[bytes]] = _Unset, + metadata: Optional[dict[str, str]] = None, + description: Optional[str] = None, + *, + foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, + **kwargs: Any + ) -> _types_models2.AgentVersionDetails: + """Create a new agent version. + + :param agent_name: The unique name that identifies the agent. Name can be used to + retrieve/update/delete the agent. + + * Must start and end with alphanumeric characters, + * Can contain hyphens in the middle + * Must not exceed 63 characters. Required. + :type agent_name: str + :param definition: The agent definition. This can be a workflow, hosted agent, or a simple + agent definition. Required. + :type definition: ~azure.ai.agents.types.AgentDefinition + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :param metadata: Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. Default value is None. + :type metadata: dict[str, str] + :param description: A human-readable description of the agent. Default value is None. + :type description: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. Known values are: "HostedAgents=V1Preview" and + "WorkflowAgents=V1Preview". Default value is None. + :paramtype foundry_features: str or ~azure.ai.agents.models.AgentDefinitionOptInKeys + :return: AgentVersionDetails + :rtype: ~azure.ai.agents.types.AgentVersionDetails :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "kind": + + # JSON input template for discriminator value "hosted": + agent_definition = { + "container_protocol_versions": [ + { + "protocol": "str", + "version": "str" + } + ], + "cpu": "str", + "kind": "hosted", + "memory": "str", + "environment_variables": { + "str": "str" + }, + "image": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "tools": [ + tool + ] + } + + # JSON input template for discriminator value "prompt": + agent_definition = { + "kind": "prompt", + "model": "str", + "instructions": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "structured_inputs": { + "str": { + "default_value": {}, + "description": "str", + "required": bool, + "schema": { + "str": {} + } + } + }, + "temperature": 0.0, + "text": { + "format": text_response_format + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_p": 0.0 + } + + # JSON input template for discriminator value "json_object": + text_response_format = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format = { + "name": "str", + "schema": { + "str": {} + }, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format = { + "type": "text" + } + + # JSON input template you can fill out and use as your body input. + body = { + "definition": agent_definition, + "description": "str", + "metadata": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "hosted": + agent_definition = { + "container_protocol_versions": [ + { + "protocol": "str", + "version": "str" + } + ], + "cpu": "str", + "kind": "hosted", + "memory": "str", + "environment_variables": { + "str": "str" + }, + "image": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "tools": [ + tool + ] + } + + # JSON input template for discriminator value "prompt": + agent_definition = { + "kind": "prompt", + "model": "str", + "instructions": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "structured_inputs": { + "str": { + "default_value": {}, + "description": "str", + "required": bool, + "schema": { + "str": {} + } + } + }, + "temperature": 0.0, + "text": { + "format": text_response_format + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_p": 0.0 + } + + # JSON input template for discriminator value "json_object": + text_response_format = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format = { + "name": "str", + "schema": { + "str": {} + }, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "definition": agent_definition, + "id": "str", + "metadata": { + "str": "str" + }, + "name": "str", + "object": "str", + "version": "str", + "description": "str" + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -948,15 +2546,32 @@ async def get(self, thread_id: str, message_id: str, **kwargs: Any) -> _models.T } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.ThreadMessage] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_types_models2.AgentVersionDetails] = kwargs.pop("cls", None) + + if body is _Unset: + if definition is _Unset: + raise TypeError("missing required argument: definition") + body = {"definition": definition, "description": description, "metadata": metadata} + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body - _request = build_messages_get_request( - thread_id=thread_id, - message_id=message_id, + _request = build_agents_create_version_request( + agent_name=agent_name, + foundry_features=foundry_features, + content_type=content_type, api_version=self._config.api_version, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -965,6 +2580,7 @@ async def get(self, thread_id: str, message_id: str, **kwargs: Any) -> _models.T } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -979,13 +2595,19 @@ async def get(self, thread_id: str, message_id: str, **kwargs: Any) -> _models.T except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) + error = self._deserialize.failsafe_deserialize( + _types_models2.ApiErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.ThreadMessage, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -993,100 +2615,549 @@ async def get(self, thread_id: str, message_id: str, **kwargs: Any) -> _models.T return deserialized # type: ignore @overload - async def update( + async def create_version_from_manifest( self, - thread_id: str, - message_id: str, + agent_name: str, + manifest_id: str, + parameter_values: dict[str, Any], + metadata: Optional[dict[str, str]] = None, + description: Optional[str] = None, *, content_type: str = "application/json", - metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> _models.ThreadMessage: - """Modifies an existing message on an existing thread. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param message_id: Identifier of the message. Required. - :type message_id: str + ) -> _types_models2.AgentVersionDetails: + """Create a new agent version from a manifest. + + :param agent_name: The unique name that identifies the agent. Name can be used to + retrieve/update/delete the agent. + + * Must start and end with alphanumeric characters, + * Can contain hyphens in the middle + * Must not exceed 63 characters. Required. + :type agent_name: str + :param manifest_id: The manifest ID to import the agent version from. Required. + :type manifest_id: str + :param parameter_values: The inputs to the manifest that will result in a fully materialized + Agent. Required. + :type parameter_values: dict[str, any] + :param metadata: Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. Default value is None. + :type metadata: dict[str, str] + :param description: A human-readable description of the agent. Default value is None. + :type description: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: ThreadMessage. The ThreadMessage is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadMessage + :return: AgentVersionDetails + :rtype: ~azure.ai.agents.types.AgentVersionDetails :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "hosted": + agent_definition = { + "container_protocol_versions": [ + { + "protocol": "str", + "version": "str" + } + ], + "cpu": "str", + "kind": "hosted", + "memory": "str", + "environment_variables": { + "str": "str" + }, + "image": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "tools": [ + tool + ] + } + + # JSON input template for discriminator value "prompt": + agent_definition = { + "kind": "prompt", + "model": "str", + "instructions": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "structured_inputs": { + "str": { + "default_value": {}, + "description": "str", + "required": bool, + "schema": { + "str": {} + } + } + }, + "temperature": 0.0, + "text": { + "format": text_response_format + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_p": 0.0 + } + + # JSON input template for discriminator value "json_object": + text_response_format = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format = { + "name": "str", + "schema": { + "str": {} + }, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "definition": agent_definition, + "id": "str", + "metadata": { + "str": "str" + }, + "name": "str", + "object": "str", + "version": "str", + "description": "str" + } """ @overload - async def update( - self, thread_id: str, message_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ThreadMessage: - """Modifies an existing message on an existing thread. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param message_id: Identifier of the message. Required. - :type message_id: str + async def create_version_from_manifest( + self, agent_name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _types_models2.AgentVersionDetails: + """Create a new agent version from a manifest. + + :param agent_name: The unique name that identifies the agent. Name can be used to + retrieve/update/delete the agent. + + * Must start and end with alphanumeric characters, + * Can contain hyphens in the middle + * Must not exceed 63 characters. Required. + :type agent_name: str :param body: Required. :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: ThreadMessage. The ThreadMessage is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadMessage + :return: AgentVersionDetails + :rtype: ~azure.ai.agents.types.AgentVersionDetails :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "manifest_id": "str", + "parameter_values": { + "str": {} + }, + "description": "str", + "metadata": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "hosted": + agent_definition = { + "container_protocol_versions": [ + { + "protocol": "str", + "version": "str" + } + ], + "cpu": "str", + "kind": "hosted", + "memory": "str", + "environment_variables": { + "str": "str" + }, + "image": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "tools": [ + tool + ] + } + + # JSON input template for discriminator value "prompt": + agent_definition = { + "kind": "prompt", + "model": "str", + "instructions": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "structured_inputs": { + "str": { + "default_value": {}, + "description": "str", + "required": bool, + "schema": { + "str": {} + } + } + }, + "temperature": 0.0, + "text": { + "format": text_response_format + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_p": 0.0 + } + + # JSON input template for discriminator value "json_object": + text_response_format = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format = { + "name": "str", + "schema": { + "str": {} + }, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "definition": agent_definition, + "id": "str", + "metadata": { + "str": "str" + }, + "name": "str", + "object": "str", + "version": "str", + "description": "str" + } """ @overload - async def update( - self, thread_id: str, message_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ThreadMessage: - """Modifies an existing message on an existing thread. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param message_id: Identifier of the message. Required. - :type message_id: str + async def create_version_from_manifest( + self, agent_name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _types_models2.AgentVersionDetails: + """Create a new agent version from a manifest. + + :param agent_name: The unique name that identifies the agent. Name can be used to + retrieve/update/delete the agent. + + * Must start and end with alphanumeric characters, + * Can contain hyphens in the middle + * Must not exceed 63 characters. Required. + :type agent_name: str :param body: Required. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: ThreadMessage. The ThreadMessage is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadMessage + :return: AgentVersionDetails + :rtype: ~azure.ai.agents.types.AgentVersionDetails :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "hosted": + agent_definition = { + "container_protocol_versions": [ + { + "protocol": "str", + "version": "str" + } + ], + "cpu": "str", + "kind": "hosted", + "memory": "str", + "environment_variables": { + "str": "str" + }, + "image": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "tools": [ + tool + ] + } + + # JSON input template for discriminator value "prompt": + agent_definition = { + "kind": "prompt", + "model": "str", + "instructions": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "structured_inputs": { + "str": { + "default_value": {}, + "description": "str", + "required": bool, + "schema": { + "str": {} + } + } + }, + "temperature": 0.0, + "text": { + "format": text_response_format + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_p": 0.0 + } + + # JSON input template for discriminator value "json_object": + text_response_format = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format = { + "name": "str", + "schema": { + "str": {} + }, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "definition": agent_definition, + "id": "str", + "metadata": { + "str": "str" + }, + "name": "str", + "object": "str", + "version": "str", + "description": "str" + } """ @distributed_trace_async - async def update( + async def create_version_from_manifest( self, - thread_id: str, - message_id: str, + agent_name: str, + manifest_id: str = _Unset, + parameter_values: dict[str, Any] = _Unset, body: Union[JSON, IO[bytes]] = _Unset, - *, metadata: Optional[dict[str, str]] = None, + description: Optional[str] = None, **kwargs: Any - ) -> _models.ThreadMessage: - """Modifies an existing message on an existing thread. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param message_id: Identifier of the message. Required. - :type message_id: str + ) -> _types_models2.AgentVersionDetails: + """Create a new agent version from a manifest. + + :param agent_name: The unique name that identifies the agent. Name can be used to + retrieve/update/delete the agent. + + * Must start and end with alphanumeric characters, + * Can contain hyphens in the middle + * Must not exceed 63 characters. Required. + :type agent_name: str + :param manifest_id: The manifest ID to import the agent version from. Required. + :type manifest_id: str + :param parameter_values: The inputs to the manifest that will result in a fully materialized + Agent. Required. + :type parameter_values: dict[str, any] :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: ThreadMessage. The ThreadMessage is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadMessage + :param metadata: Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. Default value is None. + :type metadata: dict[str, str] + :param description: A human-readable description of the agent. Default value is None. + :type description: str + :return: AgentVersionDetails + :rtype: ~azure.ai.agents.types.AgentVersionDetails :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "manifest_id": "str", + "parameter_values": { + "str": {} + }, + "description": "str", + "metadata": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "hosted": + agent_definition = { + "container_protocol_versions": [ + { + "protocol": "str", + "version": "str" + } + ], + "cpu": "str", + "kind": "hosted", + "memory": "str", + "environment_variables": { + "str": "str" + }, + "image": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "tools": [ + tool + ] + } + + # JSON input template for discriminator value "prompt": + agent_definition = { + "kind": "prompt", + "model": "str", + "instructions": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "structured_inputs": { + "str": { + "default_value": {}, + "description": "str", + "required": bool, + "schema": { + "str": {} + } + } + }, + "temperature": 0.0, + "text": { + "format": text_response_format + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_p": 0.0 + } + + # JSON input template for discriminator value "json_object": + text_response_format = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format = { + "name": "str", + "schema": { + "str": {} + }, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "definition": agent_definition, + "id": "str", + "metadata": { + "str": "str" + }, + "name": "str", + "object": "str", + "version": "str", + "description": "str" + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1100,23 +3171,33 @@ async def update( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ThreadMessage] = kwargs.pop("cls", None) + cls: ClsType[_types_models2.AgentVersionDetails] = kwargs.pop("cls", None) if body is _Unset: - body = {"metadata": metadata} + if manifest_id is _Unset: + raise TypeError("missing required argument: manifest_id") + if parameter_values is _Unset: + raise TypeError("missing required argument: parameter_values") + body = { + "description": description, + "manifest_id": manifest_id, + "metadata": metadata, + "parameter_values": parameter_values, + } body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" + _json = None _content = None if isinstance(body, (IOBase, bytes)): _content = body else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _json = body - _request = build_messages_update_request( - thread_id=thread_id, - message_id=message_id, + _request = build_agents_create_version_from_manifest_request( + agent_name=agent_name, content_type=content_type, api_version=self._config.api_version, + json=_json, content=_content, headers=_headers, params=_params, @@ -1126,6 +3207,7 @@ async def update( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1140,13 +3222,19 @@ async def update( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) + error = self._deserialize.failsafe_deserialize( + _types_models2.ApiErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.ThreadMessage, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1154,21 +3242,116 @@ async def update( return deserialized # type: ignore @distributed_trace_async - @api_version_validation( - method_added_on="v1", - params_added_on={"v1": ["api_version", "thread_id", "message_id", "accept"]}, - api_versions_list=["v1", "2025-05-15-preview"], - ) - async def _delete(self, thread_id: str, message_id: str, **kwargs: Any) -> _models._models.MessageDeletionStatus: - """Deletes an existing message on an existing thread. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param message_id: Identifier of the message. Required. - :type message_id: str - :return: MessageDeletionStatus. The MessageDeletionStatus is compatible with MutableMapping - :rtype: ~azure.ai.agents.models._models.MessageDeletionStatus + async def get_version( + self, agent_name: str, agent_version: str, **kwargs: Any + ) -> _types_models2.AgentVersionDetails: + """Retrieves a specific version of an agent. + + :param agent_name: The name of the agent to retrieve. Required. + :type agent_name: str + :param agent_version: The version of the agent to retrieve. Required. + :type agent_version: str + :return: AgentVersionDetails + :rtype: ~azure.ai.agents.types.AgentVersionDetails :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "hosted": + agent_definition = { + "container_protocol_versions": [ + { + "protocol": "str", + "version": "str" + } + ], + "cpu": "str", + "kind": "hosted", + "memory": "str", + "environment_variables": { + "str": "str" + }, + "image": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "tools": [ + tool + ] + } + + # JSON input template for discriminator value "prompt": + agent_definition = { + "kind": "prompt", + "model": "str", + "instructions": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "structured_inputs": { + "str": { + "default_value": {}, + "description": "str", + "required": bool, + "schema": { + "str": {} + } + } + }, + "temperature": 0.0, + "text": { + "format": text_response_format + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_p": 0.0 + } + + # JSON input template for discriminator value "json_object": + text_response_format = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format = { + "name": "str", + "schema": { + "str": {} + }, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "definition": agent_definition, + "id": "str", + "metadata": { + "str": "str" + }, + "name": "str", + "object": "str", + "version": "str", + "description": "str" + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1181,11 +3364,11 @@ async def _delete(self, thread_id: str, message_id: str, **kwargs: Any) -> _mode _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models._models.MessageDeletionStatus] = kwargs.pop("cls", None) + cls: ClsType[_types_models2.AgentVersionDetails] = kwargs.pop("cls", None) - _request = build_messages_delete_request( - thread_id=thread_id, - message_id=message_id, + _request = build_agents_get_version_request( + agent_name=agent_name, + agent_version=agent_version, api_version=self._config.api_version, headers=_headers, params=_params, @@ -1195,6 +3378,7 @@ async def _delete(self, thread_id: str, message_id: str, **kwargs: Any) -> _mode } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1209,379 +3393,67 @@ async def _delete(self, thread_id: str, message_id: str, **kwargs: Any) -> _mode except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) + error = self._deserialize.failsafe_deserialize( + _types_models2.ApiErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize( - _models._models.MessageDeletionStatus, response.json() # pylint: disable=protected-access - ) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + @distributed_trace_async + async def delete_version( + self, agent_name: str, agent_version: str, **kwargs: Any + ) -> _types_models2.DeleteAgentVersionResponse: + """Deletes a specific version of an agent. + + :param agent_name: The name of the agent to delete. Required. + :type agent_name: str + :param agent_version: The version of the agent to delete. Required. + :type agent_version: str + :return: DeleteAgentVersionResponse + :rtype: ~azure.ai.agents.types.DeleteAgentVersionResponse + :raises ~azure.core.exceptions.HttpResponseError: -class RunsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. + Example: + .. code-block:: python - Instead, you should access the following operations through - :class:`~azure.ai.agents.aio.AgentsClient`'s - :attr:`runs` attribute. - """ + # response body for status code(s): 200 + response == { + "deleted": bool, + "name": "str", + "object": "str", + "version": "str" + } + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AgentsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - async def create( - self, - thread_id: str, - *, - agent_id: str, - include: Optional[List[Union[str, _models.RunAdditionalFieldList]]] = None, - content_type: str = "application/json", - model: Optional[str] = None, - instructions: Optional[str] = None, - additional_instructions: Optional[str] = None, - additional_messages: Optional[List[_models.ThreadMessageOptions]] = None, - tools: Optional[List[_models.ToolDefinition]] = None, - tool_resources: Optional[_models.ToolResources] = None, - stream_parameter: Optional[bool] = None, - temperature: Optional[float] = None, - top_p: Optional[float] = None, - max_prompt_tokens: Optional[int] = None, - max_completion_tokens: Optional[int] = None, - truncation_strategy: Optional[_models.TruncationObject] = None, - tool_choice: Optional["_types.AgentsToolChoiceOption"] = None, - response_format: Optional["_types.AgentsResponseFormatOption"] = None, - parallel_tool_calls: Optional[bool] = None, - metadata: Optional[dict[str, str]] = None, - **kwargs: Any - ) -> _models.ThreadRun: - """Creates a new run for an agent thread. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :keyword agent_id: The ID of the agent that should run the thread. Required. - :paramtype agent_id: str - :keyword 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. Default value is None. - :paramtype include: list[str or ~azure.ai.agents.models.RunAdditionalFieldList] - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword model: The overridden model name that the agent should use to run the thread. Default - value is None. - :paramtype model: str - :keyword instructions: The overridden system instructions that the agent should use to run the - thread. Default value is None. - :paramtype instructions: str - :keyword additional_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. Default value is None. - :paramtype additional_instructions: str - :keyword additional_messages: Adds additional messages to the thread before creating the run. - Default value is None. - :paramtype additional_messages: list[~azure.ai.agents.models.ThreadMessageOptions] - :keyword tools: The overridden list of enabled tools that the agent should use to run the - thread. Default value is None. - :paramtype tools: list[~azure.ai.agents.models.ToolDefinition] - :keyword tool_resources: The overridden enabled tool resources that the agent should use to run - the thread. Default value is None. - :paramtype tool_resources: ~azure.ai.agents.models.ToolResources - :keyword stream_parameter: 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. Default - value is None. - :paramtype stream_parameter: bool - :keyword temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 - will make the output - more random, while lower values like 0.2 will make it more focused and deterministic. Default - value is None. - :paramtype temperature: float - :keyword top_p: An alternative to sampling with temperature, called nucleus sampling, where the - model - considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens - comprising the top 10% probability mass are considered. - - We generally recommend altering this or temperature but not both. Default value is None. - :paramtype top_p: float - :keyword max_prompt_tokens: 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. Default - value is None. - :paramtype max_prompt_tokens: int - :keyword max_completion_tokens: 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. Default value is None. - :paramtype max_completion_tokens: int - :keyword truncation_strategy: The strategy to use for dropping messages as the context windows - moves forward. Default value is None. - :paramtype truncation_strategy: ~azure.ai.agents.models.TruncationObject - :keyword tool_choice: Controls whether or not and which tool is called by the model. Is one of - the following types: str, Union[str, "_models.AgentsToolChoiceOptionMode"], - AgentsNamedToolChoice Default value is None. - :paramtype tool_choice: str or str or ~azure.ai.agents.models.AgentsToolChoiceOptionMode or - ~azure.ai.agents.models.AgentsNamedToolChoice - :keyword response_format: Specifies the format that the model must output. Is one of the - following types: str, Union[str, "_models.AgentsResponseFormatMode"], AgentsResponseFormat, - ResponseFormatJsonSchemaType Default value is None. - :paramtype response_format: str or str or ~azure.ai.agents.models.AgentsResponseFormatMode or - ~azure.ai.agents.models.AgentsResponseFormat or - ~azure.ai.agents.models.ResponseFormatJsonSchemaType - :keyword parallel_tool_calls: If ``true`` functions will run in parallel during tool use. - Default value is None. - :paramtype parallel_tool_calls: bool - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: ThreadRun. The ThreadRun is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadRun - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, - thread_id: str, - body: JSON, - *, - include: Optional[List[Union[str, _models.RunAdditionalFieldList]]] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ThreadRun: - """Creates a new run for an agent thread. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param body: Required. - :type body: JSON - :keyword 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. Default value is None. - :paramtype include: list[str or ~azure.ai.agents.models.RunAdditionalFieldList] - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ThreadRun. The ThreadRun is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadRun - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, - thread_id: str, - body: IO[bytes], - *, - include: Optional[List[Union[str, _models.RunAdditionalFieldList]]] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ThreadRun: - """Creates a new run for an agent thread. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param body: Required. - :type body: IO[bytes] - :keyword 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. Default value is None. - :paramtype include: list[str or ~azure.ai.agents.models.RunAdditionalFieldList] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: ThreadRun. The ThreadRun is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadRun - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create( - self, - thread_id: str, - body: Union[JSON, IO[bytes]] = _Unset, - *, - agent_id: str = _Unset, - include: Optional[List[Union[str, _models.RunAdditionalFieldList]]] = None, - model: Optional[str] = None, - instructions: Optional[str] = None, - additional_instructions: Optional[str] = None, - additional_messages: Optional[List[_models.ThreadMessageOptions]] = None, - tools: Optional[List[_models.ToolDefinition]] = None, - tool_resources: Optional[_models.ToolResources] = None, - stream_parameter: Optional[bool] = None, - temperature: Optional[float] = None, - top_p: Optional[float] = None, - max_prompt_tokens: Optional[int] = None, - max_completion_tokens: Optional[int] = None, - truncation_strategy: Optional[_models.TruncationObject] = None, - tool_choice: Optional["_types.AgentsToolChoiceOption"] = None, - response_format: Optional["_types.AgentsResponseFormatOption"] = None, - parallel_tool_calls: Optional[bool] = None, - metadata: Optional[dict[str, str]] = None, - **kwargs: Any - ) -> _models.ThreadRun: - """Creates a new run for an agent thread. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword agent_id: The ID of the agent that should run the thread. Required. - :paramtype agent_id: str - :keyword 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. Default value is None. - :paramtype include: list[str or ~azure.ai.agents.models.RunAdditionalFieldList] - :keyword model: The overridden model name that the agent should use to run the thread. Default - value is None. - :paramtype model: str - :keyword instructions: The overridden system instructions that the agent should use to run the - thread. Default value is None. - :paramtype instructions: str - :keyword additional_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. Default value is None. - :paramtype additional_instructions: str - :keyword additional_messages: Adds additional messages to the thread before creating the run. - Default value is None. - :paramtype additional_messages: list[~azure.ai.agents.models.ThreadMessageOptions] - :keyword tools: The overridden list of enabled tools that the agent should use to run the - thread. Default value is None. - :paramtype tools: list[~azure.ai.agents.models.ToolDefinition] - :keyword tool_resources: The overridden enabled tool resources that the agent should use to run - the thread. Default value is None. - :paramtype tool_resources: ~azure.ai.agents.models.ToolResources - :keyword stream_parameter: 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. Default - value is None. - :paramtype stream_parameter: bool - :keyword temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 - will make the output - more random, while lower values like 0.2 will make it more focused and deterministic. Default - value is None. - :paramtype temperature: float - :keyword top_p: An alternative to sampling with temperature, called nucleus sampling, where the - model - considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens - comprising the top 10% probability mass are considered. - - We generally recommend altering this or temperature but not both. Default value is None. - :paramtype top_p: float - :keyword max_prompt_tokens: 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. Default - value is None. - :paramtype max_prompt_tokens: int - :keyword max_completion_tokens: 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. Default value is None. - :paramtype max_completion_tokens: int - :keyword truncation_strategy: The strategy to use for dropping messages as the context windows - moves forward. Default value is None. - :paramtype truncation_strategy: ~azure.ai.agents.models.TruncationObject - :keyword tool_choice: Controls whether or not and which tool is called by the model. Is one of - the following types: str, Union[str, "_models.AgentsToolChoiceOptionMode"], - AgentsNamedToolChoice Default value is None. - :paramtype tool_choice: str or str or ~azure.ai.agents.models.AgentsToolChoiceOptionMode or - ~azure.ai.agents.models.AgentsNamedToolChoice - :keyword response_format: Specifies the format that the model must output. Is one of the - following types: str, Union[str, "_models.AgentsResponseFormatMode"], AgentsResponseFormat, - ResponseFormatJsonSchemaType Default value is None. - :paramtype response_format: str or str or ~azure.ai.agents.models.AgentsResponseFormatMode or - ~azure.ai.agents.models.AgentsResponseFormat or - ~azure.ai.agents.models.ResponseFormatJsonSchemaType - :keyword parallel_tool_calls: If ``true`` functions will run in parallel during tool use. - Default value is None. - :paramtype parallel_tool_calls: bool - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: ThreadRun. The ThreadRun is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadRun - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ThreadRun] = kwargs.pop("cls", None) - - if body is _Unset: - if agent_id is _Unset: - raise TypeError("missing required argument: agent_id") - body = { - "additional_instructions": additional_instructions, - "additional_messages": additional_messages, - "assistant_id": agent_id, - "instructions": instructions, - "max_completion_tokens": max_completion_tokens, - "max_prompt_tokens": max_prompt_tokens, - "metadata": metadata, - "model": model, - "parallel_tool_calls": parallel_tool_calls, - "response_format": response_format, - "stream": stream_parameter, - "temperature": temperature, - "tool_choice": tool_choice, - "tool_resources": tool_resources, - "tools": tools, - "top_p": top_p, - "truncation_strategy": truncation_strategy, - } - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + cls: ClsType[_types_models2.DeleteAgentVersionResponse] = kwargs.pop("cls", None) - _request = build_runs_create_request( - thread_id=thread_id, - include=include, - content_type=content_type, + _request = build_agents_delete_version_request( + agent_name=agent_name, + agent_version=agent_version, api_version=self._config.api_version, - content=_content, headers=_headers, params=_params, ) @@ -1590,6 +3462,7 @@ async def create( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1604,13 +3477,19 @@ async def create( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) + error = self._deserialize.failsafe_deserialize( + _types_models2.ApiErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.ThreadRun, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1618,38 +3497,139 @@ async def create( return deserialized # type: ignore @distributed_trace - def list( + def list_versions( self, - thread_id: str, + agent_name: str, *, limit: Optional[int] = None, - order: Optional[Union[str, _models.ListSortOrder]] = None, + order: Optional[types.PageOrder] = None, before: Optional[str] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.ThreadRun"]: - """Gets a list of runs for a specified thread. + ) -> AsyncItemPaged["_types_models2.AgentVersionDetails"]: + """Returns the list of versions of an agent. - :param thread_id: Identifier of the thread. Required. - :type thread_id: str + :param agent_name: The name of the agent to retrieve versions for. Required. + :type agent_name: str :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and - 100, and the default is 20. Default value is None. + 100, and the + default is 20. Default value is None. :paramtype limit: int - :keyword order: Sort order by the created_at timestamp of the objects. asc for ascending order - and desc for descending order. Known values are: "asc" and "desc". Default value is None. - :paramtype order: str or ~azure.ai.agents.models.ListSortOrder - :keyword 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. Default value is None. + :keyword order: Sort order by the ``created_at`` timestamp of the objects. ``asc`` for + ascending order and``desc`` + for descending order. Known values are: "asc" and "desc". Default value is None. + :paramtype order: str or ~azure.ai.agents.models.PageOrder + :keyword 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. + Default value is None. :paramtype before: str - :return: An iterator like instance of ThreadRun - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.models.ThreadRun] + :return: An iterator like instance of AgentVersionDetails + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.types.AgentVersionDetails] :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "hosted": + agent_definition = { + "container_protocol_versions": [ + { + "protocol": "str", + "version": "str" + } + ], + "cpu": "str", + "kind": "hosted", + "memory": "str", + "environment_variables": { + "str": "str" + }, + "image": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "tools": [ + tool + ] + } + + # JSON input template for discriminator value "prompt": + agent_definition = { + "kind": "prompt", + "model": "str", + "instructions": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "structured_inputs": { + "str": { + "default_value": {}, + "description": "str", + "required": bool, + "schema": { + "str": {} + } + } + }, + "temperature": 0.0, + "text": { + "format": text_response_format + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_p": 0.0 + } + + # JSON input template for discriminator value "json_object": + text_response_format = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format = { + "name": "str", + "schema": { + "str": {} + }, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "definition": agent_definition, + "id": "str", + "metadata": { + "str": "str" + }, + "name": "str", + "object": "str", + "version": "str", + "description": "str" + } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.ThreadRun]] = kwargs.pop("cls", None) + cls: ClsType[List[_types_models2.AgentVersionDetails]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1661,8 +3641,8 @@ def list( def prepare_request(_continuation_token=None): - _request = build_runs_list_request( - thread_id=thread_id, + _request = build_agents_list_versions_request( + agent_name=agent_name, limit=limit, order=order, after=_continuation_token, @@ -1679,7 +3659,7 @@ def prepare_request(_continuation_token=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.ThreadRun], deserialized.get("data", [])) + list_of_elem = deserialized.get("data", []) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("last_id") or None, AsyncList(list_of_elem) @@ -1695,24 +3675,78 @@ async def get_next(_continuation_token=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) + error = self._deserialize.failsafe_deserialize( + _types_models2.ApiErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error) return pipeline_response return AsyncItemPaged(get_next, extract_data) + +class EvaluationRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.agents.aio.AIProjectClient`'s + :attr:`evaluation_rules` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async - async def get(self, thread_id: str, run_id: str, **kwargs: Any) -> _models.ThreadRun: - """Gets an existing run from an existing thread. + async def get(self, id: str, **kwargs: Any) -> _types_models2.EvaluationRule: + """Get an evaluation rule. - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param run_id: Identifier of the run. Required. - :type run_id: str - :return: ThreadRun. The ThreadRun is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadRun + :param id: Unique identifier for the evaluation rule. Required. + :type id: str + :return: EvaluationRule + :rtype: ~azure.ai.agents.types.EvaluationRule :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "continuousEvaluation": + evaluation_rule_action = { + "evalId": "str", + "type": "continuousEvaluation", + "maxHourlyRuns": 0 + } + + # JSON input template for discriminator value "humanEvaluationPreview": + evaluation_rule_action = { + "templateId": "str", + "type": "humanEvaluationPreview" + } + + # response body for status code(s): 200 + response == { + "action": evaluation_rule_action, + "enabled": bool, + "eventType": "str", + "id": "str", + "systemData": { + "str": "str" + }, + "description": "str", + "displayName": "str", + "filter": { + "agentName": "str" + } + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1725,11 +3759,10 @@ async def get(self, thread_id: str, run_id: str, **kwargs: Any) -> _models.Threa _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.ThreadRun] = kwargs.pop("cls", None) + cls: ClsType[_types_models2.EvaluationRule] = kwargs.pop("cls", None) - _request = build_runs_get_request( - thread_id=thread_id, - run_id=run_id, + _request = build_evaluation_rules_get_request( + id=id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -1739,6 +3772,7 @@ async def get(self, thread_id: str, run_id: str, **kwargs: Any) -> _models.Threa } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1753,114 +3787,362 @@ async def get(self, thread_id: str, run_id: str, **kwargs: Any) -> _models.Threa except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.ThreadRun, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + @distributed_trace_async + async def delete(self, id: str, **kwargs: Any) -> None: + """Delete an evaluation rule. + + :param id: Unique identifier for the evaluation rule. Required. + :type id: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_evaluation_rules_delete_request( + id=id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + @overload - async def update( + async def create_or_update( self, - thread_id: str, - run_id: str, + id: str, + evaluation_rule: _types_models2.EvaluationRule, *, + foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW]] = None, content_type: str = "application/json", - metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> _models.ThreadRun: - """Modifies an existing thread run. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param run_id: Identifier of the run. Required. - :type run_id: str + ) -> _types_models2.EvaluationRule: + """Create or update an evaluation rule. + + :param id: Unique identifier for the evaluation rule. Required. + :type id: str + :param evaluation_rule: Evaluation rule resource. Required. + :type evaluation_rule: ~azure.ai.agents.types.EvaluationRule + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Default value is None. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: ThreadRun. The ThreadRun is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadRun + :return: EvaluationRule + :rtype: ~azure.ai.agents.types.EvaluationRule :raises ~azure.core.exceptions.HttpResponseError: - """ - @overload - async def update( - self, thread_id: str, run_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ThreadRun: - """Modifies an existing thread run. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param run_id: Identifier of the run. Required. - :type run_id: str - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ThreadRun. The ThreadRun is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadRun - :raises ~azure.core.exceptions.HttpResponseError: + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "continuousEvaluation": + evaluation_rule_action = { + "evalId": "str", + "type": "continuousEvaluation", + "maxHourlyRuns": 0 + } + + # JSON input template for discriminator value "humanEvaluationPreview": + evaluation_rule_action = { + "templateId": "str", + "type": "humanEvaluationPreview" + } + + # JSON input template you can fill out and use as your body input. + evaluation_rule = { + "action": evaluation_rule_action, + "enabled": bool, + "eventType": "str", + "id": "str", + "systemData": { + "str": "str" + }, + "description": "str", + "displayName": "str", + "filter": { + "agentName": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "continuousEvaluation": + evaluation_rule_action = { + "evalId": "str", + "type": "continuousEvaluation", + "maxHourlyRuns": 0 + } + + # JSON input template for discriminator value "humanEvaluationPreview": + evaluation_rule_action = { + "templateId": "str", + "type": "humanEvaluationPreview" + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "continuousEvaluation": + evaluation_rule_action = { + "evalId": "str", + "type": "continuousEvaluation", + "maxHourlyRuns": 0 + } + + # JSON input template for discriminator value "humanEvaluationPreview": + evaluation_rule_action = { + "templateId": "str", + "type": "humanEvaluationPreview" + } + + # response body for status code(s): 201, 200 + response == { + "action": evaluation_rule_action, + "enabled": bool, + "eventType": "str", + "id": "str", + "systemData": { + "str": "str" + }, + "description": "str", + "displayName": "str", + "filter": { + "agentName": "str" + } + } """ @overload - async def update( - self, thread_id: str, run_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ThreadRun: - """Modifies an existing thread run. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param run_id: Identifier of the run. Required. - :type run_id: str - :param body: Required. - :type body: IO[bytes] + async def create_or_update( + self, + id: str, + evaluation_rule: IO[bytes], + *, + foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW]] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models2.EvaluationRule: + """Create or update an evaluation rule. + + :param id: Unique identifier for the evaluation rule. Required. + :type id: str + :param evaluation_rule: Evaluation rule resource. Required. + :type evaluation_rule: IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Default value is None. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: ThreadRun. The ThreadRun is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadRun + :return: EvaluationRule + :rtype: ~azure.ai.agents.types.EvaluationRule :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "continuousEvaluation": + evaluation_rule_action = { + "evalId": "str", + "type": "continuousEvaluation", + "maxHourlyRuns": 0 + } + + # JSON input template for discriminator value "humanEvaluationPreview": + evaluation_rule_action = { + "templateId": "str", + "type": "humanEvaluationPreview" + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "continuousEvaluation": + evaluation_rule_action = { + "evalId": "str", + "type": "continuousEvaluation", + "maxHourlyRuns": 0 + } + + # JSON input template for discriminator value "humanEvaluationPreview": + evaluation_rule_action = { + "templateId": "str", + "type": "humanEvaluationPreview" + } + + # response body for status code(s): 201, 200 + response == { + "action": evaluation_rule_action, + "enabled": bool, + "eventType": "str", + "id": "str", + "systemData": { + "str": "str" + }, + "description": "str", + "displayName": "str", + "filter": { + "agentName": "str" + } + } """ @distributed_trace_async - async def update( + async def create_or_update( self, - thread_id: str, - run_id: str, - body: Union[JSON, IO[bytes]] = _Unset, + id: str, + evaluation_rule: Union[_types_models2.EvaluationRule, IO[bytes]], *, - metadata: Optional[dict[str, str]] = None, + foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW]] = None, **kwargs: Any - ) -> _models.ThreadRun: - """Modifies an existing thread run. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param run_id: Identifier of the run. Required. - :type run_id: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: ThreadRun. The ThreadRun is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadRun + ) -> _types_models2.EvaluationRule: + """Create or update an evaluation rule. + + :param id: Unique identifier for the evaluation rule. Required. + :type id: str + :param evaluation_rule: Evaluation rule resource. Is either a EvaluationRule type or a + IO[bytes] type. Required. + :type evaluation_rule: ~azure.ai.agents.types.EvaluationRule or IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Default value is None. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + :return: EvaluationRule + :rtype: ~azure.ai.agents.types.EvaluationRule :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "continuousEvaluation": + evaluation_rule_action = { + "evalId": "str", + "type": "continuousEvaluation", + "maxHourlyRuns": 0 + } + + # JSON input template for discriminator value "humanEvaluationPreview": + evaluation_rule_action = { + "templateId": "str", + "type": "humanEvaluationPreview" + } + + # JSON input template you can fill out and use as your body input. + evaluation_rule = { + "action": evaluation_rule_action, + "enabled": bool, + "eventType": "str", + "id": "str", + "systemData": { + "str": "str" + }, + "description": "str", + "displayName": "str", + "filter": { + "agentName": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "continuousEvaluation": + evaluation_rule_action = { + "evalId": "str", + "type": "continuousEvaluation", + "maxHourlyRuns": 0 + } + + # JSON input template for discriminator value "humanEvaluationPreview": + evaluation_rule_action = { + "templateId": "str", + "type": "humanEvaluationPreview" + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "continuousEvaluation": + evaluation_rule_action = { + "evalId": "str", + "type": "continuousEvaluation", + "maxHourlyRuns": 0 + } + + # JSON input template for discriminator value "humanEvaluationPreview": + evaluation_rule_action = { + "templateId": "str", + "type": "humanEvaluationPreview" + } + + # response body for status code(s): 201, 200 + response == { + "action": evaluation_rule_action, + "enabled": bool, + "eventType": "str", + "id": "str", + "systemData": { + "str": "str" + }, + "description": "str", + "displayName": "str", + "filter": { + "agentName": "str" + } + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1874,23 +4156,22 @@ async def update( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ThreadRun] = kwargs.pop("cls", None) + cls: ClsType[_types_models2.EvaluationRule] = kwargs.pop("cls", None) - if body is _Unset: - body = {"metadata": metadata} - body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" + _json = None _content = None - if isinstance(body, (IOBase, bytes)): - _content = body + if isinstance(evaluation_rule, (IOBase, bytes)): + _content = evaluation_rule else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _json = evaluation_rule - _request = build_runs_update_request( - thread_id=thread_id, - run_id=run_id, + _request = build_evaluation_rules_create_or_update_request( + id=id, + foundry_features=foundry_features, content_type=content_type, api_version=self._config.api_version, + json=_json, content=_content, headers=_headers, params=_params, @@ -1900,6 +4181,7 @@ async def update( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1907,133 +4189,4303 @@ async def update( response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 201]: if _stream: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.ThreadRun, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized # type: ignore + return deserialized # type: ignore + + @distributed_trace + def list( + self, + *, + action_type: Optional[types.EvaluationRuleActionType] = None, + agent_name: Optional[str] = None, + enabled: Optional[bool] = None, + **kwargs: Any + ) -> AsyncItemPaged["_types_models2.EvaluationRule"]: + """List all evaluation rules. + + :keyword action_type: Filter by the type of evaluation rule. Known values are: + "continuousEvaluation" and "humanEvaluationPreview". Default value is None. + :paramtype action_type: str or ~azure.ai.agents.models.EvaluationRuleActionType + :keyword agent_name: Filter by the agent name. Default value is None. + :paramtype agent_name: str + :keyword enabled: Filter by the enabled status. Default value is None. + :paramtype enabled: bool + :return: An iterator like instance of EvaluationRule + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.types.EvaluationRule] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "continuousEvaluation": + evaluation_rule_action = { + "evalId": "str", + "type": "continuousEvaluation", + "maxHourlyRuns": 0 + } + + # JSON input template for discriminator value "humanEvaluationPreview": + evaluation_rule_action = { + "templateId": "str", + "type": "humanEvaluationPreview" + } + + # response body for status code(s): 200 + response == { + "action": evaluation_rule_action, + "enabled": bool, + "eventType": "str", + "id": "str", + "systemData": { + "str": "str" + }, + "description": "str", + "displayName": "str", + "filter": { + "agentName": "str" + } + } + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_types_models2.EvaluationRule]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_evaluation_rules_list_request( + action_type=action_type, + agent_name=agent_name, + enabled=enabled, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized.get("value", []) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.agents.aio.AIProjectClient`'s + :attr:`connections` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def _get(self, name: str, **kwargs: Any) -> _types_models2.Connection: + """Get a connection by name, without populating connection credentials. + + :param name: The friendly name of the connection, provided by the user. Required. + :type name: str + :return: Connection + :rtype: ~azure.ai.agents.types.Connection + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AAD": + base_credentials = { + "type": "AAD" + } + + # JSON input template for discriminator value "AgenticIdentityToken_Preview": + base_credentials = { + "type": "AgenticIdentityToken_Preview" + } + + # JSON input template for discriminator value "ApiKey": + base_credentials = { + "type": "ApiKey", + "key": "str" + } + + # JSON input template for discriminator value "CustomKeys": + base_credentials = { + "type": "CustomKeys" + } + + # JSON input template for discriminator value "None": + base_credentials = { + "type": "None" + } + + # response body for status code(s): 200 + response == { + "credentials": base_credentials, + "id": "str", + "isDefault": bool, + "metadata": { + "str": "str" + }, + "name": "str", + "target": "str", + "type": "str" + } + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_types_models2.Connection] = kwargs.pop("cls", None) + + _request = build_connections_get_request( + name=name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["x-ms-client-request-id"] = self._deserialize( + "str", response.headers.get("x-ms-client-request-id") + ) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def _get_with_credentials(self, name: str, **kwargs: Any) -> _types_models2.Connection: + """Get a connection by name, with its connection credentials. + + :param name: The friendly name of the connection, provided by the user. Required. + :type name: str + :return: Connection + :rtype: ~azure.ai.agents.types.Connection + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AAD": + base_credentials = { + "type": "AAD" + } + + # JSON input template for discriminator value "AgenticIdentityToken_Preview": + base_credentials = { + "type": "AgenticIdentityToken_Preview" + } + + # JSON input template for discriminator value "ApiKey": + base_credentials = { + "type": "ApiKey", + "key": "str" + } + + # JSON input template for discriminator value "CustomKeys": + base_credentials = { + "type": "CustomKeys" + } + + # JSON input template for discriminator value "None": + base_credentials = { + "type": "None" + } + + # response body for status code(s): 200 + response == { + "credentials": base_credentials, + "id": "str", + "isDefault": bool, + "metadata": { + "str": "str" + }, + "name": "str", + "target": "str", + "type": "str" + } + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_types_models2.Connection] = kwargs.pop("cls", None) + + _request = build_connections_get_with_credentials_request( + name=name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["x-ms-client-request-id"] = self._deserialize( + "str", response.headers.get("x-ms-client-request-id") + ) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, + *, + connection_type: Optional[types.ConnectionType] = None, + default_connection: Optional[bool] = None, + **kwargs: Any + ) -> AsyncItemPaged["_types_models2.Connection"]: + """List all connections in the project, without populating connection credentials. + + :keyword connection_type: List connections of this specific type. Known values are: + "AzureOpenAI", "AzureBlob", "AzureStorageAccount", "CognitiveSearch", "CosmosDB", "ApiKey", + "AppConfig", "AppInsights", "CustomKeys", and "RemoteTool_Preview". Default value is None. + :paramtype connection_type: str or ~azure.ai.agents.models.ConnectionType + :keyword default_connection: List connections that are default connections. Default value is + None. + :paramtype default_connection: bool + :return: An iterator like instance of Connection + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.types.Connection] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AAD": + base_credentials = { + "type": "AAD" + } + + # JSON input template for discriminator value "AgenticIdentityToken_Preview": + base_credentials = { + "type": "AgenticIdentityToken_Preview" + } + + # JSON input template for discriminator value "ApiKey": + base_credentials = { + "type": "ApiKey", + "key": "str" + } + + # JSON input template for discriminator value "CustomKeys": + base_credentials = { + "type": "CustomKeys" + } + + # JSON input template for discriminator value "None": + base_credentials = { + "type": "None" + } + + # response body for status code(s): 200 + response == { + "credentials": base_credentials, + "id": "str", + "isDefault": bool, + "metadata": { + "str": "str" + }, + "name": "str", + "target": "str", + "type": "str" + } + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_types_models2.Connection]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_connections_list_request( + connection_type=connection_type, + default_connection=default_connection, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized.get("value", []) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class DatasetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.agents.aio.AIProjectClient`'s + :attr:`datasets` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_versions(self, name: str, **kwargs: Any) -> AsyncItemPaged["_types_models2.DatasetVersion"]: + """List all versions of the given DatasetVersion. + + :param name: The name of the resource. Required. + :type name: str + :return: An iterator like instance of DatasetVersion + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.types.DatasetVersion] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "uri_file": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_file", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "uri_folder": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_folder", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # response body for status code(s): 200 + response == dataset_version + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_types_models2.DatasetVersion]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_datasets_list_versions_request( + name=name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized.get("value", []) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncItemPaged["_types_models2.DatasetVersion"]: + """List the latest version of each DatasetVersion. + + :return: An iterator like instance of DatasetVersion + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.types.DatasetVersion] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "uri_file": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_file", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "uri_folder": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_folder", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # response body for status code(s): 200 + response == dataset_version + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_types_models2.DatasetVersion]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_datasets_list_request( + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized.get("value", []) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get(self, name: str, version: str, **kwargs: Any) -> _types_models2.DatasetVersion: + """Get the specific version of the DatasetVersion. The service returns 404 Not Found error if the + DatasetVersion does not exist. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to retrieve. Required. + :type version: str + :return: DatasetVersion + :rtype: ~azure.ai.agents.types.DatasetVersion + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "uri_file": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_file", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "uri_folder": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_folder", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # response body for status code(s): 200 + response == dataset_version + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_types_models2.DatasetVersion] = kwargs.pop("cls", None) + + _request = build_datasets_get_request( + name=name, + version=version, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete(self, name: str, version: str, **kwargs: Any) -> None: + """Delete the specific version of the DatasetVersion. The service returns 204 No Content if the + DatasetVersion was deleted successfully or if the DatasetVersion does not exist. + + :param name: The name of the resource. Required. + :type name: str + :param version: The version of the DatasetVersion to delete. Required. + :type version: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_datasets_delete_request( + name=name, + version=version, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + async def create_or_update( + self, + name: str, + version: str, + dataset_version: _types_models2.DatasetVersion, + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> _types_models2.DatasetVersion: + """Create a new or update an existing DatasetVersion with the given version id. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to create or update. Required. + :type version: str + :param dataset_version: The DatasetVersion to create or update. Required. + :type dataset_version: ~azure.ai.agents.types.DatasetVersion + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: DatasetVersion + :rtype: ~azure.ai.agents.types.DatasetVersion + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "uri_file": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_file", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "uri_folder": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_folder", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # JSON input template you can fill out and use as your body input. + dataset_version = dataset_version + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "uri_file": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_file", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "uri_folder": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_folder", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "uri_file": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_file", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "uri_folder": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_folder", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # response body for status code(s): 201, 200 + response == dataset_version + """ + + @overload + async def create_or_update( + self, + name: str, + version: str, + dataset_version: IO[bytes], + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> _types_models2.DatasetVersion: + """Create a new or update an existing DatasetVersion with the given version id. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to create or update. Required. + :type version: str + :param dataset_version: The DatasetVersion to create or update. Required. + :type dataset_version: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: DatasetVersion + :rtype: ~azure.ai.agents.types.DatasetVersion + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "uri_file": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_file", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "uri_folder": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_folder", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "uri_file": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_file", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "uri_folder": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_folder", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # response body for status code(s): 201, 200 + response == dataset_version + """ + + @distributed_trace_async + async def create_or_update( + self, name: str, version: str, dataset_version: Union[_types_models2.DatasetVersion, IO[bytes]], **kwargs: Any + ) -> _types_models2.DatasetVersion: + """Create a new or update an existing DatasetVersion with the given version id. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to create or update. Required. + :type version: str + :param dataset_version: The DatasetVersion to create or update. Is either a DatasetVersion type + or a IO[bytes] type. Required. + :type dataset_version: ~azure.ai.agents.types.DatasetVersion or IO[bytes] + :return: DatasetVersion + :rtype: ~azure.ai.agents.types.DatasetVersion + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "uri_file": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_file", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "uri_folder": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_folder", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # JSON input template you can fill out and use as your body input. + dataset_version = dataset_version + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "uri_file": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_file", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "uri_folder": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_folder", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "uri_file": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_file", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "uri_folder": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_folder", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # response body for status code(s): 201, 200 + response == dataset_version + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_types_models2.DatasetVersion] = kwargs.pop("cls", None) + + content_type = content_type or "application/merge-patch+json" + _json = None + _content = None + if isinstance(dataset_version, (IOBase, bytes)): + _content = dataset_version + else: + _json = dataset_version + + _request = build_datasets_create_or_update_request( + name=name, + version=version, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def pending_upload( + self, + name: str, + version: str, + pending_upload_request: _types_models2.PendingUploadRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models2.PendingUploadResponse: + """Start a new or get an existing pending upload of a dataset for a specific version. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to operate on. Required. + :type version: str + :param pending_upload_request: The pending upload request parameters. Required. + :type pending_upload_request: ~azure.ai.agents.types.PendingUploadRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PendingUploadResponse + :rtype: ~azure.ai.agents.types.PendingUploadResponse + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + pending_upload_request = { + "pendingUploadType": "str", + "connectionName": "str", + "pendingUploadId": "str" + } + + # response body for status code(s): 200 + response == { + "blobReference": { + "blobUri": "str", + "credential": { + "sasUri": "str", + "type": "SAS" + }, + "storageAccountArmId": "str" + }, + "pendingUploadId": "str", + "pendingUploadType": "str", + "version": "str" + } + """ + + @overload + async def pending_upload( + self, + name: str, + version: str, + pending_upload_request: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models2.PendingUploadResponse: + """Start a new or get an existing pending upload of a dataset for a specific version. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to operate on. Required. + :type version: str + :param pending_upload_request: The pending upload request parameters. Required. + :type pending_upload_request: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: PendingUploadResponse + :rtype: ~azure.ai.agents.types.PendingUploadResponse + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "blobReference": { + "blobUri": "str", + "credential": { + "sasUri": "str", + "type": "SAS" + }, + "storageAccountArmId": "str" + }, + "pendingUploadId": "str", + "pendingUploadType": "str", + "version": "str" + } + """ + + @distributed_trace_async + async def pending_upload( + self, + name: str, + version: str, + pending_upload_request: Union[_types_models2.PendingUploadRequest, IO[bytes]], + **kwargs: Any + ) -> _types_models2.PendingUploadResponse: + """Start a new or get an existing pending upload of a dataset for a specific version. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to operate on. Required. + :type version: str + :param pending_upload_request: The pending upload request parameters. Is either a + PendingUploadRequest type or a IO[bytes] type. Required. + :type pending_upload_request: ~azure.ai.agents.types.PendingUploadRequest or IO[bytes] + :return: PendingUploadResponse + :rtype: ~azure.ai.agents.types.PendingUploadResponse + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + pending_upload_request = { + "pendingUploadType": "str", + "connectionName": "str", + "pendingUploadId": "str" + } + + # response body for status code(s): 200 + response == { + "blobReference": { + "blobUri": "str", + "credential": { + "sasUri": "str", + "type": "SAS" + }, + "storageAccountArmId": "str" + }, + "pendingUploadId": "str", + "pendingUploadType": "str", + "version": "str" + } + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_types_models2.PendingUploadResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(pending_upload_request, (IOBase, bytes)): + _content = pending_upload_request + else: + _json = pending_upload_request + + _request = build_datasets_pending_upload_request( + name=name, + version=version, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_credentials(self, name: str, version: str, **kwargs: Any) -> _types_models2.DatasetCredential: + """Get the SAS credential to access the storage account associated with a Dataset version. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to operate on. Required. + :type version: str + :return: DatasetCredential + :rtype: ~azure.ai.agents.types.DatasetCredential + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "blobReference": { + "blobUri": "str", + "credential": { + "sasUri": "str", + "type": "SAS" + }, + "storageAccountArmId": "str" + } + } + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_types_models2.DatasetCredential] = kwargs.pop("cls", None) + + _request = build_datasets_get_credentials_request( + name=name, + version=version, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class DeploymentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.agents.aio.AIProjectClient`'s + :attr:`deployments` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, name: str, **kwargs: Any) -> _types_models2.Deployment: + """Get a deployed model. + + :param name: Name of the deployment. Required. + :type name: str + :return: Deployment + :rtype: ~azure.ai.agents.types.Deployment + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "ModelDeployment": + deployment = { + "capabilities": { + "str": "str" + }, + "modelName": "str", + "modelPublisher": "str", + "modelVersion": "str", + "name": "str", + "sku": { + "capacity": 0, + "family": "str", + "name": "str", + "size": "str", + "tier": "str" + }, + "type": "ModelDeployment", + "connectionName": "str" + } + + # response body for status code(s): 200 + response == deployment + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_types_models2.Deployment] = kwargs.pop("cls", None) + + _request = build_deployments_get_request( + name=name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["x-ms-client-request-id"] = self._deserialize( + "str", response.headers.get("x-ms-client-request-id") + ) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, + *, + model_publisher: Optional[str] = None, + model_name: Optional[str] = None, + deployment_type: Optional[types.DeploymentType] = None, + **kwargs: Any + ) -> AsyncItemPaged["_types_models2.Deployment"]: + """List all deployed models in the project. + + :keyword model_publisher: Model publisher to filter models by. Default value is None. + :paramtype model_publisher: str + :keyword model_name: Model name (the publisher specific name) to filter models by. Default + value is None. + :paramtype model_name: str + :keyword deployment_type: Type of deployment to filter list by. "ModelDeployment" Default value + is None. + :paramtype deployment_type: str or ~azure.ai.agents.models.DeploymentType + :return: An iterator like instance of Deployment + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.types.Deployment] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "ModelDeployment": + deployment = { + "capabilities": { + "str": "str" + }, + "modelName": "str", + "modelPublisher": "str", + "modelVersion": "str", + "name": "str", + "sku": { + "capacity": 0, + "family": "str", + "name": "str", + "size": "str", + "tier": "str" + }, + "type": "ModelDeployment", + "connectionName": "str" + } + + # response body for status code(s): 200 + response == deployment + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_types_models2.Deployment]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_deployments_list_request( + model_publisher=model_publisher, + model_name=model_name, + deployment_type=deployment_type, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized.get("value", []) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class IndexesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.agents.aio.AIProjectClient`'s + :attr:`indexes` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_versions(self, name: str, **kwargs: Any) -> AsyncItemPaged["_types_models2.Index"]: + """List all versions of the given Index. + + :param name: The name of the resource. Required. + :type name: str + :return: An iterator like instance of Index + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.types.Index] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AzureSearch": + index = { + "connectionName": "str", + "indexName": "str", + "name": "str", + "type": "AzureSearch", + "version": "str", + "description": "str", + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": + index = { + "connectionName": "str", + "containerName": "str", + "databaseName": "str", + "embeddingConfiguration": { + "embeddingField": "str", + "modelDeploymentName": "str" + }, + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "name": "str", + "type": "CosmosDBNoSqlVectorStore", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "ManagedAzureSearch": + index = { + "name": "str", + "type": "ManagedAzureSearch", + "vectorStoreId": "str", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # response body for status code(s): 200 + response == index + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_types_models2.Index]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_indexes_list_versions_request( + name=name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized.get("value", []) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncItemPaged["_types_models2.Index"]: + """List the latest version of each Index. + + :return: An iterator like instance of Index + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.types.Index] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AzureSearch": + index = { + "connectionName": "str", + "indexName": "str", + "name": "str", + "type": "AzureSearch", + "version": "str", + "description": "str", + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": + index = { + "connectionName": "str", + "containerName": "str", + "databaseName": "str", + "embeddingConfiguration": { + "embeddingField": "str", + "modelDeploymentName": "str" + }, + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "name": "str", + "type": "CosmosDBNoSqlVectorStore", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "ManagedAzureSearch": + index = { + "name": "str", + "type": "ManagedAzureSearch", + "vectorStoreId": "str", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # response body for status code(s): 200 + response == index + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_types_models2.Index]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_indexes_list_request( + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized.get("value", []) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get(self, name: str, version: str, **kwargs: Any) -> _types_models2.Index: + """Get the specific version of the Index. The service returns 404 Not Found error if the Index + does not exist. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the Index to retrieve. Required. + :type version: str + :return: Index + :rtype: ~azure.ai.agents.types.Index + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AzureSearch": + index = { + "connectionName": "str", + "indexName": "str", + "name": "str", + "type": "AzureSearch", + "version": "str", + "description": "str", + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": + index = { + "connectionName": "str", + "containerName": "str", + "databaseName": "str", + "embeddingConfiguration": { + "embeddingField": "str", + "modelDeploymentName": "str" + }, + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "name": "str", + "type": "CosmosDBNoSqlVectorStore", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "ManagedAzureSearch": + index = { + "name": "str", + "type": "ManagedAzureSearch", + "vectorStoreId": "str", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # response body for status code(s): 200 + response == index + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_types_models2.Index] = kwargs.pop("cls", None) + + _request = build_indexes_get_request( + name=name, + version=version, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete(self, name: str, version: str, **kwargs: Any) -> None: + """Delete the specific version of the Index. The service returns 204 No Content if the Index was + deleted successfully or if the Index does not exist. + + :param name: The name of the resource. Required. + :type name: str + :param version: The version of the Index to delete. Required. + :type version: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_indexes_delete_request( + name=name, + version=version, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + async def create_or_update( + self, + name: str, + version: str, + index: _types_models2.Index, + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> _types_models2.Index: + """Create a new or update an existing Index with the given version id. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the Index to create or update. Required. + :type version: str + :param index: The Index to create or update. Required. + :type index: ~azure.ai.agents.types.Index + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: Index + :rtype: ~azure.ai.agents.types.Index + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "AzureSearch": + index = { + "connectionName": "str", + "indexName": "str", + "name": "str", + "type": "AzureSearch", + "version": "str", + "description": "str", + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": + index = { + "connectionName": "str", + "containerName": "str", + "databaseName": "str", + "embeddingConfiguration": { + "embeddingField": "str", + "modelDeploymentName": "str" + }, + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "name": "str", + "type": "CosmosDBNoSqlVectorStore", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "ManagedAzureSearch": + index = { + "name": "str", + "type": "ManagedAzureSearch", + "vectorStoreId": "str", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template you can fill out and use as your body input. + index = index + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AzureSearch": + index = { + "connectionName": "str", + "indexName": "str", + "name": "str", + "type": "AzureSearch", + "version": "str", + "description": "str", + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": + index = { + "connectionName": "str", + "containerName": "str", + "databaseName": "str", + "embeddingConfiguration": { + "embeddingField": "str", + "modelDeploymentName": "str" + }, + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "name": "str", + "type": "CosmosDBNoSqlVectorStore", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "ManagedAzureSearch": + index = { + "name": "str", + "type": "ManagedAzureSearch", + "vectorStoreId": "str", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AzureSearch": + index = { + "connectionName": "str", + "indexName": "str", + "name": "str", + "type": "AzureSearch", + "version": "str", + "description": "str", + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": + index = { + "connectionName": "str", + "containerName": "str", + "databaseName": "str", + "embeddingConfiguration": { + "embeddingField": "str", + "modelDeploymentName": "str" + }, + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "name": "str", + "type": "CosmosDBNoSqlVectorStore", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "ManagedAzureSearch": + index = { + "name": "str", + "type": "ManagedAzureSearch", + "vectorStoreId": "str", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # response body for status code(s): 201, 200 + response == index + """ + + @overload + async def create_or_update( + self, + name: str, + version: str, + index: IO[bytes], + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> _types_models2.Index: + """Create a new or update an existing Index with the given version id. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the Index to create or update. Required. + :type version: str + :param index: The Index to create or update. Required. + :type index: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: Index + :rtype: ~azure.ai.agents.types.Index + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AzureSearch": + index = { + "connectionName": "str", + "indexName": "str", + "name": "str", + "type": "AzureSearch", + "version": "str", + "description": "str", + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": + index = { + "connectionName": "str", + "containerName": "str", + "databaseName": "str", + "embeddingConfiguration": { + "embeddingField": "str", + "modelDeploymentName": "str" + }, + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "name": "str", + "type": "CosmosDBNoSqlVectorStore", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "ManagedAzureSearch": + index = { + "name": "str", + "type": "ManagedAzureSearch", + "vectorStoreId": "str", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AzureSearch": + index = { + "connectionName": "str", + "indexName": "str", + "name": "str", + "type": "AzureSearch", + "version": "str", + "description": "str", + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": + index = { + "connectionName": "str", + "containerName": "str", + "databaseName": "str", + "embeddingConfiguration": { + "embeddingField": "str", + "modelDeploymentName": "str" + }, + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "name": "str", + "type": "CosmosDBNoSqlVectorStore", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "ManagedAzureSearch": + index = { + "name": "str", + "type": "ManagedAzureSearch", + "vectorStoreId": "str", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # response body for status code(s): 201, 200 + response == index + """ + + @distributed_trace_async + async def create_or_update( + self, name: str, version: str, index: Union[_types_models2.Index, IO[bytes]], **kwargs: Any + ) -> _types_models2.Index: + """Create a new or update an existing Index with the given version id. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the Index to create or update. Required. + :type version: str + :param index: The Index to create or update. Is either a Index type or a IO[bytes] type. + Required. + :type index: ~azure.ai.agents.types.Index or IO[bytes] + :return: Index + :rtype: ~azure.ai.agents.types.Index + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "AzureSearch": + index = { + "connectionName": "str", + "indexName": "str", + "name": "str", + "type": "AzureSearch", + "version": "str", + "description": "str", + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": + index = { + "connectionName": "str", + "containerName": "str", + "databaseName": "str", + "embeddingConfiguration": { + "embeddingField": "str", + "modelDeploymentName": "str" + }, + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "name": "str", + "type": "CosmosDBNoSqlVectorStore", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "ManagedAzureSearch": + index = { + "name": "str", + "type": "ManagedAzureSearch", + "vectorStoreId": "str", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template you can fill out and use as your body input. + index = index + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AzureSearch": + index = { + "connectionName": "str", + "indexName": "str", + "name": "str", + "type": "AzureSearch", + "version": "str", + "description": "str", + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": + index = { + "connectionName": "str", + "containerName": "str", + "databaseName": "str", + "embeddingConfiguration": { + "embeddingField": "str", + "modelDeploymentName": "str" + }, + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "name": "str", + "type": "CosmosDBNoSqlVectorStore", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "ManagedAzureSearch": + index = { + "name": "str", + "type": "ManagedAzureSearch", + "vectorStoreId": "str", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AzureSearch": + index = { + "connectionName": "str", + "indexName": "str", + "name": "str", + "type": "AzureSearch", + "version": "str", + "description": "str", + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": + index = { + "connectionName": "str", + "containerName": "str", + "databaseName": "str", + "embeddingConfiguration": { + "embeddingField": "str", + "modelDeploymentName": "str" + }, + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "name": "str", + "type": "CosmosDBNoSqlVectorStore", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "ManagedAzureSearch": + index = { + "name": "str", + "type": "ManagedAzureSearch", + "vectorStoreId": "str", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # response body for status code(s): 201, 200 + response == index + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_types_models2.Index] = kwargs.pop("cls", None) + + content_type = content_type or "application/merge-patch+json" + _json = None + _content = None + if isinstance(index, (IOBase, bytes)): + _content = index + else: + _json = index + + _request = build_indexes_create_or_update_request( + name=name, + version=version, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class _AIProjectClientOperationsMixin( + ClientMixinABC[AsyncPipelineClient[HttpRequest, AsyncHttpResponse], AIProjectClientConfiguration] +): + + @distributed_trace_async + async def delete_job(self, job_id: str, **kwargs: Any) -> None: + """Delete a job. Returns 204 No Content. + + :param job_id: The ID of the job to delete. Required. + :type job_id: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_ai_project_delete_job_request( + job_id=job_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _types_models2.ApiErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class BetaEvaluationTaxonomiesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.agents.aio.AIProjectClient`'s + :attr:`evaluation_taxonomies` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], **kwargs: Any + ) -> _types_models2.EvaluationTaxonomy: + """Get an evaluation run by name. + + :param name: The name of the resource. Required. + :type name: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + :return: EvaluationTaxonomy + :rtype: ~azure.ai.agents.types.EvaluationTaxonomy + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "agent": + evaluation_taxonomy_input = { + "riskCategories": [ + "str" + ], + "target": target, + "type": "agent" + } + + # JSON input template for discriminator value "azure_ai_agent": + target = { + "name": "str", + "type": "azure_ai_agent", + "tool_descriptions": [ + { + "description": "str", + "name": "str" + } + ], + "version": "str" + } + + # JSON input template for discriminator value "azure_ai_model": + target = { + "type": "azure_ai_model", + "model": "str", + "sampling_params": { + "max_completion_tokens": 0, + "seed": 0, + "temperature": 0.0, + "top_p": 0.0 + } + } + + # response body for status code(s): 200 + response == { + "name": "str", + "taxonomyInput": evaluation_taxonomy_input, + "version": "str", + "description": "str", + "id": "str", + "properties": { + "str": "str" + }, + "tags": { + "str": "str" + }, + "taxonomyCategories": [ + { + "id": "str", + "name": "str", + "riskCategory": "str", + "subCategories": [ + { + "enabled": bool, + "id": "str", + "name": "str", + "description": "str", + "properties": { + "str": "str" + } + } + ], + "description": "str", + "properties": { + "str": "str" + } + } + ] + } + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_types_models2.EvaluationTaxonomy] = kwargs.pop("cls", None) + + _request = build_beta_evaluation_taxonomies_get_request( + name=name, + foundry_features=foundry_features, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + input_name: Optional[str] = None, + input_type: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_types_models2.EvaluationTaxonomy"]: + """List evaluation taxonomies. + + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + :keyword input_name: Filter by the evaluation input name. Default value is None. + :paramtype input_name: str + :keyword input_type: Filter by taxonomy input type. Default value is None. + :paramtype input_type: str + :return: An iterator like instance of EvaluationTaxonomy + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.types.EvaluationTaxonomy] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "agent": + evaluation_taxonomy_input = { + "riskCategories": [ + "str" + ], + "target": target, + "type": "agent" + } + + # JSON input template for discriminator value "azure_ai_agent": + target = { + "name": "str", + "type": "azure_ai_agent", + "tool_descriptions": [ + { + "description": "str", + "name": "str" + } + ], + "version": "str" + } + + # JSON input template for discriminator value "azure_ai_model": + target = { + "type": "azure_ai_model", + "model": "str", + "sampling_params": { + "max_completion_tokens": 0, + "seed": 0, + "temperature": 0.0, + "top_p": 0.0 + } + } + + # response body for status code(s): 200 + response == { + "name": "str", + "taxonomyInput": evaluation_taxonomy_input, + "version": "str", + "description": "str", + "id": "str", + "properties": { + "str": "str" + }, + "tags": { + "str": "str" + }, + "taxonomyCategories": [ + { + "id": "str", + "name": "str", + "riskCategory": "str", + "subCategories": [ + { + "enabled": bool, + "id": "str", + "name": "str", + "description": "str", + "properties": { + "str": "str" + } + } + ], + "description": "str", + "properties": { + "str": "str" + } + } + ] + } + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_types_models2.EvaluationTaxonomy]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_beta_evaluation_taxonomies_list_request( + foundry_features=foundry_features, + input_name=input_name, + input_type=input_type, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized.get("value", []) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def delete( + self, name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], **kwargs: Any + ) -> None: + """Delete an evaluation taxonomy by name. + + :param name: The name of the resource. Required. + :type name: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_beta_evaluation_taxonomies_delete_request( + name=name, + foundry_features=foundry_features, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore @overload - async def submit_tool_outputs( + async def create( self, - thread_id: str, - run_id: str, + name: str, + body: _types_models2.EvaluationTaxonomy, *, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], content_type: str = "application/json", - tool_outputs: Optional[List[_models.StructuredToolOutput]] = None, - tool_approvals: Optional[List[_models.ToolApproval]] = None, - stream_parameter: Optional[bool] = None, **kwargs: Any - ) -> _models.ThreadRun: - """Submits outputs from tools as requested by tool calls in a run. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param run_id: Identifier of the run. Required. - :type run_id: str + ) -> _types_models2.EvaluationTaxonomy: + """Create an evaluation taxonomy. + + :param name: The name of the evaluation taxonomy. Required. + :type name: str + :param body: The evaluation taxonomy. Required. + :type body: ~azure.ai.agents.types.EvaluationTaxonomy + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword tool_outputs: A list of tools for which the outputs are being submitted. Default value - is None. - :paramtype tool_outputs: list[~azure.ai.agents.models.StructuredToolOutput] - :keyword tool_approvals: A list of tool approvals allowing data to be sent to tools. Default - value is None. - :paramtype tool_approvals: list[~azure.ai.agents.models.ToolApproval] - :keyword stream_parameter: If true, returns a stream of events that happen during the Run as - SSE, terminating at ``[DONE]``. Default value is None. - :paramtype stream_parameter: bool - :return: ThreadRun. The ThreadRun is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadRun + :return: EvaluationTaxonomy + :rtype: ~azure.ai.agents.types.EvaluationTaxonomy :raises ~azure.core.exceptions.HttpResponseError: - """ - @overload - async def submit_tool_outputs( - self, thread_id: str, run_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ThreadRun: - """Submits outputs from tools as requested by tool calls in a run. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param run_id: Identifier of the run. Required. - :type run_id: str - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ThreadRun. The ThreadRun is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadRun - :raises ~azure.core.exceptions.HttpResponseError: + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "agent": + evaluation_taxonomy_input = { + "riskCategories": [ + "str" + ], + "target": target, + "type": "agent" + } + + # JSON input template for discriminator value "azure_ai_agent": + target = { + "name": "str", + "type": "azure_ai_agent", + "tool_descriptions": [ + { + "description": "str", + "name": "str" + } + ], + "version": "str" + } + + # JSON input template for discriminator value "azure_ai_model": + target = { + "type": "azure_ai_model", + "model": "str", + "sampling_params": { + "max_completion_tokens": 0, + "seed": 0, + "temperature": 0.0, + "top_p": 0.0 + } + } + + # JSON input template you can fill out and use as your body input. + body = { + "name": "str", + "taxonomyInput": evaluation_taxonomy_input, + "version": "str", + "description": "str", + "id": "str", + "properties": { + "str": "str" + }, + "tags": { + "str": "str" + }, + "taxonomyCategories": [ + { + "id": "str", + "name": "str", + "riskCategory": "str", + "subCategories": [ + { + "enabled": bool, + "id": "str", + "name": "str", + "description": "str", + "properties": { + "str": "str" + } + } + ], + "description": "str", + "properties": { + "str": "str" + } + } + ] + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "agent": + evaluation_taxonomy_input = { + "riskCategories": [ + "str" + ], + "target": target, + "type": "agent" + } + + # JSON input template for discriminator value "azure_ai_agent": + target = { + "name": "str", + "type": "azure_ai_agent", + "tool_descriptions": [ + { + "description": "str", + "name": "str" + } + ], + "version": "str" + } + + # JSON input template for discriminator value "azure_ai_model": + target = { + "type": "azure_ai_model", + "model": "str", + "sampling_params": { + "max_completion_tokens": 0, + "seed": 0, + "temperature": 0.0, + "top_p": 0.0 + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "agent": + evaluation_taxonomy_input = { + "riskCategories": [ + "str" + ], + "target": target, + "type": "agent" + } + + # JSON input template for discriminator value "azure_ai_agent": + target = { + "name": "str", + "type": "azure_ai_agent", + "tool_descriptions": [ + { + "description": "str", + "name": "str" + } + ], + "version": "str" + } + + # JSON input template for discriminator value "azure_ai_model": + target = { + "type": "azure_ai_model", + "model": "str", + "sampling_params": { + "max_completion_tokens": 0, + "seed": 0, + "temperature": 0.0, + "top_p": 0.0 + } + } + + # response body for status code(s): 201, 200 + response == { + "name": "str", + "taxonomyInput": evaluation_taxonomy_input, + "version": "str", + "description": "str", + "id": "str", + "properties": { + "str": "str" + }, + "tags": { + "str": "str" + }, + "taxonomyCategories": [ + { + "id": "str", + "name": "str", + "riskCategory": "str", + "subCategories": [ + { + "enabled": bool, + "id": "str", + "name": "str", + "description": "str", + "properties": { + "str": "str" + } + } + ], + "description": "str", + "properties": { + "str": "str" + } + } + ] + } """ @overload - async def submit_tool_outputs( - self, thread_id: str, run_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ThreadRun: - """Submits outputs from tools as requested by tool calls in a run. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param run_id: Identifier of the run. Required. - :type run_id: str - :param body: Required. + async def create( + self, + name: str, + body: IO[bytes], + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models2.EvaluationTaxonomy: + """Create an evaluation taxonomy. + + :param name: The name of the evaluation taxonomy. Required. + :type name: str + :param body: The evaluation taxonomy. Required. :type body: IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: ThreadRun. The ThreadRun is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadRun + :return: EvaluationTaxonomy + :rtype: ~azure.ai.agents.types.EvaluationTaxonomy :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "agent": + evaluation_taxonomy_input = { + "riskCategories": [ + "str" + ], + "target": target, + "type": "agent" + } + + # JSON input template for discriminator value "azure_ai_agent": + target = { + "name": "str", + "type": "azure_ai_agent", + "tool_descriptions": [ + { + "description": "str", + "name": "str" + } + ], + "version": "str" + } + + # JSON input template for discriminator value "azure_ai_model": + target = { + "type": "azure_ai_model", + "model": "str", + "sampling_params": { + "max_completion_tokens": 0, + "seed": 0, + "temperature": 0.0, + "top_p": 0.0 + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "agent": + evaluation_taxonomy_input = { + "riskCategories": [ + "str" + ], + "target": target, + "type": "agent" + } + + # JSON input template for discriminator value "azure_ai_agent": + target = { + "name": "str", + "type": "azure_ai_agent", + "tool_descriptions": [ + { + "description": "str", + "name": "str" + } + ], + "version": "str" + } + + # JSON input template for discriminator value "azure_ai_model": + target = { + "type": "azure_ai_model", + "model": "str", + "sampling_params": { + "max_completion_tokens": 0, + "seed": 0, + "temperature": 0.0, + "top_p": 0.0 + } + } + + # response body for status code(s): 201, 200 + response == { + "name": "str", + "taxonomyInput": evaluation_taxonomy_input, + "version": "str", + "description": "str", + "id": "str", + "properties": { + "str": "str" + }, + "tags": { + "str": "str" + }, + "taxonomyCategories": [ + { + "id": "str", + "name": "str", + "riskCategory": "str", + "subCategories": [ + { + "enabled": bool, + "id": "str", + "name": "str", + "description": "str", + "properties": { + "str": "str" + } + } + ], + "description": "str", + "properties": { + "str": "str" + } + } + ] + } """ @distributed_trace_async - async def submit_tool_outputs( + async def create( self, - thread_id: str, - run_id: str, - body: Union[JSON, IO[bytes]] = _Unset, + name: str, + body: Union[_types_models2.EvaluationTaxonomy, IO[bytes]], *, - tool_outputs: Optional[List[_models.StructuredToolOutput]] = None, - tool_approvals: Optional[List[_models.ToolApproval]] = None, - stream_parameter: Optional[bool] = None, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], **kwargs: Any - ) -> _models.ThreadRun: - """Submits outputs from tools as requested by tool calls in a run. + ) -> _types_models2.EvaluationTaxonomy: + """Create an evaluation taxonomy. - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param run_id: Identifier of the run. Required. - :type run_id: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword tool_outputs: A list of tools for which the outputs are being submitted. Default value - is None. - :paramtype tool_outputs: list[~azure.ai.agents.models.StructuredToolOutput] - :keyword tool_approvals: A list of tool approvals allowing data to be sent to tools. Default - value is None. - :paramtype tool_approvals: list[~azure.ai.agents.models.ToolApproval] - :keyword stream_parameter: If true, returns a stream of events that happen during the Run as - SSE, terminating at ``[DONE]``. Default value is None. - :paramtype stream_parameter: bool - :return: ThreadRun. The ThreadRun is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadRun + :param name: The name of the evaluation taxonomy. Required. + :type name: str + :param body: The evaluation taxonomy. Is either a EvaluationTaxonomy type or a IO[bytes] type. + Required. + :type body: ~azure.ai.agents.types.EvaluationTaxonomy or IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + :return: EvaluationTaxonomy + :rtype: ~azure.ai.agents.types.EvaluationTaxonomy :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "agent": + evaluation_taxonomy_input = { + "riskCategories": [ + "str" + ], + "target": target, + "type": "agent" + } + + # JSON input template for discriminator value "azure_ai_agent": + target = { + "name": "str", + "type": "azure_ai_agent", + "tool_descriptions": [ + { + "description": "str", + "name": "str" + } + ], + "version": "str" + } + + # JSON input template for discriminator value "azure_ai_model": + target = { + "type": "azure_ai_model", + "model": "str", + "sampling_params": { + "max_completion_tokens": 0, + "seed": 0, + "temperature": 0.0, + "top_p": 0.0 + } + } + + # JSON input template you can fill out and use as your body input. + body = { + "name": "str", + "taxonomyInput": evaluation_taxonomy_input, + "version": "str", + "description": "str", + "id": "str", + "properties": { + "str": "str" + }, + "tags": { + "str": "str" + }, + "taxonomyCategories": [ + { + "id": "str", + "name": "str", + "riskCategory": "str", + "subCategories": [ + { + "enabled": bool, + "id": "str", + "name": "str", + "description": "str", + "properties": { + "str": "str" + } + } + ], + "description": "str", + "properties": { + "str": "str" + } + } + ] + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "agent": + evaluation_taxonomy_input = { + "riskCategories": [ + "str" + ], + "target": target, + "type": "agent" + } + + # JSON input template for discriminator value "azure_ai_agent": + target = { + "name": "str", + "type": "azure_ai_agent", + "tool_descriptions": [ + { + "description": "str", + "name": "str" + } + ], + "version": "str" + } + + # JSON input template for discriminator value "azure_ai_model": + target = { + "type": "azure_ai_model", + "model": "str", + "sampling_params": { + "max_completion_tokens": 0, + "seed": 0, + "temperature": 0.0, + "top_p": 0.0 + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "agent": + evaluation_taxonomy_input = { + "riskCategories": [ + "str" + ], + "target": target, + "type": "agent" + } + + # JSON input template for discriminator value "azure_ai_agent": + target = { + "name": "str", + "type": "azure_ai_agent", + "tool_descriptions": [ + { + "description": "str", + "name": "str" + } + ], + "version": "str" + } + + # JSON input template for discriminator value "azure_ai_model": + target = { + "type": "azure_ai_model", + "model": "str", + "sampling_params": { + "max_completion_tokens": 0, + "seed": 0, + "temperature": 0.0, + "top_p": 0.0 + } + } + + # response body for status code(s): 201, 200 + response == { + "name": "str", + "taxonomyInput": evaluation_taxonomy_input, + "version": "str", + "description": "str", + "id": "str", + "properties": { + "str": "str" + }, + "tags": { + "str": "str" + }, + "taxonomyCategories": [ + { + "id": "str", + "name": "str", + "riskCategory": "str", + "subCategories": [ + { + "enabled": bool, + "id": "str", + "name": "str", + "description": "str", + "properties": { + "str": "str" + } + } + ], + "description": "str", + "properties": { + "str": "str" + } + } + ] + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2047,23 +8499,22 @@ async def submit_tool_outputs( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ThreadRun] = kwargs.pop("cls", None) + cls: ClsType[_types_models2.EvaluationTaxonomy] = kwargs.pop("cls", None) - if body is _Unset: - body = {"stream": stream_parameter, "tool_approvals": tool_approvals, "tool_outputs": tool_outputs} - body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" + _json = None _content = None if isinstance(body, (IOBase, bytes)): _content = body else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _json = body - _request = build_runs_submit_tool_outputs_request( - thread_id=thread_id, - run_id=run_id, + _request = build_beta_evaluation_taxonomies_create_request( + name=name, + foundry_features=foundry_features, content_type=content_type, api_version=self._config.api_version, + json=_json, content=_content, headers=_headers, params=_params, @@ -2073,6 +8524,7 @@ async def submit_tool_outputs( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -2080,37 +8532,483 @@ async def submit_tool_outputs( response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 201]: if _stream: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.ThreadRun, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + @overload + async def update( + self, + name: str, + body: _types_models2.EvaluationTaxonomy, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models2.EvaluationTaxonomy: + """Update an evaluation taxonomy. + + :param name: The name of the evaluation taxonomy. Required. + :type name: str + :param body: The evaluation taxonomy. Required. + :type body: ~azure.ai.agents.types.EvaluationTaxonomy + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: EvaluationTaxonomy + :rtype: ~azure.ai.agents.types.EvaluationTaxonomy + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "agent": + evaluation_taxonomy_input = { + "riskCategories": [ + "str" + ], + "target": target, + "type": "agent" + } + + # JSON input template for discriminator value "azure_ai_agent": + target = { + "name": "str", + "type": "azure_ai_agent", + "tool_descriptions": [ + { + "description": "str", + "name": "str" + } + ], + "version": "str" + } + + # JSON input template for discriminator value "azure_ai_model": + target = { + "type": "azure_ai_model", + "model": "str", + "sampling_params": { + "max_completion_tokens": 0, + "seed": 0, + "temperature": 0.0, + "top_p": 0.0 + } + } + + # JSON input template you can fill out and use as your body input. + body = { + "name": "str", + "taxonomyInput": evaluation_taxonomy_input, + "version": "str", + "description": "str", + "id": "str", + "properties": { + "str": "str" + }, + "tags": { + "str": "str" + }, + "taxonomyCategories": [ + { + "id": "str", + "name": "str", + "riskCategory": "str", + "subCategories": [ + { + "enabled": bool, + "id": "str", + "name": "str", + "description": "str", + "properties": { + "str": "str" + } + } + ], + "description": "str", + "properties": { + "str": "str" + } + } + ] + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "agent": + evaluation_taxonomy_input = { + "riskCategories": [ + "str" + ], + "target": target, + "type": "agent" + } + + # JSON input template for discriminator value "azure_ai_agent": + target = { + "name": "str", + "type": "azure_ai_agent", + "tool_descriptions": [ + { + "description": "str", + "name": "str" + } + ], + "version": "str" + } + + # JSON input template for discriminator value "azure_ai_model": + target = { + "type": "azure_ai_model", + "model": "str", + "sampling_params": { + "max_completion_tokens": 0, + "seed": 0, + "temperature": 0.0, + "top_p": 0.0 + } + } + + # response body for status code(s): 200 + response == { + "name": "str", + "taxonomyInput": evaluation_taxonomy_input, + "version": "str", + "description": "str", + "id": "str", + "properties": { + "str": "str" + }, + "tags": { + "str": "str" + }, + "taxonomyCategories": [ + { + "id": "str", + "name": "str", + "riskCategory": "str", + "subCategories": [ + { + "enabled": bool, + "id": "str", + "name": "str", + "description": "str", + "properties": { + "str": "str" + } + } + ], + "description": "str", + "properties": { + "str": "str" + } + } + ] + } + """ + + @overload + async def update( + self, + name: str, + body: IO[bytes], + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models2.EvaluationTaxonomy: + """Update an evaluation taxonomy. + + :param name: The name of the evaluation taxonomy. Required. + :type name: str + :param body: The evaluation taxonomy. Required. + :type body: IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: EvaluationTaxonomy + :rtype: ~azure.ai.agents.types.EvaluationTaxonomy + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "agent": + evaluation_taxonomy_input = { + "riskCategories": [ + "str" + ], + "target": target, + "type": "agent" + } + + # JSON input template for discriminator value "azure_ai_agent": + target = { + "name": "str", + "type": "azure_ai_agent", + "tool_descriptions": [ + { + "description": "str", + "name": "str" + } + ], + "version": "str" + } + + # JSON input template for discriminator value "azure_ai_model": + target = { + "type": "azure_ai_model", + "model": "str", + "sampling_params": { + "max_completion_tokens": 0, + "seed": 0, + "temperature": 0.0, + "top_p": 0.0 + } + } + + # response body for status code(s): 200 + response == { + "name": "str", + "taxonomyInput": evaluation_taxonomy_input, + "version": "str", + "description": "str", + "id": "str", + "properties": { + "str": "str" + }, + "tags": { + "str": "str" + }, + "taxonomyCategories": [ + { + "id": "str", + "name": "str", + "riskCategory": "str", + "subCategories": [ + { + "enabled": bool, + "id": "str", + "name": "str", + "description": "str", + "properties": { + "str": "str" + } + } + ], + "description": "str", + "properties": { + "str": "str" + } + } + ] + } + """ + @distributed_trace_async - async def cancel(self, thread_id: str, run_id: str, **kwargs: Any) -> _models.ThreadRun: - """Cancels a run of an in‐progress thread. + async def update( + self, + name: str, + body: Union[_types_models2.EvaluationTaxonomy, IO[bytes]], + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + **kwargs: Any + ) -> _types_models2.EvaluationTaxonomy: + """Update an evaluation taxonomy. - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param run_id: Identifier of the run. Required. - :type run_id: str - :return: ThreadRun. The ThreadRun is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadRun + :param name: The name of the evaluation taxonomy. Required. + :type name: str + :param body: The evaluation taxonomy. Is either a EvaluationTaxonomy type or a IO[bytes] type. + Required. + :type body: ~azure.ai.agents.types.EvaluationTaxonomy or IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + :return: EvaluationTaxonomy + :rtype: ~azure.ai.agents.types.EvaluationTaxonomy :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "agent": + evaluation_taxonomy_input = { + "riskCategories": [ + "str" + ], + "target": target, + "type": "agent" + } + + # JSON input template for discriminator value "azure_ai_agent": + target = { + "name": "str", + "type": "azure_ai_agent", + "tool_descriptions": [ + { + "description": "str", + "name": "str" + } + ], + "version": "str" + } + + # JSON input template for discriminator value "azure_ai_model": + target = { + "type": "azure_ai_model", + "model": "str", + "sampling_params": { + "max_completion_tokens": 0, + "seed": 0, + "temperature": 0.0, + "top_p": 0.0 + } + } + + # JSON input template you can fill out and use as your body input. + body = { + "name": "str", + "taxonomyInput": evaluation_taxonomy_input, + "version": "str", + "description": "str", + "id": "str", + "properties": { + "str": "str" + }, + "tags": { + "str": "str" + }, + "taxonomyCategories": [ + { + "id": "str", + "name": "str", + "riskCategory": "str", + "subCategories": [ + { + "enabled": bool, + "id": "str", + "name": "str", + "description": "str", + "properties": { + "str": "str" + } + } + ], + "description": "str", + "properties": { + "str": "str" + } + } + ] + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "agent": + evaluation_taxonomy_input = { + "riskCategories": [ + "str" + ], + "target": target, + "type": "agent" + } + + # JSON input template for discriminator value "azure_ai_agent": + target = { + "name": "str", + "type": "azure_ai_agent", + "tool_descriptions": [ + { + "description": "str", + "name": "str" + } + ], + "version": "str" + } + + # JSON input template for discriminator value "azure_ai_model": + target = { + "type": "azure_ai_model", + "model": "str", + "sampling_params": { + "max_completion_tokens": 0, + "seed": 0, + "temperature": 0.0, + "top_p": 0.0 + } + } + + # response body for status code(s): 200 + response == { + "name": "str", + "taxonomyInput": evaluation_taxonomy_input, + "version": "str", + "description": "str", + "id": "str", + "properties": { + "str": "str" + }, + "tags": { + "str": "str" + }, + "taxonomyCategories": [ + { + "id": "str", + "name": "str", + "riskCategory": "str", + "subCategories": [ + { + "enabled": bool, + "id": "str", + "name": "str", + "description": "str", + "properties": { + "str": "str" + } + } + ], + "description": "str", + "properties": { + "str": "str" + } + } + ] + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2120,15 +9018,27 @@ async def cancel(self, thread_id: str, run_id: str, **kwargs: Any) -> _models.Th } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.ThreadRun] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_types_models2.EvaluationTaxonomy] = kwargs.pop("cls", None) - _request = build_runs_cancel_request( - thread_id=thread_id, - run_id=run_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_beta_evaluation_taxonomies_update_request( + name=name, + foundry_features=foundry_features, + content_type=content_type, api_version=self._config.api_version, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -2137,6 +9047,7 @@ async def cancel(self, thread_id: str, run_id: str, **kwargs: Any) -> _models.Th } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -2151,13 +9062,15 @@ async def cancel(self, thread_id: str, run_id: str, **kwargs: Any) -> _models.Th except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.ThreadRun, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -2165,50 +9078,127 @@ async def cancel(self, thread_id: str, run_id: str, **kwargs: Any) -> _models.Th return deserialized # type: ignore -class RunStepsOperations: +class BetaEvaluatorsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.ai.agents.aio.AgentsClient`'s - :attr:`run_steps` attribute. + :class:`~azure.ai.agents.aio.AIProjectClient`'s + :attr:`evaluators` attribute. """ def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AgentsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def get( + @distributed_trace + def list_versions( self, - thread_id: str, - run_id: str, - step_id: str, + name: str, *, - include: Optional[List[Union[str, _models.RunAdditionalFieldList]]] = None, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + type: Optional[Union[Literal["builtin"], Literal["custom"], Literal["all"], str]] = None, + limit: Optional[int] = None, **kwargs: Any - ) -> _models.RunStep: - """Retrieves a single run step from a thread run. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param run_id: Identifier of the run. Required. - :type run_id: str - :param step_id: Identifier of the run step. Required. - :type step_id: str - :keyword 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. Default value is None. - :paramtype include: list[str or ~azure.ai.agents.models.RunAdditionalFieldList] - :return: RunStep. The RunStep is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.RunStep + ) -> AsyncItemPaged["_types_models2.EvaluatorVersion"]: + """List all versions of the given evaluator. + + :param name: The name of the resource. Required. + :type name: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + :keyword type: Filter evaluators by type. Possible values: 'all', 'custom', 'builtin'. Is one + of the following types: Literal["builtin"], Literal["custom"], Literal["all"], str Default + value is None. + :paramtype type: str or str or str or str + :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and + 100, and the default is 20. Default value is None. + :paramtype limit: int + :return: An iterator like instance of EvaluatorVersion + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.types.EvaluatorVersion] :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "code": + evaluator_definition = { + "code_text": "str", + "type": "code", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # JSON input template for discriminator value "prompt": + evaluator_definition = { + "prompt_text": "str", + "type": "prompt", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # response body for status code(s): 200 + response == { + "categories": [ + "str" + ], + "created_at": "2020-02-20 00:00:00", + "created_by": "str", + "definition": evaluator_definition, + "evaluator_type": "str", + "modified_at": "2020-02-20 00:00:00", + "name": "str", + "version": "str", + "description": "str", + "display_name": "str", + "id": "str", + "metadata": { + "str": "str" + }, + "tags": { + "str": "str" + } + } """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_types_models2.EvaluatorVersion]] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2217,94 +9207,174 @@ async def get( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.RunStep] = kwargs.pop("cls", None) + def prepare_request(next_link=None): + if not next_link: + + _request = build_beta_evaluators_list_versions_request( + name=name, + foundry_features=foundry_features, + type=type, + limit=limit, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - _request = build_run_steps_get_request( - thread_id=thread_id, - run_id=run_id, - step_id=step_id, - include=include, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized.get("value", []) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - response = pipeline_response.http_response + async def get_next(next_link=None): + _request = prepare_request(next_link) - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.RunStep, response.json()) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return pipeline_response - return deserialized # type: ignore + return AsyncItemPaged(get_next, extract_data) @distributed_trace def list( self, - thread_id: str, - run_id: str, *, - include: Optional[List[Union[str, _models.RunAdditionalFieldList]]] = None, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + type: Optional[Union[Literal["builtin"], Literal["custom"], Literal["all"], str]] = None, limit: Optional[int] = None, - order: Optional[Union[str, _models.ListSortOrder]] = None, - before: Optional[str] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.RunStep"]: - """Gets a list of run steps from a thread run. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param run_id: Identifier of the run. Required. - :type run_id: str - :keyword 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. Default value is None. - :paramtype include: list[str or ~azure.ai.agents.models.RunAdditionalFieldList] + ) -> AsyncItemPaged["_types_models2.EvaluatorVersion"]: + """List the latest version of each evaluator. + + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + :keyword type: Filter evaluators by type. Possible values: 'all', 'custom', 'builtin'. Is one + of the following types: Literal["builtin"], Literal["custom"], Literal["all"], str Default + value is None. + :paramtype type: str or str or str or str :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. Default value is None. :paramtype limit: int - :keyword order: Sort order by the created_at timestamp of the objects. asc for ascending order - and desc for descending order. Known values are: "asc" and "desc". Default value is None. - :paramtype order: str or ~azure.ai.agents.models.ListSortOrder - :keyword 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. Default value is None. - :paramtype before: str - :return: An iterator like instance of RunStep - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.models.RunStep] + :return: An iterator like instance of EvaluatorVersion + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.types.EvaluatorVersion] :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "code": + evaluator_definition = { + "code_text": "str", + "type": "code", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # JSON input template for discriminator value "prompt": + evaluator_definition = { + "prompt_text": "str", + "type": "prompt", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # response body for status code(s): 200 + response == { + "categories": [ + "str" + ], + "created_at": "2020-02-20 00:00:00", + "created_by": "str", + "definition": evaluator_definition, + "evaluator_type": "str", + "modified_at": "2020-02-20 00:00:00", + "name": "str", + "version": "str", + "description": "str", + "display_name": "str", + "id": "str", + "metadata": { + "str": "str" + }, + "tags": { + "str": "str" + } + } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.RunStep]] = kwargs.pop("cls", None) + cls: ClsType[List[_types_models2.EvaluatorVersion]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2314,35 +9384,58 @@ def list( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(_continuation_token=None): + def prepare_request(next_link=None): + if not next_link: + + _request = build_beta_evaluators_list_request( + foundry_features=foundry_features, + type=type, + limit=limit, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - _request = build_run_steps_list_request( - thread_id=thread_id, - run_id=run_id, - include=include, - limit=limit, - order=order, - after=_continuation_token, - before=before, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) return _request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.RunStep], deserialized.get("data", [])) + list_of_elem = deserialized.get("value", []) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("last_id") or None, AsyncList(list_of_elem) + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - async def get_next(_continuation_token=None): - _request = prepare_request(_continuation_token) + async def get_next(next_link=None): + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access @@ -2352,43 +9445,105 @@ async def get_next(_continuation_token=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) return pipeline_response return AsyncItemPaged(get_next, extract_data) - -class FilesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.agents.aio.AgentsClient`'s - :attr:`files` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AgentsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def list( - self, *, purpose: Optional[Union[str, _models.FilePurpose]] = None, **kwargs: Any - ) -> _models.FileListResponse: - """Gets a list of previously uploaded files. - - :keyword purpose: The purpose of the file. Known values are: "assistants", "assistants_output", - and "vision". Default value is None. - :paramtype purpose: str or ~azure.ai.agents.models.FilePurpose - :return: FileListResponse. The FileListResponse is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.FileListResponse + async def get_version( + self, + name: str, + version: str, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + **kwargs: Any + ) -> _types_models2.EvaluatorVersion: + """Get the specific version of the EvaluatorVersion. The service returns 404 Not Found error if + the EvaluatorVersion does not exist. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the EvaluatorVersion to retrieve. Required. + :type version: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + :return: EvaluatorVersion + :rtype: ~azure.ai.agents.types.EvaluatorVersion :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "code": + evaluator_definition = { + "code_text": "str", + "type": "code", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # JSON input template for discriminator value "prompt": + evaluator_definition = { + "prompt_text": "str", + "type": "prompt", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # response body for status code(s): 200 + response == { + "categories": [ + "str" + ], + "created_at": "2020-02-20 00:00:00", + "created_by": "str", + "definition": evaluator_definition, + "evaluator_type": "str", + "modified_at": "2020-02-20 00:00:00", + "name": "str", + "version": "str", + "description": "str", + "display_name": "str", + "id": "str", + "metadata": { + "str": "str" + }, + "tags": { + "str": "str" + } + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2401,10 +9556,12 @@ async def list( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.FileListResponse] = kwargs.pop("cls", None) + cls: ClsType[_types_models2.EvaluatorVersion] = kwargs.pop("cls", None) - _request = build_files_list_request( - purpose=purpose, + _request = build_beta_evaluators_get_version_request( + name=name, + version=version, + foundry_features=foundry_features, api_version=self._config.api_version, headers=_headers, params=_params, @@ -2414,6 +9571,7 @@ async def list( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -2428,35 +9586,508 @@ async def list( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.FileListResponse, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + @distributed_trace_async + async def delete_version( + self, + name: str, + version: str, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + **kwargs: Any + ) -> None: + """Delete the specific version of the EvaluatorVersion. The service returns 204 No Content if the + EvaluatorVersion was deleted successfully or if the EvaluatorVersion does not exist. + + :param name: The name of the resource. Required. + :type name: str + :param version: The version of the EvaluatorVersion to delete. Required. + :type version: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_beta_evaluators_delete_version_request( + name=name, + version=version, + foundry_features=foundry_features, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + @overload - async def _upload_file(self, body: _models._models.UploadFileRequest, **kwargs: Any) -> _models.FileInfo: ... + async def create_version( + self, + name: str, + evaluator_version: _types_models2.EvaluatorVersion, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models2.EvaluatorVersion: + """Create a new EvaluatorVersion with auto incremented version id. + + :param name: The name of the resource. Required. + :type name: str + :param evaluator_version: Required. + :type evaluator_version: ~azure.ai.agents.types.EvaluatorVersion + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: EvaluatorVersion + :rtype: ~azure.ai.agents.types.EvaluatorVersion + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "code": + evaluator_definition = { + "code_text": "str", + "type": "code", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # JSON input template for discriminator value "prompt": + evaluator_definition = { + "prompt_text": "str", + "type": "prompt", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # JSON input template you can fill out and use as your body input. + evaluator_version = { + "categories": [ + "str" + ], + "created_at": "2020-02-20 00:00:00", + "created_by": "str", + "definition": evaluator_definition, + "evaluator_type": "str", + "modified_at": "2020-02-20 00:00:00", + "name": "str", + "version": "str", + "description": "str", + "display_name": "str", + "id": "str", + "metadata": { + "str": "str" + }, + "tags": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "code": + evaluator_definition = { + "code_text": "str", + "type": "code", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # JSON input template for discriminator value "prompt": + evaluator_definition = { + "prompt_text": "str", + "type": "prompt", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # response body for status code(s): 201 + response == { + "categories": [ + "str" + ], + "created_at": "2020-02-20 00:00:00", + "created_by": "str", + "definition": evaluator_definition, + "evaluator_type": "str", + "modified_at": "2020-02-20 00:00:00", + "name": "str", + "version": "str", + "description": "str", + "display_name": "str", + "id": "str", + "metadata": { + "str": "str" + }, + "tags": { + "str": "str" + } + } + """ + @overload - async def _upload_file(self, body: JSON, **kwargs: Any) -> _models.FileInfo: ... + async def create_version( + self, + name: str, + evaluator_version: IO[bytes], + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models2.EvaluatorVersion: + """Create a new EvaluatorVersion with auto incremented version id. + + :param name: The name of the resource. Required. + :type name: str + :param evaluator_version: Required. + :type evaluator_version: IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: EvaluatorVersion + :rtype: ~azure.ai.agents.types.EvaluatorVersion + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "code": + evaluator_definition = { + "code_text": "str", + "type": "code", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # JSON input template for discriminator value "prompt": + evaluator_definition = { + "prompt_text": "str", + "type": "prompt", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # response body for status code(s): 201 + response == { + "categories": [ + "str" + ], + "created_at": "2020-02-20 00:00:00", + "created_by": "str", + "definition": evaluator_definition, + "evaluator_type": "str", + "modified_at": "2020-02-20 00:00:00", + "name": "str", + "version": "str", + "description": "str", + "display_name": "str", + "id": "str", + "metadata": { + "str": "str" + }, + "tags": { + "str": "str" + } + } + """ @distributed_trace_async - async def _upload_file( - self, body: Union[_models._models.UploadFileRequest, JSON], **kwargs: Any - ) -> _models.FileInfo: - """Uploads a file for use by other operations. - - :param body: Multipart body. Is either a UploadFileRequest type or a JSON type. Required. - :type body: ~azure.ai.agents.models._models.UploadFileRequest or JSON - :return: FileInfo. The FileInfo is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.FileInfo + async def create_version( + self, + name: str, + evaluator_version: Union[_types_models2.EvaluatorVersion, IO[bytes]], + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + **kwargs: Any + ) -> _types_models2.EvaluatorVersion: + """Create a new EvaluatorVersion with auto incremented version id. + + :param name: The name of the resource. Required. + :type name: str + :param evaluator_version: Is either a EvaluatorVersion type or a IO[bytes] type. Required. + :type evaluator_version: ~azure.ai.agents.types.EvaluatorVersion or IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + :return: EvaluatorVersion + :rtype: ~azure.ai.agents.types.EvaluatorVersion :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "code": + evaluator_definition = { + "code_text": "str", + "type": "code", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # JSON input template for discriminator value "prompt": + evaluator_definition = { + "prompt_text": "str", + "type": "prompt", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # JSON input template you can fill out and use as your body input. + evaluator_version = { + "categories": [ + "str" + ], + "created_at": "2020-02-20 00:00:00", + "created_by": "str", + "definition": evaluator_definition, + "evaluator_type": "str", + "modified_at": "2020-02-20 00:00:00", + "name": "str", + "version": "str", + "description": "str", + "display_name": "str", + "id": "str", + "metadata": { + "str": "str" + }, + "tags": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "code": + evaluator_definition = { + "code_text": "str", + "type": "code", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # JSON input template for discriminator value "prompt": + evaluator_definition = { + "prompt_text": "str", + "type": "prompt", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # response body for status code(s): 201 + response == { + "categories": [ + "str" + ], + "created_at": "2020-02-20 00:00:00", + "created_by": "str", + "definition": evaluator_definition, + "evaluator_type": "str", + "modified_at": "2020-02-20 00:00:00", + "name": "str", + "version": "str", + "description": "str", + "display_name": "str", + "id": "str", + "metadata": { + "str": "str" + }, + "tags": { + "str": "str" + } + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2466,20 +10097,27 @@ async def _upload_file( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.FileInfo] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_types_models2.EvaluatorVersion] = kwargs.pop("cls", None) - _body = body.as_dict() if isinstance(body, _Model) else body - _file_fields: list[str] = ["file"] - _data_fields: list[str] = ["purpose", "filename"] - _files, _data = prepare_multipart_form_data(_body, _file_fields, _data_fields) + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(evaluator_version, (IOBase, bytes)): + _content = evaluator_version + else: + _json = evaluator_version - _request = build_files_upload_file_request( + _request = build_beta_evaluators_create_version_request( + name=name, + foundry_features=foundry_features, + content_type=content_type, api_version=self._config.api_version, - files=_files, - data=_data, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -2488,6 +10126,7 @@ async def _upload_file( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -2495,35 +10134,462 @@ async def _upload_file( response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [201]: if _stream: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.FileInfo, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace_async - async def _delete_file(self, file_id: str, **kwargs: Any) -> _models._models.FileDeletionStatus: - """Delete a previously uploaded file. + @overload + async def update_version( + self, + name: str, + version: str, + evaluator_version: _types_models2.EvaluatorVersion, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models2.EvaluatorVersion: + """Update an existing EvaluatorVersion with the given version id. + + :param name: The name of the resource. Required. + :type name: str + :param version: The version of the EvaluatorVersion to update. Required. + :type version: str + :param evaluator_version: Evaluator resource. Required. + :type evaluator_version: ~azure.ai.agents.types.EvaluatorVersion + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: EvaluatorVersion + :rtype: ~azure.ai.agents.types.EvaluatorVersion + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "code": + evaluator_definition = { + "code_text": "str", + "type": "code", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # JSON input template for discriminator value "prompt": + evaluator_definition = { + "prompt_text": "str", + "type": "prompt", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # JSON input template you can fill out and use as your body input. + evaluator_version = { + "categories": [ + "str" + ], + "created_at": "2020-02-20 00:00:00", + "created_by": "str", + "definition": evaluator_definition, + "evaluator_type": "str", + "modified_at": "2020-02-20 00:00:00", + "name": "str", + "version": "str", + "description": "str", + "display_name": "str", + "id": "str", + "metadata": { + "str": "str" + }, + "tags": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "code": + evaluator_definition = { + "code_text": "str", + "type": "code", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # JSON input template for discriminator value "prompt": + evaluator_definition = { + "prompt_text": "str", + "type": "prompt", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # response body for status code(s): 200 + response == { + "categories": [ + "str" + ], + "created_at": "2020-02-20 00:00:00", + "created_by": "str", + "definition": evaluator_definition, + "evaluator_type": "str", + "modified_at": "2020-02-20 00:00:00", + "name": "str", + "version": "str", + "description": "str", + "display_name": "str", + "id": "str", + "metadata": { + "str": "str" + }, + "tags": { + "str": "str" + } + } + """ + + @overload + async def update_version( + self, + name: str, + version: str, + evaluator_version: IO[bytes], + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models2.EvaluatorVersion: + """Update an existing EvaluatorVersion with the given version id. + + :param name: The name of the resource. Required. + :type name: str + :param version: The version of the EvaluatorVersion to update. Required. + :type version: str + :param evaluator_version: Evaluator resource. Required. + :type evaluator_version: IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: EvaluatorVersion + :rtype: ~azure.ai.agents.types.EvaluatorVersion + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "code": + evaluator_definition = { + "code_text": "str", + "type": "code", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # JSON input template for discriminator value "prompt": + evaluator_definition = { + "prompt_text": "str", + "type": "prompt", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # response body for status code(s): 200 + response == { + "categories": [ + "str" + ], + "created_at": "2020-02-20 00:00:00", + "created_by": "str", + "definition": evaluator_definition, + "evaluator_type": "str", + "modified_at": "2020-02-20 00:00:00", + "name": "str", + "version": "str", + "description": "str", + "display_name": "str", + "id": "str", + "metadata": { + "str": "str" + }, + "tags": { + "str": "str" + } + } + """ - :param file_id: The ID of the file to delete. Required. - :type file_id: str - :return: FileDeletionStatus. The FileDeletionStatus is compatible with MutableMapping - :rtype: ~azure.ai.agents.models._models.FileDeletionStatus + @distributed_trace_async + async def update_version( + self, + name: str, + version: str, + evaluator_version: Union[_types_models2.EvaluatorVersion, IO[bytes]], + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + **kwargs: Any + ) -> _types_models2.EvaluatorVersion: + """Update an existing EvaluatorVersion with the given version id. + + :param name: The name of the resource. Required. + :type name: str + :param version: The version of the EvaluatorVersion to update. Required. + :type version: str + :param evaluator_version: Evaluator resource. Is either a EvaluatorVersion type or a IO[bytes] + type. Required. + :type evaluator_version: ~azure.ai.agents.types.EvaluatorVersion or IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + :return: EvaluatorVersion + :rtype: ~azure.ai.agents.types.EvaluatorVersion :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "code": + evaluator_definition = { + "code_text": "str", + "type": "code", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # JSON input template for discriminator value "prompt": + evaluator_definition = { + "prompt_text": "str", + "type": "prompt", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # JSON input template you can fill out and use as your body input. + evaluator_version = { + "categories": [ + "str" + ], + "created_at": "2020-02-20 00:00:00", + "created_by": "str", + "definition": evaluator_definition, + "evaluator_type": "str", + "modified_at": "2020-02-20 00:00:00", + "name": "str", + "version": "str", + "description": "str", + "display_name": "str", + "id": "str", + "metadata": { + "str": "str" + }, + "tags": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "code": + evaluator_definition = { + "code_text": "str", + "type": "code", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # JSON input template for discriminator value "prompt": + evaluator_definition = { + "prompt_text": "str", + "type": "prompt", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # response body for status code(s): 200 + response == { + "categories": [ + "str" + ], + "created_at": "2020-02-20 00:00:00", + "created_by": "str", + "definition": evaluator_definition, + "evaluator_type": "str", + "modified_at": "2020-02-20 00:00:00", + "name": "str", + "version": "str", + "description": "str", + "display_name": "str", + "id": "str", + "metadata": { + "str": "str" + }, + "tags": { + "str": "str" + } + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2533,14 +10599,28 @@ async def _delete_file(self, file_id: str, **kwargs: Any) -> _models._models.Fil } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models._models.FileDeletionStatus] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_types_models2.EvaluatorVersion] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(evaluator_version, (IOBase, bytes)): + _content = evaluator_version + else: + _json = evaluator_version - _request = build_files_delete_file_request( - file_id=file_id, + _request = build_beta_evaluators_update_version_request( + name=name, + version=version, + foundry_features=foundry_features, + content_type=content_type, api_version=self._config.api_version, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -2549,6 +10629,7 @@ async def _delete_file(self, file_id: str, **kwargs: Any) -> _models._models.Fil } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -2563,30 +10644,722 @@ async def _delete_file(self, file_id: str, **kwargs: Any) -> _models._models.Fil except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize( - _models._models.FileDeletionStatus, response.json() # pylint: disable=protected-access - ) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace_async - async def get(self, file_id: str, **kwargs: Any) -> _models.FileInfo: - """Returns information about a specific file. Does not retrieve file content. - :param file_id: The ID of the file to retrieve. Required. - :type file_id: str - :return: FileInfo. The FileInfo is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.FileInfo +class BetaInsightsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.agents.aio.AIProjectClient`'s + :attr:`insights` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + async def generate( + self, + insight: _types_models2.Insight, + *, + foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW]] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models2.Insight: + """Generate Insights. + + :param insight: Complete evaluation configuration including data source, evaluators, and result + settings. Required. + :type insight: ~azure.ai.agents.types.Insight + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. INSIGHTS_V1_PREVIEW. Default value is None. + :paramtype foundry_features: str or ~azure.ai.agents.models.INSIGHTS_V1_PREVIEW + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Insight + :rtype: ~azure.ai.agents.types.Insight + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "AgentClusterInsight": + insight_request = { + "agentName": "str", + "type": "AgentClusterInsight", + "modelConfiguration": { + "modelDeploymentName": "str" + } + } + + # JSON input template for discriminator value "EvaluationComparison": + insight_request = { + "baselineRunId": "str", + "evalId": "str", + "treatmentRunIds": [ + "str" + ], + "type": "EvaluationComparison" + } + + # JSON input template for discriminator value "EvaluationRunClusterInsight": + insight_request = { + "evalId": "str", + "runIds": [ + "str" + ], + "type": "EvaluationRunClusterInsight", + "modelConfiguration": { + "modelDeploymentName": "str" + } + } + + # JSON input template for discriminator value "AgentClusterInsight": + insight_result = { + "clusterInsight": { + "clusters": [ + { + "description": "str", + "id": "str", + "label": "str", + "suggestion": "str", + "suggestionTitle": "str", + "weight": 0, + "samples": [ + insight_sample + ], + "subClusters": [ + ... + ] + } + ], + "summary": { + "method": "str", + "sampleCount": 0, + "uniqueClusterCount": 0, + "uniqueSubclusterCount": 0, + "usage": { + "inputTokenUsage": 0, + "outputTokenUsage": 0, + "totalTokenUsage": 0 + } + }, + "coordinates": { + "str": { + "size": 0, + "x": 0, + "y": 0 + } + } + }, + "type": "AgentClusterInsight" + } + + # JSON input template for discriminator value "EvaluationComparison": + insight_result = { + "comparisons": [ + { + "baselineRunSummary": { + "average": 0.0, + "runId": "str", + "sampleCount": 0, + "standardDeviation": 0.0 + }, + "compareItems": [ + { + "deltaEstimate": 0.0, + "pValue": 0.0, + "treatmentEffect": "str", + "treatmentRunId": "str", + "treatmentRunSummary": { + "average": 0.0, + "runId": "str", + "sampleCount": 0, + "standardDeviation": 0.0 + } + } + ], + "evaluator": "str", + "metric": "str", + "testingCriteria": "str" + } + ], + "method": "str", + "type": "EvaluationComparison" + } + + # JSON input template you can fill out and use as your body input. + insight = { + "displayName": "str", + "id": "str", + "metadata": { + "createdAt": "2020-02-20 00:00:00", + "completedAt": "2020-02-20 00:00:00" + }, + "request": insight_request, + "state": "str", + "result": insight_result + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AgentClusterInsight": + insight_request = { + "agentName": "str", + "type": "AgentClusterInsight", + "modelConfiguration": { + "modelDeploymentName": "str" + } + } + + # JSON input template for discriminator value "EvaluationComparison": + insight_request = { + "baselineRunId": "str", + "evalId": "str", + "treatmentRunIds": [ + "str" + ], + "type": "EvaluationComparison" + } + + # JSON input template for discriminator value "EvaluationRunClusterInsight": + insight_request = { + "evalId": "str", + "runIds": [ + "str" + ], + "type": "EvaluationRunClusterInsight", + "modelConfiguration": { + "modelDeploymentName": "str" + } + } + + # JSON input template for discriminator value "AgentClusterInsight": + insight_result = { + "clusterInsight": { + "clusters": [ + { + "description": "str", + "id": "str", + "label": "str", + "suggestion": "str", + "suggestionTitle": "str", + "weight": 0, + "samples": [ + insight_sample + ], + "subClusters": [ + ... + ] + } + ], + "summary": { + "method": "str", + "sampleCount": 0, + "uniqueClusterCount": 0, + "uniqueSubclusterCount": 0, + "usage": { + "inputTokenUsage": 0, + "outputTokenUsage": 0, + "totalTokenUsage": 0 + } + }, + "coordinates": { + "str": { + "size": 0, + "x": 0, + "y": 0 + } + } + }, + "type": "AgentClusterInsight" + } + + # JSON input template for discriminator value "EvaluationComparison": + insight_result = { + "comparisons": [ + { + "baselineRunSummary": { + "average": 0.0, + "runId": "str", + "sampleCount": 0, + "standardDeviation": 0.0 + }, + "compareItems": [ + { + "deltaEstimate": 0.0, + "pValue": 0.0, + "treatmentEffect": "str", + "treatmentRunId": "str", + "treatmentRunSummary": { + "average": 0.0, + "runId": "str", + "sampleCount": 0, + "standardDeviation": 0.0 + } + } + ], + "evaluator": "str", + "metric": "str", + "testingCriteria": "str" + } + ], + "method": "str", + "type": "EvaluationComparison" + } + + # response body for status code(s): 201 + response == { + "displayName": "str", + "id": "str", + "metadata": { + "createdAt": "2020-02-20 00:00:00", + "completedAt": "2020-02-20 00:00:00" + }, + "request": insight_request, + "state": "str", + "result": insight_result + } + """ + + @overload + async def generate( + self, + insight: IO[bytes], + *, + foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW]] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models2.Insight: + """Generate Insights. + + :param insight: Complete evaluation configuration including data source, evaluators, and result + settings. Required. + :type insight: IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. INSIGHTS_V1_PREVIEW. Default value is None. + :paramtype foundry_features: str or ~azure.ai.agents.models.INSIGHTS_V1_PREVIEW + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: Insight + :rtype: ~azure.ai.agents.types.Insight + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AgentClusterInsight": + insight_request = { + "agentName": "str", + "type": "AgentClusterInsight", + "modelConfiguration": { + "modelDeploymentName": "str" + } + } + + # JSON input template for discriminator value "EvaluationComparison": + insight_request = { + "baselineRunId": "str", + "evalId": "str", + "treatmentRunIds": [ + "str" + ], + "type": "EvaluationComparison" + } + + # JSON input template for discriminator value "EvaluationRunClusterInsight": + insight_request = { + "evalId": "str", + "runIds": [ + "str" + ], + "type": "EvaluationRunClusterInsight", + "modelConfiguration": { + "modelDeploymentName": "str" + } + } + + # JSON input template for discriminator value "AgentClusterInsight": + insight_result = { + "clusterInsight": { + "clusters": [ + { + "description": "str", + "id": "str", + "label": "str", + "suggestion": "str", + "suggestionTitle": "str", + "weight": 0, + "samples": [ + insight_sample + ], + "subClusters": [ + ... + ] + } + ], + "summary": { + "method": "str", + "sampleCount": 0, + "uniqueClusterCount": 0, + "uniqueSubclusterCount": 0, + "usage": { + "inputTokenUsage": 0, + "outputTokenUsage": 0, + "totalTokenUsage": 0 + } + }, + "coordinates": { + "str": { + "size": 0, + "x": 0, + "y": 0 + } + } + }, + "type": "AgentClusterInsight" + } + + # JSON input template for discriminator value "EvaluationComparison": + insight_result = { + "comparisons": [ + { + "baselineRunSummary": { + "average": 0.0, + "runId": "str", + "sampleCount": 0, + "standardDeviation": 0.0 + }, + "compareItems": [ + { + "deltaEstimate": 0.0, + "pValue": 0.0, + "treatmentEffect": "str", + "treatmentRunId": "str", + "treatmentRunSummary": { + "average": 0.0, + "runId": "str", + "sampleCount": 0, + "standardDeviation": 0.0 + } + } + ], + "evaluator": "str", + "metric": "str", + "testingCriteria": "str" + } + ], + "method": "str", + "type": "EvaluationComparison" + } + + # response body for status code(s): 201 + response == { + "displayName": "str", + "id": "str", + "metadata": { + "createdAt": "2020-02-20 00:00:00", + "completedAt": "2020-02-20 00:00:00" + }, + "request": insight_request, + "state": "str", + "result": insight_result + } + """ + + @distributed_trace_async + async def generate( + self, + insight: Union[_types_models2.Insight, IO[bytes]], + *, + foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW]] = None, + **kwargs: Any + ) -> _types_models2.Insight: + """Generate Insights. + + :param insight: Complete evaluation configuration including data source, evaluators, and result + settings. Is either a Insight type or a IO[bytes] type. Required. + :type insight: ~azure.ai.agents.types.Insight or IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. INSIGHTS_V1_PREVIEW. Default value is None. + :paramtype foundry_features: str or ~azure.ai.agents.models.INSIGHTS_V1_PREVIEW + :return: Insight + :rtype: ~azure.ai.agents.types.Insight :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "AgentClusterInsight": + insight_request = { + "agentName": "str", + "type": "AgentClusterInsight", + "modelConfiguration": { + "modelDeploymentName": "str" + } + } + + # JSON input template for discriminator value "EvaluationComparison": + insight_request = { + "baselineRunId": "str", + "evalId": "str", + "treatmentRunIds": [ + "str" + ], + "type": "EvaluationComparison" + } + + # JSON input template for discriminator value "EvaluationRunClusterInsight": + insight_request = { + "evalId": "str", + "runIds": [ + "str" + ], + "type": "EvaluationRunClusterInsight", + "modelConfiguration": { + "modelDeploymentName": "str" + } + } + + # JSON input template for discriminator value "AgentClusterInsight": + insight_result = { + "clusterInsight": { + "clusters": [ + { + "description": "str", + "id": "str", + "label": "str", + "suggestion": "str", + "suggestionTitle": "str", + "weight": 0, + "samples": [ + insight_sample + ], + "subClusters": [ + ... + ] + } + ], + "summary": { + "method": "str", + "sampleCount": 0, + "uniqueClusterCount": 0, + "uniqueSubclusterCount": 0, + "usage": { + "inputTokenUsage": 0, + "outputTokenUsage": 0, + "totalTokenUsage": 0 + } + }, + "coordinates": { + "str": { + "size": 0, + "x": 0, + "y": 0 + } + } + }, + "type": "AgentClusterInsight" + } + + # JSON input template for discriminator value "EvaluationComparison": + insight_result = { + "comparisons": [ + { + "baselineRunSummary": { + "average": 0.0, + "runId": "str", + "sampleCount": 0, + "standardDeviation": 0.0 + }, + "compareItems": [ + { + "deltaEstimate": 0.0, + "pValue": 0.0, + "treatmentEffect": "str", + "treatmentRunId": "str", + "treatmentRunSummary": { + "average": 0.0, + "runId": "str", + "sampleCount": 0, + "standardDeviation": 0.0 + } + } + ], + "evaluator": "str", + "metric": "str", + "testingCriteria": "str" + } + ], + "method": "str", + "type": "EvaluationComparison" + } + + # JSON input template you can fill out and use as your body input. + insight = { + "displayName": "str", + "id": "str", + "metadata": { + "createdAt": "2020-02-20 00:00:00", + "completedAt": "2020-02-20 00:00:00" + }, + "request": insight_request, + "state": "str", + "result": insight_result + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AgentClusterInsight": + insight_request = { + "agentName": "str", + "type": "AgentClusterInsight", + "modelConfiguration": { + "modelDeploymentName": "str" + } + } + + # JSON input template for discriminator value "EvaluationComparison": + insight_request = { + "baselineRunId": "str", + "evalId": "str", + "treatmentRunIds": [ + "str" + ], + "type": "EvaluationComparison" + } + + # JSON input template for discriminator value "EvaluationRunClusterInsight": + insight_request = { + "evalId": "str", + "runIds": [ + "str" + ], + "type": "EvaluationRunClusterInsight", + "modelConfiguration": { + "modelDeploymentName": "str" + } + } + + # JSON input template for discriminator value "AgentClusterInsight": + insight_result = { + "clusterInsight": { + "clusters": [ + { + "description": "str", + "id": "str", + "label": "str", + "suggestion": "str", + "suggestionTitle": "str", + "weight": 0, + "samples": [ + insight_sample + ], + "subClusters": [ + ... + ] + } + ], + "summary": { + "method": "str", + "sampleCount": 0, + "uniqueClusterCount": 0, + "uniqueSubclusterCount": 0, + "usage": { + "inputTokenUsage": 0, + "outputTokenUsage": 0, + "totalTokenUsage": 0 + } + }, + "coordinates": { + "str": { + "size": 0, + "x": 0, + "y": 0 + } + } + }, + "type": "AgentClusterInsight" + } + + # JSON input template for discriminator value "EvaluationComparison": + insight_result = { + "comparisons": [ + { + "baselineRunSummary": { + "average": 0.0, + "runId": "str", + "sampleCount": 0, + "standardDeviation": 0.0 + }, + "compareItems": [ + { + "deltaEstimate": 0.0, + "pValue": 0.0, + "treatmentEffect": "str", + "treatmentRunId": "str", + "treatmentRunSummary": { + "average": 0.0, + "runId": "str", + "sampleCount": 0, + "standardDeviation": 0.0 + } + } + ], + "evaluator": "str", + "metric": "str", + "testingCriteria": "str" + } + ], + "method": "str", + "type": "EvaluationComparison" + } + + # response body for status code(s): 201 + response == { + "displayName": "str", + "id": "str", + "metadata": { + "createdAt": "2020-02-20 00:00:00", + "completedAt": "2020-02-20 00:00:00" + }, + "request": insight_request, + "state": "str", + "result": insight_result + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2596,14 +11369,26 @@ async def get(self, file_id: str, **kwargs: Any) -> _models.FileInfo: } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.FileInfo] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_types_models2.Insight] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(insight, (IOBase, bytes)): + _content = insight + else: + _json = insight - _request = build_files_get_request( - file_id=file_id, + _request = build_beta_insights_generate_request( + foundry_features=foundry_features, + content_type=content_type, api_version=self._config.api_version, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -2612,6 +11397,7 @@ async def get(self, file_id: str, **kwargs: Any) -> _models.FileInfo: } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -2619,20 +11405,26 @@ async def get(self, file_id: str, **kwargs: Any) -> _models.FileInfo: response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [201]: if _stream: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) + error = self._deserialize.failsafe_deserialize( + _types_models2.ApiErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.FileInfo, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -2640,14 +11432,151 @@ async def get(self, file_id: str, **kwargs: Any) -> _models.FileInfo: return deserialized # type: ignore @distributed_trace_async - async def _get_file_content(self, file_id: str, **kwargs: Any) -> AsyncIterator[bytes]: - """Retrieves the raw content of a specific file. - - :param file_id: The ID of the file to retrieve. Required. - :type file_id: str - :return: AsyncIterator[bytes] - :rtype: AsyncIterator[bytes] + async def get( + self, + id: str, + *, + foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW]] = None, + include_coordinates: Optional[bool] = None, + **kwargs: Any + ) -> _types_models2.Insight: + """Get a specific insight by Id. + + :param id: The unique identifier for the insights report. Required. + :type id: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. INSIGHTS_V1_PREVIEW. Default value is None. + :paramtype foundry_features: str or ~azure.ai.agents.models.INSIGHTS_V1_PREVIEW + :keyword include_coordinates: Whether to include coordinates for visualization in the response. + Defaults to false. Default value is None. + :paramtype include_coordinates: bool + :return: Insight + :rtype: ~azure.ai.agents.types.Insight :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AgentClusterInsight": + insight_request = { + "agentName": "str", + "type": "AgentClusterInsight", + "modelConfiguration": { + "modelDeploymentName": "str" + } + } + + # JSON input template for discriminator value "EvaluationComparison": + insight_request = { + "baselineRunId": "str", + "evalId": "str", + "treatmentRunIds": [ + "str" + ], + "type": "EvaluationComparison" + } + + # JSON input template for discriminator value "EvaluationRunClusterInsight": + insight_request = { + "evalId": "str", + "runIds": [ + "str" + ], + "type": "EvaluationRunClusterInsight", + "modelConfiguration": { + "modelDeploymentName": "str" + } + } + + # JSON input template for discriminator value "AgentClusterInsight": + insight_result = { + "clusterInsight": { + "clusters": [ + { + "description": "str", + "id": "str", + "label": "str", + "suggestion": "str", + "suggestionTitle": "str", + "weight": 0, + "samples": [ + insight_sample + ], + "subClusters": [ + ... + ] + } + ], + "summary": { + "method": "str", + "sampleCount": 0, + "uniqueClusterCount": 0, + "uniqueSubclusterCount": 0, + "usage": { + "inputTokenUsage": 0, + "outputTokenUsage": 0, + "totalTokenUsage": 0 + } + }, + "coordinates": { + "str": { + "size": 0, + "x": 0, + "y": 0 + } + } + }, + "type": "AgentClusterInsight" + } + + # JSON input template for discriminator value "EvaluationComparison": + insight_result = { + "comparisons": [ + { + "baselineRunSummary": { + "average": 0.0, + "runId": "str", + "sampleCount": 0, + "standardDeviation": 0.0 + }, + "compareItems": [ + { + "deltaEstimate": 0.0, + "pValue": 0.0, + "treatmentEffect": "str", + "treatmentRunId": "str", + "treatmentRunSummary": { + "average": 0.0, + "runId": "str", + "sampleCount": 0, + "standardDeviation": 0.0 + } + } + ], + "evaluator": "str", + "metric": "str", + "testingCriteria": "str" + } + ], + "method": "str", + "type": "EvaluationComparison" + } + + # response body for status code(s): 200 + response == { + "displayName": "str", + "id": "str", + "metadata": { + "createdAt": "2020-02-20 00:00:00", + "completedAt": "2020-02-20 00:00:00" + }, + "request": insight_request, + "state": "str", + "result": insight_result + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2660,10 +11589,12 @@ async def _get_file_content(self, file_id: str, **kwargs: Any) -> AsyncIterator[ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[_types_models2.Insight] = kwargs.pop("cls", None) - _request = build_files_get_file_content_request( - file_id=file_id, + _request = build_beta_insights_get_request( + id=id, + foundry_features=foundry_features, + include_coordinates=include_coordinates, api_version=self._config.api_version, headers=_headers, params=_params, @@ -2673,7 +11604,8 @@ async def _get_file_content(self, file_id: str, **kwargs: Any) -> AsyncIterator[ } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", True) + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -2687,64 +11619,186 @@ async def _get_file_content(self, file_id: str, **kwargs: Any) -> AsyncIterator[ except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) + error = self._deserialize.failsafe_deserialize( + _types_models2.ApiErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error) - deserialized = response.iter_bytes() + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - -class VectorStoresOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.agents.aio.AgentsClient`'s - :attr:`vector_stores` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AgentsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, *, - limit: Optional[int] = None, - order: Optional[Union[str, _models.ListSortOrder]] = None, - before: Optional[str] = None, + foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW]] = None, + type: Optional[types.InsightType] = None, + eval_id: Optional[str] = None, + run_id: Optional[str] = None, + agent_name: Optional[str] = None, + include_coordinates: Optional[bool] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.VectorStore"]: - """Returns a list of vector stores. - - :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and - 100, and the default is 20. Default value is None. - :paramtype limit: int - :keyword order: Sort order by the created_at timestamp of the objects. asc for ascending order - and desc for descending order. Known values are: "asc" and "desc". Default value is None. - :paramtype order: str or ~azure.ai.agents.models.ListSortOrder - :keyword 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. Default value is None. - :paramtype before: str - :return: An iterator like instance of VectorStore - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.models.VectorStore] + ) -> AsyncItemPaged["_types_models2.Insight"]: + """List all insights in reverse chronological order (newest first). + + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. INSIGHTS_V1_PREVIEW. Default value is None. + :paramtype foundry_features: str or ~azure.ai.agents.models.INSIGHTS_V1_PREVIEW + :keyword type: Filter by the type of analysis. Known values are: "EvaluationRunClusterInsight", + "AgentClusterInsight", and "EvaluationComparison". Default value is None. + :paramtype type: str or ~azure.ai.agents.models.InsightType + :keyword eval_id: Filter by the evaluation ID. Default value is None. + :paramtype eval_id: str + :keyword run_id: Filter by the evaluation run ID. Default value is None. + :paramtype run_id: str + :keyword agent_name: Filter by the agent name. Default value is None. + :paramtype agent_name: str + :keyword include_coordinates: Whether to include coordinates for visualization in the response. + Defaults to false. Default value is None. + :paramtype include_coordinates: bool + :return: An iterator like instance of Insight + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.types.Insight] :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AgentClusterInsight": + insight_request = { + "agentName": "str", + "type": "AgentClusterInsight", + "modelConfiguration": { + "modelDeploymentName": "str" + } + } + + # JSON input template for discriminator value "EvaluationComparison": + insight_request = { + "baselineRunId": "str", + "evalId": "str", + "treatmentRunIds": [ + "str" + ], + "type": "EvaluationComparison" + } + + # JSON input template for discriminator value "EvaluationRunClusterInsight": + insight_request = { + "evalId": "str", + "runIds": [ + "str" + ], + "type": "EvaluationRunClusterInsight", + "modelConfiguration": { + "modelDeploymentName": "str" + } + } + + # JSON input template for discriminator value "AgentClusterInsight": + insight_result = { + "clusterInsight": { + "clusters": [ + { + "description": "str", + "id": "str", + "label": "str", + "suggestion": "str", + "suggestionTitle": "str", + "weight": 0, + "samples": [ + insight_sample + ], + "subClusters": [ + ... + ] + } + ], + "summary": { + "method": "str", + "sampleCount": 0, + "uniqueClusterCount": 0, + "uniqueSubclusterCount": 0, + "usage": { + "inputTokenUsage": 0, + "outputTokenUsage": 0, + "totalTokenUsage": 0 + } + }, + "coordinates": { + "str": { + "size": 0, + "x": 0, + "y": 0 + } + } + }, + "type": "AgentClusterInsight" + } + + # JSON input template for discriminator value "EvaluationComparison": + insight_result = { + "comparisons": [ + { + "baselineRunSummary": { + "average": 0.0, + "runId": "str", + "sampleCount": 0, + "standardDeviation": 0.0 + }, + "compareItems": [ + { + "deltaEstimate": 0.0, + "pValue": 0.0, + "treatmentEffect": "str", + "treatmentRunId": "str", + "treatmentRunSummary": { + "average": 0.0, + "runId": "str", + "sampleCount": 0, + "standardDeviation": 0.0 + } + } + ], + "evaluator": "str", + "metric": "str", + "testingCriteria": "str" + } + ], + "method": "str", + "type": "EvaluationComparison" + } + + # response body for status code(s): 200 + response == { + "displayName": "str", + "id": "str", + "metadata": { + "createdAt": "2020-02-20 00:00:00", + "completedAt": "2020-02-20 00:00:00" + }, + "request": insight_request, + "state": "str", + "result": insight_result + } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.VectorStore]] = kwargs.pop("cls", None) + cls: ClsType[List[_types_models2.Insight]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2754,32 +11808,61 @@ def list( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(_continuation_token=None): + def prepare_request(next_link=None): + if not next_link: + + _request = build_beta_insights_list_request( + foundry_features=foundry_features, + type=type, + eval_id=eval_id, + run_id=run_id, + agent_name=agent_name, + include_coordinates=include_coordinates, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - _request = build_vector_stores_list_request( - limit=limit, - order=order, - after=_continuation_token, - before=before, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) return _request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.VectorStore], deserialized.get("data", [])) + list_of_elem = deserialized.get("value", []) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("last_id") or None, AsyncList(list_of_elem) + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - async def get_next(_continuation_token=None): - _request = prepare_request(_continuation_token) + async def get_next(next_link=None): + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access @@ -2789,122 +11872,325 @@ async def get_next(_continuation_token=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) + error = self._deserialize.failsafe_deserialize( + _types_models2.ApiErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error) return pipeline_response return AsyncItemPaged(get_next, extract_data) + +class BetaMemoryStoresOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.agents.aio.AIProjectClient`'s + :attr:`memory_stores` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @overload async def create( self, + name: str, + definition: _types_models2.MemoryStoreDefinition, + description: Optional[str] = None, + metadata: Optional[dict[str, str]] = None, *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], content_type: str = "application/json", - file_ids: Optional[List[str]] = None, - name: Optional[str] = None, - store_configuration: Optional[_models.VectorStoreConfiguration] = None, - expires_after: Optional[_models.VectorStoreExpirationPolicy] = None, - chunking_strategy: Optional[_models.VectorStoreChunkingStrategyRequest] = None, - metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> _models.VectorStore: - """Creates a vector store. - + ) -> _types_models2.MemoryStoreDetails: + """Create a memory store. + + :param name: The name of the memory store. Required. + :type name: str + :param definition: The memory store definition. Required. + :type definition: ~azure.ai.agents.types.MemoryStoreDefinition + :param description: A human-readable description of the memory store. Default value is None. + :type description: str + :param metadata: Arbitrary key-value metadata to associate with the memory store. Default value + is None. + :type metadata: dict[str, str] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword file_ids: A list of file IDs that the vector store should use. Useful for tools like - ``file_search`` that can access files. Default value is None. - :paramtype file_ids: list[str] - :keyword name: The name of the vector store. Default value is None. - :paramtype name: str - :keyword store_configuration: The vector store configuration, used when vector store is created - from Azure asset URIs. Default value is None. - :paramtype store_configuration: ~azure.ai.agents.models.VectorStoreConfiguration - :keyword expires_after: Details on when this vector store expires. Default value is None. - :paramtype expires_after: ~azure.ai.agents.models.VectorStoreExpirationPolicy - :keyword chunking_strategy: 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. Default value is None. - :paramtype chunking_strategy: ~azure.ai.agents.models.VectorStoreChunkingStrategyRequest - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: VectorStore. The VectorStore is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.VectorStore + :return: MemoryStoreDetails + :rtype: ~azure.ai.agents.types.MemoryStoreDetails :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "default": + memory_store_definition = { + "chat_model": "str", + "embedding_model": "str", + "kind": "default", + "options": { + "chat_summary_enabled": bool, + "user_profile_enabled": bool, + "user_profile_details": "str" + } + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "definition": memory_store_definition, + "id": "str", + "name": "str", + "object": "str", + "updated_at": "2020-02-20 00:00:00", + "description": "str", + "metadata": { + "str": "str" + } + } """ @overload - async def create(self, body: JSON, *, content_type: str = "application/json", **kwargs: Any) -> _models.VectorStore: - """Creates a vector store. + async def create( + self, + body: JSON, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models2.MemoryStoreDetails: + """Create a memory store. :param body: Required. :type body: JSON + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: VectorStore. The VectorStore is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.VectorStore + :return: MemoryStoreDetails + :rtype: ~azure.ai.agents.types.MemoryStoreDetails :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "kind": + + # JSON input template for discriminator value "default": + memory_store_definition = { + "chat_model": "str", + "embedding_model": "str", + "kind": "default", + "options": { + "chat_summary_enabled": bool, + "user_profile_enabled": bool, + "user_profile_details": "str" + } + } + + # JSON input template you can fill out and use as your body input. + body = { + "definition": memory_store_definition, + "name": "str", + "description": "str", + "metadata": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "default": + memory_store_definition = { + "chat_model": "str", + "embedding_model": "str", + "kind": "default", + "options": { + "chat_summary_enabled": bool, + "user_profile_enabled": bool, + "user_profile_details": "str" + } + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "definition": memory_store_definition, + "id": "str", + "name": "str", + "object": "str", + "updated_at": "2020-02-20 00:00:00", + "description": "str", + "metadata": { + "str": "str" + } + } """ @overload async def create( - self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.VectorStore: - """Creates a vector store. + self, + body: IO[bytes], + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models2.MemoryStoreDetails: + """Create a memory store. :param body: Required. :type body: IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: VectorStore. The VectorStore is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.VectorStore + :return: MemoryStoreDetails + :rtype: ~azure.ai.agents.types.MemoryStoreDetails :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "default": + memory_store_definition = { + "chat_model": "str", + "embedding_model": "str", + "kind": "default", + "options": { + "chat_summary_enabled": bool, + "user_profile_enabled": bool, + "user_profile_details": "str" + } + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "definition": memory_store_definition, + "id": "str", + "name": "str", + "object": "str", + "updated_at": "2020-02-20 00:00:00", + "description": "str", + "metadata": { + "str": "str" + } + } """ @distributed_trace_async async def create( self, + name: str = _Unset, + definition: _types_models2.MemoryStoreDefinition = _Unset, body: Union[JSON, IO[bytes]] = _Unset, - *, - file_ids: Optional[List[str]] = None, - name: Optional[str] = None, - store_configuration: Optional[_models.VectorStoreConfiguration] = None, - expires_after: Optional[_models.VectorStoreExpirationPolicy] = None, - chunking_strategy: Optional[_models.VectorStoreChunkingStrategyRequest] = None, + description: Optional[str] = None, metadata: Optional[dict[str, str]] = None, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], **kwargs: Any - ) -> _models.VectorStore: - """Creates a vector store. + ) -> _types_models2.MemoryStoreDetails: + """Create a memory store. + :param name: The name of the memory store. Required. + :type name: str + :param definition: The memory store definition. Required. + :type definition: ~azure.ai.agents.types.MemoryStoreDefinition :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :keyword file_ids: A list of file IDs that the vector store should use. Useful for tools like - ``file_search`` that can access files. Default value is None. - :paramtype file_ids: list[str] - :keyword name: The name of the vector store. Default value is None. - :paramtype name: str - :keyword store_configuration: The vector store configuration, used when vector store is created - from Azure asset URIs. Default value is None. - :paramtype store_configuration: ~azure.ai.agents.models.VectorStoreConfiguration - :keyword expires_after: Details on when this vector store expires. Default value is None. - :paramtype expires_after: ~azure.ai.agents.models.VectorStoreExpirationPolicy - :keyword chunking_strategy: 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. Default value is None. - :paramtype chunking_strategy: ~azure.ai.agents.models.VectorStoreChunkingStrategyRequest - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: VectorStore. The VectorStore is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.VectorStore + :param description: A human-readable description of the memory store. Default value is None. + :type description: str + :param metadata: Arbitrary key-value metadata to associate with the memory store. Default value + is None. + :type metadata: dict[str, str] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW + :return: MemoryStoreDetails + :rtype: ~azure.ai.agents.types.MemoryStoreDetails :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "kind": + + # JSON input template for discriminator value "default": + memory_store_definition = { + "chat_model": "str", + "embedding_model": "str", + "kind": "default", + "options": { + "chat_summary_enabled": bool, + "user_profile_enabled": bool, + "user_profile_details": "str" + } + } + + # JSON input template you can fill out and use as your body input. + body = { + "definition": memory_store_definition, + "name": "str", + "description": "str", + "metadata": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "default": + memory_store_definition = { + "chat_model": "str", + "embedding_model": "str", + "kind": "default", + "options": { + "chat_summary_enabled": bool, + "user_profile_enabled": bool, + "user_profile_details": "str" + } + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "definition": memory_store_definition, + "id": "str", + "name": "str", + "object": "str", + "updated_at": "2020-02-20 00:00:00", + "description": "str", + "metadata": { + "str": "str" + } + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2918,90 +12204,29 @@ async def create( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VectorStore] = kwargs.pop("cls", None) + cls: ClsType[_types_models2.MemoryStoreDetails] = kwargs.pop("cls", None) if body is _Unset: - body = { - "chunking_strategy": chunking_strategy, - "configuration": store_configuration, - "expires_after": expires_after, - "file_ids": file_ids, - "metadata": metadata, - "name": name, - } + if name is _Unset: + raise TypeError("missing required argument: name") + if definition is _Unset: + raise TypeError("missing required argument: definition") + body = {"definition": definition, "description": description, "metadata": metadata, "name": name} body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" + _json = None _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_vector_stores_create_request( - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) - - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.VectorStore, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get(self, vector_store_id: str, **kwargs: Any) -> _models.VectorStore: - """Returns the vector store object matching the specified ID. - - :param vector_store_id: Identifier of the vector store. Required. - :type vector_store_id: str - :return: VectorStore. The VectorStore is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.VectorStore - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.VectorStore] = kwargs.pop("cls", None) + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body - _request = build_vector_stores_get_request( - vector_store_id=vector_store_id, + _request = build_beta_memory_stores_create_request( + foundry_features=foundry_features, + content_type=content_type, api_version=self._config.api_version, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -3010,6 +12235,7 @@ async def get(self, vector_store_id: str, **kwargs: Any) -> _models.VectorStore: } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -3024,13 +12250,19 @@ async def get(self, vector_store_id: str, **kwargs: Any) -> _models.VectorStore: except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) + error = self._deserialize.failsafe_deserialize( + _types_models2.ApiErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.VectorStore, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -3038,102 +12270,262 @@ async def get(self, vector_store_id: str, **kwargs: Any) -> _models.VectorStore: return deserialized # type: ignore @overload - async def modify( + async def update( self, - vector_store_id: str, + name: str, + description: Optional[str] = None, + metadata: Optional[dict[str, str]] = None, *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], content_type: str = "application/json", - name: Optional[str] = None, - expires_after: Optional[_models.VectorStoreExpirationPolicy] = None, - metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> _models.VectorStore: - """Modifies an existing vector store. - - :param vector_store_id: Identifier of the vector store. Required. - :type vector_store_id: str + ) -> _types_models2.MemoryStoreDetails: + """Update a memory store. + + :param name: The name of the memory store to update. Required. + :type name: str + :param description: A human-readable description of the memory store. Default value is None. + :type description: str + :param metadata: Arbitrary key-value metadata to associate with the memory store. Default value + is None. + :type metadata: dict[str, str] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword name: The name of the vector store. Default value is None. - :paramtype name: str - :keyword expires_after: Details on when this vector store expires. Default value is None. - :paramtype expires_after: ~azure.ai.agents.models.VectorStoreExpirationPolicy - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: VectorStore. The VectorStore is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.VectorStore + :return: MemoryStoreDetails + :rtype: ~azure.ai.agents.types.MemoryStoreDetails :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "default": + memory_store_definition = { + "chat_model": "str", + "embedding_model": "str", + "kind": "default", + "options": { + "chat_summary_enabled": bool, + "user_profile_enabled": bool, + "user_profile_details": "str" + } + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "definition": memory_store_definition, + "id": "str", + "name": "str", + "object": "str", + "updated_at": "2020-02-20 00:00:00", + "description": "str", + "metadata": { + "str": "str" + } + } """ @overload - async def modify( - self, vector_store_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.VectorStore: - """Modifies an existing vector store. + async def update( + self, + name: str, + body: JSON, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models2.MemoryStoreDetails: + """Update a memory store. - :param vector_store_id: Identifier of the vector store. Required. - :type vector_store_id: str + :param name: The name of the memory store to update. Required. + :type name: str :param body: Required. :type body: JSON + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: VectorStore. The VectorStore is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.VectorStore + :return: MemoryStoreDetails + :rtype: ~azure.ai.agents.types.MemoryStoreDetails :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "description": "str", + "metadata": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "default": + memory_store_definition = { + "chat_model": "str", + "embedding_model": "str", + "kind": "default", + "options": { + "chat_summary_enabled": bool, + "user_profile_enabled": bool, + "user_profile_details": "str" + } + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "definition": memory_store_definition, + "id": "str", + "name": "str", + "object": "str", + "updated_at": "2020-02-20 00:00:00", + "description": "str", + "metadata": { + "str": "str" + } + } """ @overload - async def modify( - self, vector_store_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.VectorStore: - """Modifies an existing vector store. + async def update( + self, + name: str, + body: IO[bytes], + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models2.MemoryStoreDetails: + """Update a memory store. - :param vector_store_id: Identifier of the vector store. Required. - :type vector_store_id: str + :param name: The name of the memory store to update. Required. + :type name: str :param body: Required. :type body: IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: VectorStore. The VectorStore is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.VectorStore + :return: MemoryStoreDetails + :rtype: ~azure.ai.agents.types.MemoryStoreDetails :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "default": + memory_store_definition = { + "chat_model": "str", + "embedding_model": "str", + "kind": "default", + "options": { + "chat_summary_enabled": bool, + "user_profile_enabled": bool, + "user_profile_details": "str" + } + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "definition": memory_store_definition, + "id": "str", + "name": "str", + "object": "str", + "updated_at": "2020-02-20 00:00:00", + "description": "str", + "metadata": { + "str": "str" + } + } """ @distributed_trace_async - async def modify( + async def update( self, - vector_store_id: str, + name: str, body: Union[JSON, IO[bytes]] = _Unset, - *, - name: Optional[str] = None, - expires_after: Optional[_models.VectorStoreExpirationPolicy] = None, + description: Optional[str] = None, metadata: Optional[dict[str, str]] = None, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], **kwargs: Any - ) -> _models.VectorStore: - """Modifies an existing vector store. + ) -> _types_models2.MemoryStoreDetails: + """Update a memory store. - :param vector_store_id: Identifier of the vector store. Required. - :type vector_store_id: str + :param name: The name of the memory store to update. Required. + :type name: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :keyword name: The name of the vector store. Default value is None. - :paramtype name: str - :keyword expires_after: Details on when this vector store expires. Default value is None. - :paramtype expires_after: ~azure.ai.agents.models.VectorStoreExpirationPolicy - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: VectorStore. The VectorStore is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.VectorStore + :param description: A human-readable description of the memory store. Default value is None. + :type description: str + :param metadata: Arbitrary key-value metadata to associate with the memory store. Default value + is None. + :type metadata: dict[str, str] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW + :return: MemoryStoreDetails + :rtype: ~azure.ai.agents.types.MemoryStoreDetails :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "description": "str", + "metadata": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "default": + memory_store_definition = { + "chat_model": "str", + "embedding_model": "str", + "kind": "default", + "options": { + "chat_summary_enabled": bool, + "user_profile_enabled": bool, + "user_profile_details": "str" + } + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "definition": memory_store_definition, + "id": "str", + "name": "str", + "object": "str", + "updated_at": "2020-02-20 00:00:00", + "description": "str", + "metadata": { + "str": "str" + } + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3147,22 +12539,25 @@ async def modify( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VectorStore] = kwargs.pop("cls", None) + cls: ClsType[_types_models2.MemoryStoreDetails] = kwargs.pop("cls", None) if body is _Unset: - body = {"expires_after": expires_after, "metadata": metadata, "name": name} + body = {"description": description, "metadata": metadata} body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" + _json = None _content = None if isinstance(body, (IOBase, bytes)): _content = body else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _json = body - _request = build_vector_stores_modify_request( - vector_store_id=vector_store_id, + _request = build_beta_memory_stores_update_request( + name=name, + foundry_features=foundry_features, content_type=content_type, api_version=self._config.api_version, + json=_json, content=_content, headers=_headers, params=_params, @@ -3172,6 +12567,7 @@ async def modify( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -3186,13 +12582,19 @@ async def modify( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) + error = self._deserialize.failsafe_deserialize( + _types_models2.ApiErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.VectorStore, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -3200,17 +12602,51 @@ async def modify( return deserialized # type: ignore @distributed_trace_async - async def _delete_vector_store( - self, vector_store_id: str, **kwargs: Any - ) -> _models._models.VectorStoreDeletionStatus: - """Deletes the vector store object matching the specified ID. - - :param vector_store_id: Identifier of the vector store. Required. - :type vector_store_id: str - :return: VectorStoreDeletionStatus. The VectorStoreDeletionStatus is compatible with - MutableMapping - :rtype: ~azure.ai.agents.models._models.VectorStoreDeletionStatus + async def get( + self, name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], **kwargs: Any + ) -> _types_models2.MemoryStoreDetails: + """Retrieve a memory store. + + :param name: The name of the memory store to retrieve. Required. + :type name: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW + :return: MemoryStoreDetails + :rtype: ~azure.ai.agents.types.MemoryStoreDetails :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "default": + memory_store_definition = { + "chat_model": "str", + "embedding_model": "str", + "kind": "default", + "options": { + "chat_summary_enabled": bool, + "user_profile_enabled": bool, + "user_profile_details": "str" + } + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "definition": memory_store_definition, + "id": "str", + "name": "str", + "object": "str", + "updated_at": "2020-02-20 00:00:00", + "description": "str", + "metadata": { + "str": "str" + } + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3223,10 +12659,11 @@ async def _delete_vector_store( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models._models.VectorStoreDeletionStatus] = kwargs.pop("cls", None) + cls: ClsType[_types_models2.MemoryStoreDetails] = kwargs.pop("cls", None) - _request = build_vector_stores_delete_vector_store_request( - vector_store_id=vector_store_id, + _request = build_beta_memory_stores_get_request( + name=name, + foundry_features=foundry_features, api_version=self._config.api_version, headers=_headers, params=_params, @@ -3236,6 +12673,7 @@ async def _delete_vector_store( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -3250,76 +12688,94 @@ async def _delete_vector_store( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) + error = self._deserialize.failsafe_deserialize( + _types_models2.ApiErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize( - _models._models.VectorStoreDeletionStatus, response.json() # pylint: disable=protected-access - ) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - -class VectorStoreFilesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.agents.aio.AgentsClient`'s - :attr:`vector_store_files` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AgentsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, - vector_store_id: str, *, - filter: Optional[Union[str, _models.VectorStoreFileStatusFilter]] = None, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], limit: Optional[int] = None, - order: Optional[Union[str, _models.ListSortOrder]] = None, + order: Optional[types.PageOrder] = None, before: Optional[str] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.VectorStoreFile"]: - """Returns a list of vector store files. - - :param vector_store_id: Identifier of the vector store. Required. - :type vector_store_id: str - :keyword filter: Filter by file status. Known values are: "in_progress", "completed", "failed", - and "cancelled". Default value is None. - :paramtype filter: str or ~azure.ai.agents.models.VectorStoreFileStatusFilter + ) -> AsyncItemPaged["_types_models2.MemoryStoreDetails"]: + """List all memory stores. + + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and - 100, and the default is 20. Default value is None. + 100, and the + default is 20. Default value is None. :paramtype limit: int - :keyword order: Sort order by the created_at timestamp of the objects. asc for ascending order - and desc for descending order. Known values are: "asc" and "desc". Default value is None. - :paramtype order: str or ~azure.ai.agents.models.ListSortOrder - :keyword 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. Default value is None. + :keyword order: Sort order by the ``created_at`` timestamp of the objects. ``asc`` for + ascending order and``desc`` + for descending order. Known values are: "asc" and "desc". Default value is None. + :paramtype order: str or ~azure.ai.agents.models.PageOrder + :keyword 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. + Default value is None. :paramtype before: str - :return: An iterator like instance of VectorStoreFile - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.models.VectorStoreFile] + :return: An iterator like instance of MemoryStoreDetails + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.types.MemoryStoreDetails] :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "default": + memory_store_definition = { + "chat_model": "str", + "embedding_model": "str", + "kind": "default", + "options": { + "chat_summary_enabled": bool, + "user_profile_enabled": bool, + "user_profile_details": "str" + } + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "definition": memory_store_definition, + "id": "str", + "name": "str", + "object": "str", + "updated_at": "2020-02-20 00:00:00", + "description": "str", + "metadata": { + "str": "str" + } + } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.VectorStoreFile]] = kwargs.pop("cls", None) + cls: ClsType[List[_types_models2.MemoryStoreDetails]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3331,9 +12787,8 @@ def list( def prepare_request(_continuation_token=None): - _request = build_vector_store_files_list_request( - vector_store_id=vector_store_id, - filter=filter, + _request = build_beta_memory_stores_list_request( + foundry_features=foundry_features, limit=limit, order=order, after=_continuation_token, @@ -3350,7 +12805,7 @@ def prepare_request(_continuation_token=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.VectorStoreFile], deserialized.get("data", [])) + list_of_elem = deserialized.get("data", []) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("last_id") or None, AsyncList(list_of_elem) @@ -3366,106 +12821,40 @@ async def get_next(_continuation_token=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) + error = self._deserialize.failsafe_deserialize( + _types_models2.ApiErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error) return pipeline_response return AsyncItemPaged(get_next, extract_data) - @overload - async def create( - self, - vector_store_id: str, - *, - content_type: str = "application/json", - file_id: Optional[str] = None, - data_source: Optional[_models.VectorStoreDataSource] = None, - chunking_strategy: Optional[_models.VectorStoreChunkingStrategyRequest] = None, - **kwargs: Any - ) -> _models.VectorStoreFile: - """Create a vector store file by attaching a file to a vector store. - - :param vector_store_id: Identifier of the vector store. Required. - :type vector_store_id: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword file_id: Identifier of the file. Default value is None. - :paramtype file_id: str - :keyword data_source: Azure asset ID. Default value is None. - :paramtype data_source: ~azure.ai.agents.models.VectorStoreDataSource - :keyword chunking_strategy: The chunking strategy used to chunk the file. If not set, uses the - auto strategy. Default value is None. - :paramtype chunking_strategy: ~azure.ai.agents.models.VectorStoreChunkingStrategyRequest - :return: VectorStoreFile. The VectorStoreFile is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.VectorStoreFile - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, vector_store_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.VectorStoreFile: - """Create a vector store file by attaching a file to a vector store. - - :param vector_store_id: Identifier of the vector store. Required. - :type vector_store_id: str - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: VectorStoreFile. The VectorStoreFile is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.VectorStoreFile - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, vector_store_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.VectorStoreFile: - """Create a vector store file by attaching a file to a vector store. - - :param vector_store_id: Identifier of the vector store. Required. - :type vector_store_id: str - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: VectorStoreFile. The VectorStoreFile is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.VectorStoreFile + @distributed_trace_async + async def delete( + self, name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], **kwargs: Any + ) -> _types_models2.DeleteMemoryStoreResult: + """Delete a memory store. + + :param name: The name of the memory store to delete. Required. + :type name: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW + :return: DeleteMemoryStoreResult + :rtype: ~azure.ai.agents.types.DeleteMemoryStoreResult :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace_async - async def create( - self, - vector_store_id: str, - body: Union[JSON, IO[bytes]] = _Unset, - *, - file_id: Optional[str] = None, - data_source: Optional[_models.VectorStoreDataSource] = None, - chunking_strategy: Optional[_models.VectorStoreChunkingStrategyRequest] = None, - **kwargs: Any - ) -> _models.VectorStoreFile: - """Create a vector store file by attaching a file to a vector store. + Example: + .. code-block:: python - :param vector_store_id: Identifier of the vector store. Required. - :type vector_store_id: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword file_id: Identifier of the file. Default value is None. - :paramtype file_id: str - :keyword data_source: Azure asset ID. Default value is None. - :paramtype data_source: ~azure.ai.agents.models.VectorStoreDataSource - :keyword chunking_strategy: The chunking strategy used to chunk the file. If not set, uses the - auto strategy. Default value is None. - :paramtype chunking_strategy: ~azure.ai.agents.models.VectorStoreChunkingStrategyRequest - :return: VectorStoreFile. The VectorStoreFile is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.VectorStoreFile - :raises ~azure.core.exceptions.HttpResponseError: + # response body for status code(s): 200 + response == { + "deleted": bool, + "name": "str", + "object": "str" + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3475,27 +12864,15 @@ async def create( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VectorStoreFile] = kwargs.pop("cls", None) - - if body is _Unset: - body = {"chunking_strategy": chunking_strategy, "data_source": data_source, "file_id": file_id} - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + cls: ClsType[_types_models2.DeleteMemoryStoreResult] = kwargs.pop("cls", None) - _request = build_vector_store_files_create_request( - vector_store_id=vector_store_id, - content_type=content_type, + _request = build_beta_memory_stores_delete_request( + name=name, + foundry_features=foundry_features, api_version=self._config.api_version, - content=_content, headers=_headers, params=_params, ) @@ -3504,6 +12881,7 @@ async def create( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -3518,30 +12896,133 @@ async def create( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) + error = self._deserialize.failsafe_deserialize( + _types_models2.ApiErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.VectorStoreFile, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + @overload + async def _search_memories( + self, + name: str, + scope: str, + items: Optional[List[dict[str, Any]]] = None, + previous_search_id: Optional[str] = None, + options: Optional[_types_models2.MemorySearchOptions] = None, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models2.MemoryStoreSearchResult: ... + @overload + async def _search_memories( + self, + name: str, + body: JSON, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models2.MemoryStoreSearchResult: ... + @overload + async def _search_memories( + self, + name: str, + body: IO[bytes], + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models2.MemoryStoreSearchResult: ... + @distributed_trace_async - async def get(self, vector_store_id: str, file_id: str, **kwargs: Any) -> _models.VectorStoreFile: - """Retrieves a vector store file. - - :param vector_store_id: Identifier of the vector store. Required. - :type vector_store_id: str - :param file_id: Identifier of the file. Required. - :type file_id: str - :return: VectorStoreFile. The VectorStoreFile is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.VectorStoreFile + async def _search_memories( + self, + name: str, + scope: str = _Unset, + body: Union[JSON, IO[bytes]] = _Unset, + items: Optional[List[dict[str, Any]]] = None, + previous_search_id: Optional[str] = None, + options: Optional[_types_models2.MemorySearchOptions] = None, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + **kwargs: Any + ) -> _types_models2.MemoryStoreSearchResult: + """Search for relevant memories from a memory store based on conversation context. + + :param name: The name of the memory store to search. Required. + :type name: str + :param scope: The namespace that logically groups and isolates memories, such as a user ID. + Required. + :type scope: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :param items: Items for which to search for relevant memories. Default value is None. + :type items: list[dict[str, any]] + :param previous_search_id: The unique ID of the previous search request, enabling incremental + memory search from where the last operation left off. Default value is None. + :type previous_search_id: str + :param options: Memory search options. Default value is None. + :type options: ~azure.ai.agents.types.MemorySearchOptions + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW + :return: MemoryStoreSearchResult + :rtype: ~azure.ai.agents.types.MemoryStoreSearchResult :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "scope": "str", + "items": [ + { + "str": {} + } + ], + "options": { + "max_memories": 0 + }, + "previous_search_id": "str" + } + + # response body for status code(s): 200 + response == { + "memories": [ + { + "memory_item": memory_item + } + ], + "search_id": "str", + "usage": { + "embedding_tokens": 0, + "input_tokens": 0, + "input_tokens_details": { + "cached_tokens": 0 + }, + "output_tokens": 0, + "output_tokens_details": { + "reasoning_tokens": 0 + }, + "total_tokens": 0 + } + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3551,15 +13032,32 @@ async def get(self, vector_store_id: str, file_id: str, **kwargs: Any) -> _model } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.VectorStoreFile] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_types_models2.MemoryStoreSearchResult] = kwargs.pop("cls", None) + + if body is _Unset: + if scope is _Unset: + raise TypeError("missing required argument: scope") + body = {"items": items, "options": options, "previous_search_id": previous_search_id, "scope": scope} + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body - _request = build_vector_store_files_get_request( - vector_store_id=vector_store_id, - file_id=file_id, + _request = build_beta_memory_stores_search_memories_request( + name=name, + foundry_features=foundry_features, + content_type=content_type, api_version=self._config.api_version, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -3568,6 +13066,7 @@ async def get(self, vector_store_id: str, file_id: str, **kwargs: Any) -> _model } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -3582,35 +13081,37 @@ async def get(self, vector_store_id: str, file_id: str, **kwargs: Any) -> _model except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) + error = self._deserialize.failsafe_deserialize( + _types_models2.ApiErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.VectorStoreFile, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace_async - async def _delete_vector_store_file( - self, vector_store_id: str, file_id: str, **kwargs: Any - ) -> _models._models.VectorStoreFileDeletionStatus: - """Deletes a vector store file. This removes the file‐to‐store link (does not delete the file - itself). - - :param vector_store_id: Identifier of the vector store. Required. - :type vector_store_id: str - :param file_id: Identifier of the file. Required. - :type file_id: str - :return: VectorStoreFileDeletionStatus. The VectorStoreFileDeletionStatus is compatible with - MutableMapping - :rtype: ~azure.ai.agents.models._models.VectorStoreFileDeletionStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ + async def _update_memories_initial( + self, + name: str, + scope: str = _Unset, + body: Union[JSON, IO[bytes]] = _Unset, + items: Optional[List[dict[str, Any]]] = None, + previous_update_id: Optional[str] = None, + update_delay: Optional[int] = None, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + **kwargs: Any + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -3619,15 +13120,37 @@ async def _delete_vector_store_file( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models._models.VectorStoreFileDeletionStatus] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + if body is _Unset: + if scope is _Unset: + raise TypeError("missing required argument: scope") + body = { + "items": items, + "previous_update_id": previous_update_id, + "scope": scope, + "update_delay": update_delay, + } + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body - _request = build_vector_store_files_delete_vector_store_file_request( - vector_store_id=vector_store_id, - file_id=file_id, + _request = build_beta_memory_stores_update_memories_request( + name=name, + foundry_features=foundry_features, + content_type=content_type, api_version=self._config.api_version, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -3636,146 +13159,374 @@ async def _delete_vector_store_file( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) + error = self._deserialize.failsafe_deserialize( + _types_models2.ApiErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize( - _models._models.VectorStoreFileDeletionStatus, response.json() # pylint: disable=protected-access - ) + response_headers = {} + response_headers["Operation-Location"] = self._deserialize("str", response.headers.get("Operation-Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore + @overload + async def _begin_update_memories( + self, + name: str, + scope: str, + items: Optional[List[dict[str, Any]]] = None, + previous_update_id: Optional[str] = None, + update_delay: Optional[int] = None, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_types_models2.MemoryStoreUpdateCompletedResult]: ... + @overload + async def _begin_update_memories( + self, + name: str, + body: JSON, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_types_models2.MemoryStoreUpdateCompletedResult]: ... + @overload + async def _begin_update_memories( + self, + name: str, + body: IO[bytes], + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_types_models2.MemoryStoreUpdateCompletedResult]: ... -class VectorStoreFileBatchesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. + @distributed_trace_async + async def _begin_update_memories( + self, + name: str, + scope: str = _Unset, + body: Union[JSON, IO[bytes]] = _Unset, + items: Optional[List[dict[str, Any]]] = None, + previous_update_id: Optional[str] = None, + update_delay: Optional[int] = None, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + **kwargs: Any + ) -> AsyncLROPoller[_types_models2.MemoryStoreUpdateCompletedResult]: + """Update memory store with conversation memories. - Instead, you should access the following operations through - :class:`~azure.ai.agents.aio.AgentsClient`'s - :attr:`vector_store_file_batches` attribute. - """ + :param name: The name of the memory store to update. Required. + :type name: str + :param scope: The namespace that logically groups and isolates memories, such as a user ID. + Required. + :type scope: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :param items: Conversation items to be stored in memory. Default value is None. + :type items: list[dict[str, any]] + :param previous_update_id: The unique ID of the previous update request, enabling incremental + memory updates from where the last operation left off. Default value is None. + :type previous_update_id: str + :param update_delay: Timeout period before processing the memory update in seconds. + If a new update request is received during this period, it will cancel the current request and + reset the timeout. + Set to 0 to immediately trigger the update without delay. + Defaults to 300 (5 minutes). Default value is None. + :type update_delay: int + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW + :return: An instance of AsyncLROPoller that returns MemoryStoreUpdateCompletedResult + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.ai.agents.types.MemoryStoreUpdateCompletedResult] + :raises ~azure.core.exceptions.HttpResponseError: - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AgentsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "scope": "str", + "items": [ + { + "str": {} + } + ], + "previous_update_id": "str", + "update_delay": 0 + } + + # response body for status code(s): 202 + response == { + "memory_operations": [ + { + "kind": "str", + "memory_item": memory_item + } + ], + "usage": { + "embedding_tokens": 0, + "input_tokens": 0, + "input_tokens_details": { + "cached_tokens": 0 + }, + "output_tokens": 0, + "output_tokens_details": { + "reasoning_tokens": 0 + }, + "total_tokens": 0 + } + } + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_types_models2.MemoryStoreUpdateCompletedResult] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_memories_initial( + name=name, + scope=scope, + body=body, + items=items, + previous_update_id=previous_update_id, + update_delay=update_delay, + foundry_features=foundry_features, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Operation-Location"] = self._deserialize( + "str", response.headers.get("Operation-Location") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncLROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_types_models.MemoryStoreUpdateCompletedResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_types_models.MemoryStoreUpdateCompletedResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @overload - async def create( + async def delete_scope( self, - vector_store_id: str, + name: str, + scope: str, *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], content_type: str = "application/json", - file_ids: Optional[List[str]] = None, - data_sources: Optional[List[_models.VectorStoreDataSource]] = None, - chunking_strategy: Optional[_models.VectorStoreChunkingStrategyRequest] = None, **kwargs: Any - ) -> _models.VectorStoreFileBatch: - """Create a vector store file batch. - - :param vector_store_id: Identifier of the vector store. Required. - :type vector_store_id: str + ) -> _types_models2.MemoryStoreDeleteScopeResult: + """Delete all memories associated with a specific scope from a memory store. + + :param name: The name of the memory store. Required. + :type name: str + :param scope: The namespace that logically groups and isolates memories to delete, such as a + user ID. Required. + :type scope: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword file_ids: List of file identifiers. Default value is None. - :paramtype file_ids: list[str] - :keyword data_sources: List of Azure assets. Default value is None. - :paramtype data_sources: list[~azure.ai.agents.models.VectorStoreDataSource] - :keyword chunking_strategy: The chunking strategy used to chunk the file(s). If not set, will - use the auto strategy. Default value is None. - :paramtype chunking_strategy: ~azure.ai.agents.models.VectorStoreChunkingStrategyRequest - :return: VectorStoreFileBatch. The VectorStoreFileBatch is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.VectorStoreFileBatch + :return: MemoryStoreDeleteScopeResult + :rtype: ~azure.ai.agents.types.MemoryStoreDeleteScopeResult :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "deleted": bool, + "name": "str", + "object": "str", + "scope": "str" + } """ @overload - async def create( - self, vector_store_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.VectorStoreFileBatch: - """Create a vector store file batch. + async def delete_scope( + self, + name: str, + body: JSON, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models2.MemoryStoreDeleteScopeResult: + """Delete all memories associated with a specific scope from a memory store. - :param vector_store_id: Identifier of the vector store. Required. - :type vector_store_id: str + :param name: The name of the memory store. Required. + :type name: str :param body: Required. :type body: JSON + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: VectorStoreFileBatch. The VectorStoreFileBatch is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.VectorStoreFileBatch + :return: MemoryStoreDeleteScopeResult + :rtype: ~azure.ai.agents.types.MemoryStoreDeleteScopeResult :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "scope": "str" + } + + # response body for status code(s): 200 + response == { + "deleted": bool, + "name": "str", + "object": "str", + "scope": "str" + } """ @overload - async def create( - self, vector_store_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.VectorStoreFileBatch: - """Create a vector store file batch. + async def delete_scope( + self, + name: str, + body: IO[bytes], + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models2.MemoryStoreDeleteScopeResult: + """Delete all memories associated with a specific scope from a memory store. - :param vector_store_id: Identifier of the vector store. Required. - :type vector_store_id: str + :param name: The name of the memory store. Required. + :type name: str :param body: Required. :type body: IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: VectorStoreFileBatch. The VectorStoreFileBatch is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.VectorStoreFileBatch + :return: MemoryStoreDeleteScopeResult + :rtype: ~azure.ai.agents.types.MemoryStoreDeleteScopeResult :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "deleted": bool, + "name": "str", + "object": "str", + "scope": "str" + } """ @distributed_trace_async - async def create( + async def delete_scope( self, - vector_store_id: str, + name: str, + scope: str = _Unset, body: Union[JSON, IO[bytes]] = _Unset, *, - file_ids: Optional[List[str]] = None, - data_sources: Optional[List[_models.VectorStoreDataSource]] = None, - chunking_strategy: Optional[_models.VectorStoreChunkingStrategyRequest] = None, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], **kwargs: Any - ) -> _models.VectorStoreFileBatch: - """Create a vector store file batch. - - :param vector_store_id: Identifier of the vector store. Required. - :type vector_store_id: str + ) -> _types_models2.MemoryStoreDeleteScopeResult: + """Delete all memories associated with a specific scope from a memory store. + + :param name: The name of the memory store. Required. + :type name: str + :param scope: The namespace that logically groups and isolates memories to delete, such as a + user ID. Required. + :type scope: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :keyword file_ids: List of file identifiers. Default value is None. - :paramtype file_ids: list[str] - :keyword data_sources: List of Azure assets. Default value is None. - :paramtype data_sources: list[~azure.ai.agents.models.VectorStoreDataSource] - :keyword chunking_strategy: The chunking strategy used to chunk the file(s). If not set, will - use the auto strategy. Default value is None. - :paramtype chunking_strategy: ~azure.ai.agents.models.VectorStoreChunkingStrategyRequest - :return: VectorStoreFileBatch. The VectorStoreFileBatch is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.VectorStoreFileBatch + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW + :return: MemoryStoreDeleteScopeResult + :rtype: ~azure.ai.agents.types.MemoryStoreDeleteScopeResult :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "scope": "str" + } + + # response body for status code(s): 200 + response == { + "deleted": bool, + "name": "str", + "object": "str", + "scope": "str" + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3789,22 +13540,27 @@ async def create( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VectorStoreFileBatch] = kwargs.pop("cls", None) + cls: ClsType[_types_models2.MemoryStoreDeleteScopeResult] = kwargs.pop("cls", None) if body is _Unset: - body = {"chunking_strategy": chunking_strategy, "data_sources": data_sources, "file_ids": file_ids} + if scope is _Unset: + raise TypeError("missing required argument: scope") + body = {"scope": scope} body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" + _json = None _content = None if isinstance(body, (IOBase, bytes)): _content = body else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _json = body - _request = build_vector_store_file_batches_create_request( - vector_store_id=vector_store_id, + _request = build_beta_memory_stores_delete_scope_request( + name=name, + foundry_features=foundry_features, content_type=content_type, api_version=self._config.api_version, + json=_json, content=_content, headers=_headers, params=_params, @@ -3814,6 +13570,7 @@ async def create( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -3828,95 +13585,92 @@ async def create( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) + error = self._deserialize.failsafe_deserialize( + _types_models2.ApiErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.VectorStoreFileBatch, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace_async - async def get(self, vector_store_id: str, batch_id: str, **kwargs: Any) -> _models.VectorStoreFileBatch: - """Retrieve a vector store file batch. - - :param vector_store_id: Identifier of the vector store. Required. - :type vector_store_id: str - :param batch_id: Identifier of the file batch. Required. - :type batch_id: str - :return: VectorStoreFileBatch. The VectorStoreFileBatch is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.VectorStoreFileBatch - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.VectorStoreFileBatch] = kwargs.pop("cls", None) - - _request = build_vector_store_file_batches_get_request( - vector_store_id=vector_store_id, - batch_id=batch_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.VectorStoreFileBatch, response.json()) +class BetaRedTeamsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + Instead, you should access the following operations through + :class:`~azure.ai.agents.aio.AIProjectClient`'s + :attr:`red_teams` attribute. + """ - return deserialized # type: ignore + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def cancel(self, vector_store_id: str, batch_id: str, **kwargs: Any) -> _models.VectorStoreFileBatch: - """Cancel a vector store file batch. This attempts to cancel the processing of files in this batch - as soon as possible. - - :param vector_store_id: Identifier of the vector store. Required. - :type vector_store_id: str - :param batch_id: Identifier of the file batch. Required. - :type batch_id: str - :return: VectorStoreFileBatch. The VectorStoreFileBatch is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.VectorStoreFileBatch + async def get( + self, name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.RED_TEAMS_V1_PREVIEW], **kwargs: Any + ) -> _types_models2.RedTeam: + """Get a redteam by name. + + :param name: Identifier of the red team run. Required. + :type name: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. RED_TEAMS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.RED_TEAMS_V1_PREVIEW + :return: RedTeam + :rtype: ~azure.ai.agents.types.RedTeam :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AzureOpenAIModel": + target_config = { + "modelDeploymentName": "str", + "type": "AzureOpenAIModel" + } + + # response body for status code(s): 200 + response == { + "id": "str", + "target": target_config, + "applicationScenario": "str", + "attackStrategies": [ + "str" + ], + "displayName": "str", + "numTurns": 0, + "properties": { + "str": "str" + }, + "riskCategories": [ + "str" + ], + "simulationOnly": bool, + "status": "str", + "tags": { + "str": "str" + } + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3929,11 +13683,11 @@ async def cancel(self, vector_store_id: str, batch_id: str, **kwargs: Any) -> _m _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.VectorStoreFileBatch] = kwargs.pop("cls", None) + cls: ClsType[_types_models2.RedTeam] = kwargs.pop("cls", None) - _request = build_vector_store_file_batches_cancel_request( - vector_store_id=vector_store_id, - batch_id=batch_id, + _request = build_beta_red_teams_get_request( + name=name, + foundry_features=foundry_features, api_version=self._config.api_version, headers=_headers, params=_params, @@ -3943,6 +13697,7 @@ async def cancel(self, vector_store_id: str, batch_id: str, **kwargs: Any) -> _m } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -3957,13 +13712,15 @@ async def cancel(self, vector_store_id: str, batch_id: str, **kwargs: Any) -> _m except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.VectorStoreFileBatch, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -3971,45 +13728,57 @@ async def cancel(self, vector_store_id: str, batch_id: str, **kwargs: Any) -> _m return deserialized # type: ignore @distributed_trace - def list_files( - self, - vector_store_id: str, - batch_id: str, - *, - filter: Optional[Union[str, _models.VectorStoreFileStatusFilter]] = None, - limit: Optional[int] = None, - order: Optional[Union[str, _models.ListSortOrder]] = None, - before: Optional[str] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.VectorStoreFile"]: - """Returns a list of vector store files in a batch. - - :param vector_store_id: Identifier of the vector store. Required. - :type vector_store_id: str - :param batch_id: Identifier of the file batch. Required. - :type batch_id: str - :keyword filter: Filter by file status. Known values are: "in_progress", "completed", "failed", - and "cancelled". Default value is None. - :paramtype filter: str or ~azure.ai.agents.models.VectorStoreFileStatusFilter - :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and - 100, and the default is 20. Default value is None. - :paramtype limit: int - :keyword order: Sort order by the created_at timestamp of the objects. asc for ascending order - and desc for descending order. Known values are: "asc" and "desc". Default value is None. - :paramtype order: str or ~azure.ai.agents.models.ListSortOrder - :keyword 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. Default value is None. - :paramtype before: str - :return: An iterator like instance of VectorStoreFile - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.models.VectorStoreFile] + def list( + self, *, foundry_features: Literal[FoundryFeaturesOptInKeys.RED_TEAMS_V1_PREVIEW], **kwargs: Any + ) -> AsyncItemPaged["_types_models2.RedTeam"]: + """List a redteam by name. + + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. RED_TEAMS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.RED_TEAMS_V1_PREVIEW + :return: An iterator like instance of RedTeam + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.types.RedTeam] :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AzureOpenAIModel": + target_config = { + "modelDeploymentName": "str", + "type": "AzureOpenAIModel" + } + + # response body for status code(s): 200 + response == { + "id": "str", + "target": target_config, + "applicationScenario": "str", + "attackStrategies": [ + "str" + ], + "displayName": "str", + "numTurns": 0, + "properties": { + "str": "str" + }, + "riskCategories": [ + "str" + ], + "simulationOnly": bool, + "status": "str", + "tags": { + "str": "str" + } + } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.VectorStoreFile]] = kwargs.pop("cls", None) + cls: ClsType[List[_types_models2.RedTeam]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4019,35 +13788,56 @@ def list_files( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(_continuation_token=None): + def prepare_request(next_link=None): + if not next_link: + + _request = build_beta_red_teams_list_request( + foundry_features=foundry_features, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - _request = build_vector_store_file_batches_list_files_request( - vector_store_id=vector_store_id, - batch_id=batch_id, - filter=filter, - limit=limit, - order=order, - after=_continuation_token, - before=before, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) return _request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.VectorStoreFile], deserialized.get("data", [])) + list_of_elem = deserialized.get("value", []) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("last_id") or None, AsyncList(list_of_elem) + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - async def get_next(_continuation_token=None): - _request = prepare_request(_continuation_token) + async def get_next(next_link=None): + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access @@ -4057,173 +13847,247 @@ async def get_next(_continuation_token=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) return pipeline_response return AsyncItemPaged(get_next, extract_data) - -class _AgentsClientOperationsMixin( - ClientMixinABC[AsyncPipelineClient[HttpRequest, AsyncHttpResponse], AgentsClientConfiguration] -): - @overload - async def create_agent( + async def create( self, + red_team: _types_models2.RedTeam, *, - model: str, + foundry_features: Literal[FoundryFeaturesOptInKeys.RED_TEAMS_V1_PREVIEW], content_type: str = "application/json", - name: Optional[str] = None, - description: Optional[str] = None, - instructions: Optional[str] = None, - tools: Optional[List[_models.ToolDefinition]] = None, - tool_resources: Optional[_models.ToolResources] = None, - temperature: Optional[float] = None, - top_p: Optional[float] = None, - response_format: Optional["_types.AgentsResponseFormatOption"] = None, - metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> _models.Agent: - """Creates a new agent. - - :keyword model: The ID of the model to use. Required. - :paramtype model: str + ) -> _types_models2.RedTeam: + """Creates a redteam run. + + :param red_team: Redteam to be run. Required. + :type red_team: ~azure.ai.agents.types.RedTeam + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. RED_TEAMS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.RED_TEAMS_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword name: The name of the new agent. Default value is None. - :paramtype name: str - :keyword description: The description of the new agent. Default value is None. - :paramtype description: str - :keyword instructions: The system instructions for the new agent to use. Default value is None. - :paramtype instructions: str - :keyword tools: The collection of tools to enable for the new agent. Default value is None. - :paramtype tools: list[~azure.ai.agents.models.ToolDefinition] - :keyword tool_resources: 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. Default value is None. - :paramtype tool_resources: ~azure.ai.agents.models.ToolResources - :keyword temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 - will make the output more random, - while lower values like 0.2 will make it more focused and deterministic. Default value is - None. - :paramtype temperature: float - :keyword top_p: An alternative to sampling with temperature, called nucleus sampling, where the - model considers the results of the tokens with top_p probability mass. - So 0.1 means only the tokens comprising the top 10% probability mass are considered. - - We generally recommend altering this or temperature but not both. Default value is None. - :paramtype top_p: float - :keyword response_format: The response format of the tool calls used by this agent. Is one of - the following types: str, Union[str, "_models.AgentsResponseFormatMode"], AgentsResponseFormat, - ResponseFormatJsonSchemaType Default value is None. - :paramtype response_format: str or str or ~azure.ai.agents.models.AgentsResponseFormatMode or - ~azure.ai.agents.models.AgentsResponseFormat or - ~azure.ai.agents.models.ResponseFormatJsonSchemaType - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: Agent. The Agent is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.Agent + :return: RedTeam + :rtype: ~azure.ai.agents.types.RedTeam :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_agent(self, body: JSON, *, content_type: str = "application/json", **kwargs: Any) -> _models.Agent: - """Creates a new agent. - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Agent. The Agent is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.Agent - :raises ~azure.core.exceptions.HttpResponseError: + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "AzureOpenAIModel": + target_config = { + "modelDeploymentName": "str", + "type": "AzureOpenAIModel" + } + + # JSON input template you can fill out and use as your body input. + red_team = { + "id": "str", + "target": target_config, + "applicationScenario": "str", + "attackStrategies": [ + "str" + ], + "displayName": "str", + "numTurns": 0, + "properties": { + "str": "str" + }, + "riskCategories": [ + "str" + ], + "simulationOnly": bool, + "status": "str", + "tags": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AzureOpenAIModel": + target_config = { + "modelDeploymentName": "str", + "type": "AzureOpenAIModel" + } + + # response body for status code(s): 201 + response == { + "id": "str", + "target": target_config, + "applicationScenario": "str", + "attackStrategies": [ + "str" + ], + "displayName": "str", + "numTurns": 0, + "properties": { + "str": "str" + }, + "riskCategories": [ + "str" + ], + "simulationOnly": bool, + "status": "str", + "tags": { + "str": "str" + } + } """ @overload - async def create_agent( - self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Agent: - """Creates a new agent. - - :param body: Required. - :type body: IO[bytes] + async def create( + self, + red_team: IO[bytes], + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.RED_TEAMS_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models2.RedTeam: + """Creates a redteam run. + + :param red_team: Redteam to be run. Required. + :type red_team: IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. RED_TEAMS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.RED_TEAMS_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: Agent. The Agent is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.Agent + :return: RedTeam + :rtype: ~azure.ai.agents.types.RedTeam :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AzureOpenAIModel": + target_config = { + "modelDeploymentName": "str", + "type": "AzureOpenAIModel" + } + + # response body for status code(s): 201 + response == { + "id": "str", + "target": target_config, + "applicationScenario": "str", + "attackStrategies": [ + "str" + ], + "displayName": "str", + "numTurns": 0, + "properties": { + "str": "str" + }, + "riskCategories": [ + "str" + ], + "simulationOnly": bool, + "status": "str", + "tags": { + "str": "str" + } + } """ @distributed_trace_async - async def create_agent( + async def create( self, - body: Union[JSON, IO[bytes]] = _Unset, + red_team: Union[_types_models2.RedTeam, IO[bytes]], *, - model: str = _Unset, - name: Optional[str] = None, - description: Optional[str] = None, - instructions: Optional[str] = None, - tools: Optional[List[_models.ToolDefinition]] = None, - tool_resources: Optional[_models.ToolResources] = None, - temperature: Optional[float] = None, - top_p: Optional[float] = None, - response_format: Optional["_types.AgentsResponseFormatOption"] = None, - metadata: Optional[dict[str, str]] = None, + foundry_features: Literal[FoundryFeaturesOptInKeys.RED_TEAMS_V1_PREVIEW], **kwargs: Any - ) -> _models.Agent: - """Creates a new agent. - - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword model: The ID of the model to use. Required. - :paramtype model: str - :keyword name: The name of the new agent. Default value is None. - :paramtype name: str - :keyword description: The description of the new agent. Default value is None. - :paramtype description: str - :keyword instructions: The system instructions for the new agent to use. Default value is None. - :paramtype instructions: str - :keyword tools: The collection of tools to enable for the new agent. Default value is None. - :paramtype tools: list[~azure.ai.agents.models.ToolDefinition] - :keyword tool_resources: 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. Default value is None. - :paramtype tool_resources: ~azure.ai.agents.models.ToolResources - :keyword temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 - will make the output more random, - while lower values like 0.2 will make it more focused and deterministic. Default value is - None. - :paramtype temperature: float - :keyword top_p: An alternative to sampling with temperature, called nucleus sampling, where the - model considers the results of the tokens with top_p probability mass. - So 0.1 means only the tokens comprising the top 10% probability mass are considered. - - We generally recommend altering this or temperature but not both. Default value is None. - :paramtype top_p: float - :keyword response_format: The response format of the tool calls used by this agent. Is one of - the following types: str, Union[str, "_models.AgentsResponseFormatMode"], AgentsResponseFormat, - ResponseFormatJsonSchemaType Default value is None. - :paramtype response_format: str or str or ~azure.ai.agents.models.AgentsResponseFormatMode or - ~azure.ai.agents.models.AgentsResponseFormat or - ~azure.ai.agents.models.ResponseFormatJsonSchemaType - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: Agent. The Agent is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.Agent + ) -> _types_models2.RedTeam: + """Creates a redteam run. + + :param red_team: Redteam to be run. Is either a RedTeam type or a IO[bytes] type. Required. + :type red_team: ~azure.ai.agents.types.RedTeam or IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. RED_TEAMS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.RED_TEAMS_V1_PREVIEW + :return: RedTeam + :rtype: ~azure.ai.agents.types.RedTeam :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "AzureOpenAIModel": + target_config = { + "modelDeploymentName": "str", + "type": "AzureOpenAIModel" + } + + # JSON input template you can fill out and use as your body input. + red_team = { + "id": "str", + "target": target_config, + "applicationScenario": "str", + "attackStrategies": [ + "str" + ], + "displayName": "str", + "numTurns": 0, + "properties": { + "str": "str" + }, + "riskCategories": [ + "str" + ], + "simulationOnly": bool, + "status": "str", + "tags": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AzureOpenAIModel": + target_config = { + "modelDeploymentName": "str", + "type": "AzureOpenAIModel" + } + + # response body for status code(s): 201 + response == { + "id": "str", + "target": target_config, + "applicationScenario": "str", + "attackStrategies": [ + "str" + ], + "displayName": "str", + "numTurns": 0, + "properties": { + "str": "str" + }, + "riskCategories": [ + "str" + ], + "simulationOnly": bool, + "status": "str", + "tags": { + "str": "str" + } + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4237,35 +14101,241 @@ async def create_agent( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Agent] = kwargs.pop("cls", None) + cls: ClsType[_types_models2.RedTeam] = kwargs.pop("cls", None) - if body is _Unset: - if model is _Unset: - raise TypeError("missing required argument: model") - body = { - "description": description, - "instructions": instructions, - "metadata": metadata, - "model": model, - "name": name, - "response_format": response_format, - "temperature": temperature, - "tool_resources": tool_resources, - "tools": tools, - "top_p": top_p, - } - body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" + _json = None _content = None - if isinstance(body, (IOBase, bytes)): - _content = body + if isinstance(red_team, (IOBase, bytes)): + _content = red_team + else: + _json = red_team + + _request = build_beta_red_teams_create_request( + foundry_features=foundry_features, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [201]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _types_models2.ApiErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class BetaSchedulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.agents.aio.AIProjectClient`'s + :attr:`schedules` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def delete( + self, + schedule_id: str, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], + **kwargs: Any + ) -> None: + """Delete a schedule. + + :param schedule_id: Identifier of the schedule. Required. + :type schedule_id: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. SCHEDULES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.SCHEDULES_V1_PREVIEW + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_beta_schedules_delete_request( + schedule_id=schedule_id, + foundry_features=foundry_features, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def get( + self, + schedule_id: str, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], + **kwargs: Any + ) -> _types_models2.Schedule: + """Get a schedule by id. + + :param schedule_id: Identifier of the schedule. Required. + :type schedule_id: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. SCHEDULES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.SCHEDULES_V1_PREVIEW + :return: Schedule + :rtype: ~azure.ai.agents.types.Schedule + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "Cron": + trigger = { + "expression": "str", + "type": "Cron", + "endTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "timeZone": "str" + } + + # JSON input template for discriminator value "OneTime": + trigger = { + "triggerAt": "2020-02-20 00:00:00", + "type": "OneTime", + "timeZone": "str" + } + + # JSON input template for discriminator value "Recurrence": + trigger = { + "interval": 0, + "schedule": recurrence_schedule, + "type": "Recurrence", + "endTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "timeZone": "str" + } + + # JSON input template for discriminator value "Daily": + recurrence_schedule = { + "hours": [ + 0 + ], + "type": "Daily" + } + + # JSON input template for discriminator value "Hourly": + recurrence_schedule = { + "type": "Hourly" + } + + # response body for status code(s): 200 + response == { + "enabled": bool, + "id": "str", + "systemData": { + "str": "str" + }, + "task": schedule_task, + "trigger": trigger, + "description": "str", + "displayName": "str", + "properties": { + "str": "str" + }, + "provisioningStatus": "str", + "tags": { + "str": "str" + } + } + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_types_models2.Schedule] = kwargs.pop("cls", None) - _request = build_agents_create_agent_request( - content_type=content_type, + _request = build_beta_schedules_get_request( + schedule_id=schedule_id, + foundry_features=foundry_features, api_version=self._config.api_version, - content=_content, headers=_headers, params=_params, ) @@ -4274,8 +14344,9 @@ async def create_agent( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -4288,13 +14359,15 @@ async def create_agent( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.Agent, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -4302,35 +14375,97 @@ async def create_agent( return deserialized # type: ignore @distributed_trace - def list_agents( + def list( self, *, - limit: Optional[int] = None, - order: Optional[Union[str, _models.ListSortOrder]] = None, - before: Optional[str] = None, + foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], + type: Optional[types.ScheduleTaskType] = None, + enabled: Optional[bool] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.Agent"]: - """Gets a list of agents that were previously created. + ) -> AsyncItemPaged["_types_models2.Schedule"]: + """List all schedules. - :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and - 100, and the default is 20. Default value is None. - :paramtype limit: int - :keyword order: Sort order by the created_at timestamp of the objects. asc for ascending order - and desc for descending order. Known values are: "asc" and "desc". Default value is None. - :paramtype order: str or ~azure.ai.agents.models.ListSortOrder - :keyword 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. Default value is None. - :paramtype before: str - :return: An iterator like instance of Agent - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.models.Agent] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. SCHEDULES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.SCHEDULES_V1_PREVIEW + :keyword type: Filter by the type of schedule. Known values are: "Evaluation" and "Insight". + Default value is None. + :paramtype type: str or ~azure.ai.agents.models.ScheduleTaskType + :keyword enabled: Filter by the enabled status. Default value is None. + :paramtype enabled: bool + :return: An iterator like instance of Schedule + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.types.Schedule] :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "Cron": + trigger = { + "expression": "str", + "type": "Cron", + "endTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "timeZone": "str" + } + + # JSON input template for discriminator value "OneTime": + trigger = { + "triggerAt": "2020-02-20 00:00:00", + "type": "OneTime", + "timeZone": "str" + } + + # JSON input template for discriminator value "Recurrence": + trigger = { + "interval": 0, + "schedule": recurrence_schedule, + "type": "Recurrence", + "endTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "timeZone": "str" + } + + # JSON input template for discriminator value "Daily": + recurrence_schedule = { + "hours": [ + 0 + ], + "type": "Daily" + } + + # JSON input template for discriminator value "Hourly": + recurrence_schedule = { + "type": "Hourly" + } + + # response body for status code(s): 200 + response == { + "enabled": bool, + "id": "str", + "systemData": { + "str": "str" + }, + "task": schedule_task, + "trigger": trigger, + "description": "str", + "displayName": "str", + "properties": { + "str": "str" + }, + "provisioningStatus": "str", + "tags": { + "str": "str" + } + } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.Agent]] = kwargs.pop("cls", None) + cls: ClsType[List[_types_models2.Schedule]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4340,280 +14475,594 @@ def list_agents( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(_continuation_token=None): + def prepare_request(next_link=None): + if not next_link: + + _request = build_beta_schedules_list_request( + foundry_features=foundry_features, + type=type, + enabled=enabled, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - _request = build_agents_list_agents_request( - limit=limit, - order=order, - after=_continuation_token, - before=before, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) return _request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.Agent], deserialized.get("data", [])) + list_of_elem = deserialized.get("value", []) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("last_id") or None, AsyncList(list_of_elem) + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - async def get_next(_continuation_token=None): - _request = prepare_request(_continuation_token) + async def get_next(next_link=None): + _request = prepare_request(next_link) _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) return pipeline_response return AsyncItemPaged(get_next, extract_data) - @distributed_trace_async - async def get_agent(self, agent_id: str, **kwargs: Any) -> _models.Agent: - """Retrieves an existing agent. - - :param agent_id: Identifier of the agent. Required. - :type agent_id: str - :return: Agent. The Agent is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.Agent - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.Agent] = kwargs.pop("cls", None) - - _request = build_agents_get_agent_request( - agent_id=agent_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) - - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.Agent, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - @overload - async def update_agent( + async def create_or_update( self, - agent_id: str, + schedule_id: str, + schedule: _types_models2.Schedule, *, + foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], content_type: str = "application/json", - model: Optional[str] = None, - name: Optional[str] = None, - description: Optional[str] = None, - instructions: Optional[str] = None, - tools: Optional[List[_models.ToolDefinition]] = None, - tool_resources: Optional[_models.ToolResources] = None, - temperature: Optional[float] = None, - top_p: Optional[float] = None, - response_format: Optional["_types.AgentsResponseFormatOption"] = None, - metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> _models.Agent: - """Modifies an existing agent. - - :param agent_id: The ID of the agent to modify. Required. - :type agent_id: str + ) -> _types_models2.Schedule: + """Create or update operation template. + + :param schedule_id: Identifier of the schedule. Required. + :type schedule_id: str + :param schedule: The resource instance. Required. + :type schedule: ~azure.ai.agents.types.Schedule + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. SCHEDULES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.SCHEDULES_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword model: The ID of the model to use. Default value is None. - :paramtype model: str - :keyword name: The modified name for the agent to use. Default value is None. - :paramtype name: str - :keyword description: The modified description for the agent to use. Default value is None. - :paramtype description: str - :keyword instructions: The modified system instructions for the new agent to use. Default value - is None. - :paramtype instructions: str - :keyword tools: The modified collection of tools to enable for the agent. Default value is - None. - :paramtype tools: list[~azure.ai.agents.models.ToolDefinition] - :keyword tool_resources: 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. Default value is None. - :paramtype tool_resources: ~azure.ai.agents.models.ToolResources - :keyword temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 - will make the output more random, - while lower values like 0.2 will make it more focused and deterministic. Default value is - None. - :paramtype temperature: float - :keyword top_p: An alternative to sampling with temperature, called nucleus sampling, where the - model considers the results of the tokens with top_p probability mass. - So 0.1 means only the tokens comprising the top 10% probability mass are considered. - - We generally recommend altering this or temperature but not both. Default value is None. - :paramtype top_p: float - :keyword response_format: The response format of the tool calls used by this agent. Is one of - the following types: str, Union[str, "_models.AgentsResponseFormatMode"], AgentsResponseFormat, - ResponseFormatJsonSchemaType Default value is None. - :paramtype response_format: str or str or ~azure.ai.agents.models.AgentsResponseFormatMode or - ~azure.ai.agents.models.AgentsResponseFormat or - ~azure.ai.agents.models.ResponseFormatJsonSchemaType - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: Agent. The Agent is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.Agent + :return: Schedule + :rtype: ~azure.ai.agents.types.Schedule :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update_agent( - self, agent_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Agent: - """Modifies an existing agent. - :param agent_id: The ID of the agent to modify. Required. - :type agent_id: str - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Agent. The Agent is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.Agent - :raises ~azure.core.exceptions.HttpResponseError: + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "Cron": + trigger = { + "expression": "str", + "type": "Cron", + "endTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "timeZone": "str" + } + + # JSON input template for discriminator value "OneTime": + trigger = { + "triggerAt": "2020-02-20 00:00:00", + "type": "OneTime", + "timeZone": "str" + } + + # JSON input template for discriminator value "Recurrence": + trigger = { + "interval": 0, + "schedule": recurrence_schedule, + "type": "Recurrence", + "endTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "timeZone": "str" + } + + # JSON input template for discriminator value "Daily": + recurrence_schedule = { + "hours": [ + 0 + ], + "type": "Daily" + } + + # JSON input template for discriminator value "Hourly": + recurrence_schedule = { + "type": "Hourly" + } + + # JSON input template you can fill out and use as your body input. + schedule = { + "enabled": bool, + "id": "str", + "systemData": { + "str": "str" + }, + "task": schedule_task, + "trigger": trigger, + "description": "str", + "displayName": "str", + "properties": { + "str": "str" + }, + "provisioningStatus": "str", + "tags": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "Cron": + trigger = { + "expression": "str", + "type": "Cron", + "endTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "timeZone": "str" + } + + # JSON input template for discriminator value "OneTime": + trigger = { + "triggerAt": "2020-02-20 00:00:00", + "type": "OneTime", + "timeZone": "str" + } + + # JSON input template for discriminator value "Recurrence": + trigger = { + "interval": 0, + "schedule": recurrence_schedule, + "type": "Recurrence", + "endTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "timeZone": "str" + } + + # JSON input template for discriminator value "Daily": + recurrence_schedule = { + "hours": [ + 0 + ], + "type": "Daily" + } + + # JSON input template for discriminator value "Hourly": + recurrence_schedule = { + "type": "Hourly" + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "Cron": + trigger = { + "expression": "str", + "type": "Cron", + "endTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "timeZone": "str" + } + + # JSON input template for discriminator value "OneTime": + trigger = { + "triggerAt": "2020-02-20 00:00:00", + "type": "OneTime", + "timeZone": "str" + } + + # JSON input template for discriminator value "Recurrence": + trigger = { + "interval": 0, + "schedule": recurrence_schedule, + "type": "Recurrence", + "endTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "timeZone": "str" + } + + # JSON input template for discriminator value "Daily": + recurrence_schedule = { + "hours": [ + 0 + ], + "type": "Daily" + } + + # JSON input template for discriminator value "Hourly": + recurrence_schedule = { + "type": "Hourly" + } + + # response body for status code(s): 201, 200 + response == { + "enabled": bool, + "id": "str", + "systemData": { + "str": "str" + }, + "task": schedule_task, + "trigger": trigger, + "description": "str", + "displayName": "str", + "properties": { + "str": "str" + }, + "provisioningStatus": "str", + "tags": { + "str": "str" + } + } """ @overload - async def update_agent( - self, agent_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Agent: - """Modifies an existing agent. - - :param agent_id: The ID of the agent to modify. Required. - :type agent_id: str - :param body: Required. - :type body: IO[bytes] + async def create_or_update( + self, + schedule_id: str, + schedule: IO[bytes], + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models2.Schedule: + """Create or update operation template. + + :param schedule_id: Identifier of the schedule. Required. + :type schedule_id: str + :param schedule: The resource instance. Required. + :type schedule: IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. SCHEDULES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.SCHEDULES_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: Agent. The Agent is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.Agent + :return: Schedule + :rtype: ~azure.ai.agents.types.Schedule :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "Cron": + trigger = { + "expression": "str", + "type": "Cron", + "endTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "timeZone": "str" + } + + # JSON input template for discriminator value "OneTime": + trigger = { + "triggerAt": "2020-02-20 00:00:00", + "type": "OneTime", + "timeZone": "str" + } + + # JSON input template for discriminator value "Recurrence": + trigger = { + "interval": 0, + "schedule": recurrence_schedule, + "type": "Recurrence", + "endTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "timeZone": "str" + } + + # JSON input template for discriminator value "Daily": + recurrence_schedule = { + "hours": [ + 0 + ], + "type": "Daily" + } + + # JSON input template for discriminator value "Hourly": + recurrence_schedule = { + "type": "Hourly" + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "Cron": + trigger = { + "expression": "str", + "type": "Cron", + "endTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "timeZone": "str" + } + + # JSON input template for discriminator value "OneTime": + trigger = { + "triggerAt": "2020-02-20 00:00:00", + "type": "OneTime", + "timeZone": "str" + } + + # JSON input template for discriminator value "Recurrence": + trigger = { + "interval": 0, + "schedule": recurrence_schedule, + "type": "Recurrence", + "endTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "timeZone": "str" + } + + # JSON input template for discriminator value "Daily": + recurrence_schedule = { + "hours": [ + 0 + ], + "type": "Daily" + } + + # JSON input template for discriminator value "Hourly": + recurrence_schedule = { + "type": "Hourly" + } + + # response body for status code(s): 201, 200 + response == { + "enabled": bool, + "id": "str", + "systemData": { + "str": "str" + }, + "task": schedule_task, + "trigger": trigger, + "description": "str", + "displayName": "str", + "properties": { + "str": "str" + }, + "provisioningStatus": "str", + "tags": { + "str": "str" + } + } """ @distributed_trace_async - async def update_agent( + async def create_or_update( self, - agent_id: str, - body: Union[JSON, IO[bytes]] = _Unset, + schedule_id: str, + schedule: Union[_types_models2.Schedule, IO[bytes]], *, - model: Optional[str] = None, - name: Optional[str] = None, - description: Optional[str] = None, - instructions: Optional[str] = None, - tools: Optional[List[_models.ToolDefinition]] = None, - tool_resources: Optional[_models.ToolResources] = None, - temperature: Optional[float] = None, - top_p: Optional[float] = None, - response_format: Optional["_types.AgentsResponseFormatOption"] = None, - metadata: Optional[dict[str, str]] = None, + foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], **kwargs: Any - ) -> _models.Agent: - """Modifies an existing agent. + ) -> _types_models2.Schedule: + """Create or update operation template. - :param agent_id: The ID of the agent to modify. Required. - :type agent_id: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword model: The ID of the model to use. Default value is None. - :paramtype model: str - :keyword name: The modified name for the agent to use. Default value is None. - :paramtype name: str - :keyword description: The modified description for the agent to use. Default value is None. - :paramtype description: str - :keyword instructions: The modified system instructions for the new agent to use. Default value - is None. - :paramtype instructions: str - :keyword tools: The modified collection of tools to enable for the agent. Default value is - None. - :paramtype tools: list[~azure.ai.agents.models.ToolDefinition] - :keyword tool_resources: 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. Default value is None. - :paramtype tool_resources: ~azure.ai.agents.models.ToolResources - :keyword temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 - will make the output more random, - while lower values like 0.2 will make it more focused and deterministic. Default value is - None. - :paramtype temperature: float - :keyword top_p: An alternative to sampling with temperature, called nucleus sampling, where the - model considers the results of the tokens with top_p probability mass. - So 0.1 means only the tokens comprising the top 10% probability mass are considered. - - We generally recommend altering this or temperature but not both. Default value is None. - :paramtype top_p: float - :keyword response_format: The response format of the tool calls used by this agent. Is one of - the following types: str, Union[str, "_models.AgentsResponseFormatMode"], AgentsResponseFormat, - ResponseFormatJsonSchemaType Default value is None. - :paramtype response_format: str or str or ~azure.ai.agents.models.AgentsResponseFormatMode or - ~azure.ai.agents.models.AgentsResponseFormat or - ~azure.ai.agents.models.ResponseFormatJsonSchemaType - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: Agent. The Agent is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.Agent + :param schedule_id: Identifier of the schedule. Required. + :type schedule_id: str + :param schedule: The resource instance. Is either a Schedule type or a IO[bytes] type. + Required. + :type schedule: ~azure.ai.agents.types.Schedule or IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. SCHEDULES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.SCHEDULES_V1_PREVIEW + :return: Schedule + :rtype: ~azure.ai.agents.types.Schedule :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "Cron": + trigger = { + "expression": "str", + "type": "Cron", + "endTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "timeZone": "str" + } + + # JSON input template for discriminator value "OneTime": + trigger = { + "triggerAt": "2020-02-20 00:00:00", + "type": "OneTime", + "timeZone": "str" + } + + # JSON input template for discriminator value "Recurrence": + trigger = { + "interval": 0, + "schedule": recurrence_schedule, + "type": "Recurrence", + "endTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "timeZone": "str" + } + + # JSON input template for discriminator value "Daily": + recurrence_schedule = { + "hours": [ + 0 + ], + "type": "Daily" + } + + # JSON input template for discriminator value "Hourly": + recurrence_schedule = { + "type": "Hourly" + } + + # JSON input template you can fill out and use as your body input. + schedule = { + "enabled": bool, + "id": "str", + "systemData": { + "str": "str" + }, + "task": schedule_task, + "trigger": trigger, + "description": "str", + "displayName": "str", + "properties": { + "str": "str" + }, + "provisioningStatus": "str", + "tags": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "Cron": + trigger = { + "expression": "str", + "type": "Cron", + "endTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "timeZone": "str" + } + + # JSON input template for discriminator value "OneTime": + trigger = { + "triggerAt": "2020-02-20 00:00:00", + "type": "OneTime", + "timeZone": "str" + } + + # JSON input template for discriminator value "Recurrence": + trigger = { + "interval": 0, + "schedule": recurrence_schedule, + "type": "Recurrence", + "endTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "timeZone": "str" + } + + # JSON input template for discriminator value "Daily": + recurrence_schedule = { + "hours": [ + 0 + ], + "type": "Daily" + } + + # JSON input template for discriminator value "Hourly": + recurrence_schedule = { + "type": "Hourly" + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "Cron": + trigger = { + "expression": "str", + "type": "Cron", + "endTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "timeZone": "str" + } + + # JSON input template for discriminator value "OneTime": + trigger = { + "triggerAt": "2020-02-20 00:00:00", + "type": "OneTime", + "timeZone": "str" + } + + # JSON input template for discriminator value "Recurrence": + trigger = { + "interval": 0, + "schedule": recurrence_schedule, + "type": "Recurrence", + "endTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "timeZone": "str" + } + + # JSON input template for discriminator value "Daily": + recurrence_schedule = { + "hours": [ + 0 + ], + "type": "Daily" + } + + # JSON input template for discriminator value "Hourly": + recurrence_schedule = { + "type": "Hourly" + } + + # response body for status code(s): 201, 200 + response == { + "enabled": bool, + "id": "str", + "systemData": { + "str": "str" + }, + "task": schedule_task, + "trigger": trigger, + "description": "str", + "displayName": "str", + "properties": { + "str": "str" + }, + "provisioningStatus": "str", + "tags": { + "str": "str" + } + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4627,33 +15076,22 @@ async def update_agent( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Agent] = kwargs.pop("cls", None) + cls: ClsType[_types_models2.Schedule] = kwargs.pop("cls", None) - if body is _Unset: - body = { - "description": description, - "instructions": instructions, - "metadata": metadata, - "model": model, - "name": name, - "response_format": response_format, - "temperature": temperature, - "tool_resources": tool_resources, - "tools": tools, - "top_p": top_p, - } - body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" + _json = None _content = None - if isinstance(body, (IOBase, bytes)): - _content = body + if isinstance(schedule, (IOBase, bytes)): + _content = schedule else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _json = schedule - _request = build_agents_update_agent_request( - agent_id=agent_id, + _request = build_beta_schedules_create_or_update_request( + schedule_id=schedule_id, + foundry_features=foundry_features, content_type=content_type, api_version=self._config.api_version, + json=_json, content=_content, headers=_headers, params=_params, @@ -4663,27 +15101,30 @@ async def update_agent( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 201]: if _stream: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.Agent, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -4691,14 +15132,41 @@ async def update_agent( return deserialized # type: ignore @distributed_trace_async - async def _delete_agent(self, agent_id: str, **kwargs: Any) -> _models._models.AgentDeletionStatus: - """Deletes an agent. + async def get_run( + self, + schedule_id: str, + run_id: str, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], + **kwargs: Any + ) -> _types_models2.ScheduleRun: + """Get a schedule run by id. - :param agent_id: Identifier of the agent. Required. - :type agent_id: str - :return: AgentDeletionStatus. The AgentDeletionStatus is compatible with MutableMapping - :rtype: ~azure.ai.agents.models._models.AgentDeletionStatus + :param schedule_id: The unique identifier of the schedule. Required. + :type schedule_id: str + :param run_id: The unique identifier of the schedule run. Required. + :type run_id: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. SCHEDULES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.SCHEDULES_V1_PREVIEW + :return: ScheduleRun + :rtype: ~azure.ai.agents.types.ScheduleRun :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "id": "str", + "properties": { + "str": "str" + }, + "scheduleId": "str", + "success": bool, + "error": "str", + "triggerTime": "2020-02-20 00:00:00" + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4711,10 +15179,12 @@ async def _delete_agent(self, agent_id: str, **kwargs: Any) -> _models._models.A _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models._models.AgentDeletionStatus] = kwargs.pop("cls", None) + cls: ClsType[_types_models2.ScheduleRun] = kwargs.pop("cls", None) - _request = build_agents_delete_agent_request( - agent_id=agent_id, + _request = build_beta_schedules_get_run_request( + schedule_id=schedule_id, + run_id=run_id, + foundry_features=foundry_features, api_version=self._config.api_version, headers=_headers, params=_params, @@ -4724,8 +15194,9 @@ async def _delete_agent(self, agent_id: str, **kwargs: Any) -> _models._models.A } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -4738,257 +15209,71 @@ async def _delete_agent(self, agent_id: str, **kwargs: Any) -> _models._models.A except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) + error = self._deserialize.failsafe_deserialize( + _types_models2.ApiErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize( - _models._models.AgentDeletionStatus, response.json() # pylint: disable=protected-access - ) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - async def create_thread_and_run( + @distributed_trace + def list_runs( self, + schedule_id: str, *, - agent_id: str, - content_type: str = "application/json", - thread: Optional[_models.AgentThreadCreationOptions] = None, - model: Optional[str] = None, - instructions: Optional[str] = None, - tools: Optional[List[_models.ToolDefinition]] = None, - tool_resources: Optional[_models.ToolResources] = None, - stream_parameter: Optional[bool] = None, - temperature: Optional[float] = None, - top_p: Optional[float] = None, - max_prompt_tokens: Optional[int] = None, - max_completion_tokens: Optional[int] = None, - truncation_strategy: Optional[_models.TruncationObject] = None, - tool_choice: Optional["_types.AgentsToolChoiceOption"] = None, - response_format: Optional["_types.AgentsResponseFormatOption"] = None, - parallel_tool_calls: Optional[bool] = None, - metadata: Optional[dict[str, str]] = None, + foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], + type: Optional[types.ScheduleTaskType] = None, + enabled: Optional[bool] = None, **kwargs: Any - ) -> _models.ThreadRun: - """Creates a new agent thread and immediately starts a run using that new thread. - - :keyword agent_id: The ID of the agent for which the thread should be created. Required. - :paramtype agent_id: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword thread: The details used to create the new thread. If no thread is provided, an empty - one will be created. Default value is None. - :paramtype thread: ~azure.ai.agents.models.AgentThreadCreationOptions - :keyword model: The overridden model that the agent should use to run the thread. Default value - is None. - :paramtype model: str - :keyword instructions: The overridden system instructions the agent should use to run the - thread. Default value is None. - :paramtype instructions: str - :keyword tools: The overridden list of enabled tools the agent should use to run the thread. - Default value is None. - :paramtype tools: list[~azure.ai.agents.models.ToolDefinition] - :keyword tool_resources: Override the tools the agent can use for this run. This is useful for - modifying the behavior on a per-run basis. Default value is None. - :paramtype tool_resources: ~azure.ai.agents.models.ToolResources - :keyword stream_parameter: 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. Default - value is None. - :paramtype stream_parameter: bool - :keyword temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 - will make the output - more random, while lower values like 0.2 will make it more focused and deterministic. Default - value is None. - :paramtype temperature: float - :keyword top_p: An alternative to sampling with temperature, called nucleus sampling, where the - model - considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens - comprising the top 10% probability mass are considered. - - We generally recommend altering this or temperature but not both. Default value is None. - :paramtype top_p: float - :keyword max_prompt_tokens: 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. Default - value is None. - :paramtype max_prompt_tokens: int - :keyword max_completion_tokens: 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. Default value is None. - :paramtype max_completion_tokens: int - :keyword truncation_strategy: The strategy to use for dropping messages as the context windows - moves forward. Default value is None. - :paramtype truncation_strategy: ~azure.ai.agents.models.TruncationObject - :keyword tool_choice: Controls whether or not and which tool is called by the model. Is one of - the following types: str, Union[str, "_models.AgentsToolChoiceOptionMode"], - AgentsNamedToolChoice Default value is None. - :paramtype tool_choice: str or str or ~azure.ai.agents.models.AgentsToolChoiceOptionMode or - ~azure.ai.agents.models.AgentsNamedToolChoice - :keyword response_format: Specifies the format that the model must output. Is one of the - following types: str, Union[str, "_models.AgentsResponseFormatMode"], AgentsResponseFormat, - ResponseFormatJsonSchemaType Default value is None. - :paramtype response_format: str or str or ~azure.ai.agents.models.AgentsResponseFormatMode or - ~azure.ai.agents.models.AgentsResponseFormat or - ~azure.ai.agents.models.ResponseFormatJsonSchemaType - :keyword parallel_tool_calls: If ``true`` functions will run in parallel during tool use. + ) -> AsyncItemPaged["_types_models2.ScheduleRun"]: + """List all schedule runs. + + :param schedule_id: Identifier of the schedule. Required. + :type schedule_id: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. SCHEDULES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.SCHEDULES_V1_PREVIEW + :keyword type: Filter by the type of schedule. Known values are: "Evaluation" and "Insight". Default value is None. - :paramtype parallel_tool_calls: bool - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: ThreadRun. The ThreadRun is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadRun - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_thread_and_run( - self, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ThreadRun: - """Creates a new agent thread and immediately starts a run using that new thread. - - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ThreadRun. The ThreadRun is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadRun + :paramtype type: str or ~azure.ai.agents.models.ScheduleTaskType + :keyword enabled: Filter by the enabled status. Default value is None. + :paramtype enabled: bool + :return: An iterator like instance of ScheduleRun + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.types.ScheduleRun] :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_thread_and_run( - self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ThreadRun: - """Creates a new agent thread and immediately starts a run using that new thread. - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: ThreadRun. The ThreadRun is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadRun - :raises ~azure.core.exceptions.HttpResponseError: + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "id": "str", + "properties": { + "str": "str" + }, + "scheduleId": "str", + "success": bool, + "error": "str", + "triggerTime": "2020-02-20 00:00:00" + } """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - @distributed_trace_async - async def create_thread_and_run( - self, - body: Union[JSON, IO[bytes]] = _Unset, - *, - agent_id: str = _Unset, - thread: Optional[_models.AgentThreadCreationOptions] = None, - model: Optional[str] = None, - instructions: Optional[str] = None, - tools: Optional[List[_models.ToolDefinition]] = None, - tool_resources: Optional[_models.ToolResources] = None, - stream_parameter: Optional[bool] = None, - temperature: Optional[float] = None, - top_p: Optional[float] = None, - max_prompt_tokens: Optional[int] = None, - max_completion_tokens: Optional[int] = None, - truncation_strategy: Optional[_models.TruncationObject] = None, - tool_choice: Optional["_types.AgentsToolChoiceOption"] = None, - response_format: Optional["_types.AgentsResponseFormatOption"] = None, - parallel_tool_calls: Optional[bool] = None, - metadata: Optional[dict[str, str]] = None, - **kwargs: Any - ) -> _models.ThreadRun: - """Creates a new agent thread and immediately starts a run using that new thread. + cls: ClsType[List[_types_models2.ScheduleRun]] = kwargs.pop("cls", None) - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword agent_id: The ID of the agent for which the thread should be created. Required. - :paramtype agent_id: str - :keyword thread: The details used to create the new thread. If no thread is provided, an empty - one will be created. Default value is None. - :paramtype thread: ~azure.ai.agents.models.AgentThreadCreationOptions - :keyword model: The overridden model that the agent should use to run the thread. Default value - is None. - :paramtype model: str - :keyword instructions: The overridden system instructions the agent should use to run the - thread. Default value is None. - :paramtype instructions: str - :keyword tools: The overridden list of enabled tools the agent should use to run the thread. - Default value is None. - :paramtype tools: list[~azure.ai.agents.models.ToolDefinition] - :keyword tool_resources: Override the tools the agent can use for this run. This is useful for - modifying the behavior on a per-run basis. Default value is None. - :paramtype tool_resources: ~azure.ai.agents.models.ToolResources - :keyword stream_parameter: 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. Default - value is None. - :paramtype stream_parameter: bool - :keyword temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 - will make the output - more random, while lower values like 0.2 will make it more focused and deterministic. Default - value is None. - :paramtype temperature: float - :keyword top_p: An alternative to sampling with temperature, called nucleus sampling, where the - model - considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens - comprising the top 10% probability mass are considered. - - We generally recommend altering this or temperature but not both. Default value is None. - :paramtype top_p: float - :keyword max_prompt_tokens: 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. Default - value is None. - :paramtype max_prompt_tokens: int - :keyword max_completion_tokens: 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. Default value is None. - :paramtype max_completion_tokens: int - :keyword truncation_strategy: The strategy to use for dropping messages as the context windows - moves forward. Default value is None. - :paramtype truncation_strategy: ~azure.ai.agents.models.TruncationObject - :keyword tool_choice: Controls whether or not and which tool is called by the model. Is one of - the following types: str, Union[str, "_models.AgentsToolChoiceOptionMode"], - AgentsNamedToolChoice Default value is None. - :paramtype tool_choice: str or str or ~azure.ai.agents.models.AgentsToolChoiceOptionMode or - ~azure.ai.agents.models.AgentsNamedToolChoice - :keyword response_format: Specifies the format that the model must output. Is one of the - following types: str, Union[str, "_models.AgentsResponseFormatMode"], AgentsResponseFormat, - ResponseFormatJsonSchemaType Default value is None. - :paramtype response_format: str or str or ~azure.ai.agents.models.AgentsResponseFormatMode or - ~azure.ai.agents.models.AgentsResponseFormat or - ~azure.ai.agents.models.ResponseFormatJsonSchemaType - :keyword parallel_tool_calls: If ``true`` functions will run in parallel during tool use. - Default value is None. - :paramtype parallel_tool_calls: bool - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: ThreadRun. The ThreadRun is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadRun - :raises ~azure.core.exceptions.HttpResponseError: - """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4997,76 +15282,70 @@ async def create_thread_and_run( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ThreadRun] = kwargs.pop("cls", None) - - if body is _Unset: - if agent_id is _Unset: - raise TypeError("missing required argument: agent_id") - body = { - "assistant_id": agent_id, - "instructions": instructions, - "max_completion_tokens": max_completion_tokens, - "max_prompt_tokens": max_prompt_tokens, - "metadata": metadata, - "model": model, - "parallel_tool_calls": parallel_tool_calls, - "response_format": response_format, - "stream": stream_parameter, - "temperature": temperature, - "thread": thread, - "tool_choice": tool_choice, - "tool_resources": tool_resources, - "tools": tools, - "top_p": top_p, - "truncation_strategy": truncation_strategy, - } - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + def prepare_request(next_link=None): + if not next_link: + + _request = build_beta_schedules_list_runs_request( + schedule_id=schedule_id, + foundry_features=foundry_features, + type=type, + enabled=enabled, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - _request = build_agents_create_thread_and_run_request( - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized.get("value", []) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - response = pipeline_response.http_response + async def get_next(next_link=None): + _request = prepare_request(next_link) - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.ThreadRun, response.json()) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return pipeline_response - return deserialized # type: ignore + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/ai/azure-ai-agents/azure/ai/agents/models/__init__.py b/sdk/ai/azure-ai-agents/azure/ai/agents/models/__init__.py index 8e589c978dc4..e3b4c5295f07 100644 --- a/sdk/ai/azure-ai-agents/azure/ai/agents/models/__init__.py +++ b/sdk/ai/azure-ai-agents/azure/ai/agents/models/__init__.py @@ -12,535 +12,10 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import - -from ._models import ( # type: ignore - AISearchIndexResource, - ActivityFunctionDefinition, - ActivityFunctionParameters, - Agent, - AgentErrorDetail, - AgentThread, - AgentThreadCreationOptions, - AgentV1Error, - AgentsNamedToolChoice, - AgentsResponseFormat, - AzureAISearchToolDefinition, - AzureAISearchToolResource, - AzureFunctionBinding, - AzureFunctionDefinition, - AzureFunctionStorageQueue, - AzureFunctionToolCallDetails, - AzureFunctionToolDefinition, - BingCustomSearchConfiguration, - BingCustomSearchToolDefinition, - BingCustomSearchToolParameters, - BingGroundingSearchConfiguration, - BingGroundingSearchToolParameters, - BingGroundingToolDefinition, - BrowserAutomationToolCallDetails, - BrowserAutomationToolCallStep, - BrowserAutomationToolConnectionParameters, - BrowserAutomationToolDefinition, - BrowserAutomationToolParameters, - ClickAction, - CodeInterpreterToolDefinition, - CodeInterpreterToolResource, - ComputerScreenshot, - ComputerToolOutput, - ComputerUseAction, - ComputerUseToolDefinition, - ComputerUseToolParameters, - ConnectedAgentDetails, - ConnectedAgentToolDefinition, - CoordinatePoint, - DeepResearchBingGroundingConnection, - DeepResearchDetails, - DeepResearchToolDefinition, - DoubleClickAction, - DragAction, - FabricDataAgentToolParameters, - FileInfo, - FileListResponse, - FileSearchRankingOptions, - FileSearchToolCallContent, - FileSearchToolDefinition, - FileSearchToolDefinitionDetails, - FileSearchToolResource, - FunctionArgument, - FunctionDefinition, - FunctionName, - FunctionToolDefinition, - IncompleteRunDetails, - KeyPressAction, - MCPApprovalPerTool, - MCPToolDefinition, - MCPToolList, - MCPToolResource, - MessageAttachment, - MessageContent, - MessageDelta, - MessageDeltaChunk, - MessageDeltaContent, - MessageDeltaImageFileContent, - MessageDeltaImageFileContentObject, - MessageDeltaTextAnnotation, - MessageDeltaTextContent, - MessageDeltaTextContentObject, - MessageDeltaTextFileCitationAnnotation, - MessageDeltaTextFileCitationAnnotationObject, - MessageDeltaTextFilePathAnnotation, - MessageDeltaTextFilePathAnnotationObject, - MessageDeltaTextUrlCitationAnnotation, - MessageDeltaTextUrlCitationDetails, - MessageImageFileContent, - MessageImageFileDetails, - MessageImageFileParam, - MessageImageUrlParam, - MessageIncompleteDetails, - MessageInputContentBlock, - MessageInputImageFileBlock, - MessageInputImageUrlBlock, - MessageInputTextBlock, - MessageTextAnnotation, - MessageTextContent, - MessageTextDetails, - MessageTextFileCitationAnnotation, - MessageTextFileCitationDetails, - MessageTextFilePathAnnotation, - MessageTextFilePathDetails, - MessageTextUrlCitationAnnotation, - MessageTextUrlCitationDetails, - MicrosoftFabricToolDefinition, - MoveAction, - OpenApiAnonymousAuthDetails, - OpenApiAuthDetails, - OpenApiConnectionAuthDetails, - OpenApiConnectionSecurityScheme, - OpenApiFunctionDefinition, - OpenApiManagedAuthDetails, - OpenApiManagedSecurityScheme, - OpenApiToolDefinition, - RequiredAction, - RequiredComputerUseToolCall, - RequiredComputerUseToolCallDetails, - RequiredFunctionToolCall, - RequiredFunctionToolCallDetails, - RequiredMcpToolCall, - RequiredToolCall, - ResponseFormatJsonSchema, - ResponseFormatJsonSchemaType, - RunCompletionUsage, - RunError, - RunStep, - RunStepActivityDetails, - RunStepAzureAISearchToolCall, - RunStepAzureFunctionToolCall, - RunStepBingCustomSearchToolCall, - RunStepBingGroundingToolCall, - RunStepBrowserAutomationToolCall, - RunStepCodeInterpreterImageOutput, - RunStepCodeInterpreterImageReference, - RunStepCodeInterpreterLogOutput, - RunStepCodeInterpreterToolCall, - RunStepCodeInterpreterToolCallDetails, - RunStepCodeInterpreterToolCallOutput, - RunStepCompletionUsage, - RunStepComputerUseToolCall, - RunStepComputerUseToolCallDetails, - RunStepConnectedAgent, - RunStepConnectedAgentToolCall, - RunStepDeepResearchToolCall, - RunStepDeepResearchToolCallDetails, - RunStepDelta, - RunStepDeltaAzureAISearchToolCall, - RunStepDeltaAzureFunctionToolCall, - RunStepDeltaBingGroundingToolCall, - RunStepDeltaChunk, - RunStepDeltaCodeInterpreterDetailItemObject, - RunStepDeltaCodeInterpreterImageOutput, - RunStepDeltaCodeInterpreterImageOutputObject, - RunStepDeltaCodeInterpreterLogOutput, - RunStepDeltaCodeInterpreterOutput, - RunStepDeltaCodeInterpreterToolCall, - RunStepDeltaComputerUseDetails, - RunStepDeltaComputerUseToolCall, - RunStepDeltaConnectedAgentToolCall, - RunStepDeltaCustomBingGroundingToolCall, - RunStepDeltaDeepResearchToolCall, - RunStepDeltaDetail, - RunStepDeltaFileSearchToolCall, - RunStepDeltaFunction, - RunStepDeltaFunctionToolCall, - RunStepDeltaMCPObject, - RunStepDeltaMcpToolCall, - RunStepDeltaMessageCreation, - RunStepDeltaMessageCreationObject, - RunStepDeltaMicrosoftFabricToolCall, - RunStepDeltaOpenAPIObject, - RunStepDeltaOpenAPIToolCall, - RunStepDeltaSharepointToolCall, - RunStepDeltaToolCall, - RunStepDeltaToolCallObject, - RunStepDetails, - RunStepDetailsActivity, - RunStepError, - RunStepFileSearchToolCall, - RunStepFileSearchToolCallResult, - RunStepFileSearchToolCallResults, - RunStepFunctionToolCall, - RunStepFunctionToolCallDetails, - RunStepMcpToolCall, - RunStepMessageCreationDetails, - RunStepMessageCreationReference, - RunStepMicrosoftFabricToolCall, - RunStepOpenAPIToolCall, - RunStepSharepointToolCall, - RunStepToolCall, - RunStepToolCallDetails, - SafetyCheck, - ScreenshotAction, - ScrollAction, - SharepointGroundingToolParameters, - SharepointToolDefinition, - StructuredToolOutput, - SubmitToolApprovalAction, - SubmitToolApprovalDetails, - SubmitToolOutputsAction, - SubmitToolOutputsDetails, - ThreadMessage, - ThreadMessageOptions, - ThreadRun, - ToolApproval, - ToolConnection, - ToolDefinition, - ToolOutput, - ToolResources, - TruncationObject, - TypeAction, - VectorStore, - VectorStoreAutoChunkingStrategyRequest, - VectorStoreAutoChunkingStrategyResponse, - VectorStoreChunkingStrategyRequest, - VectorStoreChunkingStrategyResponse, - VectorStoreConfiguration, - VectorStoreConfigurations, - VectorStoreDataSource, - VectorStoreExpirationPolicy, - VectorStoreFile, - VectorStoreFileBatch, - VectorStoreFileCount, - VectorStoreFileError, - VectorStoreStaticChunkingStrategyOptions, - VectorStoreStaticChunkingStrategyRequest, - VectorStoreStaticChunkingStrategyResponse, - WaitAction, -) - -from ._enums import ( # type: ignore - AgentStreamEvent, - AgentsNamedToolChoiceType, - AgentsResponseFormatMode, - AgentsToolChoiceOptionMode, - AzureAISearchQueryType, - ComputerUseEnvironment, - DoneEvent, - ErrorEvent, - FilePurpose, - FileState, - ImageDetailLevel, - IncompleteDetailsReason, - ListSortOrder, - MessageBlockType, - MessageIncompleteDetailsReason, - MessageRole, - MessageStatus, - MessageStreamEvent, - MouseButton, - OpenApiAuthType, - ResponseFormat, - RunAdditionalFieldList, - RunStatus, - RunStepErrorCode, - RunStepStatus, - RunStepStreamEvent, - RunStepType, - RunStreamEvent, - ThreadStreamEvent, - TruncationStrategy, - VectorStoreChunkingStrategyRequestType, - VectorStoreChunkingStrategyResponseType, - VectorStoreDataSourceAssetType, - VectorStoreExpirationPolicyAnchor, - VectorStoreFileBatchStatus, - VectorStoreFileErrorCode, - VectorStoreFileStatus, - VectorStoreFileStatusFilter, - VectorStoreStatus, -) from ._patch import __all__ as _patch_all from ._patch import * from ._patch import patch_sdk as _patch_sdk -__all__ = [ - "AISearchIndexResource", - "ActivityFunctionDefinition", - "ActivityFunctionParameters", - "Agent", - "AgentErrorDetail", - "AgentThread", - "AgentThreadCreationOptions", - "AgentV1Error", - "AgentsNamedToolChoice", - "AgentsResponseFormat", - "AzureAISearchToolDefinition", - "AzureAISearchToolResource", - "AzureFunctionBinding", - "AzureFunctionDefinition", - "AzureFunctionStorageQueue", - "AzureFunctionToolCallDetails", - "AzureFunctionToolDefinition", - "BingCustomSearchConfiguration", - "BingCustomSearchToolDefinition", - "BingCustomSearchToolParameters", - "BingGroundingSearchConfiguration", - "BingGroundingSearchToolParameters", - "BingGroundingToolDefinition", - "BrowserAutomationToolCallDetails", - "BrowserAutomationToolCallStep", - "BrowserAutomationToolConnectionParameters", - "BrowserAutomationToolDefinition", - "BrowserAutomationToolParameters", - "ClickAction", - "CodeInterpreterToolDefinition", - "CodeInterpreterToolResource", - "ComputerScreenshot", - "ComputerToolOutput", - "ComputerUseAction", - "ComputerUseToolDefinition", - "ComputerUseToolParameters", - "ConnectedAgentDetails", - "ConnectedAgentToolDefinition", - "CoordinatePoint", - "DeepResearchBingGroundingConnection", - "DeepResearchDetails", - "DeepResearchToolDefinition", - "DoubleClickAction", - "DragAction", - "FabricDataAgentToolParameters", - "FileInfo", - "FileListResponse", - "FileSearchRankingOptions", - "FileSearchToolCallContent", - "FileSearchToolDefinition", - "FileSearchToolDefinitionDetails", - "FileSearchToolResource", - "FunctionArgument", - "FunctionDefinition", - "FunctionName", - "FunctionToolDefinition", - "IncompleteRunDetails", - "KeyPressAction", - "MCPApprovalPerTool", - "MCPToolDefinition", - "MCPToolList", - "MCPToolResource", - "MessageAttachment", - "MessageContent", - "MessageDelta", - "MessageDeltaChunk", - "MessageDeltaContent", - "MessageDeltaImageFileContent", - "MessageDeltaImageFileContentObject", - "MessageDeltaTextAnnotation", - "MessageDeltaTextContent", - "MessageDeltaTextContentObject", - "MessageDeltaTextFileCitationAnnotation", - "MessageDeltaTextFileCitationAnnotationObject", - "MessageDeltaTextFilePathAnnotation", - "MessageDeltaTextFilePathAnnotationObject", - "MessageDeltaTextUrlCitationAnnotation", - "MessageDeltaTextUrlCitationDetails", - "MessageImageFileContent", - "MessageImageFileDetails", - "MessageImageFileParam", - "MessageImageUrlParam", - "MessageIncompleteDetails", - "MessageInputContentBlock", - "MessageInputImageFileBlock", - "MessageInputImageUrlBlock", - "MessageInputTextBlock", - "MessageTextAnnotation", - "MessageTextContent", - "MessageTextDetails", - "MessageTextFileCitationAnnotation", - "MessageTextFileCitationDetails", - "MessageTextFilePathAnnotation", - "MessageTextFilePathDetails", - "MessageTextUrlCitationAnnotation", - "MessageTextUrlCitationDetails", - "MicrosoftFabricToolDefinition", - "MoveAction", - "OpenApiAnonymousAuthDetails", - "OpenApiAuthDetails", - "OpenApiConnectionAuthDetails", - "OpenApiConnectionSecurityScheme", - "OpenApiFunctionDefinition", - "OpenApiManagedAuthDetails", - "OpenApiManagedSecurityScheme", - "OpenApiToolDefinition", - "RequiredAction", - "RequiredComputerUseToolCall", - "RequiredComputerUseToolCallDetails", - "RequiredFunctionToolCall", - "RequiredFunctionToolCallDetails", - "RequiredMcpToolCall", - "RequiredToolCall", - "ResponseFormatJsonSchema", - "ResponseFormatJsonSchemaType", - "RunCompletionUsage", - "RunError", - "RunStep", - "RunStepActivityDetails", - "RunStepAzureAISearchToolCall", - "RunStepAzureFunctionToolCall", - "RunStepBingCustomSearchToolCall", - "RunStepBingGroundingToolCall", - "RunStepBrowserAutomationToolCall", - "RunStepCodeInterpreterImageOutput", - "RunStepCodeInterpreterImageReference", - "RunStepCodeInterpreterLogOutput", - "RunStepCodeInterpreterToolCall", - "RunStepCodeInterpreterToolCallDetails", - "RunStepCodeInterpreterToolCallOutput", - "RunStepCompletionUsage", - "RunStepComputerUseToolCall", - "RunStepComputerUseToolCallDetails", - "RunStepConnectedAgent", - "RunStepConnectedAgentToolCall", - "RunStepDeepResearchToolCall", - "RunStepDeepResearchToolCallDetails", - "RunStepDelta", - "RunStepDeltaAzureAISearchToolCall", - "RunStepDeltaAzureFunctionToolCall", - "RunStepDeltaBingGroundingToolCall", - "RunStepDeltaChunk", - "RunStepDeltaCodeInterpreterDetailItemObject", - "RunStepDeltaCodeInterpreterImageOutput", - "RunStepDeltaCodeInterpreterImageOutputObject", - "RunStepDeltaCodeInterpreterLogOutput", - "RunStepDeltaCodeInterpreterOutput", - "RunStepDeltaCodeInterpreterToolCall", - "RunStepDeltaComputerUseDetails", - "RunStepDeltaComputerUseToolCall", - "RunStepDeltaConnectedAgentToolCall", - "RunStepDeltaCustomBingGroundingToolCall", - "RunStepDeltaDeepResearchToolCall", - "RunStepDeltaDetail", - "RunStepDeltaFileSearchToolCall", - "RunStepDeltaFunction", - "RunStepDeltaFunctionToolCall", - "RunStepDeltaMCPObject", - "RunStepDeltaMcpToolCall", - "RunStepDeltaMessageCreation", - "RunStepDeltaMessageCreationObject", - "RunStepDeltaMicrosoftFabricToolCall", - "RunStepDeltaOpenAPIObject", - "RunStepDeltaOpenAPIToolCall", - "RunStepDeltaSharepointToolCall", - "RunStepDeltaToolCall", - "RunStepDeltaToolCallObject", - "RunStepDetails", - "RunStepDetailsActivity", - "RunStepError", - "RunStepFileSearchToolCall", - "RunStepFileSearchToolCallResult", - "RunStepFileSearchToolCallResults", - "RunStepFunctionToolCall", - "RunStepFunctionToolCallDetails", - "RunStepMcpToolCall", - "RunStepMessageCreationDetails", - "RunStepMessageCreationReference", - "RunStepMicrosoftFabricToolCall", - "RunStepOpenAPIToolCall", - "RunStepSharepointToolCall", - "RunStepToolCall", - "RunStepToolCallDetails", - "SafetyCheck", - "ScreenshotAction", - "ScrollAction", - "SharepointGroundingToolParameters", - "SharepointToolDefinition", - "StructuredToolOutput", - "SubmitToolApprovalAction", - "SubmitToolApprovalDetails", - "SubmitToolOutputsAction", - "SubmitToolOutputsDetails", - "ThreadMessage", - "ThreadMessageOptions", - "ThreadRun", - "ToolApproval", - "ToolConnection", - "ToolDefinition", - "ToolOutput", - "ToolResources", - "TruncationObject", - "TypeAction", - "VectorStore", - "VectorStoreAutoChunkingStrategyRequest", - "VectorStoreAutoChunkingStrategyResponse", - "VectorStoreChunkingStrategyRequest", - "VectorStoreChunkingStrategyResponse", - "VectorStoreConfiguration", - "VectorStoreConfigurations", - "VectorStoreDataSource", - "VectorStoreExpirationPolicy", - "VectorStoreFile", - "VectorStoreFileBatch", - "VectorStoreFileCount", - "VectorStoreFileError", - "VectorStoreStaticChunkingStrategyOptions", - "VectorStoreStaticChunkingStrategyRequest", - "VectorStoreStaticChunkingStrategyResponse", - "WaitAction", - "AgentStreamEvent", - "AgentsNamedToolChoiceType", - "AgentsResponseFormatMode", - "AgentsToolChoiceOptionMode", - "AzureAISearchQueryType", - "ComputerUseEnvironment", - "DoneEvent", - "ErrorEvent", - "FilePurpose", - "FileState", - "ImageDetailLevel", - "IncompleteDetailsReason", - "ListSortOrder", - "MessageBlockType", - "MessageIncompleteDetailsReason", - "MessageRole", - "MessageStatus", - "MessageStreamEvent", - "MouseButton", - "OpenApiAuthType", - "ResponseFormat", - "RunAdditionalFieldList", - "RunStatus", - "RunStepErrorCode", - "RunStepStatus", - "RunStepStreamEvent", - "RunStepType", - "RunStreamEvent", - "ThreadStreamEvent", - "TruncationStrategy", - "VectorStoreChunkingStrategyRequestType", - "VectorStoreChunkingStrategyResponseType", - "VectorStoreDataSourceAssetType", - "VectorStoreExpirationPolicyAnchor", - "VectorStoreFileBatchStatus", - "VectorStoreFileErrorCode", - "VectorStoreFileStatus", - "VectorStoreFileStatusFilter", - "VectorStoreStatus", -] +__all__ = [] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/ai/azure-ai-agents/azure/ai/agents/models/_models.py b/sdk/ai/azure-ai-agents/azure/ai/agents/models/_models.py index 09dd194b5a8f..dc7ec89e633b 100644 --- a/sdk/ai/azure-ai-agents/azure/ai/agents/models/_models.py +++ b/sdk/ai/azure-ai-agents/azure/ai/agents/models/_models.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/ai/azure-ai-agents/azure/ai/agents/operations/__init__.py b/sdk/ai/azure-ai-agents/azure/ai/agents/operations/__init__.py index a3f2341966aa..ac09c02d32cd 100644 --- a/sdk/ai/azure-ai-agents/azure/ai/agents/operations/__init__.py +++ b/sdk/ai/azure-ai-agents/azure/ai/agents/operations/__init__.py @@ -12,29 +12,27 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._operations import ThreadsOperations # type: ignore -from ._operations import MessagesOperations # type: ignore -from ._operations import RunsOperations # type: ignore -from ._operations import RunStepsOperations # type: ignore -from ._operations import FilesOperations # type: ignore -from ._operations import VectorStoresOperations # type: ignore -from ._operations import VectorStoreFilesOperations # type: ignore -from ._operations import VectorStoreFileBatchesOperations # type: ignore -from ._operations import _AgentsClientOperationsMixin # type: ignore # pylint: disable=unused-import +from ._operations import BetaOperations # type: ignore +from ._operations import AgentsOperations # type: ignore +from ._operations import EvaluationRulesOperations # type: ignore +from ._operations import ConnectionsOperations # type: ignore +from ._operations import DatasetsOperations # type: ignore +from ._operations import DeploymentsOperations # type: ignore +from ._operations import IndexesOperations # type: ignore +from ._operations import _AIProjectClientOperationsMixin # type: ignore # pylint: disable=unused-import from ._patch import __all__ as _patch_all from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ - "ThreadsOperations", - "MessagesOperations", - "RunsOperations", - "RunStepsOperations", - "FilesOperations", - "VectorStoresOperations", - "VectorStoreFilesOperations", - "VectorStoreFileBatchesOperations", + "BetaOperations", + "AgentsOperations", + "EvaluationRulesOperations", + "ConnectionsOperations", + "DatasetsOperations", + "DeploymentsOperations", + "IndexesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/ai/azure-ai-agents/azure/ai/agents/operations/_operations.py b/sdk/ai/azure-ai-agents/azure/ai/agents/operations/_operations.py index eba194bfb068..53812981e831 100644 --- a/sdk/ai/azure-ai-agents/azure/ai/agents/operations/_operations.py +++ b/sdk/ai/azure-ai-agents/azure/ai/agents/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +7,11 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from collections.abc import MutableMapping +import datetime from io import IOBase -import json -from typing import Any, Callable, IO, Iterator, Optional, TYPE_CHECKING, TypeVar, Union, overload +from typing import Any, Callable, IO, Iterator, Literal, Optional, TypeVar, Union, cast, overload import urllib.parse +import uuid from azure.core import PipelineClient from azure.core.exceptions import ( @@ -24,21 +26,20 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.polling.base_polling import LROBasePolling from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict -from .. import models as _models -from .._configuration import AgentsClientConfiguration -from .._utils.model_base import Model as _Model, SdkJSONEncoder, _deserialize, _failsafe_deserialize +from .. import types, types as _types_models1 +from .._configuration import AIProjectClientConfiguration from .._utils.serialization import Deserializer, Serializer -from .._utils.utils import ClientMixinABC, prepare_multipart_form_data -from .._validation import api_version_validation +from .._utils.utils import ClientMixinABC +from ..models._enums import FoundryFeaturesOptInKeys -if TYPE_CHECKING: - from .. import _types -JSON = MutableMapping[str, Any] _Unset: Any = object() +JSON = MutableMapping[str, Any] T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] List = list @@ -47,73 +48,70 @@ _SERIALIZER.client_side_validation = False -def build_threads_create_request(**kwargs: Any) -> HttpRequest: +def build_agents_get_request(agent_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/threads" + _url = "/agents/{agent_name}" + path_format_arguments = { + "agent_name": _SERIALIZER.url("agent_name", agent_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_threads_list_request( - *, - limit: Optional[int] = None, - order: Optional[Union[str, _models.ListSortOrder]] = None, - after: Optional[str] = None, - before: Optional[str] = None, - **kwargs: Any +def build_agents_create_agent_request( + *, foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/threads" + _url = "/agents" # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if limit is not None: - _params["limit"] = _SERIALIZER.query("limit", limit, "int") - if order is not None: - _params["order"] = _SERIALIZER.query("order", order, "str") - if after is not None: - _params["after"] = _SERIALIZER.query("after", after, "str") - if before is not None: - _params["before"] = _SERIALIZER.query("before", before, "str") # Construct headers + if foundry_features is not None: + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_threads_get_request(thread_id: str, **kwargs: Any) -> HttpRequest: +def build_agents_update_agent_request( + agent_name: str, *, foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/threads/{threadId}" + _url = "/agents/{agent_name}" path_format_arguments = { - "threadId": _SERIALIZER.url("thread_id", thread_id, "str"), + "agent_name": _SERIALIZER.url("agent_name", agent_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -122,26 +120,25 @@ def build_threads_get_request(thread_id: str, **kwargs: Any) -> HttpRequest: _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if foundry_features is not None: + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_threads_update_request(thread_id: str, **kwargs: Any) -> HttpRequest: +def build_agents_create_agent_from_manifest_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/threads/{threadId}" - path_format_arguments = { - "threadId": _SERIALIZER.url("thread_id", thread_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore + _url = "/agents:import" # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -154,17 +151,20 @@ def build_threads_update_request(thread_id: str, **kwargs: Any) -> HttpRequest: return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_threads_delete_thread_request(thread_id: str, **kwargs: Any) -> HttpRequest: +def build_agents_update_agent_from_manifest_request( # pylint: disable=name-too-long + agent_name: str, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/threads/{threadId}" + _url = "/agents/{agent_name}/import" path_format_arguments = { - "threadId": _SERIALIZER.url("thread_id", thread_id, "str"), + "agent_name": _SERIALIZER.url("agent_name", agent_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -173,23 +173,24 @@ def build_threads_delete_thread_request(thread_id: str, **kwargs: Any) -> HttpRe _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_messages_create_request(thread_id: str, **kwargs: Any) -> HttpRequest: +def build_agents_delete_request(agent_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/threads/{threadId}/messages" + _url = "/agents/{agent_name}" path_format_arguments = { - "threadId": _SERIALIZER.url("thread_id", thread_id, "str"), + "agent_name": _SERIALIZER.url("agent_name", agent_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -198,19 +199,16 @@ def build_messages_create_request(thread_id: str, **kwargs: Any) -> HttpRequest: _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_messages_list_request( - thread_id: str, +def build_agents_list_request( *, - run_id: Optional[str] = None, + kind: Optional[types.AgentKind] = None, limit: Optional[int] = None, - order: Optional[Union[str, _models.ListSortOrder]] = None, + order: Optional[types.PageOrder] = None, after: Optional[str] = None, before: Optional[str] = None, **kwargs: Any @@ -218,21 +216,15 @@ def build_messages_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/threads/{threadId}/messages" - path_format_arguments = { - "threadId": _SERIALIZER.url("thread_id", thread_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore + _url = "/agents" # Construct parameters - if run_id is not None: - _params["run_id"] = _SERIALIZER.query("run_id", run_id, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if kind is not None: + _params["kind"] = _SERIALIZER.query("kind", kind, "str") if limit is not None: _params["limit"] = _SERIALIZER.query("limit", limit, "int") if order is not None: @@ -241,6 +233,7 @@ def build_messages_list_request( _params["after"] = _SERIALIZER.query("after", after, "str") if before is not None: _params["before"] = _SERIALIZER.query("before", before, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -248,18 +241,20 @@ def build_messages_list_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_messages_get_request(thread_id: str, message_id: str, **kwargs: Any) -> HttpRequest: +def build_agents_create_version_request( + agent_name: str, *, foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/threads/{threadId}/messages/{messageId}" + _url = "/agents/{agent_name}/versions" path_format_arguments = { - "threadId": _SERIALIZER.url("thread_id", thread_id, "str"), - "messageId": _SERIALIZER.url("message_id", message_id, "str"), + "agent_name": _SERIALIZER.url("agent_name", agent_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -268,24 +263,29 @@ def build_messages_get_request(thread_id: str, message_id: str, **kwargs: Any) - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if foundry_features is not None: + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_messages_update_request(thread_id: str, message_id: str, **kwargs: Any) -> HttpRequest: +def build_agents_create_version_from_manifest_request( # pylint: disable=name-too-long + agent_name: str, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/threads/{threadId}/messages/{messageId}" + _url = "/agents/{agent_name}/versions:import" path_format_arguments = { - "threadId": _SERIALIZER.url("thread_id", thread_id, "str"), - "messageId": _SERIALIZER.url("message_id", message_id, "str"), + "agent_name": _SERIALIZER.url("agent_name", agent_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -301,18 +301,18 @@ def build_messages_update_request(thread_id: str, message_id: str, **kwargs: Any return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_messages_delete_request(thread_id: str, message_id: str, **kwargs: Any) -> HttpRequest: +def build_agents_get_version_request(agent_name: str, agent_version: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/threads/{threadId}/messages/{messageId}" + _url = "/agents/{agent_name}/versions/{agent_version}" path_format_arguments = { - "threadId": _SERIALIZER.url("thread_id", thread_id, "str"), - "messageId": _SERIALIZER.url("message_id", message_id, "str"), + "agent_name": _SERIALIZER.url("agent_name", agent_name, "str"), + "agent_version": _SERIALIZER.url("agent_version", agent_version, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -323,45 +323,39 @@ def build_messages_delete_request(thread_id: str, message_id: str, **kwargs: Any # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_runs_create_request( - thread_id: str, *, include: Optional[List[Union[str, _models.RunAdditionalFieldList]]] = None, **kwargs: Any -) -> HttpRequest: +def build_agents_delete_version_request(agent_name: str, agent_version: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/threads/{threadId}/runs" + _url = "/agents/{agent_name}/versions/{agent_version}" path_format_arguments = { - "threadId": _SERIALIZER.url("thread_id", thread_id, "str"), + "agent_name": _SERIALIZER.url("agent_name", agent_name, "str"), + "agent_version": _SERIALIZER.url("agent_version", agent_version, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if include is not None: - _params["include[]"] = _SERIALIZER.query("include", include, "[str]", div=",") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_runs_list_request( - thread_id: str, +def build_agents_list_versions_request( + agent_name: str, *, limit: Optional[int] = None, - order: Optional[Union[str, _models.ListSortOrder]] = None, + order: Optional[types.PageOrder] = None, after: Optional[str] = None, before: Optional[str] = None, **kwargs: Any @@ -369,19 +363,18 @@ def build_runs_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/threads/{threadId}/runs" + _url = "/agents/{agent_name}/versions" path_format_arguments = { - "threadId": _SERIALIZER.url("thread_id", thread_id, "str"), + "agent_name": _SERIALIZER.url("agent_name", agent_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if limit is not None: _params["limit"] = _SERIALIZER.query("limit", limit, "int") if order is not None: @@ -390,6 +383,7 @@ def build_runs_list_request( _params["after"] = _SERIALIZER.query("after", after, "str") if before is not None: _params["before"] = _SERIALIZER.query("before", before, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -397,18 +391,17 @@ def build_runs_list_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_runs_get_request(thread_id: str, run_id: str, **kwargs: Any) -> HttpRequest: +def build_evaluation_rules_get_request(id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/threads/{threadId}/runs/{runId}" + _url = "/evaluationrules/{id}" path_format_arguments = { - "threadId": _SERIALIZER.url("thread_id", thread_id, "str"), - "runId": _SERIALIZER.url("run_id", run_id, "str"), + "id": _SERIALIZER.url("id", id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -422,19 +415,14 @@ def build_runs_get_request(thread_id: str, run_id: str, **kwargs: Any) -> HttpRe return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_runs_update_request(thread_id: str, run_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) +def build_evaluation_rules_delete_request(id: str, **kwargs: Any) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) # Construct URL - _url = "/threads/{threadId}/runs/{runId}" + _url = "/evaluationrules/{id}" path_format_arguments = { - "threadId": _SERIALIZER.url("thread_id", thread_id, "str"), - "runId": _SERIALIZER.url("run_id", run_id, "str"), + "id": _SERIALIZER.url("id", id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -442,27 +430,26 @@ def build_runs_update_request(thread_id: str, run_id: str, **kwargs: Any) -> Htt # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_runs_submit_tool_outputs_request(thread_id: str, run_id: str, **kwargs: Any) -> HttpRequest: +def build_evaluation_rules_create_or_update_request( # pylint: disable=name-too-long + id: str, + *, + foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW]] = None, + **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/threads/{threadId}/runs/{runId}/submit_tool_outputs" + _url = "/evaluationrules/{id}" path_format_arguments = { - "threadId": _SERIALIZER.url("thread_id", thread_id, "str"), - "runId": _SERIALIZER.url("run_id", run_id, "str"), + "id": _SERIALIZER.url("id", id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -471,66 +458,63 @@ def build_runs_submit_tool_outputs_request(thread_id: str, run_id: str, **kwargs _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if foundry_features is not None: + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_runs_cancel_request(thread_id: str, run_id: str, **kwargs: Any) -> HttpRequest: +def build_evaluation_rules_list_request( + *, + action_type: Optional[types.EvaluationRuleActionType] = None, + agent_name: Optional[str] = None, + enabled: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/threads/{threadId}/runs/{runId}/cancel" - path_format_arguments = { - "threadId": _SERIALIZER.url("thread_id", thread_id, "str"), - "runId": _SERIALIZER.url("run_id", run_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore + _url = "/evaluationrules" # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if action_type is not None: + _params["actionType"] = _SERIALIZER.query("action_type", action_type, "str") + if agent_name is not None: + _params["agentName"] = _SERIALIZER.query("agent_name", agent_name, "str") + if enabled is not None: + _params["enabled"] = _SERIALIZER.query("enabled", enabled, "bool") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_run_steps_get_request( - thread_id: str, - run_id: str, - step_id: str, - *, - include: Optional[List[Union[str, _models.RunAdditionalFieldList]]] = None, - **kwargs: Any -) -> HttpRequest: +def build_connections_get_request(name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/threads/{threadId}/runs/{runId}/steps/{stepId}" + _url = "/connections/{name}" path_format_arguments = { - "threadId": _SERIALIZER.url("thread_id", thread_id, "str"), - "runId": _SERIALIZER.url("run_id", run_id, "str"), - "stepId": _SERIALIZER.url("step_id", step_id, "str"), + "name": _SERIALIZER.url("name", name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if include is not None: - _params["include[]"] = _SERIALIZER.query("include", include, "[str]", div=",") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -538,67 +522,50 @@ def build_run_steps_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_run_steps_list_request( - thread_id: str, - run_id: str, - *, - include: Optional[List[Union[str, _models.RunAdditionalFieldList]]] = None, - limit: Optional[int] = None, - order: Optional[Union[str, _models.ListSortOrder]] = None, - after: Optional[str] = None, - before: Optional[str] = None, - **kwargs: Any +def build_connections_get_with_credentials_request( # pylint: disable=name-too-long + name: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/threads/{threadId}/runs/{runId}/steps" + _url = "/connections/{name}/getConnectionWithCredentials" path_format_arguments = { - "threadId": _SERIALIZER.url("thread_id", thread_id, "str"), - "runId": _SERIALIZER.url("run_id", run_id, "str"), + "name": _SERIALIZER.url("name", name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if include is not None: - _params["include[]"] = _SERIALIZER.query("include", include, "[str]", div=",") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if limit is not None: - _params["limit"] = _SERIALIZER.query("limit", limit, "int") - if order is not None: - _params["order"] = _SERIALIZER.query("order", order, "str") - if after is not None: - _params["after"] = _SERIALIZER.query("after", after, "str") - if before is not None: - _params["before"] = _SERIALIZER.query("before", before, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_files_list_request( - *, purpose: Optional[Union[str, _models.FilePurpose]] = None, **kwargs: Any +def build_connections_list_request( + *, connection_type: Optional[types.ConnectionType] = None, default_connection: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/files" + _url = "/connections" # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if purpose is not None: - _params["purpose"] = _SERIALIZER.query("purpose", purpose, "str") + if connection_type is not None: + _params["connectionType"] = _SERIALIZER.query("connection_type", connection_type, "str") + if default_connection is not None: + _params["defaultConnection"] = _SERIALIZER.query("default_connection", default_connection, "bool") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -606,15 +573,20 @@ def build_files_list_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_files_upload_file_request(**kwargs: Any) -> HttpRequest: +def build_datasets_list_versions_request(name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/files" + _url = "/datasets/{name}/versions" + path_format_arguments = { + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -622,23 +594,18 @@ def build_files_upload_file_request(**kwargs: Any) -> HttpRequest: # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_files_delete_file_request(file_id: str, **kwargs: Any) -> HttpRequest: +def build_datasets_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/files/{fileId}" - path_format_arguments = { - "fileId": _SERIALIZER.url("file_id", file_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore + _url = "/datasets" # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -646,20 +613,21 @@ def build_files_delete_file_request(file_id: str, **kwargs: Any) -> HttpRequest: # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_files_get_request(file_id: str, **kwargs: Any) -> HttpRequest: +def build_datasets_get_request(name: str, version: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/files/{fileId}" + _url = "/datasets/{name}/versions/{version}" path_format_arguments = { - "fileId": _SERIALIZER.url("file_id", file_id, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "version": _SERIALIZER.url("version", version, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -673,17 +641,15 @@ def build_files_get_request(file_id: str, **kwargs: Any) -> HttpRequest: return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_files_get_file_content_request(file_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) +def build_datasets_delete_request(name: str, version: str, **kwargs: Any) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) - accept = _headers.pop("Accept", "application/octet-stream") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) # Construct URL - _url = "/files/{fileId}/content" + _url = "/datasets/{name}/versions/{version}" path_format_arguments = { - "fileId": _SERIALIZER.url("file_id", file_id, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "version": _SERIALIZER.url("version", version, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -691,56 +657,53 @@ def build_files_get_file_content_request(file_id: str, **kwargs: Any) -> HttpReq # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_vector_stores_list_request( - *, - limit: Optional[int] = None, - order: Optional[Union[str, _models.ListSortOrder]] = None, - after: Optional[str] = None, - before: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: +def build_datasets_create_or_update_request(name: str, version: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/vector_stores" + _url = "/datasets/{name}/versions/{version}" + path_format_arguments = { + "name": _SERIALIZER.url("name", name, "str"), + "version": _SERIALIZER.url("version", version, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if limit is not None: - _params["limit"] = _SERIALIZER.query("limit", limit, "int") - if order is not None: - _params["order"] = _SERIALIZER.query("order", order, "str") - if after is not None: - _params["after"] = _SERIALIZER.query("after", after, "str") - if before is not None: - _params["before"] = _SERIALIZER.query("before", before, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_vector_stores_create_request(**kwargs: Any) -> HttpRequest: +def build_datasets_pending_upload_request(name: str, version: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/vector_stores" + _url = "/datasets/{name}/versions/{version}/startPendingUpload" + path_format_arguments = { + "name": _SERIALIZER.url("name", name, "str"), + "version": _SERIALIZER.url("version", version, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -753,17 +716,18 @@ def build_vector_stores_create_request(**kwargs: Any) -> HttpRequest: return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_vector_stores_get_request(vector_store_id: str, **kwargs: Any) -> HttpRequest: +def build_datasets_get_credentials_request(name: str, version: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/vector_stores/{vectorStoreId}" + _url = "/datasets/{name}/versions/{version}/credentials" path_format_arguments = { - "vectorStoreId": _SERIALIZER.url("vector_store_id", vector_store_id, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "version": _SERIALIZER.url("version", version, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -774,21 +738,20 @@ def build_vector_stores_get_request(vector_store_id: str, **kwargs: Any) -> Http # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_vector_stores_modify_request(vector_store_id: str, **kwargs: Any) -> HttpRequest: +def build_deployments_get_request(name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/vector_stores/{vectorStoreId}" + _url = "/deployments/{name}" path_format_arguments = { - "vectorStoreId": _SERIALIZER.url("vector_store_id", vector_store_id, "str"), + "name": _SERIALIZER.url("name", name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -797,75 +760,59 @@ def build_vector_stores_modify_request(vector_store_id: str, **kwargs: Any) -> H _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_vector_stores_delete_vector_store_request( # pylint: disable=name-too-long - vector_store_id: str, **kwargs: Any +def build_deployments_list_request( + *, + model_publisher: Optional[str] = None, + model_name: Optional[str] = None, + deployment_type: Optional[types.DeploymentType] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/vector_stores/{vectorStoreId}" - path_format_arguments = { - "vectorStoreId": _SERIALIZER.url("vector_store_id", vector_store_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore + _url = "/deployments" # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if model_publisher is not None: + _params["modelPublisher"] = _SERIALIZER.query("model_publisher", model_publisher, "str") + if model_name is not None: + _params["modelName"] = _SERIALIZER.query("model_name", model_name, "str") + if deployment_type is not None: + _params["deploymentType"] = _SERIALIZER.query("deployment_type", deployment_type, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_vector_store_files_list_request( - vector_store_id: str, - *, - filter: Optional[Union[str, _models.VectorStoreFileStatusFilter]] = None, - limit: Optional[int] = None, - order: Optional[Union[str, _models.ListSortOrder]] = None, - after: Optional[str] = None, - before: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: +def build_indexes_list_versions_request(name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/vector_stores/{vectorStoreId}/files" + _url = "/indexes/{name}/versions" path_format_arguments = { - "vectorStoreId": _SERIALIZER.url("vector_store_id", vector_store_id, "str"), + "name": _SERIALIZER.url("name", name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if filter is not None: - _params["filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if limit is not None: - _params["limit"] = _SERIALIZER.query("limit", limit, "int") - if order is not None: - _params["order"] = _SERIALIZER.query("order", order, "str") - if after is not None: - _params["after"] = _SERIALIZER.query("after", after, "str") - if before is not None: - _params["before"] = _SERIALIZER.query("before", before, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -873,45 +820,37 @@ def build_vector_store_files_list_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_vector_store_files_create_request(vector_store_id: str, **kwargs: Any) -> HttpRequest: +def build_indexes_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/vector_stores/{vectorStoreId}/files" - path_format_arguments = { - "vectorStoreId": _SERIALIZER.url("vector_store_id", vector_store_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore + _url = "/indexes" # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_vector_store_files_get_request(vector_store_id: str, file_id: str, **kwargs: Any) -> HttpRequest: +def build_indexes_get_request(name: str, version: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/vector_stores/{vectorStoreId}/files/{fileId}" + _url = "/indexes/{name}/versions/{version}" path_format_arguments = { - "vectorStoreId": _SERIALIZER.url("vector_store_id", vector_store_id, "str"), - "fileId": _SERIALIZER.url("file_id", file_id, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "version": _SERIALIZER.url("version", version, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -925,20 +864,15 @@ def build_vector_store_files_get_request(vector_store_id: str, file_id: str, **k return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_vector_store_files_delete_vector_store_file_request( # pylint: disable=name-too-long - vector_store_id: str, file_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) +def build_indexes_delete_request(name: str, version: str, **kwargs: Any) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) # Construct URL - _url = "/vector_stores/{vectorStoreId}/files/{fileId}" + _url = "/indexes/{name}/versions/{version}" path_format_arguments = { - "vectorStoreId": _SERIALIZER.url("vector_store_id", vector_store_id, "str"), - "fileId": _SERIALIZER.url("file_id", file_id, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "version": _SERIALIZER.url("version", version, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -946,26 +880,22 @@ def build_vector_store_files_delete_vector_store_file_request( # pylint: disabl # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_vector_store_file_batches_create_request( # pylint: disable=name-too-long - vector_store_id: str, **kwargs: Any -) -> HttpRequest: +def build_indexes_create_or_update_request(name: str, version: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/vector_stores/{vectorStoreId}/file_batches" + _url = "/indexes/{name}/versions/{version}" path_format_arguments = { - "vectorStoreId": _SERIALIZER.url("vector_store_id", vector_store_id, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "version": _SERIALIZER.url("version", version, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -978,23 +908,17 @@ def build_vector_store_file_batches_create_request( # pylint: disable=name-too- _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_vector_store_file_batches_get_request( # pylint: disable=name-too-long - vector_store_id: str, batch_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) +def build_ai_project_delete_job_request(job_id: str, **kwargs: Any) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) # Construct URL - _url = "/vector_stores/{vectorStoreId}/file_batches/{batchId}" + _url = "/{jobId}" path_format_arguments = { - "vectorStoreId": _SERIALIZER.url("vector_store_id", vector_store_id, "str"), - "batchId": _SERIALIZER.url("batch_id", batch_id, "str"), + "jobId": _SERIALIZER.url("job_id", job_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1002,26 +926,22 @@ def build_vector_store_file_batches_get_request( # pylint: disable=name-too-lon # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_vector_store_file_batches_cancel_request( # pylint: disable=name-too-long - vector_store_id: str, batch_id: str, **kwargs: Any +def build_beta_evaluation_taxonomies_get_request( # pylint: disable=name-too-long + name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/vector_stores/{vectorStoreId}/file_batches/{batchId}/cancel" + _url = "/evaluationtaxonomies/{name}" path_format_arguments = { - "vectorStoreId": _SERIALIZER.url("vector_store_id", vector_store_id, "str"), - "batchId": _SERIALIZER.url("batch_id", batch_id, "str"), + "name": _SERIALIZER.url("name", name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1030,123 +950,210 @@ def build_vector_store_file_batches_cancel_request( # pylint: disable=name-too- _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_vector_store_file_batches_list_files_request( # pylint: disable=name-too-long - vector_store_id: str, - batch_id: str, +def build_beta_evaluation_taxonomies_list_request( # pylint: disable=name-too-long *, - filter: Optional[Union[str, _models.VectorStoreFileStatusFilter]] = None, - limit: Optional[int] = None, - order: Optional[Union[str, _models.ListSortOrder]] = None, - after: Optional[str] = None, - before: Optional[str] = None, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + input_name: Optional[str] = None, + input_type: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/vector_stores/{vectorStoreId}/file_batches/{batchId}/files" - path_format_arguments = { - "vectorStoreId": _SERIALIZER.url("vector_store_id", vector_store_id, "str"), - "batchId": _SERIALIZER.url("batch_id", batch_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore + _url = "/evaluationtaxonomies" # Construct parameters - if filter is not None: - _params["filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if limit is not None: - _params["limit"] = _SERIALIZER.query("limit", limit, "int") - if order is not None: - _params["order"] = _SERIALIZER.query("order", order, "str") - if after is not None: - _params["after"] = _SERIALIZER.query("after", after, "str") - if before is not None: - _params["before"] = _SERIALIZER.query("before", before, "str") + if input_name is not None: + _params["inputName"] = _SERIALIZER.query("input_name", input_name, "str") + if input_type is not None: + _params["inputType"] = _SERIALIZER.query("input_type", input_type, "str") # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_agents_create_agent_request(**kwargs: Any) -> HttpRequest: +def build_beta_evaluation_taxonomies_delete_request( # pylint: disable=name-too-long + name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) # Construct URL - _url = "/assistants" + _url = "/evaluationtaxonomies/{name}" + path_format_arguments = { + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_agents_list_agents_request( - *, - limit: Optional[int] = None, - order: Optional[Union[str, _models.ListSortOrder]] = None, - after: Optional[str] = None, - before: Optional[str] = None, - **kwargs: Any +def build_beta_evaluation_taxonomies_create_request( # pylint: disable=name-too-long + name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/assistants" + _url = "/evaluationtaxonomies/{name}" + path_format_arguments = { + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_beta_evaluation_taxonomies_update_request( # pylint: disable=name-too-long + name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/evaluationtaxonomies/{name}" + path_format_arguments = { + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_beta_evaluators_list_versions_request( # pylint: disable=name-too-long + name: str, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + type: Optional[Union[Literal["builtin"], Literal["custom"], Literal["all"], str]] = None, + limit: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/evaluators/{name}/versions" + path_format_arguments = { + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if type is not None: + _params["type"] = _SERIALIZER.query("type", type, "str") + if limit is not None: + _params["limit"] = _SERIALIZER.query("limit", limit, "int") + + # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_beta_evaluators_list_request( + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + type: Optional[Union[Literal["builtin"], Literal["custom"], Literal["all"], str]] = None, + limit: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/evaluators" + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if type is not None: + _params["type"] = _SERIALIZER.query("type", type, "str") if limit is not None: _params["limit"] = _SERIALIZER.query("limit", limit, "int") - if order is not None: - _params["order"] = _SERIALIZER.query("order", order, "str") - if after is not None: - _params["after"] = _SERIALIZER.query("after", after, "str") - if before is not None: - _params["before"] = _SERIALIZER.query("before", before, "str") # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_agents_get_agent_request(agent_id: str, **kwargs: Any) -> HttpRequest: +def build_beta_evaluators_get_version_request( # pylint: disable=name-too-long + name: str, + version: str, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/assistants/{assistantId}" + _url = "/evaluators/{name}/versions/{version}" path_format_arguments = { - "assistantId": _SERIALIZER.url("agent_id", agent_id, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "version": _SERIALIZER.url("version", version, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1155,23 +1162,55 @@ def build_agents_get_agent_request(agent_id: str, **kwargs: Any) -> HttpRequest: _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_agents_update_agent_request(agent_id: str, **kwargs: Any) -> HttpRequest: +def build_beta_evaluators_delete_version_request( # pylint: disable=name-too-long + name: str, + version: str, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + # Construct URL + _url = "/evaluators/{name}/versions/{version}" + path_format_arguments = { + "name": _SERIALIZER.url("name", name, "str"), + "version": _SERIALIZER.url("version", version, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_beta_evaluators_create_version_request( # pylint: disable=name-too-long + name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/assistants/{assistantId}" + _url = "/evaluators/{name}/versions" path_format_arguments = { - "assistantId": _SERIALIZER.url("agent_id", agent_id, "str"), + "name": _SERIALIZER.url("name", name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1180,6 +1219,7 @@ def build_agents_update_agent_request(agent_id: str, **kwargs: Any) -> HttpReque _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1187,17 +1227,25 @@ def build_agents_update_agent_request(agent_id: str, **kwargs: Any) -> HttpReque return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_agents_delete_agent_request(agent_id: str, **kwargs: Any) -> HttpRequest: +def build_beta_evaluators_update_version_request( # pylint: disable=name-too-long + name: str, + version: str, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/assistants/{assistantId}" + _url = "/evaluators/{name}/versions/{version}" path_format_arguments = { - "assistantId": _SERIALIZER.url("agent_id", agent_id, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "version": _SERIALIZER.url("version", version, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1206,26 +1254,39 @@ def build_agents_delete_agent_request(agent_id: str, **kwargs: Any) -> HttpReque _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_agents_create_thread_and_run_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long +def build_beta_insights_generate_request( + *, foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW]] = None, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/threads/runs" + _url = "/insights" # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if foundry_features is not None: + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + if "Repeatability-Request-ID" not in _headers: + _headers["Repeatability-Request-ID"] = str(uuid.uuid4()) + if "Repeatability-First-Sent" not in _headers: + _headers["Repeatability-First-Sent"] = _SERIALIZER.serialize_data( + datetime.datetime.now(datetime.timezone.utc), "rfc-1123" + ) if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1233,116 +1294,5514 @@ def build_agents_create_thread_and_run_request(**kwargs: Any) -> HttpRequest: # return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class ThreadsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. +def build_beta_insights_get_request( + id: str, + *, + foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW]] = None, + include_coordinates: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/insights/{id}" + path_format_arguments = { + "id": _SERIALIZER.url("id", id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if include_coordinates is not None: + _params["includeCoordinates"] = _SERIALIZER.query("include_coordinates", include_coordinates, "bool") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if foundry_features is not None: + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_beta_insights_list_request( + *, + foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW]] = None, + type: Optional[types.InsightType] = None, + eval_id: Optional[str] = None, + run_id: Optional[str] = None, + agent_name: Optional[str] = None, + include_coordinates: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/insights" + + # Construct parameters + if type is not None: + _params["type"] = _SERIALIZER.query("type", type, "str") + if eval_id is not None: + _params["evalId"] = _SERIALIZER.query("eval_id", eval_id, "str") + if run_id is not None: + _params["runId"] = _SERIALIZER.query("run_id", run_id, "str") + if agent_name is not None: + _params["agentName"] = _SERIALIZER.query("agent_name", agent_name, "str") + if include_coordinates is not None: + _params["includeCoordinates"] = _SERIALIZER.query("include_coordinates", include_coordinates, "bool") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if foundry_features is not None: + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_beta_memory_stores_create_request( + *, foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/memory_stores" + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_beta_memory_stores_update_request( + name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/memory_stores/{name}" + path_format_arguments = { + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_beta_memory_stores_get_request( + name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/memory_stores/{name}" + path_format_arguments = { + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_beta_memory_stores_list_request( + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + limit: Optional[int] = None, + order: Optional[types.PageOrder] = None, + after: Optional[str] = None, + before: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/memory_stores" + + # Construct parameters + if limit is not None: + _params["limit"] = _SERIALIZER.query("limit", limit, "int") + if order is not None: + _params["order"] = _SERIALIZER.query("order", order, "str") + if after is not None: + _params["after"] = _SERIALIZER.query("after", after, "str") + if before is not None: + _params["before"] = _SERIALIZER.query("before", before, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_beta_memory_stores_delete_request( + name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/memory_stores/{name}" + path_format_arguments = { + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_beta_memory_stores_search_memories_request( # pylint: disable=name-too-long + name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/memory_stores/{name}:search_memories" + path_format_arguments = { + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_beta_memory_stores_update_memories_request( # pylint: disable=name-too-long + name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/memory_stores/{name}:update_memories" + path_format_arguments = { + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_beta_memory_stores_delete_scope_request( # pylint: disable=name-too-long + name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/memory_stores/{name}:delete_scope" + path_format_arguments = { + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_beta_red_teams_get_request( + name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.RED_TEAMS_V1_PREVIEW], **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/redTeams/runs/{name}" + path_format_arguments = { + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_beta_red_teams_list_request( + *, foundry_features: Literal[FoundryFeaturesOptInKeys.RED_TEAMS_V1_PREVIEW], **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/redTeams/runs" + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_beta_red_teams_create_request( + *, foundry_features: Literal[FoundryFeaturesOptInKeys.RED_TEAMS_V1_PREVIEW], **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/redTeams/runs:run" + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_beta_schedules_delete_request( + schedule_id: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + # Construct URL + _url = "/schedules/{id}" + path_format_arguments = { + "id": _SERIALIZER.url("schedule_id", schedule_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_beta_schedules_get_request( + schedule_id: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/schedules/{id}" + path_format_arguments = { + "id": _SERIALIZER.url("schedule_id", schedule_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_beta_schedules_list_request( + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], + type: Optional[types.ScheduleTaskType] = None, + enabled: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/schedules" + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if type is not None: + _params["type"] = _SERIALIZER.query("type", type, "str") + if enabled is not None: + _params["enabled"] = _SERIALIZER.query("enabled", enabled, "bool") + + # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_beta_schedules_create_or_update_request( # pylint: disable=name-too-long + schedule_id: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/schedules/{id}" + path_format_arguments = { + "id": _SERIALIZER.url("schedule_id", schedule_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_beta_schedules_get_run_request( + schedule_id: str, + run_id: str, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/schedules/{schedule_id}/runs/{run_id}" + path_format_arguments = { + "schedule_id": _SERIALIZER.url("schedule_id", schedule_id, "str"), + "run_id": _SERIALIZER.url("run_id", run_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_beta_schedules_list_runs_request( + schedule_id: str, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], + type: Optional[types.ScheduleTaskType] = None, + enabled: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/schedules/{id}/runs" + path_format_arguments = { + "id": _SERIALIZER.url("schedule_id", schedule_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if type is not None: + _params["type"] = _SERIALIZER.query("type", type, "str") + if enabled is not None: + _params["enabled"] = _SERIALIZER.query("enabled", enabled, "bool") + + # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class BetaOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.agents.AIProjectClient`'s + :attr:`beta` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + self.evaluation_taxonomies = BetaEvaluationTaxonomiesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.evaluators = BetaEvaluatorsOperations(self._client, self._config, self._serialize, self._deserialize) + self.insights = BetaInsightsOperations(self._client, self._config, self._serialize, self._deserialize) + self.memory_stores = BetaMemoryStoresOperations(self._client, self._config, self._serialize, self._deserialize) + self.red_teams = BetaRedTeamsOperations(self._client, self._config, self._serialize, self._deserialize) + self.schedules = BetaSchedulesOperations(self._client, self._config, self._serialize, self._deserialize) + + +class AgentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.agents.AIProjectClient`'s + :attr:`agents` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, agent_name: str, **kwargs: Any) -> _types_models1.AgentDetails: + """Retrieves the agent. + + :param agent_name: The name of the agent to retrieve. Required. + :type agent_name: str + :return: AgentDetails + :rtype: ~azure.ai.agents.types.AgentDetails + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "hosted": + agent_definition = { + "container_protocol_versions": [ + { + "protocol": "str", + "version": "str" + } + ], + "cpu": "str", + "kind": "hosted", + "memory": "str", + "environment_variables": { + "str": "str" + }, + "image": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "tools": [ + tool + ] + } + + # JSON input template for discriminator value "prompt": + agent_definition = { + "kind": "prompt", + "model": "str", + "instructions": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "structured_inputs": { + "str": { + "default_value": {}, + "description": "str", + "required": bool, + "schema": { + "str": {} + } + } + }, + "temperature": 0.0, + "text": { + "format": text_response_format + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_p": 0.0 + } + + # JSON input template for discriminator value "json_object": + text_response_format = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format = { + "name": "str", + "schema": { + "str": {} + }, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "id": "str", + "name": "str", + "object": "str", + "versions": { + "latest": { + "created_at": "2020-02-20 00:00:00", + "definition": agent_definition, + "id": "str", + "metadata": { + "str": "str" + }, + "name": "str", + "object": "str", + "version": "str", + "description": "str" + } + } + } + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_types_models1.AgentDetails] = kwargs.pop("cls", None) + + _request = build_agents_get_request( + agent_name=agent_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _types_models1.ApiErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def _create_agent( + self, + name: str, + definition: _types_models1.AgentDefinition, + metadata: Optional[dict[str, str]] = None, + description: Optional[str] = None, + *, + foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models1.AgentDetails: ... + @overload + def _create_agent( + self, + body: JSON, + *, + foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models1.AgentDetails: ... + @overload + def _create_agent( + self, + body: IO[bytes], + *, + foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models1.AgentDetails: ... + + @distributed_trace + def _create_agent( + self, + name: str = _Unset, + definition: _types_models1.AgentDefinition = _Unset, + body: Union[JSON, IO[bytes]] = _Unset, + metadata: Optional[dict[str, str]] = None, + description: Optional[str] = None, + *, + foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, + **kwargs: Any + ) -> _types_models1.AgentDetails: + """Creates the agent. + + :param name: The unique name that identifies the agent. Name can be used to + retrieve/update/delete the agent. + + * Must start and end with alphanumeric characters, + * Can contain hyphens in the middle + * Must not exceed 63 characters. Required. + :type name: str + :param definition: The agent definition. This can be a workflow, hosted agent, or a simple + agent definition. Required. + :type definition: ~azure.ai.agents.types.AgentDefinition + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :param metadata: Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. Default value is None. + :type metadata: dict[str, str] + :param description: A human-readable description of the agent. Default value is None. + :type description: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. Known values are: "HostedAgents=V1Preview" and + "WorkflowAgents=V1Preview". Default value is None. + :paramtype foundry_features: str or ~azure.ai.agents.models.AgentDefinitionOptInKeys + :return: AgentDetails + :rtype: ~azure.ai.agents.types.AgentDetails + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "kind": + + # JSON input template for discriminator value "hosted": + agent_definition = { + "container_protocol_versions": [ + { + "protocol": "str", + "version": "str" + } + ], + "cpu": "str", + "kind": "hosted", + "memory": "str", + "environment_variables": { + "str": "str" + }, + "image": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "tools": [ + tool + ] + } + + # JSON input template for discriminator value "prompt": + agent_definition = { + "kind": "prompt", + "model": "str", + "instructions": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "structured_inputs": { + "str": { + "default_value": {}, + "description": "str", + "required": bool, + "schema": { + "str": {} + } + } + }, + "temperature": 0.0, + "text": { + "format": text_response_format + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_p": 0.0 + } + + # JSON input template for discriminator value "json_object": + text_response_format = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format = { + "name": "str", + "schema": { + "str": {} + }, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format = { + "type": "text" + } + + # JSON input template you can fill out and use as your body input. + body = { + "definition": agent_definition, + "name": "str", + "description": "str", + "metadata": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "hosted": + agent_definition = { + "container_protocol_versions": [ + { + "protocol": "str", + "version": "str" + } + ], + "cpu": "str", + "kind": "hosted", + "memory": "str", + "environment_variables": { + "str": "str" + }, + "image": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "tools": [ + tool + ] + } + + # JSON input template for discriminator value "prompt": + agent_definition = { + "kind": "prompt", + "model": "str", + "instructions": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "structured_inputs": { + "str": { + "default_value": {}, + "description": "str", + "required": bool, + "schema": { + "str": {} + } + } + }, + "temperature": 0.0, + "text": { + "format": text_response_format + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_p": 0.0 + } + + # JSON input template for discriminator value "json_object": + text_response_format = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format = { + "name": "str", + "schema": { + "str": {} + }, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "id": "str", + "name": "str", + "object": "str", + "versions": { + "latest": { + "created_at": "2020-02-20 00:00:00", + "definition": agent_definition, + "id": "str", + "metadata": { + "str": "str" + }, + "name": "str", + "object": "str", + "version": "str", + "description": "str" + } + } + } + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_types_models1.AgentDetails] = kwargs.pop("cls", None) + + if body is _Unset: + if name is _Unset: + raise TypeError("missing required argument: name") + if definition is _Unset: + raise TypeError("missing required argument: definition") + body = {"definition": definition, "description": description, "metadata": metadata, "name": name} + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_agents_create_agent_request( + foundry_features=foundry_features, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _types_models1.ApiErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def _update_agent( + self, + agent_name: str, + definition: _types_models1.AgentDefinition, + metadata: Optional[dict[str, str]] = None, + description: Optional[str] = None, + *, + foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models1.AgentDetails: ... + @overload + def _update_agent( + self, + agent_name: str, + body: JSON, + *, + foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models1.AgentDetails: ... + @overload + def _update_agent( + self, + agent_name: str, + body: IO[bytes], + *, + foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models1.AgentDetails: ... + + @distributed_trace + def _update_agent( + self, + agent_name: str, + definition: _types_models1.AgentDefinition = _Unset, + body: Union[JSON, IO[bytes]] = _Unset, + metadata: Optional[dict[str, str]] = None, + description: Optional[str] = None, + *, + foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, + **kwargs: Any + ) -> _types_models1.AgentDetails: + """Updates the agent by adding a new version if there are any changes to the agent definition. If + no changes, returns the existing agent version. + + :param agent_name: The name of the agent to retrieve. Required. + :type agent_name: str + :param definition: The agent definition. This can be a workflow, hosted agent, or a simple + agent definition. Required. + :type definition: ~azure.ai.agents.types.AgentDefinition + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :param metadata: Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. Default value is None. + :type metadata: dict[str, str] + :param description: A human-readable description of the agent. Default value is None. + :type description: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. Known values are: "HostedAgents=V1Preview" and + "WorkflowAgents=V1Preview". Default value is None. + :paramtype foundry_features: str or ~azure.ai.agents.models.AgentDefinitionOptInKeys + :return: AgentDetails + :rtype: ~azure.ai.agents.types.AgentDetails + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "kind": + + # JSON input template for discriminator value "hosted": + agent_definition = { + "container_protocol_versions": [ + { + "protocol": "str", + "version": "str" + } + ], + "cpu": "str", + "kind": "hosted", + "memory": "str", + "environment_variables": { + "str": "str" + }, + "image": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "tools": [ + tool + ] + } + + # JSON input template for discriminator value "prompt": + agent_definition = { + "kind": "prompt", + "model": "str", + "instructions": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "structured_inputs": { + "str": { + "default_value": {}, + "description": "str", + "required": bool, + "schema": { + "str": {} + } + } + }, + "temperature": 0.0, + "text": { + "format": text_response_format + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_p": 0.0 + } + + # JSON input template for discriminator value "json_object": + text_response_format = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format = { + "name": "str", + "schema": { + "str": {} + }, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format = { + "type": "text" + } + + # JSON input template you can fill out and use as your body input. + body = { + "definition": agent_definition, + "description": "str", + "metadata": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "hosted": + agent_definition = { + "container_protocol_versions": [ + { + "protocol": "str", + "version": "str" + } + ], + "cpu": "str", + "kind": "hosted", + "memory": "str", + "environment_variables": { + "str": "str" + }, + "image": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "tools": [ + tool + ] + } + + # JSON input template for discriminator value "prompt": + agent_definition = { + "kind": "prompt", + "model": "str", + "instructions": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "structured_inputs": { + "str": { + "default_value": {}, + "description": "str", + "required": bool, + "schema": { + "str": {} + } + } + }, + "temperature": 0.0, + "text": { + "format": text_response_format + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_p": 0.0 + } + + # JSON input template for discriminator value "json_object": + text_response_format = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format = { + "name": "str", + "schema": { + "str": {} + }, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "id": "str", + "name": "str", + "object": "str", + "versions": { + "latest": { + "created_at": "2020-02-20 00:00:00", + "definition": agent_definition, + "id": "str", + "metadata": { + "str": "str" + }, + "name": "str", + "object": "str", + "version": "str", + "description": "str" + } + } + } + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_types_models1.AgentDetails] = kwargs.pop("cls", None) + + if body is _Unset: + if definition is _Unset: + raise TypeError("missing required argument: definition") + body = {"definition": definition, "description": description, "metadata": metadata} + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_agents_update_agent_request( + agent_name=agent_name, + foundry_features=foundry_features, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _types_models1.ApiErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def _create_agent_from_manifest( + self, + name: str, + manifest_id: str, + parameter_values: dict[str, Any], + metadata: Optional[dict[str, str]] = None, + description: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models1.AgentDetails: ... + @overload + def _create_agent_from_manifest( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _types_models1.AgentDetails: ... + @overload + def _create_agent_from_manifest( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _types_models1.AgentDetails: ... + + @distributed_trace + def _create_agent_from_manifest( + self, + name: str = _Unset, + manifest_id: str = _Unset, + parameter_values: dict[str, Any] = _Unset, + body: Union[JSON, IO[bytes]] = _Unset, + metadata: Optional[dict[str, str]] = None, + description: Optional[str] = None, + **kwargs: Any + ) -> _types_models1.AgentDetails: + """Creates an agent from a manifest. + + :param name: The unique name that identifies the agent. Name can be used to + retrieve/update/delete the agent. + + * Must start and end with alphanumeric characters, + * Can contain hyphens in the middle + * Must not exceed 63 characters. Required. + :type name: str + :param manifest_id: The manifest ID to import the agent version from. Required. + :type manifest_id: str + :param parameter_values: The inputs to the manifest that will result in a fully materialized + Agent. Required. + :type parameter_values: dict[str, any] + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :param metadata: Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. Default value is None. + :type metadata: dict[str, str] + :param description: A human-readable description of the agent. Default value is None. + :type description: str + :return: AgentDetails + :rtype: ~azure.ai.agents.types.AgentDetails + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "manifest_id": "str", + "name": "str", + "parameter_values": { + "str": {} + }, + "description": "str", + "metadata": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "hosted": + agent_definition = { + "container_protocol_versions": [ + { + "protocol": "str", + "version": "str" + } + ], + "cpu": "str", + "kind": "hosted", + "memory": "str", + "environment_variables": { + "str": "str" + }, + "image": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "tools": [ + tool + ] + } + + # JSON input template for discriminator value "prompt": + agent_definition = { + "kind": "prompt", + "model": "str", + "instructions": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "structured_inputs": { + "str": { + "default_value": {}, + "description": "str", + "required": bool, + "schema": { + "str": {} + } + } + }, + "temperature": 0.0, + "text": { + "format": text_response_format + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_p": 0.0 + } + + # JSON input template for discriminator value "json_object": + text_response_format = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format = { + "name": "str", + "schema": { + "str": {} + }, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "id": "str", + "name": "str", + "object": "str", + "versions": { + "latest": { + "created_at": "2020-02-20 00:00:00", + "definition": agent_definition, + "id": "str", + "metadata": { + "str": "str" + }, + "name": "str", + "object": "str", + "version": "str", + "description": "str" + } + } + } + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_types_models1.AgentDetails] = kwargs.pop("cls", None) + + if body is _Unset: + if name is _Unset: + raise TypeError("missing required argument: name") + if manifest_id is _Unset: + raise TypeError("missing required argument: manifest_id") + if parameter_values is _Unset: + raise TypeError("missing required argument: parameter_values") + body = { + "description": description, + "manifest_id": manifest_id, + "metadata": metadata, + "name": name, + "parameter_values": parameter_values, + } + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_agents_create_agent_from_manifest_request( + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _types_models1.ApiErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def _update_agent_from_manifest( + self, + agent_name: str, + manifest_id: str, + parameter_values: dict[str, Any], + metadata: Optional[dict[str, str]] = None, + description: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models1.AgentDetails: ... + @overload + def _update_agent_from_manifest( + self, agent_name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _types_models1.AgentDetails: ... + @overload + def _update_agent_from_manifest( + self, agent_name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _types_models1.AgentDetails: ... + + @distributed_trace + def _update_agent_from_manifest( + self, + agent_name: str, + manifest_id: str = _Unset, + parameter_values: dict[str, Any] = _Unset, + body: Union[JSON, IO[bytes]] = _Unset, + metadata: Optional[dict[str, str]] = None, + description: Optional[str] = None, + **kwargs: Any + ) -> _types_models1.AgentDetails: + """Updates the agent from a manifest by adding a new version if there are any changes to the agent + definition. If no changes, returns the existing agent version. + + :param agent_name: The name of the agent to update. Required. + :type agent_name: str + :param manifest_id: The manifest ID to import the agent version from. Required. + :type manifest_id: str + :param parameter_values: The inputs to the manifest that will result in a fully materialized + Agent. Required. + :type parameter_values: dict[str, any] + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :param metadata: Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. Default value is None. + :type metadata: dict[str, str] + :param description: A human-readable description of the agent. Default value is None. + :type description: str + :return: AgentDetails + :rtype: ~azure.ai.agents.types.AgentDetails + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "manifest_id": "str", + "parameter_values": { + "str": {} + }, + "description": "str", + "metadata": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "hosted": + agent_definition = { + "container_protocol_versions": [ + { + "protocol": "str", + "version": "str" + } + ], + "cpu": "str", + "kind": "hosted", + "memory": "str", + "environment_variables": { + "str": "str" + }, + "image": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "tools": [ + tool + ] + } + + # JSON input template for discriminator value "prompt": + agent_definition = { + "kind": "prompt", + "model": "str", + "instructions": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "structured_inputs": { + "str": { + "default_value": {}, + "description": "str", + "required": bool, + "schema": { + "str": {} + } + } + }, + "temperature": 0.0, + "text": { + "format": text_response_format + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_p": 0.0 + } + + # JSON input template for discriminator value "json_object": + text_response_format = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format = { + "name": "str", + "schema": { + "str": {} + }, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "id": "str", + "name": "str", + "object": "str", + "versions": { + "latest": { + "created_at": "2020-02-20 00:00:00", + "definition": agent_definition, + "id": "str", + "metadata": { + "str": "str" + }, + "name": "str", + "object": "str", + "version": "str", + "description": "str" + } + } + } + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_types_models1.AgentDetails] = kwargs.pop("cls", None) + + if body is _Unset: + if manifest_id is _Unset: + raise TypeError("missing required argument: manifest_id") + if parameter_values is _Unset: + raise TypeError("missing required argument: parameter_values") + body = { + "description": description, + "manifest_id": manifest_id, + "metadata": metadata, + "parameter_values": parameter_values, + } + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_agents_update_agent_from_manifest_request( + agent_name=agent_name, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _types_models1.ApiErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete(self, agent_name: str, **kwargs: Any) -> _types_models1.DeleteAgentResponse: + """Deletes an agent. + + :param agent_name: The name of the agent to delete. Required. + :type agent_name: str + :return: DeleteAgentResponse + :rtype: ~azure.ai.agents.types.DeleteAgentResponse + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "deleted": bool, + "name": "str", + "object": "str" + } + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_types_models1.DeleteAgentResponse] = kwargs.pop("cls", None) + + _request = build_agents_delete_request( + agent_name=agent_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _types_models1.ApiErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, + *, + kind: Optional[types.AgentKind] = None, + limit: Optional[int] = None, + order: Optional[types.PageOrder] = None, + before: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_types_models1.AgentDetails"]: + """Returns the list of all agents. + + :keyword kind: Filter agents by kind. If not provided, all agents are returned. Known values + are: "prompt", "hosted", and "workflow". Default value is None. + :paramtype kind: str or ~azure.ai.agents.models.AgentKind + :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and + 100, and the + default is 20. Default value is None. + :paramtype limit: int + :keyword order: Sort order by the ``created_at`` timestamp of the objects. ``asc`` for + ascending order and``desc`` + for descending order. Known values are: "asc" and "desc". Default value is None. + :paramtype order: str or ~azure.ai.agents.models.PageOrder + :keyword 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. + Default value is None. + :paramtype before: str + :return: An iterator like instance of AgentDetails + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.types.AgentDetails] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "hosted": + agent_definition = { + "container_protocol_versions": [ + { + "protocol": "str", + "version": "str" + } + ], + "cpu": "str", + "kind": "hosted", + "memory": "str", + "environment_variables": { + "str": "str" + }, + "image": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "tools": [ + tool + ] + } + + # JSON input template for discriminator value "prompt": + agent_definition = { + "kind": "prompt", + "model": "str", + "instructions": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "structured_inputs": { + "str": { + "default_value": {}, + "description": "str", + "required": bool, + "schema": { + "str": {} + } + } + }, + "temperature": 0.0, + "text": { + "format": text_response_format + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_p": 0.0 + } + + # JSON input template for discriminator value "json_object": + text_response_format = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format = { + "name": "str", + "schema": { + "str": {} + }, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "id": "str", + "name": "str", + "object": "str", + "versions": { + "latest": { + "created_at": "2020-02-20 00:00:00", + "definition": agent_definition, + "id": "str", + "metadata": { + "str": "str" + }, + "name": "str", + "object": "str", + "version": "str", + "description": "str" + } + } + } + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_types_models1.AgentDetails]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(_continuation_token=None): + + _request = build_agents_list_request( + kind=kind, + limit=limit, + order=order, + after=_continuation_token, + before=before, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized.get("data", []) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("last_id") or None, iter(list_of_elem) + + def get_next(_continuation_token=None): + _request = prepare_request(_continuation_token) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _types_models1.ApiErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @overload + def create_version( + self, + agent_name: str, + definition: _types_models1.AgentDefinition, + metadata: Optional[dict[str, str]] = None, + description: Optional[str] = None, + *, + foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models1.AgentVersionDetails: + """Create a new agent version. + + :param agent_name: The unique name that identifies the agent. Name can be used to + retrieve/update/delete the agent. + + * Must start and end with alphanumeric characters, + * Can contain hyphens in the middle + * Must not exceed 63 characters. Required. + :type agent_name: str + :param definition: The agent definition. This can be a workflow, hosted agent, or a simple + agent definition. Required. + :type definition: ~azure.ai.agents.types.AgentDefinition + :param metadata: Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. Default value is None. + :type metadata: dict[str, str] + :param description: A human-readable description of the agent. Default value is None. + :type description: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. Known values are: "HostedAgents=V1Preview" and + "WorkflowAgents=V1Preview". Default value is None. + :paramtype foundry_features: str or ~azure.ai.agents.models.AgentDefinitionOptInKeys + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AgentVersionDetails + :rtype: ~azure.ai.agents.types.AgentVersionDetails + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "hosted": + agent_definition = { + "container_protocol_versions": [ + { + "protocol": "str", + "version": "str" + } + ], + "cpu": "str", + "kind": "hosted", + "memory": "str", + "environment_variables": { + "str": "str" + }, + "image": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "tools": [ + tool + ] + } + + # JSON input template for discriminator value "prompt": + agent_definition = { + "kind": "prompt", + "model": "str", + "instructions": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "structured_inputs": { + "str": { + "default_value": {}, + "description": "str", + "required": bool, + "schema": { + "str": {} + } + } + }, + "temperature": 0.0, + "text": { + "format": text_response_format + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_p": 0.0 + } + + # JSON input template for discriminator value "json_object": + text_response_format = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format = { + "name": "str", + "schema": { + "str": {} + }, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "definition": agent_definition, + "id": "str", + "metadata": { + "str": "str" + }, + "name": "str", + "object": "str", + "version": "str", + "description": "str" + } + """ + + @overload + def create_version( + self, + agent_name: str, + body: JSON, + *, + foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models1.AgentVersionDetails: + """Create a new agent version. + + :param agent_name: The unique name that identifies the agent. Name can be used to + retrieve/update/delete the agent. + + * Must start and end with alphanumeric characters, + * Can contain hyphens in the middle + * Must not exceed 63 characters. Required. + :type agent_name: str + :param body: Required. + :type body: JSON + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. Known values are: "HostedAgents=V1Preview" and + "WorkflowAgents=V1Preview". Default value is None. + :paramtype foundry_features: str or ~azure.ai.agents.models.AgentDefinitionOptInKeys + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AgentVersionDetails + :rtype: ~azure.ai.agents.types.AgentVersionDetails + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "kind": + + # JSON input template for discriminator value "hosted": + agent_definition = { + "container_protocol_versions": [ + { + "protocol": "str", + "version": "str" + } + ], + "cpu": "str", + "kind": "hosted", + "memory": "str", + "environment_variables": { + "str": "str" + }, + "image": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "tools": [ + tool + ] + } + + # JSON input template for discriminator value "prompt": + agent_definition = { + "kind": "prompt", + "model": "str", + "instructions": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "structured_inputs": { + "str": { + "default_value": {}, + "description": "str", + "required": bool, + "schema": { + "str": {} + } + } + }, + "temperature": 0.0, + "text": { + "format": text_response_format + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_p": 0.0 + } + + # JSON input template for discriminator value "json_object": + text_response_format = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format = { + "name": "str", + "schema": { + "str": {} + }, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format = { + "type": "text" + } + + # JSON input template you can fill out and use as your body input. + body = { + "definition": agent_definition, + "description": "str", + "metadata": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "hosted": + agent_definition = { + "container_protocol_versions": [ + { + "protocol": "str", + "version": "str" + } + ], + "cpu": "str", + "kind": "hosted", + "memory": "str", + "environment_variables": { + "str": "str" + }, + "image": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "tools": [ + tool + ] + } + + # JSON input template for discriminator value "prompt": + agent_definition = { + "kind": "prompt", + "model": "str", + "instructions": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "structured_inputs": { + "str": { + "default_value": {}, + "description": "str", + "required": bool, + "schema": { + "str": {} + } + } + }, + "temperature": 0.0, + "text": { + "format": text_response_format + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_p": 0.0 + } + + # JSON input template for discriminator value "json_object": + text_response_format = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format = { + "name": "str", + "schema": { + "str": {} + }, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "definition": agent_definition, + "id": "str", + "metadata": { + "str": "str" + }, + "name": "str", + "object": "str", + "version": "str", + "description": "str" + } + """ + + @overload + def create_version( + self, + agent_name: str, + body: IO[bytes], + *, + foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models1.AgentVersionDetails: + """Create a new agent version. + + :param agent_name: The unique name that identifies the agent. Name can be used to + retrieve/update/delete the agent. + + * Must start and end with alphanumeric characters, + * Can contain hyphens in the middle + * Must not exceed 63 characters. Required. + :type agent_name: str + :param body: Required. + :type body: IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. Known values are: "HostedAgents=V1Preview" and + "WorkflowAgents=V1Preview". Default value is None. + :paramtype foundry_features: str or ~azure.ai.agents.models.AgentDefinitionOptInKeys + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: AgentVersionDetails + :rtype: ~azure.ai.agents.types.AgentVersionDetails + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "hosted": + agent_definition = { + "container_protocol_versions": [ + { + "protocol": "str", + "version": "str" + } + ], + "cpu": "str", + "kind": "hosted", + "memory": "str", + "environment_variables": { + "str": "str" + }, + "image": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "tools": [ + tool + ] + } + + # JSON input template for discriminator value "prompt": + agent_definition = { + "kind": "prompt", + "model": "str", + "instructions": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "structured_inputs": { + "str": { + "default_value": {}, + "description": "str", + "required": bool, + "schema": { + "str": {} + } + } + }, + "temperature": 0.0, + "text": { + "format": text_response_format + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_p": 0.0 + } + + # JSON input template for discriminator value "json_object": + text_response_format = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format = { + "name": "str", + "schema": { + "str": {} + }, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "definition": agent_definition, + "id": "str", + "metadata": { + "str": "str" + }, + "name": "str", + "object": "str", + "version": "str", + "description": "str" + } + """ + + @distributed_trace + def create_version( + self, + agent_name: str, + definition: _types_models1.AgentDefinition = _Unset, + body: Union[JSON, IO[bytes]] = _Unset, + metadata: Optional[dict[str, str]] = None, + description: Optional[str] = None, + *, + foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, + **kwargs: Any + ) -> _types_models1.AgentVersionDetails: + """Create a new agent version. + + :param agent_name: The unique name that identifies the agent. Name can be used to + retrieve/update/delete the agent. + + * Must start and end with alphanumeric characters, + * Can contain hyphens in the middle + * Must not exceed 63 characters. Required. + :type agent_name: str + :param definition: The agent definition. This can be a workflow, hosted agent, or a simple + agent definition. Required. + :type definition: ~azure.ai.agents.types.AgentDefinition + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :param metadata: Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. Default value is None. + :type metadata: dict[str, str] + :param description: A human-readable description of the agent. Default value is None. + :type description: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. Known values are: "HostedAgents=V1Preview" and + "WorkflowAgents=V1Preview". Default value is None. + :paramtype foundry_features: str or ~azure.ai.agents.models.AgentDefinitionOptInKeys + :return: AgentVersionDetails + :rtype: ~azure.ai.agents.types.AgentVersionDetails + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "kind": + + # JSON input template for discriminator value "hosted": + agent_definition = { + "container_protocol_versions": [ + { + "protocol": "str", + "version": "str" + } + ], + "cpu": "str", + "kind": "hosted", + "memory": "str", + "environment_variables": { + "str": "str" + }, + "image": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "tools": [ + tool + ] + } + + # JSON input template for discriminator value "prompt": + agent_definition = { + "kind": "prompt", + "model": "str", + "instructions": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "structured_inputs": { + "str": { + "default_value": {}, + "description": "str", + "required": bool, + "schema": { + "str": {} + } + } + }, + "temperature": 0.0, + "text": { + "format": text_response_format + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_p": 0.0 + } + + # JSON input template for discriminator value "json_object": + text_response_format = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format = { + "name": "str", + "schema": { + "str": {} + }, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format = { + "type": "text" + } + + # JSON input template you can fill out and use as your body input. + body = { + "definition": agent_definition, + "description": "str", + "metadata": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "hosted": + agent_definition = { + "container_protocol_versions": [ + { + "protocol": "str", + "version": "str" + } + ], + "cpu": "str", + "kind": "hosted", + "memory": "str", + "environment_variables": { + "str": "str" + }, + "image": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "tools": [ + tool + ] + } + + # JSON input template for discriminator value "prompt": + agent_definition = { + "kind": "prompt", + "model": "str", + "instructions": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "structured_inputs": { + "str": { + "default_value": {}, + "description": "str", + "required": bool, + "schema": { + "str": {} + } + } + }, + "temperature": 0.0, + "text": { + "format": text_response_format + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_p": 0.0 + } + + # JSON input template for discriminator value "json_object": + text_response_format = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format = { + "name": "str", + "schema": { + "str": {} + }, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "definition": agent_definition, + "id": "str", + "metadata": { + "str": "str" + }, + "name": "str", + "object": "str", + "version": "str", + "description": "str" + } + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_types_models1.AgentVersionDetails] = kwargs.pop("cls", None) + + if body is _Unset: + if definition is _Unset: + raise TypeError("missing required argument: definition") + body = {"definition": definition, "description": description, "metadata": metadata} + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_agents_create_version_request( + agent_name=agent_name, + foundry_features=foundry_features, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _types_models1.ApiErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_version_from_manifest( + self, + agent_name: str, + manifest_id: str, + parameter_values: dict[str, Any], + metadata: Optional[dict[str, str]] = None, + description: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models1.AgentVersionDetails: + """Create a new agent version from a manifest. + + :param agent_name: The unique name that identifies the agent. Name can be used to + retrieve/update/delete the agent. + + * Must start and end with alphanumeric characters, + * Can contain hyphens in the middle + * Must not exceed 63 characters. Required. + :type agent_name: str + :param manifest_id: The manifest ID to import the agent version from. Required. + :type manifest_id: str + :param parameter_values: The inputs to the manifest that will result in a fully materialized + Agent. Required. + :type parameter_values: dict[str, any] + :param metadata: Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. Default value is None. + :type metadata: dict[str, str] + :param description: A human-readable description of the agent. Default value is None. + :type description: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AgentVersionDetails + :rtype: ~azure.ai.agents.types.AgentVersionDetails + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "hosted": + agent_definition = { + "container_protocol_versions": [ + { + "protocol": "str", + "version": "str" + } + ], + "cpu": "str", + "kind": "hosted", + "memory": "str", + "environment_variables": { + "str": "str" + }, + "image": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "tools": [ + tool + ] + } + + # JSON input template for discriminator value "prompt": + agent_definition = { + "kind": "prompt", + "model": "str", + "instructions": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "structured_inputs": { + "str": { + "default_value": {}, + "description": "str", + "required": bool, + "schema": { + "str": {} + } + } + }, + "temperature": 0.0, + "text": { + "format": text_response_format + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_p": 0.0 + } + + # JSON input template for discriminator value "json_object": + text_response_format = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format = { + "name": "str", + "schema": { + "str": {} + }, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "definition": agent_definition, + "id": "str", + "metadata": { + "str": "str" + }, + "name": "str", + "object": "str", + "version": "str", + "description": "str" + } + """ + + @overload + def create_version_from_manifest( + self, agent_name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _types_models1.AgentVersionDetails: + """Create a new agent version from a manifest. + + :param agent_name: The unique name that identifies the agent. Name can be used to + retrieve/update/delete the agent. + + * Must start and end with alphanumeric characters, + * Can contain hyphens in the middle + * Must not exceed 63 characters. Required. + :type agent_name: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AgentVersionDetails + :rtype: ~azure.ai.agents.types.AgentVersionDetails + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "manifest_id": "str", + "parameter_values": { + "str": {} + }, + "description": "str", + "metadata": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "hosted": + agent_definition = { + "container_protocol_versions": [ + { + "protocol": "str", + "version": "str" + } + ], + "cpu": "str", + "kind": "hosted", + "memory": "str", + "environment_variables": { + "str": "str" + }, + "image": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "tools": [ + tool + ] + } + + # JSON input template for discriminator value "prompt": + agent_definition = { + "kind": "prompt", + "model": "str", + "instructions": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "structured_inputs": { + "str": { + "default_value": {}, + "description": "str", + "required": bool, + "schema": { + "str": {} + } + } + }, + "temperature": 0.0, + "text": { + "format": text_response_format + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_p": 0.0 + } + + # JSON input template for discriminator value "json_object": + text_response_format = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format = { + "name": "str", + "schema": { + "str": {} + }, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "definition": agent_definition, + "id": "str", + "metadata": { + "str": "str" + }, + "name": "str", + "object": "str", + "version": "str", + "description": "str" + } + """ + + @overload + def create_version_from_manifest( + self, agent_name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _types_models1.AgentVersionDetails: + """Create a new agent version from a manifest. + + :param agent_name: The unique name that identifies the agent. Name can be used to + retrieve/update/delete the agent. + + * Must start and end with alphanumeric characters, + * Can contain hyphens in the middle + * Must not exceed 63 characters. Required. + :type agent_name: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: AgentVersionDetails + :rtype: ~azure.ai.agents.types.AgentVersionDetails + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "hosted": + agent_definition = { + "container_protocol_versions": [ + { + "protocol": "str", + "version": "str" + } + ], + "cpu": "str", + "kind": "hosted", + "memory": "str", + "environment_variables": { + "str": "str" + }, + "image": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "tools": [ + tool + ] + } + + # JSON input template for discriminator value "prompt": + agent_definition = { + "kind": "prompt", + "model": "str", + "instructions": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "structured_inputs": { + "str": { + "default_value": {}, + "description": "str", + "required": bool, + "schema": { + "str": {} + } + } + }, + "temperature": 0.0, + "text": { + "format": text_response_format + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_p": 0.0 + } + + # JSON input template for discriminator value "json_object": + text_response_format = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format = { + "name": "str", + "schema": { + "str": {} + }, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "definition": agent_definition, + "id": "str", + "metadata": { + "str": "str" + }, + "name": "str", + "object": "str", + "version": "str", + "description": "str" + } + """ + + @distributed_trace + def create_version_from_manifest( + self, + agent_name: str, + manifest_id: str = _Unset, + parameter_values: dict[str, Any] = _Unset, + body: Union[JSON, IO[bytes]] = _Unset, + metadata: Optional[dict[str, str]] = None, + description: Optional[str] = None, + **kwargs: Any + ) -> _types_models1.AgentVersionDetails: + """Create a new agent version from a manifest. + + :param agent_name: The unique name that identifies the agent. Name can be used to + retrieve/update/delete the agent. + + * Must start and end with alphanumeric characters, + * Can contain hyphens in the middle + * Must not exceed 63 characters. Required. + :type agent_name: str + :param manifest_id: The manifest ID to import the agent version from. Required. + :type manifest_id: str + :param parameter_values: The inputs to the manifest that will result in a fully materialized + Agent. Required. + :type parameter_values: dict[str, any] + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :param metadata: Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. Default value is None. + :type metadata: dict[str, str] + :param description: A human-readable description of the agent. Default value is None. + :type description: str + :return: AgentVersionDetails + :rtype: ~azure.ai.agents.types.AgentVersionDetails + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "manifest_id": "str", + "parameter_values": { + "str": {} + }, + "description": "str", + "metadata": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "hosted": + agent_definition = { + "container_protocol_versions": [ + { + "protocol": "str", + "version": "str" + } + ], + "cpu": "str", + "kind": "hosted", + "memory": "str", + "environment_variables": { + "str": "str" + }, + "image": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "tools": [ + tool + ] + } + + # JSON input template for discriminator value "prompt": + agent_definition = { + "kind": "prompt", + "model": "str", + "instructions": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "structured_inputs": { + "str": { + "default_value": {}, + "description": "str", + "required": bool, + "schema": { + "str": {} + } + } + }, + "temperature": 0.0, + "text": { + "format": text_response_format + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_p": 0.0 + } + + # JSON input template for discriminator value "json_object": + text_response_format = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format = { + "name": "str", + "schema": { + "str": {} + }, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "definition": agent_definition, + "id": "str", + "metadata": { + "str": "str" + }, + "name": "str", + "object": "str", + "version": "str", + "description": "str" + } + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_types_models1.AgentVersionDetails] = kwargs.pop("cls", None) + + if body is _Unset: + if manifest_id is _Unset: + raise TypeError("missing required argument: manifest_id") + if parameter_values is _Unset: + raise TypeError("missing required argument: parameter_values") + body = { + "description": description, + "manifest_id": manifest_id, + "metadata": metadata, + "parameter_values": parameter_values, + } + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_agents_create_version_from_manifest_request( + agent_name=agent_name, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _types_models1.ApiErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_version(self, agent_name: str, agent_version: str, **kwargs: Any) -> _types_models1.AgentVersionDetails: + """Retrieves a specific version of an agent. + + :param agent_name: The name of the agent to retrieve. Required. + :type agent_name: str + :param agent_version: The version of the agent to retrieve. Required. + :type agent_version: str + :return: AgentVersionDetails + :rtype: ~azure.ai.agents.types.AgentVersionDetails + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "hosted": + agent_definition = { + "container_protocol_versions": [ + { + "protocol": "str", + "version": "str" + } + ], + "cpu": "str", + "kind": "hosted", + "memory": "str", + "environment_variables": { + "str": "str" + }, + "image": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "tools": [ + tool + ] + } + + # JSON input template for discriminator value "prompt": + agent_definition = { + "kind": "prompt", + "model": "str", + "instructions": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "structured_inputs": { + "str": { + "default_value": {}, + "description": "str", + "required": bool, + "schema": { + "str": {} + } + } + }, + "temperature": 0.0, + "text": { + "format": text_response_format + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_p": 0.0 + } + + # JSON input template for discriminator value "json_object": + text_response_format = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format = { + "name": "str", + "schema": { + "str": {} + }, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "definition": agent_definition, + "id": "str", + "metadata": { + "str": "str" + }, + "name": "str", + "object": "str", + "version": "str", + "description": "str" + } + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_types_models1.AgentVersionDetails] = kwargs.pop("cls", None) + + _request = build_agents_get_version_request( + agent_name=agent_name, + agent_version=agent_version, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _types_models1.ApiErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete_version( + self, agent_name: str, agent_version: str, **kwargs: Any + ) -> _types_models1.DeleteAgentVersionResponse: + """Deletes a specific version of an agent. + + :param agent_name: The name of the agent to delete. Required. + :type agent_name: str + :param agent_version: The version of the agent to delete. Required. + :type agent_version: str + :return: DeleteAgentVersionResponse + :rtype: ~azure.ai.agents.types.DeleteAgentVersionResponse + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "deleted": bool, + "name": "str", + "object": "str", + "version": "str" + } + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_types_models1.DeleteAgentVersionResponse] = kwargs.pop("cls", None) + + _request = build_agents_delete_version_request( + agent_name=agent_name, + agent_version=agent_version, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _types_models1.ApiErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_versions( + self, + agent_name: str, + *, + limit: Optional[int] = None, + order: Optional[types.PageOrder] = None, + before: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_types_models1.AgentVersionDetails"]: + """Returns the list of versions of an agent. + + :param agent_name: The name of the agent to retrieve versions for. Required. + :type agent_name: str + :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and + 100, and the + default is 20. Default value is None. + :paramtype limit: int + :keyword order: Sort order by the ``created_at`` timestamp of the objects. ``asc`` for + ascending order and``desc`` + for descending order. Known values are: "asc" and "desc". Default value is None. + :paramtype order: str or ~azure.ai.agents.models.PageOrder + :keyword 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. + Default value is None. + :paramtype before: str + :return: An iterator like instance of AgentVersionDetails + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.types.AgentVersionDetails] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "hosted": + agent_definition = { + "container_protocol_versions": [ + { + "protocol": "str", + "version": "str" + } + ], + "cpu": "str", + "kind": "hosted", + "memory": "str", + "environment_variables": { + "str": "str" + }, + "image": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "tools": [ + tool + ] + } + + # JSON input template for discriminator value "prompt": + agent_definition = { + "kind": "prompt", + "model": "str", + "instructions": "str", + "rai_config": { + "rai_policy_name": "str" + }, + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "structured_inputs": { + "str": { + "default_value": {}, + "description": "str", + "required": bool, + "schema": { + "str": {} + } + } + }, + "temperature": 0.0, + "text": { + "format": text_response_format + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_p": 0.0 + } + + # JSON input template for discriminator value "json_object": + text_response_format = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format = { + "name": "str", + "schema": { + "str": {} + }, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "definition": agent_definition, + "id": "str", + "metadata": { + "str": "str" + }, + "name": "str", + "object": "str", + "version": "str", + "description": "str" + } + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_types_models1.AgentVersionDetails]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(_continuation_token=None): + + _request = build_agents_list_versions_request( + agent_name=agent_name, + limit=limit, + order=order, + after=_continuation_token, + before=before, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized.get("data", []) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("last_id") or None, iter(list_of_elem) + + def get_next(_continuation_token=None): + _request = prepare_request(_continuation_token) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _types_models1.ApiErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class EvaluationRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.agents.AIProjectClient`'s + :attr:`evaluation_rules` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, id: str, **kwargs: Any) -> _types_models1.EvaluationRule: + """Get an evaluation rule. + + :param id: Unique identifier for the evaluation rule. Required. + :type id: str + :return: EvaluationRule + :rtype: ~azure.ai.agents.types.EvaluationRule + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "continuousEvaluation": + evaluation_rule_action = { + "evalId": "str", + "type": "continuousEvaluation", + "maxHourlyRuns": 0 + } + + # JSON input template for discriminator value "humanEvaluationPreview": + evaluation_rule_action = { + "templateId": "str", + "type": "humanEvaluationPreview" + } + + # response body for status code(s): 200 + response == { + "action": evaluation_rule_action, + "enabled": bool, + "eventType": "str", + "id": "str", + "systemData": { + "str": "str" + }, + "description": "str", + "displayName": "str", + "filter": { + "agentName": "str" + } + } + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_types_models1.EvaluationRule] = kwargs.pop("cls", None) + + _request = build_evaluation_rules_get_request( + id=id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete(self, id: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements + """Delete an evaluation rule. + + :param id: Unique identifier for the evaluation rule. Required. + :type id: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_evaluation_rules_delete_request( + id=id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + def create_or_update( + self, + id: str, + evaluation_rule: _types_models1.EvaluationRule, + *, + foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW]] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models1.EvaluationRule: + """Create or update an evaluation rule. + + :param id: Unique identifier for the evaluation rule. Required. + :type id: str + :param evaluation_rule: Evaluation rule resource. Required. + :type evaluation_rule: ~azure.ai.agents.types.EvaluationRule + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Default value is None. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: EvaluationRule + :rtype: ~azure.ai.agents.types.EvaluationRule + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "continuousEvaluation": + evaluation_rule_action = { + "evalId": "str", + "type": "continuousEvaluation", + "maxHourlyRuns": 0 + } + + # JSON input template for discriminator value "humanEvaluationPreview": + evaluation_rule_action = { + "templateId": "str", + "type": "humanEvaluationPreview" + } + + # JSON input template you can fill out and use as your body input. + evaluation_rule = { + "action": evaluation_rule_action, + "enabled": bool, + "eventType": "str", + "id": "str", + "systemData": { + "str": "str" + }, + "description": "str", + "displayName": "str", + "filter": { + "agentName": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "continuousEvaluation": + evaluation_rule_action = { + "evalId": "str", + "type": "continuousEvaluation", + "maxHourlyRuns": 0 + } + + # JSON input template for discriminator value "humanEvaluationPreview": + evaluation_rule_action = { + "templateId": "str", + "type": "humanEvaluationPreview" + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "continuousEvaluation": + evaluation_rule_action = { + "evalId": "str", + "type": "continuousEvaluation", + "maxHourlyRuns": 0 + } + + # JSON input template for discriminator value "humanEvaluationPreview": + evaluation_rule_action = { + "templateId": "str", + "type": "humanEvaluationPreview" + } + + # response body for status code(s): 201, 200 + response == { + "action": evaluation_rule_action, + "enabled": bool, + "eventType": "str", + "id": "str", + "systemData": { + "str": "str" + }, + "description": "str", + "displayName": "str", + "filter": { + "agentName": "str" + } + } + """ + + @overload + def create_or_update( + self, + id: str, + evaluation_rule: IO[bytes], + *, + foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW]] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models1.EvaluationRule: + """Create or update an evaluation rule. + + :param id: Unique identifier for the evaluation rule. Required. + :type id: str + :param evaluation_rule: Evaluation rule resource. Required. + :type evaluation_rule: IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Default value is None. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: EvaluationRule + :rtype: ~azure.ai.agents.types.EvaluationRule + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "continuousEvaluation": + evaluation_rule_action = { + "evalId": "str", + "type": "continuousEvaluation", + "maxHourlyRuns": 0 + } + + # JSON input template for discriminator value "humanEvaluationPreview": + evaluation_rule_action = { + "templateId": "str", + "type": "humanEvaluationPreview" + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "continuousEvaluation": + evaluation_rule_action = { + "evalId": "str", + "type": "continuousEvaluation", + "maxHourlyRuns": 0 + } + + # JSON input template for discriminator value "humanEvaluationPreview": + evaluation_rule_action = { + "templateId": "str", + "type": "humanEvaluationPreview" + } + + # response body for status code(s): 201, 200 + response == { + "action": evaluation_rule_action, + "enabled": bool, + "eventType": "str", + "id": "str", + "systemData": { + "str": "str" + }, + "description": "str", + "displayName": "str", + "filter": { + "agentName": "str" + } + } + """ + + @distributed_trace + def create_or_update( + self, + id: str, + evaluation_rule: Union[_types_models1.EvaluationRule, IO[bytes]], + *, + foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW]] = None, + **kwargs: Any + ) -> _types_models1.EvaluationRule: + """Create or update an evaluation rule. + + :param id: Unique identifier for the evaluation rule. Required. + :type id: str + :param evaluation_rule: Evaluation rule resource. Is either a EvaluationRule type or a + IO[bytes] type. Required. + :type evaluation_rule: ~azure.ai.agents.types.EvaluationRule or IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Default value is None. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + :return: EvaluationRule + :rtype: ~azure.ai.agents.types.EvaluationRule + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "continuousEvaluation": + evaluation_rule_action = { + "evalId": "str", + "type": "continuousEvaluation", + "maxHourlyRuns": 0 + } + + # JSON input template for discriminator value "humanEvaluationPreview": + evaluation_rule_action = { + "templateId": "str", + "type": "humanEvaluationPreview" + } + + # JSON input template you can fill out and use as your body input. + evaluation_rule = { + "action": evaluation_rule_action, + "enabled": bool, + "eventType": "str", + "id": "str", + "systemData": { + "str": "str" + }, + "description": "str", + "displayName": "str", + "filter": { + "agentName": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "continuousEvaluation": + evaluation_rule_action = { + "evalId": "str", + "type": "continuousEvaluation", + "maxHourlyRuns": 0 + } + + # JSON input template for discriminator value "humanEvaluationPreview": + evaluation_rule_action = { + "templateId": "str", + "type": "humanEvaluationPreview" + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "continuousEvaluation": + evaluation_rule_action = { + "evalId": "str", + "type": "continuousEvaluation", + "maxHourlyRuns": 0 + } + + # JSON input template for discriminator value "humanEvaluationPreview": + evaluation_rule_action = { + "templateId": "str", + "type": "humanEvaluationPreview" + } + + # response body for status code(s): 201, 200 + response == { + "action": evaluation_rule_action, + "enabled": bool, + "eventType": "str", + "id": "str", + "systemData": { + "str": "str" + }, + "description": "str", + "displayName": "str", + "filter": { + "agentName": "str" + } + } + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_types_models1.EvaluationRule] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(evaluation_rule, (IOBase, bytes)): + _content = evaluation_rule + else: + _json = evaluation_rule + + _request = build_evaluation_rules_create_or_update_request( + id=id, + foundry_features=foundry_features, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, + *, + action_type: Optional[types.EvaluationRuleActionType] = None, + agent_name: Optional[str] = None, + enabled: Optional[bool] = None, + **kwargs: Any + ) -> ItemPaged["_types_models1.EvaluationRule"]: + """List all evaluation rules. + + :keyword action_type: Filter by the type of evaluation rule. Known values are: + "continuousEvaluation" and "humanEvaluationPreview". Default value is None. + :paramtype action_type: str or ~azure.ai.agents.models.EvaluationRuleActionType + :keyword agent_name: Filter by the agent name. Default value is None. + :paramtype agent_name: str + :keyword enabled: Filter by the enabled status. Default value is None. + :paramtype enabled: bool + :return: An iterator like instance of EvaluationRule + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.types.EvaluationRule] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "continuousEvaluation": + evaluation_rule_action = { + "evalId": "str", + "type": "continuousEvaluation", + "maxHourlyRuns": 0 + } + + # JSON input template for discriminator value "humanEvaluationPreview": + evaluation_rule_action = { + "templateId": "str", + "type": "humanEvaluationPreview" + } + + # response body for status code(s): 200 + response == { + "action": evaluation_rule_action, + "enabled": bool, + "eventType": "str", + "id": "str", + "systemData": { + "str": "str" + }, + "description": "str", + "displayName": "str", + "filter": { + "agentName": "str" + } + } + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_types_models1.EvaluationRule]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_evaluation_rules_list_request( + action_type=action_type, + agent_name=agent_name, + enabled=enabled, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized.get("value", []) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.agents.AIProjectClient`'s + :attr:`connections` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def _get(self, name: str, **kwargs: Any) -> _types_models1.Connection: + """Get a connection by name, without populating connection credentials. + + :param name: The friendly name of the connection, provided by the user. Required. + :type name: str + :return: Connection + :rtype: ~azure.ai.agents.types.Connection + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AAD": + base_credentials = { + "type": "AAD" + } + + # JSON input template for discriminator value "AgenticIdentityToken_Preview": + base_credentials = { + "type": "AgenticIdentityToken_Preview" + } + + # JSON input template for discriminator value "ApiKey": + base_credentials = { + "type": "ApiKey", + "key": "str" + } + + # JSON input template for discriminator value "CustomKeys": + base_credentials = { + "type": "CustomKeys" + } + + # JSON input template for discriminator value "None": + base_credentials = { + "type": "None" + } + + # response body for status code(s): 200 + response == { + "credentials": base_credentials, + "id": "str", + "isDefault": bool, + "metadata": { + "str": "str" + }, + "name": "str", + "target": "str", + "type": "str" + } + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_types_models1.Connection] = kwargs.pop("cls", None) + + _request = build_connections_get_request( + name=name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["x-ms-client-request-id"] = self._deserialize( + "str", response.headers.get("x-ms-client-request-id") + ) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def _get_with_credentials(self, name: str, **kwargs: Any) -> _types_models1.Connection: + """Get a connection by name, with its connection credentials. + + :param name: The friendly name of the connection, provided by the user. Required. + :type name: str + :return: Connection + :rtype: ~azure.ai.agents.types.Connection + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AAD": + base_credentials = { + "type": "AAD" + } + + # JSON input template for discriminator value "AgenticIdentityToken_Preview": + base_credentials = { + "type": "AgenticIdentityToken_Preview" + } + + # JSON input template for discriminator value "ApiKey": + base_credentials = { + "type": "ApiKey", + "key": "str" + } + + # JSON input template for discriminator value "CustomKeys": + base_credentials = { + "type": "CustomKeys" + } + + # JSON input template for discriminator value "None": + base_credentials = { + "type": "None" + } + + # response body for status code(s): 200 + response == { + "credentials": base_credentials, + "id": "str", + "isDefault": bool, + "metadata": { + "str": "str" + }, + "name": "str", + "target": "str", + "type": "str" + } + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_types_models1.Connection] = kwargs.pop("cls", None) + + _request = build_connections_get_with_credentials_request( + name=name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["x-ms-client-request-id"] = self._deserialize( + "str", response.headers.get("x-ms-client-request-id") + ) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, + *, + connection_type: Optional[types.ConnectionType] = None, + default_connection: Optional[bool] = None, + **kwargs: Any + ) -> ItemPaged["_types_models1.Connection"]: + """List all connections in the project, without populating connection credentials. + + :keyword connection_type: List connections of this specific type. Known values are: + "AzureOpenAI", "AzureBlob", "AzureStorageAccount", "CognitiveSearch", "CosmosDB", "ApiKey", + "AppConfig", "AppInsights", "CustomKeys", and "RemoteTool_Preview". Default value is None. + :paramtype connection_type: str or ~azure.ai.agents.models.ConnectionType + :keyword default_connection: List connections that are default connections. Default value is + None. + :paramtype default_connection: bool + :return: An iterator like instance of Connection + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.types.Connection] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AAD": + base_credentials = { + "type": "AAD" + } + + # JSON input template for discriminator value "AgenticIdentityToken_Preview": + base_credentials = { + "type": "AgenticIdentityToken_Preview" + } + + # JSON input template for discriminator value "ApiKey": + base_credentials = { + "type": "ApiKey", + "key": "str" + } + + # JSON input template for discriminator value "CustomKeys": + base_credentials = { + "type": "CustomKeys" + } + + # JSON input template for discriminator value "None": + base_credentials = { + "type": "None" + } + + # response body for status code(s): 200 + response == { + "credentials": base_credentials, + "id": "str", + "isDefault": bool, + "metadata": { + "str": "str" + }, + "name": "str", + "target": "str", + "type": "str" + } + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_types_models1.Connection]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_connections_list_request( + connection_type=connection_type, + default_connection=default_connection, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized.get("value", []) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class DatasetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.agents.AIProjectClient`'s + :attr:`datasets` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_versions(self, name: str, **kwargs: Any) -> ItemPaged["_types_models1.DatasetVersion"]: + """List all versions of the given DatasetVersion. + + :param name: The name of the resource. Required. + :type name: str + :return: An iterator like instance of DatasetVersion + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.types.DatasetVersion] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "uri_file": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_file", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "uri_folder": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_folder", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # response body for status code(s): 200 + response == dataset_version + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_types_models1.DatasetVersion]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_datasets_list_versions_request( + name=name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized.get("value", []) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list(self, **kwargs: Any) -> ItemPaged["_types_models1.DatasetVersion"]: + """List the latest version of each DatasetVersion. + + :return: An iterator like instance of DatasetVersion + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.types.DatasetVersion] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "uri_file": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_file", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "uri_folder": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_folder", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # response body for status code(s): 200 + response == dataset_version + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_types_models1.DatasetVersion]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - Instead, you should access the following operations through - :class:`~azure.ai.agents.AgentsClient`'s - :attr:`threads` attribute. - """ + def prepare_request(next_link=None): + if not next_link: + + _request = build_datasets_list_request( + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AgentsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + return _request - @overload - def create( - self, - *, - content_type: str = "application/json", - messages: Optional[List[_models.ThreadMessageOptions]] = None, - tool_resources: Optional[_models.ToolResources] = None, - metadata: Optional[dict[str, str]] = None, - **kwargs: Any - ) -> _models.AgentThread: - """Creates a new thread. Threads contain messages and can be run by agents. + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized.get("value", []) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword messages: The initial messages to associate with the new thread. Default value is - None. - :paramtype messages: list[~azure.ai.agents.models.ThreadMessageOptions] - :keyword tool_resources: 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. Default value is None. - :paramtype tool_resources: ~azure.ai.agents.models.ToolResources - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: AgentThread. The AgentThread is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.AgentThread - :raises ~azure.core.exceptions.HttpResponseError: - """ + def get_next(next_link=None): + _request = prepare_request(next_link) - @overload - def create(self, body: JSON, *, content_type: str = "application/json", **kwargs: Any) -> _models.AgentThread: - """Creates a new thread. Threads contain messages and can be run by agents. + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AgentThread. The AgentThread is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.AgentThread - :raises ~azure.core.exceptions.HttpResponseError: - """ + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) - @overload - def create(self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any) -> _models.AgentThread: - """Creates a new thread. Threads contain messages and can be run by agents. + return pipeline_response - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: AgentThread. The AgentThread is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.AgentThread - :raises ~azure.core.exceptions.HttpResponseError: - """ + return ItemPaged(get_next, extract_data) @distributed_trace - def create( - self, - body: Union[JSON, IO[bytes]] = _Unset, - *, - messages: Optional[List[_models.ThreadMessageOptions]] = None, - tool_resources: Optional[_models.ToolResources] = None, - metadata: Optional[dict[str, str]] = None, - **kwargs: Any - ) -> _models.AgentThread: - """Creates a new thread. Threads contain messages and can be run by agents. - - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword messages: The initial messages to associate with the new thread. Default value is - None. - :paramtype messages: list[~azure.ai.agents.models.ThreadMessageOptions] - :keyword tool_resources: 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. Default value is None. - :paramtype tool_resources: ~azure.ai.agents.models.ToolResources - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: AgentThread. The AgentThread is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.AgentThread + def get(self, name: str, version: str, **kwargs: Any) -> _types_models1.DatasetVersion: + """Get the specific version of the DatasetVersion. The service returns 404 Not Found error if the + DatasetVersion does not exist. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to retrieve. Required. + :type version: str + :return: DatasetVersion + :rtype: ~azure.ai.agents.types.DatasetVersion :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "uri_file": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_file", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "uri_folder": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_folder", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # response body for status code(s): 200 + response == dataset_version """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1352,26 +6811,15 @@ def create( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AgentThread] = kwargs.pop("cls", None) - - if body is _Unset: - body = {"messages": messages, "metadata": metadata, "tool_resources": tool_resources} - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + cls: ClsType[_types_models1.DatasetVersion] = kwargs.pop("cls", None) - _request = build_threads_create_request( - content_type=content_type, + _request = build_datasets_get_request( + name=name, + version=version, api_version=self._config.api_version, - content=_content, headers=_headers, params=_params, ) @@ -1380,6 +6828,7 @@ def create( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1394,13 +6843,15 @@ def create( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.AgentThread, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1408,36 +6859,18 @@ def create( return deserialized # type: ignore @distributed_trace - def list( - self, - *, - limit: Optional[int] = None, - order: Optional[Union[str, _models.ListSortOrder]] = None, - before: Optional[str] = None, - **kwargs: Any - ) -> ItemPaged["_models.AgentThread"]: - """Gets a list of threads that were previously created. - - :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and - 100, and the default is 20. Default value is None. - :paramtype limit: int - :keyword order: Sort order by the created_at timestamp of the objects. asc for ascending order - and desc for descending order. Known values are: "asc" and "desc". Default value is None. - :paramtype order: str or ~azure.ai.agents.models.ListSortOrder - :keyword 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. Default value is None. - :paramtype before: str - :return: An iterator like instance of AgentThread - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.models.AgentThread] + def delete(self, name: str, version: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements + """Delete the specific version of the DatasetVersion. The service returns 204 No Content if the + DatasetVersion was deleted successfully or if the DatasetVersion does not exist. + + :param name: The name of the resource. Required. + :type name: str + :param version: The version of the DatasetVersion to delete. Required. + :type version: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.AgentThread]] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1446,57 +6879,393 @@ def list( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(_continuation_token=None): + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - _request = build_threads_list_request( - limit=limit, - order=order, - after=_continuation_token, - before=before, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - return _request + cls: ClsType[None] = kwargs.pop("cls", None) - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.AgentThread], deserialized.get("data", [])) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("last_id") or None, iter(list_of_elem) + _request = build_datasets_delete_request( + name=name, + version=version, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - def get_next(_continuation_token=None): - _request = prepare_request(_continuation_token) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + response = pipeline_response.http_response - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) - return pipeline_response + if cls: + return cls(pipeline_response, None, {}) # type: ignore - return ItemPaged(get_next, extract_data) + @overload + def create_or_update( + self, + name: str, + version: str, + dataset_version: _types_models1.DatasetVersion, + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> _types_models1.DatasetVersion: + """Create a new or update an existing DatasetVersion with the given version id. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to create or update. Required. + :type version: str + :param dataset_version: The DatasetVersion to create or update. Required. + :type dataset_version: ~azure.ai.agents.types.DatasetVersion + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: DatasetVersion + :rtype: ~azure.ai.agents.types.DatasetVersion + :raises ~azure.core.exceptions.HttpResponseError: - @distributed_trace - def get(self, thread_id: str, **kwargs: Any) -> _models.AgentThread: - """Gets information about an existing thread. + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "uri_file": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_file", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "uri_folder": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_folder", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # JSON input template you can fill out and use as your body input. + dataset_version = dataset_version + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "uri_file": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_file", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "uri_folder": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_folder", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "uri_file": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_file", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "uri_folder": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_folder", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # response body for status code(s): 201, 200 + response == dataset_version + """ + + @overload + def create_or_update( + self, + name: str, + version: str, + dataset_version: IO[bytes], + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> _types_models1.DatasetVersion: + """Create a new or update an existing DatasetVersion with the given version id. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to create or update. Required. + :type version: str + :param dataset_version: The DatasetVersion to create or update. Required. + :type dataset_version: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: DatasetVersion + :rtype: ~azure.ai.agents.types.DatasetVersion + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "uri_file": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_file", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "uri_folder": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_folder", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "uri_file": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_file", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "uri_folder": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_folder", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # response body for status code(s): 201, 200 + response == dataset_version + """ - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :return: AgentThread. The AgentThread is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.AgentThread + @distributed_trace + def create_or_update( + self, name: str, version: str, dataset_version: Union[_types_models1.DatasetVersion, IO[bytes]], **kwargs: Any + ) -> _types_models1.DatasetVersion: + """Create a new or update an existing DatasetVersion with the given version id. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to create or update. Required. + :type version: str + :param dataset_version: The DatasetVersion to create or update. Is either a DatasetVersion type + or a IO[bytes] type. Required. + :type dataset_version: ~azure.ai.agents.types.DatasetVersion or IO[bytes] + :return: DatasetVersion + :rtype: ~azure.ai.agents.types.DatasetVersion :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "uri_file": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_file", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "uri_folder": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_folder", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # JSON input template you can fill out and use as your body input. + dataset_version = dataset_version + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "uri_file": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_file", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "uri_folder": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_folder", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "uri_file": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_file", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "uri_folder": + dataset_version = { + "dataUri": "str", + "name": "str", + "type": "uri_folder", + "version": "str", + "connectionName": "str", + "description": "str", + "id": "str", + "isReference": bool, + "tags": { + "str": "str" + } + } + + # response body for status code(s): 201, 200 + response == dataset_version """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1506,14 +7275,27 @@ def get(self, thread_id: str, **kwargs: Any) -> _models.AgentThread: } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.AgentThread] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_types_models1.DatasetVersion] = kwargs.pop("cls", None) + + content_type = content_type or "application/merge-patch+json" + _json = None + _content = None + if isinstance(dataset_version, (IOBase, bytes)): + _content = dataset_version + else: + _json = dataset_version - _request = build_threads_get_request( - thread_id=thread_id, + _request = build_datasets_create_or_update_request( + name=name, + version=version, + content_type=content_type, api_version=self._config.api_version, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -1522,6 +7304,7 @@ def get(self, thread_id: str, **kwargs: Any) -> _models.AgentThread: } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1529,20 +7312,22 @@ def get(self, thread_id: str, **kwargs: Any) -> _models.AgentThread: response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 201]: if _stream: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.AgentThread, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1550,104 +7335,145 @@ def get(self, thread_id: str, **kwargs: Any) -> _models.AgentThread: return deserialized # type: ignore @overload - def update( + def pending_upload( self, - thread_id: str, + name: str, + version: str, + pending_upload_request: _types_models1.PendingUploadRequest, *, content_type: str = "application/json", - tool_resources: Optional[_models.ToolResources] = None, - metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> _models.AgentThread: - """Modifies an existing thread. - - :param thread_id: The ID of the thread to modify. Required. - :type thread_id: str + ) -> _types_models1.PendingUploadResponse: + """Start a new or get an existing pending upload of a dataset for a specific version. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to operate on. Required. + :type version: str + :param pending_upload_request: The pending upload request parameters. Required. + :type pending_upload_request: ~azure.ai.agents.types.PendingUploadRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword tool_resources: 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. Default value is None. - :paramtype tool_resources: ~azure.ai.agents.models.ToolResources - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: AgentThread. The AgentThread is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.AgentThread + :return: PendingUploadResponse + :rtype: ~azure.ai.agents.types.PendingUploadResponse :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, thread_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AgentThread: - """Modifies an existing thread. - :param thread_id: The ID of the thread to modify. Required. - :type thread_id: str - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AgentThread. The AgentThread is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.AgentThread - :raises ~azure.core.exceptions.HttpResponseError: + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + pending_upload_request = { + "pendingUploadType": "str", + "connectionName": "str", + "pendingUploadId": "str" + } + + # response body for status code(s): 200 + response == { + "blobReference": { + "blobUri": "str", + "credential": { + "sasUri": "str", + "type": "SAS" + }, + "storageAccountArmId": "str" + }, + "pendingUploadId": "str", + "pendingUploadType": "str", + "version": "str" + } """ @overload - def update( - self, thread_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AgentThread: - """Modifies an existing thread. - - :param thread_id: The ID of the thread to modify. Required. - :type thread_id: str - :param body: Required. - :type body: IO[bytes] + def pending_upload( + self, + name: str, + version: str, + pending_upload_request: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models1.PendingUploadResponse: + """Start a new or get an existing pending upload of a dataset for a specific version. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to operate on. Required. + :type version: str + :param pending_upload_request: The pending upload request parameters. Required. + :type pending_upload_request: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: AgentThread. The AgentThread is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.AgentThread + :return: PendingUploadResponse + :rtype: ~azure.ai.agents.types.PendingUploadResponse :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "blobReference": { + "blobUri": "str", + "credential": { + "sasUri": "str", + "type": "SAS" + }, + "storageAccountArmId": "str" + }, + "pendingUploadId": "str", + "pendingUploadType": "str", + "version": "str" + } """ @distributed_trace - def update( + def pending_upload( self, - thread_id: str, - body: Union[JSON, IO[bytes]] = _Unset, - *, - tool_resources: Optional[_models.ToolResources] = None, - metadata: Optional[dict[str, str]] = None, + name: str, + version: str, + pending_upload_request: Union[_types_models1.PendingUploadRequest, IO[bytes]], **kwargs: Any - ) -> _models.AgentThread: - """Modifies an existing thread. - - :param thread_id: The ID of the thread to modify. Required. - :type thread_id: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword tool_resources: 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. Default value is None. - :paramtype tool_resources: ~azure.ai.agents.models.ToolResources - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: AgentThread. The AgentThread is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.AgentThread + ) -> _types_models1.PendingUploadResponse: + """Start a new or get an existing pending upload of a dataset for a specific version. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to operate on. Required. + :type version: str + :param pending_upload_request: The pending upload request parameters. Is either a + PendingUploadRequest type or a IO[bytes] type. Required. + :type pending_upload_request: ~azure.ai.agents.types.PendingUploadRequest or IO[bytes] + :return: PendingUploadResponse + :rtype: ~azure.ai.agents.types.PendingUploadResponse :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + pending_upload_request = { + "pendingUploadType": "str", + "connectionName": "str", + "pendingUploadId": "str" + } + + # response body for status code(s): 200 + response == { + "blobReference": { + "blobUri": "str", + "credential": { + "sasUri": "str", + "type": "SAS" + }, + "storageAccountArmId": "str" + }, + "pendingUploadId": "str", + "pendingUploadType": "str", + "version": "str" + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1661,22 +7487,22 @@ def update( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AgentThread] = kwargs.pop("cls", None) + cls: ClsType[_types_models1.PendingUploadResponse] = kwargs.pop("cls", None) - if body is _Unset: - body = {"metadata": metadata, "tool_resources": tool_resources} - body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" + _json = None _content = None - if isinstance(body, (IOBase, bytes)): - _content = body + if isinstance(pending_upload_request, (IOBase, bytes)): + _content = pending_upload_request else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _json = pending_upload_request - _request = build_threads_update_request( - thread_id=thread_id, + _request = build_datasets_pending_upload_request( + name=name, + version=version, content_type=content_type, api_version=self._config.api_version, + json=_json, content=_content, headers=_headers, params=_params, @@ -1686,6 +7512,7 @@ def update( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1700,13 +7527,15 @@ def update( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.AgentThread, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1714,14 +7543,31 @@ def update( return deserialized # type: ignore @distributed_trace - def _delete_thread(self, thread_id: str, **kwargs: Any) -> _models._models.ThreadDeletionStatus: - """Deletes an existing thread. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :return: ThreadDeletionStatus. The ThreadDeletionStatus is compatible with MutableMapping - :rtype: ~azure.ai.agents.models._models.ThreadDeletionStatus + def get_credentials(self, name: str, version: str, **kwargs: Any) -> _types_models1.DatasetCredential: + """Get the SAS credential to access the storage account associated with a Dataset version. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to operate on. Required. + :type version: str + :return: DatasetCredential + :rtype: ~azure.ai.agents.types.DatasetCredential :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "blobReference": { + "blobUri": "str", + "credential": { + "sasUri": "str", + "type": "SAS" + }, + "storageAccountArmId": "str" + } + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1734,10 +7580,11 @@ def _delete_thread(self, thread_id: str, **kwargs: Any) -> _models._models.Threa _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models._models.ThreadDeletionStatus] = kwargs.pop("cls", None) + cls: ClsType[_types_models1.DatasetCredential] = kwargs.pop("cls", None) - _request = build_threads_delete_thread_request( - thread_id=thread_id, + _request = build_datasets_get_credentials_request( + name=name, + version=version, api_version=self._config.api_version, headers=_headers, params=_params, @@ -1747,6 +7594,7 @@ def _delete_thread(self, thread_id: str, **kwargs: Any) -> _models._models.Threa } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1761,15 +7609,15 @@ def _delete_thread(self, thread_id: str, **kwargs: Any) -> _models._models.Threa except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize( - _models._models.ThreadDeletionStatus, response.json() # pylint: disable=protected-access - ) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1777,142 +7625,61 @@ def _delete_thread(self, thread_id: str, **kwargs: Any) -> _models._models.Threa return deserialized # type: ignore -class MessagesOperations: +class DeploymentsOperations: """ .. warning:: **DO NOT** instantiate this class directly. - Instead, you should access the following operations through - :class:`~azure.ai.agents.AgentsClient`'s - :attr:`messages` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AgentsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - def create( - self, - thread_id: str, - *, - role: Union[str, _models.MessageRole], - content: "_types.MessageInputContent", - content_type: str = "application/json", - attachments: Optional[List[_models.MessageAttachment]] = None, - metadata: Optional[dict[str, str]] = None, - **kwargs: Any - ) -> _models.ThreadMessage: - """Creates a new message on a specified thread. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :keyword 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). Known values are: "user" and "assistant". - Required. - :paramtype role: str or ~azure.ai.agents.models.MessageRole - :keyword 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). Is either a str type or a [MessageInputContentBlock] type. Required. - :paramtype content: str or list[~azure.ai.agents.models.MessageInputContentBlock] - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword attachments: A list of files attached to the message, and the tools they should be - added to. Default value is None. - :paramtype attachments: list[~azure.ai.agents.models.MessageAttachment] - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: ThreadMessage. The ThreadMessage is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadMessage - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, thread_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ThreadMessage: - """Creates a new message on a specified thread. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ThreadMessage. The ThreadMessage is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadMessage - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, thread_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ThreadMessage: - """Creates a new message on a specified thread. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: ThreadMessage. The ThreadMessage is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadMessage - :raises ~azure.core.exceptions.HttpResponseError: - """ + Instead, you should access the following operations through + :class:`~azure.ai.agents.AIProjectClient`'s + :attr:`deployments` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def create( - self, - thread_id: str, - body: Union[JSON, IO[bytes]] = _Unset, - *, - role: Union[str, _models.MessageRole] = _Unset, - content: "_types.MessageInputContent" = _Unset, - attachments: Optional[List[_models.MessageAttachment]] = None, - metadata: Optional[dict[str, str]] = None, - **kwargs: Any - ) -> _models.ThreadMessage: - """Creates a new message on a specified thread. + def get(self, name: str, **kwargs: Any) -> _types_models1.Deployment: + """Get a deployed model. - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword 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). Known values are: "user" and "assistant". - Required. - :paramtype role: str or ~azure.ai.agents.models.MessageRole - :keyword 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). Is either a str type or a [MessageInputContentBlock] type. Required. - :paramtype content: str or list[~azure.ai.agents.models.MessageInputContentBlock] - :keyword attachments: A list of files attached to the message, and the tools they should be - added to. Default value is None. - :paramtype attachments: list[~azure.ai.agents.models.MessageAttachment] - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: ThreadMessage. The ThreadMessage is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadMessage + :param name: Name of the deployment. Required. + :type name: str + :return: Deployment + :rtype: ~azure.ai.agents.types.Deployment :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "ModelDeployment": + deployment = { + "capabilities": { + "str": "str" + }, + "modelName": "str", + "modelPublisher": "str", + "modelVersion": "str", + "name": "str", + "sku": { + "capacity": 0, + "family": "str", + "name": "str", + "size": "str", + "tier": "str" + }, + "type": "ModelDeployment", + "connectionName": "str" + } + + # response body for status code(s): 200 + response == deployment """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1922,31 +7689,14 @@ def create( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ThreadMessage] = kwargs.pop("cls", None) - - if body is _Unset: - if role is _Unset: - raise TypeError("missing required argument: role") - if content is _Unset: - raise TypeError("missing required argument: content") - body = {"attachments": attachments, "content": content, "metadata": metadata, "role": role} - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + cls: ClsType[_types_models1.Deployment] = kwargs.pop("cls", None) - _request = build_messages_create_request( - thread_id=thread_id, - content_type=content_type, + _request = build_deployments_get_request( + name=name, api_version=self._config.api_version, - content=_content, headers=_headers, params=_params, ) @@ -1955,6 +7705,7 @@ def create( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1969,55 +7720,82 @@ def create( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["x-ms-client-request-id"] = self._deserialize( + "str", response.headers.get("x-ms-client-request-id") + ) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.ThreadMessage, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace def list( self, - thread_id: str, *, - run_id: Optional[str] = None, - limit: Optional[int] = None, - order: Optional[Union[str, _models.ListSortOrder]] = None, - before: Optional[str] = None, + model_publisher: Optional[str] = None, + model_name: Optional[str] = None, + deployment_type: Optional[types.DeploymentType] = None, **kwargs: Any - ) -> ItemPaged["_models.ThreadMessage"]: - """Gets a list of messages that exist on a thread. + ) -> ItemPaged["_types_models1.Deployment"]: + """List all deployed models in the project. - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :keyword run_id: Filter messages by the run ID that generated them. Default value is None. - :paramtype run_id: str - :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and - 100, and the default is 20. Default value is None. - :paramtype limit: int - :keyword order: Sort order by the created_at timestamp of the objects. asc for ascending order - and desc for descending order. Known values are: "asc" and "desc". Default value is None. - :paramtype order: str or ~azure.ai.agents.models.ListSortOrder - :keyword 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. Default value is None. - :paramtype before: str - :return: An iterator like instance of ThreadMessage - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.models.ThreadMessage] + :keyword model_publisher: Model publisher to filter models by. Default value is None. + :paramtype model_publisher: str + :keyword model_name: Model name (the publisher specific name) to filter models by. Default + value is None. + :paramtype model_name: str + :keyword deployment_type: Type of deployment to filter list by. "ModelDeployment" Default value + is None. + :paramtype deployment_type: str or ~azure.ai.agents.models.DeploymentType + :return: An iterator like instance of Deployment + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.types.Deployment] :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "ModelDeployment": + deployment = { + "capabilities": { + "str": "str" + }, + "modelName": "str", + "modelPublisher": "str", + "modelVersion": "str", + "name": "str", + "sku": { + "capacity": 0, + "family": "str", + "name": "str", + "size": "str", + "tier": "str" + }, + "type": "ModelDeployment", + "connectionName": "str" + } + + # response body for status code(s): 200 + response == deployment """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.ThreadMessage]] = kwargs.pop("cls", None) + cls: ClsType[List[_types_models1.Deployment]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2027,34 +7805,58 @@ def list( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(_continuation_token=None): + def prepare_request(next_link=None): + if not next_link: + + _request = build_deployments_list_request( + model_publisher=model_publisher, + model_name=model_name, + deployment_type=deployment_type, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - _request = build_messages_list_request( - thread_id=thread_id, - run_id=run_id, - limit=limit, - order=order, - after=_continuation_token, - before=before, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) return _request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.ThreadMessage], deserialized.get("data", [])) + list_of_elem = deserialized.get("value", []) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("last_id") or None, iter(list_of_elem) + return deserialized.get("nextLink") or None, iter(list_of_elem) - def get_next(_continuation_token=None): - _request = prepare_request(_continuation_token) + def get_next(next_link=None): + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access @@ -2070,18 +7872,122 @@ def get_next(_continuation_token=None): return ItemPaged(get_next, extract_data) + +class IndexesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.agents.AIProjectClient`'s + :attr:`indexes` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace - def get(self, thread_id: str, message_id: str, **kwargs: Any) -> _models.ThreadMessage: - """Retrieves an existing message. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param message_id: Identifier of the message. Required. - :type message_id: str - :return: ThreadMessage. The ThreadMessage is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadMessage + def list_versions(self, name: str, **kwargs: Any) -> ItemPaged["_types_models1.Index"]: + """List all versions of the given Index. + + :param name: The name of the resource. Required. + :type name: str + :return: An iterator like instance of Index + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.types.Index] :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AzureSearch": + index = { + "connectionName": "str", + "indexName": "str", + "name": "str", + "type": "AzureSearch", + "version": "str", + "description": "str", + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": + index = { + "connectionName": "str", + "containerName": "str", + "databaseName": "str", + "embeddingConfiguration": { + "embeddingField": "str", + "modelDeploymentName": "str" + }, + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "name": "str", + "type": "CosmosDBNoSqlVectorStore", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "ManagedAzureSearch": + index = { + "name": "str", + "type": "ManagedAzureSearch", + "vectorStoreId": "str", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # response body for status code(s): 200 + response == index """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_types_models1.Index]] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2090,145 +7996,334 @@ def get(self, thread_id: str, message_id: str, **kwargs: Any) -> _models.ThreadM } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.ThreadMessage] = kwargs.pop("cls", None) + def prepare_request(next_link=None): + if not next_link: + + _request = build_indexes_list_versions_request( + name=name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - _request = build_messages_get_request( - thread_id=thread_id, - message_id=message_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized.get("value", []) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) - response = pipeline_response.http_response + def get_next(next_link=None): + _request = prepare_request(next_link) - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.ThreadMessage, response.json()) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return pipeline_response - return deserialized # type: ignore + return ItemPaged(get_next, extract_data) - @overload - def update( - self, - thread_id: str, - message_id: str, - *, - content_type: str = "application/json", - metadata: Optional[dict[str, str]] = None, - **kwargs: Any - ) -> _models.ThreadMessage: - """Modifies an existing message on an existing thread. + @distributed_trace + def list(self, **kwargs: Any) -> ItemPaged["_types_models1.Index"]: + """List the latest version of each Index. - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param message_id: Identifier of the message. Required. - :type message_id: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: ThreadMessage. The ThreadMessage is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadMessage + :return: An iterator like instance of Index + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.types.Index] :raises ~azure.core.exceptions.HttpResponseError: - """ - @overload - def update( - self, thread_id: str, message_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ThreadMessage: - """Modifies an existing message on an existing thread. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param message_id: Identifier of the message. Required. - :type message_id: str - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ThreadMessage. The ThreadMessage is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadMessage - :raises ~azure.core.exceptions.HttpResponseError: + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AzureSearch": + index = { + "connectionName": "str", + "indexName": "str", + "name": "str", + "type": "AzureSearch", + "version": "str", + "description": "str", + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": + index = { + "connectionName": "str", + "containerName": "str", + "databaseName": "str", + "embeddingConfiguration": { + "embeddingField": "str", + "modelDeploymentName": "str" + }, + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "name": "str", + "type": "CosmosDBNoSqlVectorStore", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "ManagedAzureSearch": + index = { + "name": "str", + "type": "ManagedAzureSearch", + "vectorStoreId": "str", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # response body for status code(s): 200 + response == index """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - @overload - def update( - self, thread_id: str, message_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ThreadMessage: - """Modifies an existing message on an existing thread. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param message_id: Identifier of the message. Required. - :type message_id: str - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: ThreadMessage. The ThreadMessage is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadMessage - :raises ~azure.core.exceptions.HttpResponseError: - """ + cls: ClsType[List[_types_models1.Index]] = kwargs.pop("cls", None) - @distributed_trace - def update( - self, - thread_id: str, - message_id: str, - body: Union[JSON, IO[bytes]] = _Unset, - *, - metadata: Optional[dict[str, str]] = None, - **kwargs: Any - ) -> _models.ThreadMessage: - """Modifies an existing message on an existing thread. + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param message_id: Identifier of the message. Required. - :type message_id: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: ThreadMessage. The ThreadMessage is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadMessage + def prepare_request(next_link=None): + if not next_link: + + _request = build_indexes_list_request( + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized.get("value", []) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get(self, name: str, version: str, **kwargs: Any) -> _types_models1.Index: + """Get the specific version of the Index. The service returns 404 Not Found error if the Index + does not exist. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the Index to retrieve. Required. + :type version: str + :return: Index + :rtype: ~azure.ai.agents.types.Index :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AzureSearch": + index = { + "connectionName": "str", + "indexName": "str", + "name": "str", + "type": "AzureSearch", + "version": "str", + "description": "str", + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": + index = { + "connectionName": "str", + "containerName": "str", + "databaseName": "str", + "embeddingConfiguration": { + "embeddingField": "str", + "modelDeploymentName": "str" + }, + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "name": "str", + "type": "CosmosDBNoSqlVectorStore", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "ManagedAzureSearch": + index = { + "name": "str", + "type": "ManagedAzureSearch", + "vectorStoreId": "str", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # response body for status code(s): 200 + response == index """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2238,28 +8333,15 @@ def update( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ThreadMessage] = kwargs.pop("cls", None) - - if body is _Unset: - body = {"metadata": metadata} - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + cls: ClsType[_types_models1.Index] = kwargs.pop("cls", None) - _request = build_messages_update_request( - thread_id=thread_id, - message_id=message_id, - content_type=content_type, + _request = build_indexes_get_request( + name=name, + version=version, api_version=self._config.api_version, - content=_content, headers=_headers, params=_params, ) @@ -2268,6 +8350,7 @@ def update( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -2282,13 +8365,15 @@ def update( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.ThreadMessage, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -2296,20 +8381,16 @@ def update( return deserialized # type: ignore @distributed_trace - @api_version_validation( - method_added_on="v1", - params_added_on={"v1": ["api_version", "thread_id", "message_id", "accept"]}, - api_versions_list=["v1", "2025-05-15-preview"], - ) - def _delete(self, thread_id: str, message_id: str, **kwargs: Any) -> _models._models.MessageDeletionStatus: - """Deletes an existing message on an existing thread. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param message_id: Identifier of the message. Required. - :type message_id: str - :return: MessageDeletionStatus. The MessageDeletionStatus is compatible with MutableMapping - :rtype: ~azure.ai.agents.models._models.MessageDeletionStatus + def delete(self, name: str, version: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements + """Delete the specific version of the Index. The service returns 204 No Content if the Index was + deleted successfully or if the Index does not exist. + + :param name: The name of the resource. Required. + :type name: str + :param version: The version of the Index to delete. Required. + :type version: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2323,11 +8404,11 @@ def _delete(self, thread_id: str, message_id: str, **kwargs: Any) -> _models._mo _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models._models.MessageDeletionStatus] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_messages_delete_request( - thread_id=thread_id, - message_id=message_id, + _request = build_indexes_delete_request( + name=name, + version=version, api_version=self._config.api_version, headers=_headers, params=_params, @@ -2337,342 +8418,728 @@ def _delete(self, thread_id: str, message_id: str, **kwargs: Any) -> _models._mo } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) - - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize( - _models._models.MessageDeletionStatus, response.json() # pylint: disable=protected-access - ) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class RunsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.agents.AgentsClient`'s - :attr:`runs` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AgentsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + response = pipeline_response.http_response - @overload - def create( - self, - thread_id: str, - *, - agent_id: str, - include: Optional[List[Union[str, _models.RunAdditionalFieldList]]] = None, - content_type: str = "application/json", - model: Optional[str] = None, - instructions: Optional[str] = None, - additional_instructions: Optional[str] = None, - additional_messages: Optional[List[_models.ThreadMessageOptions]] = None, - tools: Optional[List[_models.ToolDefinition]] = None, - tool_resources: Optional[_models.ToolResources] = None, - stream_parameter: Optional[bool] = None, - temperature: Optional[float] = None, - top_p: Optional[float] = None, - max_prompt_tokens: Optional[int] = None, - max_completion_tokens: Optional[int] = None, - truncation_strategy: Optional[_models.TruncationObject] = None, - tool_choice: Optional["_types.AgentsToolChoiceOption"] = None, - response_format: Optional["_types.AgentsResponseFormatOption"] = None, - parallel_tool_calls: Optional[bool] = None, - metadata: Optional[dict[str, str]] = None, - **kwargs: Any - ) -> _models.ThreadRun: - """Creates a new run for an agent thread. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :keyword agent_id: The ID of the agent that should run the thread. Required. - :paramtype agent_id: str - :keyword 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. Default value is None. - :paramtype include: list[str or ~azure.ai.agents.models.RunAdditionalFieldList] - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword model: The overridden model name that the agent should use to run the thread. Default - value is None. - :paramtype model: str - :keyword instructions: The overridden system instructions that the agent should use to run the - thread. Default value is None. - :paramtype instructions: str - :keyword additional_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. Default value is None. - :paramtype additional_instructions: str - :keyword additional_messages: Adds additional messages to the thread before creating the run. - Default value is None. - :paramtype additional_messages: list[~azure.ai.agents.models.ThreadMessageOptions] - :keyword tools: The overridden list of enabled tools that the agent should use to run the - thread. Default value is None. - :paramtype tools: list[~azure.ai.agents.models.ToolDefinition] - :keyword tool_resources: The overridden enabled tool resources that the agent should use to run - the thread. Default value is None. - :paramtype tool_resources: ~azure.ai.agents.models.ToolResources - :keyword stream_parameter: 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. Default - value is None. - :paramtype stream_parameter: bool - :keyword temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 - will make the output - more random, while lower values like 0.2 will make it more focused and deterministic. Default - value is None. - :paramtype temperature: float - :keyword top_p: An alternative to sampling with temperature, called nucleus sampling, where the - model - considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens - comprising the top 10% probability mass are considered. - - We generally recommend altering this or temperature but not both. Default value is None. - :paramtype top_p: float - :keyword max_prompt_tokens: 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. Default - value is None. - :paramtype max_prompt_tokens: int - :keyword max_completion_tokens: 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. Default value is None. - :paramtype max_completion_tokens: int - :keyword truncation_strategy: The strategy to use for dropping messages as the context windows - moves forward. Default value is None. - :paramtype truncation_strategy: ~azure.ai.agents.models.TruncationObject - :keyword tool_choice: Controls whether or not and which tool is called by the model. Is one of - the following types: str, Union[str, "_models.AgentsToolChoiceOptionMode"], - AgentsNamedToolChoice Default value is None. - :paramtype tool_choice: str or str or ~azure.ai.agents.models.AgentsToolChoiceOptionMode or - ~azure.ai.agents.models.AgentsNamedToolChoice - :keyword response_format: Specifies the format that the model must output. Is one of the - following types: str, Union[str, "_models.AgentsResponseFormatMode"], AgentsResponseFormat, - ResponseFormatJsonSchemaType Default value is None. - :paramtype response_format: str or str or ~azure.ai.agents.models.AgentsResponseFormatMode or - ~azure.ai.agents.models.AgentsResponseFormat or - ~azure.ai.agents.models.ResponseFormatJsonSchemaType - :keyword parallel_tool_calls: If ``true`` functions will run in parallel during tool use. - Default value is None. - :paramtype parallel_tool_calls: bool - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: ThreadRun. The ThreadRun is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadRun - :raises ~azure.core.exceptions.HttpResponseError: - """ + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore @overload - def create( + def create_or_update( self, - thread_id: str, - body: JSON, + name: str, + version: str, + index: _types_models1.Index, *, - include: Optional[List[Union[str, _models.RunAdditionalFieldList]]] = None, - content_type: str = "application/json", + content_type: str = "application/merge-patch+json", **kwargs: Any - ) -> _models.ThreadRun: - """Creates a new run for an agent thread. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param body: Required. - :type body: JSON - :keyword 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. Default value is None. - :paramtype include: list[str or ~azure.ai.agents.models.RunAdditionalFieldList] + ) -> _types_models1.Index: + """Create a new or update an existing Index with the given version id. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the Index to create or update. Required. + :type version: str + :param index: The Index to create or update. Required. + :type index: ~azure.ai.agents.types.Index :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". + Default value is "application/merge-patch+json". :paramtype content_type: str - :return: ThreadRun. The ThreadRun is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadRun + :return: Index + :rtype: ~azure.ai.agents.types.Index :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "AzureSearch": + index = { + "connectionName": "str", + "indexName": "str", + "name": "str", + "type": "AzureSearch", + "version": "str", + "description": "str", + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": + index = { + "connectionName": "str", + "containerName": "str", + "databaseName": "str", + "embeddingConfiguration": { + "embeddingField": "str", + "modelDeploymentName": "str" + }, + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "name": "str", + "type": "CosmosDBNoSqlVectorStore", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "ManagedAzureSearch": + index = { + "name": "str", + "type": "ManagedAzureSearch", + "vectorStoreId": "str", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template you can fill out and use as your body input. + index = index + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AzureSearch": + index = { + "connectionName": "str", + "indexName": "str", + "name": "str", + "type": "AzureSearch", + "version": "str", + "description": "str", + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": + index = { + "connectionName": "str", + "containerName": "str", + "databaseName": "str", + "embeddingConfiguration": { + "embeddingField": "str", + "modelDeploymentName": "str" + }, + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "name": "str", + "type": "CosmosDBNoSqlVectorStore", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "ManagedAzureSearch": + index = { + "name": "str", + "type": "ManagedAzureSearch", + "vectorStoreId": "str", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AzureSearch": + index = { + "connectionName": "str", + "indexName": "str", + "name": "str", + "type": "AzureSearch", + "version": "str", + "description": "str", + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": + index = { + "connectionName": "str", + "containerName": "str", + "databaseName": "str", + "embeddingConfiguration": { + "embeddingField": "str", + "modelDeploymentName": "str" + }, + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "name": "str", + "type": "CosmosDBNoSqlVectorStore", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "ManagedAzureSearch": + index = { + "name": "str", + "type": "ManagedAzureSearch", + "vectorStoreId": "str", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # response body for status code(s): 201, 200 + response == index """ @overload - def create( + def create_or_update( self, - thread_id: str, - body: IO[bytes], + name: str, + version: str, + index: IO[bytes], *, - include: Optional[List[Union[str, _models.RunAdditionalFieldList]]] = None, - content_type: str = "application/json", + content_type: str = "application/merge-patch+json", **kwargs: Any - ) -> _models.ThreadRun: - """Creates a new run for an agent thread. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param body: Required. - :type body: IO[bytes] - :keyword 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. Default value is None. - :paramtype include: list[str or ~azure.ai.agents.models.RunAdditionalFieldList] + ) -> _types_models1.Index: + """Create a new or update an existing Index with the given version id. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the Index to create or update. Required. + :type version: str + :param index: The Index to create or update. Required. + :type index: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". + Default value is "application/merge-patch+json". :paramtype content_type: str - :return: ThreadRun. The ThreadRun is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadRun + :return: Index + :rtype: ~azure.ai.agents.types.Index :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AzureSearch": + index = { + "connectionName": "str", + "indexName": "str", + "name": "str", + "type": "AzureSearch", + "version": "str", + "description": "str", + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": + index = { + "connectionName": "str", + "containerName": "str", + "databaseName": "str", + "embeddingConfiguration": { + "embeddingField": "str", + "modelDeploymentName": "str" + }, + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "name": "str", + "type": "CosmosDBNoSqlVectorStore", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "ManagedAzureSearch": + index = { + "name": "str", + "type": "ManagedAzureSearch", + "vectorStoreId": "str", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AzureSearch": + index = { + "connectionName": "str", + "indexName": "str", + "name": "str", + "type": "AzureSearch", + "version": "str", + "description": "str", + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": + index = { + "connectionName": "str", + "containerName": "str", + "databaseName": "str", + "embeddingConfiguration": { + "embeddingField": "str", + "modelDeploymentName": "str" + }, + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "name": "str", + "type": "CosmosDBNoSqlVectorStore", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "ManagedAzureSearch": + index = { + "name": "str", + "type": "ManagedAzureSearch", + "vectorStoreId": "str", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # response body for status code(s): 201, 200 + response == index """ @distributed_trace - def create( - self, - thread_id: str, - body: Union[JSON, IO[bytes]] = _Unset, - *, - agent_id: str = _Unset, - include: Optional[List[Union[str, _models.RunAdditionalFieldList]]] = None, - model: Optional[str] = None, - instructions: Optional[str] = None, - additional_instructions: Optional[str] = None, - additional_messages: Optional[List[_models.ThreadMessageOptions]] = None, - tools: Optional[List[_models.ToolDefinition]] = None, - tool_resources: Optional[_models.ToolResources] = None, - stream_parameter: Optional[bool] = None, - temperature: Optional[float] = None, - top_p: Optional[float] = None, - max_prompt_tokens: Optional[int] = None, - max_completion_tokens: Optional[int] = None, - truncation_strategy: Optional[_models.TruncationObject] = None, - tool_choice: Optional["_types.AgentsToolChoiceOption"] = None, - response_format: Optional["_types.AgentsResponseFormatOption"] = None, - parallel_tool_calls: Optional[bool] = None, - metadata: Optional[dict[str, str]] = None, - **kwargs: Any - ) -> _models.ThreadRun: - """Creates a new run for an agent thread. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword agent_id: The ID of the agent that should run the thread. Required. - :paramtype agent_id: str - :keyword 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. Default value is None. - :paramtype include: list[str or ~azure.ai.agents.models.RunAdditionalFieldList] - :keyword model: The overridden model name that the agent should use to run the thread. Default - value is None. - :paramtype model: str - :keyword instructions: The overridden system instructions that the agent should use to run the - thread. Default value is None. - :paramtype instructions: str - :keyword additional_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. Default value is None. - :paramtype additional_instructions: str - :keyword additional_messages: Adds additional messages to the thread before creating the run. - Default value is None. - :paramtype additional_messages: list[~azure.ai.agents.models.ThreadMessageOptions] - :keyword tools: The overridden list of enabled tools that the agent should use to run the - thread. Default value is None. - :paramtype tools: list[~azure.ai.agents.models.ToolDefinition] - :keyword tool_resources: The overridden enabled tool resources that the agent should use to run - the thread. Default value is None. - :paramtype tool_resources: ~azure.ai.agents.models.ToolResources - :keyword stream_parameter: 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. Default - value is None. - :paramtype stream_parameter: bool - :keyword temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 - will make the output - more random, while lower values like 0.2 will make it more focused and deterministic. Default - value is None. - :paramtype temperature: float - :keyword top_p: An alternative to sampling with temperature, called nucleus sampling, where the - model - considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens - comprising the top 10% probability mass are considered. - - We generally recommend altering this or temperature but not both. Default value is None. - :paramtype top_p: float - :keyword max_prompt_tokens: 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. Default - value is None. - :paramtype max_prompt_tokens: int - :keyword max_completion_tokens: 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. Default value is None. - :paramtype max_completion_tokens: int - :keyword truncation_strategy: The strategy to use for dropping messages as the context windows - moves forward. Default value is None. - :paramtype truncation_strategy: ~azure.ai.agents.models.TruncationObject - :keyword tool_choice: Controls whether or not and which tool is called by the model. Is one of - the following types: str, Union[str, "_models.AgentsToolChoiceOptionMode"], - AgentsNamedToolChoice Default value is None. - :paramtype tool_choice: str or str or ~azure.ai.agents.models.AgentsToolChoiceOptionMode or - ~azure.ai.agents.models.AgentsNamedToolChoice - :keyword response_format: Specifies the format that the model must output. Is one of the - following types: str, Union[str, "_models.AgentsResponseFormatMode"], AgentsResponseFormat, - ResponseFormatJsonSchemaType Default value is None. - :paramtype response_format: str or str or ~azure.ai.agents.models.AgentsResponseFormatMode or - ~azure.ai.agents.models.AgentsResponseFormat or - ~azure.ai.agents.models.ResponseFormatJsonSchemaType - :keyword parallel_tool_calls: If ``true`` functions will run in parallel during tool use. - Default value is None. - :paramtype parallel_tool_calls: bool - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: ThreadRun. The ThreadRun is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadRun + def create_or_update( + self, name: str, version: str, index: Union[_types_models1.Index, IO[bytes]], **kwargs: Any + ) -> _types_models1.Index: + """Create a new or update an existing Index with the given version id. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the Index to create or update. Required. + :type version: str + :param index: The Index to create or update. Is either a Index type or a IO[bytes] type. + Required. + :type index: ~azure.ai.agents.types.Index or IO[bytes] + :return: Index + :rtype: ~azure.ai.agents.types.Index :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "AzureSearch": + index = { + "connectionName": "str", + "indexName": "str", + "name": "str", + "type": "AzureSearch", + "version": "str", + "description": "str", + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": + index = { + "connectionName": "str", + "containerName": "str", + "databaseName": "str", + "embeddingConfiguration": { + "embeddingField": "str", + "modelDeploymentName": "str" + }, + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "name": "str", + "type": "CosmosDBNoSqlVectorStore", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "ManagedAzureSearch": + index = { + "name": "str", + "type": "ManagedAzureSearch", + "vectorStoreId": "str", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template you can fill out and use as your body input. + index = index + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AzureSearch": + index = { + "connectionName": "str", + "indexName": "str", + "name": "str", + "type": "AzureSearch", + "version": "str", + "description": "str", + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": + index = { + "connectionName": "str", + "containerName": "str", + "databaseName": "str", + "embeddingConfiguration": { + "embeddingField": "str", + "modelDeploymentName": "str" + }, + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "name": "str", + "type": "CosmosDBNoSqlVectorStore", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "ManagedAzureSearch": + index = { + "name": "str", + "type": "ManagedAzureSearch", + "vectorStoreId": "str", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AzureSearch": + index = { + "connectionName": "str", + "indexName": "str", + "name": "str", + "type": "AzureSearch", + "version": "str", + "description": "str", + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": + index = { + "connectionName": "str", + "containerName": "str", + "databaseName": "str", + "embeddingConfiguration": { + "embeddingField": "str", + "modelDeploymentName": "str" + }, + "fieldMapping": { + "contentFields": [ + "str" + ], + "filepathField": "str", + "metadataFields": [ + "str" + ], + "titleField": "str", + "urlField": "str", + "vectorFields": [ + "str" + ] + }, + "name": "str", + "type": "CosmosDBNoSqlVectorStore", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # JSON input template for discriminator value "ManagedAzureSearch": + index = { + "name": "str", + "type": "ManagedAzureSearch", + "vectorStoreId": "str", + "version": "str", + "description": "str", + "id": "str", + "tags": { + "str": "str" + } + } + + # response body for status code(s): 201, 200 + response == index """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2686,43 +9153,22 @@ def create( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ThreadRun] = kwargs.pop("cls", None) + cls: ClsType[_types_models1.Index] = kwargs.pop("cls", None) - if body is _Unset: - if agent_id is _Unset: - raise TypeError("missing required argument: agent_id") - body = { - "additional_instructions": additional_instructions, - "additional_messages": additional_messages, - "assistant_id": agent_id, - "instructions": instructions, - "max_completion_tokens": max_completion_tokens, - "max_prompt_tokens": max_prompt_tokens, - "metadata": metadata, - "model": model, - "parallel_tool_calls": parallel_tool_calls, - "response_format": response_format, - "stream": stream_parameter, - "temperature": temperature, - "tool_choice": tool_choice, - "tool_resources": tool_resources, - "tools": tools, - "top_p": top_p, - "truncation_strategy": truncation_strategy, - } - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" + content_type = content_type or "application/merge-patch+json" + _json = None _content = None - if isinstance(body, (IOBase, bytes)): - _content = body + if isinstance(index, (IOBase, bytes)): + _content = index else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _json = index - _request = build_runs_create_request( - thread_id=thread_id, - include=include, + _request = build_indexes_create_or_update_request( + name=name, + version=version, content_type=content_type, api_version=self._config.api_version, + json=_json, content=_content, headers=_headers, params=_params, @@ -2732,6 +9178,7 @@ def create( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -2739,60 +9186,43 @@ def create( response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 201]: if _stream: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.ThreadRun, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + +class _AIProjectClientOperationsMixin( + ClientMixinABC[PipelineClient[HttpRequest, HttpResponse], AIProjectClientConfiguration] +): + @distributed_trace - def list( - self, - thread_id: str, - *, - limit: Optional[int] = None, - order: Optional[Union[str, _models.ListSortOrder]] = None, - before: Optional[str] = None, - **kwargs: Any - ) -> ItemPaged["_models.ThreadRun"]: - """Gets a list of runs for a specified thread. + def delete_job(self, job_id: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements + """Delete a job. Returns 204 No Content. - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and - 100, and the default is 20. Default value is None. - :paramtype limit: int - :keyword order: Sort order by the created_at timestamp of the objects. asc for ascending order - and desc for descending order. Known values are: "asc" and "desc". Default value is None. - :paramtype order: str or ~azure.ai.agents.models.ListSortOrder - :keyword 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. Default value is None. - :paramtype before: str - :return: An iterator like instance of ThreadRun - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.models.ThreadRun] + :param job_id: The ID of the job to delete. Required. + :type job_id: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.ThreadRun]] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2801,60 +9231,149 @@ def list( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(_continuation_token=None): + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - _request = build_runs_list_request( - thread_id=thread_id, - limit=limit, - order=order, - after=_continuation_token, - before=before, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - return _request + cls: ClsType[None] = kwargs.pop("cls", None) - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.ThreadRun], deserialized.get("data", [])) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("last_id") or None, iter(list_of_elem) + _request = build_ai_project_delete_job_request( + job_id=job_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - def get_next(_continuation_token=None): - _request = prepare_request(_continuation_token) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _types_models1.ApiErrorResponse, + pipeline_response, ) - response = pipeline_response.http_response + raise HttpResponseError(response=response, model=error) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) + if cls: + return cls(pipeline_response, None, {}) # type: ignore - return pipeline_response - return ItemPaged(get_next, extract_data) +class BetaEvaluationTaxonomiesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - @distributed_trace - def get(self, thread_id: str, run_id: str, **kwargs: Any) -> _models.ThreadRun: - """Gets an existing run from an existing thread. + Instead, you should access the following operations through + :class:`~azure.ai.agents.AIProjectClient`'s + :attr:`evaluation_taxonomies` attribute. + """ - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param run_id: Identifier of the run. Required. - :type run_id: str - :return: ThreadRun. The ThreadRun is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadRun + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], **kwargs: Any + ) -> _types_models1.EvaluationTaxonomy: + """Get an evaluation run by name. + + :param name: The name of the resource. Required. + :type name: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + :return: EvaluationTaxonomy + :rtype: ~azure.ai.agents.types.EvaluationTaxonomy :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "agent": + evaluation_taxonomy_input = { + "riskCategories": [ + "str" + ], + "target": target, + "type": "agent" + } + + # JSON input template for discriminator value "azure_ai_agent": + target = { + "name": "str", + "type": "azure_ai_agent", + "tool_descriptions": [ + { + "description": "str", + "name": "str" + } + ], + "version": "str" + } + + # JSON input template for discriminator value "azure_ai_model": + target = { + "type": "azure_ai_model", + "model": "str", + "sampling_params": { + "max_completion_tokens": 0, + "seed": 0, + "temperature": 0.0, + "top_p": 0.0 + } + } + + # response body for status code(s): 200 + response == { + "name": "str", + "taxonomyInput": evaluation_taxonomy_input, + "version": "str", + "description": "str", + "id": "str", + "properties": { + "str": "str" + }, + "tags": { + "str": "str" + }, + "taxonomyCategories": [ + { + "id": "str", + "name": "str", + "riskCategory": "str", + "subCategories": [ + { + "enabled": bool, + "id": "str", + "name": "str", + "description": "str", + "properties": { + "str": "str" + } + } + ], + "description": "str", + "properties": { + "str": "str" + } + } + ] + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2867,11 +9386,11 @@ def get(self, thread_id: str, run_id: str, **kwargs: Any) -> _models.ThreadRun: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.ThreadRun] = kwargs.pop("cls", None) + cls: ClsType[_types_models1.EvaluationTaxonomy] = kwargs.pop("cls", None) - _request = build_runs_get_request( - thread_id=thread_id, - run_id=run_id, + _request = build_beta_evaluation_taxonomies_get_request( + name=name, + foundry_features=foundry_features, api_version=self._config.api_version, headers=_headers, params=_params, @@ -2881,6 +9400,7 @@ def get(self, thread_id: str, run_id: str, **kwargs: Any) -> _models.ThreadRun: } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -2895,113 +9415,213 @@ def get(self, thread_id: str, run_id: str, **kwargs: Any) -> _models.ThreadRun: except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.ThreadRun, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - def update( + @distributed_trace + def list( self, - thread_id: str, - run_id: str, *, - content_type: str = "application/json", - metadata: Optional[dict[str, str]] = None, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + input_name: Optional[str] = None, + input_type: Optional[str] = None, **kwargs: Any - ) -> _models.ThreadRun: - """Modifies an existing thread run. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param run_id: Identifier of the run. Required. - :type run_id: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: ThreadRun. The ThreadRun is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadRun + ) -> ItemPaged["_types_models1.EvaluationTaxonomy"]: + """List evaluation taxonomies. + + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + :keyword input_name: Filter by the evaluation input name. Default value is None. + :paramtype input_name: str + :keyword input_type: Filter by taxonomy input type. Default value is None. + :paramtype input_type: str + :return: An iterator like instance of EvaluationTaxonomy + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.types.EvaluationTaxonomy] :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "agent": + evaluation_taxonomy_input = { + "riskCategories": [ + "str" + ], + "target": target, + "type": "agent" + } + + # JSON input template for discriminator value "azure_ai_agent": + target = { + "name": "str", + "type": "azure_ai_agent", + "tool_descriptions": [ + { + "description": "str", + "name": "str" + } + ], + "version": "str" + } + + # JSON input template for discriminator value "azure_ai_model": + target = { + "type": "azure_ai_model", + "model": "str", + "sampling_params": { + "max_completion_tokens": 0, + "seed": 0, + "temperature": 0.0, + "top_p": 0.0 + } + } + + # response body for status code(s): 200 + response == { + "name": "str", + "taxonomyInput": evaluation_taxonomy_input, + "version": "str", + "description": "str", + "id": "str", + "properties": { + "str": "str" + }, + "tags": { + "str": "str" + }, + "taxonomyCategories": [ + { + "id": "str", + "name": "str", + "riskCategory": "str", + "subCategories": [ + { + "enabled": bool, + "id": "str", + "name": "str", + "description": "str", + "properties": { + "str": "str" + } + } + ], + "description": "str", + "properties": { + "str": "str" + } + } + ] + } """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - @overload - def update( - self, thread_id: str, run_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ThreadRun: - """Modifies an existing thread run. + cls: ClsType[List[_types_models1.EvaluationTaxonomy]] = kwargs.pop("cls", None) - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param run_id: Identifier of the run. Required. - :type run_id: str - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ThreadRun. The ThreadRun is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadRun - :raises ~azure.core.exceptions.HttpResponseError: - """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - @overload - def update( - self, thread_id: str, run_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ThreadRun: - """Modifies an existing thread run. + def prepare_request(next_link=None): + if not next_link: + + _request = build_beta_evaluation_taxonomies_list_request( + foundry_features=foundry_features, + input_name=input_name, + input_type=input_type, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param run_id: Identifier of the run. Required. - :type run_id: str - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: ThreadRun. The ThreadRun is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadRun - :raises ~azure.core.exceptions.HttpResponseError: - """ + return _request - @distributed_trace - def update( - self, - thread_id: str, - run_id: str, - body: Union[JSON, IO[bytes]] = _Unset, - *, - metadata: Optional[dict[str, str]] = None, - **kwargs: Any - ) -> _models.ThreadRun: - """Modifies an existing thread run. + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized.get("value", []) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param run_id: Identifier of the run. Required. - :type run_id: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: ThreadRun. The ThreadRun is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadRun + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], **kwargs: Any + ) -> None: + """Delete an evaluation taxonomy by name. + + :param name: The name of the resource. Required. + :type name: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -3012,28 +9632,15 @@ def update( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ThreadRun] = kwargs.pop("cls", None) - - if body is _Unset: - body = {"metadata": metadata} - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_runs_update_request( - thread_id=thread_id, - run_id=run_id, - content_type=content_type, + _request = build_beta_evaluation_taxonomies_delete_request( + name=name, + foundry_features=foundry_features, api_version=self._config.api_version, - content=_content, headers=_headers, params=_params, ) @@ -3042,140 +9649,586 @@ def update( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) - - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.ThreadRun, response.json()) + raise HttpResponseError(response=response) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + return cls(pipeline_response, None, {}) # type: ignore @overload - def submit_tool_outputs( + def create( self, - thread_id: str, - run_id: str, + name: str, + body: _types_models1.EvaluationTaxonomy, *, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], content_type: str = "application/json", - tool_outputs: Optional[List[_models.StructuredToolOutput]] = None, - tool_approvals: Optional[List[_models.ToolApproval]] = None, - stream_parameter: Optional[bool] = None, **kwargs: Any - ) -> _models.ThreadRun: - """Submits outputs from tools as requested by tool calls in a run. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param run_id: Identifier of the run. Required. - :type run_id: str + ) -> _types_models1.EvaluationTaxonomy: + """Create an evaluation taxonomy. + + :param name: The name of the evaluation taxonomy. Required. + :type name: str + :param body: The evaluation taxonomy. Required. + :type body: ~azure.ai.agents.types.EvaluationTaxonomy + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword tool_outputs: A list of tools for which the outputs are being submitted. Default value - is None. - :paramtype tool_outputs: list[~azure.ai.agents.models.StructuredToolOutput] - :keyword tool_approvals: A list of tool approvals allowing data to be sent to tools. Default - value is None. - :paramtype tool_approvals: list[~azure.ai.agents.models.ToolApproval] - :keyword stream_parameter: If true, returns a stream of events that happen during the Run as - SSE, terminating at ``[DONE]``. Default value is None. - :paramtype stream_parameter: bool - :return: ThreadRun. The ThreadRun is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadRun + :return: EvaluationTaxonomy + :rtype: ~azure.ai.agents.types.EvaluationTaxonomy :raises ~azure.core.exceptions.HttpResponseError: - """ - @overload - def submit_tool_outputs( - self, thread_id: str, run_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ThreadRun: - """Submits outputs from tools as requested by tool calls in a run. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param run_id: Identifier of the run. Required. - :type run_id: str - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ThreadRun. The ThreadRun is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadRun - :raises ~azure.core.exceptions.HttpResponseError: + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "agent": + evaluation_taxonomy_input = { + "riskCategories": [ + "str" + ], + "target": target, + "type": "agent" + } + + # JSON input template for discriminator value "azure_ai_agent": + target = { + "name": "str", + "type": "azure_ai_agent", + "tool_descriptions": [ + { + "description": "str", + "name": "str" + } + ], + "version": "str" + } + + # JSON input template for discriminator value "azure_ai_model": + target = { + "type": "azure_ai_model", + "model": "str", + "sampling_params": { + "max_completion_tokens": 0, + "seed": 0, + "temperature": 0.0, + "top_p": 0.0 + } + } + + # JSON input template you can fill out and use as your body input. + body = { + "name": "str", + "taxonomyInput": evaluation_taxonomy_input, + "version": "str", + "description": "str", + "id": "str", + "properties": { + "str": "str" + }, + "tags": { + "str": "str" + }, + "taxonomyCategories": [ + { + "id": "str", + "name": "str", + "riskCategory": "str", + "subCategories": [ + { + "enabled": bool, + "id": "str", + "name": "str", + "description": "str", + "properties": { + "str": "str" + } + } + ], + "description": "str", + "properties": { + "str": "str" + } + } + ] + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "agent": + evaluation_taxonomy_input = { + "riskCategories": [ + "str" + ], + "target": target, + "type": "agent" + } + + # JSON input template for discriminator value "azure_ai_agent": + target = { + "name": "str", + "type": "azure_ai_agent", + "tool_descriptions": [ + { + "description": "str", + "name": "str" + } + ], + "version": "str" + } + + # JSON input template for discriminator value "azure_ai_model": + target = { + "type": "azure_ai_model", + "model": "str", + "sampling_params": { + "max_completion_tokens": 0, + "seed": 0, + "temperature": 0.0, + "top_p": 0.0 + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "agent": + evaluation_taxonomy_input = { + "riskCategories": [ + "str" + ], + "target": target, + "type": "agent" + } + + # JSON input template for discriminator value "azure_ai_agent": + target = { + "name": "str", + "type": "azure_ai_agent", + "tool_descriptions": [ + { + "description": "str", + "name": "str" + } + ], + "version": "str" + } + + # JSON input template for discriminator value "azure_ai_model": + target = { + "type": "azure_ai_model", + "model": "str", + "sampling_params": { + "max_completion_tokens": 0, + "seed": 0, + "temperature": 0.0, + "top_p": 0.0 + } + } + + # response body for status code(s): 201, 200 + response == { + "name": "str", + "taxonomyInput": evaluation_taxonomy_input, + "version": "str", + "description": "str", + "id": "str", + "properties": { + "str": "str" + }, + "tags": { + "str": "str" + }, + "taxonomyCategories": [ + { + "id": "str", + "name": "str", + "riskCategory": "str", + "subCategories": [ + { + "enabled": bool, + "id": "str", + "name": "str", + "description": "str", + "properties": { + "str": "str" + } + } + ], + "description": "str", + "properties": { + "str": "str" + } + } + ] + } """ @overload - def submit_tool_outputs( - self, thread_id: str, run_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ThreadRun: - """Submits outputs from tools as requested by tool calls in a run. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param run_id: Identifier of the run. Required. - :type run_id: str - :param body: Required. + def create( + self, + name: str, + body: IO[bytes], + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models1.EvaluationTaxonomy: + """Create an evaluation taxonomy. + + :param name: The name of the evaluation taxonomy. Required. + :type name: str + :param body: The evaluation taxonomy. Required. :type body: IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: ThreadRun. The ThreadRun is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadRun + :return: EvaluationTaxonomy + :rtype: ~azure.ai.agents.types.EvaluationTaxonomy :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "agent": + evaluation_taxonomy_input = { + "riskCategories": [ + "str" + ], + "target": target, + "type": "agent" + } + + # JSON input template for discriminator value "azure_ai_agent": + target = { + "name": "str", + "type": "azure_ai_agent", + "tool_descriptions": [ + { + "description": "str", + "name": "str" + } + ], + "version": "str" + } + + # JSON input template for discriminator value "azure_ai_model": + target = { + "type": "azure_ai_model", + "model": "str", + "sampling_params": { + "max_completion_tokens": 0, + "seed": 0, + "temperature": 0.0, + "top_p": 0.0 + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "agent": + evaluation_taxonomy_input = { + "riskCategories": [ + "str" + ], + "target": target, + "type": "agent" + } + + # JSON input template for discriminator value "azure_ai_agent": + target = { + "name": "str", + "type": "azure_ai_agent", + "tool_descriptions": [ + { + "description": "str", + "name": "str" + } + ], + "version": "str" + } + + # JSON input template for discriminator value "azure_ai_model": + target = { + "type": "azure_ai_model", + "model": "str", + "sampling_params": { + "max_completion_tokens": 0, + "seed": 0, + "temperature": 0.0, + "top_p": 0.0 + } + } + + # response body for status code(s): 201, 200 + response == { + "name": "str", + "taxonomyInput": evaluation_taxonomy_input, + "version": "str", + "description": "str", + "id": "str", + "properties": { + "str": "str" + }, + "tags": { + "str": "str" + }, + "taxonomyCategories": [ + { + "id": "str", + "name": "str", + "riskCategory": "str", + "subCategories": [ + { + "enabled": bool, + "id": "str", + "name": "str", + "description": "str", + "properties": { + "str": "str" + } + } + ], + "description": "str", + "properties": { + "str": "str" + } + } + ] + } """ @distributed_trace - def submit_tool_outputs( + def create( self, - thread_id: str, - run_id: str, - body: Union[JSON, IO[bytes]] = _Unset, + name: str, + body: Union[_types_models1.EvaluationTaxonomy, IO[bytes]], *, - tool_outputs: Optional[List[_models.StructuredToolOutput]] = None, - tool_approvals: Optional[List[_models.ToolApproval]] = None, - stream_parameter: Optional[bool] = None, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], **kwargs: Any - ) -> _models.ThreadRun: - """Submits outputs from tools as requested by tool calls in a run. + ) -> _types_models1.EvaluationTaxonomy: + """Create an evaluation taxonomy. - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param run_id: Identifier of the run. Required. - :type run_id: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword tool_outputs: A list of tools for which the outputs are being submitted. Default value - is None. - :paramtype tool_outputs: list[~azure.ai.agents.models.StructuredToolOutput] - :keyword tool_approvals: A list of tool approvals allowing data to be sent to tools. Default - value is None. - :paramtype tool_approvals: list[~azure.ai.agents.models.ToolApproval] - :keyword stream_parameter: If true, returns a stream of events that happen during the Run as - SSE, terminating at ``[DONE]``. Default value is None. - :paramtype stream_parameter: bool - :return: ThreadRun. The ThreadRun is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadRun + :param name: The name of the evaluation taxonomy. Required. + :type name: str + :param body: The evaluation taxonomy. Is either a EvaluationTaxonomy type or a IO[bytes] type. + Required. + :type body: ~azure.ai.agents.types.EvaluationTaxonomy or IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + :return: EvaluationTaxonomy + :rtype: ~azure.ai.agents.types.EvaluationTaxonomy :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "agent": + evaluation_taxonomy_input = { + "riskCategories": [ + "str" + ], + "target": target, + "type": "agent" + } + + # JSON input template for discriminator value "azure_ai_agent": + target = { + "name": "str", + "type": "azure_ai_agent", + "tool_descriptions": [ + { + "description": "str", + "name": "str" + } + ], + "version": "str" + } + + # JSON input template for discriminator value "azure_ai_model": + target = { + "type": "azure_ai_model", + "model": "str", + "sampling_params": { + "max_completion_tokens": 0, + "seed": 0, + "temperature": 0.0, + "top_p": 0.0 + } + } + + # JSON input template you can fill out and use as your body input. + body = { + "name": "str", + "taxonomyInput": evaluation_taxonomy_input, + "version": "str", + "description": "str", + "id": "str", + "properties": { + "str": "str" + }, + "tags": { + "str": "str" + }, + "taxonomyCategories": [ + { + "id": "str", + "name": "str", + "riskCategory": "str", + "subCategories": [ + { + "enabled": bool, + "id": "str", + "name": "str", + "description": "str", + "properties": { + "str": "str" + } + } + ], + "description": "str", + "properties": { + "str": "str" + } + } + ] + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "agent": + evaluation_taxonomy_input = { + "riskCategories": [ + "str" + ], + "target": target, + "type": "agent" + } + + # JSON input template for discriminator value "azure_ai_agent": + target = { + "name": "str", + "type": "azure_ai_agent", + "tool_descriptions": [ + { + "description": "str", + "name": "str" + } + ], + "version": "str" + } + + # JSON input template for discriminator value "azure_ai_model": + target = { + "type": "azure_ai_model", + "model": "str", + "sampling_params": { + "max_completion_tokens": 0, + "seed": 0, + "temperature": 0.0, + "top_p": 0.0 + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "agent": + evaluation_taxonomy_input = { + "riskCategories": [ + "str" + ], + "target": target, + "type": "agent" + } + + # JSON input template for discriminator value "azure_ai_agent": + target = { + "name": "str", + "type": "azure_ai_agent", + "tool_descriptions": [ + { + "description": "str", + "name": "str" + } + ], + "version": "str" + } + + # JSON input template for discriminator value "azure_ai_model": + target = { + "type": "azure_ai_model", + "model": "str", + "sampling_params": { + "max_completion_tokens": 0, + "seed": 0, + "temperature": 0.0, + "top_p": 0.0 + } + } + + # response body for status code(s): 201, 200 + response == { + "name": "str", + "taxonomyInput": evaluation_taxonomy_input, + "version": "str", + "description": "str", + "id": "str", + "properties": { + "str": "str" + }, + "tags": { + "str": "str" + }, + "taxonomyCategories": [ + { + "id": "str", + "name": "str", + "riskCategory": "str", + "subCategories": [ + { + "enabled": bool, + "id": "str", + "name": "str", + "description": "str", + "properties": { + "str": "str" + } + } + ], + "description": "str", + "properties": { + "str": "str" + } + } + ] + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3189,23 +10242,22 @@ def submit_tool_outputs( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ThreadRun] = kwargs.pop("cls", None) + cls: ClsType[_types_models1.EvaluationTaxonomy] = kwargs.pop("cls", None) - if body is _Unset: - body = {"stream": stream_parameter, "tool_approvals": tool_approvals, "tool_outputs": tool_outputs} - body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" + _json = None _content = None if isinstance(body, (IOBase, bytes)): _content = body else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _json = body - _request = build_runs_submit_tool_outputs_request( - thread_id=thread_id, - run_id=run_id, + _request = build_beta_evaluation_taxonomies_create_request( + name=name, + foundry_features=foundry_features, content_type=content_type, api_version=self._config.api_version, + json=_json, content=_content, headers=_headers, params=_params, @@ -3215,6 +10267,7 @@ def submit_tool_outputs( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -3222,37 +10275,483 @@ def submit_tool_outputs( response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 201]: if _stream: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.ThreadRun, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + @overload + def update( + self, + name: str, + body: _types_models1.EvaluationTaxonomy, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models1.EvaluationTaxonomy: + """Update an evaluation taxonomy. + + :param name: The name of the evaluation taxonomy. Required. + :type name: str + :param body: The evaluation taxonomy. Required. + :type body: ~azure.ai.agents.types.EvaluationTaxonomy + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: EvaluationTaxonomy + :rtype: ~azure.ai.agents.types.EvaluationTaxonomy + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "agent": + evaluation_taxonomy_input = { + "riskCategories": [ + "str" + ], + "target": target, + "type": "agent" + } + + # JSON input template for discriminator value "azure_ai_agent": + target = { + "name": "str", + "type": "azure_ai_agent", + "tool_descriptions": [ + { + "description": "str", + "name": "str" + } + ], + "version": "str" + } + + # JSON input template for discriminator value "azure_ai_model": + target = { + "type": "azure_ai_model", + "model": "str", + "sampling_params": { + "max_completion_tokens": 0, + "seed": 0, + "temperature": 0.0, + "top_p": 0.0 + } + } + + # JSON input template you can fill out and use as your body input. + body = { + "name": "str", + "taxonomyInput": evaluation_taxonomy_input, + "version": "str", + "description": "str", + "id": "str", + "properties": { + "str": "str" + }, + "tags": { + "str": "str" + }, + "taxonomyCategories": [ + { + "id": "str", + "name": "str", + "riskCategory": "str", + "subCategories": [ + { + "enabled": bool, + "id": "str", + "name": "str", + "description": "str", + "properties": { + "str": "str" + } + } + ], + "description": "str", + "properties": { + "str": "str" + } + } + ] + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "agent": + evaluation_taxonomy_input = { + "riskCategories": [ + "str" + ], + "target": target, + "type": "agent" + } + + # JSON input template for discriminator value "azure_ai_agent": + target = { + "name": "str", + "type": "azure_ai_agent", + "tool_descriptions": [ + { + "description": "str", + "name": "str" + } + ], + "version": "str" + } + + # JSON input template for discriminator value "azure_ai_model": + target = { + "type": "azure_ai_model", + "model": "str", + "sampling_params": { + "max_completion_tokens": 0, + "seed": 0, + "temperature": 0.0, + "top_p": 0.0 + } + } + + # response body for status code(s): 200 + response == { + "name": "str", + "taxonomyInput": evaluation_taxonomy_input, + "version": "str", + "description": "str", + "id": "str", + "properties": { + "str": "str" + }, + "tags": { + "str": "str" + }, + "taxonomyCategories": [ + { + "id": "str", + "name": "str", + "riskCategory": "str", + "subCategories": [ + { + "enabled": bool, + "id": "str", + "name": "str", + "description": "str", + "properties": { + "str": "str" + } + } + ], + "description": "str", + "properties": { + "str": "str" + } + } + ] + } + """ + + @overload + def update( + self, + name: str, + body: IO[bytes], + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models1.EvaluationTaxonomy: + """Update an evaluation taxonomy. + + :param name: The name of the evaluation taxonomy. Required. + :type name: str + :param body: The evaluation taxonomy. Required. + :type body: IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: EvaluationTaxonomy + :rtype: ~azure.ai.agents.types.EvaluationTaxonomy + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "agent": + evaluation_taxonomy_input = { + "riskCategories": [ + "str" + ], + "target": target, + "type": "agent" + } + + # JSON input template for discriminator value "azure_ai_agent": + target = { + "name": "str", + "type": "azure_ai_agent", + "tool_descriptions": [ + { + "description": "str", + "name": "str" + } + ], + "version": "str" + } + + # JSON input template for discriminator value "azure_ai_model": + target = { + "type": "azure_ai_model", + "model": "str", + "sampling_params": { + "max_completion_tokens": 0, + "seed": 0, + "temperature": 0.0, + "top_p": 0.0 + } + } + + # response body for status code(s): 200 + response == { + "name": "str", + "taxonomyInput": evaluation_taxonomy_input, + "version": "str", + "description": "str", + "id": "str", + "properties": { + "str": "str" + }, + "tags": { + "str": "str" + }, + "taxonomyCategories": [ + { + "id": "str", + "name": "str", + "riskCategory": "str", + "subCategories": [ + { + "enabled": bool, + "id": "str", + "name": "str", + "description": "str", + "properties": { + "str": "str" + } + } + ], + "description": "str", + "properties": { + "str": "str" + } + } + ] + } + """ + @distributed_trace - def cancel(self, thread_id: str, run_id: str, **kwargs: Any) -> _models.ThreadRun: - """Cancels a run of an in‐progress thread. + def update( + self, + name: str, + body: Union[_types_models1.EvaluationTaxonomy, IO[bytes]], + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + **kwargs: Any + ) -> _types_models1.EvaluationTaxonomy: + """Update an evaluation taxonomy. - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param run_id: Identifier of the run. Required. - :type run_id: str - :return: ThreadRun. The ThreadRun is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadRun + :param name: The name of the evaluation taxonomy. Required. + :type name: str + :param body: The evaluation taxonomy. Is either a EvaluationTaxonomy type or a IO[bytes] type. + Required. + :type body: ~azure.ai.agents.types.EvaluationTaxonomy or IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + :return: EvaluationTaxonomy + :rtype: ~azure.ai.agents.types.EvaluationTaxonomy :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "agent": + evaluation_taxonomy_input = { + "riskCategories": [ + "str" + ], + "target": target, + "type": "agent" + } + + # JSON input template for discriminator value "azure_ai_agent": + target = { + "name": "str", + "type": "azure_ai_agent", + "tool_descriptions": [ + { + "description": "str", + "name": "str" + } + ], + "version": "str" + } + + # JSON input template for discriminator value "azure_ai_model": + target = { + "type": "azure_ai_model", + "model": "str", + "sampling_params": { + "max_completion_tokens": 0, + "seed": 0, + "temperature": 0.0, + "top_p": 0.0 + } + } + + # JSON input template you can fill out and use as your body input. + body = { + "name": "str", + "taxonomyInput": evaluation_taxonomy_input, + "version": "str", + "description": "str", + "id": "str", + "properties": { + "str": "str" + }, + "tags": { + "str": "str" + }, + "taxonomyCategories": [ + { + "id": "str", + "name": "str", + "riskCategory": "str", + "subCategories": [ + { + "enabled": bool, + "id": "str", + "name": "str", + "description": "str", + "properties": { + "str": "str" + } + } + ], + "description": "str", + "properties": { + "str": "str" + } + } + ] + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "agent": + evaluation_taxonomy_input = { + "riskCategories": [ + "str" + ], + "target": target, + "type": "agent" + } + + # JSON input template for discriminator value "azure_ai_agent": + target = { + "name": "str", + "type": "azure_ai_agent", + "tool_descriptions": [ + { + "description": "str", + "name": "str" + } + ], + "version": "str" + } + + # JSON input template for discriminator value "azure_ai_model": + target = { + "type": "azure_ai_model", + "model": "str", + "sampling_params": { + "max_completion_tokens": 0, + "seed": 0, + "temperature": 0.0, + "top_p": 0.0 + } + } + + # response body for status code(s): 200 + response == { + "name": "str", + "taxonomyInput": evaluation_taxonomy_input, + "version": "str", + "description": "str", + "id": "str", + "properties": { + "str": "str" + }, + "tags": { + "str": "str" + }, + "taxonomyCategories": [ + { + "id": "str", + "name": "str", + "riskCategory": "str", + "subCategories": [ + { + "enabled": bool, + "id": "str", + "name": "str", + "description": "str", + "properties": { + "str": "str" + } + } + ], + "description": "str", + "properties": { + "str": "str" + } + } + ] + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3262,15 +10761,27 @@ def cancel(self, thread_id: str, run_id: str, **kwargs: Any) -> _models.ThreadRu } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.ThreadRun] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_types_models1.EvaluationTaxonomy] = kwargs.pop("cls", None) - _request = build_runs_cancel_request( - thread_id=thread_id, - run_id=run_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_beta_evaluation_taxonomies_update_request( + name=name, + foundry_features=foundry_features, + content_type=content_type, api_version=self._config.api_version, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -3279,6 +10790,7 @@ def cancel(self, thread_id: str, run_id: str, **kwargs: Any) -> _models.ThreadRu } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -3293,13 +10805,15 @@ def cancel(self, thread_id: str, run_id: str, **kwargs: Any) -> _models.ThreadRu except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.ThreadRun, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -3307,50 +10821,127 @@ def cancel(self, thread_id: str, run_id: str, **kwargs: Any) -> _models.ThreadRu return deserialized # type: ignore -class RunStepsOperations: +class BetaEvaluatorsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.ai.agents.AgentsClient`'s - :attr:`run_steps` attribute. + :class:`~azure.ai.agents.AIProjectClient`'s + :attr:`evaluators` attribute. """ def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AgentsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( + def list_versions( self, - thread_id: str, - run_id: str, - step_id: str, + name: str, *, - include: Optional[List[Union[str, _models.RunAdditionalFieldList]]] = None, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + type: Optional[Union[Literal["builtin"], Literal["custom"], Literal["all"], str]] = None, + limit: Optional[int] = None, **kwargs: Any - ) -> _models.RunStep: - """Retrieves a single run step from a thread run. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param run_id: Identifier of the run. Required. - :type run_id: str - :param step_id: Identifier of the run step. Required. - :type step_id: str - :keyword 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. Default value is None. - :paramtype include: list[str or ~azure.ai.agents.models.RunAdditionalFieldList] - :return: RunStep. The RunStep is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.RunStep + ) -> ItemPaged["_types_models1.EvaluatorVersion"]: + """List all versions of the given evaluator. + + :param name: The name of the resource. Required. + :type name: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + :keyword type: Filter evaluators by type. Possible values: 'all', 'custom', 'builtin'. Is one + of the following types: Literal["builtin"], Literal["custom"], Literal["all"], str Default + value is None. + :paramtype type: str or str or str or str + :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and + 100, and the default is 20. Default value is None. + :paramtype limit: int + :return: An iterator like instance of EvaluatorVersion + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.types.EvaluatorVersion] :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "code": + evaluator_definition = { + "code_text": "str", + "type": "code", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # JSON input template for discriminator value "prompt": + evaluator_definition = { + "prompt_text": "str", + "type": "prompt", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # response body for status code(s): 200 + response == { + "categories": [ + "str" + ], + "created_at": "2020-02-20 00:00:00", + "created_by": "str", + "definition": evaluator_definition, + "evaluator_type": "str", + "modified_at": "2020-02-20 00:00:00", + "name": "str", + "version": "str", + "description": "str", + "display_name": "str", + "id": "str", + "metadata": { + "str": "str" + }, + "tags": { + "str": "str" + } + } """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_types_models1.EvaluatorVersion]] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -3359,94 +10950,174 @@ def get( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.RunStep] = kwargs.pop("cls", None) + def prepare_request(next_link=None): + if not next_link: + + _request = build_beta_evaluators_list_versions_request( + name=name, + foundry_features=foundry_features, + type=type, + limit=limit, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - _request = build_run_steps_get_request( - thread_id=thread_id, - run_id=run_id, - step_id=step_id, - include=include, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized.get("value", []) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) - response = pipeline_response.http_response + def get_next(next_link=None): + _request = prepare_request(next_link) - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.RunStep, response.json()) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return pipeline_response - return deserialized # type: ignore + return ItemPaged(get_next, extract_data) @distributed_trace def list( self, - thread_id: str, - run_id: str, *, - include: Optional[List[Union[str, _models.RunAdditionalFieldList]]] = None, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + type: Optional[Union[Literal["builtin"], Literal["custom"], Literal["all"], str]] = None, limit: Optional[int] = None, - order: Optional[Union[str, _models.ListSortOrder]] = None, - before: Optional[str] = None, **kwargs: Any - ) -> ItemPaged["_models.RunStep"]: - """Gets a list of run steps from a thread run. - - :param thread_id: Identifier of the thread. Required. - :type thread_id: str - :param run_id: Identifier of the run. Required. - :type run_id: str - :keyword 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. Default value is None. - :paramtype include: list[str or ~azure.ai.agents.models.RunAdditionalFieldList] + ) -> ItemPaged["_types_models1.EvaluatorVersion"]: + """List the latest version of each evaluator. + + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + :keyword type: Filter evaluators by type. Possible values: 'all', 'custom', 'builtin'. Is one + of the following types: Literal["builtin"], Literal["custom"], Literal["all"], str Default + value is None. + :paramtype type: str or str or str or str :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. Default value is None. :paramtype limit: int - :keyword order: Sort order by the created_at timestamp of the objects. asc for ascending order - and desc for descending order. Known values are: "asc" and "desc". Default value is None. - :paramtype order: str or ~azure.ai.agents.models.ListSortOrder - :keyword 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. Default value is None. - :paramtype before: str - :return: An iterator like instance of RunStep - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.models.RunStep] + :return: An iterator like instance of EvaluatorVersion + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.types.EvaluatorVersion] :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "code": + evaluator_definition = { + "code_text": "str", + "type": "code", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # JSON input template for discriminator value "prompt": + evaluator_definition = { + "prompt_text": "str", + "type": "prompt", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # response body for status code(s): 200 + response == { + "categories": [ + "str" + ], + "created_at": "2020-02-20 00:00:00", + "created_by": "str", + "definition": evaluator_definition, + "evaluator_type": "str", + "modified_at": "2020-02-20 00:00:00", + "name": "str", + "version": "str", + "description": "str", + "display_name": "str", + "id": "str", + "metadata": { + "str": "str" + }, + "tags": { + "str": "str" + } + } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.RunStep]] = kwargs.pop("cls", None) + cls: ClsType[List[_types_models1.EvaluatorVersion]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3456,35 +11127,58 @@ def list( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(_continuation_token=None): + def prepare_request(next_link=None): + if not next_link: + + _request = build_beta_evaluators_list_request( + foundry_features=foundry_features, + type=type, + limit=limit, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - _request = build_run_steps_list_request( - thread_id=thread_id, - run_id=run_id, - include=include, - limit=limit, - order=order, - after=_continuation_token, - before=before, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) return _request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.RunStep], deserialized.get("data", [])) + list_of_elem = deserialized.get("value", []) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("last_id") or None, iter(list_of_elem) + return deserialized.get("nextLink") or None, iter(list_of_elem) - def get_next(_continuation_token=None): - _request = prepare_request(_continuation_token) + def get_next(next_link=None): + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access @@ -3494,43 +11188,105 @@ def get_next(_continuation_token=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) return pipeline_response return ItemPaged(get_next, extract_data) - -class FilesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.agents.AgentsClient`'s - :attr:`files` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AgentsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, *, purpose: Optional[Union[str, _models.FilePurpose]] = None, **kwargs: Any - ) -> _models.FileListResponse: - """Gets a list of previously uploaded files. - - :keyword purpose: The purpose of the file. Known values are: "assistants", "assistants_output", - and "vision". Default value is None. - :paramtype purpose: str or ~azure.ai.agents.models.FilePurpose - :return: FileListResponse. The FileListResponse is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.FileListResponse + def get_version( + self, + name: str, + version: str, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + **kwargs: Any + ) -> _types_models1.EvaluatorVersion: + """Get the specific version of the EvaluatorVersion. The service returns 404 Not Found error if + the EvaluatorVersion does not exist. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the EvaluatorVersion to retrieve. Required. + :type version: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + :return: EvaluatorVersion + :rtype: ~azure.ai.agents.types.EvaluatorVersion :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "code": + evaluator_definition = { + "code_text": "str", + "type": "code", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # JSON input template for discriminator value "prompt": + evaluator_definition = { + "prompt_text": "str", + "type": "prompt", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # response body for status code(s): 200 + response == { + "categories": [ + "str" + ], + "created_at": "2020-02-20 00:00:00", + "created_by": "str", + "definition": evaluator_definition, + "evaluator_type": "str", + "modified_at": "2020-02-20 00:00:00", + "name": "str", + "version": "str", + "description": "str", + "display_name": "str", + "id": "str", + "metadata": { + "str": "str" + }, + "tags": { + "str": "str" + } + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3543,10 +11299,12 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.FileListResponse] = kwargs.pop("cls", None) + cls: ClsType[_types_models1.EvaluatorVersion] = kwargs.pop("cls", None) - _request = build_files_list_request( - purpose=purpose, + _request = build_beta_evaluators_get_version_request( + name=name, + version=version, + foundry_features=foundry_features, api_version=self._config.api_version, headers=_headers, params=_params, @@ -3556,6 +11314,7 @@ def list( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -3570,33 +11329,508 @@ def list( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.FileListResponse, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + @distributed_trace + def delete_version( # pylint: disable=inconsistent-return-statements + self, + name: str, + version: str, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + **kwargs: Any + ) -> None: + """Delete the specific version of the EvaluatorVersion. The service returns 204 No Content if the + EvaluatorVersion was deleted successfully or if the EvaluatorVersion does not exist. + + :param name: The name of the resource. Required. + :type name: str + :param version: The version of the EvaluatorVersion to delete. Required. + :type version: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_beta_evaluators_delete_version_request( + name=name, + version=version, + foundry_features=foundry_features, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + @overload - def _upload_file(self, body: _models._models.UploadFileRequest, **kwargs: Any) -> _models.FileInfo: ... + def create_version( + self, + name: str, + evaluator_version: _types_models1.EvaluatorVersion, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models1.EvaluatorVersion: + """Create a new EvaluatorVersion with auto incremented version id. + + :param name: The name of the resource. Required. + :type name: str + :param evaluator_version: Required. + :type evaluator_version: ~azure.ai.agents.types.EvaluatorVersion + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: EvaluatorVersion + :rtype: ~azure.ai.agents.types.EvaluatorVersion + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "code": + evaluator_definition = { + "code_text": "str", + "type": "code", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # JSON input template for discriminator value "prompt": + evaluator_definition = { + "prompt_text": "str", + "type": "prompt", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # JSON input template you can fill out and use as your body input. + evaluator_version = { + "categories": [ + "str" + ], + "created_at": "2020-02-20 00:00:00", + "created_by": "str", + "definition": evaluator_definition, + "evaluator_type": "str", + "modified_at": "2020-02-20 00:00:00", + "name": "str", + "version": "str", + "description": "str", + "display_name": "str", + "id": "str", + "metadata": { + "str": "str" + }, + "tags": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "code": + evaluator_definition = { + "code_text": "str", + "type": "code", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # JSON input template for discriminator value "prompt": + evaluator_definition = { + "prompt_text": "str", + "type": "prompt", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # response body for status code(s): 201 + response == { + "categories": [ + "str" + ], + "created_at": "2020-02-20 00:00:00", + "created_by": "str", + "definition": evaluator_definition, + "evaluator_type": "str", + "modified_at": "2020-02-20 00:00:00", + "name": "str", + "version": "str", + "description": "str", + "display_name": "str", + "id": "str", + "metadata": { + "str": "str" + }, + "tags": { + "str": "str" + } + } + """ + @overload - def _upload_file(self, body: JSON, **kwargs: Any) -> _models.FileInfo: ... + def create_version( + self, + name: str, + evaluator_version: IO[bytes], + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models1.EvaluatorVersion: + """Create a new EvaluatorVersion with auto incremented version id. + + :param name: The name of the resource. Required. + :type name: str + :param evaluator_version: Required. + :type evaluator_version: IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: EvaluatorVersion + :rtype: ~azure.ai.agents.types.EvaluatorVersion + :raises ~azure.core.exceptions.HttpResponseError: - @distributed_trace - def _upload_file(self, body: Union[_models._models.UploadFileRequest, JSON], **kwargs: Any) -> _models.FileInfo: - """Uploads a file for use by other operations. + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "code": + evaluator_definition = { + "code_text": "str", + "type": "code", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # JSON input template for discriminator value "prompt": + evaluator_definition = { + "prompt_text": "str", + "type": "prompt", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # response body for status code(s): 201 + response == { + "categories": [ + "str" + ], + "created_at": "2020-02-20 00:00:00", + "created_by": "str", + "definition": evaluator_definition, + "evaluator_type": "str", + "modified_at": "2020-02-20 00:00:00", + "name": "str", + "version": "str", + "description": "str", + "display_name": "str", + "id": "str", + "metadata": { + "str": "str" + }, + "tags": { + "str": "str" + } + } + """ - :param body: Multipart body. Is either a UploadFileRequest type or a JSON type. Required. - :type body: ~azure.ai.agents.models._models.UploadFileRequest or JSON - :return: FileInfo. The FileInfo is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.FileInfo + @distributed_trace + def create_version( + self, + name: str, + evaluator_version: Union[_types_models1.EvaluatorVersion, IO[bytes]], + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + **kwargs: Any + ) -> _types_models1.EvaluatorVersion: + """Create a new EvaluatorVersion with auto incremented version id. + + :param name: The name of the resource. Required. + :type name: str + :param evaluator_version: Is either a EvaluatorVersion type or a IO[bytes] type. Required. + :type evaluator_version: ~azure.ai.agents.types.EvaluatorVersion or IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + :return: EvaluatorVersion + :rtype: ~azure.ai.agents.types.EvaluatorVersion :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "code": + evaluator_definition = { + "code_text": "str", + "type": "code", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # JSON input template for discriminator value "prompt": + evaluator_definition = { + "prompt_text": "str", + "type": "prompt", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # JSON input template you can fill out and use as your body input. + evaluator_version = { + "categories": [ + "str" + ], + "created_at": "2020-02-20 00:00:00", + "created_by": "str", + "definition": evaluator_definition, + "evaluator_type": "str", + "modified_at": "2020-02-20 00:00:00", + "name": "str", + "version": "str", + "description": "str", + "display_name": "str", + "id": "str", + "metadata": { + "str": "str" + }, + "tags": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "code": + evaluator_definition = { + "code_text": "str", + "type": "code", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # JSON input template for discriminator value "prompt": + evaluator_definition = { + "prompt_text": "str", + "type": "prompt", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # response body for status code(s): 201 + response == { + "categories": [ + "str" + ], + "created_at": "2020-02-20 00:00:00", + "created_by": "str", + "definition": evaluator_definition, + "evaluator_type": "str", + "modified_at": "2020-02-20 00:00:00", + "name": "str", + "version": "str", + "description": "str", + "display_name": "str", + "id": "str", + "metadata": { + "str": "str" + }, + "tags": { + "str": "str" + } + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3606,20 +11840,27 @@ def _upload_file(self, body: Union[_models._models.UploadFileRequest, JSON], **k } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.FileInfo] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_types_models1.EvaluatorVersion] = kwargs.pop("cls", None) - _body = body.as_dict() if isinstance(body, _Model) else body - _file_fields: list[str] = ["file"] - _data_fields: list[str] = ["purpose", "filename"] - _files, _data = prepare_multipart_form_data(_body, _file_fields, _data_fields) + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(evaluator_version, (IOBase, bytes)): + _content = evaluator_version + else: + _json = evaluator_version - _request = build_files_upload_file_request( + _request = build_beta_evaluators_create_version_request( + name=name, + foundry_features=foundry_features, + content_type=content_type, api_version=self._config.api_version, - files=_files, - data=_data, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -3628,6 +11869,7 @@ def _upload_file(self, body: Union[_models._models.UploadFileRequest, JSON], **k } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -3635,35 +11877,462 @@ def _upload_file(self, body: Union[_models._models.UploadFileRequest, JSON], **k response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [201]: if _stream: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.FileInfo, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def _delete_file(self, file_id: str, **kwargs: Any) -> _models._models.FileDeletionStatus: - """Delete a previously uploaded file. + @overload + def update_version( + self, + name: str, + version: str, + evaluator_version: _types_models1.EvaluatorVersion, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models1.EvaluatorVersion: + """Update an existing EvaluatorVersion with the given version id. + + :param name: The name of the resource. Required. + :type name: str + :param version: The version of the EvaluatorVersion to update. Required. + :type version: str + :param evaluator_version: Evaluator resource. Required. + :type evaluator_version: ~azure.ai.agents.types.EvaluatorVersion + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: EvaluatorVersion + :rtype: ~azure.ai.agents.types.EvaluatorVersion + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "code": + evaluator_definition = { + "code_text": "str", + "type": "code", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # JSON input template for discriminator value "prompt": + evaluator_definition = { + "prompt_text": "str", + "type": "prompt", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # JSON input template you can fill out and use as your body input. + evaluator_version = { + "categories": [ + "str" + ], + "created_at": "2020-02-20 00:00:00", + "created_by": "str", + "definition": evaluator_definition, + "evaluator_type": "str", + "modified_at": "2020-02-20 00:00:00", + "name": "str", + "version": "str", + "description": "str", + "display_name": "str", + "id": "str", + "metadata": { + "str": "str" + }, + "tags": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "code": + evaluator_definition = { + "code_text": "str", + "type": "code", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # JSON input template for discriminator value "prompt": + evaluator_definition = { + "prompt_text": "str", + "type": "prompt", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # response body for status code(s): 200 + response == { + "categories": [ + "str" + ], + "created_at": "2020-02-20 00:00:00", + "created_by": "str", + "definition": evaluator_definition, + "evaluator_type": "str", + "modified_at": "2020-02-20 00:00:00", + "name": "str", + "version": "str", + "description": "str", + "display_name": "str", + "id": "str", + "metadata": { + "str": "str" + }, + "tags": { + "str": "str" + } + } + """ + + @overload + def update_version( + self, + name: str, + version: str, + evaluator_version: IO[bytes], + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models1.EvaluatorVersion: + """Update an existing EvaluatorVersion with the given version id. + + :param name: The name of the resource. Required. + :type name: str + :param version: The version of the EvaluatorVersion to update. Required. + :type version: str + :param evaluator_version: Evaluator resource. Required. + :type evaluator_version: IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: EvaluatorVersion + :rtype: ~azure.ai.agents.types.EvaluatorVersion + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "code": + evaluator_definition = { + "code_text": "str", + "type": "code", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # JSON input template for discriminator value "prompt": + evaluator_definition = { + "prompt_text": "str", + "type": "prompt", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # response body for status code(s): 200 + response == { + "categories": [ + "str" + ], + "created_at": "2020-02-20 00:00:00", + "created_by": "str", + "definition": evaluator_definition, + "evaluator_type": "str", + "modified_at": "2020-02-20 00:00:00", + "name": "str", + "version": "str", + "description": "str", + "display_name": "str", + "id": "str", + "metadata": { + "str": "str" + }, + "tags": { + "str": "str" + } + } + """ - :param file_id: The ID of the file to delete. Required. - :type file_id: str - :return: FileDeletionStatus. The FileDeletionStatus is compatible with MutableMapping - :rtype: ~azure.ai.agents.models._models.FileDeletionStatus + @distributed_trace + def update_version( + self, + name: str, + version: str, + evaluator_version: Union[_types_models1.EvaluatorVersion, IO[bytes]], + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + **kwargs: Any + ) -> _types_models1.EvaluatorVersion: + """Update an existing EvaluatorVersion with the given version id. + + :param name: The name of the resource. Required. + :type name: str + :param version: The version of the EvaluatorVersion to update. Required. + :type version: str + :param evaluator_version: Evaluator resource. Is either a EvaluatorVersion type or a IO[bytes] + type. Required. + :type evaluator_version: ~azure.ai.agents.types.EvaluatorVersion or IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + :return: EvaluatorVersion + :rtype: ~azure.ai.agents.types.EvaluatorVersion :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "code": + evaluator_definition = { + "code_text": "str", + "type": "code", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # JSON input template for discriminator value "prompt": + evaluator_definition = { + "prompt_text": "str", + "type": "prompt", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # JSON input template you can fill out and use as your body input. + evaluator_version = { + "categories": [ + "str" + ], + "created_at": "2020-02-20 00:00:00", + "created_by": "str", + "definition": evaluator_definition, + "evaluator_type": "str", + "modified_at": "2020-02-20 00:00:00", + "name": "str", + "version": "str", + "description": "str", + "display_name": "str", + "id": "str", + "metadata": { + "str": "str" + }, + "tags": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "code": + evaluator_definition = { + "code_text": "str", + "type": "code", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # JSON input template for discriminator value "prompt": + evaluator_definition = { + "prompt_text": "str", + "type": "prompt", + "data_schema": { + "str": {} + }, + "init_parameters": { + "str": {} + }, + "metrics": { + "str": { + "desirable_direction": "str", + "is_primary": bool, + "max_value": 0.0, + "min_value": 0.0, + "type": "str" + } + } + } + + # response body for status code(s): 200 + response == { + "categories": [ + "str" + ], + "created_at": "2020-02-20 00:00:00", + "created_by": "str", + "definition": evaluator_definition, + "evaluator_type": "str", + "modified_at": "2020-02-20 00:00:00", + "name": "str", + "version": "str", + "description": "str", + "display_name": "str", + "id": "str", + "metadata": { + "str": "str" + }, + "tags": { + "str": "str" + } + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3673,14 +12342,28 @@ def _delete_file(self, file_id: str, **kwargs: Any) -> _models._models.FileDelet } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models._models.FileDeletionStatus] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_types_models1.EvaluatorVersion] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(evaluator_version, (IOBase, bytes)): + _content = evaluator_version + else: + _json = evaluator_version - _request = build_files_delete_file_request( - file_id=file_id, + _request = build_beta_evaluators_update_version_request( + name=name, + version=version, + foundry_features=foundry_features, + content_type=content_type, api_version=self._config.api_version, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -3689,6 +12372,7 @@ def _delete_file(self, file_id: str, **kwargs: Any) -> _models._models.FileDelet } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -3703,30 +12387,722 @@ def _delete_file(self, file_id: str, **kwargs: Any) -> _models._models.FileDelet except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize( - _models._models.FileDeletionStatus, response.json() # pylint: disable=protected-access - ) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def get(self, file_id: str, **kwargs: Any) -> _models.FileInfo: - """Returns information about a specific file. Does not retrieve file content. - :param file_id: The ID of the file to retrieve. Required. - :type file_id: str - :return: FileInfo. The FileInfo is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.FileInfo +class BetaInsightsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.agents.AIProjectClient`'s + :attr:`insights` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + def generate( + self, + insight: _types_models1.Insight, + *, + foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW]] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models1.Insight: + """Generate Insights. + + :param insight: Complete evaluation configuration including data source, evaluators, and result + settings. Required. + :type insight: ~azure.ai.agents.types.Insight + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. INSIGHTS_V1_PREVIEW. Default value is None. + :paramtype foundry_features: str or ~azure.ai.agents.models.INSIGHTS_V1_PREVIEW + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Insight + :rtype: ~azure.ai.agents.types.Insight + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "AgentClusterInsight": + insight_request = { + "agentName": "str", + "type": "AgentClusterInsight", + "modelConfiguration": { + "modelDeploymentName": "str" + } + } + + # JSON input template for discriminator value "EvaluationComparison": + insight_request = { + "baselineRunId": "str", + "evalId": "str", + "treatmentRunIds": [ + "str" + ], + "type": "EvaluationComparison" + } + + # JSON input template for discriminator value "EvaluationRunClusterInsight": + insight_request = { + "evalId": "str", + "runIds": [ + "str" + ], + "type": "EvaluationRunClusterInsight", + "modelConfiguration": { + "modelDeploymentName": "str" + } + } + + # JSON input template for discriminator value "AgentClusterInsight": + insight_result = { + "clusterInsight": { + "clusters": [ + { + "description": "str", + "id": "str", + "label": "str", + "suggestion": "str", + "suggestionTitle": "str", + "weight": 0, + "samples": [ + insight_sample + ], + "subClusters": [ + ... + ] + } + ], + "summary": { + "method": "str", + "sampleCount": 0, + "uniqueClusterCount": 0, + "uniqueSubclusterCount": 0, + "usage": { + "inputTokenUsage": 0, + "outputTokenUsage": 0, + "totalTokenUsage": 0 + } + }, + "coordinates": { + "str": { + "size": 0, + "x": 0, + "y": 0 + } + } + }, + "type": "AgentClusterInsight" + } + + # JSON input template for discriminator value "EvaluationComparison": + insight_result = { + "comparisons": [ + { + "baselineRunSummary": { + "average": 0.0, + "runId": "str", + "sampleCount": 0, + "standardDeviation": 0.0 + }, + "compareItems": [ + { + "deltaEstimate": 0.0, + "pValue": 0.0, + "treatmentEffect": "str", + "treatmentRunId": "str", + "treatmentRunSummary": { + "average": 0.0, + "runId": "str", + "sampleCount": 0, + "standardDeviation": 0.0 + } + } + ], + "evaluator": "str", + "metric": "str", + "testingCriteria": "str" + } + ], + "method": "str", + "type": "EvaluationComparison" + } + + # JSON input template you can fill out and use as your body input. + insight = { + "displayName": "str", + "id": "str", + "metadata": { + "createdAt": "2020-02-20 00:00:00", + "completedAt": "2020-02-20 00:00:00" + }, + "request": insight_request, + "state": "str", + "result": insight_result + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AgentClusterInsight": + insight_request = { + "agentName": "str", + "type": "AgentClusterInsight", + "modelConfiguration": { + "modelDeploymentName": "str" + } + } + + # JSON input template for discriminator value "EvaluationComparison": + insight_request = { + "baselineRunId": "str", + "evalId": "str", + "treatmentRunIds": [ + "str" + ], + "type": "EvaluationComparison" + } + + # JSON input template for discriminator value "EvaluationRunClusterInsight": + insight_request = { + "evalId": "str", + "runIds": [ + "str" + ], + "type": "EvaluationRunClusterInsight", + "modelConfiguration": { + "modelDeploymentName": "str" + } + } + + # JSON input template for discriminator value "AgentClusterInsight": + insight_result = { + "clusterInsight": { + "clusters": [ + { + "description": "str", + "id": "str", + "label": "str", + "suggestion": "str", + "suggestionTitle": "str", + "weight": 0, + "samples": [ + insight_sample + ], + "subClusters": [ + ... + ] + } + ], + "summary": { + "method": "str", + "sampleCount": 0, + "uniqueClusterCount": 0, + "uniqueSubclusterCount": 0, + "usage": { + "inputTokenUsage": 0, + "outputTokenUsage": 0, + "totalTokenUsage": 0 + } + }, + "coordinates": { + "str": { + "size": 0, + "x": 0, + "y": 0 + } + } + }, + "type": "AgentClusterInsight" + } + + # JSON input template for discriminator value "EvaluationComparison": + insight_result = { + "comparisons": [ + { + "baselineRunSummary": { + "average": 0.0, + "runId": "str", + "sampleCount": 0, + "standardDeviation": 0.0 + }, + "compareItems": [ + { + "deltaEstimate": 0.0, + "pValue": 0.0, + "treatmentEffect": "str", + "treatmentRunId": "str", + "treatmentRunSummary": { + "average": 0.0, + "runId": "str", + "sampleCount": 0, + "standardDeviation": 0.0 + } + } + ], + "evaluator": "str", + "metric": "str", + "testingCriteria": "str" + } + ], + "method": "str", + "type": "EvaluationComparison" + } + + # response body for status code(s): 201 + response == { + "displayName": "str", + "id": "str", + "metadata": { + "createdAt": "2020-02-20 00:00:00", + "completedAt": "2020-02-20 00:00:00" + }, + "request": insight_request, + "state": "str", + "result": insight_result + } + """ + + @overload + def generate( + self, + insight: IO[bytes], + *, + foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW]] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models1.Insight: + """Generate Insights. + + :param insight: Complete evaluation configuration including data source, evaluators, and result + settings. Required. + :type insight: IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. INSIGHTS_V1_PREVIEW. Default value is None. + :paramtype foundry_features: str or ~azure.ai.agents.models.INSIGHTS_V1_PREVIEW + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: Insight + :rtype: ~azure.ai.agents.types.Insight + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AgentClusterInsight": + insight_request = { + "agentName": "str", + "type": "AgentClusterInsight", + "modelConfiguration": { + "modelDeploymentName": "str" + } + } + + # JSON input template for discriminator value "EvaluationComparison": + insight_request = { + "baselineRunId": "str", + "evalId": "str", + "treatmentRunIds": [ + "str" + ], + "type": "EvaluationComparison" + } + + # JSON input template for discriminator value "EvaluationRunClusterInsight": + insight_request = { + "evalId": "str", + "runIds": [ + "str" + ], + "type": "EvaluationRunClusterInsight", + "modelConfiguration": { + "modelDeploymentName": "str" + } + } + + # JSON input template for discriminator value "AgentClusterInsight": + insight_result = { + "clusterInsight": { + "clusters": [ + { + "description": "str", + "id": "str", + "label": "str", + "suggestion": "str", + "suggestionTitle": "str", + "weight": 0, + "samples": [ + insight_sample + ], + "subClusters": [ + ... + ] + } + ], + "summary": { + "method": "str", + "sampleCount": 0, + "uniqueClusterCount": 0, + "uniqueSubclusterCount": 0, + "usage": { + "inputTokenUsage": 0, + "outputTokenUsage": 0, + "totalTokenUsage": 0 + } + }, + "coordinates": { + "str": { + "size": 0, + "x": 0, + "y": 0 + } + } + }, + "type": "AgentClusterInsight" + } + + # JSON input template for discriminator value "EvaluationComparison": + insight_result = { + "comparisons": [ + { + "baselineRunSummary": { + "average": 0.0, + "runId": "str", + "sampleCount": 0, + "standardDeviation": 0.0 + }, + "compareItems": [ + { + "deltaEstimate": 0.0, + "pValue": 0.0, + "treatmentEffect": "str", + "treatmentRunId": "str", + "treatmentRunSummary": { + "average": 0.0, + "runId": "str", + "sampleCount": 0, + "standardDeviation": 0.0 + } + } + ], + "evaluator": "str", + "metric": "str", + "testingCriteria": "str" + } + ], + "method": "str", + "type": "EvaluationComparison" + } + + # response body for status code(s): 201 + response == { + "displayName": "str", + "id": "str", + "metadata": { + "createdAt": "2020-02-20 00:00:00", + "completedAt": "2020-02-20 00:00:00" + }, + "request": insight_request, + "state": "str", + "result": insight_result + } + """ + + @distributed_trace + def generate( + self, + insight: Union[_types_models1.Insight, IO[bytes]], + *, + foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW]] = None, + **kwargs: Any + ) -> _types_models1.Insight: + """Generate Insights. + + :param insight: Complete evaluation configuration including data source, evaluators, and result + settings. Is either a Insight type or a IO[bytes] type. Required. + :type insight: ~azure.ai.agents.types.Insight or IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. INSIGHTS_V1_PREVIEW. Default value is None. + :paramtype foundry_features: str or ~azure.ai.agents.models.INSIGHTS_V1_PREVIEW + :return: Insight + :rtype: ~azure.ai.agents.types.Insight :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "AgentClusterInsight": + insight_request = { + "agentName": "str", + "type": "AgentClusterInsight", + "modelConfiguration": { + "modelDeploymentName": "str" + } + } + + # JSON input template for discriminator value "EvaluationComparison": + insight_request = { + "baselineRunId": "str", + "evalId": "str", + "treatmentRunIds": [ + "str" + ], + "type": "EvaluationComparison" + } + + # JSON input template for discriminator value "EvaluationRunClusterInsight": + insight_request = { + "evalId": "str", + "runIds": [ + "str" + ], + "type": "EvaluationRunClusterInsight", + "modelConfiguration": { + "modelDeploymentName": "str" + } + } + + # JSON input template for discriminator value "AgentClusterInsight": + insight_result = { + "clusterInsight": { + "clusters": [ + { + "description": "str", + "id": "str", + "label": "str", + "suggestion": "str", + "suggestionTitle": "str", + "weight": 0, + "samples": [ + insight_sample + ], + "subClusters": [ + ... + ] + } + ], + "summary": { + "method": "str", + "sampleCount": 0, + "uniqueClusterCount": 0, + "uniqueSubclusterCount": 0, + "usage": { + "inputTokenUsage": 0, + "outputTokenUsage": 0, + "totalTokenUsage": 0 + } + }, + "coordinates": { + "str": { + "size": 0, + "x": 0, + "y": 0 + } + } + }, + "type": "AgentClusterInsight" + } + + # JSON input template for discriminator value "EvaluationComparison": + insight_result = { + "comparisons": [ + { + "baselineRunSummary": { + "average": 0.0, + "runId": "str", + "sampleCount": 0, + "standardDeviation": 0.0 + }, + "compareItems": [ + { + "deltaEstimate": 0.0, + "pValue": 0.0, + "treatmentEffect": "str", + "treatmentRunId": "str", + "treatmentRunSummary": { + "average": 0.0, + "runId": "str", + "sampleCount": 0, + "standardDeviation": 0.0 + } + } + ], + "evaluator": "str", + "metric": "str", + "testingCriteria": "str" + } + ], + "method": "str", + "type": "EvaluationComparison" + } + + # JSON input template you can fill out and use as your body input. + insight = { + "displayName": "str", + "id": "str", + "metadata": { + "createdAt": "2020-02-20 00:00:00", + "completedAt": "2020-02-20 00:00:00" + }, + "request": insight_request, + "state": "str", + "result": insight_result + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AgentClusterInsight": + insight_request = { + "agentName": "str", + "type": "AgentClusterInsight", + "modelConfiguration": { + "modelDeploymentName": "str" + } + } + + # JSON input template for discriminator value "EvaluationComparison": + insight_request = { + "baselineRunId": "str", + "evalId": "str", + "treatmentRunIds": [ + "str" + ], + "type": "EvaluationComparison" + } + + # JSON input template for discriminator value "EvaluationRunClusterInsight": + insight_request = { + "evalId": "str", + "runIds": [ + "str" + ], + "type": "EvaluationRunClusterInsight", + "modelConfiguration": { + "modelDeploymentName": "str" + } + } + + # JSON input template for discriminator value "AgentClusterInsight": + insight_result = { + "clusterInsight": { + "clusters": [ + { + "description": "str", + "id": "str", + "label": "str", + "suggestion": "str", + "suggestionTitle": "str", + "weight": 0, + "samples": [ + insight_sample + ], + "subClusters": [ + ... + ] + } + ], + "summary": { + "method": "str", + "sampleCount": 0, + "uniqueClusterCount": 0, + "uniqueSubclusterCount": 0, + "usage": { + "inputTokenUsage": 0, + "outputTokenUsage": 0, + "totalTokenUsage": 0 + } + }, + "coordinates": { + "str": { + "size": 0, + "x": 0, + "y": 0 + } + } + }, + "type": "AgentClusterInsight" + } + + # JSON input template for discriminator value "EvaluationComparison": + insight_result = { + "comparisons": [ + { + "baselineRunSummary": { + "average": 0.0, + "runId": "str", + "sampleCount": 0, + "standardDeviation": 0.0 + }, + "compareItems": [ + { + "deltaEstimate": 0.0, + "pValue": 0.0, + "treatmentEffect": "str", + "treatmentRunId": "str", + "treatmentRunSummary": { + "average": 0.0, + "runId": "str", + "sampleCount": 0, + "standardDeviation": 0.0 + } + } + ], + "evaluator": "str", + "metric": "str", + "testingCriteria": "str" + } + ], + "method": "str", + "type": "EvaluationComparison" + } + + # response body for status code(s): 201 + response == { + "displayName": "str", + "id": "str", + "metadata": { + "createdAt": "2020-02-20 00:00:00", + "completedAt": "2020-02-20 00:00:00" + }, + "request": insight_request, + "state": "str", + "result": insight_result + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3736,14 +13112,26 @@ def get(self, file_id: str, **kwargs: Any) -> _models.FileInfo: } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.FileInfo] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_types_models1.Insight] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(insight, (IOBase, bytes)): + _content = insight + else: + _json = insight - _request = build_files_get_request( - file_id=file_id, + _request = build_beta_insights_generate_request( + foundry_features=foundry_features, + content_type=content_type, api_version=self._config.api_version, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -3752,6 +13140,7 @@ def get(self, file_id: str, **kwargs: Any) -> _models.FileInfo: } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -3759,20 +13148,26 @@ def get(self, file_id: str, **kwargs: Any) -> _models.FileInfo: response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [201]: if _stream: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) + error = self._deserialize.failsafe_deserialize( + _types_models1.ApiErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.FileInfo, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -3780,14 +13175,151 @@ def get(self, file_id: str, **kwargs: Any) -> _models.FileInfo: return deserialized # type: ignore @distributed_trace - def _get_file_content(self, file_id: str, **kwargs: Any) -> Iterator[bytes]: - """Retrieves the raw content of a specific file. - - :param file_id: The ID of the file to retrieve. Required. - :type file_id: str - :return: Iterator[bytes] - :rtype: Iterator[bytes] + def get( + self, + id: str, + *, + foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW]] = None, + include_coordinates: Optional[bool] = None, + **kwargs: Any + ) -> _types_models1.Insight: + """Get a specific insight by Id. + + :param id: The unique identifier for the insights report. Required. + :type id: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. INSIGHTS_V1_PREVIEW. Default value is None. + :paramtype foundry_features: str or ~azure.ai.agents.models.INSIGHTS_V1_PREVIEW + :keyword include_coordinates: Whether to include coordinates for visualization in the response. + Defaults to false. Default value is None. + :paramtype include_coordinates: bool + :return: Insight + :rtype: ~azure.ai.agents.types.Insight :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AgentClusterInsight": + insight_request = { + "agentName": "str", + "type": "AgentClusterInsight", + "modelConfiguration": { + "modelDeploymentName": "str" + } + } + + # JSON input template for discriminator value "EvaluationComparison": + insight_request = { + "baselineRunId": "str", + "evalId": "str", + "treatmentRunIds": [ + "str" + ], + "type": "EvaluationComparison" + } + + # JSON input template for discriminator value "EvaluationRunClusterInsight": + insight_request = { + "evalId": "str", + "runIds": [ + "str" + ], + "type": "EvaluationRunClusterInsight", + "modelConfiguration": { + "modelDeploymentName": "str" + } + } + + # JSON input template for discriminator value "AgentClusterInsight": + insight_result = { + "clusterInsight": { + "clusters": [ + { + "description": "str", + "id": "str", + "label": "str", + "suggestion": "str", + "suggestionTitle": "str", + "weight": 0, + "samples": [ + insight_sample + ], + "subClusters": [ + ... + ] + } + ], + "summary": { + "method": "str", + "sampleCount": 0, + "uniqueClusterCount": 0, + "uniqueSubclusterCount": 0, + "usage": { + "inputTokenUsage": 0, + "outputTokenUsage": 0, + "totalTokenUsage": 0 + } + }, + "coordinates": { + "str": { + "size": 0, + "x": 0, + "y": 0 + } + } + }, + "type": "AgentClusterInsight" + } + + # JSON input template for discriminator value "EvaluationComparison": + insight_result = { + "comparisons": [ + { + "baselineRunSummary": { + "average": 0.0, + "runId": "str", + "sampleCount": 0, + "standardDeviation": 0.0 + }, + "compareItems": [ + { + "deltaEstimate": 0.0, + "pValue": 0.0, + "treatmentEffect": "str", + "treatmentRunId": "str", + "treatmentRunSummary": { + "average": 0.0, + "runId": "str", + "sampleCount": 0, + "standardDeviation": 0.0 + } + } + ], + "evaluator": "str", + "metric": "str", + "testingCriteria": "str" + } + ], + "method": "str", + "type": "EvaluationComparison" + } + + # response body for status code(s): 200 + response == { + "displayName": "str", + "id": "str", + "metadata": { + "createdAt": "2020-02-20 00:00:00", + "completedAt": "2020-02-20 00:00:00" + }, + "request": insight_request, + "state": "str", + "result": insight_result + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3800,10 +13332,12 @@ def _get_file_content(self, file_id: str, **kwargs: Any) -> Iterator[bytes]: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[_types_models1.Insight] = kwargs.pop("cls", None) - _request = build_files_get_file_content_request( - file_id=file_id, + _request = build_beta_insights_get_request( + id=id, + foundry_features=foundry_features, + include_coordinates=include_coordinates, api_version=self._config.api_version, headers=_headers, params=_params, @@ -3813,7 +13347,8 @@ def _get_file_content(self, file_id: str, **kwargs: Any) -> Iterator[bytes]: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", True) + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -3827,64 +13362,186 @@ def _get_file_content(self, file_id: str, **kwargs: Any) -> Iterator[bytes]: except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) + error = self._deserialize.failsafe_deserialize( + _types_models1.ApiErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error) - deserialized = response.iter_bytes() + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - -class VectorStoresOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.agents.AgentsClient`'s - :attr:`vector_stores` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AgentsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, *, - limit: Optional[int] = None, - order: Optional[Union[str, _models.ListSortOrder]] = None, - before: Optional[str] = None, + foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW]] = None, + type: Optional[types.InsightType] = None, + eval_id: Optional[str] = None, + run_id: Optional[str] = None, + agent_name: Optional[str] = None, + include_coordinates: Optional[bool] = None, **kwargs: Any - ) -> ItemPaged["_models.VectorStore"]: - """Returns a list of vector stores. - - :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and - 100, and the default is 20. Default value is None. - :paramtype limit: int - :keyword order: Sort order by the created_at timestamp of the objects. asc for ascending order - and desc for descending order. Known values are: "asc" and "desc". Default value is None. - :paramtype order: str or ~azure.ai.agents.models.ListSortOrder - :keyword 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. Default value is None. - :paramtype before: str - :return: An iterator like instance of VectorStore - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.models.VectorStore] + ) -> ItemPaged["_types_models1.Insight"]: + """List all insights in reverse chronological order (newest first). + + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. INSIGHTS_V1_PREVIEW. Default value is None. + :paramtype foundry_features: str or ~azure.ai.agents.models.INSIGHTS_V1_PREVIEW + :keyword type: Filter by the type of analysis. Known values are: "EvaluationRunClusterInsight", + "AgentClusterInsight", and "EvaluationComparison". Default value is None. + :paramtype type: str or ~azure.ai.agents.models.InsightType + :keyword eval_id: Filter by the evaluation ID. Default value is None. + :paramtype eval_id: str + :keyword run_id: Filter by the evaluation run ID. Default value is None. + :paramtype run_id: str + :keyword agent_name: Filter by the agent name. Default value is None. + :paramtype agent_name: str + :keyword include_coordinates: Whether to include coordinates for visualization in the response. + Defaults to false. Default value is None. + :paramtype include_coordinates: bool + :return: An iterator like instance of Insight + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.types.Insight] :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AgentClusterInsight": + insight_request = { + "agentName": "str", + "type": "AgentClusterInsight", + "modelConfiguration": { + "modelDeploymentName": "str" + } + } + + # JSON input template for discriminator value "EvaluationComparison": + insight_request = { + "baselineRunId": "str", + "evalId": "str", + "treatmentRunIds": [ + "str" + ], + "type": "EvaluationComparison" + } + + # JSON input template for discriminator value "EvaluationRunClusterInsight": + insight_request = { + "evalId": "str", + "runIds": [ + "str" + ], + "type": "EvaluationRunClusterInsight", + "modelConfiguration": { + "modelDeploymentName": "str" + } + } + + # JSON input template for discriminator value "AgentClusterInsight": + insight_result = { + "clusterInsight": { + "clusters": [ + { + "description": "str", + "id": "str", + "label": "str", + "suggestion": "str", + "suggestionTitle": "str", + "weight": 0, + "samples": [ + insight_sample + ], + "subClusters": [ + ... + ] + } + ], + "summary": { + "method": "str", + "sampleCount": 0, + "uniqueClusterCount": 0, + "uniqueSubclusterCount": 0, + "usage": { + "inputTokenUsage": 0, + "outputTokenUsage": 0, + "totalTokenUsage": 0 + } + }, + "coordinates": { + "str": { + "size": 0, + "x": 0, + "y": 0 + } + } + }, + "type": "AgentClusterInsight" + } + + # JSON input template for discriminator value "EvaluationComparison": + insight_result = { + "comparisons": [ + { + "baselineRunSummary": { + "average": 0.0, + "runId": "str", + "sampleCount": 0, + "standardDeviation": 0.0 + }, + "compareItems": [ + { + "deltaEstimate": 0.0, + "pValue": 0.0, + "treatmentEffect": "str", + "treatmentRunId": "str", + "treatmentRunSummary": { + "average": 0.0, + "runId": "str", + "sampleCount": 0, + "standardDeviation": 0.0 + } + } + ], + "evaluator": "str", + "metric": "str", + "testingCriteria": "str" + } + ], + "method": "str", + "type": "EvaluationComparison" + } + + # response body for status code(s): 200 + response == { + "displayName": "str", + "id": "str", + "metadata": { + "createdAt": "2020-02-20 00:00:00", + "completedAt": "2020-02-20 00:00:00" + }, + "request": insight_request, + "state": "str", + "result": insight_result + } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.VectorStore]] = kwargs.pop("cls", None) + cls: ClsType[List[_types_models1.Insight]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3894,32 +13551,61 @@ def list( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(_continuation_token=None): + def prepare_request(next_link=None): + if not next_link: + + _request = build_beta_insights_list_request( + foundry_features=foundry_features, + type=type, + eval_id=eval_id, + run_id=run_id, + agent_name=agent_name, + include_coordinates=include_coordinates, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - _request = build_vector_stores_list_request( - limit=limit, - order=order, - after=_continuation_token, - before=before, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) return _request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.VectorStore], deserialized.get("data", [])) + list_of_elem = deserialized.get("value", []) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("last_id") or None, iter(list_of_elem) + return deserialized.get("nextLink") or None, iter(list_of_elem) - def get_next(_continuation_token=None): - _request = prepare_request(_continuation_token) + def get_next(next_link=None): + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access @@ -3929,200 +13615,325 @@ def get_next(_continuation_token=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) + error = self._deserialize.failsafe_deserialize( + _types_models1.ApiErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error) return pipeline_response return ItemPaged(get_next, extract_data) + +class BetaMemoryStoresOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.agents.AIProjectClient`'s + :attr:`memory_stores` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @overload def create( self, + name: str, + definition: _types_models1.MemoryStoreDefinition, + description: Optional[str] = None, + metadata: Optional[dict[str, str]] = None, *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], content_type: str = "application/json", - file_ids: Optional[List[str]] = None, - name: Optional[str] = None, - store_configuration: Optional[_models.VectorStoreConfiguration] = None, - expires_after: Optional[_models.VectorStoreExpirationPolicy] = None, - chunking_strategy: Optional[_models.VectorStoreChunkingStrategyRequest] = None, - metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> _models.VectorStore: - """Creates a vector store. - + ) -> _types_models1.MemoryStoreDetails: + """Create a memory store. + + :param name: The name of the memory store. Required. + :type name: str + :param definition: The memory store definition. Required. + :type definition: ~azure.ai.agents.types.MemoryStoreDefinition + :param description: A human-readable description of the memory store. Default value is None. + :type description: str + :param metadata: Arbitrary key-value metadata to associate with the memory store. Default value + is None. + :type metadata: dict[str, str] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword file_ids: A list of file IDs that the vector store should use. Useful for tools like - ``file_search`` that can access files. Default value is None. - :paramtype file_ids: list[str] - :keyword name: The name of the vector store. Default value is None. - :paramtype name: str - :keyword store_configuration: The vector store configuration, used when vector store is created - from Azure asset URIs. Default value is None. - :paramtype store_configuration: ~azure.ai.agents.models.VectorStoreConfiguration - :keyword expires_after: Details on when this vector store expires. Default value is None. - :paramtype expires_after: ~azure.ai.agents.models.VectorStoreExpirationPolicy - :keyword chunking_strategy: 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. Default value is None. - :paramtype chunking_strategy: ~azure.ai.agents.models.VectorStoreChunkingStrategyRequest - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: VectorStore. The VectorStore is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.VectorStore + :return: MemoryStoreDetails + :rtype: ~azure.ai.agents.types.MemoryStoreDetails :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "default": + memory_store_definition = { + "chat_model": "str", + "embedding_model": "str", + "kind": "default", + "options": { + "chat_summary_enabled": bool, + "user_profile_enabled": bool, + "user_profile_details": "str" + } + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "definition": memory_store_definition, + "id": "str", + "name": "str", + "object": "str", + "updated_at": "2020-02-20 00:00:00", + "description": "str", + "metadata": { + "str": "str" + } + } """ @overload - def create(self, body: JSON, *, content_type: str = "application/json", **kwargs: Any) -> _models.VectorStore: - """Creates a vector store. + def create( + self, + body: JSON, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models1.MemoryStoreDetails: + """Create a memory store. :param body: Required. :type body: JSON + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: VectorStore. The VectorStore is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.VectorStore + :return: MemoryStoreDetails + :rtype: ~azure.ai.agents.types.MemoryStoreDetails :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "kind": + + # JSON input template for discriminator value "default": + memory_store_definition = { + "chat_model": "str", + "embedding_model": "str", + "kind": "default", + "options": { + "chat_summary_enabled": bool, + "user_profile_enabled": bool, + "user_profile_details": "str" + } + } + + # JSON input template you can fill out and use as your body input. + body = { + "definition": memory_store_definition, + "name": "str", + "description": "str", + "metadata": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "default": + memory_store_definition = { + "chat_model": "str", + "embedding_model": "str", + "kind": "default", + "options": { + "chat_summary_enabled": bool, + "user_profile_enabled": bool, + "user_profile_details": "str" + } + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "definition": memory_store_definition, + "id": "str", + "name": "str", + "object": "str", + "updated_at": "2020-02-20 00:00:00", + "description": "str", + "metadata": { + "str": "str" + } + } """ @overload - def create(self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any) -> _models.VectorStore: - """Creates a vector store. + def create( + self, + body: IO[bytes], + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models1.MemoryStoreDetails: + """Create a memory store. :param body: Required. :type body: IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: VectorStore. The VectorStore is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.VectorStore + :return: MemoryStoreDetails + :rtype: ~azure.ai.agents.types.MemoryStoreDetails :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "default": + memory_store_definition = { + "chat_model": "str", + "embedding_model": "str", + "kind": "default", + "options": { + "chat_summary_enabled": bool, + "user_profile_enabled": bool, + "user_profile_details": "str" + } + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "definition": memory_store_definition, + "id": "str", + "name": "str", + "object": "str", + "updated_at": "2020-02-20 00:00:00", + "description": "str", + "metadata": { + "str": "str" + } + } """ @distributed_trace def create( self, + name: str = _Unset, + definition: _types_models1.MemoryStoreDefinition = _Unset, body: Union[JSON, IO[bytes]] = _Unset, - *, - file_ids: Optional[List[str]] = None, - name: Optional[str] = None, - store_configuration: Optional[_models.VectorStoreConfiguration] = None, - expires_after: Optional[_models.VectorStoreExpirationPolicy] = None, - chunking_strategy: Optional[_models.VectorStoreChunkingStrategyRequest] = None, + description: Optional[str] = None, metadata: Optional[dict[str, str]] = None, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], **kwargs: Any - ) -> _models.VectorStore: - """Creates a vector store. + ) -> _types_models1.MemoryStoreDetails: + """Create a memory store. + :param name: The name of the memory store. Required. + :type name: str + :param definition: The memory store definition. Required. + :type definition: ~azure.ai.agents.types.MemoryStoreDefinition :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :keyword file_ids: A list of file IDs that the vector store should use. Useful for tools like - ``file_search`` that can access files. Default value is None. - :paramtype file_ids: list[str] - :keyword name: The name of the vector store. Default value is None. - :paramtype name: str - :keyword store_configuration: The vector store configuration, used when vector store is created - from Azure asset URIs. Default value is None. - :paramtype store_configuration: ~azure.ai.agents.models.VectorStoreConfiguration - :keyword expires_after: Details on when this vector store expires. Default value is None. - :paramtype expires_after: ~azure.ai.agents.models.VectorStoreExpirationPolicy - :keyword chunking_strategy: 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. Default value is None. - :paramtype chunking_strategy: ~azure.ai.agents.models.VectorStoreChunkingStrategyRequest - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: VectorStore. The VectorStore is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.VectorStore + :param description: A human-readable description of the memory store. Default value is None. + :type description: str + :param metadata: Arbitrary key-value metadata to associate with the memory store. Default value + is None. + :type metadata: dict[str, str] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW + :return: MemoryStoreDetails + :rtype: ~azure.ai.agents.types.MemoryStoreDetails :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VectorStore] = kwargs.pop("cls", None) - - if body is _Unset: - body = { - "chunking_strategy": chunking_strategy, - "configuration": store_configuration, - "expires_after": expires_after, - "file_ids": file_ids, - "metadata": metadata, - "name": name, - } - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_vector_stores_create_request( - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) - - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.VectorStore, response.json()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get(self, vector_store_id: str, **kwargs: Any) -> _models.VectorStore: - """Returns the vector store object matching the specified ID. - - :param vector_store_id: Identifier of the vector store. Required. - :type vector_store_id: str - :return: VectorStore. The VectorStore is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.VectorStore - :raises ~azure.core.exceptions.HttpResponseError: + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "kind": + + # JSON input template for discriminator value "default": + memory_store_definition = { + "chat_model": "str", + "embedding_model": "str", + "kind": "default", + "options": { + "chat_summary_enabled": bool, + "user_profile_enabled": bool, + "user_profile_details": "str" + } + } + + # JSON input template you can fill out and use as your body input. + body = { + "definition": memory_store_definition, + "name": "str", + "description": "str", + "metadata": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "default": + memory_store_definition = { + "chat_model": "str", + "embedding_model": "str", + "kind": "default", + "options": { + "chat_summary_enabled": bool, + "user_profile_enabled": bool, + "user_profile_details": "str" + } + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "definition": memory_store_definition, + "id": "str", + "name": "str", + "object": "str", + "updated_at": "2020-02-20 00:00:00", + "description": "str", + "metadata": { + "str": "str" + } + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4132,14 +13943,33 @@ def get(self, vector_store_id: str, **kwargs: Any) -> _models.VectorStore: } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.VectorStore] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_types_models1.MemoryStoreDetails] = kwargs.pop("cls", None) + + if body is _Unset: + if name is _Unset: + raise TypeError("missing required argument: name") + if definition is _Unset: + raise TypeError("missing required argument: definition") + body = {"definition": definition, "description": description, "metadata": metadata, "name": name} + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body - _request = build_vector_stores_get_request( - vector_store_id=vector_store_id, + _request = build_beta_memory_stores_create_request( + foundry_features=foundry_features, + content_type=content_type, api_version=self._config.api_version, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -4148,6 +13978,7 @@ def get(self, vector_store_id: str, **kwargs: Any) -> _models.VectorStore: } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -4162,13 +13993,19 @@ def get(self, vector_store_id: str, **kwargs: Any) -> _models.VectorStore: except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) + error = self._deserialize.failsafe_deserialize( + _types_models1.ApiErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.VectorStore, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -4176,102 +14013,262 @@ def get(self, vector_store_id: str, **kwargs: Any) -> _models.VectorStore: return deserialized # type: ignore @overload - def modify( + def update( self, - vector_store_id: str, + name: str, + description: Optional[str] = None, + metadata: Optional[dict[str, str]] = None, *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], content_type: str = "application/json", - name: Optional[str] = None, - expires_after: Optional[_models.VectorStoreExpirationPolicy] = None, - metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> _models.VectorStore: - """Modifies an existing vector store. - - :param vector_store_id: Identifier of the vector store. Required. - :type vector_store_id: str + ) -> _types_models1.MemoryStoreDetails: + """Update a memory store. + + :param name: The name of the memory store to update. Required. + :type name: str + :param description: A human-readable description of the memory store. Default value is None. + :type description: str + :param metadata: Arbitrary key-value metadata to associate with the memory store. Default value + is None. + :type metadata: dict[str, str] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword name: The name of the vector store. Default value is None. - :paramtype name: str - :keyword expires_after: Details on when this vector store expires. Default value is None. - :paramtype expires_after: ~azure.ai.agents.models.VectorStoreExpirationPolicy - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: VectorStore. The VectorStore is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.VectorStore + :return: MemoryStoreDetails + :rtype: ~azure.ai.agents.types.MemoryStoreDetails :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "default": + memory_store_definition = { + "chat_model": "str", + "embedding_model": "str", + "kind": "default", + "options": { + "chat_summary_enabled": bool, + "user_profile_enabled": bool, + "user_profile_details": "str" + } + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "definition": memory_store_definition, + "id": "str", + "name": "str", + "object": "str", + "updated_at": "2020-02-20 00:00:00", + "description": "str", + "metadata": { + "str": "str" + } + } """ @overload - def modify( - self, vector_store_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.VectorStore: - """Modifies an existing vector store. + def update( + self, + name: str, + body: JSON, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models1.MemoryStoreDetails: + """Update a memory store. - :param vector_store_id: Identifier of the vector store. Required. - :type vector_store_id: str + :param name: The name of the memory store to update. Required. + :type name: str :param body: Required. :type body: JSON + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: VectorStore. The VectorStore is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.VectorStore + :return: MemoryStoreDetails + :rtype: ~azure.ai.agents.types.MemoryStoreDetails :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "description": "str", + "metadata": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "default": + memory_store_definition = { + "chat_model": "str", + "embedding_model": "str", + "kind": "default", + "options": { + "chat_summary_enabled": bool, + "user_profile_enabled": bool, + "user_profile_details": "str" + } + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "definition": memory_store_definition, + "id": "str", + "name": "str", + "object": "str", + "updated_at": "2020-02-20 00:00:00", + "description": "str", + "metadata": { + "str": "str" + } + } """ @overload - def modify( - self, vector_store_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.VectorStore: - """Modifies an existing vector store. + def update( + self, + name: str, + body: IO[bytes], + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models1.MemoryStoreDetails: + """Update a memory store. - :param vector_store_id: Identifier of the vector store. Required. - :type vector_store_id: str + :param name: The name of the memory store to update. Required. + :type name: str :param body: Required. :type body: IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: VectorStore. The VectorStore is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.VectorStore + :return: MemoryStoreDetails + :rtype: ~azure.ai.agents.types.MemoryStoreDetails :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "default": + memory_store_definition = { + "chat_model": "str", + "embedding_model": "str", + "kind": "default", + "options": { + "chat_summary_enabled": bool, + "user_profile_enabled": bool, + "user_profile_details": "str" + } + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "definition": memory_store_definition, + "id": "str", + "name": "str", + "object": "str", + "updated_at": "2020-02-20 00:00:00", + "description": "str", + "metadata": { + "str": "str" + } + } """ @distributed_trace - def modify( + def update( self, - vector_store_id: str, + name: str, body: Union[JSON, IO[bytes]] = _Unset, - *, - name: Optional[str] = None, - expires_after: Optional[_models.VectorStoreExpirationPolicy] = None, + description: Optional[str] = None, metadata: Optional[dict[str, str]] = None, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], **kwargs: Any - ) -> _models.VectorStore: - """Modifies an existing vector store. + ) -> _types_models1.MemoryStoreDetails: + """Update a memory store. - :param vector_store_id: Identifier of the vector store. Required. - :type vector_store_id: str + :param name: The name of the memory store to update. Required. + :type name: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :keyword name: The name of the vector store. Default value is None. - :paramtype name: str - :keyword expires_after: Details on when this vector store expires. Default value is None. - :paramtype expires_after: ~azure.ai.agents.models.VectorStoreExpirationPolicy - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: VectorStore. The VectorStore is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.VectorStore + :param description: A human-readable description of the memory store. Default value is None. + :type description: str + :param metadata: Arbitrary key-value metadata to associate with the memory store. Default value + is None. + :type metadata: dict[str, str] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW + :return: MemoryStoreDetails + :rtype: ~azure.ai.agents.types.MemoryStoreDetails :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "description": "str", + "metadata": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "default": + memory_store_definition = { + "chat_model": "str", + "embedding_model": "str", + "kind": "default", + "options": { + "chat_summary_enabled": bool, + "user_profile_enabled": bool, + "user_profile_details": "str" + } + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "definition": memory_store_definition, + "id": "str", + "name": "str", + "object": "str", + "updated_at": "2020-02-20 00:00:00", + "description": "str", + "metadata": { + "str": "str" + } + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4285,22 +14282,25 @@ def modify( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VectorStore] = kwargs.pop("cls", None) + cls: ClsType[_types_models1.MemoryStoreDetails] = kwargs.pop("cls", None) if body is _Unset: - body = {"expires_after": expires_after, "metadata": metadata, "name": name} + body = {"description": description, "metadata": metadata} body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" + _json = None _content = None if isinstance(body, (IOBase, bytes)): _content = body else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _json = body - _request = build_vector_stores_modify_request( - vector_store_id=vector_store_id, + _request = build_beta_memory_stores_update_request( + name=name, + foundry_features=foundry_features, content_type=content_type, api_version=self._config.api_version, + json=_json, content=_content, headers=_headers, params=_params, @@ -4310,6 +14310,7 @@ def modify( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -4324,13 +14325,19 @@ def modify( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) + error = self._deserialize.failsafe_deserialize( + _types_models1.ApiErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.VectorStore, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -4338,15 +14345,51 @@ def modify( return deserialized # type: ignore @distributed_trace - def _delete_vector_store(self, vector_store_id: str, **kwargs: Any) -> _models._models.VectorStoreDeletionStatus: - """Deletes the vector store object matching the specified ID. - - :param vector_store_id: Identifier of the vector store. Required. - :type vector_store_id: str - :return: VectorStoreDeletionStatus. The VectorStoreDeletionStatus is compatible with - MutableMapping - :rtype: ~azure.ai.agents.models._models.VectorStoreDeletionStatus + def get( + self, name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], **kwargs: Any + ) -> _types_models1.MemoryStoreDetails: + """Retrieve a memory store. + + :param name: The name of the memory store to retrieve. Required. + :type name: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW + :return: MemoryStoreDetails + :rtype: ~azure.ai.agents.types.MemoryStoreDetails :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "default": + memory_store_definition = { + "chat_model": "str", + "embedding_model": "str", + "kind": "default", + "options": { + "chat_summary_enabled": bool, + "user_profile_enabled": bool, + "user_profile_details": "str" + } + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "definition": memory_store_definition, + "id": "str", + "name": "str", + "object": "str", + "updated_at": "2020-02-20 00:00:00", + "description": "str", + "metadata": { + "str": "str" + } + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4359,10 +14402,11 @@ def _delete_vector_store(self, vector_store_id: str, **kwargs: Any) -> _models._ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models._models.VectorStoreDeletionStatus] = kwargs.pop("cls", None) + cls: ClsType[_types_models1.MemoryStoreDetails] = kwargs.pop("cls", None) - _request = build_vector_stores_delete_vector_store_request( - vector_store_id=vector_store_id, + _request = build_beta_memory_stores_get_request( + name=name, + foundry_features=foundry_features, api_version=self._config.api_version, headers=_headers, params=_params, @@ -4372,6 +14416,7 @@ def _delete_vector_store(self, vector_store_id: str, **kwargs: Any) -> _models._ } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -4386,76 +14431,94 @@ def _delete_vector_store(self, vector_store_id: str, **kwargs: Any) -> _models._ except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) + error = self._deserialize.failsafe_deserialize( + _types_models1.ApiErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize( - _models._models.VectorStoreDeletionStatus, response.json() # pylint: disable=protected-access - ) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - -class VectorStoreFilesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.agents.AgentsClient`'s - :attr:`vector_store_files` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AgentsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, - vector_store_id: str, *, - filter: Optional[Union[str, _models.VectorStoreFileStatusFilter]] = None, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], limit: Optional[int] = None, - order: Optional[Union[str, _models.ListSortOrder]] = None, + order: Optional[types.PageOrder] = None, before: Optional[str] = None, **kwargs: Any - ) -> ItemPaged["_models.VectorStoreFile"]: - """Returns a list of vector store files. - - :param vector_store_id: Identifier of the vector store. Required. - :type vector_store_id: str - :keyword filter: Filter by file status. Known values are: "in_progress", "completed", "failed", - and "cancelled". Default value is None. - :paramtype filter: str or ~azure.ai.agents.models.VectorStoreFileStatusFilter + ) -> ItemPaged["_types_models1.MemoryStoreDetails"]: + """List all memory stores. + + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and - 100, and the default is 20. Default value is None. + 100, and the + default is 20. Default value is None. :paramtype limit: int - :keyword order: Sort order by the created_at timestamp of the objects. asc for ascending order - and desc for descending order. Known values are: "asc" and "desc". Default value is None. - :paramtype order: str or ~azure.ai.agents.models.ListSortOrder - :keyword 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. Default value is None. + :keyword order: Sort order by the ``created_at`` timestamp of the objects. ``asc`` for + ascending order and``desc`` + for descending order. Known values are: "asc" and "desc". Default value is None. + :paramtype order: str or ~azure.ai.agents.models.PageOrder + :keyword 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. + Default value is None. :paramtype before: str - :return: An iterator like instance of VectorStoreFile - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.models.VectorStoreFile] + :return: An iterator like instance of MemoryStoreDetails + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.types.MemoryStoreDetails] :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "default": + memory_store_definition = { + "chat_model": "str", + "embedding_model": "str", + "kind": "default", + "options": { + "chat_summary_enabled": bool, + "user_profile_enabled": bool, + "user_profile_details": "str" + } + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "definition": memory_store_definition, + "id": "str", + "name": "str", + "object": "str", + "updated_at": "2020-02-20 00:00:00", + "description": "str", + "metadata": { + "str": "str" + } + } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.VectorStoreFile]] = kwargs.pop("cls", None) + cls: ClsType[List[_types_models1.MemoryStoreDetails]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4467,9 +14530,8 @@ def list( def prepare_request(_continuation_token=None): - _request = build_vector_store_files_list_request( - vector_store_id=vector_store_id, - filter=filter, + _request = build_beta_memory_stores_list_request( + foundry_features=foundry_features, limit=limit, order=order, after=_continuation_token, @@ -4486,7 +14548,7 @@ def prepare_request(_continuation_token=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.VectorStoreFile], deserialized.get("data", [])) + list_of_elem = deserialized.get("data", []) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("last_id") or None, iter(list_of_elem) @@ -4502,106 +14564,40 @@ def get_next(_continuation_token=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) + error = self._deserialize.failsafe_deserialize( + _types_models1.ApiErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error) return pipeline_response return ItemPaged(get_next, extract_data) - @overload - def create( - self, - vector_store_id: str, - *, - content_type: str = "application/json", - file_id: Optional[str] = None, - data_source: Optional[_models.VectorStoreDataSource] = None, - chunking_strategy: Optional[_models.VectorStoreChunkingStrategyRequest] = None, - **kwargs: Any - ) -> _models.VectorStoreFile: - """Create a vector store file by attaching a file to a vector store. - - :param vector_store_id: Identifier of the vector store. Required. - :type vector_store_id: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword file_id: Identifier of the file. Default value is None. - :paramtype file_id: str - :keyword data_source: Azure asset ID. Default value is None. - :paramtype data_source: ~azure.ai.agents.models.VectorStoreDataSource - :keyword chunking_strategy: The chunking strategy used to chunk the file. If not set, uses the - auto strategy. Default value is None. - :paramtype chunking_strategy: ~azure.ai.agents.models.VectorStoreChunkingStrategyRequest - :return: VectorStoreFile. The VectorStoreFile is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.VectorStoreFile - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, vector_store_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.VectorStoreFile: - """Create a vector store file by attaching a file to a vector store. - - :param vector_store_id: Identifier of the vector store. Required. - :type vector_store_id: str - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: VectorStoreFile. The VectorStoreFile is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.VectorStoreFile - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, vector_store_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.VectorStoreFile: - """Create a vector store file by attaching a file to a vector store. - - :param vector_store_id: Identifier of the vector store. Required. - :type vector_store_id: str - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: VectorStoreFile. The VectorStoreFile is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.VectorStoreFile + @distributed_trace + def delete( + self, name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], **kwargs: Any + ) -> _types_models1.DeleteMemoryStoreResult: + """Delete a memory store. + + :param name: The name of the memory store to delete. Required. + :type name: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW + :return: DeleteMemoryStoreResult + :rtype: ~azure.ai.agents.types.DeleteMemoryStoreResult :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace - def create( - self, - vector_store_id: str, - body: Union[JSON, IO[bytes]] = _Unset, - *, - file_id: Optional[str] = None, - data_source: Optional[_models.VectorStoreDataSource] = None, - chunking_strategy: Optional[_models.VectorStoreChunkingStrategyRequest] = None, - **kwargs: Any - ) -> _models.VectorStoreFile: - """Create a vector store file by attaching a file to a vector store. + Example: + .. code-block:: python - :param vector_store_id: Identifier of the vector store. Required. - :type vector_store_id: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword file_id: Identifier of the file. Default value is None. - :paramtype file_id: str - :keyword data_source: Azure asset ID. Default value is None. - :paramtype data_source: ~azure.ai.agents.models.VectorStoreDataSource - :keyword chunking_strategy: The chunking strategy used to chunk the file. If not set, uses the - auto strategy. Default value is None. - :paramtype chunking_strategy: ~azure.ai.agents.models.VectorStoreChunkingStrategyRequest - :return: VectorStoreFile. The VectorStoreFile is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.VectorStoreFile - :raises ~azure.core.exceptions.HttpResponseError: + # response body for status code(s): 200 + response == { + "deleted": bool, + "name": "str", + "object": "str" + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4611,27 +14607,15 @@ def create( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VectorStoreFile] = kwargs.pop("cls", None) - - if body is _Unset: - body = {"chunking_strategy": chunking_strategy, "data_source": data_source, "file_id": file_id} - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + cls: ClsType[_types_models1.DeleteMemoryStoreResult] = kwargs.pop("cls", None) - _request = build_vector_store_files_create_request( - vector_store_id=vector_store_id, - content_type=content_type, + _request = build_beta_memory_stores_delete_request( + name=name, + foundry_features=foundry_features, api_version=self._config.api_version, - content=_content, headers=_headers, params=_params, ) @@ -4640,6 +14624,7 @@ def create( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -4654,30 +14639,133 @@ def create( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) + error = self._deserialize.failsafe_deserialize( + _types_models1.ApiErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.VectorStoreFile, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + @overload + def _search_memories( + self, + name: str, + scope: str, + items: Optional[List[dict[str, Any]]] = None, + previous_search_id: Optional[str] = None, + options: Optional[_types_models1.MemorySearchOptions] = None, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models1.MemoryStoreSearchResult: ... + @overload + def _search_memories( + self, + name: str, + body: JSON, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models1.MemoryStoreSearchResult: ... + @overload + def _search_memories( + self, + name: str, + body: IO[bytes], + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models1.MemoryStoreSearchResult: ... + @distributed_trace - def get(self, vector_store_id: str, file_id: str, **kwargs: Any) -> _models.VectorStoreFile: - """Retrieves a vector store file. - - :param vector_store_id: Identifier of the vector store. Required. - :type vector_store_id: str - :param file_id: Identifier of the file. Required. - :type file_id: str - :return: VectorStoreFile. The VectorStoreFile is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.VectorStoreFile + def _search_memories( + self, + name: str, + scope: str = _Unset, + body: Union[JSON, IO[bytes]] = _Unset, + items: Optional[List[dict[str, Any]]] = None, + previous_search_id: Optional[str] = None, + options: Optional[_types_models1.MemorySearchOptions] = None, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + **kwargs: Any + ) -> _types_models1.MemoryStoreSearchResult: + """Search for relevant memories from a memory store based on conversation context. + + :param name: The name of the memory store to search. Required. + :type name: str + :param scope: The namespace that logically groups and isolates memories, such as a user ID. + Required. + :type scope: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :param items: Items for which to search for relevant memories. Default value is None. + :type items: list[dict[str, any]] + :param previous_search_id: The unique ID of the previous search request, enabling incremental + memory search from where the last operation left off. Default value is None. + :type previous_search_id: str + :param options: Memory search options. Default value is None. + :type options: ~azure.ai.agents.types.MemorySearchOptions + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW + :return: MemoryStoreSearchResult + :rtype: ~azure.ai.agents.types.MemoryStoreSearchResult :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "scope": "str", + "items": [ + { + "str": {} + } + ], + "options": { + "max_memories": 0 + }, + "previous_search_id": "str" + } + + # response body for status code(s): 200 + response == { + "memories": [ + { + "memory_item": memory_item + } + ], + "search_id": "str", + "usage": { + "embedding_tokens": 0, + "input_tokens": 0, + "input_tokens_details": { + "cached_tokens": 0 + }, + "output_tokens": 0, + "output_tokens_details": { + "reasoning_tokens": 0 + }, + "total_tokens": 0 + } + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4687,15 +14775,32 @@ def get(self, vector_store_id: str, file_id: str, **kwargs: Any) -> _models.Vect } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.VectorStoreFile] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_types_models1.MemoryStoreSearchResult] = kwargs.pop("cls", None) + + if body is _Unset: + if scope is _Unset: + raise TypeError("missing required argument: scope") + body = {"items": items, "options": options, "previous_search_id": previous_search_id, "scope": scope} + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body - _request = build_vector_store_files_get_request( - vector_store_id=vector_store_id, - file_id=file_id, + _request = build_beta_memory_stores_search_memories_request( + name=name, + foundry_features=foundry_features, + content_type=content_type, api_version=self._config.api_version, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -4704,6 +14809,7 @@ def get(self, vector_store_id: str, file_id: str, **kwargs: Any) -> _models.Vect } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -4718,35 +14824,37 @@ def get(self, vector_store_id: str, file_id: str, **kwargs: Any) -> _models.Vect except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) + error = self._deserialize.failsafe_deserialize( + _types_models1.ApiErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.VectorStoreFile, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def _delete_vector_store_file( - self, vector_store_id: str, file_id: str, **kwargs: Any - ) -> _models._models.VectorStoreFileDeletionStatus: - """Deletes a vector store file. This removes the file‐to‐store link (does not delete the file - itself). - - :param vector_store_id: Identifier of the vector store. Required. - :type vector_store_id: str - :param file_id: Identifier of the file. Required. - :type file_id: str - :return: VectorStoreFileDeletionStatus. The VectorStoreFileDeletionStatus is compatible with - MutableMapping - :rtype: ~azure.ai.agents.models._models.VectorStoreFileDeletionStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ + def _update_memories_initial( + self, + name: str, + scope: str = _Unset, + body: Union[JSON, IO[bytes]] = _Unset, + items: Optional[List[dict[str, Any]]] = None, + previous_update_id: Optional[str] = None, + update_delay: Optional[int] = None, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4755,15 +14863,37 @@ def _delete_vector_store_file( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models._models.VectorStoreFileDeletionStatus] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + if body is _Unset: + if scope is _Unset: + raise TypeError("missing required argument: scope") + body = { + "items": items, + "previous_update_id": previous_update_id, + "scope": scope, + "update_delay": update_delay, + } + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body - _request = build_vector_store_files_delete_vector_store_file_request( - vector_store_id=vector_store_id, - file_id=file_id, + _request = build_beta_memory_stores_update_memories_request( + name=name, + foundry_features=foundry_features, + content_type=content_type, api_version=self._config.api_version, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -4772,146 +14902,372 @@ def _delete_vector_store_file( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) + error = self._deserialize.failsafe_deserialize( + _types_models1.ApiErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize( - _models._models.VectorStoreFileDeletionStatus, response.json() # pylint: disable=protected-access - ) + response_headers = {} + response_headers["Operation-Location"] = self._deserialize("str", response.headers.get("Operation-Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore + @overload + def _begin_update_memories( + self, + name: str, + scope: str, + items: Optional[List[dict[str, Any]]] = None, + previous_update_id: Optional[str] = None, + update_delay: Optional[int] = None, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_types_models1.MemoryStoreUpdateCompletedResult]: ... + @overload + def _begin_update_memories( + self, + name: str, + body: JSON, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_types_models1.MemoryStoreUpdateCompletedResult]: ... + @overload + def _begin_update_memories( + self, + name: str, + body: IO[bytes], + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_types_models1.MemoryStoreUpdateCompletedResult]: ... -class VectorStoreFileBatchesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. + @distributed_trace + def _begin_update_memories( + self, + name: str, + scope: str = _Unset, + body: Union[JSON, IO[bytes]] = _Unset, + items: Optional[List[dict[str, Any]]] = None, + previous_update_id: Optional[str] = None, + update_delay: Optional[int] = None, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + **kwargs: Any + ) -> LROPoller[_types_models1.MemoryStoreUpdateCompletedResult]: + """Update memory store with conversation memories. - Instead, you should access the following operations through - :class:`~azure.ai.agents.AgentsClient`'s - :attr:`vector_store_file_batches` attribute. - """ + :param name: The name of the memory store to update. Required. + :type name: str + :param scope: The namespace that logically groups and isolates memories, such as a user ID. + Required. + :type scope: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :param items: Conversation items to be stored in memory. Default value is None. + :type items: list[dict[str, any]] + :param previous_update_id: The unique ID of the previous update request, enabling incremental + memory updates from where the last operation left off. Default value is None. + :type previous_update_id: str + :param update_delay: Timeout period before processing the memory update in seconds. + If a new update request is received during this period, it will cancel the current request and + reset the timeout. + Set to 0 to immediately trigger the update without delay. + Defaults to 300 (5 minutes). Default value is None. + :type update_delay: int + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW + :return: An instance of LROPoller that returns MemoryStoreUpdateCompletedResult + :rtype: ~azure.core.polling.LROPoller[~azure.ai.agents.types.MemoryStoreUpdateCompletedResult] + :raises ~azure.core.exceptions.HttpResponseError: - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AgentsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "scope": "str", + "items": [ + { + "str": {} + } + ], + "previous_update_id": "str", + "update_delay": 0 + } + + # response body for status code(s): 202 + response == { + "memory_operations": [ + { + "kind": "str", + "memory_item": memory_item + } + ], + "usage": { + "embedding_tokens": 0, + "input_tokens": 0, + "input_tokens_details": { + "cached_tokens": 0 + }, + "output_tokens": 0, + "output_tokens_details": { + "reasoning_tokens": 0 + }, + "total_tokens": 0 + } + } + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_types_models1.MemoryStoreUpdateCompletedResult] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_memories_initial( + name=name, + scope=scope, + body=body, + items=items, + previous_update_id=previous_update_id, + update_delay=update_delay, + foundry_features=foundry_features, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Operation-Location"] = self._deserialize( + "str", response.headers.get("Operation-Location") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, LROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_types_models.MemoryStoreUpdateCompletedResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_types_models.MemoryStoreUpdateCompletedResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @overload - def create( + def delete_scope( self, - vector_store_id: str, + name: str, + scope: str, *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], content_type: str = "application/json", - file_ids: Optional[List[str]] = None, - data_sources: Optional[List[_models.VectorStoreDataSource]] = None, - chunking_strategy: Optional[_models.VectorStoreChunkingStrategyRequest] = None, **kwargs: Any - ) -> _models.VectorStoreFileBatch: - """Create a vector store file batch. - - :param vector_store_id: Identifier of the vector store. Required. - :type vector_store_id: str + ) -> _types_models1.MemoryStoreDeleteScopeResult: + """Delete all memories associated with a specific scope from a memory store. + + :param name: The name of the memory store. Required. + :type name: str + :param scope: The namespace that logically groups and isolates memories to delete, such as a + user ID. Required. + :type scope: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword file_ids: List of file identifiers. Default value is None. - :paramtype file_ids: list[str] - :keyword data_sources: List of Azure assets. Default value is None. - :paramtype data_sources: list[~azure.ai.agents.models.VectorStoreDataSource] - :keyword chunking_strategy: The chunking strategy used to chunk the file(s). If not set, will - use the auto strategy. Default value is None. - :paramtype chunking_strategy: ~azure.ai.agents.models.VectorStoreChunkingStrategyRequest - :return: VectorStoreFileBatch. The VectorStoreFileBatch is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.VectorStoreFileBatch + :return: MemoryStoreDeleteScopeResult + :rtype: ~azure.ai.agents.types.MemoryStoreDeleteScopeResult :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "deleted": bool, + "name": "str", + "object": "str", + "scope": "str" + } """ @overload - def create( - self, vector_store_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.VectorStoreFileBatch: - """Create a vector store file batch. + def delete_scope( + self, + name: str, + body: JSON, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models1.MemoryStoreDeleteScopeResult: + """Delete all memories associated with a specific scope from a memory store. - :param vector_store_id: Identifier of the vector store. Required. - :type vector_store_id: str + :param name: The name of the memory store. Required. + :type name: str :param body: Required. :type body: JSON + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: VectorStoreFileBatch. The VectorStoreFileBatch is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.VectorStoreFileBatch + :return: MemoryStoreDeleteScopeResult + :rtype: ~azure.ai.agents.types.MemoryStoreDeleteScopeResult :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "scope": "str" + } + + # response body for status code(s): 200 + response == { + "deleted": bool, + "name": "str", + "object": "str", + "scope": "str" + } """ @overload - def create( - self, vector_store_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.VectorStoreFileBatch: - """Create a vector store file batch. + def delete_scope( + self, + name: str, + body: IO[bytes], + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models1.MemoryStoreDeleteScopeResult: + """Delete all memories associated with a specific scope from a memory store. - :param vector_store_id: Identifier of the vector store. Required. - :type vector_store_id: str + :param name: The name of the memory store. Required. + :type name: str :param body: Required. :type body: IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: VectorStoreFileBatch. The VectorStoreFileBatch is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.VectorStoreFileBatch + :return: MemoryStoreDeleteScopeResult + :rtype: ~azure.ai.agents.types.MemoryStoreDeleteScopeResult :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "deleted": bool, + "name": "str", + "object": "str", + "scope": "str" + } """ @distributed_trace - def create( + def delete_scope( self, - vector_store_id: str, + name: str, + scope: str = _Unset, body: Union[JSON, IO[bytes]] = _Unset, *, - file_ids: Optional[List[str]] = None, - data_sources: Optional[List[_models.VectorStoreDataSource]] = None, - chunking_strategy: Optional[_models.VectorStoreChunkingStrategyRequest] = None, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], **kwargs: Any - ) -> _models.VectorStoreFileBatch: - """Create a vector store file batch. - - :param vector_store_id: Identifier of the vector store. Required. - :type vector_store_id: str + ) -> _types_models1.MemoryStoreDeleteScopeResult: + """Delete all memories associated with a specific scope from a memory store. + + :param name: The name of the memory store. Required. + :type name: str + :param scope: The namespace that logically groups and isolates memories to delete, such as a + user ID. Required. + :type scope: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :keyword file_ids: List of file identifiers. Default value is None. - :paramtype file_ids: list[str] - :keyword data_sources: List of Azure assets. Default value is None. - :paramtype data_sources: list[~azure.ai.agents.models.VectorStoreDataSource] - :keyword chunking_strategy: The chunking strategy used to chunk the file(s). If not set, will - use the auto strategy. Default value is None. - :paramtype chunking_strategy: ~azure.ai.agents.models.VectorStoreChunkingStrategyRequest - :return: VectorStoreFileBatch. The VectorStoreFileBatch is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.VectorStoreFileBatch + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW + :return: MemoryStoreDeleteScopeResult + :rtype: ~azure.ai.agents.types.MemoryStoreDeleteScopeResult :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "scope": "str" + } + + # response body for status code(s): 200 + response == { + "deleted": bool, + "name": "str", + "object": "str", + "scope": "str" + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4925,22 +15281,27 @@ def create( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VectorStoreFileBatch] = kwargs.pop("cls", None) + cls: ClsType[_types_models1.MemoryStoreDeleteScopeResult] = kwargs.pop("cls", None) if body is _Unset: - body = {"chunking_strategy": chunking_strategy, "data_sources": data_sources, "file_ids": file_ids} + if scope is _Unset: + raise TypeError("missing required argument: scope") + body = {"scope": scope} body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" + _json = None _content = None if isinstance(body, (IOBase, bytes)): _content = body else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _json = body - _request = build_vector_store_file_batches_create_request( - vector_store_id=vector_store_id, + _request = build_beta_memory_stores_delete_scope_request( + name=name, + foundry_features=foundry_features, content_type=content_type, api_version=self._config.api_version, + json=_json, content=_content, headers=_headers, params=_params, @@ -4950,6 +15311,7 @@ def create( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -4964,95 +15326,92 @@ def create( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) + error = self._deserialize.failsafe_deserialize( + _types_models1.ApiErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.VectorStoreFileBatch, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def get(self, vector_store_id: str, batch_id: str, **kwargs: Any) -> _models.VectorStoreFileBatch: - """Retrieve a vector store file batch. - - :param vector_store_id: Identifier of the vector store. Required. - :type vector_store_id: str - :param batch_id: Identifier of the file batch. Required. - :type batch_id: str - :return: VectorStoreFileBatch. The VectorStoreFileBatch is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.VectorStoreFileBatch - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.VectorStoreFileBatch] = kwargs.pop("cls", None) - - _request = build_vector_store_file_batches_get_request( - vector_store_id=vector_store_id, - batch_id=batch_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.VectorStoreFileBatch, response.json()) +class BetaRedTeamsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + Instead, you should access the following operations through + :class:`~azure.ai.agents.AIProjectClient`'s + :attr:`red_teams` attribute. + """ - return deserialized # type: ignore + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def cancel(self, vector_store_id: str, batch_id: str, **kwargs: Any) -> _models.VectorStoreFileBatch: - """Cancel a vector store file batch. This attempts to cancel the processing of files in this batch - as soon as possible. - - :param vector_store_id: Identifier of the vector store. Required. - :type vector_store_id: str - :param batch_id: Identifier of the file batch. Required. - :type batch_id: str - :return: VectorStoreFileBatch. The VectorStoreFileBatch is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.VectorStoreFileBatch + def get( + self, name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.RED_TEAMS_V1_PREVIEW], **kwargs: Any + ) -> _types_models1.RedTeam: + """Get a redteam by name. + + :param name: Identifier of the red team run. Required. + :type name: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. RED_TEAMS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.RED_TEAMS_V1_PREVIEW + :return: RedTeam + :rtype: ~azure.ai.agents.types.RedTeam :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AzureOpenAIModel": + target_config = { + "modelDeploymentName": "str", + "type": "AzureOpenAIModel" + } + + # response body for status code(s): 200 + response == { + "id": "str", + "target": target_config, + "applicationScenario": "str", + "attackStrategies": [ + "str" + ], + "displayName": "str", + "numTurns": 0, + "properties": { + "str": "str" + }, + "riskCategories": [ + "str" + ], + "simulationOnly": bool, + "status": "str", + "tags": { + "str": "str" + } + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -5065,11 +15424,11 @@ def cancel(self, vector_store_id: str, batch_id: str, **kwargs: Any) -> _models. _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.VectorStoreFileBatch] = kwargs.pop("cls", None) + cls: ClsType[_types_models1.RedTeam] = kwargs.pop("cls", None) - _request = build_vector_store_file_batches_cancel_request( - vector_store_id=vector_store_id, - batch_id=batch_id, + _request = build_beta_red_teams_get_request( + name=name, + foundry_features=foundry_features, api_version=self._config.api_version, headers=_headers, params=_params, @@ -5079,6 +15438,7 @@ def cancel(self, vector_store_id: str, batch_id: str, **kwargs: Any) -> _models. } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -5093,13 +15453,15 @@ def cancel(self, vector_store_id: str, batch_id: str, **kwargs: Any) -> _models. except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.VectorStoreFileBatch, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -5107,45 +15469,57 @@ def cancel(self, vector_store_id: str, batch_id: str, **kwargs: Any) -> _models. return deserialized # type: ignore @distributed_trace - def list_files( - self, - vector_store_id: str, - batch_id: str, - *, - filter: Optional[Union[str, _models.VectorStoreFileStatusFilter]] = None, - limit: Optional[int] = None, - order: Optional[Union[str, _models.ListSortOrder]] = None, - before: Optional[str] = None, - **kwargs: Any - ) -> ItemPaged["_models.VectorStoreFile"]: - """Returns a list of vector store files in a batch. - - :param vector_store_id: Identifier of the vector store. Required. - :type vector_store_id: str - :param batch_id: Identifier of the file batch. Required. - :type batch_id: str - :keyword filter: Filter by file status. Known values are: "in_progress", "completed", "failed", - and "cancelled". Default value is None. - :paramtype filter: str or ~azure.ai.agents.models.VectorStoreFileStatusFilter - :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and - 100, and the default is 20. Default value is None. - :paramtype limit: int - :keyword order: Sort order by the created_at timestamp of the objects. asc for ascending order - and desc for descending order. Known values are: "asc" and "desc". Default value is None. - :paramtype order: str or ~azure.ai.agents.models.ListSortOrder - :keyword 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. Default value is None. - :paramtype before: str - :return: An iterator like instance of VectorStoreFile - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.models.VectorStoreFile] + def list( + self, *, foundry_features: Literal[FoundryFeaturesOptInKeys.RED_TEAMS_V1_PREVIEW], **kwargs: Any + ) -> ItemPaged["_types_models1.RedTeam"]: + """List a redteam by name. + + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. RED_TEAMS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.RED_TEAMS_V1_PREVIEW + :return: An iterator like instance of RedTeam + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.types.RedTeam] :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AzureOpenAIModel": + target_config = { + "modelDeploymentName": "str", + "type": "AzureOpenAIModel" + } + + # response body for status code(s): 200 + response == { + "id": "str", + "target": target_config, + "applicationScenario": "str", + "attackStrategies": [ + "str" + ], + "displayName": "str", + "numTurns": 0, + "properties": { + "str": "str" + }, + "riskCategories": [ + "str" + ], + "simulationOnly": bool, + "status": "str", + "tags": { + "str": "str" + } + } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.VectorStoreFile]] = kwargs.pop("cls", None) + cls: ClsType[List[_types_models1.RedTeam]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -5155,35 +15529,56 @@ def list_files( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(_continuation_token=None): + def prepare_request(next_link=None): + if not next_link: + + _request = build_beta_red_teams_list_request( + foundry_features=foundry_features, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - _request = build_vector_store_file_batches_list_files_request( - vector_store_id=vector_store_id, - batch_id=batch_id, - filter=filter, - limit=limit, - order=order, - after=_continuation_token, - before=before, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) return _request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.VectorStoreFile], deserialized.get("data", [])) + list_of_elem = deserialized.get("value", []) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("last_id") or None, iter(list_of_elem) + return deserialized.get("nextLink") or None, iter(list_of_elem) - def get_next(_continuation_token=None): - _request = prepare_request(_continuation_token) + def get_next(next_link=None): + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access @@ -5193,171 +15588,247 @@ def get_next(_continuation_token=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) return pipeline_response return ItemPaged(get_next, extract_data) - -class _AgentsClientOperationsMixin( - ClientMixinABC[PipelineClient[HttpRequest, HttpResponse], AgentsClientConfiguration] -): - @overload - def create_agent( + def create( self, + red_team: _types_models1.RedTeam, *, - model: str, + foundry_features: Literal[FoundryFeaturesOptInKeys.RED_TEAMS_V1_PREVIEW], content_type: str = "application/json", - name: Optional[str] = None, - description: Optional[str] = None, - instructions: Optional[str] = None, - tools: Optional[List[_models.ToolDefinition]] = None, - tool_resources: Optional[_models.ToolResources] = None, - temperature: Optional[float] = None, - top_p: Optional[float] = None, - response_format: Optional["_types.AgentsResponseFormatOption"] = None, - metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> _models.Agent: - """Creates a new agent. - - :keyword model: The ID of the model to use. Required. - :paramtype model: str + ) -> _types_models1.RedTeam: + """Creates a redteam run. + + :param red_team: Redteam to be run. Required. + :type red_team: ~azure.ai.agents.types.RedTeam + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. RED_TEAMS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.RED_TEAMS_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword name: The name of the new agent. Default value is None. - :paramtype name: str - :keyword description: The description of the new agent. Default value is None. - :paramtype description: str - :keyword instructions: The system instructions for the new agent to use. Default value is None. - :paramtype instructions: str - :keyword tools: The collection of tools to enable for the new agent. Default value is None. - :paramtype tools: list[~azure.ai.agents.models.ToolDefinition] - :keyword tool_resources: 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. Default value is None. - :paramtype tool_resources: ~azure.ai.agents.models.ToolResources - :keyword temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 - will make the output more random, - while lower values like 0.2 will make it more focused and deterministic. Default value is - None. - :paramtype temperature: float - :keyword top_p: An alternative to sampling with temperature, called nucleus sampling, where the - model considers the results of the tokens with top_p probability mass. - So 0.1 means only the tokens comprising the top 10% probability mass are considered. - - We generally recommend altering this or temperature but not both. Default value is None. - :paramtype top_p: float - :keyword response_format: The response format of the tool calls used by this agent. Is one of - the following types: str, Union[str, "_models.AgentsResponseFormatMode"], AgentsResponseFormat, - ResponseFormatJsonSchemaType Default value is None. - :paramtype response_format: str or str or ~azure.ai.agents.models.AgentsResponseFormatMode or - ~azure.ai.agents.models.AgentsResponseFormat or - ~azure.ai.agents.models.ResponseFormatJsonSchemaType - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: Agent. The Agent is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.Agent + :return: RedTeam + :rtype: ~azure.ai.agents.types.RedTeam :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_agent(self, body: JSON, *, content_type: str = "application/json", **kwargs: Any) -> _models.Agent: - """Creates a new agent. - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Agent. The Agent is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.Agent - :raises ~azure.core.exceptions.HttpResponseError: + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "AzureOpenAIModel": + target_config = { + "modelDeploymentName": "str", + "type": "AzureOpenAIModel" + } + + # JSON input template you can fill out and use as your body input. + red_team = { + "id": "str", + "target": target_config, + "applicationScenario": "str", + "attackStrategies": [ + "str" + ], + "displayName": "str", + "numTurns": 0, + "properties": { + "str": "str" + }, + "riskCategories": [ + "str" + ], + "simulationOnly": bool, + "status": "str", + "tags": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AzureOpenAIModel": + target_config = { + "modelDeploymentName": "str", + "type": "AzureOpenAIModel" + } + + # response body for status code(s): 201 + response == { + "id": "str", + "target": target_config, + "applicationScenario": "str", + "attackStrategies": [ + "str" + ], + "displayName": "str", + "numTurns": 0, + "properties": { + "str": "str" + }, + "riskCategories": [ + "str" + ], + "simulationOnly": bool, + "status": "str", + "tags": { + "str": "str" + } + } """ @overload - def create_agent(self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any) -> _models.Agent: - """Creates a new agent. - - :param body: Required. - :type body: IO[bytes] + def create( + self, + red_team: IO[bytes], + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.RED_TEAMS_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models1.RedTeam: + """Creates a redteam run. + + :param red_team: Redteam to be run. Required. + :type red_team: IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. RED_TEAMS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.RED_TEAMS_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: Agent. The Agent is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.Agent + :return: RedTeam + :rtype: ~azure.ai.agents.types.RedTeam :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AzureOpenAIModel": + target_config = { + "modelDeploymentName": "str", + "type": "AzureOpenAIModel" + } + + # response body for status code(s): 201 + response == { + "id": "str", + "target": target_config, + "applicationScenario": "str", + "attackStrategies": [ + "str" + ], + "displayName": "str", + "numTurns": 0, + "properties": { + "str": "str" + }, + "riskCategories": [ + "str" + ], + "simulationOnly": bool, + "status": "str", + "tags": { + "str": "str" + } + } """ @distributed_trace - def create_agent( + def create( self, - body: Union[JSON, IO[bytes]] = _Unset, + red_team: Union[_types_models1.RedTeam, IO[bytes]], *, - model: str = _Unset, - name: Optional[str] = None, - description: Optional[str] = None, - instructions: Optional[str] = None, - tools: Optional[List[_models.ToolDefinition]] = None, - tool_resources: Optional[_models.ToolResources] = None, - temperature: Optional[float] = None, - top_p: Optional[float] = None, - response_format: Optional["_types.AgentsResponseFormatOption"] = None, - metadata: Optional[dict[str, str]] = None, + foundry_features: Literal[FoundryFeaturesOptInKeys.RED_TEAMS_V1_PREVIEW], **kwargs: Any - ) -> _models.Agent: - """Creates a new agent. - - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword model: The ID of the model to use. Required. - :paramtype model: str - :keyword name: The name of the new agent. Default value is None. - :paramtype name: str - :keyword description: The description of the new agent. Default value is None. - :paramtype description: str - :keyword instructions: The system instructions for the new agent to use. Default value is None. - :paramtype instructions: str - :keyword tools: The collection of tools to enable for the new agent. Default value is None. - :paramtype tools: list[~azure.ai.agents.models.ToolDefinition] - :keyword tool_resources: 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. Default value is None. - :paramtype tool_resources: ~azure.ai.agents.models.ToolResources - :keyword temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 - will make the output more random, - while lower values like 0.2 will make it more focused and deterministic. Default value is - None. - :paramtype temperature: float - :keyword top_p: An alternative to sampling with temperature, called nucleus sampling, where the - model considers the results of the tokens with top_p probability mass. - So 0.1 means only the tokens comprising the top 10% probability mass are considered. - - We generally recommend altering this or temperature but not both. Default value is None. - :paramtype top_p: float - :keyword response_format: The response format of the tool calls used by this agent. Is one of - the following types: str, Union[str, "_models.AgentsResponseFormatMode"], AgentsResponseFormat, - ResponseFormatJsonSchemaType Default value is None. - :paramtype response_format: str or str or ~azure.ai.agents.models.AgentsResponseFormatMode or - ~azure.ai.agents.models.AgentsResponseFormat or - ~azure.ai.agents.models.ResponseFormatJsonSchemaType - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: Agent. The Agent is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.Agent + ) -> _types_models1.RedTeam: + """Creates a redteam run. + + :param red_team: Redteam to be run. Is either a RedTeam type or a IO[bytes] type. Required. + :type red_team: ~azure.ai.agents.types.RedTeam or IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. RED_TEAMS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.RED_TEAMS_V1_PREVIEW + :return: RedTeam + :rtype: ~azure.ai.agents.types.RedTeam :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "AzureOpenAIModel": + target_config = { + "modelDeploymentName": "str", + "type": "AzureOpenAIModel" + } + + # JSON input template you can fill out and use as your body input. + red_team = { + "id": "str", + "target": target_config, + "applicationScenario": "str", + "attackStrategies": [ + "str" + ], + "displayName": "str", + "numTurns": 0, + "properties": { + "str": "str" + }, + "riskCategories": [ + "str" + ], + "simulationOnly": bool, + "status": "str", + "tags": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "AzureOpenAIModel": + target_config = { + "modelDeploymentName": "str", + "type": "AzureOpenAIModel" + } + + # response body for status code(s): 201 + response == { + "id": "str", + "target": target_config, + "applicationScenario": "str", + "attackStrategies": [ + "str" + ], + "displayName": "str", + "numTurns": 0, + "properties": { + "str": "str" + }, + "riskCategories": [ + "str" + ], + "simulationOnly": bool, + "status": "str", + "tags": { + "str": "str" + } + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -5371,35 +15842,241 @@ def create_agent( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Agent] = kwargs.pop("cls", None) + cls: ClsType[_types_models1.RedTeam] = kwargs.pop("cls", None) - if body is _Unset: - if model is _Unset: - raise TypeError("missing required argument: model") - body = { - "description": description, - "instructions": instructions, - "metadata": metadata, - "model": model, - "name": name, - "response_format": response_format, - "temperature": temperature, - "tool_resources": tool_resources, - "tools": tools, - "top_p": top_p, - } - body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" + _json = None _content = None - if isinstance(body, (IOBase, bytes)): - _content = body + if isinstance(red_team, (IOBase, bytes)): + _content = red_team + else: + _json = red_team + + _request = build_beta_red_teams_create_request( + foundry_features=foundry_features, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [201]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _types_models1.ApiErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class BetaSchedulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.agents.AIProjectClient`'s + :attr:`schedules` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + schedule_id: str, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], + **kwargs: Any + ) -> None: + """Delete a schedule. + + :param schedule_id: Identifier of the schedule. Required. + :type schedule_id: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. SCHEDULES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.SCHEDULES_V1_PREVIEW + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_beta_schedules_delete_request( + schedule_id=schedule_id, + foundry_features=foundry_features, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def get( + self, + schedule_id: str, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], + **kwargs: Any + ) -> _types_models1.Schedule: + """Get a schedule by id. + + :param schedule_id: Identifier of the schedule. Required. + :type schedule_id: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. SCHEDULES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.SCHEDULES_V1_PREVIEW + :return: Schedule + :rtype: ~azure.ai.agents.types.Schedule + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "Cron": + trigger = { + "expression": "str", + "type": "Cron", + "endTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "timeZone": "str" + } + + # JSON input template for discriminator value "OneTime": + trigger = { + "triggerAt": "2020-02-20 00:00:00", + "type": "OneTime", + "timeZone": "str" + } + + # JSON input template for discriminator value "Recurrence": + trigger = { + "interval": 0, + "schedule": recurrence_schedule, + "type": "Recurrence", + "endTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "timeZone": "str" + } + + # JSON input template for discriminator value "Daily": + recurrence_schedule = { + "hours": [ + 0 + ], + "type": "Daily" + } + + # JSON input template for discriminator value "Hourly": + recurrence_schedule = { + "type": "Hourly" + } + + # response body for status code(s): 200 + response == { + "enabled": bool, + "id": "str", + "systemData": { + "str": "str" + }, + "task": schedule_task, + "trigger": trigger, + "description": "str", + "displayName": "str", + "properties": { + "str": "str" + }, + "provisioningStatus": "str", + "tags": { + "str": "str" + } + } + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - _request = build_agents_create_agent_request( - content_type=content_type, + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_types_models1.Schedule] = kwargs.pop("cls", None) + + _request = build_beta_schedules_get_request( + schedule_id=schedule_id, + foundry_features=foundry_features, api_version=self._config.api_version, - content=_content, headers=_headers, params=_params, ) @@ -5408,6 +16085,7 @@ def create_agent( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -5422,13 +16100,15 @@ def create_agent( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.Agent, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -5436,35 +16116,97 @@ def create_agent( return deserialized # type: ignore @distributed_trace - def list_agents( + def list( self, *, - limit: Optional[int] = None, - order: Optional[Union[str, _models.ListSortOrder]] = None, - before: Optional[str] = None, + foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], + type: Optional[types.ScheduleTaskType] = None, + enabled: Optional[bool] = None, **kwargs: Any - ) -> ItemPaged["_models.Agent"]: - """Gets a list of agents that were previously created. + ) -> ItemPaged["_types_models1.Schedule"]: + """List all schedules. - :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and - 100, and the default is 20. Default value is None. - :paramtype limit: int - :keyword order: Sort order by the created_at timestamp of the objects. asc for ascending order - and desc for descending order. Known values are: "asc" and "desc". Default value is None. - :paramtype order: str or ~azure.ai.agents.models.ListSortOrder - :keyword 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. Default value is None. - :paramtype before: str - :return: An iterator like instance of Agent - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.models.Agent] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. SCHEDULES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.SCHEDULES_V1_PREVIEW + :keyword type: Filter by the type of schedule. Known values are: "Evaluation" and "Insight". + Default value is None. + :paramtype type: str or ~azure.ai.agents.models.ScheduleTaskType + :keyword enabled: Filter by the enabled status. Default value is None. + :paramtype enabled: bool + :return: An iterator like instance of Schedule + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.types.Schedule] :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "Cron": + trigger = { + "expression": "str", + "type": "Cron", + "endTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "timeZone": "str" + } + + # JSON input template for discriminator value "OneTime": + trigger = { + "triggerAt": "2020-02-20 00:00:00", + "type": "OneTime", + "timeZone": "str" + } + + # JSON input template for discriminator value "Recurrence": + trigger = { + "interval": 0, + "schedule": recurrence_schedule, + "type": "Recurrence", + "endTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "timeZone": "str" + } + + # JSON input template for discriminator value "Daily": + recurrence_schedule = { + "hours": [ + 0 + ], + "type": "Daily" + } + + # JSON input template for discriminator value "Hourly": + recurrence_schedule = { + "type": "Hourly" + } + + # response body for status code(s): 200 + response == { + "enabled": bool, + "id": "str", + "systemData": { + "str": "str" + }, + "task": schedule_task, + "trigger": trigger, + "description": "str", + "displayName": "str", + "properties": { + "str": "str" + }, + "provisioningStatus": "str", + "tags": { + "str": "str" + } + } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.Agent]] = kwargs.pop("cls", None) + cls: ClsType[List[_types_models1.Schedule]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -5474,32 +16216,58 @@ def list_agents( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(_continuation_token=None): + def prepare_request(next_link=None): + if not next_link: + + _request = build_beta_schedules_list_request( + foundry_features=foundry_features, + type=type, + enabled=enabled, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - _request = build_agents_list_agents_request( - limit=limit, - order=order, - after=_continuation_token, - before=before, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) return _request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.Agent], deserialized.get("data", [])) + list_of_elem = deserialized.get("value", []) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("last_id") or None, iter(list_of_elem) + return deserialized.get("nextLink") or None, iter(list_of_elem) - def get_next(_continuation_token=None): - _request = prepare_request(_continuation_token) + def get_next(next_link=None): + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access @@ -5509,245 +16277,533 @@ def get_next(_continuation_token=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) return pipeline_response return ItemPaged(get_next, extract_data) - @distributed_trace - def get_agent(self, agent_id: str, **kwargs: Any) -> _models.Agent: - """Retrieves an existing agent. - - :param agent_id: Identifier of the agent. Required. - :type agent_id: str - :return: Agent. The Agent is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.Agent - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.Agent] = kwargs.pop("cls", None) - - _request = build_agents_get_agent_request( - agent_id=agent_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) - - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.Agent, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - @overload - def update_agent( + def create_or_update( self, - agent_id: str, + schedule_id: str, + schedule: _types_models1.Schedule, *, + foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], content_type: str = "application/json", - model: Optional[str] = None, - name: Optional[str] = None, - description: Optional[str] = None, - instructions: Optional[str] = None, - tools: Optional[List[_models.ToolDefinition]] = None, - tool_resources: Optional[_models.ToolResources] = None, - temperature: Optional[float] = None, - top_p: Optional[float] = None, - response_format: Optional["_types.AgentsResponseFormatOption"] = None, - metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> _models.Agent: - """Modifies an existing agent. - - :param agent_id: The ID of the agent to modify. Required. - :type agent_id: str + ) -> _types_models1.Schedule: + """Create or update operation template. + + :param schedule_id: Identifier of the schedule. Required. + :type schedule_id: str + :param schedule: The resource instance. Required. + :type schedule: ~azure.ai.agents.types.Schedule + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. SCHEDULES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.SCHEDULES_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword model: The ID of the model to use. Default value is None. - :paramtype model: str - :keyword name: The modified name for the agent to use. Default value is None. - :paramtype name: str - :keyword description: The modified description for the agent to use. Default value is None. - :paramtype description: str - :keyword instructions: The modified system instructions for the new agent to use. Default value - is None. - :paramtype instructions: str - :keyword tools: The modified collection of tools to enable for the agent. Default value is - None. - :paramtype tools: list[~azure.ai.agents.models.ToolDefinition] - :keyword tool_resources: 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. Default value is None. - :paramtype tool_resources: ~azure.ai.agents.models.ToolResources - :keyword temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 - will make the output more random, - while lower values like 0.2 will make it more focused and deterministic. Default value is - None. - :paramtype temperature: float - :keyword top_p: An alternative to sampling with temperature, called nucleus sampling, where the - model considers the results of the tokens with top_p probability mass. - So 0.1 means only the tokens comprising the top 10% probability mass are considered. - - We generally recommend altering this or temperature but not both. Default value is None. - :paramtype top_p: float - :keyword response_format: The response format of the tool calls used by this agent. Is one of - the following types: str, Union[str, "_models.AgentsResponseFormatMode"], AgentsResponseFormat, - ResponseFormatJsonSchemaType Default value is None. - :paramtype response_format: str or str or ~azure.ai.agents.models.AgentsResponseFormatMode or - ~azure.ai.agents.models.AgentsResponseFormat or - ~azure.ai.agents.models.ResponseFormatJsonSchemaType - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: Agent. The Agent is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.Agent + :return: Schedule + :rtype: ~azure.ai.agents.types.Schedule :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update_agent( - self, agent_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Agent: - """Modifies an existing agent. - :param agent_id: The ID of the agent to modify. Required. - :type agent_id: str - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Agent. The Agent is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.Agent - :raises ~azure.core.exceptions.HttpResponseError: + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "Cron": + trigger = { + "expression": "str", + "type": "Cron", + "endTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "timeZone": "str" + } + + # JSON input template for discriminator value "OneTime": + trigger = { + "triggerAt": "2020-02-20 00:00:00", + "type": "OneTime", + "timeZone": "str" + } + + # JSON input template for discriminator value "Recurrence": + trigger = { + "interval": 0, + "schedule": recurrence_schedule, + "type": "Recurrence", + "endTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "timeZone": "str" + } + + # JSON input template for discriminator value "Daily": + recurrence_schedule = { + "hours": [ + 0 + ], + "type": "Daily" + } + + # JSON input template for discriminator value "Hourly": + recurrence_schedule = { + "type": "Hourly" + } + + # JSON input template you can fill out and use as your body input. + schedule = { + "enabled": bool, + "id": "str", + "systemData": { + "str": "str" + }, + "task": schedule_task, + "trigger": trigger, + "description": "str", + "displayName": "str", + "properties": { + "str": "str" + }, + "provisioningStatus": "str", + "tags": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "Cron": + trigger = { + "expression": "str", + "type": "Cron", + "endTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "timeZone": "str" + } + + # JSON input template for discriminator value "OneTime": + trigger = { + "triggerAt": "2020-02-20 00:00:00", + "type": "OneTime", + "timeZone": "str" + } + + # JSON input template for discriminator value "Recurrence": + trigger = { + "interval": 0, + "schedule": recurrence_schedule, + "type": "Recurrence", + "endTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "timeZone": "str" + } + + # JSON input template for discriminator value "Daily": + recurrence_schedule = { + "hours": [ + 0 + ], + "type": "Daily" + } + + # JSON input template for discriminator value "Hourly": + recurrence_schedule = { + "type": "Hourly" + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "Cron": + trigger = { + "expression": "str", + "type": "Cron", + "endTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "timeZone": "str" + } + + # JSON input template for discriminator value "OneTime": + trigger = { + "triggerAt": "2020-02-20 00:00:00", + "type": "OneTime", + "timeZone": "str" + } + + # JSON input template for discriminator value "Recurrence": + trigger = { + "interval": 0, + "schedule": recurrence_schedule, + "type": "Recurrence", + "endTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "timeZone": "str" + } + + # JSON input template for discriminator value "Daily": + recurrence_schedule = { + "hours": [ + 0 + ], + "type": "Daily" + } + + # JSON input template for discriminator value "Hourly": + recurrence_schedule = { + "type": "Hourly" + } + + # response body for status code(s): 201, 200 + response == { + "enabled": bool, + "id": "str", + "systemData": { + "str": "str" + }, + "task": schedule_task, + "trigger": trigger, + "description": "str", + "displayName": "str", + "properties": { + "str": "str" + }, + "provisioningStatus": "str", + "tags": { + "str": "str" + } + } """ @overload - def update_agent( - self, agent_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Agent: - """Modifies an existing agent. - - :param agent_id: The ID of the agent to modify. Required. - :type agent_id: str - :param body: Required. - :type body: IO[bytes] + def create_or_update( + self, + schedule_id: str, + schedule: IO[bytes], + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _types_models1.Schedule: + """Create or update operation template. + + :param schedule_id: Identifier of the schedule. Required. + :type schedule_id: str + :param schedule: The resource instance. Required. + :type schedule: IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. SCHEDULES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.SCHEDULES_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: Agent. The Agent is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.Agent + :return: Schedule + :rtype: ~azure.ai.agents.types.Schedule :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "Cron": + trigger = { + "expression": "str", + "type": "Cron", + "endTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "timeZone": "str" + } + + # JSON input template for discriminator value "OneTime": + trigger = { + "triggerAt": "2020-02-20 00:00:00", + "type": "OneTime", + "timeZone": "str" + } + + # JSON input template for discriminator value "Recurrence": + trigger = { + "interval": 0, + "schedule": recurrence_schedule, + "type": "Recurrence", + "endTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "timeZone": "str" + } + + # JSON input template for discriminator value "Daily": + recurrence_schedule = { + "hours": [ + 0 + ], + "type": "Daily" + } + + # JSON input template for discriminator value "Hourly": + recurrence_schedule = { + "type": "Hourly" + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "Cron": + trigger = { + "expression": "str", + "type": "Cron", + "endTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "timeZone": "str" + } + + # JSON input template for discriminator value "OneTime": + trigger = { + "triggerAt": "2020-02-20 00:00:00", + "type": "OneTime", + "timeZone": "str" + } + + # JSON input template for discriminator value "Recurrence": + trigger = { + "interval": 0, + "schedule": recurrence_schedule, + "type": "Recurrence", + "endTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "timeZone": "str" + } + + # JSON input template for discriminator value "Daily": + recurrence_schedule = { + "hours": [ + 0 + ], + "type": "Daily" + } + + # JSON input template for discriminator value "Hourly": + recurrence_schedule = { + "type": "Hourly" + } + + # response body for status code(s): 201, 200 + response == { + "enabled": bool, + "id": "str", + "systemData": { + "str": "str" + }, + "task": schedule_task, + "trigger": trigger, + "description": "str", + "displayName": "str", + "properties": { + "str": "str" + }, + "provisioningStatus": "str", + "tags": { + "str": "str" + } + } """ @distributed_trace - def update_agent( + def create_or_update( self, - agent_id: str, - body: Union[JSON, IO[bytes]] = _Unset, + schedule_id: str, + schedule: Union[_types_models1.Schedule, IO[bytes]], *, - model: Optional[str] = None, - name: Optional[str] = None, - description: Optional[str] = None, - instructions: Optional[str] = None, - tools: Optional[List[_models.ToolDefinition]] = None, - tool_resources: Optional[_models.ToolResources] = None, - temperature: Optional[float] = None, - top_p: Optional[float] = None, - response_format: Optional["_types.AgentsResponseFormatOption"] = None, - metadata: Optional[dict[str, str]] = None, + foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], **kwargs: Any - ) -> _models.Agent: - """Modifies an existing agent. + ) -> _types_models1.Schedule: + """Create or update operation template. - :param agent_id: The ID of the agent to modify. Required. - :type agent_id: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword model: The ID of the model to use. Default value is None. - :paramtype model: str - :keyword name: The modified name for the agent to use. Default value is None. - :paramtype name: str - :keyword description: The modified description for the agent to use. Default value is None. - :paramtype description: str - :keyword instructions: The modified system instructions for the new agent to use. Default value - is None. - :paramtype instructions: str - :keyword tools: The modified collection of tools to enable for the agent. Default value is - None. - :paramtype tools: list[~azure.ai.agents.models.ToolDefinition] - :keyword tool_resources: 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. Default value is None. - :paramtype tool_resources: ~azure.ai.agents.models.ToolResources - :keyword temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 - will make the output more random, - while lower values like 0.2 will make it more focused and deterministic. Default value is - None. - :paramtype temperature: float - :keyword top_p: An alternative to sampling with temperature, called nucleus sampling, where the - model considers the results of the tokens with top_p probability mass. - So 0.1 means only the tokens comprising the top 10% probability mass are considered. - - We generally recommend altering this or temperature but not both. Default value is None. - :paramtype top_p: float - :keyword response_format: The response format of the tool calls used by this agent. Is one of - the following types: str, Union[str, "_models.AgentsResponseFormatMode"], AgentsResponseFormat, - ResponseFormatJsonSchemaType Default value is None. - :paramtype response_format: str or str or ~azure.ai.agents.models.AgentsResponseFormatMode or - ~azure.ai.agents.models.AgentsResponseFormat or - ~azure.ai.agents.models.ResponseFormatJsonSchemaType - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: Agent. The Agent is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.Agent + :param schedule_id: Identifier of the schedule. Required. + :type schedule_id: str + :param schedule: The resource instance. Is either a Schedule type or a IO[bytes] type. + Required. + :type schedule: ~azure.ai.agents.types.Schedule or IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. SCHEDULES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.SCHEDULES_V1_PREVIEW + :return: Schedule + :rtype: ~azure.ai.agents.types.Schedule :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "Cron": + trigger = { + "expression": "str", + "type": "Cron", + "endTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "timeZone": "str" + } + + # JSON input template for discriminator value "OneTime": + trigger = { + "triggerAt": "2020-02-20 00:00:00", + "type": "OneTime", + "timeZone": "str" + } + + # JSON input template for discriminator value "Recurrence": + trigger = { + "interval": 0, + "schedule": recurrence_schedule, + "type": "Recurrence", + "endTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "timeZone": "str" + } + + # JSON input template for discriminator value "Daily": + recurrence_schedule = { + "hours": [ + 0 + ], + "type": "Daily" + } + + # JSON input template for discriminator value "Hourly": + recurrence_schedule = { + "type": "Hourly" + } + + # JSON input template you can fill out and use as your body input. + schedule = { + "enabled": bool, + "id": "str", + "systemData": { + "str": "str" + }, + "task": schedule_task, + "trigger": trigger, + "description": "str", + "displayName": "str", + "properties": { + "str": "str" + }, + "provisioningStatus": "str", + "tags": { + "str": "str" + } + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "Cron": + trigger = { + "expression": "str", + "type": "Cron", + "endTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "timeZone": "str" + } + + # JSON input template for discriminator value "OneTime": + trigger = { + "triggerAt": "2020-02-20 00:00:00", + "type": "OneTime", + "timeZone": "str" + } + + # JSON input template for discriminator value "Recurrence": + trigger = { + "interval": 0, + "schedule": recurrence_schedule, + "type": "Recurrence", + "endTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "timeZone": "str" + } + + # JSON input template for discriminator value "Daily": + recurrence_schedule = { + "hours": [ + 0 + ], + "type": "Daily" + } + + # JSON input template for discriminator value "Hourly": + recurrence_schedule = { + "type": "Hourly" + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "Cron": + trigger = { + "expression": "str", + "type": "Cron", + "endTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "timeZone": "str" + } + + # JSON input template for discriminator value "OneTime": + trigger = { + "triggerAt": "2020-02-20 00:00:00", + "type": "OneTime", + "timeZone": "str" + } + + # JSON input template for discriminator value "Recurrence": + trigger = { + "interval": 0, + "schedule": recurrence_schedule, + "type": "Recurrence", + "endTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "timeZone": "str" + } + + # JSON input template for discriminator value "Daily": + recurrence_schedule = { + "hours": [ + 0 + ], + "type": "Daily" + } + + # JSON input template for discriminator value "Hourly": + recurrence_schedule = { + "type": "Hourly" + } + + # response body for status code(s): 201, 200 + response == { + "enabled": bool, + "id": "str", + "systemData": { + "str": "str" + }, + "task": schedule_task, + "trigger": trigger, + "description": "str", + "displayName": "str", + "properties": { + "str": "str" + }, + "provisioningStatus": "str", + "tags": { + "str": "str" + } + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -5761,33 +16817,22 @@ def update_agent( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Agent] = kwargs.pop("cls", None) + cls: ClsType[_types_models1.Schedule] = kwargs.pop("cls", None) - if body is _Unset: - body = { - "description": description, - "instructions": instructions, - "metadata": metadata, - "model": model, - "name": name, - "response_format": response_format, - "temperature": temperature, - "tool_resources": tool_resources, - "tools": tools, - "top_p": top_p, - } - body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" + _json = None _content = None - if isinstance(body, (IOBase, bytes)): - _content = body + if isinstance(schedule, (IOBase, bytes)): + _content = schedule else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _json = schedule - _request = build_agents_update_agent_request( - agent_id=agent_id, + _request = build_beta_schedules_create_or_update_request( + schedule_id=schedule_id, + foundry_features=foundry_features, content_type=content_type, api_version=self._config.api_version, + json=_json, content=_content, headers=_headers, params=_params, @@ -5797,6 +16842,7 @@ def update_agent( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -5804,20 +16850,22 @@ def update_agent( response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 201]: if _stream: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.Agent, response.json()) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -5825,14 +16873,41 @@ def update_agent( return deserialized # type: ignore @distributed_trace - def _delete_agent(self, agent_id: str, **kwargs: Any) -> _models._models.AgentDeletionStatus: - """Deletes an agent. + def get_run( + self, + schedule_id: str, + run_id: str, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], + **kwargs: Any + ) -> _types_models1.ScheduleRun: + """Get a schedule run by id. - :param agent_id: Identifier of the agent. Required. - :type agent_id: str - :return: AgentDeletionStatus. The AgentDeletionStatus is compatible with MutableMapping - :rtype: ~azure.ai.agents.models._models.AgentDeletionStatus + :param schedule_id: The unique identifier of the schedule. Required. + :type schedule_id: str + :param run_id: The unique identifier of the schedule run. Required. + :type run_id: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. SCHEDULES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.SCHEDULES_V1_PREVIEW + :return: ScheduleRun + :rtype: ~azure.ai.agents.types.ScheduleRun :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "id": "str", + "properties": { + "str": "str" + }, + "scheduleId": "str", + "success": bool, + "error": "str", + "triggerTime": "2020-02-20 00:00:00" + } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -5845,10 +16920,12 @@ def _delete_agent(self, agent_id: str, **kwargs: Any) -> _models._models.AgentDe _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models._models.AgentDeletionStatus] = kwargs.pop("cls", None) + cls: ClsType[_types_models1.ScheduleRun] = kwargs.pop("cls", None) - _request = build_agents_delete_agent_request( - agent_id=agent_id, + _request = build_beta_schedules_get_run_request( + schedule_id=schedule_id, + run_id=run_id, + foundry_features=foundry_features, api_version=self._config.api_version, headers=_headers, params=_params, @@ -5858,6 +16935,7 @@ def _delete_agent(self, agent_id: str, **kwargs: Any) -> _models._models.AgentDe } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -5872,257 +16950,71 @@ def _delete_agent(self, agent_id: str, **kwargs: Any) -> _models._models.AgentDe except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) + error = self._deserialize.failsafe_deserialize( + _types_models1.ApiErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize( - _models._models.AgentDeletionStatus, response.json() # pylint: disable=protected-access - ) + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - def create_thread_and_run( + @distributed_trace + def list_runs( self, + schedule_id: str, *, - agent_id: str, - content_type: str = "application/json", - thread: Optional[_models.AgentThreadCreationOptions] = None, - model: Optional[str] = None, - instructions: Optional[str] = None, - tools: Optional[List[_models.ToolDefinition]] = None, - tool_resources: Optional[_models.ToolResources] = None, - stream_parameter: Optional[bool] = None, - temperature: Optional[float] = None, - top_p: Optional[float] = None, - max_prompt_tokens: Optional[int] = None, - max_completion_tokens: Optional[int] = None, - truncation_strategy: Optional[_models.TruncationObject] = None, - tool_choice: Optional["_types.AgentsToolChoiceOption"] = None, - response_format: Optional["_types.AgentsResponseFormatOption"] = None, - parallel_tool_calls: Optional[bool] = None, - metadata: Optional[dict[str, str]] = None, + foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], + type: Optional[types.ScheduleTaskType] = None, + enabled: Optional[bool] = None, **kwargs: Any - ) -> _models.ThreadRun: - """Creates a new agent thread and immediately starts a run using that new thread. - - :keyword agent_id: The ID of the agent for which the thread should be created. Required. - :paramtype agent_id: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword thread: The details used to create the new thread. If no thread is provided, an empty - one will be created. Default value is None. - :paramtype thread: ~azure.ai.agents.models.AgentThreadCreationOptions - :keyword model: The overridden model that the agent should use to run the thread. Default value - is None. - :paramtype model: str - :keyword instructions: The overridden system instructions the agent should use to run the - thread. Default value is None. - :paramtype instructions: str - :keyword tools: The overridden list of enabled tools the agent should use to run the thread. - Default value is None. - :paramtype tools: list[~azure.ai.agents.models.ToolDefinition] - :keyword tool_resources: Override the tools the agent can use for this run. This is useful for - modifying the behavior on a per-run basis. Default value is None. - :paramtype tool_resources: ~azure.ai.agents.models.ToolResources - :keyword stream_parameter: 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. Default - value is None. - :paramtype stream_parameter: bool - :keyword temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 - will make the output - more random, while lower values like 0.2 will make it more focused and deterministic. Default - value is None. - :paramtype temperature: float - :keyword top_p: An alternative to sampling with temperature, called nucleus sampling, where the - model - considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens - comprising the top 10% probability mass are considered. - - We generally recommend altering this or temperature but not both. Default value is None. - :paramtype top_p: float - :keyword max_prompt_tokens: 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. Default - value is None. - :paramtype max_prompt_tokens: int - :keyword max_completion_tokens: 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. Default value is None. - :paramtype max_completion_tokens: int - :keyword truncation_strategy: The strategy to use for dropping messages as the context windows - moves forward. Default value is None. - :paramtype truncation_strategy: ~azure.ai.agents.models.TruncationObject - :keyword tool_choice: Controls whether or not and which tool is called by the model. Is one of - the following types: str, Union[str, "_models.AgentsToolChoiceOptionMode"], - AgentsNamedToolChoice Default value is None. - :paramtype tool_choice: str or str or ~azure.ai.agents.models.AgentsToolChoiceOptionMode or - ~azure.ai.agents.models.AgentsNamedToolChoice - :keyword response_format: Specifies the format that the model must output. Is one of the - following types: str, Union[str, "_models.AgentsResponseFormatMode"], AgentsResponseFormat, - ResponseFormatJsonSchemaType Default value is None. - :paramtype response_format: str or str or ~azure.ai.agents.models.AgentsResponseFormatMode or - ~azure.ai.agents.models.AgentsResponseFormat or - ~azure.ai.agents.models.ResponseFormatJsonSchemaType - :keyword parallel_tool_calls: If ``true`` functions will run in parallel during tool use. + ) -> ItemPaged["_types_models1.ScheduleRun"]: + """List all schedule runs. + + :param schedule_id: Identifier of the schedule. Required. + :type schedule_id: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. SCHEDULES_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.agents.models.SCHEDULES_V1_PREVIEW + :keyword type: Filter by the type of schedule. Known values are: "Evaluation" and "Insight". Default value is None. - :paramtype parallel_tool_calls: bool - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: ThreadRun. The ThreadRun is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadRun - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_thread_and_run( - self, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ThreadRun: - """Creates a new agent thread and immediately starts a run using that new thread. - - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ThreadRun. The ThreadRun is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadRun + :paramtype type: str or ~azure.ai.agents.models.ScheduleTaskType + :keyword enabled: Filter by the enabled status. Default value is None. + :paramtype enabled: bool + :return: An iterator like instance of ScheduleRun + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.types.ScheduleRun] :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_thread_and_run( - self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ThreadRun: - """Creates a new agent thread and immediately starts a run using that new thread. - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: ThreadRun. The ThreadRun is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadRun - :raises ~azure.core.exceptions.HttpResponseError: + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "id": "str", + "properties": { + "str": "str" + }, + "scheduleId": "str", + "success": bool, + "error": "str", + "triggerTime": "2020-02-20 00:00:00" + } """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - @distributed_trace - def create_thread_and_run( - self, - body: Union[JSON, IO[bytes]] = _Unset, - *, - agent_id: str = _Unset, - thread: Optional[_models.AgentThreadCreationOptions] = None, - model: Optional[str] = None, - instructions: Optional[str] = None, - tools: Optional[List[_models.ToolDefinition]] = None, - tool_resources: Optional[_models.ToolResources] = None, - stream_parameter: Optional[bool] = None, - temperature: Optional[float] = None, - top_p: Optional[float] = None, - max_prompt_tokens: Optional[int] = None, - max_completion_tokens: Optional[int] = None, - truncation_strategy: Optional[_models.TruncationObject] = None, - tool_choice: Optional["_types.AgentsToolChoiceOption"] = None, - response_format: Optional["_types.AgentsResponseFormatOption"] = None, - parallel_tool_calls: Optional[bool] = None, - metadata: Optional[dict[str, str]] = None, - **kwargs: Any - ) -> _models.ThreadRun: - """Creates a new agent thread and immediately starts a run using that new thread. + cls: ClsType[List[_types_models1.ScheduleRun]] = kwargs.pop("cls", None) - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword agent_id: The ID of the agent for which the thread should be created. Required. - :paramtype agent_id: str - :keyword thread: The details used to create the new thread. If no thread is provided, an empty - one will be created. Default value is None. - :paramtype thread: ~azure.ai.agents.models.AgentThreadCreationOptions - :keyword model: The overridden model that the agent should use to run the thread. Default value - is None. - :paramtype model: str - :keyword instructions: The overridden system instructions the agent should use to run the - thread. Default value is None. - :paramtype instructions: str - :keyword tools: The overridden list of enabled tools the agent should use to run the thread. - Default value is None. - :paramtype tools: list[~azure.ai.agents.models.ToolDefinition] - :keyword tool_resources: Override the tools the agent can use for this run. This is useful for - modifying the behavior on a per-run basis. Default value is None. - :paramtype tool_resources: ~azure.ai.agents.models.ToolResources - :keyword stream_parameter: 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. Default - value is None. - :paramtype stream_parameter: bool - :keyword temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 - will make the output - more random, while lower values like 0.2 will make it more focused and deterministic. Default - value is None. - :paramtype temperature: float - :keyword top_p: An alternative to sampling with temperature, called nucleus sampling, where the - model - considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens - comprising the top 10% probability mass are considered. - - We generally recommend altering this or temperature but not both. Default value is None. - :paramtype top_p: float - :keyword max_prompt_tokens: 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. Default - value is None. - :paramtype max_prompt_tokens: int - :keyword max_completion_tokens: 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. Default value is None. - :paramtype max_completion_tokens: int - :keyword truncation_strategy: The strategy to use for dropping messages as the context windows - moves forward. Default value is None. - :paramtype truncation_strategy: ~azure.ai.agents.models.TruncationObject - :keyword tool_choice: Controls whether or not and which tool is called by the model. Is one of - the following types: str, Union[str, "_models.AgentsToolChoiceOptionMode"], - AgentsNamedToolChoice Default value is None. - :paramtype tool_choice: str or str or ~azure.ai.agents.models.AgentsToolChoiceOptionMode or - ~azure.ai.agents.models.AgentsNamedToolChoice - :keyword response_format: Specifies the format that the model must output. Is one of the - following types: str, Union[str, "_models.AgentsResponseFormatMode"], AgentsResponseFormat, - ResponseFormatJsonSchemaType Default value is None. - :paramtype response_format: str or str or ~azure.ai.agents.models.AgentsResponseFormatMode or - ~azure.ai.agents.models.AgentsResponseFormat or - ~azure.ai.agents.models.ResponseFormatJsonSchemaType - :keyword parallel_tool_calls: If ``true`` functions will run in parallel during tool use. - Default value is None. - :paramtype parallel_tool_calls: bool - :keyword 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. Default value is - None. - :paramtype metadata: dict[str, str] - :return: ThreadRun. The ThreadRun is compatible with MutableMapping - :rtype: ~azure.ai.agents.models.ThreadRun - :raises ~azure.core.exceptions.HttpResponseError: - """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -6131,76 +17023,70 @@ def create_thread_and_run( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ThreadRun] = kwargs.pop("cls", None) - - if body is _Unset: - if agent_id is _Unset: - raise TypeError("missing required argument: agent_id") - body = { - "assistant_id": agent_id, - "instructions": instructions, - "max_completion_tokens": max_completion_tokens, - "max_prompt_tokens": max_prompt_tokens, - "metadata": metadata, - "model": model, - "parallel_tool_calls": parallel_tool_calls, - "response_format": response_format, - "stream": stream_parameter, - "temperature": temperature, - "thread": thread, - "tool_choice": tool_choice, - "tool_resources": tool_resources, - "tools": tools, - "top_p": top_p, - "truncation_strategy": truncation_strategy, - } - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + def prepare_request(next_link=None): + if not next_link: + + _request = build_beta_schedules_list_runs_request( + schedule_id=schedule_id, + foundry_features=foundry_features, + type=type, + enabled=enabled, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - _request = build_agents_create_thread_and_run_request( - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized.get("value", []) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) - response = pipeline_response.http_response + def get_next(next_link=None): + _request = prepare_request(next_link) - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.AgentV1Error, response) - raise HttpResponseError(response=response, model=error) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.ThreadRun, response.json()) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return pipeline_response - return deserialized # type: ignore + return ItemPaged(get_next, extract_data) diff --git a/sdk/ai/azure-ai-agents/azure/ai/agents/types.py b/sdk/ai/azure-ai-agents/azure/ai/agents/types.py new file mode 100644 index 000000000000..935b8ec4fc4d --- /dev/null +++ b/sdk/ai/azure-ai-agents/azure/ai/agents/types.py @@ -0,0 +1,3342 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Literal, Optional, TYPE_CHECKING, Union +from typing_extensions import Required, TypedDict + +from ..projects.models._enums import ToolType +from .models._enums import ( + AgentKind, + AgentObjectType, + CredentialType, + DatasetType, + DeploymentType, + EvaluationRuleActionType, + EvaluationTaxonomyInputType, + EvaluatorDefinitionType, + IndexType, + InsightType, + MemoryItemKind, + MemoryStoreKind, + MemoryStoreObjectType, + OpenApiAuthType, + PendingUploadType, + RecurrenceType, + SampleType, + ScheduleTaskType, + TriggerType, +) + +if TYPE_CHECKING: + from ..projects import types as _types_projects_models2 + +AgentDefinitionOptInKeys = Literal["HostedAgents=V1Preview", "WorkflowAgents=V1Preview"] +"""Feature opt-in keys for agent definition operations supporting hosted or workflow agents.""" + +AgentKind = Literal["prompt", "hosted", "workflow"] +"""Type of AgentKind.""" + +AgentObjectType = Literal["agent", "agent.version", "agent.deleted", "agent.version.deleted", "agent.container"] +"""Type of AgentObjectType.""" + +AgentProtocol = Literal["activity_protocol", "responses"] +"""Type of AgentProtocol.""" + +AttackStrategy = Literal[ + "easy", + "moderate", + "difficult", + "ascii_art", + "ascii_smuggler", + "atbash", + "base64", + "binary", + "caesar", + "character_space", + "jailbreak", + "ansi_attack", + "character_swap", + "suffix_append", + "string_join", + "unicode_confusable", + "unicode_substitution", + "diacritic", + "flip", + "leetspeak", + "rot13", + "morse", + "url", + "baseline", + "indirect_jailbreak", + "tense", + "multi_turn", + "crescendo", +] +"""Strategies for attacks.""" + +AzureAISearchQueryType = Literal["simple", "semantic", "vector", "vector_simple_hybrid", "vector_semantic_hybrid"] +"""Available query types for Azure AI Search tool.""" + +ConnectionType = Literal[ + "AzureOpenAI", + "AzureBlob", + "AzureStorageAccount", + "CognitiveSearch", + "CosmosDB", + "ApiKey", + "AppConfig", + "AppInsights", + "CustomKeys", + "RemoteTool_Preview", +] +"""The Type (or category) of the connection.""" + +CredentialType = Literal["ApiKey", "AAD", "SAS", "CustomKeys", "None", "AgenticIdentityToken_Preview"] +"""The credential type used by the connection.""" + +DatasetType = Literal["uri_file", "uri_folder"] +"""Enum to determine the type of data.""" + +DayOfWeek = Literal["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] +"""Days of the week for recurrence schedule.""" + +DeploymentType = Literal["ModelDeployment"] +"""Type of DeploymentType.""" + +EvaluationRuleActionType = Literal["continuousEvaluation", "humanEvaluationPreview"] +"""Type of the evaluation action.""" + +EvaluationRuleEventType = Literal["responseCompleted", "manual"] +"""Type of the evaluation rule event.""" + +EvaluationTaxonomyInputType = Literal["agent", "policy"] +"""Type of the evaluation taxonomy input.""" + +EvaluatorCategory = Literal["quality", "safety", "agents"] +"""The category of the evaluator.""" + +EvaluatorDefinitionType = Literal["prompt", "code", "prompt_and_code", "service", "openai_graders"] +"""The type of evaluator definition.""" + +EvaluatorMetricDirection = Literal["increase", "decrease", "neutral"] +"""The direction of the metric indicating whether a higher value is better, a lower value is +better, or neutral.""" + +EvaluatorMetricType = Literal["ordinal", "continuous", "boolean"] +"""The type of the evaluator.""" + +EvaluatorType = Literal["builtin", "custom"] +"""The type of the evaluator.""" + +FoundryFeaturesOptInKeys = Literal[ + "Evaluations=V1Preview", "Schedules=V1Preview", "RedTeams=V1Preview", "Insights=V1Preview", "MemoryStores=V1Preview" +] +"""Type of FoundryFeaturesOptInKeys.""" + +IndexType = Literal["AzureSearch", "CosmosDBNoSqlVectorStore", "ManagedAzureSearch"] +"""Type of IndexType.""" + +InsightType = Literal["EvaluationRunClusterInsight", "AgentClusterInsight", "EvaluationComparison"] +"""The request of the insights.""" + +MemoryItemKind = Literal["user_profile", "chat_summary"] +"""Memory item kind.""" + +MemoryOperationKind = Literal["create", "update", "delete"] +"""Memory operation kind.""" + +MemoryStoreKind = Literal["default"] +"""The type of memory store implementation to use.""" + +MemoryStoreObjectType = Literal["memory_store", "memory_store.deleted", "memory_store.scope.deleted"] +"""Type of MemoryStoreObjectType.""" + +MemoryStoreUpdateStatus = Literal["queued", "in_progress", "completed", "failed", "superseded"] +"""Status of a memory store update operation.""" + +OpenApiAuthType = Literal["anonymous", "project_connection", "managed_identity"] +"""Authentication type for OpenApi endpoint. Allowed types are: + +* Anonymous (no authentication required) +* Project Connection (requires project_connection_id to endpoint, as setup in AI Foundry) +* Managed_Identity (requires audience for identity based auth).""" + +OperationState = Literal["NotStarted", "Running", "Succeeded", "Failed", "Canceled"] +"""Enum describing allowed operation states.""" + +PageOrder = Literal["asc", "desc"] +"""Type of PageOrder.""" + +PendingUploadType = Literal["None", "BlobReference"] +"""The type of pending upload.""" + +RecurrenceType = Literal["Hourly", "Daily", "Weekly", "Monthly"] +"""Recurrence type.""" + +RiskCategory = Literal[ + "HateUnfairness", + "Violence", + "Sexual", + "SelfHarm", + "ProtectedMaterial", + "CodeVulnerability", + "UngroundedAttributes", + "ProhibitedActions", + "SensitiveDataLeakage", + "TaskAdherence", +] +"""Risk category for the attack objective.""" + +SampleType = Literal["EvaluationResultSample"] +"""The type of sample used in the analysis.""" + +ScheduleProvisioningStatus = Literal["Creating", "Updating", "Deleting", "Succeeded", "Failed"] +"""Schedule provisioning status.""" + +ScheduleTaskType = Literal["Evaluation", "Insight"] +"""Type of the task.""" + +TreatmentEffectType = Literal["TooFewSamples", "Inconclusive", "Changed", "Improved", "Degraded"] +"""Treatment Effect Type.""" + +TriggerType = Literal["Cron", "Recurrence", "OneTime"] +"""Type of the trigger.""" + + +class A2APreviewTool(TypedDict, total=False): + """An agent implementing the A2A protocol. + + :ivar type: The type of the tool. Always ``"a2a_preview``. Required. A2_A_PREVIEW. + :vartype type: str or ~azure.ai.projects.models.A2_A_PREVIEW + :ivar base_url: Base URL of the agent. + :vartype base_url: str + :ivar agent_card_path: The path to the agent card relative to the ``base_url``. If not + provided, defaults to ``/.well-known/agent-card.json``. + :vartype agent_card_path: str + :ivar project_connection_id: The connection ID in the project for the A2A server. The + connection stores authentication and other connection details needed to connect to the A2A + server. + :vartype project_connection_id: str + """ + + type: Required[Literal[ToolType.A2_A_PREVIEW]] + """The type of the tool. Always ``\"a2a_preview``. Required. A2_A_PREVIEW.""" + base_url: str + """Base URL of the agent.""" + agent_card_path: str + """The path to the agent card relative to the ``base_url``. If not provided, defaults to + ``/.well-known/agent-card.json``.""" + project_connection_id: str + """The connection ID in the project for the A2A server. The connection stores authentication and + other connection details needed to connect to the A2A server.""" + + +class AgentClusterInsightRequest(TypedDict, total=False): + """Insights on set of Agent Evaluation Results. + + :ivar type: The type of request. Required. Cluster Insight on an Agent. + :vartype type: str or ~azure.ai.agents.models.AGENT_CLUSTER_INSIGHT + :ivar agent_name: Identifier for the agent. Required. + :vartype agent_name: str + :ivar model_configuration: Configuration of the model used in the insight generation. + :vartype model_configuration: ~azure.ai.agents.types.InsightModelConfiguration + """ + + type: Required[Literal[InsightType.AGENT_CLUSTER_INSIGHT]] + """The type of request. Required. Cluster Insight on an Agent.""" + agentName: Required[str] + """Identifier for the agent. Required.""" + modelConfiguration: "InsightModelConfiguration" + """Configuration of the model used in the insight generation.""" + + +class AgentClusterInsightResult(TypedDict, total=False): + """Insights from the agent cluster analysis. + + :ivar type: The type of insights result. Required. Cluster Insight on an Agent. + :vartype type: str or ~azure.ai.agents.models.AGENT_CLUSTER_INSIGHT + :ivar cluster_insight: Required. + :vartype cluster_insight: ~azure.ai.agents.types.ClusterInsightResult + """ + + type: Required[Literal[InsightType.AGENT_CLUSTER_INSIGHT]] + """The type of insights result. Required. Cluster Insight on an Agent.""" + clusterInsight: Required["ClusterInsightResult"] + """Required.""" + + +class AgentDetails(TypedDict, total=False): + """AgentDetails. + + :ivar object: The object type, which is always 'agent'. Required. AGENT. + :vartype object: str or ~azure.ai.agents.models.AGENT + :ivar id: The unique identifier of the agent. Required. + :vartype id: str + :ivar name: The name of the agent. Required. + :vartype name: str + :ivar versions: The latest version of the agent. Required. + :vartype versions: ~azure.ai.agents.types.AgentObjectVersions + """ + + object: Required[Literal[AgentObjectType.AGENT]] + """The object type, which is always 'agent'. Required. AGENT.""" + id: Required[str] + """The unique identifier of the agent. Required.""" + name: Required[str] + """The name of the agent. Required.""" + versions: Required["AgentObjectVersions"] + """The latest version of the agent. Required.""" + + +class AgenticIdentityPreviewCredentials(TypedDict, total=False): + """Agentic identity credential definition. + + :ivar type: The credential type. Required. Agentic identity credential. + :vartype type: str or ~azure.ai.agents.models.AGENTIC_IDENTITY_PREVIEW + """ + + type: Required[Literal[CredentialType.AGENTIC_IDENTITY_PREVIEW]] + """The credential type. Required. Agentic identity credential.""" + + +class AgentObjectVersions(TypedDict, total=False): + """AgentObjectVersions. + + :ivar latest: Required. + :vartype latest: ~azure.ai.agents.types.AgentVersionDetails + """ + + latest: Required["AgentVersionDetails"] + """Required.""" + + +class AgentTaxonomyInput(TypedDict, total=False): + """Input configuration for the evaluation taxonomy when the input type is agent. + + :ivar type: Input type of the evaluation taxonomy. Required. Agent. + :vartype type: str or ~azure.ai.agents.models.AGENT + :ivar target: Target configuration for the agent. Required. + :vartype target: ~azure.ai.agents.types.Target + :ivar risk_categories: List of risk categories to evaluate against. Required. + :vartype risk_categories: list[str or ~azure.ai.agents.models.RiskCategory] + """ + + type: Required[Literal[EvaluationTaxonomyInputType.AGENT]] + """Input type of the evaluation taxonomy. Required. Agent.""" + target: Required["Target"] + """Target configuration for the agent. Required.""" + riskCategories: Required[list[RiskCategory]] + """List of risk categories to evaluate against. Required.""" + + +class AgentVersionDetails(TypedDict, total=False): + """AgentVersionDetails. + + :ivar metadata: Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. Required. + :vartype metadata: dict[str, str] + :ivar object: The object type, which is always 'agent.version'. Required. AGENT_VERSION. + :vartype object: str or ~azure.ai.agents.models.AGENT_VERSION + :ivar id: The unique identifier of the agent version. Required. + :vartype id: str + :ivar name: The name of the agent. Name can be used to retrieve/update/delete the agent. + Required. + :vartype name: str + :ivar version: The version identifier of the agent. Agents are immutable and every update + creates a new version while keeping the name same. Required. + :vartype version: str + :ivar description: A human-readable description of the agent. + :vartype description: str + :ivar created_at: The Unix timestamp (seconds) when the agent was created. Required. + :vartype created_at: ~datetime.datetime + :ivar definition: Required. + :vartype definition: ~azure.ai.agents.types.AgentDefinition + """ + + metadata: Required[Optional[dict[str, str]]] + """Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. Required.""" + object: Required[Literal[AgentObjectType.AGENT_VERSION]] + """The object type, which is always 'agent.version'. Required. AGENT_VERSION.""" + id: Required[str] + """The unique identifier of the agent version. Required.""" + name: Required[str] + """The name of the agent. Name can be used to retrieve/update/delete the agent. Required.""" + version: Required[str] + """The version identifier of the agent. Agents are immutable and every update creates a new + version while keeping the name same. Required.""" + description: str + """A human-readable description of the agent.""" + created_at: Required[int] + """The Unix timestamp (seconds) when the agent was created. Required.""" + definition: Required["AgentDefinition"] + """Required.""" + + +class AISearchIndexResource(TypedDict, total=False): + """A AI Search Index resource. + + :ivar project_connection_id: An index connection ID in an IndexResource attached to this agent. + :vartype project_connection_id: str + :ivar index_name: The name of an index in an IndexResource attached to this agent. + :vartype index_name: str + :ivar query_type: Type of query in an AIIndexResource attached to this agent. Known values are: + "simple", "semantic", "vector", "vector_simple_hybrid", and "vector_semantic_hybrid". + :vartype query_type: str or ~azure.ai.agents.models.AzureAISearchQueryType + :ivar top_k: Number of documents to retrieve from search and present to the model. + :vartype top_k: int + :ivar filter: filter string for search resource. `Learn more here + `_. + :vartype filter: str + :ivar index_asset_id: Index asset id for search resource. + :vartype index_asset_id: str + """ + + project_connection_id: str + """An index connection ID in an IndexResource attached to this agent.""" + index_name: str + """The name of an index in an IndexResource attached to this agent.""" + query_type: AzureAISearchQueryType + """Type of query in an AIIndexResource attached to this agent. Known values are: \"simple\", + \"semantic\", \"vector\", \"vector_simple_hybrid\", and \"vector_semantic_hybrid\".""" + top_k: int + """Number of documents to retrieve from search and present to the model.""" + filter: str + """filter string for search resource. `Learn more here + `_.""" + index_asset_id: str + """Index asset id for search resource.""" + + +class ApiErrorResponse(TypedDict, total=False): + """Error response for API failures. + + :ivar error: Required. + :vartype error: ~azure.ai.projects.types.ApiError + """ + + error: Required["ApiError"] + """Required.""" + + +class ApiKeyCredentials(TypedDict, total=False): + """API Key Credential definition. + + :ivar type: The credential type. Required. API Key credential. + :vartype type: str or ~azure.ai.agents.models.API_KEY + :ivar api_key: API Key. + :vartype api_key: str + """ + + type: Required[Literal[CredentialType.API_KEY]] + """The credential type. Required. API Key credential.""" + key: str + """API Key.""" + + +class AzureAIAgentTarget(TypedDict, total=False): + """Represents a target specifying an Azure AI agent. + + :ivar type: The type of target, always ``azure_ai_agent``. Required. Default value is + "azure_ai_agent". + :vartype type: str + :ivar name: The unique identifier of the Azure AI agent. Required. + :vartype name: str + :ivar version: The version of the Azure AI agent. + :vartype version: str + :ivar tool_descriptions: The parameters used to control the sampling behavior of the agent + during text generation. + :vartype tool_descriptions: list[~azure.ai.agents.types.ToolDescription] + """ + + type: Required[Literal["azure_ai_agent"]] + """The type of target, always ``azure_ai_agent``. Required. Default value is \"azure_ai_agent\".""" + name: Required[str] + """The unique identifier of the Azure AI agent. Required.""" + version: str + """The version of the Azure AI agent.""" + tool_descriptions: list["ToolDescription"] + """The parameters used to control the sampling behavior of the agent during text generation.""" + + +class AzureAIModelTarget(TypedDict, total=False): + """Represents a target specifying an Azure AI model for operations requiring model selection. + + :ivar type: The type of target, always ``azure_ai_model``. Required. Default value is + "azure_ai_model". + :vartype type: str + :ivar model: The unique identifier of the Azure AI model. + :vartype model: str + :ivar sampling_params: The parameters used to control the sampling behavior of the model during + text generation. + :vartype sampling_params: ~azure.ai.agents.types.ModelSamplingParams + """ + + type: Required[Literal["azure_ai_model"]] + """The type of target, always ``azure_ai_model``. Required. Default value is \"azure_ai_model\".""" + model: str + """The unique identifier of the Azure AI model.""" + sampling_params: "ModelSamplingParams" + """The parameters used to control the sampling behavior of the model during text generation.""" + + +class AzureAISearchIndex(TypedDict, total=False): + """Azure AI Search Index Definition. + + :ivar id: Asset ID, a unique identifier for the asset. + :vartype id: str + :ivar name: The name of the resource. Required. + :vartype name: str + :ivar version: The version of the resource. Required. + :vartype version: str + :ivar description: The asset description text. + :vartype description: str + :ivar tags: Tag dictionary. Tags can be added, removed, and updated. + :vartype tags: dict[str, str] + :ivar type: Type of index. Required. Azure search. + :vartype type: str or ~azure.ai.agents.models.AZURE_SEARCH + :ivar connection_name: Name of connection to Azure AI Search. Required. + :vartype connection_name: str + :ivar index_name: Name of index in Azure AI Search resource to attach. Required. + :vartype index_name: str + :ivar field_mapping: Field mapping configuration. + :vartype field_mapping: ~azure.ai.agents.types.FieldMapping + """ + + id: str + """Asset ID, a unique identifier for the asset.""" + name: Required[str] + """The name of the resource. Required.""" + version: Required[str] + """The version of the resource. Required.""" + description: str + """The asset description text.""" + tags: dict[str, str] + """Tag dictionary. Tags can be added, removed, and updated.""" + type: Required[Literal[IndexType.AZURE_SEARCH]] + """Type of index. Required. Azure search.""" + connectionName: Required[str] + """Name of connection to Azure AI Search. Required.""" + indexName: Required[str] + """Name of index in Azure AI Search resource to attach. Required.""" + fieldMapping: "FieldMapping" + """Field mapping configuration.""" + + +class AzureAISearchTool(TypedDict, total=False): + """The input definition information for an Azure AI search tool as used to configure an agent. + + :ivar type: The object type, which is always 'azure_ai_search'. Required. AZURE_AI_SEARCH. + :vartype type: str or ~azure.ai.projects.models.AZURE_AI_SEARCH + :ivar azure_ai_search: The azure ai search index resource. Required. + :vartype azure_ai_search: ~azure.ai.agents.types.AzureAISearchToolResource + """ + + type: Required[Literal[ToolType.AZURE_AI_SEARCH]] + """The object type, which is always 'azure_ai_search'. Required. AZURE_AI_SEARCH.""" + azure_ai_search: Required["AzureAISearchToolResource"] + """The azure ai search index resource. Required.""" + + +class AzureAISearchToolResource(TypedDict, total=False): + """A set of index resources used by the ``azure_ai_search`` tool. + + :ivar indexes: The indices attached to this agent. There can be a maximum of 1 index resource + attached to the agent. Required. + :vartype indexes: list[~azure.ai.agents.types.AISearchIndexResource] + """ + + indexes: Required[list["AISearchIndexResource"]] + """The indices attached to this agent. There can be a maximum of 1 index resource attached to the + agent. Required.""" + + +class AzureFunctionBinding(TypedDict, total=False): + """The structure for keeping storage queue name and URI. + + :ivar type: The type of binding, which is always 'storage_queue'. Required. Default value is + "storage_queue". + :vartype type: str + :ivar storage_queue: Storage queue. Required. + :vartype storage_queue: ~azure.ai.agents.types.AzureFunctionStorageQueue + """ + + type: Required[Literal["storage_queue"]] + """The type of binding, which is always 'storage_queue'. Required. Default value is + \"storage_queue\".""" + storage_queue: Required["AzureFunctionStorageQueue"] + """Storage queue. Required.""" + + +class AzureFunctionDefinition(TypedDict, total=False): + """The definition of Azure function. + + :ivar function: The definition of azure function and its parameters. Required. + :vartype function: ~azure.ai.agents.types.AzureFunctionDefinitionFunction + :ivar input_binding: Input storage queue. The queue storage trigger runs a function as messages + are added to it. Required. + :vartype input_binding: ~azure.ai.agents.types.AzureFunctionBinding + :ivar output_binding: Output storage queue. The function writes output to this queue when the + input items are processed. Required. + :vartype output_binding: ~azure.ai.agents.types.AzureFunctionBinding + """ + + function: Required["AzureFunctionDefinitionFunction"] + """The definition of azure function and its parameters. Required.""" + input_binding: Required["AzureFunctionBinding"] + """Input storage queue. The queue storage trigger runs a function as messages are added to it. + Required.""" + output_binding: Required["AzureFunctionBinding"] + """Output storage queue. The function writes output to this queue when the input items are + processed. Required.""" + + +class AzureFunctionDefinitionFunction(TypedDict, total=False): + """AzureFunctionDefinitionFunction. + + :ivar name: The name of the function to be called. Required. + :vartype name: str + :ivar description: A description of what the function does, used by the model to choose when + and how to call the function. + :vartype description: str + :ivar parameters: The parameters the functions accepts, described as a JSON Schema object. + Required. + :vartype parameters: dict[str, any] + """ + + name: Required[str] + """The name of the function to be called. Required.""" + description: str + """A description of what the function does, used by the model to choose when and how to call the + function.""" + parameters: Required[dict[str, Any]] + """The parameters the functions accepts, described as a JSON Schema object. Required.""" + + +class AzureFunctionStorageQueue(TypedDict, total=False): + """The structure for keeping storage queue name and URI. + + :ivar queue_service_endpoint: URI to the Azure Storage Queue service allowing you to manipulate + a queue. Required. + :vartype queue_service_endpoint: str + :ivar queue_name: The name of an Azure function storage queue. Required. + :vartype queue_name: str + """ + + queue_service_endpoint: Required[str] + """URI to the Azure Storage Queue service allowing you to manipulate a queue. Required.""" + queue_name: Required[str] + """The name of an Azure function storage queue. Required.""" + + +class AzureFunctionTool(TypedDict, total=False): + """The input definition information for an Azure Function Tool, as used to configure an Agent. + + :ivar type: The object type, which is always 'browser_automation'. Required. AZURE_FUNCTION. + :vartype type: str or ~azure.ai.projects.models.AZURE_FUNCTION + :ivar azure_function: The Azure Function Tool definition. Required. + :vartype azure_function: ~azure.ai.agents.types.AzureFunctionDefinition + """ + + type: Required[Literal[ToolType.AZURE_FUNCTION]] + """The object type, which is always 'browser_automation'. Required. AZURE_FUNCTION.""" + azure_function: Required["AzureFunctionDefinition"] + """The Azure Function Tool definition. Required.""" + + +class AzureOpenAIModelConfiguration(TypedDict, total=False): + """Azure OpenAI model configuration. The API version would be selected by the service for querying + the model. + + :ivar type: Required. Default value is "AzureOpenAIModel". + :vartype type: str + :ivar model_deployment_name: Deployment name for AOAI model. Example: gpt-4o if in AIServices + or connection based ``connection_name/deployment_name`` (e.g. ``my-aoai-connection/gpt-4o``). + Required. + :vartype model_deployment_name: str + """ + + type: Required[Literal["AzureOpenAIModel"]] + """Required. Default value is \"AzureOpenAIModel\".""" + modelDeploymentName: Required[str] + """Deployment name for AOAI model. Example: gpt-4o if in AIServices or connection based + ``connection_name/deployment_name`` (e.g. ``my-aoai-connection/gpt-4o``). Required.""" + + +class BingCustomSearchConfiguration(TypedDict, total=False): + """A bing custom search configuration. + + :ivar project_connection_id: Project connection id for grounding with bing search. Required. + :vartype project_connection_id: str + :ivar instance_name: Name of the custom configuration instance given to config. Required. + :vartype instance_name: str + :ivar market: The market where the results come from. + :vartype market: str + :ivar set_lang: The language to use for user interface strings when calling Bing API. + :vartype set_lang: str + :ivar count: The number of search results to return in the bing api response. + :vartype count: int + :ivar freshness: Filter search results by a specific time range. See `accepted values here + `_. + :vartype freshness: str + """ + + project_connection_id: Required[str] + """Project connection id for grounding with bing search. Required.""" + instance_name: Required[str] + """Name of the custom configuration instance given to config. Required.""" + market: str + """The market where the results come from.""" + set_lang: str + """The language to use for user interface strings when calling Bing API.""" + count: int + """The number of search results to return in the bing api response.""" + freshness: str + """Filter search results by a specific time range. See `accepted values here + `_.""" + + +class BingCustomSearchPreviewTool(TypedDict, total=False): + """The input definition information for a Bing custom search tool as used to configure an agent. + + :ivar type: The object type, which is always 'bing_custom_search_preview'. Required. + BING_CUSTOM_SEARCH_PREVIEW. + :vartype type: str or ~azure.ai.projects.models.BING_CUSTOM_SEARCH_PREVIEW + :ivar bing_custom_search_preview: The bing custom search tool parameters. Required. + :vartype bing_custom_search_preview: ~azure.ai.agents.types.BingCustomSearchToolParameters + """ + + type: Required[Literal[ToolType.BING_CUSTOM_SEARCH_PREVIEW]] + """The object type, which is always 'bing_custom_search_preview'. Required. + BING_CUSTOM_SEARCH_PREVIEW.""" + bing_custom_search_preview: Required["BingCustomSearchToolParameters"] + """The bing custom search tool parameters. Required.""" + + +class BingCustomSearchToolParameters(TypedDict, total=False): + """The bing custom search tool parameters. + + :ivar search_configurations: The project connections attached to this tool. There can be a + maximum of 1 connection resource attached to the tool. Required. + :vartype search_configurations: list[~azure.ai.agents.types.BingCustomSearchConfiguration] + """ + + search_configurations: Required[list["BingCustomSearchConfiguration"]] + """The project connections attached to this tool. There can be a maximum of 1 connection resource + attached to the tool. Required.""" + + +class BingGroundingSearchConfiguration(TypedDict, total=False): + """Search configuration for Bing Grounding. + + :ivar project_connection_id: Project connection id for grounding with bing search. Required. + :vartype project_connection_id: str + :ivar market: The market where the results come from. + :vartype market: str + :ivar set_lang: The language to use for user interface strings when calling Bing API. + :vartype set_lang: str + :ivar count: The number of search results to return in the bing api response. + :vartype count: int + :ivar freshness: Filter search results by a specific time range. See `accepted values here + `_. + :vartype freshness: str + """ + + project_connection_id: Required[str] + """Project connection id for grounding with bing search. Required.""" + market: str + """The market where the results come from.""" + set_lang: str + """The language to use for user interface strings when calling Bing API.""" + count: int + """The number of search results to return in the bing api response.""" + freshness: str + """Filter search results by a specific time range. See `accepted values here + `_.""" + + +class BingGroundingSearchToolParameters(TypedDict, total=False): + """The bing grounding search tool parameters. + + :ivar search_configurations: The search configurations attached to this tool. There can be a + maximum of 1 search configuration resource attached to the tool. Required. + :vartype search_configurations: list[~azure.ai.agents.types.BingGroundingSearchConfiguration] + """ + + search_configurations: Required[list["BingGroundingSearchConfiguration"]] + """The search configurations attached to this tool. There can be a maximum of 1 search + configuration resource attached to the tool. Required.""" + + +class BingGroundingTool(TypedDict, total=False): + """The input definition information for a bing grounding search tool as used to configure an + agent. + + :ivar type: The object type, which is always 'bing_grounding'. Required. BING_GROUNDING. + :vartype type: str or ~azure.ai.projects.models.BING_GROUNDING + :ivar bing_grounding: The bing grounding search tool parameters. Required. + :vartype bing_grounding: ~azure.ai.agents.types.BingGroundingSearchToolParameters + """ + + type: Required[Literal[ToolType.BING_GROUNDING]] + """The object type, which is always 'bing_grounding'. Required. BING_GROUNDING.""" + bing_grounding: Required["BingGroundingSearchToolParameters"] + """The bing grounding search tool parameters. Required.""" + + +class BlobReference(TypedDict, total=False): + """Blob reference details. + + :ivar blob_uri: Blob URI path for client to upload data. Example: + ``https://blob.windows.core.net/Container/Path``. Required. + :vartype blob_uri: str + :ivar storage_account_arm_id: ARM ID of the storage account to use. Required. + :vartype storage_account_arm_id: str + :ivar credential: Credential info to access the storage account. Required. + :vartype credential: ~azure.ai.agents.types.BlobReferenceSasCredential + """ + + blobUri: Required[str] + """Blob URI path for client to upload data. Example: + ``https://blob.windows.core.net/Container/Path``. Required.""" + storageAccountArmId: Required[str] + """ARM ID of the storage account to use. Required.""" + credential: Required["BlobReferenceSasCredential"] + """Credential info to access the storage account. Required.""" + + +class BlobReferenceSasCredential(TypedDict, total=False): + """SAS Credential definition. + + :ivar sas_uri: SAS uri. Required. + :vartype sas_uri: str + :ivar type: Type of credential. Required. Default value is "SAS". + :vartype type: str + """ + + sasUri: Required[str] + """SAS uri. Required.""" + type: Required[Literal["SAS"]] + """Type of credential. Required. Default value is \"SAS\".""" + + +class BrowserAutomationPreviewTool(TypedDict, total=False): + """The input definition information for a Browser Automation Tool, as used to configure an Agent. + + :ivar type: The object type, which is always 'browser_automation_preview'. Required. + BROWSER_AUTOMATION_PREVIEW. + :vartype type: str or ~azure.ai.projects.models.BROWSER_AUTOMATION_PREVIEW + :ivar browser_automation_preview: The Browser Automation Tool parameters. Required. + :vartype browser_automation_preview: ~azure.ai.agents.types.BrowserAutomationToolParameters + """ + + type: Required[Literal[ToolType.BROWSER_AUTOMATION_PREVIEW]] + """The object type, which is always 'browser_automation_preview'. Required. + BROWSER_AUTOMATION_PREVIEW.""" + browser_automation_preview: Required["BrowserAutomationToolParameters"] + """The Browser Automation Tool parameters. Required.""" + + +class BrowserAutomationToolConnectionParameters(TypedDict, total=False): # pylint: disable=name-too-long + """Definition of input parameters for the connection used by the Browser Automation Tool. + + :ivar project_connection_id: The ID of the project connection to your Azure Playwright + resource. Required. + :vartype project_connection_id: str + """ + + project_connection_id: Required[str] + """The ID of the project connection to your Azure Playwright resource. Required.""" + + +class BrowserAutomationToolParameters(TypedDict, total=False): + """Definition of input parameters for the Browser Automation Tool. + + :ivar connection: The project connection parameters associated with the Browser Automation + Tool. Required. + :vartype connection: ~azure.ai.agents.types.BrowserAutomationToolConnectionParameters + """ + + connection: Required["BrowserAutomationToolConnectionParameters"] + """The project connection parameters associated with the Browser Automation Tool. Required.""" + + +class CaptureStructuredOutputsTool(TypedDict, total=False): + """A tool for capturing structured outputs. + + :ivar type: The type of the tool. Always ``capture_structured_outputs``. Required. + CAPTURE_STRUCTURED_OUTPUTS. + :vartype type: str or ~azure.ai.projects.models.CAPTURE_STRUCTURED_OUTPUTS + :ivar outputs: The structured outputs to capture from the model. Required. + :vartype outputs: ~azure.ai.agents.types.StructuredOutputDefinition + """ + + type: Required[Literal[ToolType.CAPTURE_STRUCTURED_OUTPUTS]] + """The type of the tool. Always ``capture_structured_outputs``. Required. + CAPTURE_STRUCTURED_OUTPUTS.""" + outputs: Required["StructuredOutputDefinition"] + """The structured outputs to capture from the model. Required.""" + + +class ChartCoordinate(TypedDict, total=False): + """Coordinates for the analysis chart. + + :ivar x: X-axis coordinate. Required. + :vartype x: int + :ivar y: Y-axis coordinate. Required. + :vartype y: int + :ivar size: Size of the chart element. Required. + :vartype size: int + """ + + x: Required[int] + """X-axis coordinate. Required.""" + y: Required[int] + """Y-axis coordinate. Required.""" + size: Required[int] + """Size of the chart element. Required.""" + + +class ChatSummaryMemoryItem(TypedDict, total=False): + """A memory item containing a summary extracted from conversations. + + :ivar memory_id: The unique ID of the memory item. Required. + :vartype memory_id: str + :ivar updated_at: The last update time of the memory item. Required. + :vartype updated_at: ~datetime.datetime + :ivar scope: The namespace that logically groups and isolates memories, such as a user ID. + Required. + :vartype scope: str + :ivar content: The content of the memory. Required. + :vartype content: str + :ivar kind: The kind of the memory item. Required. Summary of chat conversations. + :vartype kind: str or ~azure.ai.agents.models.CHAT_SUMMARY + """ + + memory_id: Required[str] + """The unique ID of the memory item. Required.""" + updated_at: Required[int] + """The last update time of the memory item. Required.""" + scope: Required[str] + """The namespace that logically groups and isolates memories, such as a user ID. Required.""" + content: Required[str] + """The content of the memory. Required.""" + kind: Required[Literal[MemoryItemKind.CHAT_SUMMARY]] + """The kind of the memory item. Required. Summary of chat conversations.""" + + +class ClusterInsightResult(TypedDict, total=False): + """Insights from the cluster analysis. + + :ivar summary: Summary of the insights report. Required. + :vartype summary: ~azure.ai.agents.types.InsightSummary + :ivar clusters: List of clusters identified in the insights. Required. + :vartype clusters: list[~azure.ai.agents.types.InsightCluster] + :ivar coordinates: Optional mapping of IDs to 2D coordinates used by the UX for + visualization. + + The map keys are string identifiers (for example, a cluster id or a sample id) + and the values are the coordinates and visual size for rendering on a 2D chart. + + This property is omitted unless the client requests coordinates (for example, + by passing ``includeCoordinates=true`` as a query parameter). + + Example: + + .. code-block:: + + { + "cluster-1": { "x": 12, "y": 34, "size": 8 }, + "sample-123": { "x": 18, "y": 22, "size": 4 } + } + + Coordinates are intended only for client-side visualization and do not + modify the canonical insights results. + :vartype coordinates: dict[str, ~azure.ai.agents.types.ChartCoordinate] + """ + + summary: Required["InsightSummary"] + """Summary of the insights report. Required.""" + clusters: Required[list["InsightCluster"]] + """List of clusters identified in the insights. Required.""" + coordinates: dict[str, "ChartCoordinate"] + """ Optional mapping of IDs to 2D coordinates used by the UX for visualization. + + The map keys are string identifiers (for example, a cluster id or a sample id) + and the values are the coordinates and visual size for rendering on a 2D chart. + + This property is omitted unless the client requests coordinates (for example, + by passing ``includeCoordinates=true`` as a query parameter). + + Example: + + .. code-block:: + + { + \"cluster-1\": { \"x\": 12, \"y\": 34, \"size\": 8 }, + \"sample-123\": { \"x\": 18, \"y\": 22, \"size\": 4 } + } + + Coordinates are intended only for client-side visualization and do not + modify the canonical insights results.""" + + +class ClusterTokenUsage(TypedDict, total=False): + """Token usage for cluster analysis. + + :ivar input_token_usage: input token usage. Required. + :vartype input_token_usage: int + :ivar output_token_usage: output token usage. Required. + :vartype output_token_usage: int + :ivar total_token_usage: total token usage. Required. + :vartype total_token_usage: int + """ + + inputTokenUsage: Required[int] + """input token usage. Required.""" + outputTokenUsage: Required[int] + """output token usage. Required.""" + totalTokenUsage: Required[int] + """total token usage. Required.""" + + +class CodeBasedEvaluatorDefinition(TypedDict, total=False): + """Code-based evaluator definition using python code. + + :ivar init_parameters: The JSON schema (Draft 2020-12) for the evaluator's input parameters. + This includes parameters like type, properties, required. + :vartype init_parameters: dict[str, any] + :ivar data_schema: The JSON schema (Draft 2020-12) for the evaluator's input data. This + includes parameters like type, properties, required. + :vartype data_schema: dict[str, any] + :ivar metrics: List of output metrics produced by this evaluator. + :vartype metrics: dict[str, ~azure.ai.agents.types.EvaluatorMetric] + :ivar type: Required. Code-based definition. + :vartype type: str or ~azure.ai.agents.models.CODE + :ivar code_text: Inline code text for the evaluator. Required. + :vartype code_text: str + """ + + init_parameters: dict[str, Any] + """The JSON schema (Draft 2020-12) for the evaluator's input parameters. This includes parameters + like type, properties, required.""" + data_schema: dict[str, Any] + """The JSON schema (Draft 2020-12) for the evaluator's input data. This includes parameters like + type, properties, required.""" + metrics: dict[str, "EvaluatorMetric"] + """List of output metrics produced by this evaluator.""" + type: Required[Literal[EvaluatorDefinitionType.CODE]] + """Required. Code-based definition.""" + code_text: Required[str] + """Inline code text for the evaluator. Required.""" + + +class Connection(TypedDict, total=False): + """Response from the list and get connections operations. + + :ivar name: The friendly name of the connection, provided by the user. Required. + :vartype name: str + :ivar id: A unique identifier for the connection, generated by the service. Required. + :vartype id: str + :ivar type: Category of the connection. Required. Known values are: "AzureOpenAI", "AzureBlob", + "AzureStorageAccount", "CognitiveSearch", "CosmosDB", "ApiKey", "AppConfig", "AppInsights", + "CustomKeys", and "RemoteTool_Preview". + :vartype type: str or ~azure.ai.agents.models.ConnectionType + :ivar target: The connection URL to be used for this service. Required. + :vartype target: str + :ivar is_default: Whether the connection is tagged as the default connection of its type. + Required. + :vartype is_default: bool + :ivar credentials: The credentials used by the connection. Required. + :vartype credentials: ~azure.ai.agents.types.BaseCredentials + :ivar metadata: Metadata of the connection. Required. + :vartype metadata: dict[str, str] + """ + + name: Required[str] + """The friendly name of the connection, provided by the user. Required.""" + id: Required[str] + """A unique identifier for the connection, generated by the service. Required.""" + type: Required[ConnectionType] + """Category of the connection. Required. Known values are: \"AzureOpenAI\", \"AzureBlob\", + \"AzureStorageAccount\", \"CognitiveSearch\", \"CosmosDB\", \"ApiKey\", \"AppConfig\", + \"AppInsights\", \"CustomKeys\", and \"RemoteTool_Preview\".""" + target: Required[str] + """The connection URL to be used for this service. Required.""" + isDefault: Required[bool] + """Whether the connection is tagged as the default connection of its type. Required.""" + credentials: Required["BaseCredentials"] + """The credentials used by the connection. Required.""" + metadata: Required[dict[str, str]] + """Metadata of the connection. Required.""" + + +class ContinuousEvaluationRuleAction(TypedDict, total=False): + """Evaluation rule action for continuous evaluation. + + :ivar type: Required. Continuous evaluation. + :vartype type: str or ~azure.ai.agents.models.CONTINUOUS_EVALUATION + :ivar eval_id: Eval Id to add continuous evaluation runs to. Required. + :vartype eval_id: str + :ivar max_hourly_runs: Maximum number of evaluation runs allowed per hour. + :vartype max_hourly_runs: int + """ + + type: Required[Literal[EvaluationRuleActionType.CONTINUOUS_EVALUATION]] + """Required. Continuous evaluation.""" + evalId: Required[str] + """Eval Id to add continuous evaluation runs to. Required.""" + maxHourlyRuns: int + """Maximum number of evaluation runs allowed per hour.""" + + +class CosmosDBIndex(TypedDict, total=False): + """CosmosDB Vector Store Index Definition. + + :ivar id: Asset ID, a unique identifier for the asset. + :vartype id: str + :ivar name: The name of the resource. Required. + :vartype name: str + :ivar version: The version of the resource. Required. + :vartype version: str + :ivar description: The asset description text. + :vartype description: str + :ivar tags: Tag dictionary. Tags can be added, removed, and updated. + :vartype tags: dict[str, str] + :ivar type: Type of index. Required. CosmosDB. + :vartype type: str or ~azure.ai.agents.models.COSMOS_DB + :ivar connection_name: Name of connection to CosmosDB. Required. + :vartype connection_name: str + :ivar database_name: Name of the CosmosDB Database. Required. + :vartype database_name: str + :ivar container_name: Name of CosmosDB Container. Required. + :vartype container_name: str + :ivar embedding_configuration: Embedding model configuration. Required. + :vartype embedding_configuration: ~azure.ai.agents.types.EmbeddingConfiguration + :ivar field_mapping: Field mapping configuration. Required. + :vartype field_mapping: ~azure.ai.agents.types.FieldMapping + """ + + id: str + """Asset ID, a unique identifier for the asset.""" + name: Required[str] + """The name of the resource. Required.""" + version: Required[str] + """The version of the resource. Required.""" + description: str + """The asset description text.""" + tags: dict[str, str] + """Tag dictionary. Tags can be added, removed, and updated.""" + type: Required[Literal[IndexType.COSMOS_DB]] + """Type of index. Required. CosmosDB.""" + connectionName: Required[str] + """Name of connection to CosmosDB. Required.""" + databaseName: Required[str] + """Name of the CosmosDB Database. Required.""" + containerName: Required[str] + """Name of CosmosDB Container. Required.""" + embeddingConfiguration: Required["EmbeddingConfiguration"] + """Embedding model configuration. Required.""" + fieldMapping: Required["FieldMapping"] + """Field mapping configuration. Required.""" + + +class CronTrigger(TypedDict, total=False): + """Cron based trigger. + + :ivar type: Required. Cron based trigger. + :vartype type: str or ~azure.ai.agents.models.CRON + :ivar expression: Cron expression that defines the schedule frequency. Required. + :vartype expression: str + :ivar time_zone: Time zone for the cron schedule. + :vartype time_zone: str + :ivar start_time: Start time for the cron schedule in ISO 8601 format. + :vartype start_time: ~datetime.datetime + :ivar end_time: End time for the cron schedule in ISO 8601 format. + :vartype end_time: ~datetime.datetime + """ + + type: Required[Literal[TriggerType.CRON]] + """Required. Cron based trigger.""" + expression: Required[str] + """Cron expression that defines the schedule frequency. Required.""" + timeZone: str + """Time zone for the cron schedule.""" + startTime: str + """Start time for the cron schedule in ISO 8601 format.""" + endTime: str + """End time for the cron schedule in ISO 8601 format.""" + + +class CustomCredential(TypedDict, total=False): + """Custom credential definition. + + :ivar type: The credential type. Required. Custom credential. + :vartype type: str or ~azure.ai.agents.models.CUSTOM + """ + + type: Required[Literal[CredentialType.CUSTOM]] + """The credential type. Required. Custom credential.""" + + +class DailyRecurrenceSchedule(TypedDict, total=False): + """Daily recurrence schedule. + + :ivar type: Daily recurrence type. Required. Daily recurrence pattern. + :vartype type: str or ~azure.ai.agents.models.DAILY + :ivar hours: Hours for the recurrence schedule. Required. + :vartype hours: list[int] + """ + + type: Required[Literal[RecurrenceType.DAILY]] + """Daily recurrence type. Required. Daily recurrence pattern.""" + hours: Required[list[int]] + """Hours for the recurrence schedule. Required.""" + + +class DatasetCredential(TypedDict, total=False): + """Represents a reference to a blob for consumption. + + :ivar blob_reference: Credential info to access the storage account. Required. + :vartype blob_reference: ~azure.ai.agents.types.BlobReference + """ + + blobReference: Required["BlobReference"] + """Credential info to access the storage account. Required.""" + + +class DeleteAgentResponse(TypedDict, total=False): + """A deleted agent Object. + + :ivar object: The object type. Always 'agent.deleted'. Required. AGENT_DELETED. + :vartype object: str or ~azure.ai.agents.models.AGENT_DELETED + :ivar name: The name of the agent. Required. + :vartype name: str + :ivar deleted: Whether the agent was successfully deleted. Required. + :vartype deleted: bool + """ + + object: Required[Literal[AgentObjectType.AGENT_DELETED]] + """The object type. Always 'agent.deleted'. Required. AGENT_DELETED.""" + name: Required[str] + """The name of the agent. Required.""" + deleted: Required[bool] + """Whether the agent was successfully deleted. Required.""" + + +class DeleteAgentVersionResponse(TypedDict, total=False): + """A deleted agent version Object. + + :ivar object: The object type. Always 'agent.version.deleted'. Required. AGENT_VERSION_DELETED. + :vartype object: str or ~azure.ai.agents.models.AGENT_VERSION_DELETED + :ivar name: The name of the agent. Required. + :vartype name: str + :ivar version: The version identifier of the agent. Required. + :vartype version: str + :ivar deleted: Whether the agent was successfully deleted. Required. + :vartype deleted: bool + """ + + object: Required[Literal[AgentObjectType.AGENT_VERSION_DELETED]] + """The object type. Always 'agent.version.deleted'. Required. AGENT_VERSION_DELETED.""" + name: Required[str] + """The name of the agent. Required.""" + version: Required[str] + """The version identifier of the agent. Required.""" + deleted: Required[bool] + """Whether the agent was successfully deleted. Required.""" + + +class DeleteMemoryStoreResult(TypedDict, total=False): + """DeleteMemoryStoreResult. + + :ivar object: The object type. Always 'memory_store.deleted'. Required. MEMORY_STORE_DELETED. + :vartype object: str or ~azure.ai.agents.models.MEMORY_STORE_DELETED + :ivar name: The name of the memory store. Required. + :vartype name: str + :ivar deleted: Whether the memory store was successfully deleted. Required. + :vartype deleted: bool + """ + + object: Required[Literal[MemoryStoreObjectType.MEMORY_STORE_DELETED]] + """The object type. Always 'memory_store.deleted'. Required. MEMORY_STORE_DELETED.""" + name: Required[str] + """The name of the memory store. Required.""" + deleted: Required[bool] + """Whether the memory store was successfully deleted. Required.""" + + +class EmbeddingConfiguration(TypedDict, total=False): + """Embedding configuration class. + + :ivar model_deployment_name: Deployment name of embedding model. It can point to a model + deployment either in the parent AIServices or a connection. Required. + :vartype model_deployment_name: str + :ivar embedding_field: Embedding field. Required. + :vartype embedding_field: str + """ + + modelDeploymentName: Required[str] + """Deployment name of embedding model. It can point to a model deployment either in the parent + AIServices or a connection. Required.""" + embeddingField: Required[str] + """Embedding field. Required.""" + + +class EntraIDCredentials(TypedDict, total=False): + """Entra ID credential definition. + + :ivar type: The credential type. Required. Entra ID credential (formerly known as AAD). + :vartype type: str or ~azure.ai.agents.models.ENTRA_ID + """ + + type: Required[Literal[CredentialType.ENTRA_ID]] + """The credential type. Required. Entra ID credential (formerly known as AAD).""" + + +class EvalResult(TypedDict, total=False): + """Result of the evaluation. + + :ivar name: name of the check. Required. + :vartype name: str + :ivar type: type of the check. Required. + :vartype type: str + :ivar score: score. Required. + :vartype score: float + :ivar passed: indicates if the check passed or failed. Required. + :vartype passed: bool + """ + + name: Required[str] + """name of the check. Required.""" + type: Required[str] + """type of the check. Required.""" + score: Required[float] + """score. Required.""" + passed: Required[bool] + """indicates if the check passed or failed. Required.""" + + +class EvalRunResultCompareItem(TypedDict, total=False): + """Metric comparison for a treatment against the baseline. + + :ivar treatment_run_id: The treatment run ID. Required. + :vartype treatment_run_id: str + :ivar treatment_run_summary: Summary statistics of the treatment run. Required. + :vartype treatment_run_summary: ~azure.ai.agents.types.EvalRunResultSummary + :ivar delta_estimate: Estimated difference between treatment and baseline. Required. + :vartype delta_estimate: float + :ivar p_value: P-value for the treatment effect. Required. + :vartype p_value: float + :ivar treatment_effect: Type of treatment effect. Required. Known values are: "TooFewSamples", + "Inconclusive", "Changed", "Improved", and "Degraded". + :vartype treatment_effect: str or ~azure.ai.agents.models.TreatmentEffectType + """ + + treatmentRunId: Required[str] + """The treatment run ID. Required.""" + treatmentRunSummary: Required["EvalRunResultSummary"] + """Summary statistics of the treatment run. Required.""" + deltaEstimate: Required[float] + """Estimated difference between treatment and baseline. Required.""" + pValue: Required[float] + """P-value for the treatment effect. Required.""" + treatmentEffect: Required[TreatmentEffectType] + """Type of treatment effect. Required. Known values are: \"TooFewSamples\", \"Inconclusive\", + \"Changed\", \"Improved\", and \"Degraded\".""" + + +class EvalRunResultComparison(TypedDict, total=False): + """Comparison results for treatment runs against the baseline. + + :ivar testing_criteria: Name of the testing criteria. Required. + :vartype testing_criteria: str + :ivar metric: Metric being evaluated. Required. + :vartype metric: str + :ivar evaluator: Name of the evaluator for this testing criteria. Required. + :vartype evaluator: str + :ivar baseline_run_summary: Summary statistics of the baseline run. Required. + :vartype baseline_run_summary: ~azure.ai.agents.types.EvalRunResultSummary + :ivar compare_items: List of comparison results for each treatment run. Required. + :vartype compare_items: list[~azure.ai.agents.types.EvalRunResultCompareItem] + """ + + testingCriteria: Required[str] + """Name of the testing criteria. Required.""" + metric: Required[str] + """Metric being evaluated. Required.""" + evaluator: Required[str] + """Name of the evaluator for this testing criteria. Required.""" + baselineRunSummary: Required["EvalRunResultSummary"] + """Summary statistics of the baseline run. Required.""" + compareItems: Required[list["EvalRunResultCompareItem"]] + """List of comparison results for each treatment run. Required.""" + + +class EvalRunResultSummary(TypedDict, total=False): + """Summary statistics of a metric in an evaluation run. + + :ivar run_id: The evaluation run ID. Required. + :vartype run_id: str + :ivar sample_count: Number of samples in the evaluation run. Required. + :vartype sample_count: int + :ivar average: Average value of the metric in the evaluation run. Required. + :vartype average: float + :ivar standard_deviation: Standard deviation of the metric in the evaluation run. Required. + :vartype standard_deviation: float + """ + + runId: Required[str] + """The evaluation run ID. Required.""" + sampleCount: Required[int] + """Number of samples in the evaluation run. Required.""" + average: Required[float] + """Average value of the metric in the evaluation run. Required.""" + standardDeviation: Required[float] + """Standard deviation of the metric in the evaluation run. Required.""" + + +class EvaluationComparisonInsightRequest(TypedDict, total=False): + """Evaluation Comparison Request. + + :ivar type: The type of request. Required. Evaluation Comparison. + :vartype type: str or ~azure.ai.agents.models.EVALUATION_COMPARISON + :ivar eval_id: Identifier for the evaluation. Required. + :vartype eval_id: str + :ivar baseline_run_id: The baseline run ID for comparison. Required. + :vartype baseline_run_id: str + :ivar treatment_run_ids: List of treatment run IDs for comparison. Required. + :vartype treatment_run_ids: list[str] + """ + + type: Required[Literal[InsightType.EVALUATION_COMPARISON]] + """The type of request. Required. Evaluation Comparison.""" + evalId: Required[str] + """Identifier for the evaluation. Required.""" + baselineRunId: Required[str] + """The baseline run ID for comparison. Required.""" + treatmentRunIds: Required[list[str]] + """List of treatment run IDs for comparison. Required.""" + + +class EvaluationComparisonInsightResult(TypedDict, total=False): + """Insights from the evaluation comparison. + + :ivar type: The type of insights result. Required. Evaluation Comparison. + :vartype type: str or ~azure.ai.agents.models.EVALUATION_COMPARISON + :ivar comparisons: Comparison results for each treatment run against the baseline. Required. + :vartype comparisons: list[~azure.ai.agents.types.EvalRunResultComparison] + :ivar method: The statistical method used for comparison. Required. + :vartype method: str + """ + + type: Required[Literal[InsightType.EVALUATION_COMPARISON]] + """The type of insights result. Required. Evaluation Comparison.""" + comparisons: Required[list["EvalRunResultComparison"]] + """Comparison results for each treatment run against the baseline. Required.""" + method: Required[str] + """The statistical method used for comparison. Required.""" + + +class EvaluationResultSample(TypedDict, total=False): + """A sample from the evaluation result. + + :ivar id: The unique identifier for the analysis sample. Required. + :vartype id: str + :ivar features: Features to help with additional filtering of data in UX. Required. + :vartype features: dict[str, any] + :ivar correlation_info: Info about the correlation for the analysis sample. Required. + :vartype correlation_info: dict[str, any] + :ivar type: Evaluation Result Sample Type. Required. A sample from the evaluation result. + :vartype type: str or ~azure.ai.agents.models.EVALUATION_RESULT_SAMPLE + :ivar evaluation_result: Evaluation result for the analysis sample. Required. + :vartype evaluation_result: ~azure.ai.agents.types.EvalResult + """ + + id: Required[str] + """The unique identifier for the analysis sample. Required.""" + features: Required[dict[str, Any]] + """Features to help with additional filtering of data in UX. Required.""" + correlationInfo: Required[dict[str, Any]] + """Info about the correlation for the analysis sample. Required.""" + type: Required[Literal[SampleType.EVALUATION_RESULT_SAMPLE]] + """Evaluation Result Sample Type. Required. A sample from the evaluation result.""" + evaluationResult: Required["EvalResult"] + """Evaluation result for the analysis sample. Required.""" + + +class EvaluationRule(TypedDict, total=False): + """Evaluation rule model. + + :ivar id: Unique identifier for the evaluation rule. Required. + :vartype id: str + :ivar display_name: Display Name for the evaluation rule. + :vartype display_name: str + :ivar description: Description for the evaluation rule. + :vartype description: str + :ivar action: Definition of the evaluation rule action. Required. + :vartype action: ~azure.ai.agents.types.EvaluationRuleAction + :ivar filter: Filter condition of the evaluation rule. + :vartype filter: ~azure.ai.agents.types.EvaluationRuleFilter + :ivar event_type: Event type that the evaluation rule applies to. Required. Known values are: + "responseCompleted" and "manual". + :vartype event_type: str or ~azure.ai.agents.models.EvaluationRuleEventType + :ivar enabled: Indicates whether the evaluation rule is enabled. Default is true. Required. + :vartype enabled: bool + :ivar system_data: System metadata for the evaluation rule. Required. + :vartype system_data: dict[str, str] + """ + + id: Required[str] + """Unique identifier for the evaluation rule. Required.""" + displayName: str + """Display Name for the evaluation rule.""" + description: str + """Description for the evaluation rule.""" + action: Required["EvaluationRuleAction"] + """Definition of the evaluation rule action. Required.""" + filter: "EvaluationRuleFilter" + """Filter condition of the evaluation rule.""" + eventType: Required[EvaluationRuleEventType] + """Event type that the evaluation rule applies to. Required. Known values are: + \"responseCompleted\" and \"manual\".""" + enabled: Required[bool] + """Indicates whether the evaluation rule is enabled. Default is true. Required.""" + systemData: Required[dict[str, str]] + """System metadata for the evaluation rule. Required.""" + + +class EvaluationRuleFilter(TypedDict, total=False): + """Evaluation filter model. + + :ivar agent_name: Filter by agent name. Required. + :vartype agent_name: str + """ + + agentName: Required[str] + """Filter by agent name. Required.""" + + +class EvaluationRunClusterInsightRequest(TypedDict, total=False): + """Insights on set of Evaluation Results. + + :ivar type: The type of insights request. Required. Insights on an Evaluation run result. + :vartype type: str or ~azure.ai.agents.models.EVALUATION_RUN_CLUSTER_INSIGHT + :ivar eval_id: Evaluation Id for the insights. Required. + :vartype eval_id: str + :ivar run_ids: List of evaluation run IDs for the insights. Required. + :vartype run_ids: list[str] + :ivar model_configuration: Configuration of the model used in the insight generation. + :vartype model_configuration: ~azure.ai.agents.types.InsightModelConfiguration + """ + + type: Required[Literal[InsightType.EVALUATION_RUN_CLUSTER_INSIGHT]] + """The type of insights request. Required. Insights on an Evaluation run result.""" + evalId: Required[str] + """Evaluation Id for the insights. Required.""" + runIds: Required[list[str]] + """List of evaluation run IDs for the insights. Required.""" + modelConfiguration: "InsightModelConfiguration" + """Configuration of the model used in the insight generation.""" + + +class EvaluationRunClusterInsightResult(TypedDict, total=False): + """Insights from the evaluation run cluster analysis. + + :ivar type: The type of insights result. Required. Insights on an Evaluation run result. + :vartype type: str or ~azure.ai.agents.models.EVALUATION_RUN_CLUSTER_INSIGHT + :ivar cluster_insight: Required. + :vartype cluster_insight: ~azure.ai.agents.types.ClusterInsightResult + """ + + type: Required[Literal[InsightType.EVALUATION_RUN_CLUSTER_INSIGHT]] + """The type of insights result. Required. Insights on an Evaluation run result.""" + clusterInsight: Required["ClusterInsightResult"] + """Required.""" + + +class EvaluationScheduleTask(TypedDict, total=False): + """Evaluation task for the schedule. + + :ivar configuration: Configuration for the task. + :vartype configuration: dict[str, str] + :ivar type: Required. Evaluation task. + :vartype type: str or ~azure.ai.agents.models.EVALUATION + :ivar eval_id: Identifier of the evaluation group. Required. + :vartype eval_id: str + :ivar eval_run: The evaluation run payload. Required. + :vartype eval_run: any + """ + + configuration: dict[str, str] + """Configuration for the task.""" + type: Required[Literal[ScheduleTaskType.EVALUATION]] + """Required. Evaluation task.""" + evalId: Required[str] + """Identifier of the evaluation group. Required.""" + evalRun: Required[Any] + """The evaluation run payload. Required.""" + + +class EvaluationTaxonomy(TypedDict, total=False): + """Evaluation Taxonomy Definition. + + :ivar id: Asset ID, a unique identifier for the asset. + :vartype id: str + :ivar name: The name of the resource. Required. + :vartype name: str + :ivar version: The version of the resource. Required. + :vartype version: str + :ivar description: The asset description text. + :vartype description: str + :ivar tags: Tag dictionary. Tags can be added, removed, and updated. + :vartype tags: dict[str, str] + :ivar taxonomy_input: Input configuration for the evaluation taxonomy. Required. + :vartype taxonomy_input: ~azure.ai.agents.types.EvaluationTaxonomyInput + :ivar taxonomy_categories: List of taxonomy categories. + :vartype taxonomy_categories: list[~azure.ai.agents.types.TaxonomyCategory] + :ivar properties: Additional properties for the evaluation taxonomy. + :vartype properties: dict[str, str] + """ + + id: str + """Asset ID, a unique identifier for the asset.""" + name: Required[str] + """The name of the resource. Required.""" + version: Required[str] + """The version of the resource. Required.""" + description: str + """The asset description text.""" + tags: dict[str, str] + """Tag dictionary. Tags can be added, removed, and updated.""" + taxonomyInput: Required["EvaluationTaxonomyInput"] + """Input configuration for the evaluation taxonomy. Required.""" + taxonomyCategories: list["TaxonomyCategory"] + """List of taxonomy categories.""" + properties: dict[str, str] + """Additional properties for the evaluation taxonomy.""" + + +class EvaluatorMetric(TypedDict, total=False): + """Evaluator Metric. + + :ivar type: Type of the metric. Known values are: "ordinal", "continuous", and "boolean". + :vartype type: str or ~azure.ai.agents.models.EvaluatorMetricType + :ivar desirable_direction: It indicates whether a higher value is better or a lower value is + better for this metric. Known values are: "increase", "decrease", and "neutral". + :vartype desirable_direction: str or ~azure.ai.agents.models.EvaluatorMetricDirection + :ivar min_value: Minimum value for the metric. + :vartype min_value: float + :ivar max_value: Maximum value for the metric. If not specified, it is assumed to be unbounded. + :vartype max_value: float + :ivar is_primary: Indicates if this metric is primary when there are multiple metrics. + :vartype is_primary: bool + """ + + type: EvaluatorMetricType + """Type of the metric. Known values are: \"ordinal\", \"continuous\", and \"boolean\".""" + desirable_direction: EvaluatorMetricDirection + """It indicates whether a higher value is better or a lower value is better for this metric. Known + values are: \"increase\", \"decrease\", and \"neutral\".""" + min_value: float + """Minimum value for the metric.""" + max_value: float + """Maximum value for the metric. If not specified, it is assumed to be unbounded.""" + is_primary: bool + """Indicates if this metric is primary when there are multiple metrics.""" + + +class EvaluatorVersion(TypedDict, total=False): + """Evaluator Definition. + + :ivar display_name: Display Name for evaluator. It helps to find the evaluator easily in AI + Foundry. It does not need to be unique. + :vartype display_name: str + :ivar metadata: Metadata about the evaluator. + :vartype metadata: dict[str, str] + :ivar evaluator_type: The type of the evaluator. Required. Known values are: "builtin" and + "custom". + :vartype evaluator_type: str or ~azure.ai.agents.models.EvaluatorType + :ivar categories: The categories of the evaluator. Required. + :vartype categories: list[str or ~azure.ai.agents.models.EvaluatorCategory] + :ivar definition: Definition of the evaluator. Required. + :vartype definition: ~azure.ai.agents.types.EvaluatorDefinition + :ivar created_by: Creator of the evaluator. Required. + :vartype created_by: str + :ivar created_at: Creation date/time of the evaluator. Required. + :vartype created_at: ~datetime.datetime + :ivar modified_at: Last modified date/time of the evaluator. Required. + :vartype modified_at: ~datetime.datetime + :ivar id: Asset ID, a unique identifier for the asset. + :vartype id: str + :ivar name: The name of the resource. Required. + :vartype name: str + :ivar version: The version of the resource. Required. + :vartype version: str + :ivar description: The asset description text. + :vartype description: str + :ivar tags: Tag dictionary. Tags can be added, removed, and updated. + :vartype tags: dict[str, str] + """ + + display_name: str + """Display Name for evaluator. It helps to find the evaluator easily in AI Foundry. It does not + need to be unique.""" + metadata: dict[str, str] + """Metadata about the evaluator.""" + evaluator_type: Required[EvaluatorType] + """The type of the evaluator. Required. Known values are: \"builtin\" and \"custom\".""" + categories: Required[list[EvaluatorCategory]] + """The categories of the evaluator. Required.""" + definition: Required["EvaluatorDefinition"] + """Definition of the evaluator. Required.""" + created_by: Required[str] + """Creator of the evaluator. Required.""" + created_at: Required[str] + """Creation date/time of the evaluator. Required.""" + modified_at: Required[str] + """Last modified date/time of the evaluator. Required.""" + id: str + """Asset ID, a unique identifier for the asset.""" + name: Required[str] + """The name of the resource. Required.""" + version: Required[str] + """The version of the resource. Required.""" + description: str + """The asset description text.""" + tags: dict[str, str] + """Tag dictionary. Tags can be added, removed, and updated.""" + + +class FabricDataAgentToolParameters(TypedDict, total=False): + """The fabric data agent tool parameters. + + :ivar project_connections: The project connections attached to this tool. There can be a + maximum of 1 connection resource attached to the tool. + :vartype project_connections: list[~azure.ai.agents.types.ToolProjectConnection] + """ + + project_connections: list["ToolProjectConnection"] + """The project connections attached to this tool. There can be a maximum of 1 connection resource + attached to the tool.""" + + +class FieldMapping(TypedDict, total=False): + """Field mapping configuration class. + + :ivar content_fields: List of fields with text content. Required. + :vartype content_fields: list[str] + :ivar filepath_field: Path of file to be used as a source of text content. + :vartype filepath_field: str + :ivar title_field: Field containing the title of the document. + :vartype title_field: str + :ivar url_field: Field containing the url of the document. + :vartype url_field: str + :ivar vector_fields: List of fields with vector content. + :vartype vector_fields: list[str] + :ivar metadata_fields: List of fields with metadata content. + :vartype metadata_fields: list[str] + """ + + contentFields: Required[list[str]] + """List of fields with text content. Required.""" + filepathField: str + """Path of file to be used as a source of text content.""" + titleField: str + """Field containing the title of the document.""" + urlField: str + """Field containing the url of the document.""" + vectorFields: list[str] + """List of fields with vector content.""" + metadataFields: list[str] + """List of fields with metadata content.""" + + +class FileDatasetVersion(TypedDict, total=False): + """FileDatasetVersion Definition. + + :ivar data_uri: URI of the data (`example `_). + Required. + :vartype data_uri: str + :ivar is_reference: Indicates if the dataset holds a reference to the storage, or the dataset + manages storage itself. If true, the underlying data will not be deleted when the dataset + version is deleted. + :vartype is_reference: bool + :ivar connection_name: The Azure Storage Account connection name. Required if + startPendingUploadVersion was not called before creating the Dataset. + :vartype connection_name: str + :ivar id: Asset ID, a unique identifier for the asset. + :vartype id: str + :ivar name: The name of the resource. Required. + :vartype name: str + :ivar version: The version of the resource. Required. + :vartype version: str + :ivar description: The asset description text. + :vartype description: str + :ivar tags: Tag dictionary. Tags can be added, removed, and updated. + :vartype tags: dict[str, str] + :ivar type: Dataset type. Required. URI file. + :vartype type: str or ~azure.ai.agents.models.URI_FILE + """ + + dataUri: Required[str] + """URI of the data (`example `_). Required.""" + isReference: bool + """Indicates if the dataset holds a reference to the storage, or the dataset manages storage + itself. If true, the underlying data will not be deleted when the dataset version is deleted.""" + connectionName: str + """The Azure Storage Account connection name. Required if startPendingUploadVersion was not called + before creating the Dataset.""" + id: str + """Asset ID, a unique identifier for the asset.""" + name: Required[str] + """The name of the resource. Required.""" + version: Required[str] + """The version of the resource. Required.""" + description: str + """The asset description text.""" + tags: dict[str, str] + """Tag dictionary. Tags can be added, removed, and updated.""" + type: Required[Literal[DatasetType.URI_FILE]] + """Dataset type. Required. URI file.""" + + +class FolderDatasetVersion(TypedDict, total=False): + """FileDatasetVersion Definition. + + :ivar data_uri: URI of the data (`example `_). + Required. + :vartype data_uri: str + :ivar is_reference: Indicates if the dataset holds a reference to the storage, or the dataset + manages storage itself. If true, the underlying data will not be deleted when the dataset + version is deleted. + :vartype is_reference: bool + :ivar connection_name: The Azure Storage Account connection name. Required if + startPendingUploadVersion was not called before creating the Dataset. + :vartype connection_name: str + :ivar id: Asset ID, a unique identifier for the asset. + :vartype id: str + :ivar name: The name of the resource. Required. + :vartype name: str + :ivar version: The version of the resource. Required. + :vartype version: str + :ivar description: The asset description text. + :vartype description: str + :ivar tags: Tag dictionary. Tags can be added, removed, and updated. + :vartype tags: dict[str, str] + :ivar type: Dataset type. Required. URI folder. + :vartype type: str or ~azure.ai.agents.models.URI_FOLDER + """ + + dataUri: Required[str] + """URI of the data (`example `_). Required.""" + isReference: bool + """Indicates if the dataset holds a reference to the storage, or the dataset manages storage + itself. If true, the underlying data will not be deleted when the dataset version is deleted.""" + connectionName: str + """The Azure Storage Account connection name. Required if startPendingUploadVersion was not called + before creating the Dataset.""" + id: str + """Asset ID, a unique identifier for the asset.""" + name: Required[str] + """The name of the resource. Required.""" + version: Required[str] + """The version of the resource. Required.""" + description: str + """The asset description text.""" + tags: dict[str, str] + """Tag dictionary. Tags can be added, removed, and updated.""" + type: Required[Literal[DatasetType.URI_FOLDER]] + """Dataset type. Required. URI folder.""" + + +class HostedAgentDefinition(TypedDict, total=False): + """The hosted agent definition. + + :ivar rai_config: Configuration for Responsible AI (RAI) content filtering and safety features. + :vartype rai_config: ~azure.ai.agents.types.RaiConfig + :ivar kind: Required. HOSTED. + :vartype kind: str or ~azure.ai.agents.models.HOSTED + :ivar tools: An array of tools the hosted agent's model may call while generating a response. + You can specify which tool to use by setting the ``tool_choice`` parameter. + :vartype tools: list[~azure.ai.projects.types.Tool] + :ivar container_protocol_versions: The protocols that the agent supports for ingress + communication of the containers. Required. + :vartype container_protocol_versions: list[~azure.ai.agents.types.ProtocolVersionRecord] + :ivar cpu: The CPU configuration for the hosted agent. Required. + :vartype cpu: str + :ivar memory: The memory configuration for the hosted agent. Required. + :vartype memory: str + :ivar environment_variables: Environment variables to set in the hosted agent container. + :vartype environment_variables: dict[str, str] + :ivar image: The image ID for the agent, applicable to image-based hosted agents. + :vartype image: str + """ + + rai_config: "RaiConfig" + """Configuration for Responsible AI (RAI) content filtering and safety features.""" + kind: Required[Literal[AgentKind.HOSTED]] + """Required. HOSTED.""" + tools: list["Tool"] + """An array of tools the hosted agent's model may call while generating a response. You can + specify which tool to use by setting the ``tool_choice`` parameter.""" + container_protocol_versions: Required[list["ProtocolVersionRecord"]] + """The protocols that the agent supports for ingress communication of the containers. Required.""" + cpu: Required[str] + """The CPU configuration for the hosted agent. Required.""" + memory: Required[str] + """The memory configuration for the hosted agent. Required.""" + environment_variables: dict[str, str] + """Environment variables to set in the hosted agent container.""" + image: str + """The image ID for the agent, applicable to image-based hosted agents.""" + + +class HourlyRecurrenceSchedule(TypedDict, total=False): + """Hourly recurrence schedule. + + :ivar type: Required. Hourly recurrence pattern. + :vartype type: str or ~azure.ai.agents.models.HOURLY + """ + + type: Required[Literal[RecurrenceType.HOURLY]] + """Required. Hourly recurrence pattern.""" + + +class HumanEvaluationPreviewRuleAction(TypedDict, total=False): + """Evaluation rule action for human evaluation. + + :ivar type: Required. Human evaluation preview. + :vartype type: str or ~azure.ai.agents.models.HUMAN_EVALUATION_PREVIEW + :ivar template_id: Human evaluation template Id. Required. + :vartype template_id: str + """ + + type: Required[Literal[EvaluationRuleActionType.HUMAN_EVALUATION_PREVIEW]] + """Required. Human evaluation preview.""" + templateId: Required[str] + """Human evaluation template Id. Required.""" + + +class Insight(TypedDict, total=False): + """The response body for cluster insights. + + :ivar insight_id: The unique identifier for the insights report. Required. + :vartype insight_id: str + :ivar metadata: Metadata about the insights report. Required. + :vartype metadata: ~azure.ai.agents.types.InsightsMetadata + :ivar state: The current state of the insights. Required. Known values are: "NotStarted", + "Running", "Succeeded", "Failed", and "Canceled". + :vartype state: str or ~azure.ai.agents.models.OperationState + :ivar display_name: User friendly display name for the insight. Required. + :vartype display_name: str + :ivar request: Request for the insights analysis. Required. + :vartype request: ~azure.ai.agents.types.InsightRequest + :ivar result: The result of the insights report. + :vartype result: ~azure.ai.agents.types.InsightResult + """ + + id: Required[str] + """The unique identifier for the insights report. Required.""" + metadata: Required["InsightsMetadata"] + """Metadata about the insights report. Required.""" + state: Required[OperationState] + """The current state of the insights. Required. Known values are: \"NotStarted\", \"Running\", + \"Succeeded\", \"Failed\", and \"Canceled\".""" + displayName: Required[str] + """User friendly display name for the insight. Required.""" + request: Required["InsightRequest"] + """Request for the insights analysis. Required.""" + result: "InsightResult" + """The result of the insights report.""" + + +class InsightCluster(TypedDict, total=False): + """A cluster of analysis samples. + + :ivar id: The id of the analysis cluster. Required. + :vartype id: str + :ivar label: Label for the cluster. Required. + :vartype label: str + :ivar suggestion: Suggestion for the cluster. Required. + :vartype suggestion: str + :ivar suggestion_title: The title of the suggestion for the cluster. Required. + :vartype suggestion_title: str + :ivar description: Description of the analysis cluster. Required. + :vartype description: str + :ivar weight: The weight of the analysis cluster. This indicate number of samples in the + cluster. Required. + :vartype weight: int + :ivar sub_clusters: List of subclusters within this cluster. Empty if no subclusters exist. + :vartype sub_clusters: list[~azure.ai.agents.types.InsightCluster] + :ivar samples: List of samples that belong to this cluster. Empty if samples are part of + subclusters. + :vartype samples: list[~azure.ai.agents.types.InsightSample] + """ + + id: Required[str] + """The id of the analysis cluster. Required.""" + label: Required[str] + """Label for the cluster. Required.""" + suggestion: Required[str] + """Suggestion for the cluster. Required.""" + suggestionTitle: Required[str] + """The title of the suggestion for the cluster. Required.""" + description: Required[str] + """Description of the analysis cluster. Required.""" + weight: Required[int] + """The weight of the analysis cluster. This indicate number of samples in the cluster. Required.""" + subClusters: list["InsightCluster"] + """List of subclusters within this cluster. Empty if no subclusters exist.""" + samples: list["InsightSample"] + """List of samples that belong to this cluster. Empty if samples are part of subclusters.""" + + +class InsightModelConfiguration(TypedDict, total=False): + """Configuration of the model used in the insight generation. + + :ivar model_deployment_name: The model deployment to be evaluated. Accepts either the + deployment name alone or with the connection name as '{connectionName}/'. + Required. + :vartype model_deployment_name: str + """ + + modelDeploymentName: Required[str] + """The model deployment to be evaluated. Accepts either the deployment name alone or with the + connection name as '{connectionName}/'. Required.""" + + +class InsightScheduleTask(TypedDict, total=False): + """Insight task for the schedule. + + :ivar configuration: Configuration for the task. + :vartype configuration: dict[str, str] + :ivar type: Required. Insight task. + :vartype type: str or ~azure.ai.agents.models.INSIGHT + :ivar insight: The insight payload. Required. + :vartype insight: ~azure.ai.agents.types.Insight + """ + + configuration: dict[str, str] + """Configuration for the task.""" + type: Required[Literal[ScheduleTaskType.INSIGHT]] + """Required. Insight task.""" + insight: Required["Insight"] + """The insight payload. Required.""" + + +class InsightsMetadata(TypedDict, total=False): + """Metadata about the insights. + + :ivar created_at: The timestamp when the insights were created. Required. + :vartype created_at: ~datetime.datetime + :ivar completed_at: The timestamp when the insights were completed. + :vartype completed_at: ~datetime.datetime + """ + + createdAt: Required[str] + """The timestamp when the insights were created. Required.""" + completedAt: str + """The timestamp when the insights were completed.""" + + +class InsightSummary(TypedDict, total=False): + """Summary of the error cluster analysis. + + :ivar sample_count: Total number of samples analyzed. Required. + :vartype sample_count: int + :ivar unique_subcluster_count: Total number of unique subcluster labels. Required. + :vartype unique_subcluster_count: int + :ivar unique_cluster_count: Total number of unique clusters. Required. + :vartype unique_cluster_count: int + :ivar method: Method used for clustering. Required. + :vartype method: str + :ivar usage: Token usage while performing clustering analysis. Required. + :vartype usage: ~azure.ai.agents.types.ClusterTokenUsage + """ + + sampleCount: Required[int] + """Total number of samples analyzed. Required.""" + uniqueSubclusterCount: Required[int] + """Total number of unique subcluster labels. Required.""" + uniqueClusterCount: Required[int] + """Total number of unique clusters. Required.""" + method: Required[str] + """Method used for clustering. Required.""" + usage: Required["ClusterTokenUsage"] + """Token usage while performing clustering analysis. Required.""" + + +class ManagedAzureAISearchIndex(TypedDict, total=False): + """Managed Azure AI Search Index Definition. + + :ivar id: Asset ID, a unique identifier for the asset. + :vartype id: str + :ivar name: The name of the resource. Required. + :vartype name: str + :ivar version: The version of the resource. Required. + :vartype version: str + :ivar description: The asset description text. + :vartype description: str + :ivar tags: Tag dictionary. Tags can be added, removed, and updated. + :vartype tags: dict[str, str] + :ivar type: Type of index. Required. Managed Azure Search. + :vartype type: str or ~azure.ai.agents.models.MANAGED_AZURE_SEARCH + :ivar vector_store_id: Vector store id of managed index. Required. + :vartype vector_store_id: str + """ + + id: str + """Asset ID, a unique identifier for the asset.""" + name: Required[str] + """The name of the resource. Required.""" + version: Required[str] + """The version of the resource. Required.""" + description: str + """The asset description text.""" + tags: dict[str, str] + """Tag dictionary. Tags can be added, removed, and updated.""" + type: Required[Literal[IndexType.MANAGED_AZURE_SEARCH]] + """Type of index. Required. Managed Azure Search.""" + vectorStoreId: Required[str] + """Vector store id of managed index. Required.""" + + +class MemoryOperation(TypedDict, total=False): + """Represents a single memory operation (create, update, or delete) performed on a memory item. + + :ivar kind: The type of memory operation being performed. Required. Known values are: "create", + "update", and "delete". + :vartype kind: str or ~azure.ai.agents.models.MemoryOperationKind + :ivar memory_item: The memory item to create, update, or delete. Required. + :vartype memory_item: ~azure.ai.agents.types.MemoryItem + """ + + kind: Required[MemoryOperationKind] + """The type of memory operation being performed. Required. Known values are: \"create\", + \"update\", and \"delete\".""" + memory_item: Required["MemoryItem"] + """The memory item to create, update, or delete. Required.""" + + +class MemorySearchItem(TypedDict, total=False): + """A retrieved memory item from memory search. + + :ivar memory_item: Retrieved memory item. Required. + :vartype memory_item: ~azure.ai.agents.types.MemoryItem + """ + + memory_item: Required["MemoryItem"] + """Retrieved memory item. Required.""" + + +class MemorySearchOptions(TypedDict, total=False): + """Memory search options. + + :ivar max_memories: Maximum number of memory items to return. + :vartype max_memories: int + """ + + max_memories: int + """Maximum number of memory items to return.""" + + +class MemorySearchPreviewTool(TypedDict, total=False): + """A tool for integrating memories into the agent. + + :ivar type: The type of the tool. Always ``memory_search_preview``. Required. + MEMORY_SEARCH_PREVIEW. + :vartype type: str or ~azure.ai.projects.models.MEMORY_SEARCH_PREVIEW + :ivar memory_store_name: The name of the memory store to use. Required. + :vartype memory_store_name: str + :ivar scope: The namespace used to group and isolate memories, such as a user ID. Limits which + memories can be retrieved or updated. Use special variable ``{{$userId}}`` to scope memories to + the current signed-in user. Required. + :vartype scope: str + :ivar search_options: Options for searching the memory store. + :vartype search_options: ~azure.ai.agents.types.MemorySearchOptions + :ivar update_delay: Time to wait before updating memories after inactivity (seconds). Default + 300. + :vartype update_delay: int + """ + + type: Required[Literal[ToolType.MEMORY_SEARCH_PREVIEW]] + """The type of the tool. Always ``memory_search_preview``. Required. MEMORY_SEARCH_PREVIEW.""" + memory_store_name: Required[str] + """The name of the memory store to use. Required.""" + scope: Required[str] + """The namespace used to group and isolate memories, such as a user ID. Limits which memories can + be retrieved or updated. Use special variable ``{{$userId}}`` to scope memories to the current + signed-in user. Required.""" + search_options: "MemorySearchOptions" + """Options for searching the memory store.""" + update_delay: int + """Time to wait before updating memories after inactivity (seconds). Default 300.""" + + +class MemoryStoreDefaultDefinition(TypedDict, total=False): + """Default memory store implementation. + + :ivar kind: The kind of the memory store. Required. The default memory store implementation. + :vartype kind: str or ~azure.ai.agents.models.DEFAULT + :ivar chat_model: The name or identifier of the chat completion model deployment used for + memory processing. Required. + :vartype chat_model: str + :ivar embedding_model: The name or identifier of the embedding model deployment used for memory + processing. Required. + :vartype embedding_model: str + :ivar options: Default memory store options. + :vartype options: ~azure.ai.agents.types.MemoryStoreDefaultOptions + """ + + kind: Required[Literal[MemoryStoreKind.DEFAULT]] + """The kind of the memory store. Required. The default memory store implementation.""" + chat_model: Required[str] + """The name or identifier of the chat completion model deployment used for memory processing. + Required.""" + embedding_model: Required[str] + """The name or identifier of the embedding model deployment used for memory processing. Required.""" + options: "MemoryStoreDefaultOptions" + """Default memory store options.""" + + +class MemoryStoreDefaultOptions(TypedDict, total=False): + """Default memory store configurations. + + :ivar user_profile_enabled: Whether to enable user profile extraction and storage. Default is + true. Required. + :vartype user_profile_enabled: bool + :ivar user_profile_details: Specific categories or types of user profile information to extract + and store. + :vartype user_profile_details: str + :ivar chat_summary_enabled: Whether to enable chat summary extraction and storage. Default is + true. Required. + :vartype chat_summary_enabled: bool + """ + + user_profile_enabled: Required[bool] + """Whether to enable user profile extraction and storage. Default is true. Required.""" + user_profile_details: str + """Specific categories or types of user profile information to extract and store.""" + chat_summary_enabled: Required[bool] + """Whether to enable chat summary extraction and storage. Default is true. Required.""" + + +class MemoryStoreDeleteScopeResult(TypedDict, total=False): + """Response for deleting memories from a scope. + + :ivar object: The object type. Always 'memory_store.scope.deleted'. Required. + MEMORY_STORE_SCOPE_DELETED. + :vartype object: str or ~azure.ai.agents.models.MEMORY_STORE_SCOPE_DELETED + :ivar name: The name of the memory store. Required. + :vartype name: str + :ivar scope: The scope from which memories were deleted. Required. + :vartype scope: str + :ivar deleted: Whether the deletion operation was successful. Required. + :vartype deleted: bool + """ + + object: Required[Literal[MemoryStoreObjectType.MEMORY_STORE_SCOPE_DELETED]] + """The object type. Always 'memory_store.scope.deleted'. Required. MEMORY_STORE_SCOPE_DELETED.""" + name: Required[str] + """The name of the memory store. Required.""" + scope: Required[str] + """The scope from which memories were deleted. Required.""" + deleted: Required[bool] + """Whether the deletion operation was successful. Required.""" + + +class MemoryStoreDetails(TypedDict, total=False): + """A memory store that can store and retrieve user memories. + + :ivar object: The object type, which is always 'memory_store'. Required. MEMORY_STORE. + :vartype object: str or ~azure.ai.agents.models.MEMORY_STORE + :ivar id: The unique identifier of the memory store. Required. + :vartype id: str + :ivar created_at: The Unix timestamp (seconds) when the memory store was created. Required. + :vartype created_at: ~datetime.datetime + :ivar updated_at: The Unix timestamp (seconds) when the memory store was last updated. + Required. + :vartype updated_at: ~datetime.datetime + :ivar name: The name of the memory store. Required. + :vartype name: str + :ivar description: A human-readable description of the memory store. + :vartype description: str + :ivar metadata: Arbitrary key-value metadata to associate with the memory store. + :vartype metadata: dict[str, str] + :ivar definition: The definition of the memory store. Required. + :vartype definition: ~azure.ai.agents.types.MemoryStoreDefinition + """ + + object: Required[Literal[MemoryStoreObjectType.MEMORY_STORE]] + """The object type, which is always 'memory_store'. Required. MEMORY_STORE.""" + id: Required[str] + """The unique identifier of the memory store. Required.""" + created_at: Required[int] + """The Unix timestamp (seconds) when the memory store was created. Required.""" + updated_at: Required[int] + """The Unix timestamp (seconds) when the memory store was last updated. Required.""" + name: Required[str] + """The name of the memory store. Required.""" + description: str + """A human-readable description of the memory store.""" + metadata: dict[str, str] + """Arbitrary key-value metadata to associate with the memory store.""" + definition: Required["MemoryStoreDefinition"] + """The definition of the memory store. Required.""" + + +class MemoryStoreOperationUsage(TypedDict, total=False): + """Usage statistics of a memory store operation. + + :ivar embedding_tokens: The number of embedding tokens. Required. + :vartype embedding_tokens: int + :ivar input_tokens: The number of input tokens. Required. + :vartype input_tokens: int + :ivar input_tokens_details: A detailed breakdown of the input tokens. Required. + :vartype input_tokens_details: ~azure.ai.projects.types.ResponseUsageInputTokensDetails + :ivar output_tokens: The number of output tokens. Required. + :vartype output_tokens: int + :ivar output_tokens_details: A detailed breakdown of the output tokens. Required. + :vartype output_tokens_details: ~azure.ai.projects.types.ResponseUsageOutputTokensDetails + :ivar total_tokens: The total number of tokens used. Required. + :vartype total_tokens: int + """ + + embedding_tokens: Required[int] + """The number of embedding tokens. Required.""" + input_tokens: Required[int] + """The number of input tokens. Required.""" + input_tokens_details: Required["ResponseUsageInputTokensDetails"] + """A detailed breakdown of the input tokens. Required.""" + output_tokens: Required[int] + """The number of output tokens. Required.""" + output_tokens_details: Required["ResponseUsageOutputTokensDetails"] + """A detailed breakdown of the output tokens. Required.""" + total_tokens: Required[int] + """The total number of tokens used. Required.""" + + +class MemoryStoreSearchResult(TypedDict, total=False): + """Memory search response. + + :ivar search_id: The unique ID of this search request. Use this value as previous_search_id in + subsequent requests to perform incremental searches. Required. + :vartype search_id: str + :ivar memories: Related memory items found during the search operation. Required. + :vartype memories: list[~azure.ai.agents.types.MemorySearchItem] + :ivar usage: Usage statistics associated with the memory search operation. Required. + :vartype usage: ~azure.ai.agents.types.MemoryStoreOperationUsage + """ + + search_id: Required[str] + """The unique ID of this search request. Use this value as previous_search_id in subsequent + requests to perform incremental searches. Required.""" + memories: Required[list["MemorySearchItem"]] + """Related memory items found during the search operation. Required.""" + usage: Required["MemoryStoreOperationUsage"] + """Usage statistics associated with the memory search operation. Required.""" + + +class MemoryStoreUpdateCompletedResult(TypedDict, total=False): + """Memory update result. + + :ivar memory_operations: A list of individual memory operations that were performed during the + update. Required. + :vartype memory_operations: list[~azure.ai.agents.types.MemoryOperation] + :ivar usage: Usage statistics associated with the memory update operation. Required. + :vartype usage: ~azure.ai.agents.types.MemoryStoreOperationUsage + """ + + memory_operations: Required[list["MemoryOperation"]] + """A list of individual memory operations that were performed during the update. Required.""" + usage: Required["MemoryStoreOperationUsage"] + """Usage statistics associated with the memory update operation. Required.""" + + +class MemoryStoreUpdateResult(TypedDict, total=False): + """Provides the status of a memory store update operation. + + :ivar update_id: The unique ID of this update request. Use this value as previous_update_id in + subsequent requests to perform incremental updates. Required. + :vartype update_id: str + :ivar status: The status of the memory update operation. One of "queued", "in_progress", + "completed", "failed", or "superseded". Required. Known values are: "queued", "in_progress", + "completed", "failed", and "superseded". + :vartype status: str or ~azure.ai.agents.models.MemoryStoreUpdateStatus + :ivar superseded_by: The update_id the operation was superseded by when status is "superseded". + :vartype superseded_by: str + :ivar result: The result of memory store update operation when status is "completed". + :vartype result: ~azure.ai.agents.types.MemoryStoreUpdateCompletedResult + :ivar error: Error object that describes the error when status is "failed". + :vartype error: ~azure.ai.projects.types.ApiError + """ + + update_id: Required[str] + """The unique ID of this update request. Use this value as previous_update_id in subsequent + requests to perform incremental updates. Required.""" + status: Required[MemoryStoreUpdateStatus] + """The status of the memory update operation. One of \"queued\", \"in_progress\", \"completed\", + \"failed\", or \"superseded\". Required. Known values are: \"queued\", \"in_progress\", + \"completed\", \"failed\", and \"superseded\".""" + superseded_by: str + """The update_id the operation was superseded by when status is \"superseded\".""" + result: "MemoryStoreUpdateCompletedResult" + """The result of memory store update operation when status is \"completed\".""" + error: "ApiError" + """Error object that describes the error when status is \"failed\".""" + + +class MicrosoftFabricPreviewTool(TypedDict, total=False): + """The input definition information for a Microsoft Fabric tool as used to configure an agent. + + :ivar type: The object type, which is always 'fabric_dataagent_preview'. Required. + FABRIC_DATAAGENT_PREVIEW. + :vartype type: str or ~azure.ai.projects.models.FABRIC_DATAAGENT_PREVIEW + :ivar fabric_dataagent_preview: The fabric data agent tool parameters. Required. + :vartype fabric_dataagent_preview: ~azure.ai.agents.types.FabricDataAgentToolParameters + """ + + type: Required[Literal[ToolType.FABRIC_DATAAGENT_PREVIEW]] + """The object type, which is always 'fabric_dataagent_preview'. Required. + FABRIC_DATAAGENT_PREVIEW.""" + fabric_dataagent_preview: Required["FabricDataAgentToolParameters"] + """The fabric data agent tool parameters. Required.""" + + +class ModelDeployment(TypedDict, total=False): + """Model Deployment Definition. + + :ivar name: Name of the deployment. Required. + :vartype name: str + :ivar type: The type of the deployment. Required. Model deployment. + :vartype type: str or ~azure.ai.agents.models.MODEL_DEPLOYMENT + :ivar model_name: Publisher-specific name of the deployed model. Required. + :vartype model_name: str + :ivar model_version: Publisher-specific version of the deployed model. Required. + :vartype model_version: str + :ivar model_publisher: Name of the deployed model's publisher. Required. + :vartype model_publisher: str + :ivar capabilities: Capabilities of deployed model. Required. + :vartype capabilities: dict[str, str] + :ivar sku: Sku of the model deployment. Required. + :vartype sku: ~azure.ai.agents.types.ModelDeploymentSku + :ivar connection_name: Name of the connection the deployment comes from. + :vartype connection_name: str + """ + + name: Required[str] + """Name of the deployment. Required.""" + type: Required[Literal[DeploymentType.MODEL_DEPLOYMENT]] + """The type of the deployment. Required. Model deployment.""" + modelName: Required[str] + """Publisher-specific name of the deployed model. Required.""" + modelVersion: Required[str] + """Publisher-specific version of the deployed model. Required.""" + modelPublisher: Required[str] + """Name of the deployed model's publisher. Required.""" + capabilities: Required[dict[str, str]] + """Capabilities of deployed model. Required.""" + sku: Required["ModelDeploymentSku"] + """Sku of the model deployment. Required.""" + connectionName: str + """Name of the connection the deployment comes from.""" + + +class ModelDeploymentSku(TypedDict, total=False): + """Sku information. + + :ivar capacity: Sku capacity. Required. + :vartype capacity: int + :ivar family: Sku family. Required. + :vartype family: str + :ivar name: Sku name. Required. + :vartype name: str + :ivar size: Sku size. Required. + :vartype size: str + :ivar tier: Sku tier. Required. + :vartype tier: str + """ + + capacity: Required[int] + """Sku capacity. Required.""" + family: Required[str] + """Sku family. Required.""" + name: Required[str] + """Sku name. Required.""" + size: Required[str] + """Sku size. Required.""" + tier: Required[str] + """Sku tier. Required.""" + + +class ModelSamplingParams(TypedDict, total=False): + """Represents a set of parameters used to control the sampling behavior of a language model during + text generation. + + :ivar temperature: The temperature parameter for sampling. Required. + :vartype temperature: float + :ivar top_p: The top-p parameter for nucleus sampling. Required. + :vartype top_p: float + :ivar seed: The random seed for reproducibility. Required. + :vartype seed: int + :ivar max_completion_tokens: The maximum number of tokens allowed in the completion. Required. + :vartype max_completion_tokens: int + """ + + temperature: Required[float] + """The temperature parameter for sampling. Required.""" + top_p: Required[float] + """The top-p parameter for nucleus sampling. Required.""" + seed: Required[int] + """The random seed for reproducibility. Required.""" + max_completion_tokens: Required[int] + """The maximum number of tokens allowed in the completion. Required.""" + + +class MonthlyRecurrenceSchedule(TypedDict, total=False): + """Monthly recurrence schedule. + + :ivar type: Monthly recurrence type. Required. Monthly recurrence pattern. + :vartype type: str or ~azure.ai.agents.models.MONTHLY + :ivar days_of_month: Days of the month for the recurrence schedule. Required. + :vartype days_of_month: list[int] + """ + + type: Required[Literal[RecurrenceType.MONTHLY]] + """Monthly recurrence type. Required. Monthly recurrence pattern.""" + daysOfMonth: Required[list[int]] + """Days of the month for the recurrence schedule. Required.""" + + +class NoAuthenticationCredentials(TypedDict, total=False): + """Credentials that do not require authentication. + + :ivar type: The credential type. Required. No credential. + :vartype type: str or ~azure.ai.agents.models.NONE + """ + + type: Required[Literal[CredentialType.NONE]] + """The credential type. Required. No credential.""" + + +class OneTimeTrigger(TypedDict, total=False): + """One-time trigger. + + :ivar type: Required. One-time trigger. + :vartype type: str or ~azure.ai.agents.models.ONE_TIME + :ivar trigger_at: Date and time for the one-time trigger in ISO 8601 format. Required. + :vartype trigger_at: ~datetime.datetime + :ivar time_zone: Time zone for the one-time trigger. + :vartype time_zone: str + """ + + type: Required[Literal[TriggerType.ONE_TIME]] + """Required. One-time trigger.""" + triggerAt: Required[str] + """Date and time for the one-time trigger in ISO 8601 format. Required.""" + timeZone: str + """Time zone for the one-time trigger.""" + + +class OpenApiAnonymousAuthDetails(TypedDict, total=False): + """Security details for OpenApi anonymous authentication. + + :ivar type: The object type, which is always 'anonymous'. Required. ANONYMOUS. + :vartype type: str or ~azure.ai.agents.models.ANONYMOUS + """ + + type: Required[Literal[OpenApiAuthType.ANONYMOUS]] + """The object type, which is always 'anonymous'. Required. ANONYMOUS.""" + + +class OpenApiFunctionDefinition(TypedDict, total=False): + """The input definition information for an openapi function. + + :ivar name: The name of the function to be called. Required. + :vartype name: str + :ivar description: A description of what the function does, used by the model to choose when + and how to call the function. + :vartype description: str + :ivar spec: The openapi function shape, described as a JSON Schema object. Required. + :vartype spec: dict[str, any] + :ivar auth: Open API authentication details. Required. + :vartype auth: ~azure.ai.agents.types.OpenApiAuthDetails + :ivar default_params: List of OpenAPI spec parameters that will use user-provided defaults. + :vartype default_params: list[str] + :ivar functions: List of function definitions used by OpenApi tool. + :vartype functions: list[~azure.ai.agents.types.OpenApiFunctionDefinitionFunction] + """ + + name: Required[str] + """The name of the function to be called. Required.""" + description: str + """A description of what the function does, used by the model to choose when and how to call the + function.""" + spec: Required[dict[str, Any]] + """The openapi function shape, described as a JSON Schema object. Required.""" + auth: Required["OpenApiAuthDetails"] + """Open API authentication details. Required.""" + default_params: list[str] + """List of OpenAPI spec parameters that will use user-provided defaults.""" + functions: list["OpenApiFunctionDefinitionFunction"] + """List of function definitions used by OpenApi tool.""" + + +class OpenApiFunctionDefinitionFunction(TypedDict, total=False): + """OpenApiFunctionDefinitionFunction. + + :ivar name: The name of the function to be called. Required. + :vartype name: str + :ivar description: A description of what the function does, used by the model to choose when + and how to call the function. + :vartype description: str + :ivar parameters: The parameters the functions accepts, described as a JSON Schema object. + Required. + :vartype parameters: dict[str, any] + """ + + name: Required[str] + """The name of the function to be called. Required.""" + description: str + """A description of what the function does, used by the model to choose when and how to call the + function.""" + parameters: Required[dict[str, Any]] + """The parameters the functions accepts, described as a JSON Schema object. Required.""" + + +class OpenApiManagedAuthDetails(TypedDict, total=False): + """Security details for OpenApi managed_identity authentication. + + :ivar type: The object type, which is always 'managed_identity'. Required. MANAGED_IDENTITY. + :vartype type: str or ~azure.ai.agents.models.MANAGED_IDENTITY + :ivar security_scheme: Connection auth security details. Required. + :vartype security_scheme: ~azure.ai.agents.types.OpenApiManagedSecurityScheme + """ + + type: Required[Literal[OpenApiAuthType.MANAGED_IDENTITY]] + """The object type, which is always 'managed_identity'. Required. MANAGED_IDENTITY.""" + security_scheme: Required["OpenApiManagedSecurityScheme"] + """Connection auth security details. Required.""" + + +class OpenApiManagedSecurityScheme(TypedDict, total=False): + """Security scheme for OpenApi managed_identity authentication. + + :ivar audience: Authentication scope for managed_identity auth type. Required. + :vartype audience: str + """ + + audience: Required[str] + """Authentication scope for managed_identity auth type. Required.""" + + +class OpenApiProjectConnectionAuthDetails(TypedDict, total=False): + """Security details for OpenApi project connection authentication. + + :ivar type: The object type, which is always 'project_connection'. Required. + PROJECT_CONNECTION. + :vartype type: str or ~azure.ai.agents.models.PROJECT_CONNECTION + :ivar security_scheme: Project connection auth security details. Required. + :vartype security_scheme: ~azure.ai.agents.types.OpenApiProjectConnectionSecurityScheme + """ + + type: Required[Literal[OpenApiAuthType.PROJECT_CONNECTION]] + """The object type, which is always 'project_connection'. Required. PROJECT_CONNECTION.""" + security_scheme: Required["OpenApiProjectConnectionSecurityScheme"] + """Project connection auth security details. Required.""" + + +class OpenApiProjectConnectionSecurityScheme(TypedDict, total=False): + """Security scheme for OpenApi managed_identity authentication. + + :ivar project_connection_id: Project connection id for Project Connection auth type. Required. + :vartype project_connection_id: str + """ + + project_connection_id: Required[str] + """Project connection id for Project Connection auth type. Required.""" + + +class OpenApiTool(TypedDict, total=False): + """The input definition information for an OpenAPI tool as used to configure an agent. + + :ivar type: The object type, which is always 'openapi'. Required. OPENAPI. + :vartype type: str or ~azure.ai.projects.models.OPENAPI + :ivar openapi: The openapi function definition. Required. + :vartype openapi: ~azure.ai.agents.types.OpenApiFunctionDefinition + """ + + type: Required[Literal[ToolType.OPENAPI]] + """The object type, which is always 'openapi'. Required. OPENAPI.""" + openapi: Required["OpenApiFunctionDefinition"] + """The openapi function definition. Required.""" + + +class PendingUploadRequest(TypedDict, total=False): + """Represents a request for a pending upload. + + :ivar pending_upload_id: If PendingUploadId is not provided, a random GUID will be used. + :vartype pending_upload_id: str + :ivar connection_name: Azure Storage Account connection name to use for generating temporary + SAS token. + :vartype connection_name: str + :ivar pending_upload_type: BlobReference is the only supported type. Required. Blob Reference + is the only supported type. + :vartype pending_upload_type: str or ~azure.ai.agents.models.BLOB_REFERENCE + """ + + pendingUploadId: str + """If PendingUploadId is not provided, a random GUID will be used.""" + connectionName: str + """Azure Storage Account connection name to use for generating temporary SAS token.""" + pendingUploadType: Required[Literal[PendingUploadType.BLOB_REFERENCE]] + """BlobReference is the only supported type. Required. Blob Reference is the only supported type.""" + + +class PendingUploadResponse(TypedDict, total=False): + """Represents the response for a pending upload request. + + :ivar blob_reference: Container-level read, write, list SAS. Required. + :vartype blob_reference: ~azure.ai.agents.types.BlobReference + :ivar pending_upload_id: ID for this upload request. Required. + :vartype pending_upload_id: str + :ivar version: Version of asset to be created if user did not specify version when initially + creating upload. + :vartype version: str + :ivar pending_upload_type: BlobReference is the only supported type. Required. Blob Reference + is the only supported type. + :vartype pending_upload_type: str or ~azure.ai.agents.models.BLOB_REFERENCE + """ + + blobReference: Required["BlobReference"] + """Container-level read, write, list SAS. Required.""" + pendingUploadId: Required[str] + """ID for this upload request. Required.""" + version: str + """Version of asset to be created if user did not specify version when initially creating upload.""" + pendingUploadType: Required[Literal[PendingUploadType.BLOB_REFERENCE]] + """BlobReference is the only supported type. Required. Blob Reference is the only supported type.""" + + +class PromptAgentDefinition(TypedDict, total=False): + """The prompt agent definition. + + :ivar rai_config: Configuration for Responsible AI (RAI) content filtering and safety features. + :vartype rai_config: ~azure.ai.agents.types.RaiConfig + :ivar kind: Required. PROMPT. + :vartype kind: str or ~azure.ai.agents.models.PROMPT + :ivar model: The model deployment to use for this agent. Required. + :vartype model: str + :ivar instructions: A system (or developer) message inserted into the model's context. + :vartype instructions: str + :ivar temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 + will make the output more random, while lower values like 0.2 will make it more focused and + deterministic. We generally recommend altering this or ``top_p`` but not both. + :vartype temperature: float + :ivar top_p: 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. + :vartype top_p: float + :ivar reasoning: + :vartype reasoning: ~azure.ai.projects.types.Reasoning + :ivar tools: An array of tools the model may call while generating a response. You can specify + which tool to use by setting the ``tool_choice`` parameter. + :vartype tools: list[~azure.ai.projects.types.Tool] + :ivar tool_choice: How the model should select which tool (or tools) to use when generating a + response. See the ``tools`` parameter to see how to specify which tools the model can call. Is + either a str type or a ToolChoiceParam type. + :vartype tool_choice: str or ~azure.ai.projects.types.ToolChoiceParam + :ivar text: Configuration options for a text response from the model. Can be plain text or + structured JSON data. + :vartype text: ~azure.ai.agents.types.PromptAgentDefinitionTextOptions + :ivar structured_inputs: Set of structured inputs that can participate in prompt template + substitution or tool argument bindings. + :vartype structured_inputs: dict[str, ~azure.ai.agents.types.StructuredInputDefinition] + """ + + rai_config: "RaiConfig" + """Configuration for Responsible AI (RAI) content filtering and safety features.""" + kind: Required[Literal[AgentKind.PROMPT]] + """Required. PROMPT.""" + model: Required[str] + """The model deployment to use for this agent. Required.""" + instructions: Optional[str] + """A system (or developer) message inserted into the model's context.""" + temperature: Optional[float] + """What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output + more random, while lower values like 0.2 will make it more focused and deterministic. We + generally recommend altering this or ``top_p`` but not both.""" + top_p: Optional[float] + """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.""" + reasoning: Optional["Reasoning"] + tools: list["Tool"] + """An array of tools the model may call while generating a response. You can specify which tool to + use by setting the ``tool_choice`` parameter.""" + tool_choice: Union[str, "ToolChoiceParam"] + """How the model should select which tool (or tools) to use when generating a response. See the + ``tools`` parameter to see how to specify which tools the model can call. Is either a str type + or a ToolChoiceParam type.""" + text: "PromptAgentDefinitionTextOptions" + """Configuration options for a text response from the model. Can be plain text or structured JSON + data.""" + structured_inputs: dict[str, "StructuredInputDefinition"] + """Set of structured inputs that can participate in prompt template substitution or tool argument + bindings.""" + + +class PromptAgentDefinitionTextOptions(TypedDict, total=False): + """Configuration options for a text response from the model. Can be plain text or structured JSON + data. + + :ivar format: + :vartype format: ~azure.ai.projects.types.TextResponseFormat + """ + + format: "TextResponseFormat" + + +class PromptBasedEvaluatorDefinition(TypedDict, total=False): + """Prompt-based evaluator. + + :ivar init_parameters: The JSON schema (Draft 2020-12) for the evaluator's input parameters. + This includes parameters like type, properties, required. + :vartype init_parameters: dict[str, any] + :ivar data_schema: The JSON schema (Draft 2020-12) for the evaluator's input data. This + includes parameters like type, properties, required. + :vartype data_schema: dict[str, any] + :ivar metrics: List of output metrics produced by this evaluator. + :vartype metrics: dict[str, ~azure.ai.agents.types.EvaluatorMetric] + :ivar type: Required. Prompt-based definition. + :vartype type: str or ~azure.ai.agents.models.PROMPT + :ivar prompt_text: The prompt text used for evaluation. Required. + :vartype prompt_text: str + """ + + init_parameters: dict[str, Any] + """The JSON schema (Draft 2020-12) for the evaluator's input parameters. This includes parameters + like type, properties, required.""" + data_schema: dict[str, Any] + """The JSON schema (Draft 2020-12) for the evaluator's input data. This includes parameters like + type, properties, required.""" + metrics: dict[str, "EvaluatorMetric"] + """List of output metrics produced by this evaluator.""" + type: Required[Literal[EvaluatorDefinitionType.PROMPT]] + """Required. Prompt-based definition.""" + prompt_text: Required[str] + """The prompt text used for evaluation. Required.""" + + +class ProtocolVersionRecord(TypedDict, total=False): + """A record mapping for a single protocol and its version. + + :ivar protocol: The protocol type. Required. Known values are: "activity_protocol" and + "responses". + :vartype protocol: str or ~azure.ai.agents.models.AgentProtocol + :ivar version: The version string for the protocol, e.g. 'v0.1.1'. Required. + :vartype version: str + """ + + protocol: Required[AgentProtocol] + """The protocol type. Required. Known values are: \"activity_protocol\" and \"responses\".""" + version: Required[str] + """The version string for the protocol, e.g. 'v0.1.1'. Required.""" + + +class RaiConfig(TypedDict, total=False): + """Configuration for Responsible AI (RAI) content filtering and safety features. + + :ivar rai_policy_name: The name of the RAI policy to apply. Required. + :vartype rai_policy_name: str + """ + + rai_policy_name: Required[str] + """The name of the RAI policy to apply. Required.""" + + +class RecurrenceTrigger(TypedDict, total=False): + """Recurrence based trigger. + + :ivar type: Type of the trigger. Required. Recurrence based trigger. + :vartype type: str or ~azure.ai.agents.models.RECURRENCE + :ivar start_time: Start time for the recurrence schedule in ISO 8601 format. + :vartype start_time: ~datetime.datetime + :ivar end_time: End time for the recurrence schedule in ISO 8601 format. + :vartype end_time: ~datetime.datetime + :ivar time_zone: Time zone for the recurrence schedule. + :vartype time_zone: str + :ivar interval: Interval for the recurrence schedule. Required. + :vartype interval: int + :ivar schedule: Recurrence schedule for the recurrence trigger. Required. + :vartype schedule: ~azure.ai.agents.types.RecurrenceSchedule + """ + + type: Required[Literal[TriggerType.RECURRENCE]] + """Type of the trigger. Required. Recurrence based trigger.""" + startTime: str + """Start time for the recurrence schedule in ISO 8601 format.""" + endTime: str + """End time for the recurrence schedule in ISO 8601 format.""" + timeZone: str + """Time zone for the recurrence schedule.""" + interval: Required[int] + """Interval for the recurrence schedule. Required.""" + schedule: Required["RecurrenceSchedule"] + """Recurrence schedule for the recurrence trigger. Required.""" + + +class RedTeam(TypedDict, total=False): + """Red team details. + + :ivar name: Identifier of the red team run. Required. + :vartype name: str + :ivar display_name: Name of the red-team run. + :vartype display_name: str + :ivar num_turns: Number of simulation rounds. + :vartype num_turns: int + :ivar attack_strategies: List of attack strategies or nested lists of attack strategies. + :vartype attack_strategies: list[str or ~azure.ai.agents.models.AttackStrategy] + :ivar simulation_only: Simulation-only or Simulation + Evaluation. Default false, if true the + scan outputs conversation not evaluation result. + :vartype simulation_only: bool + :ivar risk_categories: List of risk categories to generate attack objectives for. + :vartype risk_categories: list[str or ~azure.ai.agents.models.RiskCategory] + :ivar application_scenario: Application scenario for the red team operation, to generate + scenario specific attacks. + :vartype application_scenario: str + :ivar tags: Red team's tags. Unlike properties, tags are fully mutable. + :vartype tags: dict[str, str] + :ivar properties: Red team's properties. Unlike tags, properties are add-only. Once added, a + property cannot be removed. + :vartype properties: dict[str, str] + :ivar status: Status of the red-team. It is set by service and is read-only. + :vartype status: str + :ivar target: Target configuration for the red-team run. Required. + :vartype target: ~azure.ai.agents.types.TargetConfig + """ + + id: Required[str] + """Identifier of the red team run. Required.""" + displayName: str + """Name of the red-team run.""" + numTurns: int + """Number of simulation rounds.""" + attackStrategies: list[AttackStrategy] + """List of attack strategies or nested lists of attack strategies.""" + simulationOnly: bool + """Simulation-only or Simulation + Evaluation. Default false, if true the scan outputs + conversation not evaluation result.""" + riskCategories: list[RiskCategory] + """List of risk categories to generate attack objectives for.""" + applicationScenario: str + """Application scenario for the red team operation, to generate scenario specific attacks.""" + tags: dict[str, str] + """Red team's tags. Unlike properties, tags are fully mutable.""" + properties: dict[str, str] + """Red team's properties. Unlike tags, properties are add-only. Once added, a property cannot be + removed.""" + status: str + """Status of the red-team. It is set by service and is read-only.""" + target: Required["TargetConfig"] + """Target configuration for the red-team run. Required.""" + + +class SASCredentials(TypedDict, total=False): + """Shared Access Signature (SAS) credential definition. + + :ivar type: The credential type. Required. Shared Access Signature (SAS) credential. + :vartype type: str or ~azure.ai.agents.models.SAS + :ivar sas_token: SAS token. + :vartype sas_token: str + """ + + type: Required[Literal[CredentialType.SAS]] + """The credential type. Required. Shared Access Signature (SAS) credential.""" + SAS: str + """SAS token.""" + + +class Schedule(TypedDict, total=False): + """Schedule model. + + :ivar schedule_id: Identifier of the schedule. Required. + :vartype schedule_id: str + :ivar display_name: Name of the schedule. + :vartype display_name: str + :ivar description: Description of the schedule. + :vartype description: str + :ivar enabled: Enabled status of the schedule. Required. + :vartype enabled: bool + :ivar provisioning_status: Provisioning status of the schedule. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", and "Failed". + :vartype provisioning_status: str or ~azure.ai.agents.models.ScheduleProvisioningStatus + :ivar trigger: Trigger for the schedule. Required. + :vartype trigger: ~azure.ai.agents.types.Trigger + :ivar task: Task for the schedule. Required. + :vartype task: ~azure.ai.agents.types.ScheduleTask + :ivar tags: Schedule's tags. Unlike properties, tags are fully mutable. + :vartype tags: dict[str, str] + :ivar properties: Schedule's properties. Unlike tags, properties are add-only. Once added, a + property cannot be removed. + :vartype properties: dict[str, str] + :ivar system_data: System metadata for the resource. Required. + :vartype system_data: dict[str, str] + """ + + id: Required[str] + """Identifier of the schedule. Required.""" + displayName: str + """Name of the schedule.""" + description: str + """Description of the schedule.""" + enabled: Required[bool] + """Enabled status of the schedule. Required.""" + provisioningStatus: ScheduleProvisioningStatus + """Provisioning status of the schedule. Known values are: \"Creating\", \"Updating\", + \"Deleting\", \"Succeeded\", and \"Failed\".""" + trigger: Required["Trigger"] + """Trigger for the schedule. Required.""" + task: Required["ScheduleTask"] + """Task for the schedule. Required.""" + tags: dict[str, str] + """Schedule's tags. Unlike properties, tags are fully mutable.""" + properties: dict[str, str] + """Schedule's properties. Unlike tags, properties are add-only. Once added, a property cannot be + removed.""" + systemData: Required[dict[str, str]] + """System metadata for the resource. Required.""" + + +class ScheduleRun(TypedDict, total=False): + """Schedule run model. + + :ivar run_id: Identifier of the schedule run. Required. + :vartype run_id: str + :ivar schedule_id: Identifier of the schedule. Required. + :vartype schedule_id: str + :ivar success: Trigger success status of the schedule run. Required. + :vartype success: bool + :ivar trigger_time: Trigger time of the schedule run. + :vartype trigger_time: ~datetime.datetime + :ivar error: Error information for the schedule run. + :vartype error: str + :ivar properties: Properties of the schedule run. Required. + :vartype properties: dict[str, str] + """ + + id: Required[str] + """Identifier of the schedule run. Required.""" + scheduleId: Required[str] + """Identifier of the schedule. Required.""" + success: Required[bool] + """Trigger success status of the schedule run. Required.""" + triggerTime: str + """Trigger time of the schedule run.""" + error: str + """Error information for the schedule run.""" + properties: Required[dict[str, str]] + """Properties of the schedule run. Required.""" + + +class SharepointGroundingToolParameters(TypedDict, total=False): + """The sharepoint grounding tool parameters. + + :ivar project_connections: The project connections attached to this tool. There can be a + maximum of 1 connection resource attached to the tool. + :vartype project_connections: list[~azure.ai.agents.types.ToolProjectConnection] + """ + + project_connections: list["ToolProjectConnection"] + """The project connections attached to this tool. There can be a maximum of 1 connection resource + attached to the tool.""" + + +class SharepointPreviewTool(TypedDict, total=False): + """The input definition information for a sharepoint tool as used to configure an agent. + + :ivar type: The object type, which is always 'sharepoint_grounding_preview'. Required. + SHAREPOINT_GROUNDING_PREVIEW. + :vartype type: str or ~azure.ai.projects.models.SHAREPOINT_GROUNDING_PREVIEW + :ivar sharepoint_grounding_preview: The sharepoint grounding tool parameters. Required. + :vartype sharepoint_grounding_preview: ~azure.ai.agents.types.SharepointGroundingToolParameters + """ + + type: Required[Literal[ToolType.SHAREPOINT_GROUNDING_PREVIEW]] + """The object type, which is always 'sharepoint_grounding_preview'. Required. + SHAREPOINT_GROUNDING_PREVIEW.""" + sharepoint_grounding_preview: Required["SharepointGroundingToolParameters"] + """The sharepoint grounding tool parameters. Required.""" + + +class StructuredInputDefinition(TypedDict, total=False): + """An structured input that can participate in prompt template substitutions and tool argument + binding. + + :ivar description: A human-readable description of the input. + :vartype description: str + :ivar default_value: The default value for the input if no run-time value is provided. + :vartype default_value: any + :ivar schema: The JSON schema for the structured input (optional). + :vartype schema: dict[str, any] + :ivar required: Whether the input property is required when the agent is invoked. + :vartype required: bool + """ + + description: str + """A human-readable description of the input.""" + default_value: Any + """The default value for the input if no run-time value is provided.""" + schema: dict[str, Any] + """The JSON schema for the structured input (optional).""" + required: bool + """Whether the input property is required when the agent is invoked.""" + + +class StructuredOutputDefinition(TypedDict, total=False): + """A structured output that can be produced by the agent. + + :ivar name: The name of the structured output. Required. + :vartype name: str + :ivar description: A description of the output to emit. Used by the model to determine when to + emit the output. Required. + :vartype description: str + :ivar schema: The JSON schema for the structured output. Required. + :vartype schema: dict[str, any] + :ivar strict: Whether to enforce strict validation. Default ``true``. Required. + :vartype strict: bool + """ + + name: Required[str] + """The name of the structured output. Required.""" + description: Required[str] + """A description of the output to emit. Used by the model to determine when to emit the output. + Required.""" + schema: Required[dict[str, Any]] + """The JSON schema for the structured output. Required.""" + strict: Required[Optional[bool]] + """Whether to enforce strict validation. Default ``true``. Required.""" + + +class TaxonomyCategory(TypedDict, total=False): + """Taxonomy category definition. + + :ivar id: Unique identifier of the taxonomy category. Required. + :vartype id: str + :ivar name: Name of the taxonomy category. Required. + :vartype name: str + :ivar description: Description of the taxonomy category. + :vartype description: str + :ivar risk_category: Risk category associated with this taxonomy category. Required. Known + values are: "HateUnfairness", "Violence", "Sexual", "SelfHarm", "ProtectedMaterial", + "CodeVulnerability", "UngroundedAttributes", "ProhibitedActions", "SensitiveDataLeakage", and + "TaskAdherence". + :vartype risk_category: str or ~azure.ai.agents.models.RiskCategory + :ivar sub_categories: List of taxonomy sub categories. Required. + :vartype sub_categories: list[~azure.ai.agents.types.TaxonomySubCategory] + :ivar properties: Additional properties for the taxonomy category. + :vartype properties: dict[str, str] + """ + + id: Required[str] + """Unique identifier of the taxonomy category. Required.""" + name: Required[str] + """Name of the taxonomy category. Required.""" + description: str + """Description of the taxonomy category.""" + riskCategory: Required[RiskCategory] + """Risk category associated with this taxonomy category. Required. Known values are: + \"HateUnfairness\", \"Violence\", \"Sexual\", \"SelfHarm\", \"ProtectedMaterial\", + \"CodeVulnerability\", \"UngroundedAttributes\", \"ProhibitedActions\", + \"SensitiveDataLeakage\", and \"TaskAdherence\".""" + subCategories: Required[list["TaxonomySubCategory"]] + """List of taxonomy sub categories. Required.""" + properties: dict[str, str] + """Additional properties for the taxonomy category.""" + + +class TaxonomySubCategory(TypedDict, total=False): + """Taxonomy sub-category definition. + + :ivar id: Unique identifier of the taxonomy sub-category. Required. + :vartype id: str + :ivar name: Name of the taxonomy sub-category. Required. + :vartype name: str + :ivar description: Description of the taxonomy sub-category. + :vartype description: str + :ivar enabled: List of taxonomy items under this sub-category. Required. + :vartype enabled: bool + :ivar properties: Additional properties for the taxonomy sub-category. + :vartype properties: dict[str, str] + """ + + id: Required[str] + """Unique identifier of the taxonomy sub-category. Required.""" + name: Required[str] + """Name of the taxonomy sub-category. Required.""" + description: str + """Description of the taxonomy sub-category.""" + enabled: Required[bool] + """List of taxonomy items under this sub-category. Required.""" + properties: dict[str, str] + """Additional properties for the taxonomy sub-category.""" + + +class ToolDescription(TypedDict, total=False): + """Description of a tool that can be used by an agent. + + :ivar name: The name of the tool. + :vartype name: str + :ivar description: A brief description of the tool's purpose. + :vartype description: str + """ + + name: str + """The name of the tool.""" + description: str + """A brief description of the tool's purpose.""" + + +class ToolProjectConnection(TypedDict, total=False): + """A project connection resource. + + :ivar project_connection_id: A project connection in a ToolProjectConnectionList attached to + this tool. Required. + :vartype project_connection_id: str + """ + + project_connection_id: Required[str] + """A project connection in a ToolProjectConnectionList attached to this tool. Required.""" + + +class UserProfileMemoryItem(TypedDict, total=False): + """A memory item specifically containing user profile information extracted from conversations, + such as preferences, interests, and personal details. + + :ivar memory_id: The unique ID of the memory item. Required. + :vartype memory_id: str + :ivar updated_at: The last update time of the memory item. Required. + :vartype updated_at: ~datetime.datetime + :ivar scope: The namespace that logically groups and isolates memories, such as a user ID. + Required. + :vartype scope: str + :ivar content: The content of the memory. Required. + :vartype content: str + :ivar kind: The kind of the memory item. Required. User profile information extracted from + conversations. + :vartype kind: str or ~azure.ai.agents.models.USER_PROFILE + """ + + memory_id: Required[str] + """The unique ID of the memory item. Required.""" + updated_at: Required[int] + """The last update time of the memory item. Required.""" + scope: Required[str] + """The namespace that logically groups and isolates memories, such as a user ID. Required.""" + content: Required[str] + """The content of the memory. Required.""" + kind: Required[Literal[MemoryItemKind.USER_PROFILE]] + """The kind of the memory item. Required. User profile information extracted from conversations.""" + + +class WebSearchConfiguration(TypedDict, total=False): + """A web search configuration for bing custom search. + + :ivar project_connection_id: Project connection id for grounding with bing custom search. + Required. + :vartype project_connection_id: str + :ivar instance_name: Name of the custom configuration instance given to config. Required. + :vartype instance_name: str + """ + + project_connection_id: Required[str] + """Project connection id for grounding with bing custom search. Required.""" + instance_name: Required[str] + """Name of the custom configuration instance given to config. Required.""" + + +class WeeklyRecurrenceSchedule(TypedDict, total=False): + """Weekly recurrence schedule. + + :ivar type: Weekly recurrence type. Required. Weekly recurrence pattern. + :vartype type: str or ~azure.ai.agents.models.WEEKLY + :ivar days_of_week: Days of the week for the recurrence schedule. Required. + :vartype days_of_week: list[str or ~azure.ai.agents.models.DayOfWeek] + """ + + type: Required[Literal[RecurrenceType.WEEKLY]] + """Weekly recurrence type. Required. Weekly recurrence pattern.""" + daysOfWeek: Required[list[DayOfWeek]] + """Days of the week for the recurrence schedule. Required.""" + + +class WorkflowAgentDefinition(TypedDict, total=False): + """The workflow agent definition. + + :ivar rai_config: Configuration for Responsible AI (RAI) content filtering and safety features. + :vartype rai_config: ~azure.ai.agents.types.RaiConfig + :ivar kind: Required. WORKFLOW. + :vartype kind: str or ~azure.ai.agents.models.WORKFLOW + :ivar workflow: The CSDL YAML definition of the workflow. + :vartype workflow: str + """ + + rai_config: "RaiConfig" + """Configuration for Responsible AI (RAI) content filtering and safety features.""" + kind: Required[Literal[AgentKind.WORKFLOW]] + """Required. WORKFLOW.""" + workflow: str + """The CSDL YAML definition of the workflow.""" + + +InsightRequest = Union[ + AgentClusterInsightRequest, EvaluationComparisonInsightRequest, EvaluationRunClusterInsightRequest +] +InsightResult = Union[AgentClusterInsightResult, EvaluationComparisonInsightResult, EvaluationRunClusterInsightResult] +AgentDefinition = Union[HostedAgentDefinition, PromptAgentDefinition, WorkflowAgentDefinition] +BaseCredentials = Union[ + EntraIDCredentials, + AgenticIdentityPreviewCredentials, + ApiKeyCredentials, + CustomCredential, + NoAuthenticationCredentials, + SASCredentials, +] +EvaluationTaxonomyInput = Union[AgentTaxonomyInput] +Target = Union[AzureAIAgentTarget, AzureAIModelTarget] +Index = Union[AzureAISearchIndex, CosmosDBIndex, ManagedAzureAISearchIndex] +TargetConfig = Union[AzureOpenAIModelConfiguration] +MemoryItem = Union[ChatSummaryMemoryItem, UserProfileMemoryItem] +EvaluatorDefinition = Union[CodeBasedEvaluatorDefinition, PromptBasedEvaluatorDefinition] +EvaluationRuleAction = Union[ContinuousEvaluationRuleAction, HumanEvaluationPreviewRuleAction] +Trigger = Union[CronTrigger, OneTimeTrigger, RecurrenceTrigger] +RecurrenceSchedule = Union[ + DailyRecurrenceSchedule, HourlyRecurrenceSchedule, MonthlyRecurrenceSchedule, WeeklyRecurrenceSchedule +] +DatasetVersion = Union[FileDatasetVersion, FolderDatasetVersion] +Deployment = Union[ModelDeployment] +InsightSample = Union[EvaluationResultSample] +ScheduleTask = Union[EvaluationScheduleTask, InsightScheduleTask] +MemoryStoreDefinition = Union[MemoryStoreDefaultDefinition] +OpenApiAuthDetails = Union[OpenApiAnonymousAuthDetails, OpenApiManagedAuthDetails, OpenApiProjectConnectionAuthDetails] diff --git a/sdk/ai/azure-ai-agents/azure/ai/projects/__init__.py b/sdk/ai/azure-ai-agents/azure/ai/projects/__init__.py new file mode 100644 index 000000000000..d55ccad1f573 --- /dev/null +++ b/sdk/ai/azure-ai-agents/azure/ai/projects/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/sdk/ai/azure-ai-agents/azure/ai/projects/models/__init__.py b/sdk/ai/azure-ai-agents/azure/ai/projects/models/__init__.py new file mode 100644 index 000000000000..e3b4c5295f07 --- /dev/null +++ b/sdk/ai/azure-ai-agents/azure/ai/projects/models/__init__.py @@ -0,0 +1,21 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/sdk/ai/azure-ai-agents/azure/ai/projects/models/_patch.py b/sdk/ai/azure-ai-agents/azure/ai/projects/models/_patch.py new file mode 100644 index 000000000000..87676c65a8f0 --- /dev/null +++ b/sdk/ai/azure-ai-agents/azure/ai/projects/models/_patch.py @@ -0,0 +1,21 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" + + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/ai/azure-ai-agents/azure/ai/projects/types.py b/sdk/ai/azure-ai-agents/azure/ai/projects/types.py new file mode 100644 index 000000000000..27c4083bea09 --- /dev/null +++ b/sdk/ai/azure-ai-agents/azure/ai/projects/types.py @@ -0,0 +1,1317 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Literal, Optional, TYPE_CHECKING, Union +from typing_extensions import Required, TypedDict + +from .models._enums import ( + ContainerNetworkPolicyParamType, + ContainerSkillType, + CustomToolParamFormatType, + FunctionShellToolParamEnvironmentType, + TextResponseFormatConfigurationType, + ToolChoiceParamType, + ToolType, +) + +if TYPE_CHECKING: + from ..agents import _unions, types as _types_agents_models2 + +ComputerEnvironment = Literal["windows", "mac", "linux", "ubuntu", "browser"] +"""Type of ComputerEnvironment.""" + +ContainerMemoryLimit = Literal["1g", "4g", "16g", "64g"] +"""Type of ContainerMemoryLimit.""" + +ContainerNetworkPolicyParamType = Literal["disabled", "allowlist"] +"""Type of ContainerNetworkPolicyParamType.""" + +ContainerSkillType = Literal["skill_reference", "inline"] +"""Type of ContainerSkillType.""" + +CustomToolParamFormatType = Literal["text", "grammar"] +"""Type of CustomToolParamFormatType.""" + +FunctionShellToolParamEnvironmentType = Literal["container_auto", "local", "container_reference"] +"""Type of FunctionShellToolParamEnvironmentType.""" + +GrammarSyntax1 = Literal["lark", "regex"] +"""Type of GrammarSyntax1.""" + +ImageGenAction = Literal["generate", "edit", "auto"] +"""Type of ImageGenAction.""" + +InputFidelity = Literal["high", "low"] +"""Control how much effort the model will exert to match the style and features, especially facial +features, of input images. This parameter is only supported for ``gpt-image-1`` and +``gpt-image-1.5`` and later models, unsupported for ``gpt-image-1-mini``. Supports ``high`` and +``low``. Defaults to ``low``.""" + +RankerVersionType = Literal["auto", "default-2024-11-15"] +"""Type of RankerVersionType.""" + +SearchContextSize = Literal["low", "medium", "high"] +"""Type of SearchContextSize.""" + +TextResponseFormatConfigurationType = Literal["text", "json_schema", "json_object"] +"""Type of TextResponseFormatConfigurationType.""" + +ToolChoiceParamType = Literal[ + "allowed_tools", + "function", + "mcp", + "custom", + "apply_patch", + "shell", + "file_search", + "web_search_preview", + "computer_use_preview", + "web_search_preview_2025_03_11", + "image_generation", + "code_interpreter", +] +"""Type of ToolChoiceParamType.""" + +ToolType = Literal[ + "function", + "file_search", + "computer_use_preview", + "web_search", + "mcp", + "code_interpreter", + "image_generation", + "local_shell", + "shell", + "custom", + "web_search_preview", + "apply_patch", + "a2a_preview", + "bing_custom_search_preview", + "browser_automation_preview", + "fabric_dataagent_preview", + "sharepoint_grounding_preview", + "memory_search_preview", + "azure_ai_search", + "azure_function", + "bing_grounding", + "capture_structured_outputs", + "openapi", +] +"""Type of ToolType.""" + + +class ApiError(TypedDict, total=False): + """ApiError. + + :ivar code: Required. + :vartype code: str + :ivar message: Required. + :vartype message: str + :ivar param: + :vartype param: str + :ivar type: + :vartype type: str + :ivar details: + :vartype details: list[~azure.ai.projects.types.ApiError] + :ivar additional_info: + :vartype additional_info: dict[str, any] + :ivar debug_info: + :vartype debug_info: dict[str, any] + """ + + code: Required[Optional[str]] + """Required.""" + message: Required[str] + """Required.""" + param: Optional[str] + type: str + details: list["ApiError"] + additionalInfo: dict[str, Any] + debugInfo: dict[str, Any] + + +class ApplyPatchToolParam(TypedDict, total=False): + """Apply patch tool. + + :ivar type: The type of the tool. Always ``apply_patch``. Required. APPLY_PATCH. + :vartype type: str or ~azure.ai.projects.models.APPLY_PATCH + """ + + type: Required[Literal[ToolType.APPLY_PATCH]] + """The type of the tool. Always ``apply_patch``. Required. APPLY_PATCH.""" + + +class ApproximateLocation(TypedDict, total=False): + """ApproximateLocation. + + :ivar type: The type of location approximation. Always ``approximate``. Required. Default value + is "approximate". + :vartype type: str + :ivar country: + :vartype country: str + :ivar region: + :vartype region: str + :ivar city: + :vartype city: str + :ivar timezone: + :vartype timezone: str + """ + + type: Required[Literal["approximate"]] + """The type of location approximation. Always ``approximate``. Required. Default value is + \"approximate\".""" + country: Optional[str] + region: Optional[str] + city: Optional[str] + timezone: Optional[str] + + +class AutoCodeInterpreterToolParam(TypedDict, total=False): + """Automatic Code Interpreter Tool Parameters. + + :ivar type: Always ``auto``. Required. Default value is "auto". + :vartype type: str + :ivar file_ids: An optional list of uploaded files to make available to your code. + :vartype file_ids: list[str] + :ivar memory_limit: Known values are: "1g", "4g", "16g", and "64g". + :vartype memory_limit: str or ~azure.ai.projects.models.ContainerMemoryLimit + :ivar network_policy: + :vartype network_policy: ~azure.ai.projects.types.ContainerNetworkPolicyParam + """ + + type: Required[Literal["auto"]] + """Always ``auto``. Required. Default value is \"auto\".""" + file_ids: list[str] + """An optional list of uploaded files to make available to your code.""" + memory_limit: Optional[ContainerMemoryLimit] + """Known values are: \"1g\", \"4g\", \"16g\", and \"64g\".""" + network_policy: "ContainerNetworkPolicyParam" + + +class CodeInterpreterTool(TypedDict, total=False): + """Code interpreter. + + :ivar type: The type of the code interpreter tool. Always ``code_interpreter``. Required. + CODE_INTERPRETER. + :vartype type: str or ~azure.ai.projects.models.CODE_INTERPRETER + :ivar container: The code interpreter container. Can be a container ID or an object that + specifies uploaded file IDs to make available to your code, along with an optional + ``memory_limit`` setting. If not provided, the service assumes auto. Is either a str type or a + AutoCodeInterpreterToolParam type. + :vartype container: str or ~azure.ai.projects.types.AutoCodeInterpreterToolParam + """ + + type: Required[Literal[ToolType.CODE_INTERPRETER]] + """The type of the code interpreter tool. Always ``code_interpreter``. Required. CODE_INTERPRETER.""" + container: Union[str, "AutoCodeInterpreterToolParam"] + """The code interpreter container. Can be a container ID or an object that specifies uploaded file + IDs to make available to your code, along with an optional ``memory_limit`` setting. If not + provided, the service assumes auto. Is either a str type or a AutoCodeInterpreterToolParam + type.""" + + +class ComparisonFilter(TypedDict, total=False): + """Comparison Filter. + + :ivar type: Specifies the comparison operator: ``eq``, ``ne``, ``gt``, ``gte``, ``lt``, + ``lte``, ``in``, ``nin``. + + * `eq`: equals + * `ne`: not equal + * `gt`: greater than + * `gte`: greater than or equal + * `lt`: less than + * `lte`: less than or equal + * `in`: in + * `nin`: not in. Required. Is one of the following types: Literal["eq"], Literal["ne"], + Literal["gt"], Literal["gte"], Literal["lt"], Literal["lte"] + :vartype type: str or str or str or str or str or str + :ivar key: The key to compare against the value. Required. + :vartype key: str + :ivar value: The value to compare against the attribute key; supports string, number, or + boolean types. Required. Is one of the following types: str, float, bool, [Union[str, float]] + :vartype value: str or float or bool or list[str or float] + """ + + type: Required[Literal["eq", "ne", "gt", "gte", "lt", "lte"]] + """Specifies the comparison operator: ``eq``, ``ne``, ``gt``, ``gte``, ``lt``, ``lte``, ``in``, + ``nin``. + + * `eq`: equals + * `ne`: not equal + * `gt`: greater than + * `gte`: greater than or equal + * `lt`: less than + * `lte`: less than or equal + * `in`: in + * `nin`: not in. Required. Is one of the following types: Literal[\"eq\"], + Literal[\"ne\"], Literal[\"gt\"], Literal[\"gte\"], Literal[\"lt\"], Literal[\"lte\"]""" + key: Required[str] + """The key to compare against the value. Required.""" + value: Required[Union[str, float, bool, list[Union[str, float]]]] + """The value to compare against the attribute key; supports string, number, or boolean types. + Required. Is one of the following types: str, float, bool, [Union[str, float]]""" + + +class CompoundFilter(TypedDict, total=False): + """Compound Filter. + + :ivar type: Type of operation: ``and`` or ``or``. Required. Is either a Literal["and"] type or + a Literal["or"] type. + :vartype type: str or str + :ivar filters: Array of filters to combine. Items can be ``ComparisonFilter`` or + ``CompoundFilter``. Required. + :vartype filters: list[~azure.ai.projects.types.ComparisonFilter or any] + """ + + type: Required[Literal["and", "or"]] + """Type of operation: ``and`` or ``or``. Required. Is either a Literal[\"and\"] type or a + Literal[\"or\"] type.""" + filters: Required[list[Union["ComparisonFilter", Any]]] + """Array of filters to combine. Items can be ``ComparisonFilter`` or ``CompoundFilter``. Required.""" + + +class ComputerUsePreviewTool(TypedDict, total=False): + """Computer use preview. + + :ivar type: The type of the computer use tool. Always ``computer_use_preview``. Required. + COMPUTER_USE_PREVIEW. + :vartype type: str or ~azure.ai.projects.models.COMPUTER_USE_PREVIEW + :ivar environment: The type of computer environment to control. Required. Known values are: + "windows", "mac", "linux", "ubuntu", and "browser". + :vartype environment: str or ~azure.ai.projects.models.ComputerEnvironment + :ivar display_width: The width of the computer display. Required. + :vartype display_width: int + :ivar display_height: The height of the computer display. Required. + :vartype display_height: int + """ + + type: Required[Literal[ToolType.COMPUTER_USE_PREVIEW]] + """The type of the computer use tool. Always ``computer_use_preview``. Required. + COMPUTER_USE_PREVIEW.""" + environment: Required[ComputerEnvironment] + """The type of computer environment to control. Required. Known values are: \"windows\", \"mac\", + \"linux\", \"ubuntu\", and \"browser\".""" + display_width: Required[int] + """The width of the computer display. Required.""" + display_height: Required[int] + """The height of the computer display. Required.""" + + +class ContainerAutoParam(TypedDict, total=False): + """ContainerAutoParam. + + :ivar type: Automatically creates a container for this request. Required. CONTAINER_AUTO. + :vartype type: str or ~azure.ai.projects.models.CONTAINER_AUTO + :ivar file_ids: An optional list of uploaded files to make available to your code. + :vartype file_ids: list[str] + :ivar memory_limit: Known values are: "1g", "4g", "16g", and "64g". + :vartype memory_limit: str or ~azure.ai.projects.models.ContainerMemoryLimit + :ivar skills: An optional list of skills referenced by id or inline data. + :vartype skills: list[~azure.ai.projects.types.ContainerSkill] + :ivar network_policy: + :vartype network_policy: ~azure.ai.projects.types.ContainerNetworkPolicyParam + """ + + type: Required[Literal[FunctionShellToolParamEnvironmentType.CONTAINER_AUTO]] + """Automatically creates a container for this request. Required. CONTAINER_AUTO.""" + file_ids: list[str] + """An optional list of uploaded files to make available to your code.""" + memory_limit: Optional[ContainerMemoryLimit] + """Known values are: \"1g\", \"4g\", \"16g\", and \"64g\".""" + skills: list["ContainerSkill"] + """An optional list of skills referenced by id or inline data.""" + network_policy: "ContainerNetworkPolicyParam" + + +class ContainerNetworkPolicyAllowlistParam(TypedDict, total=False): + """ContainerNetworkPolicyAllowlistParam. + + :ivar type: Allow outbound network access only to specified domains. Always ``allowlist``. + Required. ALLOWLIST. + :vartype type: str or ~azure.ai.projects.models.ALLOWLIST + :ivar allowed_domains: A list of allowed domains when type is ``allowlist``. Required. + :vartype allowed_domains: list[str] + :ivar domain_secrets: Optional domain-scoped secrets for allowlisted domains. + :vartype domain_secrets: list[~azure.ai.projects.types.ContainerNetworkPolicyDomainSecretParam] + """ + + type: Required[Literal[ContainerNetworkPolicyParamType.ALLOWLIST]] + """Allow outbound network access only to specified domains. Always ``allowlist``. Required. + ALLOWLIST.""" + allowed_domains: Required[list[str]] + """A list of allowed domains when type is ``allowlist``. Required.""" + domain_secrets: list["ContainerNetworkPolicyDomainSecretParam"] + """Optional domain-scoped secrets for allowlisted domains.""" + + +class ContainerNetworkPolicyDisabledParam(TypedDict, total=False): + """ContainerNetworkPolicyDisabledParam. + + :ivar type: Disable outbound network access. Always ``disabled``. Required. DISABLED. + :vartype type: str or ~azure.ai.projects.models.DISABLED + """ + + type: Required[Literal[ContainerNetworkPolicyParamType.DISABLED]] + """Disable outbound network access. Always ``disabled``. Required. DISABLED.""" + + +class ContainerNetworkPolicyDomainSecretParam(TypedDict, total=False): + """ContainerNetworkPolicyDomainSecretParam. + + :ivar domain: The domain associated with the secret. Required. + :vartype domain: str + :ivar name: The name of the secret to inject for the domain. Required. + :vartype name: str + :ivar value: The secret value to inject for the domain. Required. + :vartype value: str + """ + + domain: Required[str] + """The domain associated with the secret. Required.""" + name: Required[str] + """The name of the secret to inject for the domain. Required.""" + value: Required[str] + """The secret value to inject for the domain. Required.""" + + +class CustomGrammarFormatParam(TypedDict, total=False): + """Grammar format. + + :ivar type: Grammar format. Always ``grammar``. Required. GRAMMAR. + :vartype type: str or ~azure.ai.projects.models.GRAMMAR + :ivar syntax: The syntax of the grammar definition. One of ``lark`` or ``regex``. Required. + Known values are: "lark" and "regex". + :vartype syntax: str or ~azure.ai.projects.models.GrammarSyntax1 + :ivar definition: The grammar definition. Required. + :vartype definition: str + """ + + type: Required[Literal[CustomToolParamFormatType.GRAMMAR]] + """Grammar format. Always ``grammar``. Required. GRAMMAR.""" + syntax: Required[GrammarSyntax1] + """The syntax of the grammar definition. One of ``lark`` or ``regex``. Required. Known values are: + \"lark\" and \"regex\".""" + definition: Required[str] + """The grammar definition. Required.""" + + +class CustomTextFormatParam(TypedDict, total=False): + """Text format. + + :ivar type: Unconstrained text format. Always ``text``. Required. TEXT. + :vartype type: str or ~azure.ai.projects.models.TEXT + """ + + type: Required[Literal[CustomToolParamFormatType.TEXT]] + """Unconstrained text format. Always ``text``. Required. TEXT.""" + + +class CustomToolParam(TypedDict, total=False): + """Custom tool. + + :ivar type: The type of the custom tool. Always ``custom``. Required. CUSTOM. + :vartype type: str or ~azure.ai.projects.models.CUSTOM + :ivar name: The name of the custom tool, used to identify it in tool calls. Required. + :vartype name: str + :ivar description: Optional description of the custom tool, used to provide more context. + :vartype description: str + :ivar format: The input format for the custom tool. Default is unconstrained text. + :vartype format: ~azure.ai.projects.types.CustomToolParamFormat + """ + + type: Required[Literal[ToolType.CUSTOM]] + """The type of the custom tool. Always ``custom``. Required. CUSTOM.""" + name: Required[str] + """The name of the custom tool, used to identify it in tool calls. Required.""" + description: str + """Optional description of the custom tool, used to provide more context.""" + format: "CustomToolParamFormat" + """The input format for the custom tool. Default is unconstrained text.""" + + +class FileSearchTool(TypedDict, total=False): + """File search. + + :ivar type: The type of the file search tool. Always ``file_search``. Required. FILE_SEARCH. + :vartype type: str or ~azure.ai.projects.models.FILE_SEARCH + :ivar vector_store_ids: The IDs of the vector stores to search. Required. + :vartype vector_store_ids: list[str] + :ivar max_num_results: The maximum number of results to return. This number should be between 1 + and 50 inclusive. + :vartype max_num_results: int + :ivar ranking_options: Ranking options for search. + :vartype ranking_options: ~azure.ai.projects.types.RankingOptions + :ivar filters: Is either a ComparisonFilter type or a CompoundFilter type. + :vartype filters: ~azure.ai.projects.types.ComparisonFilter or + ~azure.ai.projects.types.CompoundFilter + """ + + type: Required[Literal[ToolType.FILE_SEARCH]] + """The type of the file search tool. Always ``file_search``. Required. FILE_SEARCH.""" + vector_store_ids: Required[list[str]] + """The IDs of the vector stores to search. Required.""" + max_num_results: int + """The maximum number of results to return. This number should be between 1 and 50 inclusive.""" + ranking_options: "RankingOptions" + """Ranking options for search.""" + filters: Optional["_unions.Filters"] + """Is either a ComparisonFilter type or a CompoundFilter type.""" + + +class FunctionShellToolParam(TypedDict, total=False): + """Shell tool. + + :ivar type: The type of the shell tool. Always ``shell``. Required. SHELL. + :vartype type: str or ~azure.ai.projects.models.SHELL + :ivar environment: + :vartype environment: ~azure.ai.projects.types.FunctionShellToolParamEnvironment + """ + + type: Required[Literal[ToolType.SHELL]] + """The type of the shell tool. Always ``shell``. Required. SHELL.""" + environment: Optional["FunctionShellToolParamEnvironment"] + + +class FunctionShellToolParamEnvironmentContainerReferenceParam(TypedDict, total=False): # pylint: disable=name-too-long + """FunctionShellToolParamEnvironmentContainerReferenceParam. + + :ivar type: References a container created with the /v1/containers endpoint. Required. + CONTAINER_REFERENCE. + :vartype type: str or ~azure.ai.projects.models.CONTAINER_REFERENCE + :ivar container_id: The ID of the referenced container. Required. + :vartype container_id: str + """ + + type: Required[Literal[FunctionShellToolParamEnvironmentType.CONTAINER_REFERENCE]] + """References a container created with the /v1/containers endpoint. Required. CONTAINER_REFERENCE.""" + container_id: Required[str] + """The ID of the referenced container. Required.""" + + +class FunctionShellToolParamEnvironmentLocalEnvironmentParam(TypedDict, total=False): # pylint: disable=name-too-long + """FunctionShellToolParamEnvironmentLocalEnvironmentParam. + + :ivar type: Use a local computer environment. Required. LOCAL. + :vartype type: str or ~azure.ai.projects.models.LOCAL + :ivar skills: An optional list of skills. + :vartype skills: list[~azure.ai.projects.types.LocalSkillParam] + """ + + type: Required[Literal[FunctionShellToolParamEnvironmentType.LOCAL]] + """Use a local computer environment. Required. LOCAL.""" + skills: list["LocalSkillParam"] + """An optional list of skills.""" + + +class FunctionTool(TypedDict, total=False): + """Function. + + :ivar type: The type of the function tool. Always ``function``. Required. FUNCTION. + :vartype type: str or ~azure.ai.projects.models.FUNCTION + :ivar name: The name of the function to call. Required. + :vartype name: str + :ivar description: + :vartype description: str + :ivar parameters: Required. + :vartype parameters: dict[str, any] + :ivar strict: Required. + :vartype strict: bool + """ + + type: Required[Literal[ToolType.FUNCTION]] + """The type of the function tool. Always ``function``. Required. FUNCTION.""" + name: Required[str] + """The name of the function to call. Required.""" + description: Optional[str] + parameters: Required[Optional[dict[str, Any]]] + """Required.""" + strict: Required[Optional[bool]] + """Required.""" + + +class HybridSearchOptions(TypedDict, total=False): + """HybridSearchOptions. + + :ivar embedding_weight: The weight of the embedding in the reciprocal ranking fusion. Required. + :vartype embedding_weight: float + :ivar text_weight: The weight of the text in the reciprocal ranking fusion. Required. + :vartype text_weight: float + """ + + embedding_weight: Required[float] + """The weight of the embedding in the reciprocal ranking fusion. Required.""" + text_weight: Required[float] + """The weight of the text in the reciprocal ranking fusion. Required.""" + + +class ImageGenTool(TypedDict, total=False): + """Image generation tool. + + :ivar type: The type of the image generation tool. Always ``image_generation``. Required. + IMAGE_GENERATION. + :vartype type: str or ~azure.ai.projects.models.IMAGE_GENERATION + :ivar model: Is one of the following types: Literal["gpt-image-1"], + Literal["gpt-image-1-mini"], Literal["gpt-image-1.5"], str + :vartype model: str or str or str or str + :ivar quality: The quality of the generated image. One of ``low``, ``medium``, ``high``, or + ``auto``. Default: ``auto``. Is one of the following types: Literal["low"], Literal["medium"], + Literal["high"], Literal["auto"] + :vartype quality: str or str or str or str + :ivar size: The size of the generated image. One of ``1024x1024``, ``1024x1536``, + ``1536x1024``, or ``auto``. Default: ``auto``. Is one of the following types: + Literal["1024x1024"], Literal["1024x1536"], Literal["1536x1024"], Literal["auto"] + :vartype size: str or str or str or str + :ivar output_format: The output format of the generated image. One of ``png``, ``webp``, or + ``jpeg``. Default: ``png``. Is one of the following types: Literal["png"], Literal["webp"], + Literal["jpeg"] + :vartype output_format: str or str or str + :ivar output_compression: Compression level for the output image. Default: 100. + :vartype output_compression: int + :ivar moderation: Moderation level for the generated image. Default: ``auto``. Is either a + Literal["auto"] type or a Literal["low"] type. + :vartype moderation: str or str + :ivar background: Background type for the generated image. One of ``transparent``, ``opaque``, + or ``auto``. Default: ``auto``. Is one of the following types: Literal["transparent"], + Literal["opaque"], Literal["auto"] + :vartype background: str or str or str + :ivar input_fidelity: Known values are: "high" and "low". + :vartype input_fidelity: str or ~azure.ai.projects.models.InputFidelity + :ivar input_image_mask: Optional mask for inpainting. Contains ``image_url`` (string, optional) + and ``file_id`` (string, optional). + :vartype input_image_mask: ~azure.ai.projects.types.ImageGenToolInputImageMask + :ivar partial_images: Number of partial images to generate in streaming mode, from 0 (default + value) to 3. + :vartype partial_images: int + :ivar action: Whether to generate a new image or edit an existing image. Default: ``auto``. + Known values are: "generate", "edit", and "auto". + :vartype action: str or ~azure.ai.projects.models.ImageGenAction + """ + + type: Required[Literal[ToolType.IMAGE_GENERATION]] + """The type of the image generation tool. Always ``image_generation``. Required. IMAGE_GENERATION.""" + model: Union[Literal["gpt-image-1"], Literal["gpt-image-1-mini"], Literal["gpt-image-1.5"], str] + """Is one of the following types: Literal[\"gpt-image-1\"], Literal[\"gpt-image-1-mini\"], + Literal[\"gpt-image-1.5\"], str""" + quality: Literal["low", "medium", "high", "auto"] + """The quality of the generated image. One of ``low``, ``medium``, ``high``, or ``auto``. Default: + ``auto``. Is one of the following types: Literal[\"low\"], Literal[\"medium\"], + Literal[\"high\"], Literal[\"auto\"]""" + size: Literal["1024x1024", "1024x1536", "1536x1024", "auto"] + """The size of the generated image. One of ``1024x1024``, ``1024x1536``, ``1536x1024``, or + ``auto``. Default: ``auto``. Is one of the following types: Literal[\"1024x1024\"], + Literal[\"1024x1536\"], Literal[\"1536x1024\"], Literal[\"auto\"]""" + output_format: Literal["png", "webp", "jpeg"] + """The output format of the generated image. One of ``png``, ``webp``, or ``jpeg``. Default: + ``png``. Is one of the following types: Literal[\"png\"], Literal[\"webp\"], Literal[\"jpeg\"]""" + output_compression: int + """Compression level for the output image. Default: 100.""" + moderation: Literal["auto", "low"] + """Moderation level for the generated image. Default: ``auto``. Is either a Literal[\"auto\"] type + or a Literal[\"low\"] type.""" + background: Literal["transparent", "opaque", "auto"] + """Background type for the generated image. One of ``transparent``, ``opaque``, or ``auto``. + Default: ``auto``. Is one of the following types: Literal[\"transparent\"], + Literal[\"opaque\"], Literal[\"auto\"]""" + input_fidelity: Optional[InputFidelity] + """Known values are: \"high\" and \"low\".""" + input_image_mask: "ImageGenToolInputImageMask" + """Optional mask for inpainting. Contains ``image_url`` (string, optional) and ``file_id`` + (string, optional).""" + partial_images: int + """Number of partial images to generate in streaming mode, from 0 (default value) to 3.""" + action: ImageGenAction + """Whether to generate a new image or edit an existing image. Default: ``auto``. Known values are: + \"generate\", \"edit\", and \"auto\".""" + + +class ImageGenToolInputImageMask(TypedDict, total=False): + """ImageGenToolInputImageMask. + + :ivar image_url: + :vartype image_url: str + :ivar file_id: + :vartype file_id: str + """ + + image_url: str + file_id: str + + +class InlineSkillParam(TypedDict, total=False): + """InlineSkillParam. + + :ivar type: Defines an inline skill for this request. Required. INLINE. + :vartype type: str or ~azure.ai.projects.models.INLINE + :ivar name: The name of the skill. Required. + :vartype name: str + :ivar description: The description of the skill. Required. + :vartype description: str + :ivar source: Inline skill payload. Required. + :vartype source: ~azure.ai.projects.types.InlineSkillSourceParam + """ + + type: Required[Literal[ContainerSkillType.INLINE]] + """Defines an inline skill for this request. Required. INLINE.""" + name: Required[str] + """The name of the skill. Required.""" + description: Required[str] + """The description of the skill. Required.""" + source: Required["InlineSkillSourceParam"] + """Inline skill payload. Required.""" + + +class InlineSkillSourceParam(TypedDict, total=False): + """Inline skill payload. + + :ivar type: The type of the inline skill source. Must be ``base64``. Required. Default value is + "base64". + :vartype type: str + :ivar media_type: The media type of the inline skill payload. Must be ``application/zip``. + Required. Default value is "application/zip". + :vartype media_type: str + :ivar data: Base64-encoded skill zip bundle. Required. + :vartype data: str + """ + + type: Required[Literal["base64"]] + """The type of the inline skill source. Must be ``base64``. Required. Default value is \"base64\".""" + media_type: Required[Literal["application/zip"]] + """The media type of the inline skill payload. Must be ``application/zip``. Required. Default + value is \"application/zip\".""" + data: Required[str] + """Base64-encoded skill zip bundle. Required.""" + + +class LocalShellToolParam(TypedDict, total=False): + """Local shell tool. + + :ivar type: The type of the local shell tool. Always ``local_shell``. Required. LOCAL_SHELL. + :vartype type: str or ~azure.ai.projects.models.LOCAL_SHELL + """ + + type: Required[Literal[ToolType.LOCAL_SHELL]] + """The type of the local shell tool. Always ``local_shell``. Required. LOCAL_SHELL.""" + + +class LocalSkillParam(TypedDict, total=False): + """LocalSkillParam. + + :ivar name: The name of the skill. Required. + :vartype name: str + :ivar description: The description of the skill. Required. + :vartype description: str + :ivar path: The path to the directory containing the skill. Required. + :vartype path: str + """ + + name: Required[str] + """The name of the skill. Required.""" + description: Required[str] + """The description of the skill. Required.""" + path: Required[str] + """The path to the directory containing the skill. Required.""" + + +class MCPTool(TypedDict, total=False): + """MCP tool. + + :ivar type: The type of the MCP tool. Always ``mcp``. Required. MCP. + :vartype type: str or ~azure.ai.projects.models.MCP + :ivar server_label: A label for this MCP server, used to identify it in tool calls. Required. + :vartype server_label: str + :ivar server_url: The URL for the MCP server. One of ``server_url`` or ``connector_id`` must be + provided. + :vartype server_url: str + :ivar connector_id: Identifier for service connectors, like those available in ChatGPT. One of + ``server_url`` or ``connector_id`` must be provided. Learn more about service connectors `here + `_. Currently supported ``connector_id`` values are: + + * Dropbox: `connector_dropbox` + * Gmail: `connector_gmail` + * Google Calendar: `connector_googlecalendar` + * Google Drive: `connector_googledrive` + * Microsoft Teams: `connector_microsoftteams` + * Outlook Calendar: `connector_outlookcalendar` + * Outlook Email: `connector_outlookemail` + * SharePoint: `connector_sharepoint`. Is one of the following types: + Literal["connector_dropbox"], Literal["connector_gmail"], Literal["connector_googlecalendar"], + Literal["connector_googledrive"], Literal["connector_microsoftteams"], + Literal["connector_outlookcalendar"], Literal["connector_outlookemail"], + Literal["connector_sharepoint"] + :vartype connector_id: str or str or str or str or str or str or str or str + :ivar authorization: An OAuth access token that can be used with a remote MCP server, either + with a custom MCP server URL or a service connector. Your application must handle the OAuth + authorization flow and provide the token here. + :vartype authorization: str + :ivar server_description: Optional description of the MCP server, used to provide more context. + :vartype server_description: str + :ivar headers: + :vartype headers: dict[str, str] + :ivar allowed_tools: Is either a [str] type or a MCPToolFilter type. + :vartype allowed_tools: list[str] or ~azure.ai.projects.types.MCPToolFilter + :ivar require_approval: Is one of the following types: MCPToolRequireApproval, + Literal["always"], Literal["never"] + :vartype require_approval: ~azure.ai.projects.types.MCPToolRequireApproval or str or str + :ivar project_connection_id: The connection ID in the project for the MCP server. The + connection stores authentication and other connection details needed to connect to the MCP + server. + :vartype project_connection_id: str + """ + + type: Required[Literal[ToolType.MCP]] + """The type of the MCP tool. Always ``mcp``. Required. MCP.""" + server_label: Required[str] + """A label for this MCP server, used to identify it in tool calls. Required.""" + server_url: str + """The URL for the MCP server. One of ``server_url`` or ``connector_id`` must be provided.""" + connector_id: Literal[ + "connector_dropbox", + "connector_gmail", + "connector_googlecalendar", + "connector_googledrive", + "connector_microsoftteams", + "connector_outlookcalendar", + "connector_outlookemail", + "connector_sharepoint", + ] + """Identifier for service connectors, like those available in ChatGPT. One of ``server_url`` or + ``connector_id`` must be provided. Learn more about service connectors `here + `_. Currently supported ``connector_id`` values are: + + * Dropbox: `connector_dropbox` + * Gmail: `connector_gmail` + * Google Calendar: `connector_googlecalendar` + * Google Drive: `connector_googledrive` + * Microsoft Teams: `connector_microsoftteams` + * Outlook Calendar: `connector_outlookcalendar` + * Outlook Email: `connector_outlookemail` + * SharePoint: `connector_sharepoint`. Is one of the following types: + Literal[\"connector_dropbox\"], Literal[\"connector_gmail\"], + Literal[\"connector_googlecalendar\"], Literal[\"connector_googledrive\"], + Literal[\"connector_microsoftteams\"], Literal[\"connector_outlookcalendar\"], + Literal[\"connector_outlookemail\"], Literal[\"connector_sharepoint\"]""" + authorization: str + """An OAuth access token that can be used with a remote MCP server, either with a custom MCP + server URL or a service connector. Your application must handle the OAuth authorization flow + and provide the token here.""" + server_description: str + """Optional description of the MCP server, used to provide more context.""" + headers: Optional[dict[str, str]] + allowed_tools: Optional[Union[list[str], "MCPToolFilter"]] + """Is either a [str] type or a MCPToolFilter type.""" + require_approval: Optional[Union["MCPToolRequireApproval", Literal["always"], Literal["never"]]] + """Is one of the following types: MCPToolRequireApproval, Literal[\"always\"], Literal[\"never\"]""" + project_connection_id: str + """The connection ID in the project for the MCP server. The connection stores authentication and + other connection details needed to connect to the MCP server.""" + + +class MCPToolFilter(TypedDict, total=False): + """MCP tool filter. + + :ivar tool_names: MCP allowed tools. + :vartype tool_names: list[str] + :ivar read_only: Indicates whether or not a tool modifies data or is read-only. If an MCP + server is `annotated with `readOnlyHint` + `_, + it will match this filter. + :vartype read_only: bool + """ + + tool_names: list[str] + """MCP allowed tools.""" + read_only: bool + """Indicates whether or not a tool modifies data or is read-only. If an MCP server is `annotated + with `readOnlyHint` + `_, + it will match this filter.""" + + +class MCPToolRequireApproval(TypedDict, total=False): + """MCPToolRequireApproval. + + :ivar always: + :vartype always: ~azure.ai.projects.types.MCPToolFilter + :ivar never: + :vartype never: ~azure.ai.projects.types.MCPToolFilter + """ + + always: "MCPToolFilter" + never: "MCPToolFilter" + + +class RankingOptions(TypedDict, total=False): + """RankingOptions. + + :ivar ranker: The ranker to use for the file search. Known values are: "auto" and + "default-2024-11-15". + :vartype ranker: str or ~azure.ai.projects.models.RankerVersionType + :ivar score_threshold: The score threshold for the file search, a number between 0 and 1. + Numbers closer to 1 will attempt to return only the most relevant results, but may return fewer + results. + :vartype score_threshold: float + :ivar hybrid_search: Weights that control how reciprocal rank fusion balances semantic + embedding matches versus sparse keyword matches when hybrid search is enabled. + :vartype hybrid_search: ~azure.ai.projects.types.HybridSearchOptions + """ + + ranker: RankerVersionType + """The ranker to use for the file search. Known values are: \"auto\" and \"default-2024-11-15\".""" + score_threshold: float + """The score threshold for the file search, a number between 0 and 1. Numbers closer to 1 will + attempt to return only the most relevant results, but may return fewer results.""" + hybrid_search: "HybridSearchOptions" + """Weights that control how reciprocal rank fusion balances semantic embedding matches versus + sparse keyword matches when hybrid search is enabled.""" + + +class Reasoning(TypedDict, total=False): + """Reasoning. + + :ivar effort: Is one of the following types: Literal["none"], Literal["minimal"], + Literal["low"], Literal["medium"], Literal["high"], Literal["xhigh"] + :vartype effort: str or str or str or str or str or str + :ivar summary: Is one of the following types: Literal["auto"], Literal["concise"], + Literal["detailed"] + :vartype summary: str or str or str + :ivar generate_summary: Is one of the following types: Literal["auto"], Literal["concise"], + Literal["detailed"] + :vartype generate_summary: str or str or str + """ + + effort: Optional[Literal["none", "minimal", "low", "medium", "high", "xhigh"]] + """Is one of the following types: Literal[\"none\"], Literal[\"minimal\"], Literal[\"low\"], + Literal[\"medium\"], Literal[\"high\"], Literal[\"xhigh\"]""" + summary: Optional[Literal["auto", "concise", "detailed"]] + """Is one of the following types: Literal[\"auto\"], Literal[\"concise\"], Literal[\"detailed\"]""" + generate_summary: Optional[Literal["auto", "concise", "detailed"]] + """Is one of the following types: Literal[\"auto\"], Literal[\"concise\"], Literal[\"detailed\"]""" + + +class ResponseUsageInputTokensDetails(TypedDict, total=False): + """ResponseUsageInputTokensDetails. + + :ivar cached_tokens: Required. + :vartype cached_tokens: int + """ + + cached_tokens: Required[int] + """Required.""" + + +class ResponseUsageOutputTokensDetails(TypedDict, total=False): + """ResponseUsageOutputTokensDetails. + + :ivar reasoning_tokens: Required. + :vartype reasoning_tokens: int + """ + + reasoning_tokens: Required[int] + """Required.""" + + +class SkillReferenceParam(TypedDict, total=False): + """SkillReferenceParam. + + :ivar type: References a skill created with the /v1/skills endpoint. Required. SKILL_REFERENCE. + :vartype type: str or ~azure.ai.projects.models.SKILL_REFERENCE + :ivar skill_id: The ID of the referenced skill. Required. + :vartype skill_id: str + :ivar version: Optional skill version. Use a positive integer or 'latest'. Omit for default. + :vartype version: str + """ + + type: Required[Literal[ContainerSkillType.SKILL_REFERENCE]] + """References a skill created with the /v1/skills endpoint. Required. SKILL_REFERENCE.""" + skill_id: Required[str] + """The ID of the referenced skill. Required.""" + version: str + """Optional skill version. Use a positive integer or 'latest'. Omit for default.""" + + +class SpecificApplyPatchParam(TypedDict, total=False): + """Specific apply patch tool choice. + + :ivar type: The tool to call. Always ``apply_patch``. Required. APPLY_PATCH. + :vartype type: str or ~azure.ai.projects.models.APPLY_PATCH + """ + + type: Required[Literal[ToolChoiceParamType.APPLY_PATCH]] + """The tool to call. Always ``apply_patch``. Required. APPLY_PATCH.""" + + +class SpecificFunctionShellParam(TypedDict, total=False): + """Specific shell tool choice. + + :ivar type: The tool to call. Always ``shell``. Required. SHELL. + :vartype type: str or ~azure.ai.projects.models.SHELL + """ + + type: Required[Literal[ToolChoiceParamType.SHELL]] + """The tool to call. Always ``shell``. Required. SHELL.""" + + +class TextResponseFormatJsonObject(TypedDict, total=False): + """JSON object. + + :ivar type: The type of response format being defined. Always ``json_object``. Required. + JSON_OBJECT. + :vartype type: str or ~azure.ai.projects.models.JSON_OBJECT + """ + + type: Required[Literal[TextResponseFormatConfigurationType.JSON_OBJECT]] + """The type of response format being defined. Always ``json_object``. Required. JSON_OBJECT.""" + + +class TextResponseFormatJsonSchema(TypedDict, total=False): + """JSON schema. + + :ivar type: The type of response format being defined. Always ``json_schema``. Required. + JSON_SCHEMA. + :vartype type: str or ~azure.ai.projects.models.JSON_SCHEMA + :ivar description: A description of what the response format is for, used by the model to + determine how to respond in the format. + :vartype description: str + :ivar name: The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and + dashes, with a maximum length of 64. Required. + :vartype name: str + :ivar schema: Required. + :vartype schema: dict[str, any] + :ivar strict: + :vartype strict: bool + """ + + type: Required[Literal[TextResponseFormatConfigurationType.JSON_SCHEMA]] + """The type of response format being defined. Always ``json_schema``. Required. JSON_SCHEMA.""" + description: str + """A description of what the response format is for, used by the model to determine how to respond + in the format.""" + name: Required[str] + """The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with + a maximum length of 64. Required.""" + schema: Required[dict[str, Any]] + """Required.""" + strict: Optional[bool] + + +class TextResponseFormatText(TypedDict, total=False): + """Text. + + :ivar type: The type of response format being defined. Always ``text``. Required. TEXT. + :vartype type: str or ~azure.ai.projects.models.TEXT + """ + + type: Required[Literal[TextResponseFormatConfigurationType.TEXT]] + """The type of response format being defined. Always ``text``. Required. TEXT.""" + + +class ToolChoiceAllowed(TypedDict, total=False): + """Allowed tools. + + :ivar type: Allowed tool configuration type. Always ``allowed_tools``. Required. ALLOWED_TOOLS. + :vartype type: str or ~azure.ai.projects.models.ALLOWED_TOOLS + :ivar mode: Constrains the tools available to the model to a pre-defined set. ``auto`` allows + the model to pick from among the allowed tools and generate a message. ``required`` requires + the model to call one or more of the allowed tools. Required. Is either a Literal["auto"] type + or a Literal["required"] type. + :vartype mode: str or str + :ivar tools: A list of tool definitions that the model should be allowed to call. For the + Responses API, the list of tool definitions might look like: + + .. code-block:: json + + [ + { "type": "function", "name": "get_weather" }, + { "type": "mcp", "server_label": "deepwiki" }, + { "type": "image_generation" } + ]. Required. + :vartype tools: list[dict[str, any]] + """ + + type: Required[Literal[ToolChoiceParamType.ALLOWED_TOOLS]] + """Allowed tool configuration type. Always ``allowed_tools``. Required. ALLOWED_TOOLS.""" + mode: Required[Literal["auto", "required"]] + """Constrains the tools available to the model to a pre-defined set. ``auto`` allows the model to + pick from among the allowed tools and generate a message. ``required`` requires the model to + call one or more of the allowed tools. Required. Is either a Literal[\"auto\"] type or a + Literal[\"required\"] type.""" + tools: Required[list[dict[str, Any]]] + """A list of tool definitions that the model should be allowed to call. For the Responses API, the + list of tool definitions might look like: + + .. code-block:: json + + [ + { \"type\": \"function\", \"name\": \"get_weather\" }, + { \"type\": \"mcp\", \"server_label\": \"deepwiki\" }, + { \"type\": \"image_generation\" } + ]. Required.""" + + +class ToolChoiceCodeInterpreter(TypedDict, total=False): + """Indicates that the model should use a built-in tool to generate a response. `Learn more about + built-in tools `_. + + :ivar type: Required. CODE_INTERPRETER. + :vartype type: str or ~azure.ai.projects.models.CODE_INTERPRETER + """ + + type: Required[Literal[ToolChoiceParamType.CODE_INTERPRETER]] + """Required. CODE_INTERPRETER.""" + + +class ToolChoiceComputerUsePreview(TypedDict, total=False): + """Indicates that the model should use a built-in tool to generate a response. `Learn more about + built-in tools `_. + + :ivar type: Required. COMPUTER_USE_PREVIEW. + :vartype type: str or ~azure.ai.projects.models.COMPUTER_USE_PREVIEW + """ + + type: Required[Literal[ToolChoiceParamType.COMPUTER_USE_PREVIEW]] + """Required. COMPUTER_USE_PREVIEW.""" + + +class ToolChoiceCustom(TypedDict, total=False): + """Custom tool. + + :ivar type: For custom tool calling, the type is always ``custom``. Required. CUSTOM. + :vartype type: str or ~azure.ai.projects.models.CUSTOM + :ivar name: The name of the custom tool to call. Required. + :vartype name: str + """ + + type: Required[Literal[ToolChoiceParamType.CUSTOM]] + """For custom tool calling, the type is always ``custom``. Required. CUSTOM.""" + name: Required[str] + """The name of the custom tool to call. Required.""" + + +class ToolChoiceFileSearch(TypedDict, total=False): + """Indicates that the model should use a built-in tool to generate a response. `Learn more about + built-in tools `_. + + :ivar type: Required. FILE_SEARCH. + :vartype type: str or ~azure.ai.projects.models.FILE_SEARCH + """ + + type: Required[Literal[ToolChoiceParamType.FILE_SEARCH]] + """Required. FILE_SEARCH.""" + + +class ToolChoiceFunction(TypedDict, total=False): + """Function tool. + + :ivar type: For function calling, the type is always ``function``. Required. FUNCTION. + :vartype type: str or ~azure.ai.projects.models.FUNCTION + :ivar name: The name of the function to call. Required. + :vartype name: str + """ + + type: Required[Literal[ToolChoiceParamType.FUNCTION]] + """For function calling, the type is always ``function``. Required. FUNCTION.""" + name: Required[str] + """The name of the function to call. Required.""" + + +class ToolChoiceImageGeneration(TypedDict, total=False): + """Indicates that the model should use a built-in tool to generate a response. `Learn more about + built-in tools `_. + + :ivar type: Required. IMAGE_GENERATION. + :vartype type: str or ~azure.ai.projects.models.IMAGE_GENERATION + """ + + type: Required[Literal[ToolChoiceParamType.IMAGE_GENERATION]] + """Required. IMAGE_GENERATION.""" + + +class ToolChoiceMCP(TypedDict, total=False): + """MCP tool. + + :ivar type: For MCP tools, the type is always ``mcp``. Required. MCP. + :vartype type: str or ~azure.ai.projects.models.MCP + :ivar server_label: The label of the MCP server to use. Required. + :vartype server_label: str + :ivar name: + :vartype name: str + """ + + type: Required[Literal[ToolChoiceParamType.MCP]] + """For MCP tools, the type is always ``mcp``. Required. MCP.""" + server_label: Required[str] + """The label of the MCP server to use. Required.""" + name: Optional[str] + + +class ToolChoiceWebSearchPreview(TypedDict, total=False): + """Indicates that the model should use a built-in tool to generate a response. `Learn more about + built-in tools `_. + + :ivar type: Required. WEB_SEARCH_PREVIEW. + :vartype type: str or ~azure.ai.projects.models.WEB_SEARCH_PREVIEW + """ + + type: Required[Literal[ToolChoiceParamType.WEB_SEARCH_PREVIEW]] + """Required. WEB_SEARCH_PREVIEW.""" + + +class ToolChoiceWebSearchPreview20250311(TypedDict, total=False): + """Indicates that the model should use a built-in tool to generate a response. `Learn more about + built-in tools `_. + + :ivar type: Required. WEB_SEARCH_PREVIEW2025_03_11. + :vartype type: str or ~azure.ai.projects.models.WEB_SEARCH_PREVIEW2025_03_11 + """ + + type: Required[Literal[ToolChoiceParamType.WEB_SEARCH_PREVIEW2025_03_11]] + """Required. WEB_SEARCH_PREVIEW2025_03_11.""" + + +class WebSearchApproximateLocation(TypedDict, total=False): + """Web search approximate location. + + :ivar type: The type of location approximation. Always ``approximate``. Required. Default value + is "approximate". + :vartype type: str + :ivar country: + :vartype country: str + :ivar region: + :vartype region: str + :ivar city: + :vartype city: str + :ivar timezone: + :vartype timezone: str + """ + + type: Required[Literal["approximate"]] + """The type of location approximation. Always ``approximate``. Required. Default value is + \"approximate\".""" + country: Optional[str] + region: Optional[str] + city: Optional[str] + timezone: Optional[str] + + +class WebSearchPreviewTool(TypedDict, total=False): + """Web search preview. + + :ivar type: The type of the web search tool. One of ``web_search_preview`` or + ``web_search_preview_2025_03_11``. Required. WEB_SEARCH_PREVIEW. + :vartype type: str or ~azure.ai.projects.models.WEB_SEARCH_PREVIEW + :ivar user_location: + :vartype user_location: ~azure.ai.projects.types.ApproximateLocation + :ivar search_context_size: High level guidance for the amount of context window space to use + for the search. One of ``low``, ``medium``, or ``high``. ``medium`` is the default. Known + values are: "low", "medium", and "high". + :vartype search_context_size: str or ~azure.ai.projects.models.SearchContextSize + """ + + type: Required[Literal[ToolType.WEB_SEARCH_PREVIEW]] + """The type of the web search tool. One of ``web_search_preview`` or + ``web_search_preview_2025_03_11``. Required. WEB_SEARCH_PREVIEW.""" + user_location: Optional["ApproximateLocation"] + search_context_size: SearchContextSize + """High level guidance for the amount of context window space to use for the search. One of + ``low``, ``medium``, or ``high``. ``medium`` is the default. Known values are: \"low\", + \"medium\", and \"high\".""" + + +class WebSearchTool(TypedDict, total=False): + """Web search. + + :ivar type: The type of the web search tool. One of ``web_search`` or + ``web_search_2025_08_26``. Required. WEB_SEARCH. + :vartype type: str or ~azure.ai.projects.models.WEB_SEARCH + :ivar filters: + :vartype filters: ~azure.ai.projects.types.WebSearchToolFilters + :ivar user_location: + :vartype user_location: ~azure.ai.projects.types.WebSearchApproximateLocation + :ivar search_context_size: High level guidance for the amount of context window space to use + for the search. One of ``low``, ``medium``, or ``high``. ``medium`` is the default. Is one of + the following types: Literal["low"], Literal["medium"], Literal["high"] + :vartype search_context_size: str or str or str + :ivar custom_search_configuration: The project connections attached to this tool. There can be + a maximum of 1 connection resource attached to the tool. + :vartype custom_search_configuration: ~azure.ai.agents.types.WebSearchConfiguration + """ + + type: Required[Literal[ToolType.WEB_SEARCH]] + """The type of the web search tool. One of ``web_search`` or ``web_search_2025_08_26``. Required. + WEB_SEARCH.""" + filters: Optional["WebSearchToolFilters"] + user_location: Optional["WebSearchApproximateLocation"] + search_context_size: Literal["low", "medium", "high"] + """High level guidance for the amount of context window space to use for the search. One of + ``low``, ``medium``, or ``high``. ``medium`` is the default. Is one of the following types: + Literal[\"low\"], Literal[\"medium\"], Literal[\"high\"]""" + custom_search_configuration: "WebSearchConfiguration" + """The project connections attached to this tool. There can be a maximum of 1 connection resource + attached to the tool.""" + + +class WebSearchToolFilters(TypedDict, total=False): + """WebSearchToolFilters. + + :ivar allowed_domains: + :vartype allowed_domains: list[str] + """ + + allowed_domains: Optional[list[str]] + + +Tool = Union[ + A2APreviewTool, + ApplyPatchToolParam, + AzureAISearchTool, + AzureFunctionTool, + BingCustomSearchPreviewTool, + BingGroundingTool, + BrowserAutomationPreviewTool, + CaptureStructuredOutputsTool, + CodeInterpreterTool, + ComputerUsePreviewTool, + CustomToolParam, + MicrosoftFabricPreviewTool, + FileSearchTool, + FunctionTool, + ImageGenTool, + LocalShellToolParam, + MCPTool, + MemorySearchPreviewTool, + OpenApiTool, + SharepointPreviewTool, + FunctionShellToolParam, + WebSearchTool, + WebSearchPreviewTool, +] +FunctionShellToolParamEnvironment = Union[ + ContainerAutoParam, + FunctionShellToolParamEnvironmentContainerReferenceParam, + FunctionShellToolParamEnvironmentLocalEnvironmentParam, +] +ContainerNetworkPolicyParam = Union[ContainerNetworkPolicyAllowlistParam, ContainerNetworkPolicyDisabledParam] +ContainerSkill = Union[InlineSkillParam, SkillReferenceParam] +CustomToolParamFormat = Union[CustomGrammarFormatParam, CustomTextFormatParam] +ToolChoiceParam = Union[ + ToolChoiceAllowed, + SpecificApplyPatchParam, + ToolChoiceCodeInterpreter, + ToolChoiceComputerUsePreview, + ToolChoiceCustom, + ToolChoiceFileSearch, + ToolChoiceFunction, + ToolChoiceImageGeneration, + ToolChoiceMCP, + SpecificFunctionShellParam, + ToolChoiceWebSearchPreview, + ToolChoiceWebSearchPreview20250311, +] +TextResponseFormat = Union[TextResponseFormatJsonObject, TextResponseFormatJsonSchema, TextResponseFormatText] diff --git a/sdk/ai/azure-ai-agents/pyproject.toml b/sdk/ai/azure-ai-agents/pyproject.toml index 062a6418ec7b..25f2d68057a4 100644 --- a/sdk/ai/azure-ai-agents/pyproject.toml +++ b/sdk/ai/azure-ai-agents/pyproject.toml @@ -1,26 +1,67 @@ -[tool.mypy] -python_version = "3.10" -exclude = [ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +[build-system] +requires = ["setuptools>=77.0.3", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "azure-ai-agents" +authors = [ + { name = "Microsoft Corporation", email = "azpysdkhelp@microsoft.com" }, +] +description = "Microsoft Corporation Azure Ai Agents Client Library for Python" +license = "MIT" +classifiers = [ + "Development Status :: 4 - Beta", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", +] +requires-python = ">=3.10" +keywords = ["azure", "azure sdk"] + +dependencies = [ + "isodate>=0.6.1", + "azure-core>=1.37.0", + "typing-extensions>=4.6.0", ] -warn_unused_configs = true -ignore_missing_imports = true -follow_imports_for_stubs = false - -[tool.isort] -profile = "black" -line_length = 120 -known_first_party = ["azure"] -filter_files=true -extend_skip_glob = [ - "*/_vendor/*", - "*/_generated/*", - "*/_restclient/*", - "*/doc/*", - "*/.tox/*", +dynamic = [ +"version", "readme" ] +[project.urls] +repository = "https://github.com/Azure/azure-sdk-for-python" + +[tool.setuptools.dynamic] +version = {attr = "azure.ai.agents._version.VERSION"} +readme = {file = ["README.md", "CHANGELOG.md"], content-type = "text/markdown"} + +[tool.setuptools.packages.find] +exclude = [ + "tests*", + "generated_tests*", + "samples*", + "generated_samples*", + "doc*", + "azure", + "azure.ai", +] + +[tool.setuptools.package-data] +pytyped = ["py.typed"] + [tool.azure-sdk-build] -whl_no_aio= false +whl_no_aio = false [tool.azure-sdk-conda] in_bundle = false diff --git a/sdk/ai/azure-ai-agents/samples/agents_async/sample_agents_basics_with_console_tracing_async.py b/sdk/ai/azure-ai-agents/samples/agents_async/sample_agents_basics_with_console_tracing_async.py index bacec1c100b0..67c32b24c200 100644 --- a/sdk/ai/azure-ai-agents/samples/agents_async/sample_agents_basics_with_console_tracing_async.py +++ b/sdk/ai/azure-ai-agents/samples/agents_async/sample_agents_basics_with_console_tracing_async.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -37,6 +38,7 @@ from azure.identity.aio import DefaultAzureCredential from azure.core.settings import settings + settings.tracing_implementation = "opentelemetry" # Install opentelemetry with command "pip install azure-ai-projects opentelemetry-sdk". @@ -53,6 +55,7 @@ tracer = trace.get_tracer(__name__) from azure.ai.agents.telemetry import AIAgentsInstrumentor + AIAgentsInstrumentor().instrument() @@ -80,7 +83,9 @@ async def main() -> None: thread = await project_client.agents.threads.create() print(f"Created thread, thread ID: {thread.id}") - message = await project_client.agents.messages.create(thread_id=thread.id, role="user", content="Hello, tell me a joke") + message = await project_client.agents.messages.create( + thread_id=thread.id, role="user", content="Hello, tell me a joke" + ) print(f"Created message, message ID: {message.id}") run = await project_client.agents.runs.create_and_process(thread_id=thread.id, agent_id=agent.id) diff --git a/sdk/ai/azure-ai-agents/setup.py b/sdk/ai/azure-ai-agents/setup.py deleted file mode 100644 index 372a1c431d12..000000000000 --- a/sdk/ai/azure-ai-agents/setup.py +++ /dev/null @@ -1,80 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - - -import os -import re -from setuptools import setup, find_packages - - -PACKAGE_NAME = "azure-ai-agents" -PACKAGE_PPRINT_NAME = "Azure AI Agents" - -# a-b-c => a/b/c -package_folder_path = PACKAGE_NAME.replace("-", "/") - -# Version extraction inspired from 'requests' -with open(os.path.join(package_folder_path, "_version.py"), "r") as fd: - version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) - -if not version: - raise RuntimeError("Cannot find version information") - - -setup( - name=PACKAGE_NAME, - version=version, - description="Microsoft Corporation {} Client Library for Python".format(PACKAGE_PPRINT_NAME), - long_description=open("README.md", "r").read(), - long_description_content_type="text/markdown", - license="MIT License", - author="Microsoft Corporation", - author_email="azpysdkhelp@microsoft.com", - url="https://github.com/Azure/azure-sdk-for-python/tree/main/sdk", - keywords="azure, azure sdk", - classifiers=[ - "Development Status :: 4 - Beta", - "Programming Language :: Python", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "License :: OSI Approved :: MIT License", - ], - zip_safe=False, - packages=find_packages( - exclude=[ - "samples", - "samples.utils", - "samples.agents_tools", - "samples.agents_async", - "samples.agents_multiagent", - "samples.agents_streaming", - "samples.agents_telemetry", - "samples.agents_tools", - "samples.assets", - "samples.agents_async.utils", - "tests", - # Exclude packages that will be covered by PEP420 or nspkg - "azure", - "azure.ai", - ] - ), - include_package_data=True, - package_data={ - "azure.ai.agents": ["py.typed"], - }, - install_requires=[ - "isodate>=0.6.1", - "azure-core>=1.30.0", - "typing-extensions>=4.6.0", - ], - python_requires=">=3.9", -) From c53c0fcea79f1310610ed7bc464e3985c01478e2 Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Wed, 17 Jun 2026 14:48:42 -0400 Subject: [PATCH 2/5] regenerate --- .../azure/ai/projects/_unions.py | 13 + .../azure/ai/projects/types.py | 4640 +++++++++++++++++ 2 files changed, 4653 insertions(+) create mode 100644 sdk/ai/azure-ai-projects/azure/ai/projects/_unions.py create mode 100644 sdk/ai/azure-ai-projects/azure/ai/projects/types.py diff --git a/sdk/ai/azure-ai-projects/azure/ai/projects/_unions.py b/sdk/ai/azure-ai-projects/azure/ai/projects/_unions.py new file mode 100644 index 000000000000..b03d9e548284 --- /dev/null +++ b/sdk/ai/azure-ai-projects/azure/ai/projects/_unions.py @@ -0,0 +1,13 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import TYPE_CHECKING, Union + +if TYPE_CHECKING: + from . import types as _types +Filters = Union["_types.ComparisonFilter", "_types.CompoundFilter"] diff --git a/sdk/ai/azure-ai-projects/azure/ai/projects/types.py b/sdk/ai/azure-ai-projects/azure/ai/projects/types.py new file mode 100644 index 000000000000..5a5d1fefd0e3 --- /dev/null +++ b/sdk/ai/azure-ai-projects/azure/ai/projects/types.py @@ -0,0 +1,4640 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Literal, Optional, TYPE_CHECKING, Union +from typing_extensions import Required, TypedDict + +from .models._enums import ( + AgentKind, + AgentObjectType, + ContainerNetworkPolicyParamType, + ContainerSkillType, + CredentialType, + CustomToolParamFormatType, + DatasetType, + DeploymentType, + EvaluationRuleActionType, + EvaluationTaxonomyInputType, + EvaluatorDefinitionType, + FunctionShellToolParamEnvironmentType, + IndexType, + InsightType, + MemoryItemKind, + MemoryStoreKind, + MemoryStoreObjectType, + OpenApiAuthType, + PendingUploadType, + RecurrenceType, + SampleType, + ScheduleTaskType, + TextResponseFormatConfigurationType, + ToolChoiceParamType, + ToolType, + TriggerType, +) + +if TYPE_CHECKING: + from . import _unions + +AgentDefinitionOptInKeys = Literal["HostedAgents=V1Preview", "WorkflowAgents=V1Preview"] +"""Feature opt-in keys for agent definition operations supporting hosted or workflow agents.""" + +AgentKind = Literal["prompt", "hosted", "workflow"] +"""Type of AgentKind.""" + +AgentObjectType = Literal["agent", "agent.version", "agent.deleted", "agent.version.deleted", "agent.container"] +"""Type of AgentObjectType.""" + +AgentProtocol = Literal["activity_protocol", "responses"] +"""Type of AgentProtocol.""" + +AttackStrategy = Literal[ + "easy", + "moderate", + "difficult", + "ascii_art", + "ascii_smuggler", + "atbash", + "base64", + "binary", + "caesar", + "character_space", + "jailbreak", + "ansi_attack", + "character_swap", + "suffix_append", + "string_join", + "unicode_confusable", + "unicode_substitution", + "diacritic", + "flip", + "leetspeak", + "rot13", + "morse", + "url", + "baseline", + "indirect_jailbreak", + "tense", + "multi_turn", + "crescendo", +] +"""Strategies for attacks.""" + +AzureAISearchQueryType = Literal["simple", "semantic", "vector", "vector_simple_hybrid", "vector_semantic_hybrid"] +"""Available query types for Azure AI Search tool.""" + +ComputerEnvironment = Literal["windows", "mac", "linux", "ubuntu", "browser"] +"""Type of ComputerEnvironment.""" + +ConnectionType = Literal[ + "AzureOpenAI", + "AzureBlob", + "AzureStorageAccount", + "CognitiveSearch", + "CosmosDB", + "ApiKey", + "AppConfig", + "AppInsights", + "CustomKeys", + "RemoteTool_Preview", +] +"""The Type (or category) of the connection.""" + +ContainerMemoryLimit = Literal["1g", "4g", "16g", "64g"] +"""Type of ContainerMemoryLimit.""" + +ContainerNetworkPolicyParamType = Literal["disabled", "allowlist"] +"""Type of ContainerNetworkPolicyParamType.""" + +ContainerSkillType = Literal["skill_reference", "inline"] +"""Type of ContainerSkillType.""" + +CredentialType = Literal["ApiKey", "AAD", "SAS", "CustomKeys", "None", "AgenticIdentityToken_Preview"] +"""The credential type used by the connection.""" + +CustomToolParamFormatType = Literal["text", "grammar"] +"""Type of CustomToolParamFormatType.""" + +DatasetType = Literal["uri_file", "uri_folder"] +"""Enum to determine the type of data.""" + +DayOfWeek = Literal["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] +"""Days of the week for recurrence schedule.""" + +DeploymentType = Literal["ModelDeployment"] +"""Type of DeploymentType.""" + +EvaluationRuleActionType = Literal["continuousEvaluation", "humanEvaluationPreview"] +"""Type of the evaluation action.""" + +EvaluationRuleEventType = Literal["responseCompleted", "manual"] +"""Type of the evaluation rule event.""" + +EvaluationTaxonomyInputType = Literal["agent", "policy"] +"""Type of the evaluation taxonomy input.""" + +EvaluatorCategory = Literal["quality", "safety", "agents"] +"""The category of the evaluator.""" + +EvaluatorDefinitionType = Literal["prompt", "code", "prompt_and_code", "service", "openai_graders"] +"""The type of evaluator definition.""" + +EvaluatorMetricDirection = Literal["increase", "decrease", "neutral"] +"""The direction of the metric indicating whether a higher value is better, a lower value is +better, or neutral.""" + +EvaluatorMetricType = Literal["ordinal", "continuous", "boolean"] +"""The type of the evaluator.""" + +EvaluatorType = Literal["builtin", "custom"] +"""The type of the evaluator.""" + +FoundryFeaturesOptInKeys = Literal[ + "Evaluations=V1Preview", "Schedules=V1Preview", "RedTeams=V1Preview", "Insights=V1Preview", "MemoryStores=V1Preview" +] +"""Type of FoundryFeaturesOptInKeys.""" + +FunctionShellToolParamEnvironmentType = Literal["container_auto", "local", "container_reference"] +"""Type of FunctionShellToolParamEnvironmentType.""" + +GrammarSyntax1 = Literal["lark", "regex"] +"""Type of GrammarSyntax1.""" + +ImageGenAction = Literal["generate", "edit", "auto"] +"""Type of ImageGenAction.""" + +IndexType = Literal["AzureSearch", "CosmosDBNoSqlVectorStore", "ManagedAzureSearch"] +"""Type of IndexType.""" + +InputFidelity = Literal["high", "low"] +"""Control how much effort the model will exert to match the style and features, especially facial +features, of input images. This parameter is only supported for ``gpt-image-1`` and +``gpt-image-1.5`` and later models, unsupported for ``gpt-image-1-mini``. Supports ``high`` and +``low``. Defaults to ``low``.""" + +InsightType = Literal["EvaluationRunClusterInsight", "AgentClusterInsight", "EvaluationComparison"] +"""The request of the insights.""" + +MemoryItemKind = Literal["user_profile", "chat_summary"] +"""Memory item kind.""" + +MemoryOperationKind = Literal["create", "update", "delete"] +"""Memory operation kind.""" + +MemoryStoreKind = Literal["default"] +"""The type of memory store implementation to use.""" + +MemoryStoreObjectType = Literal["memory_store", "memory_store.deleted", "memory_store.scope.deleted"] +"""Type of MemoryStoreObjectType.""" + +MemoryStoreUpdateStatus = Literal["queued", "in_progress", "completed", "failed", "superseded"] +"""Status of a memory store update operation.""" + +OpenApiAuthType = Literal["anonymous", "project_connection", "managed_identity"] +"""Authentication type for OpenApi endpoint. Allowed types are: + +* Anonymous (no authentication required) +* Project Connection (requires project_connection_id to endpoint, as setup in AI Foundry) +* Managed_Identity (requires audience for identity based auth).""" + +OperationState = Literal["NotStarted", "Running", "Succeeded", "Failed", "Canceled"] +"""Enum describing allowed operation states.""" + +PageOrder = Literal["asc", "desc"] +"""Type of PageOrder.""" + +PendingUploadType = Literal["None", "BlobReference"] +"""The type of pending upload.""" + +RankerVersionType = Literal["auto", "default-2024-11-15"] +"""Type of RankerVersionType.""" + +RecurrenceType = Literal["Hourly", "Daily", "Weekly", "Monthly"] +"""Recurrence type.""" + +RiskCategory = Literal[ + "HateUnfairness", + "Violence", + "Sexual", + "SelfHarm", + "ProtectedMaterial", + "CodeVulnerability", + "UngroundedAttributes", + "ProhibitedActions", + "SensitiveDataLeakage", + "TaskAdherence", +] +"""Risk category for the attack objective.""" + +SampleType = Literal["EvaluationResultSample"] +"""The type of sample used in the analysis.""" + +ScheduleProvisioningStatus = Literal["Creating", "Updating", "Deleting", "Succeeded", "Failed"] +"""Schedule provisioning status.""" + +ScheduleTaskType = Literal["Evaluation", "Insight"] +"""Type of the task.""" + +SearchContextSize = Literal["low", "medium", "high"] +"""Type of SearchContextSize.""" + +TextResponseFormatConfigurationType = Literal["text", "json_schema", "json_object"] +"""Type of TextResponseFormatConfigurationType.""" + +ToolChoiceParamType = Literal[ + "allowed_tools", + "function", + "mcp", + "custom", + "apply_patch", + "shell", + "file_search", + "web_search_preview", + "computer_use_preview", + "web_search_preview_2025_03_11", + "image_generation", + "code_interpreter", +] +"""Type of ToolChoiceParamType.""" + +ToolType = Literal[ + "function", + "file_search", + "computer_use_preview", + "web_search", + "mcp", + "code_interpreter", + "image_generation", + "local_shell", + "shell", + "custom", + "web_search_preview", + "apply_patch", + "a2a_preview", + "bing_custom_search_preview", + "browser_automation_preview", + "fabric_dataagent_preview", + "sharepoint_grounding_preview", + "memory_search_preview", + "azure_ai_search", + "azure_function", + "bing_grounding", + "capture_structured_outputs", + "openapi", +] +"""Type of ToolType.""" + +TreatmentEffectType = Literal["TooFewSamples", "Inconclusive", "Changed", "Improved", "Degraded"] +"""Treatment Effect Type.""" + +TriggerType = Literal["Cron", "Recurrence", "OneTime"] +"""Type of the trigger.""" + + +class A2APreviewTool(TypedDict, total=False): + """An agent implementing the A2A protocol. + + :ivar type: The type of the tool. Always ``"a2a_preview``. Required. A2_A_PREVIEW. + :vartype type: str or ~azure.ai.projects.models.A2_A_PREVIEW + :ivar base_url: Base URL of the agent. + :vartype base_url: str + :ivar agent_card_path: The path to the agent card relative to the ``base_url``. If not + provided, defaults to ``/.well-known/agent-card.json``. + :vartype agent_card_path: str + :ivar project_connection_id: The connection ID in the project for the A2A server. The + connection stores authentication and other connection details needed to connect to the A2A + server. + :vartype project_connection_id: str + """ + + type: Required[Literal[ToolType.A2_A_PREVIEW]] + """The type of the tool. Always ``\"a2a_preview``. Required. A2_A_PREVIEW.""" + base_url: str + """Base URL of the agent.""" + agent_card_path: str + """The path to the agent card relative to the ``base_url``. If not provided, defaults to + ``/.well-known/agent-card.json``.""" + project_connection_id: str + """The connection ID in the project for the A2A server. The connection stores authentication and + other connection details needed to connect to the A2A server.""" + + +class AgentClusterInsightRequest(TypedDict, total=False): + """Insights on set of Agent Evaluation Results. + + :ivar type: The type of request. Required. Cluster Insight on an Agent. + :vartype type: str or ~azure.ai.projects.models.AGENT_CLUSTER_INSIGHT + :ivar agent_name: Identifier for the agent. Required. + :vartype agent_name: str + :ivar model_configuration: Configuration of the model used in the insight generation. + :vartype model_configuration: ~azure.ai.projects.types.InsightModelConfiguration + """ + + type: Required[Literal[InsightType.AGENT_CLUSTER_INSIGHT]] + """The type of request. Required. Cluster Insight on an Agent.""" + agentName: Required[str] + """Identifier for the agent. Required.""" + modelConfiguration: "InsightModelConfiguration" + """Configuration of the model used in the insight generation.""" + + +class AgentClusterInsightResult(TypedDict, total=False): + """Insights from the agent cluster analysis. + + :ivar type: The type of insights result. Required. Cluster Insight on an Agent. + :vartype type: str or ~azure.ai.projects.models.AGENT_CLUSTER_INSIGHT + :ivar cluster_insight: Required. + :vartype cluster_insight: ~azure.ai.projects.types.ClusterInsightResult + """ + + type: Required[Literal[InsightType.AGENT_CLUSTER_INSIGHT]] + """The type of insights result. Required. Cluster Insight on an Agent.""" + clusterInsight: Required["ClusterInsightResult"] + """Required.""" + + +class AgentDetails(TypedDict, total=False): + """AgentDetails. + + :ivar object: The object type, which is always 'agent'. Required. AGENT. + :vartype object: str or ~azure.ai.projects.models.AGENT + :ivar id: The unique identifier of the agent. Required. + :vartype id: str + :ivar name: The name of the agent. Required. + :vartype name: str + :ivar versions: The latest version of the agent. Required. + :vartype versions: ~azure.ai.projects.types.AgentObjectVersions + """ + + object: Required[Literal[AgentObjectType.AGENT]] + """The object type, which is always 'agent'. Required. AGENT.""" + id: Required[str] + """The unique identifier of the agent. Required.""" + name: Required[str] + """The name of the agent. Required.""" + versions: Required["AgentObjectVersions"] + """The latest version of the agent. Required.""" + + +class AgenticIdentityPreviewCredentials(TypedDict, total=False): + """Agentic identity credential definition. + + :ivar type: The credential type. Required. Agentic identity credential. + :vartype type: str or ~azure.ai.projects.models.AGENTIC_IDENTITY_PREVIEW + """ + + type: Required[Literal[CredentialType.AGENTIC_IDENTITY_PREVIEW]] + """The credential type. Required. Agentic identity credential.""" + + +class AgentObjectVersions(TypedDict, total=False): + """AgentObjectVersions. + + :ivar latest: Required. + :vartype latest: ~azure.ai.projects.types.AgentVersionDetails + """ + + latest: Required["AgentVersionDetails"] + """Required.""" + + +class AgentTaxonomyInput(TypedDict, total=False): + """Input configuration for the evaluation taxonomy when the input type is agent. + + :ivar type: Input type of the evaluation taxonomy. Required. Agent. + :vartype type: str or ~azure.ai.projects.models.AGENT + :ivar target: Target configuration for the agent. Required. + :vartype target: ~azure.ai.projects.types.Target + :ivar risk_categories: List of risk categories to evaluate against. Required. + :vartype risk_categories: list[str or ~azure.ai.projects.models.RiskCategory] + """ + + type: Required[Literal[EvaluationTaxonomyInputType.AGENT]] + """Input type of the evaluation taxonomy. Required. Agent.""" + target: Required["Target"] + """Target configuration for the agent. Required.""" + riskCategories: Required[list[RiskCategory]] + """List of risk categories to evaluate against. Required.""" + + +class AgentVersionDetails(TypedDict, total=False): + """AgentVersionDetails. + + :ivar metadata: Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. Required. + :vartype metadata: dict[str, str] + :ivar object: The object type, which is always 'agent.version'. Required. AGENT_VERSION. + :vartype object: str or ~azure.ai.projects.models.AGENT_VERSION + :ivar id: The unique identifier of the agent version. Required. + :vartype id: str + :ivar name: The name of the agent. Name can be used to retrieve/update/delete the agent. + Required. + :vartype name: str + :ivar version: The version identifier of the agent. Agents are immutable and every update + creates a new version while keeping the name same. Required. + :vartype version: str + :ivar description: A human-readable description of the agent. + :vartype description: str + :ivar created_at: The Unix timestamp (seconds) when the agent was created. Required. + :vartype created_at: ~datetime.datetime + :ivar definition: Required. + :vartype definition: ~azure.ai.projects.types.AgentDefinition + """ + + metadata: Required[Optional[dict[str, str]]] + """Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. Required.""" + object: Required[Literal[AgentObjectType.AGENT_VERSION]] + """The object type, which is always 'agent.version'. Required. AGENT_VERSION.""" + id: Required[str] + """The unique identifier of the agent version. Required.""" + name: Required[str] + """The name of the agent. Name can be used to retrieve/update/delete the agent. Required.""" + version: Required[str] + """The version identifier of the agent. Agents are immutable and every update creates a new + version while keeping the name same. Required.""" + description: str + """A human-readable description of the agent.""" + created_at: Required[int] + """The Unix timestamp (seconds) when the agent was created. Required.""" + definition: Required["AgentDefinition"] + """Required.""" + + +class AISearchIndexResource(TypedDict, total=False): + """A AI Search Index resource. + + :ivar project_connection_id: An index connection ID in an IndexResource attached to this agent. + :vartype project_connection_id: str + :ivar index_name: The name of an index in an IndexResource attached to this agent. + :vartype index_name: str + :ivar query_type: Type of query in an AIIndexResource attached to this agent. Known values are: + "simple", "semantic", "vector", "vector_simple_hybrid", and "vector_semantic_hybrid". + :vartype query_type: str or ~azure.ai.projects.models.AzureAISearchQueryType + :ivar top_k: Number of documents to retrieve from search and present to the model. + :vartype top_k: int + :ivar filter: filter string for search resource. `Learn more here + `_. + :vartype filter: str + :ivar index_asset_id: Index asset id for search resource. + :vartype index_asset_id: str + """ + + project_connection_id: str + """An index connection ID in an IndexResource attached to this agent.""" + index_name: str + """The name of an index in an IndexResource attached to this agent.""" + query_type: AzureAISearchQueryType + """Type of query in an AIIndexResource attached to this agent. Known values are: \"simple\", + \"semantic\", \"vector\", \"vector_simple_hybrid\", and \"vector_semantic_hybrid\".""" + top_k: int + """Number of documents to retrieve from search and present to the model.""" + filter: str + """filter string for search resource. `Learn more here + `_.""" + index_asset_id: str + """Index asset id for search resource.""" + + +class ApiError(TypedDict, total=False): + """ApiError. + + :ivar code: Required. + :vartype code: str + :ivar message: Required. + :vartype message: str + :ivar param: + :vartype param: str + :ivar type: + :vartype type: str + :ivar details: + :vartype details: list[~azure.ai.projects.types.ApiError] + :ivar additional_info: + :vartype additional_info: dict[str, any] + :ivar debug_info: + :vartype debug_info: dict[str, any] + """ + + code: Required[Optional[str]] + """Required.""" + message: Required[str] + """Required.""" + param: Optional[str] + type: str + details: list["ApiError"] + additionalInfo: dict[str, Any] + debugInfo: dict[str, Any] + + +class ApiErrorResponse(TypedDict, total=False): + """Error response for API failures. + + :ivar error: Required. + :vartype error: ~azure.ai.projects.types.ApiError + """ + + error: Required["ApiError"] + """Required.""" + + +class ApiKeyCredentials(TypedDict, total=False): + """API Key Credential definition. + + :ivar type: The credential type. Required. API Key credential. + :vartype type: str or ~azure.ai.projects.models.API_KEY + :ivar api_key: API Key. + :vartype api_key: str + """ + + type: Required[Literal[CredentialType.API_KEY]] + """The credential type. Required. API Key credential.""" + key: str + """API Key.""" + + +class ApplyPatchToolParam(TypedDict, total=False): + """Apply patch tool. + + :ivar type: The type of the tool. Always ``apply_patch``. Required. APPLY_PATCH. + :vartype type: str or ~azure.ai.projects.models.APPLY_PATCH + """ + + type: Required[Literal[ToolType.APPLY_PATCH]] + """The type of the tool. Always ``apply_patch``. Required. APPLY_PATCH.""" + + +class ApproximateLocation(TypedDict, total=False): + """ApproximateLocation. + + :ivar type: The type of location approximation. Always ``approximate``. Required. Default value + is "approximate". + :vartype type: str + :ivar country: + :vartype country: str + :ivar region: + :vartype region: str + :ivar city: + :vartype city: str + :ivar timezone: + :vartype timezone: str + """ + + type: Required[Literal["approximate"]] + """The type of location approximation. Always ``approximate``. Required. Default value is + \"approximate\".""" + country: Optional[str] + region: Optional[str] + city: Optional[str] + timezone: Optional[str] + + +class AutoCodeInterpreterToolParam(TypedDict, total=False): + """Automatic Code Interpreter Tool Parameters. + + :ivar type: Always ``auto``. Required. Default value is "auto". + :vartype type: str + :ivar file_ids: An optional list of uploaded files to make available to your code. + :vartype file_ids: list[str] + :ivar memory_limit: Known values are: "1g", "4g", "16g", and "64g". + :vartype memory_limit: str or ~azure.ai.projects.models.ContainerMemoryLimit + :ivar network_policy: + :vartype network_policy: ~azure.ai.projects.types.ContainerNetworkPolicyParam + """ + + type: Required[Literal["auto"]] + """Always ``auto``. Required. Default value is \"auto\".""" + file_ids: list[str] + """An optional list of uploaded files to make available to your code.""" + memory_limit: Optional[ContainerMemoryLimit] + """Known values are: \"1g\", \"4g\", \"16g\", and \"64g\".""" + network_policy: "ContainerNetworkPolicyParam" + + +class AzureAIAgentTarget(TypedDict, total=False): + """Represents a target specifying an Azure AI agent. + + :ivar type: The type of target, always ``azure_ai_agent``. Required. Default value is + "azure_ai_agent". + :vartype type: str + :ivar name: The unique identifier of the Azure AI agent. Required. + :vartype name: str + :ivar version: The version of the Azure AI agent. + :vartype version: str + :ivar tool_descriptions: The parameters used to control the sampling behavior of the agent + during text generation. + :vartype tool_descriptions: list[~azure.ai.projects.types.ToolDescription] + """ + + type: Required[Literal["azure_ai_agent"]] + """The type of target, always ``azure_ai_agent``. Required. Default value is \"azure_ai_agent\".""" + name: Required[str] + """The unique identifier of the Azure AI agent. Required.""" + version: str + """The version of the Azure AI agent.""" + tool_descriptions: list["ToolDescription"] + """The parameters used to control the sampling behavior of the agent during text generation.""" + + +class AzureAIModelTarget(TypedDict, total=False): + """Represents a target specifying an Azure AI model for operations requiring model selection. + + :ivar type: The type of target, always ``azure_ai_model``. Required. Default value is + "azure_ai_model". + :vartype type: str + :ivar model: The unique identifier of the Azure AI model. + :vartype model: str + :ivar sampling_params: The parameters used to control the sampling behavior of the model during + text generation. + :vartype sampling_params: ~azure.ai.projects.types.ModelSamplingParams + """ + + type: Required[Literal["azure_ai_model"]] + """The type of target, always ``azure_ai_model``. Required. Default value is \"azure_ai_model\".""" + model: str + """The unique identifier of the Azure AI model.""" + sampling_params: "ModelSamplingParams" + """The parameters used to control the sampling behavior of the model during text generation.""" + + +class AzureAISearchIndex(TypedDict, total=False): + """Azure AI Search Index Definition. + + :ivar id: Asset ID, a unique identifier for the asset. + :vartype id: str + :ivar name: The name of the resource. Required. + :vartype name: str + :ivar version: The version of the resource. Required. + :vartype version: str + :ivar description: The asset description text. + :vartype description: str + :ivar tags: Tag dictionary. Tags can be added, removed, and updated. + :vartype tags: dict[str, str] + :ivar type: Type of index. Required. Azure search. + :vartype type: str or ~azure.ai.projects.models.AZURE_SEARCH + :ivar connection_name: Name of connection to Azure AI Search. Required. + :vartype connection_name: str + :ivar index_name: Name of index in Azure AI Search resource to attach. Required. + :vartype index_name: str + :ivar field_mapping: Field mapping configuration. + :vartype field_mapping: ~azure.ai.projects.types.FieldMapping + """ + + id: str + """Asset ID, a unique identifier for the asset.""" + name: Required[str] + """The name of the resource. Required.""" + version: Required[str] + """The version of the resource. Required.""" + description: str + """The asset description text.""" + tags: dict[str, str] + """Tag dictionary. Tags can be added, removed, and updated.""" + type: Required[Literal[IndexType.AZURE_SEARCH]] + """Type of index. Required. Azure search.""" + connectionName: Required[str] + """Name of connection to Azure AI Search. Required.""" + indexName: Required[str] + """Name of index in Azure AI Search resource to attach. Required.""" + fieldMapping: "FieldMapping" + """Field mapping configuration.""" + + +class AzureAISearchTool(TypedDict, total=False): + """The input definition information for an Azure AI search tool as used to configure an agent. + + :ivar type: The object type, which is always 'azure_ai_search'. Required. AZURE_AI_SEARCH. + :vartype type: str or ~azure.ai.projects.models.AZURE_AI_SEARCH + :ivar azure_ai_search: The azure ai search index resource. Required. + :vartype azure_ai_search: ~azure.ai.projects.types.AzureAISearchToolResource + """ + + type: Required[Literal[ToolType.AZURE_AI_SEARCH]] + """The object type, which is always 'azure_ai_search'. Required. AZURE_AI_SEARCH.""" + azure_ai_search: Required["AzureAISearchToolResource"] + """The azure ai search index resource. Required.""" + + +class AzureAISearchToolResource(TypedDict, total=False): + """A set of index resources used by the ``azure_ai_search`` tool. + + :ivar indexes: The indices attached to this agent. There can be a maximum of 1 index resource + attached to the agent. Required. + :vartype indexes: list[~azure.ai.projects.types.AISearchIndexResource] + """ + + indexes: Required[list["AISearchIndexResource"]] + """The indices attached to this agent. There can be a maximum of 1 index resource attached to the + agent. Required.""" + + +class AzureFunctionBinding(TypedDict, total=False): + """The structure for keeping storage queue name and URI. + + :ivar type: The type of binding, which is always 'storage_queue'. Required. Default value is + "storage_queue". + :vartype type: str + :ivar storage_queue: Storage queue. Required. + :vartype storage_queue: ~azure.ai.projects.types.AzureFunctionStorageQueue + """ + + type: Required[Literal["storage_queue"]] + """The type of binding, which is always 'storage_queue'. Required. Default value is + \"storage_queue\".""" + storage_queue: Required["AzureFunctionStorageQueue"] + """Storage queue. Required.""" + + +class AzureFunctionDefinition(TypedDict, total=False): + """The definition of Azure function. + + :ivar function: The definition of azure function and its parameters. Required. + :vartype function: ~azure.ai.projects.types.AzureFunctionDefinitionFunction + :ivar input_binding: Input storage queue. The queue storage trigger runs a function as messages + are added to it. Required. + :vartype input_binding: ~azure.ai.projects.types.AzureFunctionBinding + :ivar output_binding: Output storage queue. The function writes output to this queue when the + input items are processed. Required. + :vartype output_binding: ~azure.ai.projects.types.AzureFunctionBinding + """ + + function: Required["AzureFunctionDefinitionFunction"] + """The definition of azure function and its parameters. Required.""" + input_binding: Required["AzureFunctionBinding"] + """Input storage queue. The queue storage trigger runs a function as messages are added to it. + Required.""" + output_binding: Required["AzureFunctionBinding"] + """Output storage queue. The function writes output to this queue when the input items are + processed. Required.""" + + +class AzureFunctionDefinitionFunction(TypedDict, total=False): + """AzureFunctionDefinitionFunction. + + :ivar name: The name of the function to be called. Required. + :vartype name: str + :ivar description: A description of what the function does, used by the model to choose when + and how to call the function. + :vartype description: str + :ivar parameters: The parameters the functions accepts, described as a JSON Schema object. + Required. + :vartype parameters: dict[str, any] + """ + + name: Required[str] + """The name of the function to be called. Required.""" + description: str + """A description of what the function does, used by the model to choose when and how to call the + function.""" + parameters: Required[dict[str, Any]] + """The parameters the functions accepts, described as a JSON Schema object. Required.""" + + +class AzureFunctionStorageQueue(TypedDict, total=False): + """The structure for keeping storage queue name and URI. + + :ivar queue_service_endpoint: URI to the Azure Storage Queue service allowing you to manipulate + a queue. Required. + :vartype queue_service_endpoint: str + :ivar queue_name: The name of an Azure function storage queue. Required. + :vartype queue_name: str + """ + + queue_service_endpoint: Required[str] + """URI to the Azure Storage Queue service allowing you to manipulate a queue. Required.""" + queue_name: Required[str] + """The name of an Azure function storage queue. Required.""" + + +class AzureFunctionTool(TypedDict, total=False): + """The input definition information for an Azure Function Tool, as used to configure an Agent. + + :ivar type: The object type, which is always 'browser_automation'. Required. AZURE_FUNCTION. + :vartype type: str or ~azure.ai.projects.models.AZURE_FUNCTION + :ivar azure_function: The Azure Function Tool definition. Required. + :vartype azure_function: ~azure.ai.projects.types.AzureFunctionDefinition + """ + + type: Required[Literal[ToolType.AZURE_FUNCTION]] + """The object type, which is always 'browser_automation'. Required. AZURE_FUNCTION.""" + azure_function: Required["AzureFunctionDefinition"] + """The Azure Function Tool definition. Required.""" + + +class AzureOpenAIModelConfiguration(TypedDict, total=False): + """Azure OpenAI model configuration. The API version would be selected by the service for querying + the model. + + :ivar type: Required. Default value is "AzureOpenAIModel". + :vartype type: str + :ivar model_deployment_name: Deployment name for AOAI model. Example: gpt-4o if in AIServices + or connection based ``connection_name/deployment_name`` (e.g. ``my-aoai-connection/gpt-4o``). + Required. + :vartype model_deployment_name: str + """ + + type: Required[Literal["AzureOpenAIModel"]] + """Required. Default value is \"AzureOpenAIModel\".""" + modelDeploymentName: Required[str] + """Deployment name for AOAI model. Example: gpt-4o if in AIServices or connection based + ``connection_name/deployment_name`` (e.g. ``my-aoai-connection/gpt-4o``). Required.""" + + +class BingCustomSearchConfiguration(TypedDict, total=False): + """A bing custom search configuration. + + :ivar project_connection_id: Project connection id for grounding with bing search. Required. + :vartype project_connection_id: str + :ivar instance_name: Name of the custom configuration instance given to config. Required. + :vartype instance_name: str + :ivar market: The market where the results come from. + :vartype market: str + :ivar set_lang: The language to use for user interface strings when calling Bing API. + :vartype set_lang: str + :ivar count: The number of search results to return in the bing api response. + :vartype count: int + :ivar freshness: Filter search results by a specific time range. See `accepted values here + `_. + :vartype freshness: str + """ + + project_connection_id: Required[str] + """Project connection id for grounding with bing search. Required.""" + instance_name: Required[str] + """Name of the custom configuration instance given to config. Required.""" + market: str + """The market where the results come from.""" + set_lang: str + """The language to use for user interface strings when calling Bing API.""" + count: int + """The number of search results to return in the bing api response.""" + freshness: str + """Filter search results by a specific time range. See `accepted values here + `_.""" + + +class BingCustomSearchPreviewTool(TypedDict, total=False): + """The input definition information for a Bing custom search tool as used to configure an agent. + + :ivar type: The object type, which is always 'bing_custom_search_preview'. Required. + BING_CUSTOM_SEARCH_PREVIEW. + :vartype type: str or ~azure.ai.projects.models.BING_CUSTOM_SEARCH_PREVIEW + :ivar bing_custom_search_preview: The bing custom search tool parameters. Required. + :vartype bing_custom_search_preview: ~azure.ai.projects.types.BingCustomSearchToolParameters + """ + + type: Required[Literal[ToolType.BING_CUSTOM_SEARCH_PREVIEW]] + """The object type, which is always 'bing_custom_search_preview'. Required. + BING_CUSTOM_SEARCH_PREVIEW.""" + bing_custom_search_preview: Required["BingCustomSearchToolParameters"] + """The bing custom search tool parameters. Required.""" + + +class BingCustomSearchToolParameters(TypedDict, total=False): + """The bing custom search tool parameters. + + :ivar search_configurations: The project connections attached to this tool. There can be a + maximum of 1 connection resource attached to the tool. Required. + :vartype search_configurations: list[~azure.ai.projects.types.BingCustomSearchConfiguration] + """ + + search_configurations: Required[list["BingCustomSearchConfiguration"]] + """The project connections attached to this tool. There can be a maximum of 1 connection resource + attached to the tool. Required.""" + + +class BingGroundingSearchConfiguration(TypedDict, total=False): + """Search configuration for Bing Grounding. + + :ivar project_connection_id: Project connection id for grounding with bing search. Required. + :vartype project_connection_id: str + :ivar market: The market where the results come from. + :vartype market: str + :ivar set_lang: The language to use for user interface strings when calling Bing API. + :vartype set_lang: str + :ivar count: The number of search results to return in the bing api response. + :vartype count: int + :ivar freshness: Filter search results by a specific time range. See `accepted values here + `_. + :vartype freshness: str + """ + + project_connection_id: Required[str] + """Project connection id for grounding with bing search. Required.""" + market: str + """The market where the results come from.""" + set_lang: str + """The language to use for user interface strings when calling Bing API.""" + count: int + """The number of search results to return in the bing api response.""" + freshness: str + """Filter search results by a specific time range. See `accepted values here + `_.""" + + +class BingGroundingSearchToolParameters(TypedDict, total=False): + """The bing grounding search tool parameters. + + :ivar search_configurations: The search configurations attached to this tool. There can be a + maximum of 1 search configuration resource attached to the tool. Required. + :vartype search_configurations: list[~azure.ai.projects.types.BingGroundingSearchConfiguration] + """ + + search_configurations: Required[list["BingGroundingSearchConfiguration"]] + """The search configurations attached to this tool. There can be a maximum of 1 search + configuration resource attached to the tool. Required.""" + + +class BingGroundingTool(TypedDict, total=False): + """The input definition information for a bing grounding search tool as used to configure an + agent. + + :ivar type: The object type, which is always 'bing_grounding'. Required. BING_GROUNDING. + :vartype type: str or ~azure.ai.projects.models.BING_GROUNDING + :ivar bing_grounding: The bing grounding search tool parameters. Required. + :vartype bing_grounding: ~azure.ai.projects.types.BingGroundingSearchToolParameters + """ + + type: Required[Literal[ToolType.BING_GROUNDING]] + """The object type, which is always 'bing_grounding'. Required. BING_GROUNDING.""" + bing_grounding: Required["BingGroundingSearchToolParameters"] + """The bing grounding search tool parameters. Required.""" + + +class BlobReference(TypedDict, total=False): + """Blob reference details. + + :ivar blob_uri: Blob URI path for client to upload data. Example: + ``https://blob.windows.core.net/Container/Path``. Required. + :vartype blob_uri: str + :ivar storage_account_arm_id: ARM ID of the storage account to use. Required. + :vartype storage_account_arm_id: str + :ivar credential: Credential info to access the storage account. Required. + :vartype credential: ~azure.ai.projects.types.BlobReferenceSasCredential + """ + + blobUri: Required[str] + """Blob URI path for client to upload data. Example: + ``https://blob.windows.core.net/Container/Path``. Required.""" + storageAccountArmId: Required[str] + """ARM ID of the storage account to use. Required.""" + credential: Required["BlobReferenceSasCredential"] + """Credential info to access the storage account. Required.""" + + +class BlobReferenceSasCredential(TypedDict, total=False): + """SAS Credential definition. + + :ivar sas_uri: SAS uri. Required. + :vartype sas_uri: str + :ivar type: Type of credential. Required. Default value is "SAS". + :vartype type: str + """ + + sasUri: Required[str] + """SAS uri. Required.""" + type: Required[Literal["SAS"]] + """Type of credential. Required. Default value is \"SAS\".""" + + +class BrowserAutomationPreviewTool(TypedDict, total=False): + """The input definition information for a Browser Automation Tool, as used to configure an Agent. + + :ivar type: The object type, which is always 'browser_automation_preview'. Required. + BROWSER_AUTOMATION_PREVIEW. + :vartype type: str or ~azure.ai.projects.models.BROWSER_AUTOMATION_PREVIEW + :ivar browser_automation_preview: The Browser Automation Tool parameters. Required. + :vartype browser_automation_preview: ~azure.ai.projects.types.BrowserAutomationToolParameters + """ + + type: Required[Literal[ToolType.BROWSER_AUTOMATION_PREVIEW]] + """The object type, which is always 'browser_automation_preview'. Required. + BROWSER_AUTOMATION_PREVIEW.""" + browser_automation_preview: Required["BrowserAutomationToolParameters"] + """The Browser Automation Tool parameters. Required.""" + + +class BrowserAutomationToolConnectionParameters(TypedDict, total=False): # pylint: disable=name-too-long + """Definition of input parameters for the connection used by the Browser Automation Tool. + + :ivar project_connection_id: The ID of the project connection to your Azure Playwright + resource. Required. + :vartype project_connection_id: str + """ + + project_connection_id: Required[str] + """The ID of the project connection to your Azure Playwright resource. Required.""" + + +class BrowserAutomationToolParameters(TypedDict, total=False): + """Definition of input parameters for the Browser Automation Tool. + + :ivar connection: The project connection parameters associated with the Browser Automation + Tool. Required. + :vartype connection: ~azure.ai.projects.types.BrowserAutomationToolConnectionParameters + """ + + connection: Required["BrowserAutomationToolConnectionParameters"] + """The project connection parameters associated with the Browser Automation Tool. Required.""" + + +class CaptureStructuredOutputsTool(TypedDict, total=False): + """A tool for capturing structured outputs. + + :ivar type: The type of the tool. Always ``capture_structured_outputs``. Required. + CAPTURE_STRUCTURED_OUTPUTS. + :vartype type: str or ~azure.ai.projects.models.CAPTURE_STRUCTURED_OUTPUTS + :ivar outputs: The structured outputs to capture from the model. Required. + :vartype outputs: ~azure.ai.projects.types.StructuredOutputDefinition + """ + + type: Required[Literal[ToolType.CAPTURE_STRUCTURED_OUTPUTS]] + """The type of the tool. Always ``capture_structured_outputs``. Required. + CAPTURE_STRUCTURED_OUTPUTS.""" + outputs: Required["StructuredOutputDefinition"] + """The structured outputs to capture from the model. Required.""" + + +class ChartCoordinate(TypedDict, total=False): + """Coordinates for the analysis chart. + + :ivar x: X-axis coordinate. Required. + :vartype x: int + :ivar y: Y-axis coordinate. Required. + :vartype y: int + :ivar size: Size of the chart element. Required. + :vartype size: int + """ + + x: Required[int] + """X-axis coordinate. Required.""" + y: Required[int] + """Y-axis coordinate. Required.""" + size: Required[int] + """Size of the chart element. Required.""" + + +class ChatSummaryMemoryItem(TypedDict, total=False): + """A memory item containing a summary extracted from conversations. + + :ivar memory_id: The unique ID of the memory item. Required. + :vartype memory_id: str + :ivar updated_at: The last update time of the memory item. Required. + :vartype updated_at: ~datetime.datetime + :ivar scope: The namespace that logically groups and isolates memories, such as a user ID. + Required. + :vartype scope: str + :ivar content: The content of the memory. Required. + :vartype content: str + :ivar kind: The kind of the memory item. Required. Summary of chat conversations. + :vartype kind: str or ~azure.ai.projects.models.CHAT_SUMMARY + """ + + memory_id: Required[str] + """The unique ID of the memory item. Required.""" + updated_at: Required[int] + """The last update time of the memory item. Required.""" + scope: Required[str] + """The namespace that logically groups and isolates memories, such as a user ID. Required.""" + content: Required[str] + """The content of the memory. Required.""" + kind: Required[Literal[MemoryItemKind.CHAT_SUMMARY]] + """The kind of the memory item. Required. Summary of chat conversations.""" + + +class ClusterInsightResult(TypedDict, total=False): + """Insights from the cluster analysis. + + :ivar summary: Summary of the insights report. Required. + :vartype summary: ~azure.ai.projects.types.InsightSummary + :ivar clusters: List of clusters identified in the insights. Required. + :vartype clusters: list[~azure.ai.projects.types.InsightCluster] + :ivar coordinates: Optional mapping of IDs to 2D coordinates used by the UX for + visualization. + + The map keys are string identifiers (for example, a cluster id or a sample id) + and the values are the coordinates and visual size for rendering on a 2D chart. + + This property is omitted unless the client requests coordinates (for example, + by passing ``includeCoordinates=true`` as a query parameter). + + Example: + + .. code-block:: + + { + "cluster-1": { "x": 12, "y": 34, "size": 8 }, + "sample-123": { "x": 18, "y": 22, "size": 4 } + } + + Coordinates are intended only for client-side visualization and do not + modify the canonical insights results. + :vartype coordinates: dict[str, ~azure.ai.projects.types.ChartCoordinate] + """ + + summary: Required["InsightSummary"] + """Summary of the insights report. Required.""" + clusters: Required[list["InsightCluster"]] + """List of clusters identified in the insights. Required.""" + coordinates: dict[str, "ChartCoordinate"] + """ Optional mapping of IDs to 2D coordinates used by the UX for visualization. + + The map keys are string identifiers (for example, a cluster id or a sample id) + and the values are the coordinates and visual size for rendering on a 2D chart. + + This property is omitted unless the client requests coordinates (for example, + by passing ``includeCoordinates=true`` as a query parameter). + + Example: + + .. code-block:: + + { + \"cluster-1\": { \"x\": 12, \"y\": 34, \"size\": 8 }, + \"sample-123\": { \"x\": 18, \"y\": 22, \"size\": 4 } + } + + Coordinates are intended only for client-side visualization and do not + modify the canonical insights results.""" + + +class ClusterTokenUsage(TypedDict, total=False): + """Token usage for cluster analysis. + + :ivar input_token_usage: input token usage. Required. + :vartype input_token_usage: int + :ivar output_token_usage: output token usage. Required. + :vartype output_token_usage: int + :ivar total_token_usage: total token usage. Required. + :vartype total_token_usage: int + """ + + inputTokenUsage: Required[int] + """input token usage. Required.""" + outputTokenUsage: Required[int] + """output token usage. Required.""" + totalTokenUsage: Required[int] + """total token usage. Required.""" + + +class CodeBasedEvaluatorDefinition(TypedDict, total=False): + """Code-based evaluator definition using python code. + + :ivar init_parameters: The JSON schema (Draft 2020-12) for the evaluator's input parameters. + This includes parameters like type, properties, required. + :vartype init_parameters: dict[str, any] + :ivar data_schema: The JSON schema (Draft 2020-12) for the evaluator's input data. This + includes parameters like type, properties, required. + :vartype data_schema: dict[str, any] + :ivar metrics: List of output metrics produced by this evaluator. + :vartype metrics: dict[str, ~azure.ai.projects.types.EvaluatorMetric] + :ivar type: Required. Code-based definition. + :vartype type: str or ~azure.ai.projects.models.CODE + :ivar code_text: Inline code text for the evaluator. Required. + :vartype code_text: str + """ + + init_parameters: dict[str, Any] + """The JSON schema (Draft 2020-12) for the evaluator's input parameters. This includes parameters + like type, properties, required.""" + data_schema: dict[str, Any] + """The JSON schema (Draft 2020-12) for the evaluator's input data. This includes parameters like + type, properties, required.""" + metrics: dict[str, "EvaluatorMetric"] + """List of output metrics produced by this evaluator.""" + type: Required[Literal[EvaluatorDefinitionType.CODE]] + """Required. Code-based definition.""" + code_text: Required[str] + """Inline code text for the evaluator. Required.""" + + +class CodeInterpreterTool(TypedDict, total=False): + """Code interpreter. + + :ivar type: The type of the code interpreter tool. Always ``code_interpreter``. Required. + CODE_INTERPRETER. + :vartype type: str or ~azure.ai.projects.models.CODE_INTERPRETER + :ivar container: The code interpreter container. Can be a container ID or an object that + specifies uploaded file IDs to make available to your code, along with an optional + ``memory_limit`` setting. If not provided, the service assumes auto. Is either a str type or a + AutoCodeInterpreterToolParam type. + :vartype container: str or ~azure.ai.projects.types.AutoCodeInterpreterToolParam + """ + + type: Required[Literal[ToolType.CODE_INTERPRETER]] + """The type of the code interpreter tool. Always ``code_interpreter``. Required. CODE_INTERPRETER.""" + container: Union[str, "AutoCodeInterpreterToolParam"] + """The code interpreter container. Can be a container ID or an object that specifies uploaded file + IDs to make available to your code, along with an optional ``memory_limit`` setting. If not + provided, the service assumes auto. Is either a str type or a AutoCodeInterpreterToolParam + type.""" + + +class ComparisonFilter(TypedDict, total=False): + """Comparison Filter. + + :ivar type: Specifies the comparison operator: ``eq``, ``ne``, ``gt``, ``gte``, ``lt``, + ``lte``, ``in``, ``nin``. + + * `eq`: equals + * `ne`: not equal + * `gt`: greater than + * `gte`: greater than or equal + * `lt`: less than + * `lte`: less than or equal + * `in`: in + * `nin`: not in. Required. Is one of the following types: Literal["eq"], Literal["ne"], + Literal["gt"], Literal["gte"], Literal["lt"], Literal["lte"] + :vartype type: str or str or str or str or str or str + :ivar key: The key to compare against the value. Required. + :vartype key: str + :ivar value: The value to compare against the attribute key; supports string, number, or + boolean types. Required. Is one of the following types: str, float, bool, [Union[str, float]] + :vartype value: str or float or bool or list[str or float] + """ + + type: Required[Literal["eq", "ne", "gt", "gte", "lt", "lte"]] + """Specifies the comparison operator: ``eq``, ``ne``, ``gt``, ``gte``, ``lt``, ``lte``, ``in``, + ``nin``. + + * `eq`: equals + * `ne`: not equal + * `gt`: greater than + * `gte`: greater than or equal + * `lt`: less than + * `lte`: less than or equal + * `in`: in + * `nin`: not in. Required. Is one of the following types: Literal[\"eq\"], + Literal[\"ne\"], Literal[\"gt\"], Literal[\"gte\"], Literal[\"lt\"], Literal[\"lte\"]""" + key: Required[str] + """The key to compare against the value. Required.""" + value: Required[Union[str, float, bool, list[Union[str, float]]]] + """The value to compare against the attribute key; supports string, number, or boolean types. + Required. Is one of the following types: str, float, bool, [Union[str, float]]""" + + +class CompoundFilter(TypedDict, total=False): + """Compound Filter. + + :ivar type: Type of operation: ``and`` or ``or``. Required. Is either a Literal["and"] type or + a Literal["or"] type. + :vartype type: str or str + :ivar filters: Array of filters to combine. Items can be ``ComparisonFilter`` or + ``CompoundFilter``. Required. + :vartype filters: list[~azure.ai.projects.types.ComparisonFilter or any] + """ + + type: Required[Literal["and", "or"]] + """Type of operation: ``and`` or ``or``. Required. Is either a Literal[\"and\"] type or a + Literal[\"or\"] type.""" + filters: Required[list[Union["ComparisonFilter", Any]]] + """Array of filters to combine. Items can be ``ComparisonFilter`` or ``CompoundFilter``. Required.""" + + +class ComputerUsePreviewTool(TypedDict, total=False): + """Computer use preview. + + :ivar type: The type of the computer use tool. Always ``computer_use_preview``. Required. + COMPUTER_USE_PREVIEW. + :vartype type: str or ~azure.ai.projects.models.COMPUTER_USE_PREVIEW + :ivar environment: The type of computer environment to control. Required. Known values are: + "windows", "mac", "linux", "ubuntu", and "browser". + :vartype environment: str or ~azure.ai.projects.models.ComputerEnvironment + :ivar display_width: The width of the computer display. Required. + :vartype display_width: int + :ivar display_height: The height of the computer display. Required. + :vartype display_height: int + """ + + type: Required[Literal[ToolType.COMPUTER_USE_PREVIEW]] + """The type of the computer use tool. Always ``computer_use_preview``. Required. + COMPUTER_USE_PREVIEW.""" + environment: Required[ComputerEnvironment] + """The type of computer environment to control. Required. Known values are: \"windows\", \"mac\", + \"linux\", \"ubuntu\", and \"browser\".""" + display_width: Required[int] + """The width of the computer display. Required.""" + display_height: Required[int] + """The height of the computer display. Required.""" + + +class Connection(TypedDict, total=False): + """Response from the list and get connections operations. + + :ivar name: The friendly name of the connection, provided by the user. Required. + :vartype name: str + :ivar id: A unique identifier for the connection, generated by the service. Required. + :vartype id: str + :ivar type: Category of the connection. Required. Known values are: "AzureOpenAI", "AzureBlob", + "AzureStorageAccount", "CognitiveSearch", "CosmosDB", "ApiKey", "AppConfig", "AppInsights", + "CustomKeys", and "RemoteTool_Preview". + :vartype type: str or ~azure.ai.projects.models.ConnectionType + :ivar target: The connection URL to be used for this service. Required. + :vartype target: str + :ivar is_default: Whether the connection is tagged as the default connection of its type. + Required. + :vartype is_default: bool + :ivar credentials: The credentials used by the connection. Required. + :vartype credentials: ~azure.ai.projects.types.BaseCredentials + :ivar metadata: Metadata of the connection. Required. + :vartype metadata: dict[str, str] + """ + + name: Required[str] + """The friendly name of the connection, provided by the user. Required.""" + id: Required[str] + """A unique identifier for the connection, generated by the service. Required.""" + type: Required[ConnectionType] + """Category of the connection. Required. Known values are: \"AzureOpenAI\", \"AzureBlob\", + \"AzureStorageAccount\", \"CognitiveSearch\", \"CosmosDB\", \"ApiKey\", \"AppConfig\", + \"AppInsights\", \"CustomKeys\", and \"RemoteTool_Preview\".""" + target: Required[str] + """The connection URL to be used for this service. Required.""" + isDefault: Required[bool] + """Whether the connection is tagged as the default connection of its type. Required.""" + credentials: Required["BaseCredentials"] + """The credentials used by the connection. Required.""" + metadata: Required[dict[str, str]] + """Metadata of the connection. Required.""" + + +class ContainerAutoParam(TypedDict, total=False): + """ContainerAutoParam. + + :ivar type: Automatically creates a container for this request. Required. CONTAINER_AUTO. + :vartype type: str or ~azure.ai.projects.models.CONTAINER_AUTO + :ivar file_ids: An optional list of uploaded files to make available to your code. + :vartype file_ids: list[str] + :ivar memory_limit: Known values are: "1g", "4g", "16g", and "64g". + :vartype memory_limit: str or ~azure.ai.projects.models.ContainerMemoryLimit + :ivar skills: An optional list of skills referenced by id or inline data. + :vartype skills: list[~azure.ai.projects.types.ContainerSkill] + :ivar network_policy: + :vartype network_policy: ~azure.ai.projects.types.ContainerNetworkPolicyParam + """ + + type: Required[Literal[FunctionShellToolParamEnvironmentType.CONTAINER_AUTO]] + """Automatically creates a container for this request. Required. CONTAINER_AUTO.""" + file_ids: list[str] + """An optional list of uploaded files to make available to your code.""" + memory_limit: Optional[ContainerMemoryLimit] + """Known values are: \"1g\", \"4g\", \"16g\", and \"64g\".""" + skills: list["ContainerSkill"] + """An optional list of skills referenced by id or inline data.""" + network_policy: "ContainerNetworkPolicyParam" + + +class ContainerNetworkPolicyAllowlistParam(TypedDict, total=False): + """ContainerNetworkPolicyAllowlistParam. + + :ivar type: Allow outbound network access only to specified domains. Always ``allowlist``. + Required. ALLOWLIST. + :vartype type: str or ~azure.ai.projects.models.ALLOWLIST + :ivar allowed_domains: A list of allowed domains when type is ``allowlist``. Required. + :vartype allowed_domains: list[str] + :ivar domain_secrets: Optional domain-scoped secrets for allowlisted domains. + :vartype domain_secrets: list[~azure.ai.projects.types.ContainerNetworkPolicyDomainSecretParam] + """ + + type: Required[Literal[ContainerNetworkPolicyParamType.ALLOWLIST]] + """Allow outbound network access only to specified domains. Always ``allowlist``. Required. + ALLOWLIST.""" + allowed_domains: Required[list[str]] + """A list of allowed domains when type is ``allowlist``. Required.""" + domain_secrets: list["ContainerNetworkPolicyDomainSecretParam"] + """Optional domain-scoped secrets for allowlisted domains.""" + + +class ContainerNetworkPolicyDisabledParam(TypedDict, total=False): + """ContainerNetworkPolicyDisabledParam. + + :ivar type: Disable outbound network access. Always ``disabled``. Required. DISABLED. + :vartype type: str or ~azure.ai.projects.models.DISABLED + """ + + type: Required[Literal[ContainerNetworkPolicyParamType.DISABLED]] + """Disable outbound network access. Always ``disabled``. Required. DISABLED.""" + + +class ContainerNetworkPolicyDomainSecretParam(TypedDict, total=False): + """ContainerNetworkPolicyDomainSecretParam. + + :ivar domain: The domain associated with the secret. Required. + :vartype domain: str + :ivar name: The name of the secret to inject for the domain. Required. + :vartype name: str + :ivar value: The secret value to inject for the domain. Required. + :vartype value: str + """ + + domain: Required[str] + """The domain associated with the secret. Required.""" + name: Required[str] + """The name of the secret to inject for the domain. Required.""" + value: Required[str] + """The secret value to inject for the domain. Required.""" + + +class ContinuousEvaluationRuleAction(TypedDict, total=False): + """Evaluation rule action for continuous evaluation. + + :ivar type: Required. Continuous evaluation. + :vartype type: str or ~azure.ai.projects.models.CONTINUOUS_EVALUATION + :ivar eval_id: Eval Id to add continuous evaluation runs to. Required. + :vartype eval_id: str + :ivar max_hourly_runs: Maximum number of evaluation runs allowed per hour. + :vartype max_hourly_runs: int + """ + + type: Required[Literal[EvaluationRuleActionType.CONTINUOUS_EVALUATION]] + """Required. Continuous evaluation.""" + evalId: Required[str] + """Eval Id to add continuous evaluation runs to. Required.""" + maxHourlyRuns: int + """Maximum number of evaluation runs allowed per hour.""" + + +class CosmosDBIndex(TypedDict, total=False): + """CosmosDB Vector Store Index Definition. + + :ivar id: Asset ID, a unique identifier for the asset. + :vartype id: str + :ivar name: The name of the resource. Required. + :vartype name: str + :ivar version: The version of the resource. Required. + :vartype version: str + :ivar description: The asset description text. + :vartype description: str + :ivar tags: Tag dictionary. Tags can be added, removed, and updated. + :vartype tags: dict[str, str] + :ivar type: Type of index. Required. CosmosDB. + :vartype type: str or ~azure.ai.projects.models.COSMOS_DB + :ivar connection_name: Name of connection to CosmosDB. Required. + :vartype connection_name: str + :ivar database_name: Name of the CosmosDB Database. Required. + :vartype database_name: str + :ivar container_name: Name of CosmosDB Container. Required. + :vartype container_name: str + :ivar embedding_configuration: Embedding model configuration. Required. + :vartype embedding_configuration: ~azure.ai.projects.types.EmbeddingConfiguration + :ivar field_mapping: Field mapping configuration. Required. + :vartype field_mapping: ~azure.ai.projects.types.FieldMapping + """ + + id: str + """Asset ID, a unique identifier for the asset.""" + name: Required[str] + """The name of the resource. Required.""" + version: Required[str] + """The version of the resource. Required.""" + description: str + """The asset description text.""" + tags: dict[str, str] + """Tag dictionary. Tags can be added, removed, and updated.""" + type: Required[Literal[IndexType.COSMOS_DB]] + """Type of index. Required. CosmosDB.""" + connectionName: Required[str] + """Name of connection to CosmosDB. Required.""" + databaseName: Required[str] + """Name of the CosmosDB Database. Required.""" + containerName: Required[str] + """Name of CosmosDB Container. Required.""" + embeddingConfiguration: Required["EmbeddingConfiguration"] + """Embedding model configuration. Required.""" + fieldMapping: Required["FieldMapping"] + """Field mapping configuration. Required.""" + + +class CronTrigger(TypedDict, total=False): + """Cron based trigger. + + :ivar type: Required. Cron based trigger. + :vartype type: str or ~azure.ai.projects.models.CRON + :ivar expression: Cron expression that defines the schedule frequency. Required. + :vartype expression: str + :ivar time_zone: Time zone for the cron schedule. + :vartype time_zone: str + :ivar start_time: Start time for the cron schedule in ISO 8601 format. + :vartype start_time: ~datetime.datetime + :ivar end_time: End time for the cron schedule in ISO 8601 format. + :vartype end_time: ~datetime.datetime + """ + + type: Required[Literal[TriggerType.CRON]] + """Required. Cron based trigger.""" + expression: Required[str] + """Cron expression that defines the schedule frequency. Required.""" + timeZone: str + """Time zone for the cron schedule.""" + startTime: str + """Start time for the cron schedule in ISO 8601 format.""" + endTime: str + """End time for the cron schedule in ISO 8601 format.""" + + +class CustomCredential(TypedDict, total=False): + """Custom credential definition. + + :ivar type: The credential type. Required. Custom credential. + :vartype type: str or ~azure.ai.projects.models.CUSTOM + """ + + type: Required[Literal[CredentialType.CUSTOM]] + """The credential type. Required. Custom credential.""" + + +class CustomGrammarFormatParam(TypedDict, total=False): + """Grammar format. + + :ivar type: Grammar format. Always ``grammar``. Required. GRAMMAR. + :vartype type: str or ~azure.ai.projects.models.GRAMMAR + :ivar syntax: The syntax of the grammar definition. One of ``lark`` or ``regex``. Required. + Known values are: "lark" and "regex". + :vartype syntax: str or ~azure.ai.projects.models.GrammarSyntax1 + :ivar definition: The grammar definition. Required. + :vartype definition: str + """ + + type: Required[Literal[CustomToolParamFormatType.GRAMMAR]] + """Grammar format. Always ``grammar``. Required. GRAMMAR.""" + syntax: Required[GrammarSyntax1] + """The syntax of the grammar definition. One of ``lark`` or ``regex``. Required. Known values are: + \"lark\" and \"regex\".""" + definition: Required[str] + """The grammar definition. Required.""" + + +class CustomTextFormatParam(TypedDict, total=False): + """Text format. + + :ivar type: Unconstrained text format. Always ``text``. Required. TEXT. + :vartype type: str or ~azure.ai.projects.models.TEXT + """ + + type: Required[Literal[CustomToolParamFormatType.TEXT]] + """Unconstrained text format. Always ``text``. Required. TEXT.""" + + +class CustomToolParam(TypedDict, total=False): + """Custom tool. + + :ivar type: The type of the custom tool. Always ``custom``. Required. CUSTOM. + :vartype type: str or ~azure.ai.projects.models.CUSTOM + :ivar name: The name of the custom tool, used to identify it in tool calls. Required. + :vartype name: str + :ivar description: Optional description of the custom tool, used to provide more context. + :vartype description: str + :ivar format: The input format for the custom tool. Default is unconstrained text. + :vartype format: ~azure.ai.projects.types.CustomToolParamFormat + """ + + type: Required[Literal[ToolType.CUSTOM]] + """The type of the custom tool. Always ``custom``. Required. CUSTOM.""" + name: Required[str] + """The name of the custom tool, used to identify it in tool calls. Required.""" + description: str + """Optional description of the custom tool, used to provide more context.""" + format: "CustomToolParamFormat" + """The input format for the custom tool. Default is unconstrained text.""" + + +class DailyRecurrenceSchedule(TypedDict, total=False): + """Daily recurrence schedule. + + :ivar type: Daily recurrence type. Required. Daily recurrence pattern. + :vartype type: str or ~azure.ai.projects.models.DAILY + :ivar hours: Hours for the recurrence schedule. Required. + :vartype hours: list[int] + """ + + type: Required[Literal[RecurrenceType.DAILY]] + """Daily recurrence type. Required. Daily recurrence pattern.""" + hours: Required[list[int]] + """Hours for the recurrence schedule. Required.""" + + +class DatasetCredential(TypedDict, total=False): + """Represents a reference to a blob for consumption. + + :ivar blob_reference: Credential info to access the storage account. Required. + :vartype blob_reference: ~azure.ai.projects.types.BlobReference + """ + + blobReference: Required["BlobReference"] + """Credential info to access the storage account. Required.""" + + +class DeleteAgentResponse(TypedDict, total=False): + """A deleted agent Object. + + :ivar object: The object type. Always 'agent.deleted'. Required. AGENT_DELETED. + :vartype object: str or ~azure.ai.projects.models.AGENT_DELETED + :ivar name: The name of the agent. Required. + :vartype name: str + :ivar deleted: Whether the agent was successfully deleted. Required. + :vartype deleted: bool + """ + + object: Required[Literal[AgentObjectType.AGENT_DELETED]] + """The object type. Always 'agent.deleted'. Required. AGENT_DELETED.""" + name: Required[str] + """The name of the agent. Required.""" + deleted: Required[bool] + """Whether the agent was successfully deleted. Required.""" + + +class DeleteAgentVersionResponse(TypedDict, total=False): + """A deleted agent version Object. + + :ivar object: The object type. Always 'agent.version.deleted'. Required. AGENT_VERSION_DELETED. + :vartype object: str or ~azure.ai.projects.models.AGENT_VERSION_DELETED + :ivar name: The name of the agent. Required. + :vartype name: str + :ivar version: The version identifier of the agent. Required. + :vartype version: str + :ivar deleted: Whether the agent was successfully deleted. Required. + :vartype deleted: bool + """ + + object: Required[Literal[AgentObjectType.AGENT_VERSION_DELETED]] + """The object type. Always 'agent.version.deleted'. Required. AGENT_VERSION_DELETED.""" + name: Required[str] + """The name of the agent. Required.""" + version: Required[str] + """The version identifier of the agent. Required.""" + deleted: Required[bool] + """Whether the agent was successfully deleted. Required.""" + + +class DeleteMemoryStoreResult(TypedDict, total=False): + """DeleteMemoryStoreResult. + + :ivar object: The object type. Always 'memory_store.deleted'. Required. MEMORY_STORE_DELETED. + :vartype object: str or ~azure.ai.projects.models.MEMORY_STORE_DELETED + :ivar name: The name of the memory store. Required. + :vartype name: str + :ivar deleted: Whether the memory store was successfully deleted. Required. + :vartype deleted: bool + """ + + object: Required[Literal[MemoryStoreObjectType.MEMORY_STORE_DELETED]] + """The object type. Always 'memory_store.deleted'. Required. MEMORY_STORE_DELETED.""" + name: Required[str] + """The name of the memory store. Required.""" + deleted: Required[bool] + """Whether the memory store was successfully deleted. Required.""" + + +class EmbeddingConfiguration(TypedDict, total=False): + """Embedding configuration class. + + :ivar model_deployment_name: Deployment name of embedding model. It can point to a model + deployment either in the parent AIServices or a connection. Required. + :vartype model_deployment_name: str + :ivar embedding_field: Embedding field. Required. + :vartype embedding_field: str + """ + + modelDeploymentName: Required[str] + """Deployment name of embedding model. It can point to a model deployment either in the parent + AIServices or a connection. Required.""" + embeddingField: Required[str] + """Embedding field. Required.""" + + +class EntraIDCredentials(TypedDict, total=False): + """Entra ID credential definition. + + :ivar type: The credential type. Required. Entra ID credential (formerly known as AAD). + :vartype type: str or ~azure.ai.projects.models.ENTRA_ID + """ + + type: Required[Literal[CredentialType.ENTRA_ID]] + """The credential type. Required. Entra ID credential (formerly known as AAD).""" + + +class EvalResult(TypedDict, total=False): + """Result of the evaluation. + + :ivar name: name of the check. Required. + :vartype name: str + :ivar type: type of the check. Required. + :vartype type: str + :ivar score: score. Required. + :vartype score: float + :ivar passed: indicates if the check passed or failed. Required. + :vartype passed: bool + """ + + name: Required[str] + """name of the check. Required.""" + type: Required[str] + """type of the check. Required.""" + score: Required[float] + """score. Required.""" + passed: Required[bool] + """indicates if the check passed or failed. Required.""" + + +class EvalRunResultCompareItem(TypedDict, total=False): + """Metric comparison for a treatment against the baseline. + + :ivar treatment_run_id: The treatment run ID. Required. + :vartype treatment_run_id: str + :ivar treatment_run_summary: Summary statistics of the treatment run. Required. + :vartype treatment_run_summary: ~azure.ai.projects.types.EvalRunResultSummary + :ivar delta_estimate: Estimated difference between treatment and baseline. Required. + :vartype delta_estimate: float + :ivar p_value: P-value for the treatment effect. Required. + :vartype p_value: float + :ivar treatment_effect: Type of treatment effect. Required. Known values are: "TooFewSamples", + "Inconclusive", "Changed", "Improved", and "Degraded". + :vartype treatment_effect: str or ~azure.ai.projects.models.TreatmentEffectType + """ + + treatmentRunId: Required[str] + """The treatment run ID. Required.""" + treatmentRunSummary: Required["EvalRunResultSummary"] + """Summary statistics of the treatment run. Required.""" + deltaEstimate: Required[float] + """Estimated difference between treatment and baseline. Required.""" + pValue: Required[float] + """P-value for the treatment effect. Required.""" + treatmentEffect: Required[TreatmentEffectType] + """Type of treatment effect. Required. Known values are: \"TooFewSamples\", \"Inconclusive\", + \"Changed\", \"Improved\", and \"Degraded\".""" + + +class EvalRunResultComparison(TypedDict, total=False): + """Comparison results for treatment runs against the baseline. + + :ivar testing_criteria: Name of the testing criteria. Required. + :vartype testing_criteria: str + :ivar metric: Metric being evaluated. Required. + :vartype metric: str + :ivar evaluator: Name of the evaluator for this testing criteria. Required. + :vartype evaluator: str + :ivar baseline_run_summary: Summary statistics of the baseline run. Required. + :vartype baseline_run_summary: ~azure.ai.projects.types.EvalRunResultSummary + :ivar compare_items: List of comparison results for each treatment run. Required. + :vartype compare_items: list[~azure.ai.projects.types.EvalRunResultCompareItem] + """ + + testingCriteria: Required[str] + """Name of the testing criteria. Required.""" + metric: Required[str] + """Metric being evaluated. Required.""" + evaluator: Required[str] + """Name of the evaluator for this testing criteria. Required.""" + baselineRunSummary: Required["EvalRunResultSummary"] + """Summary statistics of the baseline run. Required.""" + compareItems: Required[list["EvalRunResultCompareItem"]] + """List of comparison results for each treatment run. Required.""" + + +class EvalRunResultSummary(TypedDict, total=False): + """Summary statistics of a metric in an evaluation run. + + :ivar run_id: The evaluation run ID. Required. + :vartype run_id: str + :ivar sample_count: Number of samples in the evaluation run. Required. + :vartype sample_count: int + :ivar average: Average value of the metric in the evaluation run. Required. + :vartype average: float + :ivar standard_deviation: Standard deviation of the metric in the evaluation run. Required. + :vartype standard_deviation: float + """ + + runId: Required[str] + """The evaluation run ID. Required.""" + sampleCount: Required[int] + """Number of samples in the evaluation run. Required.""" + average: Required[float] + """Average value of the metric in the evaluation run. Required.""" + standardDeviation: Required[float] + """Standard deviation of the metric in the evaluation run. Required.""" + + +class EvaluationComparisonInsightRequest(TypedDict, total=False): + """Evaluation Comparison Request. + + :ivar type: The type of request. Required. Evaluation Comparison. + :vartype type: str or ~azure.ai.projects.models.EVALUATION_COMPARISON + :ivar eval_id: Identifier for the evaluation. Required. + :vartype eval_id: str + :ivar baseline_run_id: The baseline run ID for comparison. Required. + :vartype baseline_run_id: str + :ivar treatment_run_ids: List of treatment run IDs for comparison. Required. + :vartype treatment_run_ids: list[str] + """ + + type: Required[Literal[InsightType.EVALUATION_COMPARISON]] + """The type of request. Required. Evaluation Comparison.""" + evalId: Required[str] + """Identifier for the evaluation. Required.""" + baselineRunId: Required[str] + """The baseline run ID for comparison. Required.""" + treatmentRunIds: Required[list[str]] + """List of treatment run IDs for comparison. Required.""" + + +class EvaluationComparisonInsightResult(TypedDict, total=False): + """Insights from the evaluation comparison. + + :ivar type: The type of insights result. Required. Evaluation Comparison. + :vartype type: str or ~azure.ai.projects.models.EVALUATION_COMPARISON + :ivar comparisons: Comparison results for each treatment run against the baseline. Required. + :vartype comparisons: list[~azure.ai.projects.types.EvalRunResultComparison] + :ivar method: The statistical method used for comparison. Required. + :vartype method: str + """ + + type: Required[Literal[InsightType.EVALUATION_COMPARISON]] + """The type of insights result. Required. Evaluation Comparison.""" + comparisons: Required[list["EvalRunResultComparison"]] + """Comparison results for each treatment run against the baseline. Required.""" + method: Required[str] + """The statistical method used for comparison. Required.""" + + +class EvaluationResultSample(TypedDict, total=False): + """A sample from the evaluation result. + + :ivar id: The unique identifier for the analysis sample. Required. + :vartype id: str + :ivar features: Features to help with additional filtering of data in UX. Required. + :vartype features: dict[str, any] + :ivar correlation_info: Info about the correlation for the analysis sample. Required. + :vartype correlation_info: dict[str, any] + :ivar type: Evaluation Result Sample Type. Required. A sample from the evaluation result. + :vartype type: str or ~azure.ai.projects.models.EVALUATION_RESULT_SAMPLE + :ivar evaluation_result: Evaluation result for the analysis sample. Required. + :vartype evaluation_result: ~azure.ai.projects.types.EvalResult + """ + + id: Required[str] + """The unique identifier for the analysis sample. Required.""" + features: Required[dict[str, Any]] + """Features to help with additional filtering of data in UX. Required.""" + correlationInfo: Required[dict[str, Any]] + """Info about the correlation for the analysis sample. Required.""" + type: Required[Literal[SampleType.EVALUATION_RESULT_SAMPLE]] + """Evaluation Result Sample Type. Required. A sample from the evaluation result.""" + evaluationResult: Required["EvalResult"] + """Evaluation result for the analysis sample. Required.""" + + +class EvaluationRule(TypedDict, total=False): + """Evaluation rule model. + + :ivar id: Unique identifier for the evaluation rule. Required. + :vartype id: str + :ivar display_name: Display Name for the evaluation rule. + :vartype display_name: str + :ivar description: Description for the evaluation rule. + :vartype description: str + :ivar action: Definition of the evaluation rule action. Required. + :vartype action: ~azure.ai.projects.types.EvaluationRuleAction + :ivar filter: Filter condition of the evaluation rule. + :vartype filter: ~azure.ai.projects.types.EvaluationRuleFilter + :ivar event_type: Event type that the evaluation rule applies to. Required. Known values are: + "responseCompleted" and "manual". + :vartype event_type: str or ~azure.ai.projects.models.EvaluationRuleEventType + :ivar enabled: Indicates whether the evaluation rule is enabled. Default is true. Required. + :vartype enabled: bool + :ivar system_data: System metadata for the evaluation rule. Required. + :vartype system_data: dict[str, str] + """ + + id: Required[str] + """Unique identifier for the evaluation rule. Required.""" + displayName: str + """Display Name for the evaluation rule.""" + description: str + """Description for the evaluation rule.""" + action: Required["EvaluationRuleAction"] + """Definition of the evaluation rule action. Required.""" + filter: "EvaluationRuleFilter" + """Filter condition of the evaluation rule.""" + eventType: Required[EvaluationRuleEventType] + """Event type that the evaluation rule applies to. Required. Known values are: + \"responseCompleted\" and \"manual\".""" + enabled: Required[bool] + """Indicates whether the evaluation rule is enabled. Default is true. Required.""" + systemData: Required[dict[str, str]] + """System metadata for the evaluation rule. Required.""" + + +class EvaluationRuleFilter(TypedDict, total=False): + """Evaluation filter model. + + :ivar agent_name: Filter by agent name. Required. + :vartype agent_name: str + """ + + agentName: Required[str] + """Filter by agent name. Required.""" + + +class EvaluationRunClusterInsightRequest(TypedDict, total=False): + """Insights on set of Evaluation Results. + + :ivar type: The type of insights request. Required. Insights on an Evaluation run result. + :vartype type: str or ~azure.ai.projects.models.EVALUATION_RUN_CLUSTER_INSIGHT + :ivar eval_id: Evaluation Id for the insights. Required. + :vartype eval_id: str + :ivar run_ids: List of evaluation run IDs for the insights. Required. + :vartype run_ids: list[str] + :ivar model_configuration: Configuration of the model used in the insight generation. + :vartype model_configuration: ~azure.ai.projects.types.InsightModelConfiguration + """ + + type: Required[Literal[InsightType.EVALUATION_RUN_CLUSTER_INSIGHT]] + """The type of insights request. Required. Insights on an Evaluation run result.""" + evalId: Required[str] + """Evaluation Id for the insights. Required.""" + runIds: Required[list[str]] + """List of evaluation run IDs for the insights. Required.""" + modelConfiguration: "InsightModelConfiguration" + """Configuration of the model used in the insight generation.""" + + +class EvaluationRunClusterInsightResult(TypedDict, total=False): + """Insights from the evaluation run cluster analysis. + + :ivar type: The type of insights result. Required. Insights on an Evaluation run result. + :vartype type: str or ~azure.ai.projects.models.EVALUATION_RUN_CLUSTER_INSIGHT + :ivar cluster_insight: Required. + :vartype cluster_insight: ~azure.ai.projects.types.ClusterInsightResult + """ + + type: Required[Literal[InsightType.EVALUATION_RUN_CLUSTER_INSIGHT]] + """The type of insights result. Required. Insights on an Evaluation run result.""" + clusterInsight: Required["ClusterInsightResult"] + """Required.""" + + +class EvaluationScheduleTask(TypedDict, total=False): + """Evaluation task for the schedule. + + :ivar configuration: Configuration for the task. + :vartype configuration: dict[str, str] + :ivar type: Required. Evaluation task. + :vartype type: str or ~azure.ai.projects.models.EVALUATION + :ivar eval_id: Identifier of the evaluation group. Required. + :vartype eval_id: str + :ivar eval_run: The evaluation run payload. Required. + :vartype eval_run: any + """ + + configuration: dict[str, str] + """Configuration for the task.""" + type: Required[Literal[ScheduleTaskType.EVALUATION]] + """Required. Evaluation task.""" + evalId: Required[str] + """Identifier of the evaluation group. Required.""" + evalRun: Required[Any] + """The evaluation run payload. Required.""" + + +class EvaluationTaxonomy(TypedDict, total=False): + """Evaluation Taxonomy Definition. + + :ivar id: Asset ID, a unique identifier for the asset. + :vartype id: str + :ivar name: The name of the resource. Required. + :vartype name: str + :ivar version: The version of the resource. Required. + :vartype version: str + :ivar description: The asset description text. + :vartype description: str + :ivar tags: Tag dictionary. Tags can be added, removed, and updated. + :vartype tags: dict[str, str] + :ivar taxonomy_input: Input configuration for the evaluation taxonomy. Required. + :vartype taxonomy_input: ~azure.ai.projects.types.EvaluationTaxonomyInput + :ivar taxonomy_categories: List of taxonomy categories. + :vartype taxonomy_categories: list[~azure.ai.projects.types.TaxonomyCategory] + :ivar properties: Additional properties for the evaluation taxonomy. + :vartype properties: dict[str, str] + """ + + id: str + """Asset ID, a unique identifier for the asset.""" + name: Required[str] + """The name of the resource. Required.""" + version: Required[str] + """The version of the resource. Required.""" + description: str + """The asset description text.""" + tags: dict[str, str] + """Tag dictionary. Tags can be added, removed, and updated.""" + taxonomyInput: Required["EvaluationTaxonomyInput"] + """Input configuration for the evaluation taxonomy. Required.""" + taxonomyCategories: list["TaxonomyCategory"] + """List of taxonomy categories.""" + properties: dict[str, str] + """Additional properties for the evaluation taxonomy.""" + + +class EvaluatorMetric(TypedDict, total=False): + """Evaluator Metric. + + :ivar type: Type of the metric. Known values are: "ordinal", "continuous", and "boolean". + :vartype type: str or ~azure.ai.projects.models.EvaluatorMetricType + :ivar desirable_direction: It indicates whether a higher value is better or a lower value is + better for this metric. Known values are: "increase", "decrease", and "neutral". + :vartype desirable_direction: str or ~azure.ai.projects.models.EvaluatorMetricDirection + :ivar min_value: Minimum value for the metric. + :vartype min_value: float + :ivar max_value: Maximum value for the metric. If not specified, it is assumed to be unbounded. + :vartype max_value: float + :ivar is_primary: Indicates if this metric is primary when there are multiple metrics. + :vartype is_primary: bool + """ + + type: EvaluatorMetricType + """Type of the metric. Known values are: \"ordinal\", \"continuous\", and \"boolean\".""" + desirable_direction: EvaluatorMetricDirection + """It indicates whether a higher value is better or a lower value is better for this metric. Known + values are: \"increase\", \"decrease\", and \"neutral\".""" + min_value: float + """Minimum value for the metric.""" + max_value: float + """Maximum value for the metric. If not specified, it is assumed to be unbounded.""" + is_primary: bool + """Indicates if this metric is primary when there are multiple metrics.""" + + +class EvaluatorVersion(TypedDict, total=False): + """Evaluator Definition. + + :ivar display_name: Display Name for evaluator. It helps to find the evaluator easily in AI + Foundry. It does not need to be unique. + :vartype display_name: str + :ivar metadata: Metadata about the evaluator. + :vartype metadata: dict[str, str] + :ivar evaluator_type: The type of the evaluator. Required. Known values are: "builtin" and + "custom". + :vartype evaluator_type: str or ~azure.ai.projects.models.EvaluatorType + :ivar categories: The categories of the evaluator. Required. + :vartype categories: list[str or ~azure.ai.projects.models.EvaluatorCategory] + :ivar definition: Definition of the evaluator. Required. + :vartype definition: ~azure.ai.projects.types.EvaluatorDefinition + :ivar created_by: Creator of the evaluator. Required. + :vartype created_by: str + :ivar created_at: Creation date/time of the evaluator. Required. + :vartype created_at: ~datetime.datetime + :ivar modified_at: Last modified date/time of the evaluator. Required. + :vartype modified_at: ~datetime.datetime + :ivar id: Asset ID, a unique identifier for the asset. + :vartype id: str + :ivar name: The name of the resource. Required. + :vartype name: str + :ivar version: The version of the resource. Required. + :vartype version: str + :ivar description: The asset description text. + :vartype description: str + :ivar tags: Tag dictionary. Tags can be added, removed, and updated. + :vartype tags: dict[str, str] + """ + + display_name: str + """Display Name for evaluator. It helps to find the evaluator easily in AI Foundry. It does not + need to be unique.""" + metadata: dict[str, str] + """Metadata about the evaluator.""" + evaluator_type: Required[EvaluatorType] + """The type of the evaluator. Required. Known values are: \"builtin\" and \"custom\".""" + categories: Required[list[EvaluatorCategory]] + """The categories of the evaluator. Required.""" + definition: Required["EvaluatorDefinition"] + """Definition of the evaluator. Required.""" + created_by: Required[str] + """Creator of the evaluator. Required.""" + created_at: Required[str] + """Creation date/time of the evaluator. Required.""" + modified_at: Required[str] + """Last modified date/time of the evaluator. Required.""" + id: str + """Asset ID, a unique identifier for the asset.""" + name: Required[str] + """The name of the resource. Required.""" + version: Required[str] + """The version of the resource. Required.""" + description: str + """The asset description text.""" + tags: dict[str, str] + """Tag dictionary. Tags can be added, removed, and updated.""" + + +class FabricDataAgentToolParameters(TypedDict, total=False): + """The fabric data agent tool parameters. + + :ivar project_connections: The project connections attached to this tool. There can be a + maximum of 1 connection resource attached to the tool. + :vartype project_connections: list[~azure.ai.projects.types.ToolProjectConnection] + """ + + project_connections: list["ToolProjectConnection"] + """The project connections attached to this tool. There can be a maximum of 1 connection resource + attached to the tool.""" + + +class FieldMapping(TypedDict, total=False): + """Field mapping configuration class. + + :ivar content_fields: List of fields with text content. Required. + :vartype content_fields: list[str] + :ivar filepath_field: Path of file to be used as a source of text content. + :vartype filepath_field: str + :ivar title_field: Field containing the title of the document. + :vartype title_field: str + :ivar url_field: Field containing the url of the document. + :vartype url_field: str + :ivar vector_fields: List of fields with vector content. + :vartype vector_fields: list[str] + :ivar metadata_fields: List of fields with metadata content. + :vartype metadata_fields: list[str] + """ + + contentFields: Required[list[str]] + """List of fields with text content. Required.""" + filepathField: str + """Path of file to be used as a source of text content.""" + titleField: str + """Field containing the title of the document.""" + urlField: str + """Field containing the url of the document.""" + vectorFields: list[str] + """List of fields with vector content.""" + metadataFields: list[str] + """List of fields with metadata content.""" + + +class FileDatasetVersion(TypedDict, total=False): + """FileDatasetVersion Definition. + + :ivar data_uri: URI of the data (`example `_). + Required. + :vartype data_uri: str + :ivar is_reference: Indicates if the dataset holds a reference to the storage, or the dataset + manages storage itself. If true, the underlying data will not be deleted when the dataset + version is deleted. + :vartype is_reference: bool + :ivar connection_name: The Azure Storage Account connection name. Required if + startPendingUploadVersion was not called before creating the Dataset. + :vartype connection_name: str + :ivar id: Asset ID, a unique identifier for the asset. + :vartype id: str + :ivar name: The name of the resource. Required. + :vartype name: str + :ivar version: The version of the resource. Required. + :vartype version: str + :ivar description: The asset description text. + :vartype description: str + :ivar tags: Tag dictionary. Tags can be added, removed, and updated. + :vartype tags: dict[str, str] + :ivar type: Dataset type. Required. URI file. + :vartype type: str or ~azure.ai.projects.models.URI_FILE + """ + + dataUri: Required[str] + """URI of the data (`example `_). Required.""" + isReference: bool + """Indicates if the dataset holds a reference to the storage, or the dataset manages storage + itself. If true, the underlying data will not be deleted when the dataset version is deleted.""" + connectionName: str + """The Azure Storage Account connection name. Required if startPendingUploadVersion was not called + before creating the Dataset.""" + id: str + """Asset ID, a unique identifier for the asset.""" + name: Required[str] + """The name of the resource. Required.""" + version: Required[str] + """The version of the resource. Required.""" + description: str + """The asset description text.""" + tags: dict[str, str] + """Tag dictionary. Tags can be added, removed, and updated.""" + type: Required[Literal[DatasetType.URI_FILE]] + """Dataset type. Required. URI file.""" + + +class FileSearchTool(TypedDict, total=False): + """File search. + + :ivar type: The type of the file search tool. Always ``file_search``. Required. FILE_SEARCH. + :vartype type: str or ~azure.ai.projects.models.FILE_SEARCH + :ivar vector_store_ids: The IDs of the vector stores to search. Required. + :vartype vector_store_ids: list[str] + :ivar max_num_results: The maximum number of results to return. This number should be between 1 + and 50 inclusive. + :vartype max_num_results: int + :ivar ranking_options: Ranking options for search. + :vartype ranking_options: ~azure.ai.projects.types.RankingOptions + :ivar filters: Is either a ComparisonFilter type or a CompoundFilter type. + :vartype filters: ~azure.ai.projects.types.ComparisonFilter or + ~azure.ai.projects.types.CompoundFilter + """ + + type: Required[Literal[ToolType.FILE_SEARCH]] + """The type of the file search tool. Always ``file_search``. Required. FILE_SEARCH.""" + vector_store_ids: Required[list[str]] + """The IDs of the vector stores to search. Required.""" + max_num_results: int + """The maximum number of results to return. This number should be between 1 and 50 inclusive.""" + ranking_options: "RankingOptions" + """Ranking options for search.""" + filters: Optional["_unions.Filters"] + """Is either a ComparisonFilter type or a CompoundFilter type.""" + + +class FolderDatasetVersion(TypedDict, total=False): + """FileDatasetVersion Definition. + + :ivar data_uri: URI of the data (`example `_). + Required. + :vartype data_uri: str + :ivar is_reference: Indicates if the dataset holds a reference to the storage, or the dataset + manages storage itself. If true, the underlying data will not be deleted when the dataset + version is deleted. + :vartype is_reference: bool + :ivar connection_name: The Azure Storage Account connection name. Required if + startPendingUploadVersion was not called before creating the Dataset. + :vartype connection_name: str + :ivar id: Asset ID, a unique identifier for the asset. + :vartype id: str + :ivar name: The name of the resource. Required. + :vartype name: str + :ivar version: The version of the resource. Required. + :vartype version: str + :ivar description: The asset description text. + :vartype description: str + :ivar tags: Tag dictionary. Tags can be added, removed, and updated. + :vartype tags: dict[str, str] + :ivar type: Dataset type. Required. URI folder. + :vartype type: str or ~azure.ai.projects.models.URI_FOLDER + """ + + dataUri: Required[str] + """URI of the data (`example `_). Required.""" + isReference: bool + """Indicates if the dataset holds a reference to the storage, or the dataset manages storage + itself. If true, the underlying data will not be deleted when the dataset version is deleted.""" + connectionName: str + """The Azure Storage Account connection name. Required if startPendingUploadVersion was not called + before creating the Dataset.""" + id: str + """Asset ID, a unique identifier for the asset.""" + name: Required[str] + """The name of the resource. Required.""" + version: Required[str] + """The version of the resource. Required.""" + description: str + """The asset description text.""" + tags: dict[str, str] + """Tag dictionary. Tags can be added, removed, and updated.""" + type: Required[Literal[DatasetType.URI_FOLDER]] + """Dataset type. Required. URI folder.""" + + +class FunctionShellToolParam(TypedDict, total=False): + """Shell tool. + + :ivar type: The type of the shell tool. Always ``shell``. Required. SHELL. + :vartype type: str or ~azure.ai.projects.models.SHELL + :ivar environment: + :vartype environment: ~azure.ai.projects.types.FunctionShellToolParamEnvironment + """ + + type: Required[Literal[ToolType.SHELL]] + """The type of the shell tool. Always ``shell``. Required. SHELL.""" + environment: Optional["FunctionShellToolParamEnvironment"] + + +class FunctionShellToolParamEnvironmentContainerReferenceParam(TypedDict, total=False): # pylint: disable=name-too-long + """FunctionShellToolParamEnvironmentContainerReferenceParam. + + :ivar type: References a container created with the /v1/containers endpoint. Required. + CONTAINER_REFERENCE. + :vartype type: str or ~azure.ai.projects.models.CONTAINER_REFERENCE + :ivar container_id: The ID of the referenced container. Required. + :vartype container_id: str + """ + + type: Required[Literal[FunctionShellToolParamEnvironmentType.CONTAINER_REFERENCE]] + """References a container created with the /v1/containers endpoint. Required. CONTAINER_REFERENCE.""" + container_id: Required[str] + """The ID of the referenced container. Required.""" + + +class FunctionShellToolParamEnvironmentLocalEnvironmentParam(TypedDict, total=False): # pylint: disable=name-too-long + """FunctionShellToolParamEnvironmentLocalEnvironmentParam. + + :ivar type: Use a local computer environment. Required. LOCAL. + :vartype type: str or ~azure.ai.projects.models.LOCAL + :ivar skills: An optional list of skills. + :vartype skills: list[~azure.ai.projects.types.LocalSkillParam] + """ + + type: Required[Literal[FunctionShellToolParamEnvironmentType.LOCAL]] + """Use a local computer environment. Required. LOCAL.""" + skills: list["LocalSkillParam"] + """An optional list of skills.""" + + +class FunctionTool(TypedDict, total=False): + """Function. + + :ivar type: The type of the function tool. Always ``function``. Required. FUNCTION. + :vartype type: str or ~azure.ai.projects.models.FUNCTION + :ivar name: The name of the function to call. Required. + :vartype name: str + :ivar description: + :vartype description: str + :ivar parameters: Required. + :vartype parameters: dict[str, any] + :ivar strict: Required. + :vartype strict: bool + """ + + type: Required[Literal[ToolType.FUNCTION]] + """The type of the function tool. Always ``function``. Required. FUNCTION.""" + name: Required[str] + """The name of the function to call. Required.""" + description: Optional[str] + parameters: Required[Optional[dict[str, Any]]] + """Required.""" + strict: Required[Optional[bool]] + """Required.""" + + +class HostedAgentDefinition(TypedDict, total=False): + """The hosted agent definition. + + :ivar rai_config: Configuration for Responsible AI (RAI) content filtering and safety features. + :vartype rai_config: ~azure.ai.projects.types.RaiConfig + :ivar kind: Required. HOSTED. + :vartype kind: str or ~azure.ai.projects.models.HOSTED + :ivar tools: An array of tools the hosted agent's model may call while generating a response. + You can specify which tool to use by setting the ``tool_choice`` parameter. + :vartype tools: list[~azure.ai.projects.types.Tool] + :ivar container_protocol_versions: The protocols that the agent supports for ingress + communication of the containers. Required. + :vartype container_protocol_versions: list[~azure.ai.projects.types.ProtocolVersionRecord] + :ivar cpu: The CPU configuration for the hosted agent. Required. + :vartype cpu: str + :ivar memory: The memory configuration for the hosted agent. Required. + :vartype memory: str + :ivar environment_variables: Environment variables to set in the hosted agent container. + :vartype environment_variables: dict[str, str] + :ivar image: The image ID for the agent, applicable to image-based hosted agents. + :vartype image: str + """ + + rai_config: "RaiConfig" + """Configuration for Responsible AI (RAI) content filtering and safety features.""" + kind: Required[Literal[AgentKind.HOSTED]] + """Required. HOSTED.""" + tools: list["Tool"] + """An array of tools the hosted agent's model may call while generating a response. You can + specify which tool to use by setting the ``tool_choice`` parameter.""" + container_protocol_versions: Required[list["ProtocolVersionRecord"]] + """The protocols that the agent supports for ingress communication of the containers. Required.""" + cpu: Required[str] + """The CPU configuration for the hosted agent. Required.""" + memory: Required[str] + """The memory configuration for the hosted agent. Required.""" + environment_variables: dict[str, str] + """Environment variables to set in the hosted agent container.""" + image: str + """The image ID for the agent, applicable to image-based hosted agents.""" + + +class HourlyRecurrenceSchedule(TypedDict, total=False): + """Hourly recurrence schedule. + + :ivar type: Required. Hourly recurrence pattern. + :vartype type: str or ~azure.ai.projects.models.HOURLY + """ + + type: Required[Literal[RecurrenceType.HOURLY]] + """Required. Hourly recurrence pattern.""" + + +class HumanEvaluationPreviewRuleAction(TypedDict, total=False): + """Evaluation rule action for human evaluation. + + :ivar type: Required. Human evaluation preview. + :vartype type: str or ~azure.ai.projects.models.HUMAN_EVALUATION_PREVIEW + :ivar template_id: Human evaluation template Id. Required. + :vartype template_id: str + """ + + type: Required[Literal[EvaluationRuleActionType.HUMAN_EVALUATION_PREVIEW]] + """Required. Human evaluation preview.""" + templateId: Required[str] + """Human evaluation template Id. Required.""" + + +class HybridSearchOptions(TypedDict, total=False): + """HybridSearchOptions. + + :ivar embedding_weight: The weight of the embedding in the reciprocal ranking fusion. Required. + :vartype embedding_weight: float + :ivar text_weight: The weight of the text in the reciprocal ranking fusion. Required. + :vartype text_weight: float + """ + + embedding_weight: Required[float] + """The weight of the embedding in the reciprocal ranking fusion. Required.""" + text_weight: Required[float] + """The weight of the text in the reciprocal ranking fusion. Required.""" + + +class ImageGenTool(TypedDict, total=False): + """Image generation tool. + + :ivar type: The type of the image generation tool. Always ``image_generation``. Required. + IMAGE_GENERATION. + :vartype type: str or ~azure.ai.projects.models.IMAGE_GENERATION + :ivar model: Is one of the following types: Literal["gpt-image-1"], + Literal["gpt-image-1-mini"], Literal["gpt-image-1.5"], str + :vartype model: str or str or str or str + :ivar quality: The quality of the generated image. One of ``low``, ``medium``, ``high``, or + ``auto``. Default: ``auto``. Is one of the following types: Literal["low"], Literal["medium"], + Literal["high"], Literal["auto"] + :vartype quality: str or str or str or str + :ivar size: The size of the generated image. One of ``1024x1024``, ``1024x1536``, + ``1536x1024``, or ``auto``. Default: ``auto``. Is one of the following types: + Literal["1024x1024"], Literal["1024x1536"], Literal["1536x1024"], Literal["auto"] + :vartype size: str or str or str or str + :ivar output_format: The output format of the generated image. One of ``png``, ``webp``, or + ``jpeg``. Default: ``png``. Is one of the following types: Literal["png"], Literal["webp"], + Literal["jpeg"] + :vartype output_format: str or str or str + :ivar output_compression: Compression level for the output image. Default: 100. + :vartype output_compression: int + :ivar moderation: Moderation level for the generated image. Default: ``auto``. Is either a + Literal["auto"] type or a Literal["low"] type. + :vartype moderation: str or str + :ivar background: Background type for the generated image. One of ``transparent``, ``opaque``, + or ``auto``. Default: ``auto``. Is one of the following types: Literal["transparent"], + Literal["opaque"], Literal["auto"] + :vartype background: str or str or str + :ivar input_fidelity: Known values are: "high" and "low". + :vartype input_fidelity: str or ~azure.ai.projects.models.InputFidelity + :ivar input_image_mask: Optional mask for inpainting. Contains ``image_url`` (string, optional) + and ``file_id`` (string, optional). + :vartype input_image_mask: ~azure.ai.projects.types.ImageGenToolInputImageMask + :ivar partial_images: Number of partial images to generate in streaming mode, from 0 (default + value) to 3. + :vartype partial_images: int + :ivar action: Whether to generate a new image or edit an existing image. Default: ``auto``. + Known values are: "generate", "edit", and "auto". + :vartype action: str or ~azure.ai.projects.models.ImageGenAction + """ + + type: Required[Literal[ToolType.IMAGE_GENERATION]] + """The type of the image generation tool. Always ``image_generation``. Required. IMAGE_GENERATION.""" + model: Union[Literal["gpt-image-1"], Literal["gpt-image-1-mini"], Literal["gpt-image-1.5"], str] + """Is one of the following types: Literal[\"gpt-image-1\"], Literal[\"gpt-image-1-mini\"], + Literal[\"gpt-image-1.5\"], str""" + quality: Literal["low", "medium", "high", "auto"] + """The quality of the generated image. One of ``low``, ``medium``, ``high``, or ``auto``. Default: + ``auto``. Is one of the following types: Literal[\"low\"], Literal[\"medium\"], + Literal[\"high\"], Literal[\"auto\"]""" + size: Literal["1024x1024", "1024x1536", "1536x1024", "auto"] + """The size of the generated image. One of ``1024x1024``, ``1024x1536``, ``1536x1024``, or + ``auto``. Default: ``auto``. Is one of the following types: Literal[\"1024x1024\"], + Literal[\"1024x1536\"], Literal[\"1536x1024\"], Literal[\"auto\"]""" + output_format: Literal["png", "webp", "jpeg"] + """The output format of the generated image. One of ``png``, ``webp``, or ``jpeg``. Default: + ``png``. Is one of the following types: Literal[\"png\"], Literal[\"webp\"], Literal[\"jpeg\"]""" + output_compression: int + """Compression level for the output image. Default: 100.""" + moderation: Literal["auto", "low"] + """Moderation level for the generated image. Default: ``auto``. Is either a Literal[\"auto\"] type + or a Literal[\"low\"] type.""" + background: Literal["transparent", "opaque", "auto"] + """Background type for the generated image. One of ``transparent``, ``opaque``, or ``auto``. + Default: ``auto``. Is one of the following types: Literal[\"transparent\"], + Literal[\"opaque\"], Literal[\"auto\"]""" + input_fidelity: Optional[InputFidelity] + """Known values are: \"high\" and \"low\".""" + input_image_mask: "ImageGenToolInputImageMask" + """Optional mask for inpainting. Contains ``image_url`` (string, optional) and ``file_id`` + (string, optional).""" + partial_images: int + """Number of partial images to generate in streaming mode, from 0 (default value) to 3.""" + action: ImageGenAction + """Whether to generate a new image or edit an existing image. Default: ``auto``. Known values are: + \"generate\", \"edit\", and \"auto\".""" + + +class ImageGenToolInputImageMask(TypedDict, total=False): + """ImageGenToolInputImageMask. + + :ivar image_url: + :vartype image_url: str + :ivar file_id: + :vartype file_id: str + """ + + image_url: str + file_id: str + + +class InlineSkillParam(TypedDict, total=False): + """InlineSkillParam. + + :ivar type: Defines an inline skill for this request. Required. INLINE. + :vartype type: str or ~azure.ai.projects.models.INLINE + :ivar name: The name of the skill. Required. + :vartype name: str + :ivar description: The description of the skill. Required. + :vartype description: str + :ivar source: Inline skill payload. Required. + :vartype source: ~azure.ai.projects.types.InlineSkillSourceParam + """ + + type: Required[Literal[ContainerSkillType.INLINE]] + """Defines an inline skill for this request. Required. INLINE.""" + name: Required[str] + """The name of the skill. Required.""" + description: Required[str] + """The description of the skill. Required.""" + source: Required["InlineSkillSourceParam"] + """Inline skill payload. Required.""" + + +class InlineSkillSourceParam(TypedDict, total=False): + """Inline skill payload. + + :ivar type: The type of the inline skill source. Must be ``base64``. Required. Default value is + "base64". + :vartype type: str + :ivar media_type: The media type of the inline skill payload. Must be ``application/zip``. + Required. Default value is "application/zip". + :vartype media_type: str + :ivar data: Base64-encoded skill zip bundle. Required. + :vartype data: str + """ + + type: Required[Literal["base64"]] + """The type of the inline skill source. Must be ``base64``. Required. Default value is \"base64\".""" + media_type: Required[Literal["application/zip"]] + """The media type of the inline skill payload. Must be ``application/zip``. Required. Default + value is \"application/zip\".""" + data: Required[str] + """Base64-encoded skill zip bundle. Required.""" + + +class Insight(TypedDict, total=False): + """The response body for cluster insights. + + :ivar insight_id: The unique identifier for the insights report. Required. + :vartype insight_id: str + :ivar metadata: Metadata about the insights report. Required. + :vartype metadata: ~azure.ai.projects.types.InsightsMetadata + :ivar state: The current state of the insights. Required. Known values are: "NotStarted", + "Running", "Succeeded", "Failed", and "Canceled". + :vartype state: str or ~azure.ai.projects.models.OperationState + :ivar display_name: User friendly display name for the insight. Required. + :vartype display_name: str + :ivar request: Request for the insights analysis. Required. + :vartype request: ~azure.ai.projects.types.InsightRequest + :ivar result: The result of the insights report. + :vartype result: ~azure.ai.projects.types.InsightResult + """ + + id: Required[str] + """The unique identifier for the insights report. Required.""" + metadata: Required["InsightsMetadata"] + """Metadata about the insights report. Required.""" + state: Required[OperationState] + """The current state of the insights. Required. Known values are: \"NotStarted\", \"Running\", + \"Succeeded\", \"Failed\", and \"Canceled\".""" + displayName: Required[str] + """User friendly display name for the insight. Required.""" + request: Required["InsightRequest"] + """Request for the insights analysis. Required.""" + result: "InsightResult" + """The result of the insights report.""" + + +class InsightCluster(TypedDict, total=False): + """A cluster of analysis samples. + + :ivar id: The id of the analysis cluster. Required. + :vartype id: str + :ivar label: Label for the cluster. Required. + :vartype label: str + :ivar suggestion: Suggestion for the cluster. Required. + :vartype suggestion: str + :ivar suggestion_title: The title of the suggestion for the cluster. Required. + :vartype suggestion_title: str + :ivar description: Description of the analysis cluster. Required. + :vartype description: str + :ivar weight: The weight of the analysis cluster. This indicate number of samples in the + cluster. Required. + :vartype weight: int + :ivar sub_clusters: List of subclusters within this cluster. Empty if no subclusters exist. + :vartype sub_clusters: list[~azure.ai.projects.types.InsightCluster] + :ivar samples: List of samples that belong to this cluster. Empty if samples are part of + subclusters. + :vartype samples: list[~azure.ai.projects.types.InsightSample] + """ + + id: Required[str] + """The id of the analysis cluster. Required.""" + label: Required[str] + """Label for the cluster. Required.""" + suggestion: Required[str] + """Suggestion for the cluster. Required.""" + suggestionTitle: Required[str] + """The title of the suggestion for the cluster. Required.""" + description: Required[str] + """Description of the analysis cluster. Required.""" + weight: Required[int] + """The weight of the analysis cluster. This indicate number of samples in the cluster. Required.""" + subClusters: list["InsightCluster"] + """List of subclusters within this cluster. Empty if no subclusters exist.""" + samples: list["InsightSample"] + """List of samples that belong to this cluster. Empty if samples are part of subclusters.""" + + +class InsightModelConfiguration(TypedDict, total=False): + """Configuration of the model used in the insight generation. + + :ivar model_deployment_name: The model deployment to be evaluated. Accepts either the + deployment name alone or with the connection name as '{connectionName}/'. + Required. + :vartype model_deployment_name: str + """ + + modelDeploymentName: Required[str] + """The model deployment to be evaluated. Accepts either the deployment name alone or with the + connection name as '{connectionName}/'. Required.""" + + +class InsightScheduleTask(TypedDict, total=False): + """Insight task for the schedule. + + :ivar configuration: Configuration for the task. + :vartype configuration: dict[str, str] + :ivar type: Required. Insight task. + :vartype type: str or ~azure.ai.projects.models.INSIGHT + :ivar insight: The insight payload. Required. + :vartype insight: ~azure.ai.projects.types.Insight + """ + + configuration: dict[str, str] + """Configuration for the task.""" + type: Required[Literal[ScheduleTaskType.INSIGHT]] + """Required. Insight task.""" + insight: Required["Insight"] + """The insight payload. Required.""" + + +class InsightsMetadata(TypedDict, total=False): + """Metadata about the insights. + + :ivar created_at: The timestamp when the insights were created. Required. + :vartype created_at: ~datetime.datetime + :ivar completed_at: The timestamp when the insights were completed. + :vartype completed_at: ~datetime.datetime + """ + + createdAt: Required[str] + """The timestamp when the insights were created. Required.""" + completedAt: str + """The timestamp when the insights were completed.""" + + +class InsightSummary(TypedDict, total=False): + """Summary of the error cluster analysis. + + :ivar sample_count: Total number of samples analyzed. Required. + :vartype sample_count: int + :ivar unique_subcluster_count: Total number of unique subcluster labels. Required. + :vartype unique_subcluster_count: int + :ivar unique_cluster_count: Total number of unique clusters. Required. + :vartype unique_cluster_count: int + :ivar method: Method used for clustering. Required. + :vartype method: str + :ivar usage: Token usage while performing clustering analysis. Required. + :vartype usage: ~azure.ai.projects.types.ClusterTokenUsage + """ + + sampleCount: Required[int] + """Total number of samples analyzed. Required.""" + uniqueSubclusterCount: Required[int] + """Total number of unique subcluster labels. Required.""" + uniqueClusterCount: Required[int] + """Total number of unique clusters. Required.""" + method: Required[str] + """Method used for clustering. Required.""" + usage: Required["ClusterTokenUsage"] + """Token usage while performing clustering analysis. Required.""" + + +class LocalShellToolParam(TypedDict, total=False): + """Local shell tool. + + :ivar type: The type of the local shell tool. Always ``local_shell``. Required. LOCAL_SHELL. + :vartype type: str or ~azure.ai.projects.models.LOCAL_SHELL + """ + + type: Required[Literal[ToolType.LOCAL_SHELL]] + """The type of the local shell tool. Always ``local_shell``. Required. LOCAL_SHELL.""" + + +class LocalSkillParam(TypedDict, total=False): + """LocalSkillParam. + + :ivar name: The name of the skill. Required. + :vartype name: str + :ivar description: The description of the skill. Required. + :vartype description: str + :ivar path: The path to the directory containing the skill. Required. + :vartype path: str + """ + + name: Required[str] + """The name of the skill. Required.""" + description: Required[str] + """The description of the skill. Required.""" + path: Required[str] + """The path to the directory containing the skill. Required.""" + + +class ManagedAzureAISearchIndex(TypedDict, total=False): + """Managed Azure AI Search Index Definition. + + :ivar id: Asset ID, a unique identifier for the asset. + :vartype id: str + :ivar name: The name of the resource. Required. + :vartype name: str + :ivar version: The version of the resource. Required. + :vartype version: str + :ivar description: The asset description text. + :vartype description: str + :ivar tags: Tag dictionary. Tags can be added, removed, and updated. + :vartype tags: dict[str, str] + :ivar type: Type of index. Required. Managed Azure Search. + :vartype type: str or ~azure.ai.projects.models.MANAGED_AZURE_SEARCH + :ivar vector_store_id: Vector store id of managed index. Required. + :vartype vector_store_id: str + """ + + id: str + """Asset ID, a unique identifier for the asset.""" + name: Required[str] + """The name of the resource. Required.""" + version: Required[str] + """The version of the resource. Required.""" + description: str + """The asset description text.""" + tags: dict[str, str] + """Tag dictionary. Tags can be added, removed, and updated.""" + type: Required[Literal[IndexType.MANAGED_AZURE_SEARCH]] + """Type of index. Required. Managed Azure Search.""" + vectorStoreId: Required[str] + """Vector store id of managed index. Required.""" + + +class MCPTool(TypedDict, total=False): + """MCP tool. + + :ivar type: The type of the MCP tool. Always ``mcp``. Required. MCP. + :vartype type: str or ~azure.ai.projects.models.MCP + :ivar server_label: A label for this MCP server, used to identify it in tool calls. Required. + :vartype server_label: str + :ivar server_url: The URL for the MCP server. One of ``server_url`` or ``connector_id`` must be + provided. + :vartype server_url: str + :ivar connector_id: Identifier for service connectors, like those available in ChatGPT. One of + ``server_url`` or ``connector_id`` must be provided. Learn more about service connectors `here + `_. Currently supported ``connector_id`` values are: + + * Dropbox: `connector_dropbox` + * Gmail: `connector_gmail` + * Google Calendar: `connector_googlecalendar` + * Google Drive: `connector_googledrive` + * Microsoft Teams: `connector_microsoftteams` + * Outlook Calendar: `connector_outlookcalendar` + * Outlook Email: `connector_outlookemail` + * SharePoint: `connector_sharepoint`. Is one of the following types: + Literal["connector_dropbox"], Literal["connector_gmail"], Literal["connector_googlecalendar"], + Literal["connector_googledrive"], Literal["connector_microsoftteams"], + Literal["connector_outlookcalendar"], Literal["connector_outlookemail"], + Literal["connector_sharepoint"] + :vartype connector_id: str or str or str or str or str or str or str or str + :ivar authorization: An OAuth access token that can be used with a remote MCP server, either + with a custom MCP server URL or a service connector. Your application must handle the OAuth + authorization flow and provide the token here. + :vartype authorization: str + :ivar server_description: Optional description of the MCP server, used to provide more context. + :vartype server_description: str + :ivar headers: + :vartype headers: dict[str, str] + :ivar allowed_tools: Is either a [str] type or a MCPToolFilter type. + :vartype allowed_tools: list[str] or ~azure.ai.projects.types.MCPToolFilter + :ivar require_approval: Is one of the following types: MCPToolRequireApproval, + Literal["always"], Literal["never"] + :vartype require_approval: ~azure.ai.projects.types.MCPToolRequireApproval or str or str + :ivar project_connection_id: The connection ID in the project for the MCP server. The + connection stores authentication and other connection details needed to connect to the MCP + server. + :vartype project_connection_id: str + """ + + type: Required[Literal[ToolType.MCP]] + """The type of the MCP tool. Always ``mcp``. Required. MCP.""" + server_label: Required[str] + """A label for this MCP server, used to identify it in tool calls. Required.""" + server_url: str + """The URL for the MCP server. One of ``server_url`` or ``connector_id`` must be provided.""" + connector_id: Literal[ + "connector_dropbox", + "connector_gmail", + "connector_googlecalendar", + "connector_googledrive", + "connector_microsoftteams", + "connector_outlookcalendar", + "connector_outlookemail", + "connector_sharepoint", + ] + """Identifier for service connectors, like those available in ChatGPT. One of ``server_url`` or + ``connector_id`` must be provided. Learn more about service connectors `here + `_. Currently supported ``connector_id`` values are: + + * Dropbox: `connector_dropbox` + * Gmail: `connector_gmail` + * Google Calendar: `connector_googlecalendar` + * Google Drive: `connector_googledrive` + * Microsoft Teams: `connector_microsoftteams` + * Outlook Calendar: `connector_outlookcalendar` + * Outlook Email: `connector_outlookemail` + * SharePoint: `connector_sharepoint`. Is one of the following types: + Literal[\"connector_dropbox\"], Literal[\"connector_gmail\"], + Literal[\"connector_googlecalendar\"], Literal[\"connector_googledrive\"], + Literal[\"connector_microsoftteams\"], Literal[\"connector_outlookcalendar\"], + Literal[\"connector_outlookemail\"], Literal[\"connector_sharepoint\"]""" + authorization: str + """An OAuth access token that can be used with a remote MCP server, either with a custom MCP + server URL or a service connector. Your application must handle the OAuth authorization flow + and provide the token here.""" + server_description: str + """Optional description of the MCP server, used to provide more context.""" + headers: Optional[dict[str, str]] + allowed_tools: Optional[Union[list[str], "MCPToolFilter"]] + """Is either a [str] type or a MCPToolFilter type.""" + require_approval: Optional[Union["MCPToolRequireApproval", Literal["always"], Literal["never"]]] + """Is one of the following types: MCPToolRequireApproval, Literal[\"always\"], Literal[\"never\"]""" + project_connection_id: str + """The connection ID in the project for the MCP server. The connection stores authentication and + other connection details needed to connect to the MCP server.""" + + +class MCPToolFilter(TypedDict, total=False): + """MCP tool filter. + + :ivar tool_names: MCP allowed tools. + :vartype tool_names: list[str] + :ivar read_only: Indicates whether or not a tool modifies data or is read-only. If an MCP + server is `annotated with `readOnlyHint` + `_, + it will match this filter. + :vartype read_only: bool + """ + + tool_names: list[str] + """MCP allowed tools.""" + read_only: bool + """Indicates whether or not a tool modifies data or is read-only. If an MCP server is `annotated + with `readOnlyHint` + `_, + it will match this filter.""" + + +class MCPToolRequireApproval(TypedDict, total=False): + """MCPToolRequireApproval. + + :ivar always: + :vartype always: ~azure.ai.projects.types.MCPToolFilter + :ivar never: + :vartype never: ~azure.ai.projects.types.MCPToolFilter + """ + + always: "MCPToolFilter" + never: "MCPToolFilter" + + +class MemoryOperation(TypedDict, total=False): + """Represents a single memory operation (create, update, or delete) performed on a memory item. + + :ivar kind: The type of memory operation being performed. Required. Known values are: "create", + "update", and "delete". + :vartype kind: str or ~azure.ai.projects.models.MemoryOperationKind + :ivar memory_item: The memory item to create, update, or delete. Required. + :vartype memory_item: ~azure.ai.projects.types.MemoryItem + """ + + kind: Required[MemoryOperationKind] + """The type of memory operation being performed. Required. Known values are: \"create\", + \"update\", and \"delete\".""" + memory_item: Required["MemoryItem"] + """The memory item to create, update, or delete. Required.""" + + +class MemorySearchItem(TypedDict, total=False): + """A retrieved memory item from memory search. + + :ivar memory_item: Retrieved memory item. Required. + :vartype memory_item: ~azure.ai.projects.types.MemoryItem + """ + + memory_item: Required["MemoryItem"] + """Retrieved memory item. Required.""" + + +class MemorySearchOptions(TypedDict, total=False): + """Memory search options. + + :ivar max_memories: Maximum number of memory items to return. + :vartype max_memories: int + """ + + max_memories: int + """Maximum number of memory items to return.""" + + +class MemorySearchPreviewTool(TypedDict, total=False): + """A tool for integrating memories into the agent. + + :ivar type: The type of the tool. Always ``memory_search_preview``. Required. + MEMORY_SEARCH_PREVIEW. + :vartype type: str or ~azure.ai.projects.models.MEMORY_SEARCH_PREVIEW + :ivar memory_store_name: The name of the memory store to use. Required. + :vartype memory_store_name: str + :ivar scope: The namespace used to group and isolate memories, such as a user ID. Limits which + memories can be retrieved or updated. Use special variable ``{{$userId}}`` to scope memories to + the current signed-in user. Required. + :vartype scope: str + :ivar search_options: Options for searching the memory store. + :vartype search_options: ~azure.ai.projects.types.MemorySearchOptions + :ivar update_delay: Time to wait before updating memories after inactivity (seconds). Default + 300. + :vartype update_delay: int + """ + + type: Required[Literal[ToolType.MEMORY_SEARCH_PREVIEW]] + """The type of the tool. Always ``memory_search_preview``. Required. MEMORY_SEARCH_PREVIEW.""" + memory_store_name: Required[str] + """The name of the memory store to use. Required.""" + scope: Required[str] + """The namespace used to group and isolate memories, such as a user ID. Limits which memories can + be retrieved or updated. Use special variable ``{{$userId}}`` to scope memories to the current + signed-in user. Required.""" + search_options: "MemorySearchOptions" + """Options for searching the memory store.""" + update_delay: int + """Time to wait before updating memories after inactivity (seconds). Default 300.""" + + +class MemoryStoreDefaultDefinition(TypedDict, total=False): + """Default memory store implementation. + + :ivar kind: The kind of the memory store. Required. The default memory store implementation. + :vartype kind: str or ~azure.ai.projects.models.DEFAULT + :ivar chat_model: The name or identifier of the chat completion model deployment used for + memory processing. Required. + :vartype chat_model: str + :ivar embedding_model: The name or identifier of the embedding model deployment used for memory + processing. Required. + :vartype embedding_model: str + :ivar options: Default memory store options. + :vartype options: ~azure.ai.projects.types.MemoryStoreDefaultOptions + """ + + kind: Required[Literal[MemoryStoreKind.DEFAULT]] + """The kind of the memory store. Required. The default memory store implementation.""" + chat_model: Required[str] + """The name or identifier of the chat completion model deployment used for memory processing. + Required.""" + embedding_model: Required[str] + """The name or identifier of the embedding model deployment used for memory processing. Required.""" + options: "MemoryStoreDefaultOptions" + """Default memory store options.""" + + +class MemoryStoreDefaultOptions(TypedDict, total=False): + """Default memory store configurations. + + :ivar user_profile_enabled: Whether to enable user profile extraction and storage. Default is + true. Required. + :vartype user_profile_enabled: bool + :ivar user_profile_details: Specific categories or types of user profile information to extract + and store. + :vartype user_profile_details: str + :ivar chat_summary_enabled: Whether to enable chat summary extraction and storage. Default is + true. Required. + :vartype chat_summary_enabled: bool + """ + + user_profile_enabled: Required[bool] + """Whether to enable user profile extraction and storage. Default is true. Required.""" + user_profile_details: str + """Specific categories or types of user profile information to extract and store.""" + chat_summary_enabled: Required[bool] + """Whether to enable chat summary extraction and storage. Default is true. Required.""" + + +class MemoryStoreDeleteScopeResult(TypedDict, total=False): + """Response for deleting memories from a scope. + + :ivar object: The object type. Always 'memory_store.scope.deleted'. Required. + MEMORY_STORE_SCOPE_DELETED. + :vartype object: str or ~azure.ai.projects.models.MEMORY_STORE_SCOPE_DELETED + :ivar name: The name of the memory store. Required. + :vartype name: str + :ivar scope: The scope from which memories were deleted. Required. + :vartype scope: str + :ivar deleted: Whether the deletion operation was successful. Required. + :vartype deleted: bool + """ + + object: Required[Literal[MemoryStoreObjectType.MEMORY_STORE_SCOPE_DELETED]] + """The object type. Always 'memory_store.scope.deleted'. Required. MEMORY_STORE_SCOPE_DELETED.""" + name: Required[str] + """The name of the memory store. Required.""" + scope: Required[str] + """The scope from which memories were deleted. Required.""" + deleted: Required[bool] + """Whether the deletion operation was successful. Required.""" + + +class MemoryStoreDetails(TypedDict, total=False): + """A memory store that can store and retrieve user memories. + + :ivar object: The object type, which is always 'memory_store'. Required. MEMORY_STORE. + :vartype object: str or ~azure.ai.projects.models.MEMORY_STORE + :ivar id: The unique identifier of the memory store. Required. + :vartype id: str + :ivar created_at: The Unix timestamp (seconds) when the memory store was created. Required. + :vartype created_at: ~datetime.datetime + :ivar updated_at: The Unix timestamp (seconds) when the memory store was last updated. + Required. + :vartype updated_at: ~datetime.datetime + :ivar name: The name of the memory store. Required. + :vartype name: str + :ivar description: A human-readable description of the memory store. + :vartype description: str + :ivar metadata: Arbitrary key-value metadata to associate with the memory store. + :vartype metadata: dict[str, str] + :ivar definition: The definition of the memory store. Required. + :vartype definition: ~azure.ai.projects.types.MemoryStoreDefinition + """ + + object: Required[Literal[MemoryStoreObjectType.MEMORY_STORE]] + """The object type, which is always 'memory_store'. Required. MEMORY_STORE.""" + id: Required[str] + """The unique identifier of the memory store. Required.""" + created_at: Required[int] + """The Unix timestamp (seconds) when the memory store was created. Required.""" + updated_at: Required[int] + """The Unix timestamp (seconds) when the memory store was last updated. Required.""" + name: Required[str] + """The name of the memory store. Required.""" + description: str + """A human-readable description of the memory store.""" + metadata: dict[str, str] + """Arbitrary key-value metadata to associate with the memory store.""" + definition: Required["MemoryStoreDefinition"] + """The definition of the memory store. Required.""" + + +class MemoryStoreOperationUsage(TypedDict, total=False): + """Usage statistics of a memory store operation. + + :ivar embedding_tokens: The number of embedding tokens. Required. + :vartype embedding_tokens: int + :ivar input_tokens: The number of input tokens. Required. + :vartype input_tokens: int + :ivar input_tokens_details: A detailed breakdown of the input tokens. Required. + :vartype input_tokens_details: ~azure.ai.projects.types.ResponseUsageInputTokensDetails + :ivar output_tokens: The number of output tokens. Required. + :vartype output_tokens: int + :ivar output_tokens_details: A detailed breakdown of the output tokens. Required. + :vartype output_tokens_details: ~azure.ai.projects.types.ResponseUsageOutputTokensDetails + :ivar total_tokens: The total number of tokens used. Required. + :vartype total_tokens: int + """ + + embedding_tokens: Required[int] + """The number of embedding tokens. Required.""" + input_tokens: Required[int] + """The number of input tokens. Required.""" + input_tokens_details: Required["ResponseUsageInputTokensDetails"] + """A detailed breakdown of the input tokens. Required.""" + output_tokens: Required[int] + """The number of output tokens. Required.""" + output_tokens_details: Required["ResponseUsageOutputTokensDetails"] + """A detailed breakdown of the output tokens. Required.""" + total_tokens: Required[int] + """The total number of tokens used. Required.""" + + +class MemoryStoreSearchResult(TypedDict, total=False): + """Memory search response. + + :ivar search_id: The unique ID of this search request. Use this value as previous_search_id in + subsequent requests to perform incremental searches. Required. + :vartype search_id: str + :ivar memories: Related memory items found during the search operation. Required. + :vartype memories: list[~azure.ai.projects.types.MemorySearchItem] + :ivar usage: Usage statistics associated with the memory search operation. Required. + :vartype usage: ~azure.ai.projects.types.MemoryStoreOperationUsage + """ + + search_id: Required[str] + """The unique ID of this search request. Use this value as previous_search_id in subsequent + requests to perform incremental searches. Required.""" + memories: Required[list["MemorySearchItem"]] + """Related memory items found during the search operation. Required.""" + usage: Required["MemoryStoreOperationUsage"] + """Usage statistics associated with the memory search operation. Required.""" + + +class MemoryStoreUpdateCompletedResult(TypedDict, total=False): + """Memory update result. + + :ivar memory_operations: A list of individual memory operations that were performed during the + update. Required. + :vartype memory_operations: list[~azure.ai.projects.types.MemoryOperation] + :ivar usage: Usage statistics associated with the memory update operation. Required. + :vartype usage: ~azure.ai.projects.types.MemoryStoreOperationUsage + """ + + memory_operations: Required[list["MemoryOperation"]] + """A list of individual memory operations that were performed during the update. Required.""" + usage: Required["MemoryStoreOperationUsage"] + """Usage statistics associated with the memory update operation. Required.""" + + +class MemoryStoreUpdateResult(TypedDict, total=False): + """Provides the status of a memory store update operation. + + :ivar update_id: The unique ID of this update request. Use this value as previous_update_id in + subsequent requests to perform incremental updates. Required. + :vartype update_id: str + :ivar status: The status of the memory update operation. One of "queued", "in_progress", + "completed", "failed", or "superseded". Required. Known values are: "queued", "in_progress", + "completed", "failed", and "superseded". + :vartype status: str or ~azure.ai.projects.models.MemoryStoreUpdateStatus + :ivar superseded_by: The update_id the operation was superseded by when status is "superseded". + :vartype superseded_by: str + :ivar result: The result of memory store update operation when status is "completed". + :vartype result: ~azure.ai.projects.types.MemoryStoreUpdateCompletedResult + :ivar error: Error object that describes the error when status is "failed". + :vartype error: ~azure.ai.projects.types.ApiError + """ + + update_id: Required[str] + """The unique ID of this update request. Use this value as previous_update_id in subsequent + requests to perform incremental updates. Required.""" + status: Required[MemoryStoreUpdateStatus] + """The status of the memory update operation. One of \"queued\", \"in_progress\", \"completed\", + \"failed\", or \"superseded\". Required. Known values are: \"queued\", \"in_progress\", + \"completed\", \"failed\", and \"superseded\".""" + superseded_by: str + """The update_id the operation was superseded by when status is \"superseded\".""" + result: "MemoryStoreUpdateCompletedResult" + """The result of memory store update operation when status is \"completed\".""" + error: "ApiError" + """Error object that describes the error when status is \"failed\".""" + + +class MicrosoftFabricPreviewTool(TypedDict, total=False): + """The input definition information for a Microsoft Fabric tool as used to configure an agent. + + :ivar type: The object type, which is always 'fabric_dataagent_preview'. Required. + FABRIC_DATAAGENT_PREVIEW. + :vartype type: str or ~azure.ai.projects.models.FABRIC_DATAAGENT_PREVIEW + :ivar fabric_dataagent_preview: The fabric data agent tool parameters. Required. + :vartype fabric_dataagent_preview: ~azure.ai.projects.types.FabricDataAgentToolParameters + """ + + type: Required[Literal[ToolType.FABRIC_DATAAGENT_PREVIEW]] + """The object type, which is always 'fabric_dataagent_preview'. Required. + FABRIC_DATAAGENT_PREVIEW.""" + fabric_dataagent_preview: Required["FabricDataAgentToolParameters"] + """The fabric data agent tool parameters. Required.""" + + +class ModelDeployment(TypedDict, total=False): + """Model Deployment Definition. + + :ivar name: Name of the deployment. Required. + :vartype name: str + :ivar type: The type of the deployment. Required. Model deployment. + :vartype type: str or ~azure.ai.projects.models.MODEL_DEPLOYMENT + :ivar model_name: Publisher-specific name of the deployed model. Required. + :vartype model_name: str + :ivar model_version: Publisher-specific version of the deployed model. Required. + :vartype model_version: str + :ivar model_publisher: Name of the deployed model's publisher. Required. + :vartype model_publisher: str + :ivar capabilities: Capabilities of deployed model. Required. + :vartype capabilities: dict[str, str] + :ivar sku: Sku of the model deployment. Required. + :vartype sku: ~azure.ai.projects.types.ModelDeploymentSku + :ivar connection_name: Name of the connection the deployment comes from. + :vartype connection_name: str + """ + + name: Required[str] + """Name of the deployment. Required.""" + type: Required[Literal[DeploymentType.MODEL_DEPLOYMENT]] + """The type of the deployment. Required. Model deployment.""" + modelName: Required[str] + """Publisher-specific name of the deployed model. Required.""" + modelVersion: Required[str] + """Publisher-specific version of the deployed model. Required.""" + modelPublisher: Required[str] + """Name of the deployed model's publisher. Required.""" + capabilities: Required[dict[str, str]] + """Capabilities of deployed model. Required.""" + sku: Required["ModelDeploymentSku"] + """Sku of the model deployment. Required.""" + connectionName: str + """Name of the connection the deployment comes from.""" + + +class ModelDeploymentSku(TypedDict, total=False): + """Sku information. + + :ivar capacity: Sku capacity. Required. + :vartype capacity: int + :ivar family: Sku family. Required. + :vartype family: str + :ivar name: Sku name. Required. + :vartype name: str + :ivar size: Sku size. Required. + :vartype size: str + :ivar tier: Sku tier. Required. + :vartype tier: str + """ + + capacity: Required[int] + """Sku capacity. Required.""" + family: Required[str] + """Sku family. Required.""" + name: Required[str] + """Sku name. Required.""" + size: Required[str] + """Sku size. Required.""" + tier: Required[str] + """Sku tier. Required.""" + + +class ModelSamplingParams(TypedDict, total=False): + """Represents a set of parameters used to control the sampling behavior of a language model during + text generation. + + :ivar temperature: The temperature parameter for sampling. Required. + :vartype temperature: float + :ivar top_p: The top-p parameter for nucleus sampling. Required. + :vartype top_p: float + :ivar seed: The random seed for reproducibility. Required. + :vartype seed: int + :ivar max_completion_tokens: The maximum number of tokens allowed in the completion. Required. + :vartype max_completion_tokens: int + """ + + temperature: Required[float] + """The temperature parameter for sampling. Required.""" + top_p: Required[float] + """The top-p parameter for nucleus sampling. Required.""" + seed: Required[int] + """The random seed for reproducibility. Required.""" + max_completion_tokens: Required[int] + """The maximum number of tokens allowed in the completion. Required.""" + + +class MonthlyRecurrenceSchedule(TypedDict, total=False): + """Monthly recurrence schedule. + + :ivar type: Monthly recurrence type. Required. Monthly recurrence pattern. + :vartype type: str or ~azure.ai.projects.models.MONTHLY + :ivar days_of_month: Days of the month for the recurrence schedule. Required. + :vartype days_of_month: list[int] + """ + + type: Required[Literal[RecurrenceType.MONTHLY]] + """Monthly recurrence type. Required. Monthly recurrence pattern.""" + daysOfMonth: Required[list[int]] + """Days of the month for the recurrence schedule. Required.""" + + +class NoAuthenticationCredentials(TypedDict, total=False): + """Credentials that do not require authentication. + + :ivar type: The credential type. Required. No credential. + :vartype type: str or ~azure.ai.projects.models.NONE + """ + + type: Required[Literal[CredentialType.NONE]] + """The credential type. Required. No credential.""" + + +class OneTimeTrigger(TypedDict, total=False): + """One-time trigger. + + :ivar type: Required. One-time trigger. + :vartype type: str or ~azure.ai.projects.models.ONE_TIME + :ivar trigger_at: Date and time for the one-time trigger in ISO 8601 format. Required. + :vartype trigger_at: ~datetime.datetime + :ivar time_zone: Time zone for the one-time trigger. + :vartype time_zone: str + """ + + type: Required[Literal[TriggerType.ONE_TIME]] + """Required. One-time trigger.""" + triggerAt: Required[str] + """Date and time for the one-time trigger in ISO 8601 format. Required.""" + timeZone: str + """Time zone for the one-time trigger.""" + + +class OpenApiAnonymousAuthDetails(TypedDict, total=False): + """Security details for OpenApi anonymous authentication. + + :ivar type: The object type, which is always 'anonymous'. Required. ANONYMOUS. + :vartype type: str or ~azure.ai.projects.models.ANONYMOUS + """ + + type: Required[Literal[OpenApiAuthType.ANONYMOUS]] + """The object type, which is always 'anonymous'. Required. ANONYMOUS.""" + + +class OpenApiFunctionDefinition(TypedDict, total=False): + """The input definition information for an openapi function. + + :ivar name: The name of the function to be called. Required. + :vartype name: str + :ivar description: A description of what the function does, used by the model to choose when + and how to call the function. + :vartype description: str + :ivar spec: The openapi function shape, described as a JSON Schema object. Required. + :vartype spec: dict[str, any] + :ivar auth: Open API authentication details. Required. + :vartype auth: ~azure.ai.projects.types.OpenApiAuthDetails + :ivar default_params: List of OpenAPI spec parameters that will use user-provided defaults. + :vartype default_params: list[str] + :ivar functions: List of function definitions used by OpenApi tool. + :vartype functions: list[~azure.ai.projects.types.OpenApiFunctionDefinitionFunction] + """ + + name: Required[str] + """The name of the function to be called. Required.""" + description: str + """A description of what the function does, used by the model to choose when and how to call the + function.""" + spec: Required[dict[str, Any]] + """The openapi function shape, described as a JSON Schema object. Required.""" + auth: Required["OpenApiAuthDetails"] + """Open API authentication details. Required.""" + default_params: list[str] + """List of OpenAPI spec parameters that will use user-provided defaults.""" + functions: list["OpenApiFunctionDefinitionFunction"] + """List of function definitions used by OpenApi tool.""" + + +class OpenApiFunctionDefinitionFunction(TypedDict, total=False): + """OpenApiFunctionDefinitionFunction. + + :ivar name: The name of the function to be called. Required. + :vartype name: str + :ivar description: A description of what the function does, used by the model to choose when + and how to call the function. + :vartype description: str + :ivar parameters: The parameters the functions accepts, described as a JSON Schema object. + Required. + :vartype parameters: dict[str, any] + """ + + name: Required[str] + """The name of the function to be called. Required.""" + description: str + """A description of what the function does, used by the model to choose when and how to call the + function.""" + parameters: Required[dict[str, Any]] + """The parameters the functions accepts, described as a JSON Schema object. Required.""" + + +class OpenApiManagedAuthDetails(TypedDict, total=False): + """Security details for OpenApi managed_identity authentication. + + :ivar type: The object type, which is always 'managed_identity'. Required. MANAGED_IDENTITY. + :vartype type: str or ~azure.ai.projects.models.MANAGED_IDENTITY + :ivar security_scheme: Connection auth security details. Required. + :vartype security_scheme: ~azure.ai.projects.types.OpenApiManagedSecurityScheme + """ + + type: Required[Literal[OpenApiAuthType.MANAGED_IDENTITY]] + """The object type, which is always 'managed_identity'. Required. MANAGED_IDENTITY.""" + security_scheme: Required["OpenApiManagedSecurityScheme"] + """Connection auth security details. Required.""" + + +class OpenApiManagedSecurityScheme(TypedDict, total=False): + """Security scheme for OpenApi managed_identity authentication. + + :ivar audience: Authentication scope for managed_identity auth type. Required. + :vartype audience: str + """ + + audience: Required[str] + """Authentication scope for managed_identity auth type. Required.""" + + +class OpenApiProjectConnectionAuthDetails(TypedDict, total=False): + """Security details for OpenApi project connection authentication. + + :ivar type: The object type, which is always 'project_connection'. Required. + PROJECT_CONNECTION. + :vartype type: str or ~azure.ai.projects.models.PROJECT_CONNECTION + :ivar security_scheme: Project connection auth security details. Required. + :vartype security_scheme: ~azure.ai.projects.types.OpenApiProjectConnectionSecurityScheme + """ + + type: Required[Literal[OpenApiAuthType.PROJECT_CONNECTION]] + """The object type, which is always 'project_connection'. Required. PROJECT_CONNECTION.""" + security_scheme: Required["OpenApiProjectConnectionSecurityScheme"] + """Project connection auth security details. Required.""" + + +class OpenApiProjectConnectionSecurityScheme(TypedDict, total=False): + """Security scheme for OpenApi managed_identity authentication. + + :ivar project_connection_id: Project connection id for Project Connection auth type. Required. + :vartype project_connection_id: str + """ + + project_connection_id: Required[str] + """Project connection id for Project Connection auth type. Required.""" + + +class OpenApiTool(TypedDict, total=False): + """The input definition information for an OpenAPI tool as used to configure an agent. + + :ivar type: The object type, which is always 'openapi'. Required. OPENAPI. + :vartype type: str or ~azure.ai.projects.models.OPENAPI + :ivar openapi: The openapi function definition. Required. + :vartype openapi: ~azure.ai.projects.types.OpenApiFunctionDefinition + """ + + type: Required[Literal[ToolType.OPENAPI]] + """The object type, which is always 'openapi'. Required. OPENAPI.""" + openapi: Required["OpenApiFunctionDefinition"] + """The openapi function definition. Required.""" + + +class PendingUploadRequest(TypedDict, total=False): + """Represents a request for a pending upload. + + :ivar pending_upload_id: If PendingUploadId is not provided, a random GUID will be used. + :vartype pending_upload_id: str + :ivar connection_name: Azure Storage Account connection name to use for generating temporary + SAS token. + :vartype connection_name: str + :ivar pending_upload_type: BlobReference is the only supported type. Required. Blob Reference + is the only supported type. + :vartype pending_upload_type: str or ~azure.ai.projects.models.BLOB_REFERENCE + """ + + pendingUploadId: str + """If PendingUploadId is not provided, a random GUID will be used.""" + connectionName: str + """Azure Storage Account connection name to use for generating temporary SAS token.""" + pendingUploadType: Required[Literal[PendingUploadType.BLOB_REFERENCE]] + """BlobReference is the only supported type. Required. Blob Reference is the only supported type.""" + + +class PendingUploadResponse(TypedDict, total=False): + """Represents the response for a pending upload request. + + :ivar blob_reference: Container-level read, write, list SAS. Required. + :vartype blob_reference: ~azure.ai.projects.types.BlobReference + :ivar pending_upload_id: ID for this upload request. Required. + :vartype pending_upload_id: str + :ivar version: Version of asset to be created if user did not specify version when initially + creating upload. + :vartype version: str + :ivar pending_upload_type: BlobReference is the only supported type. Required. Blob Reference + is the only supported type. + :vartype pending_upload_type: str or ~azure.ai.projects.models.BLOB_REFERENCE + """ + + blobReference: Required["BlobReference"] + """Container-level read, write, list SAS. Required.""" + pendingUploadId: Required[str] + """ID for this upload request. Required.""" + version: str + """Version of asset to be created if user did not specify version when initially creating upload.""" + pendingUploadType: Required[Literal[PendingUploadType.BLOB_REFERENCE]] + """BlobReference is the only supported type. Required. Blob Reference is the only supported type.""" + + +class PromptAgentDefinition(TypedDict, total=False): + """The prompt agent definition. + + :ivar rai_config: Configuration for Responsible AI (RAI) content filtering and safety features. + :vartype rai_config: ~azure.ai.projects.types.RaiConfig + :ivar kind: Required. PROMPT. + :vartype kind: str or ~azure.ai.projects.models.PROMPT + :ivar model: The model deployment to use for this agent. Required. + :vartype model: str + :ivar instructions: A system (or developer) message inserted into the model's context. + :vartype instructions: str + :ivar temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 + will make the output more random, while lower values like 0.2 will make it more focused and + deterministic. We generally recommend altering this or ``top_p`` but not both. + :vartype temperature: float + :ivar top_p: 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. + :vartype top_p: float + :ivar reasoning: + :vartype reasoning: ~azure.ai.projects.types.Reasoning + :ivar tools: An array of tools the model may call while generating a response. You can specify + which tool to use by setting the ``tool_choice`` parameter. + :vartype tools: list[~azure.ai.projects.types.Tool] + :ivar tool_choice: How the model should select which tool (or tools) to use when generating a + response. See the ``tools`` parameter to see how to specify which tools the model can call. Is + either a str type or a ToolChoiceParam type. + :vartype tool_choice: str or ~azure.ai.projects.types.ToolChoiceParam + :ivar text: Configuration options for a text response from the model. Can be plain text or + structured JSON data. + :vartype text: ~azure.ai.projects.types.PromptAgentDefinitionTextOptions + :ivar structured_inputs: Set of structured inputs that can participate in prompt template + substitution or tool argument bindings. + :vartype structured_inputs: dict[str, ~azure.ai.projects.types.StructuredInputDefinition] + """ + + rai_config: "RaiConfig" + """Configuration for Responsible AI (RAI) content filtering and safety features.""" + kind: Required[Literal[AgentKind.PROMPT]] + """Required. PROMPT.""" + model: Required[str] + """The model deployment to use for this agent. Required.""" + instructions: Optional[str] + """A system (or developer) message inserted into the model's context.""" + temperature: Optional[float] + """What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output + more random, while lower values like 0.2 will make it more focused and deterministic. We + generally recommend altering this or ``top_p`` but not both.""" + top_p: Optional[float] + """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.""" + reasoning: Optional["Reasoning"] + tools: list["Tool"] + """An array of tools the model may call while generating a response. You can specify which tool to + use by setting the ``tool_choice`` parameter.""" + tool_choice: Union[str, "ToolChoiceParam"] + """How the model should select which tool (or tools) to use when generating a response. See the + ``tools`` parameter to see how to specify which tools the model can call. Is either a str type + or a ToolChoiceParam type.""" + text: "PromptAgentDefinitionTextOptions" + """Configuration options for a text response from the model. Can be plain text or structured JSON + data.""" + structured_inputs: dict[str, "StructuredInputDefinition"] + """Set of structured inputs that can participate in prompt template substitution or tool argument + bindings.""" + + +class PromptAgentDefinitionTextOptions(TypedDict, total=False): + """Configuration options for a text response from the model. Can be plain text or structured JSON + data. + + :ivar format: + :vartype format: ~azure.ai.projects.types.TextResponseFormat + """ + + format: "TextResponseFormat" + + +class PromptBasedEvaluatorDefinition(TypedDict, total=False): + """Prompt-based evaluator. + + :ivar init_parameters: The JSON schema (Draft 2020-12) for the evaluator's input parameters. + This includes parameters like type, properties, required. + :vartype init_parameters: dict[str, any] + :ivar data_schema: The JSON schema (Draft 2020-12) for the evaluator's input data. This + includes parameters like type, properties, required. + :vartype data_schema: dict[str, any] + :ivar metrics: List of output metrics produced by this evaluator. + :vartype metrics: dict[str, ~azure.ai.projects.types.EvaluatorMetric] + :ivar type: Required. Prompt-based definition. + :vartype type: str or ~azure.ai.projects.models.PROMPT + :ivar prompt_text: The prompt text used for evaluation. Required. + :vartype prompt_text: str + """ + + init_parameters: dict[str, Any] + """The JSON schema (Draft 2020-12) for the evaluator's input parameters. This includes parameters + like type, properties, required.""" + data_schema: dict[str, Any] + """The JSON schema (Draft 2020-12) for the evaluator's input data. This includes parameters like + type, properties, required.""" + metrics: dict[str, "EvaluatorMetric"] + """List of output metrics produced by this evaluator.""" + type: Required[Literal[EvaluatorDefinitionType.PROMPT]] + """Required. Prompt-based definition.""" + prompt_text: Required[str] + """The prompt text used for evaluation. Required.""" + + +class ProtocolVersionRecord(TypedDict, total=False): + """A record mapping for a single protocol and its version. + + :ivar protocol: The protocol type. Required. Known values are: "activity_protocol" and + "responses". + :vartype protocol: str or ~azure.ai.projects.models.AgentProtocol + :ivar version: The version string for the protocol, e.g. 'v0.1.1'. Required. + :vartype version: str + """ + + protocol: Required[AgentProtocol] + """The protocol type. Required. Known values are: \"activity_protocol\" and \"responses\".""" + version: Required[str] + """The version string for the protocol, e.g. 'v0.1.1'. Required.""" + + +class RaiConfig(TypedDict, total=False): + """Configuration for Responsible AI (RAI) content filtering and safety features. + + :ivar rai_policy_name: The name of the RAI policy to apply. Required. + :vartype rai_policy_name: str + """ + + rai_policy_name: Required[str] + """The name of the RAI policy to apply. Required.""" + + +class RankingOptions(TypedDict, total=False): + """RankingOptions. + + :ivar ranker: The ranker to use for the file search. Known values are: "auto" and + "default-2024-11-15". + :vartype ranker: str or ~azure.ai.projects.models.RankerVersionType + :ivar score_threshold: The score threshold for the file search, a number between 0 and 1. + Numbers closer to 1 will attempt to return only the most relevant results, but may return fewer + results. + :vartype score_threshold: float + :ivar hybrid_search: Weights that control how reciprocal rank fusion balances semantic + embedding matches versus sparse keyword matches when hybrid search is enabled. + :vartype hybrid_search: ~azure.ai.projects.types.HybridSearchOptions + """ + + ranker: RankerVersionType + """The ranker to use for the file search. Known values are: \"auto\" and \"default-2024-11-15\".""" + score_threshold: float + """The score threshold for the file search, a number between 0 and 1. Numbers closer to 1 will + attempt to return only the most relevant results, but may return fewer results.""" + hybrid_search: "HybridSearchOptions" + """Weights that control how reciprocal rank fusion balances semantic embedding matches versus + sparse keyword matches when hybrid search is enabled.""" + + +class Reasoning(TypedDict, total=False): + """Reasoning. + + :ivar effort: Is one of the following types: Literal["none"], Literal["minimal"], + Literal["low"], Literal["medium"], Literal["high"], Literal["xhigh"] + :vartype effort: str or str or str or str or str or str + :ivar summary: Is one of the following types: Literal["auto"], Literal["concise"], + Literal["detailed"] + :vartype summary: str or str or str + :ivar generate_summary: Is one of the following types: Literal["auto"], Literal["concise"], + Literal["detailed"] + :vartype generate_summary: str or str or str + """ + + effort: Optional[Literal["none", "minimal", "low", "medium", "high", "xhigh"]] + """Is one of the following types: Literal[\"none\"], Literal[\"minimal\"], Literal[\"low\"], + Literal[\"medium\"], Literal[\"high\"], Literal[\"xhigh\"]""" + summary: Optional[Literal["auto", "concise", "detailed"]] + """Is one of the following types: Literal[\"auto\"], Literal[\"concise\"], Literal[\"detailed\"]""" + generate_summary: Optional[Literal["auto", "concise", "detailed"]] + """Is one of the following types: Literal[\"auto\"], Literal[\"concise\"], Literal[\"detailed\"]""" + + +class RecurrenceTrigger(TypedDict, total=False): + """Recurrence based trigger. + + :ivar type: Type of the trigger. Required. Recurrence based trigger. + :vartype type: str or ~azure.ai.projects.models.RECURRENCE + :ivar start_time: Start time for the recurrence schedule in ISO 8601 format. + :vartype start_time: ~datetime.datetime + :ivar end_time: End time for the recurrence schedule in ISO 8601 format. + :vartype end_time: ~datetime.datetime + :ivar time_zone: Time zone for the recurrence schedule. + :vartype time_zone: str + :ivar interval: Interval for the recurrence schedule. Required. + :vartype interval: int + :ivar schedule: Recurrence schedule for the recurrence trigger. Required. + :vartype schedule: ~azure.ai.projects.types.RecurrenceSchedule + """ + + type: Required[Literal[TriggerType.RECURRENCE]] + """Type of the trigger. Required. Recurrence based trigger.""" + startTime: str + """Start time for the recurrence schedule in ISO 8601 format.""" + endTime: str + """End time for the recurrence schedule in ISO 8601 format.""" + timeZone: str + """Time zone for the recurrence schedule.""" + interval: Required[int] + """Interval for the recurrence schedule. Required.""" + schedule: Required["RecurrenceSchedule"] + """Recurrence schedule for the recurrence trigger. Required.""" + + +class RedTeam(TypedDict, total=False): + """Red team details. + + :ivar name: Identifier of the red team run. Required. + :vartype name: str + :ivar display_name: Name of the red-team run. + :vartype display_name: str + :ivar num_turns: Number of simulation rounds. + :vartype num_turns: int + :ivar attack_strategies: List of attack strategies or nested lists of attack strategies. + :vartype attack_strategies: list[str or ~azure.ai.projects.models.AttackStrategy] + :ivar simulation_only: Simulation-only or Simulation + Evaluation. Default false, if true the + scan outputs conversation not evaluation result. + :vartype simulation_only: bool + :ivar risk_categories: List of risk categories to generate attack objectives for. + :vartype risk_categories: list[str or ~azure.ai.projects.models.RiskCategory] + :ivar application_scenario: Application scenario for the red team operation, to generate + scenario specific attacks. + :vartype application_scenario: str + :ivar tags: Red team's tags. Unlike properties, tags are fully mutable. + :vartype tags: dict[str, str] + :ivar properties: Red team's properties. Unlike tags, properties are add-only. Once added, a + property cannot be removed. + :vartype properties: dict[str, str] + :ivar status: Status of the red-team. It is set by service and is read-only. + :vartype status: str + :ivar target: Target configuration for the red-team run. Required. + :vartype target: ~azure.ai.projects.types.TargetConfig + """ + + id: Required[str] + """Identifier of the red team run. Required.""" + displayName: str + """Name of the red-team run.""" + numTurns: int + """Number of simulation rounds.""" + attackStrategies: list[AttackStrategy] + """List of attack strategies or nested lists of attack strategies.""" + simulationOnly: bool + """Simulation-only or Simulation + Evaluation. Default false, if true the scan outputs + conversation not evaluation result.""" + riskCategories: list[RiskCategory] + """List of risk categories to generate attack objectives for.""" + applicationScenario: str + """Application scenario for the red team operation, to generate scenario specific attacks.""" + tags: dict[str, str] + """Red team's tags. Unlike properties, tags are fully mutable.""" + properties: dict[str, str] + """Red team's properties. Unlike tags, properties are add-only. Once added, a property cannot be + removed.""" + status: str + """Status of the red-team. It is set by service and is read-only.""" + target: Required["TargetConfig"] + """Target configuration for the red-team run. Required.""" + + +class ResponseUsageInputTokensDetails(TypedDict, total=False): + """ResponseUsageInputTokensDetails. + + :ivar cached_tokens: Required. + :vartype cached_tokens: int + """ + + cached_tokens: Required[int] + """Required.""" + + +class ResponseUsageOutputTokensDetails(TypedDict, total=False): + """ResponseUsageOutputTokensDetails. + + :ivar reasoning_tokens: Required. + :vartype reasoning_tokens: int + """ + + reasoning_tokens: Required[int] + """Required.""" + + +class SASCredentials(TypedDict, total=False): + """Shared Access Signature (SAS) credential definition. + + :ivar type: The credential type. Required. Shared Access Signature (SAS) credential. + :vartype type: str or ~azure.ai.projects.models.SAS + :ivar sas_token: SAS token. + :vartype sas_token: str + """ + + type: Required[Literal[CredentialType.SAS]] + """The credential type. Required. Shared Access Signature (SAS) credential.""" + SAS: str + """SAS token.""" + + +class Schedule(TypedDict, total=False): + """Schedule model. + + :ivar schedule_id: Identifier of the schedule. Required. + :vartype schedule_id: str + :ivar display_name: Name of the schedule. + :vartype display_name: str + :ivar description: Description of the schedule. + :vartype description: str + :ivar enabled: Enabled status of the schedule. Required. + :vartype enabled: bool + :ivar provisioning_status: Provisioning status of the schedule. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", and "Failed". + :vartype provisioning_status: str or ~azure.ai.projects.models.ScheduleProvisioningStatus + :ivar trigger: Trigger for the schedule. Required. + :vartype trigger: ~azure.ai.projects.types.Trigger + :ivar task: Task for the schedule. Required. + :vartype task: ~azure.ai.projects.types.ScheduleTask + :ivar tags: Schedule's tags. Unlike properties, tags are fully mutable. + :vartype tags: dict[str, str] + :ivar properties: Schedule's properties. Unlike tags, properties are add-only. Once added, a + property cannot be removed. + :vartype properties: dict[str, str] + :ivar system_data: System metadata for the resource. Required. + :vartype system_data: dict[str, str] + """ + + id: Required[str] + """Identifier of the schedule. Required.""" + displayName: str + """Name of the schedule.""" + description: str + """Description of the schedule.""" + enabled: Required[bool] + """Enabled status of the schedule. Required.""" + provisioningStatus: ScheduleProvisioningStatus + """Provisioning status of the schedule. Known values are: \"Creating\", \"Updating\", + \"Deleting\", \"Succeeded\", and \"Failed\".""" + trigger: Required["Trigger"] + """Trigger for the schedule. Required.""" + task: Required["ScheduleTask"] + """Task for the schedule. Required.""" + tags: dict[str, str] + """Schedule's tags. Unlike properties, tags are fully mutable.""" + properties: dict[str, str] + """Schedule's properties. Unlike tags, properties are add-only. Once added, a property cannot be + removed.""" + systemData: Required[dict[str, str]] + """System metadata for the resource. Required.""" + + +class ScheduleRun(TypedDict, total=False): + """Schedule run model. + + :ivar run_id: Identifier of the schedule run. Required. + :vartype run_id: str + :ivar schedule_id: Identifier of the schedule. Required. + :vartype schedule_id: str + :ivar success: Trigger success status of the schedule run. Required. + :vartype success: bool + :ivar trigger_time: Trigger time of the schedule run. + :vartype trigger_time: ~datetime.datetime + :ivar error: Error information for the schedule run. + :vartype error: str + :ivar properties: Properties of the schedule run. Required. + :vartype properties: dict[str, str] + """ + + id: Required[str] + """Identifier of the schedule run. Required.""" + scheduleId: Required[str] + """Identifier of the schedule. Required.""" + success: Required[bool] + """Trigger success status of the schedule run. Required.""" + triggerTime: str + """Trigger time of the schedule run.""" + error: str + """Error information for the schedule run.""" + properties: Required[dict[str, str]] + """Properties of the schedule run. Required.""" + + +class SharepointGroundingToolParameters(TypedDict, total=False): + """The sharepoint grounding tool parameters. + + :ivar project_connections: The project connections attached to this tool. There can be a + maximum of 1 connection resource attached to the tool. + :vartype project_connections: list[~azure.ai.projects.types.ToolProjectConnection] + """ + + project_connections: list["ToolProjectConnection"] + """The project connections attached to this tool. There can be a maximum of 1 connection resource + attached to the tool.""" + + +class SharepointPreviewTool(TypedDict, total=False): + """The input definition information for a sharepoint tool as used to configure an agent. + + :ivar type: The object type, which is always 'sharepoint_grounding_preview'. Required. + SHAREPOINT_GROUNDING_PREVIEW. + :vartype type: str or ~azure.ai.projects.models.SHAREPOINT_GROUNDING_PREVIEW + :ivar sharepoint_grounding_preview: The sharepoint grounding tool parameters. Required. + :vartype sharepoint_grounding_preview: + ~azure.ai.projects.types.SharepointGroundingToolParameters + """ + + type: Required[Literal[ToolType.SHAREPOINT_GROUNDING_PREVIEW]] + """The object type, which is always 'sharepoint_grounding_preview'. Required. + SHAREPOINT_GROUNDING_PREVIEW.""" + sharepoint_grounding_preview: Required["SharepointGroundingToolParameters"] + """The sharepoint grounding tool parameters. Required.""" + + +class SkillReferenceParam(TypedDict, total=False): + """SkillReferenceParam. + + :ivar type: References a skill created with the /v1/skills endpoint. Required. SKILL_REFERENCE. + :vartype type: str or ~azure.ai.projects.models.SKILL_REFERENCE + :ivar skill_id: The ID of the referenced skill. Required. + :vartype skill_id: str + :ivar version: Optional skill version. Use a positive integer or 'latest'. Omit for default. + :vartype version: str + """ + + type: Required[Literal[ContainerSkillType.SKILL_REFERENCE]] + """References a skill created with the /v1/skills endpoint. Required. SKILL_REFERENCE.""" + skill_id: Required[str] + """The ID of the referenced skill. Required.""" + version: str + """Optional skill version. Use a positive integer or 'latest'. Omit for default.""" + + +class SpecificApplyPatchParam(TypedDict, total=False): + """Specific apply patch tool choice. + + :ivar type: The tool to call. Always ``apply_patch``. Required. APPLY_PATCH. + :vartype type: str or ~azure.ai.projects.models.APPLY_PATCH + """ + + type: Required[Literal[ToolChoiceParamType.APPLY_PATCH]] + """The tool to call. Always ``apply_patch``. Required. APPLY_PATCH.""" + + +class SpecificFunctionShellParam(TypedDict, total=False): + """Specific shell tool choice. + + :ivar type: The tool to call. Always ``shell``. Required. SHELL. + :vartype type: str or ~azure.ai.projects.models.SHELL + """ + + type: Required[Literal[ToolChoiceParamType.SHELL]] + """The tool to call. Always ``shell``. Required. SHELL.""" + + +class StructuredInputDefinition(TypedDict, total=False): + """An structured input that can participate in prompt template substitutions and tool argument + binding. + + :ivar description: A human-readable description of the input. + :vartype description: str + :ivar default_value: The default value for the input if no run-time value is provided. + :vartype default_value: any + :ivar schema: The JSON schema for the structured input (optional). + :vartype schema: dict[str, any] + :ivar required: Whether the input property is required when the agent is invoked. + :vartype required: bool + """ + + description: str + """A human-readable description of the input.""" + default_value: Any + """The default value for the input if no run-time value is provided.""" + schema: dict[str, Any] + """The JSON schema for the structured input (optional).""" + required: bool + """Whether the input property is required when the agent is invoked.""" + + +class StructuredOutputDefinition(TypedDict, total=False): + """A structured output that can be produced by the agent. + + :ivar name: The name of the structured output. Required. + :vartype name: str + :ivar description: A description of the output to emit. Used by the model to determine when to + emit the output. Required. + :vartype description: str + :ivar schema: The JSON schema for the structured output. Required. + :vartype schema: dict[str, any] + :ivar strict: Whether to enforce strict validation. Default ``true``. Required. + :vartype strict: bool + """ + + name: Required[str] + """The name of the structured output. Required.""" + description: Required[str] + """A description of the output to emit. Used by the model to determine when to emit the output. + Required.""" + schema: Required[dict[str, Any]] + """The JSON schema for the structured output. Required.""" + strict: Required[Optional[bool]] + """Whether to enforce strict validation. Default ``true``. Required.""" + + +class TaxonomyCategory(TypedDict, total=False): + """Taxonomy category definition. + + :ivar id: Unique identifier of the taxonomy category. Required. + :vartype id: str + :ivar name: Name of the taxonomy category. Required. + :vartype name: str + :ivar description: Description of the taxonomy category. + :vartype description: str + :ivar risk_category: Risk category associated with this taxonomy category. Required. Known + values are: "HateUnfairness", "Violence", "Sexual", "SelfHarm", "ProtectedMaterial", + "CodeVulnerability", "UngroundedAttributes", "ProhibitedActions", "SensitiveDataLeakage", and + "TaskAdherence". + :vartype risk_category: str or ~azure.ai.projects.models.RiskCategory + :ivar sub_categories: List of taxonomy sub categories. Required. + :vartype sub_categories: list[~azure.ai.projects.types.TaxonomySubCategory] + :ivar properties: Additional properties for the taxonomy category. + :vartype properties: dict[str, str] + """ + + id: Required[str] + """Unique identifier of the taxonomy category. Required.""" + name: Required[str] + """Name of the taxonomy category. Required.""" + description: str + """Description of the taxonomy category.""" + riskCategory: Required[RiskCategory] + """Risk category associated with this taxonomy category. Required. Known values are: + \"HateUnfairness\", \"Violence\", \"Sexual\", \"SelfHarm\", \"ProtectedMaterial\", + \"CodeVulnerability\", \"UngroundedAttributes\", \"ProhibitedActions\", + \"SensitiveDataLeakage\", and \"TaskAdherence\".""" + subCategories: Required[list["TaxonomySubCategory"]] + """List of taxonomy sub categories. Required.""" + properties: dict[str, str] + """Additional properties for the taxonomy category.""" + + +class TaxonomySubCategory(TypedDict, total=False): + """Taxonomy sub-category definition. + + :ivar id: Unique identifier of the taxonomy sub-category. Required. + :vartype id: str + :ivar name: Name of the taxonomy sub-category. Required. + :vartype name: str + :ivar description: Description of the taxonomy sub-category. + :vartype description: str + :ivar enabled: List of taxonomy items under this sub-category. Required. + :vartype enabled: bool + :ivar properties: Additional properties for the taxonomy sub-category. + :vartype properties: dict[str, str] + """ + + id: Required[str] + """Unique identifier of the taxonomy sub-category. Required.""" + name: Required[str] + """Name of the taxonomy sub-category. Required.""" + description: str + """Description of the taxonomy sub-category.""" + enabled: Required[bool] + """List of taxonomy items under this sub-category. Required.""" + properties: dict[str, str] + """Additional properties for the taxonomy sub-category.""" + + +class TextResponseFormatJsonObject(TypedDict, total=False): + """JSON object. + + :ivar type: The type of response format being defined. Always ``json_object``. Required. + JSON_OBJECT. + :vartype type: str or ~azure.ai.projects.models.JSON_OBJECT + """ + + type: Required[Literal[TextResponseFormatConfigurationType.JSON_OBJECT]] + """The type of response format being defined. Always ``json_object``. Required. JSON_OBJECT.""" + + +class TextResponseFormatJsonSchema(TypedDict, total=False): + """JSON schema. + + :ivar type: The type of response format being defined. Always ``json_schema``. Required. + JSON_SCHEMA. + :vartype type: str or ~azure.ai.projects.models.JSON_SCHEMA + :ivar description: A description of what the response format is for, used by the model to + determine how to respond in the format. + :vartype description: str + :ivar name: The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and + dashes, with a maximum length of 64. Required. + :vartype name: str + :ivar schema: Required. + :vartype schema: dict[str, any] + :ivar strict: + :vartype strict: bool + """ + + type: Required[Literal[TextResponseFormatConfigurationType.JSON_SCHEMA]] + """The type of response format being defined. Always ``json_schema``. Required. JSON_SCHEMA.""" + description: str + """A description of what the response format is for, used by the model to determine how to respond + in the format.""" + name: Required[str] + """The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with + a maximum length of 64. Required.""" + schema: Required[dict[str, Any]] + """Required.""" + strict: Optional[bool] + + +class TextResponseFormatText(TypedDict, total=False): + """Text. + + :ivar type: The type of response format being defined. Always ``text``. Required. TEXT. + :vartype type: str or ~azure.ai.projects.models.TEXT + """ + + type: Required[Literal[TextResponseFormatConfigurationType.TEXT]] + """The type of response format being defined. Always ``text``. Required. TEXT.""" + + +class ToolChoiceAllowed(TypedDict, total=False): + """Allowed tools. + + :ivar type: Allowed tool configuration type. Always ``allowed_tools``. Required. ALLOWED_TOOLS. + :vartype type: str or ~azure.ai.projects.models.ALLOWED_TOOLS + :ivar mode: Constrains the tools available to the model to a pre-defined set. ``auto`` allows + the model to pick from among the allowed tools and generate a message. ``required`` requires + the model to call one or more of the allowed tools. Required. Is either a Literal["auto"] type + or a Literal["required"] type. + :vartype mode: str or str + :ivar tools: A list of tool definitions that the model should be allowed to call. For the + Responses API, the list of tool definitions might look like: + + .. code-block:: json + + [ + { "type": "function", "name": "get_weather" }, + { "type": "mcp", "server_label": "deepwiki" }, + { "type": "image_generation" } + ]. Required. + :vartype tools: list[dict[str, any]] + """ + + type: Required[Literal[ToolChoiceParamType.ALLOWED_TOOLS]] + """Allowed tool configuration type. Always ``allowed_tools``. Required. ALLOWED_TOOLS.""" + mode: Required[Literal["auto", "required"]] + """Constrains the tools available to the model to a pre-defined set. ``auto`` allows the model to + pick from among the allowed tools and generate a message. ``required`` requires the model to + call one or more of the allowed tools. Required. Is either a Literal[\"auto\"] type or a + Literal[\"required\"] type.""" + tools: Required[list[dict[str, Any]]] + """A list of tool definitions that the model should be allowed to call. For the Responses API, the + list of tool definitions might look like: + + .. code-block:: json + + [ + { \"type\": \"function\", \"name\": \"get_weather\" }, + { \"type\": \"mcp\", \"server_label\": \"deepwiki\" }, + { \"type\": \"image_generation\" } + ]. Required.""" + + +class ToolChoiceCodeInterpreter(TypedDict, total=False): + """Indicates that the model should use a built-in tool to generate a response. `Learn more about + built-in tools `_. + + :ivar type: Required. CODE_INTERPRETER. + :vartype type: str or ~azure.ai.projects.models.CODE_INTERPRETER + """ + + type: Required[Literal[ToolChoiceParamType.CODE_INTERPRETER]] + """Required. CODE_INTERPRETER.""" + + +class ToolChoiceComputerUsePreview(TypedDict, total=False): + """Indicates that the model should use a built-in tool to generate a response. `Learn more about + built-in tools `_. + + :ivar type: Required. COMPUTER_USE_PREVIEW. + :vartype type: str or ~azure.ai.projects.models.COMPUTER_USE_PREVIEW + """ + + type: Required[Literal[ToolChoiceParamType.COMPUTER_USE_PREVIEW]] + """Required. COMPUTER_USE_PREVIEW.""" + + +class ToolChoiceCustom(TypedDict, total=False): + """Custom tool. + + :ivar type: For custom tool calling, the type is always ``custom``. Required. CUSTOM. + :vartype type: str or ~azure.ai.projects.models.CUSTOM + :ivar name: The name of the custom tool to call. Required. + :vartype name: str + """ + + type: Required[Literal[ToolChoiceParamType.CUSTOM]] + """For custom tool calling, the type is always ``custom``. Required. CUSTOM.""" + name: Required[str] + """The name of the custom tool to call. Required.""" + + +class ToolChoiceFileSearch(TypedDict, total=False): + """Indicates that the model should use a built-in tool to generate a response. `Learn more about + built-in tools `_. + + :ivar type: Required. FILE_SEARCH. + :vartype type: str or ~azure.ai.projects.models.FILE_SEARCH + """ + + type: Required[Literal[ToolChoiceParamType.FILE_SEARCH]] + """Required. FILE_SEARCH.""" + + +class ToolChoiceFunction(TypedDict, total=False): + """Function tool. + + :ivar type: For function calling, the type is always ``function``. Required. FUNCTION. + :vartype type: str or ~azure.ai.projects.models.FUNCTION + :ivar name: The name of the function to call. Required. + :vartype name: str + """ + + type: Required[Literal[ToolChoiceParamType.FUNCTION]] + """For function calling, the type is always ``function``. Required. FUNCTION.""" + name: Required[str] + """The name of the function to call. Required.""" + + +class ToolChoiceImageGeneration(TypedDict, total=False): + """Indicates that the model should use a built-in tool to generate a response. `Learn more about + built-in tools `_. + + :ivar type: Required. IMAGE_GENERATION. + :vartype type: str or ~azure.ai.projects.models.IMAGE_GENERATION + """ + + type: Required[Literal[ToolChoiceParamType.IMAGE_GENERATION]] + """Required. IMAGE_GENERATION.""" + + +class ToolChoiceMCP(TypedDict, total=False): + """MCP tool. + + :ivar type: For MCP tools, the type is always ``mcp``. Required. MCP. + :vartype type: str or ~azure.ai.projects.models.MCP + :ivar server_label: The label of the MCP server to use. Required. + :vartype server_label: str + :ivar name: + :vartype name: str + """ + + type: Required[Literal[ToolChoiceParamType.MCP]] + """For MCP tools, the type is always ``mcp``. Required. MCP.""" + server_label: Required[str] + """The label of the MCP server to use. Required.""" + name: Optional[str] + + +class ToolChoiceWebSearchPreview(TypedDict, total=False): + """Indicates that the model should use a built-in tool to generate a response. `Learn more about + built-in tools `_. + + :ivar type: Required. WEB_SEARCH_PREVIEW. + :vartype type: str or ~azure.ai.projects.models.WEB_SEARCH_PREVIEW + """ + + type: Required[Literal[ToolChoiceParamType.WEB_SEARCH_PREVIEW]] + """Required. WEB_SEARCH_PREVIEW.""" + + +class ToolChoiceWebSearchPreview20250311(TypedDict, total=False): + """Indicates that the model should use a built-in tool to generate a response. `Learn more about + built-in tools `_. + + :ivar type: Required. WEB_SEARCH_PREVIEW2025_03_11. + :vartype type: str or ~azure.ai.projects.models.WEB_SEARCH_PREVIEW2025_03_11 + """ + + type: Required[Literal[ToolChoiceParamType.WEB_SEARCH_PREVIEW2025_03_11]] + """Required. WEB_SEARCH_PREVIEW2025_03_11.""" + + +class ToolDescription(TypedDict, total=False): + """Description of a tool that can be used by an agent. + + :ivar name: The name of the tool. + :vartype name: str + :ivar description: A brief description of the tool's purpose. + :vartype description: str + """ + + name: str + """The name of the tool.""" + description: str + """A brief description of the tool's purpose.""" + + +class ToolProjectConnection(TypedDict, total=False): + """A project connection resource. + + :ivar project_connection_id: A project connection in a ToolProjectConnectionList attached to + this tool. Required. + :vartype project_connection_id: str + """ + + project_connection_id: Required[str] + """A project connection in a ToolProjectConnectionList attached to this tool. Required.""" + + +class UserProfileMemoryItem(TypedDict, total=False): + """A memory item specifically containing user profile information extracted from conversations, + such as preferences, interests, and personal details. + + :ivar memory_id: The unique ID of the memory item. Required. + :vartype memory_id: str + :ivar updated_at: The last update time of the memory item. Required. + :vartype updated_at: ~datetime.datetime + :ivar scope: The namespace that logically groups and isolates memories, such as a user ID. + Required. + :vartype scope: str + :ivar content: The content of the memory. Required. + :vartype content: str + :ivar kind: The kind of the memory item. Required. User profile information extracted from + conversations. + :vartype kind: str or ~azure.ai.projects.models.USER_PROFILE + """ + + memory_id: Required[str] + """The unique ID of the memory item. Required.""" + updated_at: Required[int] + """The last update time of the memory item. Required.""" + scope: Required[str] + """The namespace that logically groups and isolates memories, such as a user ID. Required.""" + content: Required[str] + """The content of the memory. Required.""" + kind: Required[Literal[MemoryItemKind.USER_PROFILE]] + """The kind of the memory item. Required. User profile information extracted from conversations.""" + + +class WebSearchApproximateLocation(TypedDict, total=False): + """Web search approximate location. + + :ivar type: The type of location approximation. Always ``approximate``. Required. Default value + is "approximate". + :vartype type: str + :ivar country: + :vartype country: str + :ivar region: + :vartype region: str + :ivar city: + :vartype city: str + :ivar timezone: + :vartype timezone: str + """ + + type: Required[Literal["approximate"]] + """The type of location approximation. Always ``approximate``. Required. Default value is + \"approximate\".""" + country: Optional[str] + region: Optional[str] + city: Optional[str] + timezone: Optional[str] + + +class WebSearchConfiguration(TypedDict, total=False): + """A web search configuration for bing custom search. + + :ivar project_connection_id: Project connection id for grounding with bing custom search. + Required. + :vartype project_connection_id: str + :ivar instance_name: Name of the custom configuration instance given to config. Required. + :vartype instance_name: str + """ + + project_connection_id: Required[str] + """Project connection id for grounding with bing custom search. Required.""" + instance_name: Required[str] + """Name of the custom configuration instance given to config. Required.""" + + +class WebSearchPreviewTool(TypedDict, total=False): + """Web search preview. + + :ivar type: The type of the web search tool. One of ``web_search_preview`` or + ``web_search_preview_2025_03_11``. Required. WEB_SEARCH_PREVIEW. + :vartype type: str or ~azure.ai.projects.models.WEB_SEARCH_PREVIEW + :ivar user_location: + :vartype user_location: ~azure.ai.projects.types.ApproximateLocation + :ivar search_context_size: High level guidance for the amount of context window space to use + for the search. One of ``low``, ``medium``, or ``high``. ``medium`` is the default. Known + values are: "low", "medium", and "high". + :vartype search_context_size: str or ~azure.ai.projects.models.SearchContextSize + """ + + type: Required[Literal[ToolType.WEB_SEARCH_PREVIEW]] + """The type of the web search tool. One of ``web_search_preview`` or + ``web_search_preview_2025_03_11``. Required. WEB_SEARCH_PREVIEW.""" + user_location: Optional["ApproximateLocation"] + search_context_size: SearchContextSize + """High level guidance for the amount of context window space to use for the search. One of + ``low``, ``medium``, or ``high``. ``medium`` is the default. Known values are: \"low\", + \"medium\", and \"high\".""" + + +class WebSearchTool(TypedDict, total=False): + """Web search. + + :ivar type: The type of the web search tool. One of ``web_search`` or + ``web_search_2025_08_26``. Required. WEB_SEARCH. + :vartype type: str or ~azure.ai.projects.models.WEB_SEARCH + :ivar filters: + :vartype filters: ~azure.ai.projects.types.WebSearchToolFilters + :ivar user_location: + :vartype user_location: ~azure.ai.projects.types.WebSearchApproximateLocation + :ivar search_context_size: High level guidance for the amount of context window space to use + for the search. One of ``low``, ``medium``, or ``high``. ``medium`` is the default. Is one of + the following types: Literal["low"], Literal["medium"], Literal["high"] + :vartype search_context_size: str or str or str + :ivar custom_search_configuration: The project connections attached to this tool. There can be + a maximum of 1 connection resource attached to the tool. + :vartype custom_search_configuration: ~azure.ai.projects.types.WebSearchConfiguration + """ + + type: Required[Literal[ToolType.WEB_SEARCH]] + """The type of the web search tool. One of ``web_search`` or ``web_search_2025_08_26``. Required. + WEB_SEARCH.""" + filters: Optional["WebSearchToolFilters"] + user_location: Optional["WebSearchApproximateLocation"] + search_context_size: Literal["low", "medium", "high"] + """High level guidance for the amount of context window space to use for the search. One of + ``low``, ``medium``, or ``high``. ``medium`` is the default. Is one of the following types: + Literal[\"low\"], Literal[\"medium\"], Literal[\"high\"]""" + custom_search_configuration: "WebSearchConfiguration" + """The project connections attached to this tool. There can be a maximum of 1 connection resource + attached to the tool.""" + + +class WebSearchToolFilters(TypedDict, total=False): + """WebSearchToolFilters. + + :ivar allowed_domains: + :vartype allowed_domains: list[str] + """ + + allowed_domains: Optional[list[str]] + + +class WeeklyRecurrenceSchedule(TypedDict, total=False): + """Weekly recurrence schedule. + + :ivar type: Weekly recurrence type. Required. Weekly recurrence pattern. + :vartype type: str or ~azure.ai.projects.models.WEEKLY + :ivar days_of_week: Days of the week for the recurrence schedule. Required. + :vartype days_of_week: list[str or ~azure.ai.projects.models.DayOfWeek] + """ + + type: Required[Literal[RecurrenceType.WEEKLY]] + """Weekly recurrence type. Required. Weekly recurrence pattern.""" + daysOfWeek: Required[list[DayOfWeek]] + """Days of the week for the recurrence schedule. Required.""" + + +class WorkflowAgentDefinition(TypedDict, total=False): + """The workflow agent definition. + + :ivar rai_config: Configuration for Responsible AI (RAI) content filtering and safety features. + :vartype rai_config: ~azure.ai.projects.types.RaiConfig + :ivar kind: Required. WORKFLOW. + :vartype kind: str or ~azure.ai.projects.models.WORKFLOW + :ivar workflow: The CSDL YAML definition of the workflow. + :vartype workflow: str + """ + + rai_config: "RaiConfig" + """Configuration for Responsible AI (RAI) content filtering and safety features.""" + kind: Required[Literal[AgentKind.WORKFLOW]] + """Required. WORKFLOW.""" + workflow: str + """The CSDL YAML definition of the workflow.""" + + +Tool = Union[ + A2APreviewTool, + ApplyPatchToolParam, + AzureAISearchTool, + AzureFunctionTool, + BingCustomSearchPreviewTool, + BingGroundingTool, + BrowserAutomationPreviewTool, + CaptureStructuredOutputsTool, + CodeInterpreterTool, + ComputerUsePreviewTool, + CustomToolParam, + MicrosoftFabricPreviewTool, + FileSearchTool, + FunctionTool, + ImageGenTool, + LocalShellToolParam, + MCPTool, + MemorySearchPreviewTool, + OpenApiTool, + SharepointPreviewTool, + FunctionShellToolParam, + WebSearchTool, + WebSearchPreviewTool, +] +InsightRequest = Union[ + AgentClusterInsightRequest, EvaluationComparisonInsightRequest, EvaluationRunClusterInsightRequest +] +InsightResult = Union[AgentClusterInsightResult, EvaluationComparisonInsightResult, EvaluationRunClusterInsightResult] +AgentDefinition = Union[HostedAgentDefinition, PromptAgentDefinition, WorkflowAgentDefinition] +BaseCredentials = Union[ + EntraIDCredentials, + AgenticIdentityPreviewCredentials, + ApiKeyCredentials, + CustomCredential, + NoAuthenticationCredentials, + SASCredentials, +] +EvaluationTaxonomyInput = Union[AgentTaxonomyInput] +Target = Union[AzureAIAgentTarget, AzureAIModelTarget] +Index = Union[AzureAISearchIndex, CosmosDBIndex, ManagedAzureAISearchIndex] +TargetConfig = Union[AzureOpenAIModelConfiguration] +MemoryItem = Union[ChatSummaryMemoryItem, UserProfileMemoryItem] +EvaluatorDefinition = Union[CodeBasedEvaluatorDefinition, PromptBasedEvaluatorDefinition] +FunctionShellToolParamEnvironment = Union[ + ContainerAutoParam, + FunctionShellToolParamEnvironmentContainerReferenceParam, + FunctionShellToolParamEnvironmentLocalEnvironmentParam, +] +ContainerNetworkPolicyParam = Union[ContainerNetworkPolicyAllowlistParam, ContainerNetworkPolicyDisabledParam] +ContainerSkill = Union[InlineSkillParam, SkillReferenceParam] +EvaluationRuleAction = Union[ContinuousEvaluationRuleAction, HumanEvaluationPreviewRuleAction] +Trigger = Union[CronTrigger, OneTimeTrigger, RecurrenceTrigger] +CustomToolParamFormat = Union[CustomGrammarFormatParam, CustomTextFormatParam] +RecurrenceSchedule = Union[ + DailyRecurrenceSchedule, HourlyRecurrenceSchedule, MonthlyRecurrenceSchedule, WeeklyRecurrenceSchedule +] +DatasetVersion = Union[FileDatasetVersion, FolderDatasetVersion] +Deployment = Union[ModelDeployment] +InsightSample = Union[EvaluationResultSample] +ScheduleTask = Union[EvaluationScheduleTask, InsightScheduleTask] +MemoryStoreDefinition = Union[MemoryStoreDefaultDefinition] +OpenApiAuthDetails = Union[OpenApiAnonymousAuthDetails, OpenApiManagedAuthDetails, OpenApiProjectConnectionAuthDetails] +ToolChoiceParam = Union[ + ToolChoiceAllowed, + SpecificApplyPatchParam, + ToolChoiceCodeInterpreter, + ToolChoiceComputerUsePreview, + ToolChoiceCustom, + ToolChoiceFileSearch, + ToolChoiceFunction, + ToolChoiceImageGeneration, + ToolChoiceMCP, + SpecificFunctionShellParam, + ToolChoiceWebSearchPreview, + ToolChoiceWebSearchPreview20250311, +] +TextResponseFormat = Union[TextResponseFormatJsonObject, TextResponseFormatJsonSchema, TextResponseFormatText] From f89936232496f29e84f2ae75491769ab21b9ce9d Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Wed, 17 Jun 2026 15:16:51 -0400 Subject: [PATCH 3/5] switch to agentserver only --- .../_metadata.json | 6 + .../apiview-properties.json | 77 + .../agentserver/responses/models/_client.py | 110 + .../responses/models/_configuration.py | 69 + .../ai/agentserver/responses/models/_patch.py | 21 + .../agentserver/responses/models/_unions.py | 71 + .../responses/models/_utils/__init__.py | 6 + .../responses/models/_utils/serialization.py | 2066 ++++ .../agentserver/responses/models/_version.py | 9 + .../responses/models/aio/__init__.py | 30 + .../responses/models/aio/_client.py | 114 + .../responses/models/aio/_configuration.py | 71 + .../responses/models/aio/_patch.py | 21 + .../models/aio/operations/__init__.py | 25 + .../models/aio/operations/_operations.py | 3532 ++++++ .../responses/models/aio/operations/_patch.py | 21 + .../responses/models/models/__init__.py | 21 + .../responses/models/models/_patch.py | 21 + .../responses/models/operations/__init__.py | 25 + .../models/operations/_operations.py | 3762 ++++++ .../responses/models/operations/_patch.py | 21 + .../ai/agentserver/responses/models/py.typed | 1 + .../ai/agentserver/responses/models/types.py | 10134 ++++++++++++++++ 23 files changed, 20234 insertions(+) create mode 100644 sdk/agentserver/azure-ai-agentserver-responses/_metadata.json create mode 100644 sdk/agentserver/azure-ai-agentserver-responses/apiview-properties.json create mode 100644 sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/_client.py create mode 100644 sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/_configuration.py create mode 100644 sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/_patch.py create mode 100644 sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/_unions.py create mode 100644 sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/_utils/__init__.py create mode 100644 sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/_utils/serialization.py create mode 100644 sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/_version.py create mode 100644 sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/aio/__init__.py create mode 100644 sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/aio/_client.py create mode 100644 sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/aio/_configuration.py create mode 100644 sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/aio/_patch.py create mode 100644 sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/aio/operations/__init__.py create mode 100644 sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/aio/operations/_operations.py create mode 100644 sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/aio/operations/_patch.py create mode 100644 sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/models/__init__.py create mode 100644 sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/models/_patch.py create mode 100644 sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/operations/__init__.py create mode 100644 sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/operations/_operations.py create mode 100644 sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/operations/_patch.py create mode 100644 sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/py.typed create mode 100644 sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/types.py diff --git a/sdk/agentserver/azure-ai-agentserver-responses/_metadata.json b/sdk/agentserver/azure-ai-agentserver-responses/_metadata.json new file mode 100644 index 000000000000..d5e9ee4c04bb --- /dev/null +++ b/sdk/agentserver/azure-ai-agentserver-responses/_metadata.json @@ -0,0 +1,6 @@ +{ + "apiVersion": "virtual-public-preview", + "apiVersions": { + "Azure.AI.Projects": "virtual-public-preview" + } +} \ No newline at end of file diff --git a/sdk/agentserver/azure-ai-agentserver-responses/apiview-properties.json b/sdk/agentserver/azure-ai-agentserver-responses/apiview-properties.json new file mode 100644 index 000000000000..204a4452fc7b --- /dev/null +++ b/sdk/agentserver/azure-ai-agentserver-responses/apiview-properties.json @@ -0,0 +1,77 @@ +{ + "CrossLanguagePackageId": "Azure.AI.Projects", + "CrossLanguageDefinitionId": { + "azure.ai.agentserver.responses.models.models.TextResponseFormatConfigurationType": "OpenAI.TextResponseFormatConfigurationType", + "azure.ai.agentserver.responses.models.models.ToolType": "OpenAI.ToolType", + "azure.ai.agentserver.responses.models.models.AzureAISearchQueryType": "Azure.AI.Projects.AzureAISearchQueryType", + "azure.ai.agentserver.responses.models.models.ContainerMemoryLimit": "OpenAI.ContainerMemoryLimit", + "azure.ai.agentserver.responses.models.models.ContainerNetworkPolicyParamType": "OpenAI.ContainerNetworkPolicyParamType", + "azure.ai.agentserver.responses.models.models.ComputerEnvironment": "OpenAI.ComputerEnvironment", + "azure.ai.agentserver.responses.models.models.CustomToolParamFormatType": "OpenAI.CustomToolParamFormatType", + "azure.ai.agentserver.responses.models.models.GrammarSyntax1": "OpenAI.GrammarSyntax1", + "azure.ai.agentserver.responses.models.models.RankerVersionType": "OpenAI.RankerVersionType", + "azure.ai.agentserver.responses.models.models.InputFidelity": "OpenAI.InputFidelity", + "azure.ai.agentserver.responses.models.models.ImageGenActionEnum": "OpenAI.ImageGenActionEnum", + "azure.ai.agentserver.responses.models.models.OpenApiAuthType": "Azure.AI.Projects.OpenApiAuthType", + "azure.ai.agentserver.responses.models.models.FunctionShellToolParamEnvironmentType": "OpenAI.FunctionShellToolParamEnvironmentType", + "azure.ai.agentserver.responses.models.models.ContainerSkillType": "OpenAI.ContainerSkillType", + "azure.ai.agentserver.responses.models.models.SearchContextSize": "OpenAI.SearchContextSize", + "azure.ai.agentserver.responses.models.models.ToolChoiceOptions": "OpenAI.ToolChoiceOptions", + "azure.ai.agentserver.responses.models.models.ToolChoiceParamType": "OpenAI.ToolChoiceParamType", + "azure.ai.agentserver.responses.models.models.ResponseErrorCode": "OpenAI.ResponseErrorCode", + "azure.ai.agentserver.responses.models.models.OutputItemType": "OpenAI.OutputItemType", + "azure.ai.agentserver.responses.models.models.ToolCallStatus": "Azure.AI.Projects.ToolCallStatus", + "azure.ai.agentserver.responses.models.models.ApplyPatchCallStatus": "OpenAI.ApplyPatchCallStatus", + "azure.ai.agentserver.responses.models.models.ApplyPatchFileOperationType": "OpenAI.ApplyPatchFileOperationType", + "azure.ai.agentserver.responses.models.models.ApplyPatchCallOutputStatus": "OpenAI.ApplyPatchCallOutputStatus", + "azure.ai.agentserver.responses.models.models.ComputerActionType": "OpenAI.ComputerActionType", + "azure.ai.agentserver.responses.models.models.ClickButtonType": "OpenAI.ClickButtonType", + "azure.ai.agentserver.responses.models.models.FunctionAndCustomToolCallOutputType": "OpenAI.FunctionAndCustomToolCallOutputType", + "azure.ai.agentserver.responses.models.models.ImageDetail": "OpenAI.ImageDetail", + "azure.ai.agentserver.responses.models.models.MCPToolCallStatus": "OpenAI.MCPToolCallStatus", + "azure.ai.agentserver.responses.models.models.MemoryItemKind": "Azure.AI.Projects.MemoryItemKind", + "azure.ai.agentserver.responses.models.models.MessageStatus": "OpenAI.MessageStatus", + "azure.ai.agentserver.responses.models.models.MessageRole": "OpenAI.MessageRole", + "azure.ai.agentserver.responses.models.models.MessageContentType": "OpenAI.MessageContentType", + "azure.ai.agentserver.responses.models.models.AnnotationType": "OpenAI.AnnotationType", + "azure.ai.agentserver.responses.models.models.OutputMessageContentType": "OpenAI.OutputMessageContentType", + "azure.ai.agentserver.responses.models.models.LocalShellCallStatus": "OpenAI.LocalShellCallStatus", + "azure.ai.agentserver.responses.models.models.FunctionShellCallEnvironmentType": "OpenAI.FunctionShellCallEnvironmentType", + "azure.ai.agentserver.responses.models.models.LocalShellCallOutputStatusEnum": "OpenAI.LocalShellCallOutputStatusEnum", + "azure.ai.agentserver.responses.models.models.FunctionShellCallOutputOutcomeType": "OpenAI.FunctionShellCallOutputOutcomeType", + "azure.ai.agentserver.responses.models.models.ItemType": "OpenAI.ItemType", + "azure.ai.agentserver.responses.models.models.ApplyPatchCallStatusParam": "OpenAI.ApplyPatchCallStatusParam", + "azure.ai.agentserver.responses.models.models.ApplyPatchOperationParamType": "OpenAI.ApplyPatchOperationParamType", + "azure.ai.agentserver.responses.models.models.ApplyPatchCallOutputStatusParam": "OpenAI.ApplyPatchCallOutputStatusParam", + "azure.ai.agentserver.responses.models.models.FunctionCallItemStatus": "OpenAI.FunctionCallItemStatus", + "azure.ai.agentserver.responses.models.models.DetailEnum": "OpenAI.DetailEnum", + "azure.ai.agentserver.responses.models.models.FunctionShellCallItemStatus": "OpenAI.FunctionShellCallItemStatus", + "azure.ai.agentserver.responses.models.models.FunctionShellCallItemParamEnvironmentType": "OpenAI.FunctionShellCallItemParamEnvironmentType", + "azure.ai.agentserver.responses.models.models.FunctionShellCallOutputOutcomeParamType": "OpenAI.FunctionShellCallOutputOutcomeParamType", + "azure.ai.agentserver.responses.models.models.IncludeEnum": "OpenAI.IncludeEnum", + "azure.ai.agentserver.responses.models.models.ResponseStreamEventType": "OpenAI.ResponseStreamEventType", + "azure.ai.agentserver.responses.models.models.OutputContentType": "OpenAI.OutputContentType", + "azure.ai.agentserver.responses.models.models.PageOrder": "Azure.AI.Projects.PageOrder", + "azure.ai.agentserver.responses.models.models.ItemFieldType": "OpenAI.ItemFieldType", + "azure.ai.agentserver.responses.models.models.ModelIdsCompaction": "OpenAI.ModelIdsCompaction", + "azure.ai.agentserver.responses.models.operations.ResponsesOperations.create_response": "Azure.AI.Projects.Responses.createResponse", + "azure.ai.agentserver.responses.models.aio.operations.ResponsesOperations.create_response": "Azure.AI.Projects.Responses.createResponse", + "azure.ai.agentserver.responses.models.operations.ResponsesOperations.create_response_stream": "Azure.AI.Projects.Responses.createResponseStream", + "azure.ai.agentserver.responses.models.aio.operations.ResponsesOperations.create_response_stream": "Azure.AI.Projects.Responses.createResponseStream", + "azure.ai.agentserver.responses.models.operations.ResponsesOperations.get_response": "Azure.AI.Projects.Responses.getResponse", + "azure.ai.agentserver.responses.models.aio.operations.ResponsesOperations.get_response": "Azure.AI.Projects.Responses.getResponse", + "azure.ai.agentserver.responses.models.operations.ResponsesOperations.get_response_stream": "Azure.AI.Projects.Responses.getResponseStream", + "azure.ai.agentserver.responses.models.aio.operations.ResponsesOperations.get_response_stream": "Azure.AI.Projects.Responses.getResponseStream", + "azure.ai.agentserver.responses.models.operations.ResponsesOperations.delete_response": "Azure.AI.Projects.Responses.deleteResponse", + "azure.ai.agentserver.responses.models.aio.operations.ResponsesOperations.delete_response": "Azure.AI.Projects.Responses.deleteResponse", + "azure.ai.agentserver.responses.models.operations.ResponsesOperations.cancel_response": "Azure.AI.Projects.Responses.cancelResponse", + "azure.ai.agentserver.responses.models.aio.operations.ResponsesOperations.cancel_response": "Azure.AI.Projects.Responses.cancelResponse", + "azure.ai.agentserver.responses.models.operations.ResponsesOperations.list_input_items": "Azure.AI.Projects.Responses.listInputItems", + "azure.ai.agentserver.responses.models.aio.operations.ResponsesOperations.list_input_items": "Azure.AI.Projects.Responses.listInputItems", + "azure.ai.agentserver.responses.models.operations.ResponsesOperations.list_responses": "Azure.AI.Projects.Responses.listResponses", + "azure.ai.agentserver.responses.models.aio.operations.ResponsesOperations.list_responses": "Azure.AI.Projects.Responses.listResponses", + "azure.ai.agentserver.responses.models.operations.ResponsesOperations.compact_response_conversation": "Azure.AI.Projects.Responses.compactResponseConversation", + "azure.ai.agentserver.responses.models.aio.operations.ResponsesOperations.compact_response_conversation": "Azure.AI.Projects.Responses.compactResponseConversation" + }, + "CrossLanguageVersion": "8daa8c9e22b2" +} \ No newline at end of file diff --git a/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/_client.py b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/_client.py new file mode 100644 index 000000000000..8e9304961d5e --- /dev/null +++ b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/_client.py @@ -0,0 +1,110 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +import sys +from typing import Any, TYPE_CHECKING, Union + +from azure.core import PipelineClient +from azure.core.credentials import AzureKeyCredential +from azure.core.pipeline import policies +from azure.core.rest import HttpRequest, HttpResponse + +from ._configuration import ProjectsClientConfiguration +from ._utils.serialization import Deserializer, Serializer +from .operations import ResponsesOperations + +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self # type: ignore + +if TYPE_CHECKING: + from azure.core.credentials import TokenCredential + + +class ProjectsClient: # pylint: disable=client-accepts-api-version-keyword + """ProjectsClient. + + :ivar responses: ResponsesOperations operations + :vartype responses: azure.ai.agentserver.responses.models.operations.ResponsesOperations + :param endpoint: Foundry Project endpoint in the form + "https://{ai-services-account-name}.services.ai.azure.com/api/projects/{project-name}". If you + only have one Project in your Foundry Hub, or to target the default Project in your Hub, use + the form "https://{ai-services-account-name}.services.ai.azure.com/api/projects/_project". + Required. + :type endpoint: str + :param credential: Credential used to authenticate requests to the service. Is either a key + credential type or a token credential type. Required. + :type credential: ~azure.core.credentials.AzureKeyCredential or + ~azure.core.credentials.TokenCredential + """ + + def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCredential"], **kwargs: Any) -> None: + _endpoint = "{endpoint}" + self._config = ProjectsClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) + + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs) + + self._serialize = Serializer() + self._deserialize = Deserializer() + self._serialize.client_side_validation = False + self.responses = ResponsesOperations(self._client, self._config, self._serialize, self._deserialize) + + def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore + + def close(self) -> None: + self._client.close() + + def __enter__(self) -> Self: + self._client.__enter__() + return self + + def __exit__(self, *exc_details: Any) -> None: + self._client.__exit__(*exc_details) diff --git a/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/_configuration.py b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/_configuration.py new file mode 100644 index 000000000000..d8003dceaa12 --- /dev/null +++ b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/_configuration.py @@ -0,0 +1,69 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING, Union + +from azure.core.credentials import AzureKeyCredential +from azure.core.pipeline import policies + +from ._version import VERSION + +if TYPE_CHECKING: + from azure.core.credentials import TokenCredential + + +class ProjectsClientConfiguration: # pylint: disable=too-many-instance-attributes + """Configuration for ProjectsClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param endpoint: Foundry Project endpoint in the form + "https://{ai-services-account-name}.services.ai.azure.com/api/projects/{project-name}". If you + only have one Project in your Foundry Hub, or to target the default Project in your Hub, use + the form "https://{ai-services-account-name}.services.ai.azure.com/api/projects/_project". + Required. + :type endpoint: str + :param credential: Credential used to authenticate requests to the service. Is either a key + credential type or a token credential type. Required. + :type credential: ~azure.core.credentials.AzureKeyCredential or + ~azure.core.credentials.TokenCredential + """ + + def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCredential"], **kwargs: Any) -> None: + if endpoint is None: + raise ValueError("Parameter 'endpoint' must not be None.") + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + + self.endpoint = endpoint + self.credential = credential + self.credential_scopes = kwargs.pop("credential_scopes", ["https://ai.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "ai-agentserver-responses/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) + self._configure(**kwargs) + + def _infer_policy(self, **kwargs): + if isinstance(self.credential, AzureKeyCredential): + return policies.AzureKeyCredentialPolicy(self.credential, "api-key", **kwargs) + if hasattr(self.credential, "get_token"): + return policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + raise TypeError(f"Unsupported credential: {self.credential}") + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") + if self.credential and not self.authentication_policy: + self.authentication_policy = self._infer_policy(**kwargs) diff --git a/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/_patch.py b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/_patch.py new file mode 100644 index 000000000000..87676c65a8f0 --- /dev/null +++ b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/_patch.py @@ -0,0 +1,21 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" + + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/_unions.py b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/_unions.py new file mode 100644 index 000000000000..d64fad734dab --- /dev/null +++ b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/_unions.py @@ -0,0 +1,71 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING, Union + +if TYPE_CHECKING: + from . import types as _types +Filters = Union["_types.ComparisonFilter", "_types.CompoundFilter"] +ToolCallOutputContent = Union[dict[str, Any], str, list[Any]] +InputParam = Union[str, list["_types.Item"]] +ConversationParam = Union[str, "_types.ConversationParam_2"] +CreateResponseStreamingResponse = Union[ + "_types.ResponseAudioDeltaEvent", + "_types.ResponseAudioTranscriptDeltaEvent", + "_types.ResponseCodeInterpreterCallCodeDeltaEvent", + "_types.ResponseCodeInterpreterCallInProgressEvent", + "_types.ResponseCodeInterpreterCallInterpretingEvent", + "_types.ResponseContentPartAddedEvent", + "_types.ResponseCreatedEvent", + "_types.ResponseErrorEvent", + "_types.ResponseFileSearchCallInProgressEvent", + "_types.ResponseFileSearchCallSearchingEvent", + "_types.ResponseFunctionCallArgumentsDeltaEvent", + "_types.ResponseInProgressEvent", + "_types.ResponseFailedEvent", + "_types.ResponseIncompleteEvent", + "_types.ResponseOutputItemAddedEvent", + "_types.ResponseReasoningSummaryPartAddedEvent", + "_types.ResponseReasoningSummaryTextDeltaEvent", + "_types.ResponseReasoningTextDeltaEvent", + "_types.ResponseRefusalDeltaEvent", + "_types.ResponseTextDeltaEvent", + "_types.ResponseWebSearchCallInProgressEvent", + "_types.ResponseWebSearchCallSearchingEvent", + "_types.ResponseImageGenCallGeneratingEvent", + "_types.ResponseImageGenCallInProgressEvent", + "_types.ResponseImageGenCallPartialImageEvent", + "_types.ResponseMCPCallArgumentsDeltaEvent", + "_types.ResponseMCPCallFailedEvent", + "_types.ResponseMCPCallInProgressEvent", + "_types.ResponseMCPListToolsFailedEvent", + "_types.ResponseMCPListToolsInProgressEvent", + "_types.ResponseOutputTextAnnotationAddedEvent", + "_types.ResponseQueuedEvent", + "_types.ResponseCustomToolCallInputDeltaEvent", + "_types.ResponseAudioDoneEvent", + "_types.ResponseAudioTranscriptDoneEvent", + "_types.ResponseCodeInterpreterCallCodeDoneEvent", + "_types.ResponseCodeInterpreterCallCompletedEvent", + "_types.ResponseCompletedEvent", + "_types.ResponseContentPartDoneEvent", + "_types.ResponseFileSearchCallCompletedEvent", + "_types.ResponseFunctionCallArgumentsDoneEvent", + "_types.ResponseOutputItemDoneEvent", + "_types.ResponseReasoningSummaryPartDoneEvent", + "_types.ResponseReasoningSummaryTextDoneEvent", + "_types.ResponseReasoningTextDoneEvent", + "_types.ResponseRefusalDoneEvent", + "_types.ResponseTextDoneEvent", + "_types.ResponseWebSearchCallCompletedEvent", + "_types.ResponseImageGenCallCompletedEvent", + "_types.ResponseMCPCallArgumentsDoneEvent", + "_types.ResponseMCPCallCompletedEvent", + "_types.ResponseMCPListToolsCompletedEvent", + "_types.ResponseCustomToolCallInputDoneEvent", +] diff --git a/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/_utils/__init__.py b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/_utils/__init__.py new file mode 100644 index 000000000000..8026245c2abc --- /dev/null +++ b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/_utils/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- diff --git a/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/_utils/serialization.py b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/_utils/serialization.py new file mode 100644 index 000000000000..a088671e9c51 --- /dev/null +++ b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/_utils/serialization.py @@ -0,0 +1,2066 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +# pyright: reportUnnecessaryTypeIgnoreComment=false + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs +from typing import ( + Any, + cast, + Optional, + Union, + AnyStr, + IO, + Mapping, + Callable, + MutableMapping, +) + +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote +import xml.etree.ElementTree as ET + +import isodate # type: ignore + +from azure.core.exceptions import DeserializationError, SerializationError +from azure.core.serialization import NULL as CoreNull + +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self + +_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") + +JSON = MutableMapping[str, Any] + + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + :return: The deserialized data. + :rtype: object + """ + if hasattr(data, "read"): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding="utf-8-sig") + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) from err + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError as err: + # It might be because the server has an issue, and returned JSON with + # content-type XML.... + # So let's try a JSON load, and if it's still broken + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # The function hack is because Py2.7 messes up with exception + # context otherwise. + _LOGGER.critical("Wasn't XML not JSON, failing") + raise DeserializationError("XML is invalid") from err + elif content_type.startswith("text/"): + return data_as_str + raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) + + @classmethod + def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + + :param bytes body_bytes: The body of the response. + :param dict headers: The headers of the response. + :returns: The deserialized data. + :rtype: object + """ + # Try to use content-type from headers if available + content_type = None + if "content-type" in headers: + content_type = headers["content-type"].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + +TZ_UTC = datetime.timezone.utc + +_FLATTEN = re.compile(r"(? None: + self.additional_properties: Optional[dict[str, Any]] = {} + for k in kwargs: # pylint: disable=consider-using-dict-items + if k not in self._attribute_map: + _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) + elif k in self._validation and self._validation[k].get("readonly", False): + _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) + else: + setattr(self, k, kwargs[k]) + + def __eq__(self, other: Any) -> bool: + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are equal + :rtype: bool + """ + if isinstance(other, self.__class__): + return self.__dict__ == other.__dict__ + return False + + def __ne__(self, other: Any) -> bool: + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are not equal + :rtype: bool + """ + return not self.__eq__(other) + + def __str__(self) -> str: + return str(self.__dict__) + + @classmethod + def enable_additional_properties_sending(cls) -> None: + cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} + + @classmethod + def is_xml_model(cls) -> bool: + try: + cls._xml_map # type: ignore + except AttributeError: + return False + return True + + @classmethod + def _create_xml_node(cls): + """Create XML node. + + :returns: The XML node + :rtype: xml.etree.ElementTree.Element + """ + try: + xml_map = cls._xml_map # type: ignore + except AttributeError: + xml_map = {} + + return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) + + def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: + """Return the JSON that would be sent to server from this model. + + This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. + + If you want XML serialization, you can pass the kwargs is_xml=True. + + :param bool keep_readonly: If you want to serialize the readonly attributes + :returns: A dict JSON compatible object + :rtype: dict + """ + serializer = Serializer(self._infer_class_models()) + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, keep_readonly=keep_readonly, **kwargs + ) + + def as_dict( + self, + keep_readonly: bool = True, + key_transformer: Callable[[str, dict[str, Any], Any], Any] = attribute_transformer, + **kwargs: Any + ) -> JSON: + """Return a dict that can be serialized using json.dump. + + Advanced usage might optionally use a callback as parameter: + + .. code::python + + def my_key_transformer(key, attr_desc, value): + return key + + Key is the attribute name used in Python. Attr_desc + is a dict of metadata. Currently contains 'type' with the + msrest type and 'key' with the RestAPI encoded key. + Value is the current value in this object. + + The string returned will be used to serialize the key. + If the return type is a list, this is considered hierarchical + result dict. + + See the three examples in this file: + + - attribute_transformer + - full_restapi_key_transformer + - last_restapi_key_transformer + + If you want XML serialization, you can pass the kwargs is_xml=True. + + :param bool keep_readonly: If you want to serialize the readonly attributes + :param function key_transformer: A key transformer function. + :returns: A dict JSON compatible object + :rtype: dict + """ + serializer = Serializer(self._infer_class_models()) + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs + ) + + @classmethod + def _infer_class_models(cls): + try: + str_models = cls.__module__.rsplit(".", 1)[0] + models = sys.modules[str_models] + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + if cls.__name__ not in client_models: + raise ValueError("Not Autorest generated code") + except Exception: # pylint: disable=broad-exception-caught + # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. + client_models = {cls.__name__: cls} + return client_models + + @classmethod + def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: + """Parse a str using the RestAPI syntax and return a model. + + :param str data: A str using RestAPI structure. JSON by default. + :param str content_type: JSON by default, set application/xml if XML. + :returns: An instance of this model + :raises DeserializationError: if something went wrong + :rtype: Self + """ + deserializer = Deserializer(cls._infer_class_models()) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore + + @classmethod + def from_dict( + cls, + data: Any, + key_extractors: Optional[Callable[[str, dict[str, Any], Any], Any]] = None, + content_type: Optional[str] = None, + ) -> Self: + """Parse a dict using given key extractor return a model. + + By default consider key + extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor + and last_rest_key_case_insensitive_extractor) + + :param dict data: A dict using RestAPI structure + :param function key_extractors: A key extractor function. + :param str content_type: JSON by default, set application/xml if XML. + :returns: An instance of this model + :raises DeserializationError: if something went wrong + :rtype: Self + """ + deserializer = Deserializer(cls._infer_class_models()) + deserializer.key_extractors = ( # type: ignore + [ # type: ignore + attribute_key_case_insensitive_extractor, + rest_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + if key_extractors is None + else key_extractors + ) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore + + @classmethod + def _flatten_subtype(cls, key, objects): + if "_subtype_map" not in cls.__dict__: + return {} + result = dict(cls._subtype_map[key]) + for valuetype in cls._subtype_map[key].values(): + result |= objects[valuetype]._flatten_subtype(key, objects) # pylint: disable=protected-access + return result + + @classmethod + def _classify(cls, response, objects): + """Check the class _subtype_map for any child classes. + We want to ignore any inherited _subtype_maps. + + :param dict response: The initial data + :param dict objects: The class objects + :returns: The class to be used + :rtype: class + """ + for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): + subtype_value = None + + if not isinstance(response, ET.Element): + rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] + subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) + else: + subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) + if subtype_value: + # Try to match base class. Can be class name only + # (bug to fix in Autorest to support x-ms-discriminator-name) + if cls.__name__ == subtype_value: + return cls + flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) + try: + return objects[flatten_mapping_type[subtype_value]] # type: ignore + except KeyError: + _LOGGER.warning( + "Subtype value %s has no mapping, use base class %s.", + subtype_value, + cls.__name__, + ) + break + else: + _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) + break + return cls + + @classmethod + def _get_rest_key_parts(cls, attr_key): + """Get the RestAPI key of this attr, split it and decode part + :param str attr_key: Attribute key must be in attribute_map. + :returns: A list of RestAPI part + :rtype: list + """ + rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) + return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] + + +def _decode_attribute_map_key(key): + """This decode a key in an _attribute_map to the actual key we want to look at + inside the received data. + + :param str key: A key string from the generated code + :returns: The decoded key + :rtype: str + """ + return key.replace("\\.", ".") + + +class Serializer: # pylint: disable=too-many-public-methods + """Request object model serializer.""" + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} + days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} + months = { + 1: "Jan", + 2: "Feb", + 3: "Mar", + 4: "Apr", + 5: "May", + 6: "Jun", + 7: "Jul", + 8: "Aug", + 9: "Sep", + 10: "Oct", + 11: "Nov", + 12: "Dec", + } + validation = { + "min_length": lambda x, y: len(x) < y, + "max_length": lambda x, y: len(x) > y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0, + } + + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: + self.serialize_type = { + "iso-8601": Serializer.serialize_iso, + "rfc-1123": Serializer.serialize_rfc, + "unix-time": Serializer.serialize_unix, + "duration": Serializer.serialize_duration, + "date": Serializer.serialize_date, + "time": Serializer.serialize_time, + "decimal": Serializer.serialize_decimal, + "long": Serializer.serialize_long, + "bytearray": Serializer.serialize_bytearray, + "base64": Serializer.serialize_base64, + "object": self.serialize_object, + "[]": self.serialize_iter, + "{}": self.serialize_dict, + } + self.dependencies: dict[str, type] = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals + self, target_obj, data_type=None, **kwargs + ): + """Serialize data into a string according to type. + + :param object target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises SerializationError: if serialization fails. + :returns: The serialized data. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data(target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data(target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() # pylint: disable=protected-access + try: + attributes = target_obj._attribute_map # pylint: disable=protected-access + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access + attr_name, {} + ).get("readonly", False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == "": + if target_obj.additional_properties is not None: + serialized |= target_obj.additional_properties + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) + + if is_xml_model_serialization: + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + xml_prefix = xml_desc.get("prefix", None) + xml_ns = xml_desc.get("ns", None) + if xml_desc.get("attr", False): + if xml_ns: + ET.register_namespace(xml_prefix, xml_ns) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + serialized.set(xml_name, new_attr) # type: ignore + continue + if xml_desc.get("text", False): + serialized.text = new_attr # type: ignore + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) # type: ignore + elif isinstance(new_attr, ET.Element): + # If the down XML has no XML/Name, + # we MUST replace the tag with the local tag. But keeping the namespaces. + if "name" not in getattr(orig_attr, "_xml_map", {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) # type: ignore + else: # That's a basic type + # Integrate namespace if necessary + local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) + local_node.text = str(new_attr) + serialized.append(local_node) # type: ignore + else: # JSON + for k in reversed(keys): # type: ignore + new_attr = {k: new_attr} + + _new_attr = new_attr + _serialized = serialized + for k in keys: # type: ignore + if k not in _serialized: + _serialized.update(_new_attr) # type: ignore + _new_attr = _new_attr[k] # type: ignore + _serialized = _serialized[k] + except ValueError as err: + if isinstance(err, SerializationError): + raise + + except (AttributeError, KeyError, TypeError) as err: + msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) + raise SerializationError(msg) from err + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises SerializationError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized request body + """ + + # Just in case this is a dict + internal_data_type_str = data_type.strip("[]{}") + internal_data_type = self.dependencies.get(internal_data_type_str, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ # type: ignore + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access + except DeserializationError as err: + raise SerializationError("Unable to build a model: " + str(err)) from err + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param str name: The name of the URL path parameter. + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :returns: The serialized URL path + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + + if kwargs.get("skip_quote") is True: + output = str(output) + output = output.replace("{", quote("{")).replace("}", quote("}")) + else: + output = quote(str(output), safe="") + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param str name: The name of the query parameter. + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, list + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized query parameter + """ + try: + # Treat the list aside, since we don't want to encode the div separator + if data_type.startswith("["): + internal_data_type = data_type[1:-1] + do_quote = not kwargs.get("skip_quote", False) + return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param str name: The name of the header. + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized header + """ + try: + if data_type in ["[str]"]: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :raises AttributeError: if required data is None. + :raises ValueError: if data is None + :raises SerializationError: if serialization fails. + :returns: The serialized data. + :rtype: str, int, float, bool, dict, list + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data is CoreNull: + return None + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + if data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, cast(type, data.__class__)) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) + + except (ValueError, TypeError) as err: + msg = "Unable to serialize value: {!r} as type: {!r}." + raise SerializationError(msg.format(data, data_type)) from err + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param obj data: Object to be serialized. + :param str data_type: Type of object in the iterable. + :rtype: str, int, float, bool + :return: serialized object + :raises TypeError: raise if data_type is not one of str, int, float, bool. + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == "str": + return cls.serialize_unicode(data) + if data_type == "int": + return int(data) + if data_type == "float": + return float(data) + if data_type == "bool": + return bool(data) + raise TypeError("Unknown basic data type: {}".format(data_type)) + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param str data: Object to be serialized. + :rtype: str + :return: serialized object + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): # type: ignore + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list data: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + Defaults to False. + :rtype: list, str + :return: serialized iterable + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError as err: + if isinstance(err, SerializationError): + raise + serialized.append(None) + + if kwargs.get("do_quote", False): + serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] + + if div: + serialized = ["" if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if "xml" in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get("xml", {}) + xml_name = xml_desc.get("name") + if not xml_name: + xml_name = serialization_ctxt["key"] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :rtype: dict + :return: serialized dictionary + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) + except ValueError as err: + if isinstance(err, SerializationError): + raise + serialized[self.serialize_unicode(key)] = None + + if "xml" in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt["xml"] + xml_name = xml_desc["name"] + + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + :return: serialized object + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) + if obj_type is _long_type: + return self.serialize_long(attr) + if obj_type is str: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + if obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object(obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) # type: ignore + return result + except ValueError as exc: + for enum_value in enum_obj: # type: ignore + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) from exc + + @staticmethod + def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument + """Serialize bytearray into base-64 string. + + :param str attr: Object to be serialized. + :rtype: str + :return: serialized base64 + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument + """Serialize str into base-64 string. + + :param str attr: Object to be serialized. + :rtype: str + :return: serialized base64 + """ + encoded = b64encode(attr).decode("ascii") + return encoded.strip("=").replace("+", "-").replace("/", "_") + + @staticmethod + def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Decimal object to float. + + :param decimal attr: Object to be serialized. + :rtype: float + :return: serialized decimal + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): # pylint: disable=unused-argument + """Serialize long (Py2) or int (Py3). + + :param int attr: Object to be serialized. + :rtype: int/long + :return: serialized long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + :return: serialized date + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + :return: serialized time + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + :return: serialized duration + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises TypeError: if format invalid. + :return: serialized rfc + """ + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError as exc: + raise TypeError("RFC1123 object must be valid Datetime object.") from exc + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], + utc.tm_mday, + Serializer.months[utc.tm_mon], + utc.tm_year, + utc.tm_hour, + utc.tm_min, + utc.tm_sec, + ) + + @staticmethod + def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises SerializationError: if format invalid. + :return: serialized iso + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") + if microseconds: + microseconds = "." + microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec + ) + return date + microseconds + "Z" + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise SerializationError(msg) from err + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise TypeError(msg) from err + + @staticmethod + def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises SerializationError: if format invalid + :return: serialied unix + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError as exc: + raise TypeError("Unix time object must be valid Datetime object.") from exc + + +def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + key = attr_desc["key"] + working_data = data + + while "." in key: + # Need the cast, as for some reasons "split" is typed as list[str | Any] + dict_keys = cast(list[str], _FLATTEN.split(key)) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + return None + key = ".".join(dict_keys[1:]) + + return working_data.get(key) + + +def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements + attr, attr_desc, data +): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + return None + key = ".".join(dict_keys[1:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + + +def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + """Extract the attribute in "data" based on the last part of the JSON path key. + + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute + """ + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute + """ + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + xml_name = internal_type_xml_map.get("name", internal_type.__name__) + xml_ns = internal_type_xml_map.get("ns", None) + if xml_ns: + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + + # Look for a children + is_iter_type = attr_desc["type"].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # Integrate namespace if necessary + xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) + if xml_ns: + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and "name" in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name + ) + ) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + + +class Deserializer: + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") + + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: + self.deserialize_type = { + "iso-8601": Deserializer.deserialize_iso, + "rfc-1123": Deserializer.deserialize_rfc, + "unix-time": Deserializer.deserialize_unix, + "duration": Deserializer.deserialize_duration, + "date": Deserializer.deserialize_date, + "time": Deserializer.deserialize_time, + "decimal": Deserializer.deserialize_decimal, + "long": Deserializer.deserialize_long, + "bytearray": Deserializer.deserialize_bytearray, + "base64": Deserializer.deserialize_base64, + "object": self.deserialize_object, + "[]": self.deserialize_iter, + "{}": self.deserialize_dict, + } + self.deserialize_expected_types = { + "duration": (isodate.Duration, datetime.timedelta), + "iso-8601": (datetime.datetime), + } + self.dependencies: dict[str, type] = dict(classes) if classes else {} + self.key_extractors = [rest_key_extractor, xml_key_extractor] + # Additional properties only works if the "rest_key_extractor" is used to + # extract the keys. Making it to work whatever the key extractor is too much + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): # pylint: disable=too-many-return-statements + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises DeserializationError: if deserialization fails. + :return: Deserialized object. + :rtype: object + """ + # Fast path for header deserialization: response_data is a plain str or None + # and target_obj is a simple scalar type. This avoids the expensive + # _unpack_content → _deserialize → _classify_target → deserialize_data chain. + if response_data is None: + return None + if target_obj == "str" and isinstance(response_data, str): + return response_data + if isinstance(response_data, str): + if target_obj == "int": + return int(response_data) + if target_obj == "bool": + if response_data in ("true", "1", "True"): + return True + if response_data in ("false", "0", "False"): + return False + return bool(response_data) + if target_obj == "rfc-1123": + return Deserializer.deserialize_rfc(response_data) + if target_obj == "bytearray": + return Deserializer.deserialize_bytearray(response_data) + + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises DeserializationError: if deserialization fails. + :return: Deserialized object. + :rtype: object + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] + try: + for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig["type"] + internal_data_type = local_type.strip("[]{}") + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr(data, attr, self._deserialize(local_type, value)) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, str): + return self.deserialize_data(data, response) + if isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None or data is CoreNull: + return data + try: + attributes = response._attribute_map # type: ignore # pylint: disable=protected-access + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == "": + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip("[]{}") + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ( + "Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" + ) + _LOGGER.warning(msg, found_value, key_extractor, attr) + continue + raw_value = found_value + + value = self.deserialize_data(raw_value, attr_desc["type"]) + d_attrs[attr] = value + except (AttributeError, TypeError, KeyError) as err: + msg = "Unable to deserialize to object: " + class_name # type: ignore + raise DeserializationError(msg) from err + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = { + _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) + for desc in attribute_map.values() + if desc["key"] != "" + } + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + Once classification has been determined, initialize object. + + :param str target: The target object type to deserialize to. + :param str/dict data: The response data to deserialize. + :return: The classified target object and its class name. + :rtype: tuple + """ + if target is None: + return None, None + + if isinstance(target, str): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ # type: ignore + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + a deserialization error. + + :param str target_obj: The target object type to deserialize to. + :param str/dict data: The response data to deserialize. + :param str content_type: Swagger "produces" if available. + :return: Deserialized object. + :rtype: object + """ + try: + return self(target_obj, data, content_type=content_type) + except: # pylint: disable=bare-except + _LOGGER.debug( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param obj raw_data: Data to be processed. + :param str content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + :rtype: object + :return: Unpacked content. + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + # Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) + + # Assume this enough to recognize requests.Response without importing it. + if hasattr(raw_data, "_content_consumed"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) + + if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): + return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore + return raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param Response response: The response model class. + :param dict attrs: The deserialized response attributes. + :param dict additional_properties: Additional properties to be set. + :rtype: Response + :return: The instantiated response model. + """ + if callable(response): + subtype = getattr(response, "_subtype_map", {}) + try: + readonly = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("readonly") + ] + const = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("constant") + ] + kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties # type: ignore + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore + raise DeserializationError(msg + str(err)) from err + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) from exp + + def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises DeserializationError: if deserialization fails. + :return: Deserialized object. + :rtype: object + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment + "object", + "[]", + r"{}", + ] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_type) + + except (ValueError, TypeError, AttributeError) as err: + msg = "Unable to deserialize response data." + msg += " Data: {}, {}".format(data, data_type) + raise DeserializationError(msg) from err + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :return: Deserialized iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :return: Deserialized dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :return: Deserialized object. + :rtype: dict + :raises TypeError: if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, str): + return self.deserialize_basic(attr, "str") + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object(value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object(obj, **kwargs)) + except ValueError: + pass + return deserialized + + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :return: Deserialized basic type. + :rtype: str, int, float or bool + :raises TypeError: if string format is not valid or data_type is not one of str, int, float, bool. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return "" + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == "bool": + if attr in [True, False, 1, 0]: + return bool(attr) + if isinstance(attr, str): + if attr.lower() in ["true", "1"]: + return True + if attr.lower() in ["false", "0"]: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == "str": + return self.deserialize_unicode(attr) + if data_type == "int": + return int(attr) + if data_type == "float": + return float(attr) + raise TypeError("Unknown basic data type: {}".format(data_type)) + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :return: Deserialized string. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): # type: ignore + return data + except NameError: + return str(data) + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :return: Deserialized enum object. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + data = data.value + if isinstance(data, int): + # Workaround. We might consider remove it in the future. + try: + return list(enum_obj.__members__.values())[data] + except IndexError as exc: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) from exc + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :return: Deserialized bytearray + :rtype: bytearray + :raises TypeError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) # type: ignore + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :return: Deserialized base64 string + :rtype: bytearray + :raises TypeError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore + encoded = attr.replace("-", "+").replace("_", "/") + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :return: Deserialized decimal + :raises DeserializationError: if string format invalid. + :rtype: decimal + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(str(attr)) # type: ignore + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise DeserializationError(msg) from err + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :return: Deserialized int + :rtype: long or int + :raises ValueError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) # type: ignore + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :return: Deserialized duration + :rtype: TimeDelta + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise DeserializationError(msg) from err + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :return: Deserialized date + :rtype: Date + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + return isodate.parse_date(attr, defaultmonth=0, defaultday=0) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :return: Deserialized time + :rtype: datetime.time + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :return: Deserialized RFC datetime + :rtype: Datetime + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) # type: ignore + date_obj = datetime.datetime( + *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + ) + if not date_obj.tzinfo: + date_obj = date_obj.astimezone(tz=TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to rfc datetime object." + raise DeserializationError(msg) from err + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :return: Deserialized ISO datetime + :rtype: Datetime + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() # type: ignore + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise DeserializationError(msg) from err + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :return: Deserialized datetime + :rtype: Datetime + :raises DeserializationError: if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) # type: ignore + try: + attr = int(attr) + date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to unix datetime object." + raise DeserializationError(msg) from err + return date_obj diff --git a/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/_version.py b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/_version.py new file mode 100644 index 000000000000..be71c81bd282 --- /dev/null +++ b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/aio/__init__.py b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/aio/__init__.py new file mode 100644 index 000000000000..52998e7e9eee --- /dev/null +++ b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/aio/__init__.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._client import ProjectsClient # type: ignore +from . import types # type: ignore + +try: + from ._patch import __all__ as _patch_all + from ._patch import * +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ProjectsClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore + +_patch_sdk() diff --git a/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/aio/_client.py b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/aio/_client.py new file mode 100644 index 000000000000..7b6650c19a9f --- /dev/null +++ b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/aio/_client.py @@ -0,0 +1,114 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +import sys +from typing import Any, Awaitable, TYPE_CHECKING, Union + +from azure.core import AsyncPipelineClient +from azure.core.credentials import AzureKeyCredential +from azure.core.pipeline import policies +from azure.core.rest import AsyncHttpResponse, HttpRequest + +from .._utils.serialization import Deserializer, Serializer +from ._configuration import ProjectsClientConfiguration +from .operations import ResponsesOperations + +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self # type: ignore + +if TYPE_CHECKING: + from azure.core.credentials_async import AsyncTokenCredential + + +class ProjectsClient: # pylint: disable=client-accepts-api-version-keyword + """ProjectsClient. + + :ivar responses: ResponsesOperations operations + :vartype responses: azure.ai.agentserver.responses.models.aio.operations.ResponsesOperations + :param endpoint: Foundry Project endpoint in the form + "https://{ai-services-account-name}.services.ai.azure.com/api/projects/{project-name}". If you + only have one Project in your Foundry Hub, or to target the default Project in your Hub, use + the form "https://{ai-services-account-name}.services.ai.azure.com/api/projects/_project". + Required. + :type endpoint: str + :param credential: Credential used to authenticate requests to the service. Is either a key + credential type or a token credential type. Required. + :type credential: ~azure.core.credentials.AzureKeyCredential or + ~azure.core.credentials_async.AsyncTokenCredential + """ + + def __init__( + self, endpoint: str, credential: Union[AzureKeyCredential, "AsyncTokenCredential"], **kwargs: Any + ) -> None: + _endpoint = "{endpoint}" + self._config = ProjectsClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) + + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncPipelineClient = AsyncPipelineClient(base_url=_endpoint, policies=_policies, **kwargs) + + self._serialize = Serializer() + self._deserialize = Deserializer() + self._serialize.client_side_validation = False + self.responses = ResponsesOperations(self._client, self._config, self._serialize, self._deserialize) + + def send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> Self: + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details: Any) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/aio/_configuration.py b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/aio/_configuration.py new file mode 100644 index 000000000000..29e2586f87fc --- /dev/null +++ b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/aio/_configuration.py @@ -0,0 +1,71 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING, Union + +from azure.core.credentials import AzureKeyCredential +from azure.core.pipeline import policies + +from .._version import VERSION + +if TYPE_CHECKING: + from azure.core.credentials_async import AsyncTokenCredential + + +class ProjectsClientConfiguration: # pylint: disable=too-many-instance-attributes + """Configuration for ProjectsClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param endpoint: Foundry Project endpoint in the form + "https://{ai-services-account-name}.services.ai.azure.com/api/projects/{project-name}". If you + only have one Project in your Foundry Hub, or to target the default Project in your Hub, use + the form "https://{ai-services-account-name}.services.ai.azure.com/api/projects/_project". + Required. + :type endpoint: str + :param credential: Credential used to authenticate requests to the service. Is either a key + credential type or a token credential type. Required. + :type credential: ~azure.core.credentials.AzureKeyCredential or + ~azure.core.credentials_async.AsyncTokenCredential + """ + + def __init__( + self, endpoint: str, credential: Union[AzureKeyCredential, "AsyncTokenCredential"], **kwargs: Any + ) -> None: + if endpoint is None: + raise ValueError("Parameter 'endpoint' must not be None.") + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + + self.endpoint = endpoint + self.credential = credential + self.credential_scopes = kwargs.pop("credential_scopes", ["https://ai.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "ai-agentserver-responses/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) + self._configure(**kwargs) + + def _infer_policy(self, **kwargs): + if isinstance(self.credential, AzureKeyCredential): + return policies.AzureKeyCredentialPolicy(self.credential, "api-key", **kwargs) + if hasattr(self.credential, "get_token"): + return policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + raise TypeError(f"Unsupported credential: {self.credential}") + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") + if self.credential and not self.authentication_policy: + self.authentication_policy = self._infer_policy(**kwargs) diff --git a/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/aio/_patch.py b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/aio/_patch.py new file mode 100644 index 000000000000..87676c65a8f0 --- /dev/null +++ b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/aio/_patch.py @@ -0,0 +1,21 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" + + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/aio/operations/__init__.py b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/aio/operations/__init__.py new file mode 100644 index 000000000000..9b86cda3e392 --- /dev/null +++ b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/aio/operations/__init__.py @@ -0,0 +1,25 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import ResponsesOperations # type: ignore + +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ResponsesOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/aio/operations/_operations.py b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/aio/operations/_operations.py new file mode 100644 index 000000000000..25e11c586bd4 --- /dev/null +++ b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/aio/operations/_operations.py @@ -0,0 +1,3532 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, IO, Literal, Optional, TYPE_CHECKING, TypeVar, Union, overload + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict + +from ... import types, types as _types +from ..._utils.serialization import Deserializer, Serializer +from ...operations._operations import ( + build_responses_cancel_response_request, + build_responses_compact_response_conversation_request, + build_responses_create_response_request, + build_responses_create_response_stream_request, + build_responses_delete_response_request, + build_responses_get_response_request, + build_responses_get_response_stream_request, + build_responses_list_input_items_request, + build_responses_list_responses_request, +) +from .._configuration import ProjectsClientConfiguration + +if TYPE_CHECKING: + from ... import _unions +JSON = MutableMapping[str, Any] +_Unset: Any = object() +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] + + +class ResponsesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.agentserver.responses.models.aio.ProjectsClient`'s + :attr:`responses` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ProjectsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + async def create_response( # pylint: disable=too-many-locals + self, + metadata: Optional[_types.Metadata] = None, + top_logprobs: Optional[int] = None, + temperature: Optional[float] = None, + top_p: Optional[float] = None, + user: Optional[str] = None, + safety_identifier: Optional[str] = None, + prompt_cache_key: Optional[str] = None, + service_tier: Optional[Literal["auto", "default", "flex", "scale", "priority"]] = None, + prompt_cache_retention: Optional[Literal["in-memory", "24h"]] = None, + previous_response_id: Optional[str] = None, + model: Optional[str] = None, + reasoning: Optional[_types.Reasoning] = None, + background: Optional[bool] = None, + max_output_tokens: Optional[int] = None, + max_tool_calls: Optional[int] = None, + text: Optional[_types.ResponseTextParam] = None, + tools: Optional[list[_types.Tool]] = None, + tool_choice: Optional[Union[types.ToolChoiceOptions, _types.ToolChoiceParam]] = None, + prompt: Optional[_types.Prompt] = None, + truncation: Optional[Literal["auto", "disabled"]] = None, + input: Optional["_unions.InputParam"] = None, + include: Optional[list[types.IncludeEnum]] = None, + parallel_tool_calls: Optional[bool] = None, + store: Optional[bool] = None, + instructions: Optional[str] = None, + stream_parameter: Optional[bool] = None, + stream_options: Optional[_types.ResponseStreamOptions] = None, + conversation: Optional["_unions.ConversationParam"] = None, + context_management: Optional[list[_types.ContextManagementParam]] = None, + agent: Optional[_types.AgentReference] = None, + agent_session_id: Optional[str] = None, + agent_reference: Optional[_types.AgentReference] = None, + structured_inputs: Optional[dict[str, Any]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _types.ResponseObject: + """Creates a model response. + + :param metadata: Default value is None. + :type metadata: ~azure.ai.agentserver.responses.models.types.Metadata + :param top_logprobs: Default value is None. + :type top_logprobs: int + :param temperature: Default value is None. + :type temperature: float + :param top_p: Default value is None. + :type top_p: float + :param user: This field is being replaced by ``safety_identifier`` and ``prompt_cache_key``. + Use ``prompt_cache_key`` instead to maintain caching optimizations. + A stable identifier for your end-users. + Used to boost cache hit rates by better bucketing similar requests and to help OpenAI + detect and prevent abuse. `Learn more + `_. Default value is None. + :type user: str + :param safety_identifier: A stable identifier used to help detect users of your application + that may be violating OpenAI's usage policies. + The IDs should be a string that uniquely identifies each user. We recommend hashing their + username or email address, in order to avoid sending us any identifying information. `Learn + more `_. Default value is None. + :type safety_identifier: str + :param prompt_cache_key: Used by OpenAI to cache responses for similar requests to optimize + your cache hit rates. Replaces the ``user`` field. `Learn more `_. + Default value is None. + :type prompt_cache_key: str + :param service_tier: Is one of the following types: Literal["auto"], Literal["default"], + Literal["flex"], Literal["scale"], Literal["priority"] Default value is None. + :type service_tier: str or str or str or str or str + :param prompt_cache_retention: Is either a Literal["in-memory"] type or a Literal["24h"] type. + Default value is None. + :type prompt_cache_retention: str or str + :param previous_response_id: Default value is None. + :type previous_response_id: str + :param model: The model deployment to use for the creation of this response. Default value is + None. + :type model: str + :param reasoning: Default value is None. + :type reasoning: ~azure.ai.agentserver.responses.models.types.Reasoning + :param background: Default value is None. + :type background: bool + :param max_output_tokens: Default value is None. + :type max_output_tokens: int + :param max_tool_calls: Default value is None. + :type max_tool_calls: int + :param text: Default value is None. + :type text: ~azure.ai.agentserver.responses.models.types.ResponseTextParam + :param tools: Default value is None. + :type tools: list[~azure.ai.agentserver.responses.models.types.Tool] + :param tool_choice: Is either a types.ToolChoiceOptions type or a ToolChoiceParam type. Default + value is None. + :type tool_choice: str or ~azure.ai.agentserver.responses.models.models.ToolChoiceOptions or + ~azure.ai.agentserver.responses.models.types.ToolChoiceParam + :param prompt: Default value is None. + :type prompt: ~azure.ai.agentserver.responses.models.types.Prompt + :param truncation: Is either a Literal["auto"] type or a Literal["disabled"] type. Default + value is None. + :type truncation: str or str + :param input: Is either a str type or a [Item] type. Default value is None. + :type input: str or list[~azure.ai.agentserver.responses.models.types.Item] + :param include: Default value is None. + :type include: list[str or ~azure.ai.agentserver.responses.models.models.IncludeEnum] + :param parallel_tool_calls: Default value is None. + :type parallel_tool_calls: bool + :param store: Default value is None. + :type store: bool + :param instructions: Default value is None. + :type instructions: str + :param stream_parameter: Default value is None. + :type stream_parameter: bool + :param stream_options: Default value is None. + :type stream_options: ~azure.ai.agentserver.responses.models.types.ResponseStreamOptions + :param conversation: Is either a str type or a ConversationParam_2 type. Default value is None. + :type conversation: str or ~azure.ai.agentserver.responses.models.types.ConversationParam_2 + :param context_management: Context management configuration for this request. Default value is + None. + :type context_management: + list[~azure.ai.agentserver.responses.models.types.ContextManagementParam] + :param agent: (Deprecated) Use agent_reference instead. + The agent to use for generating the response. Default value is None. + :type agent: ~azure.ai.agentserver.responses.models.types.AgentReference + :param agent_session_id: Optional session identifier for sandbox affinity. Currently only + relevant for hosted agents. + When provided, the request is routed to the same sandbox. When omitted, auto-derived from + conversation_id/prev_response_id or a new UUID is generated. Default value is None. + :type agent_session_id: str + :param agent_reference: The agent to use for generating the response. Default value is None. + :type agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :param structured_inputs: The structured inputs to the response that can participate in prompt + template substitution or tool argument bindings. Default value is None. + :type structured_inputs: dict[str, any] + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ResponseObject + :rtype: ~azure.ai.agentserver.responses.models.types.ResponseObject + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "json_object": + text_response_format_configuration = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format_configuration = { + "name": "str", + "schema": {}, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format_configuration = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "agent_reference": { + "name": "str", + "type": "agent_reference", + "version": "str" + }, + "created_at": "2020-02-20 00:00:00", + "error": { + "code": "str", + "message": "str" + }, + "id": "str", + "incomplete_details": { + "reason": "max_output_tokens" + }, + "instructions": "str", + "object": "response", + "output": [ + output_item + ], + "parallel_tool_calls": bool, + "agent": { + "name": "str", + "type": "agent_id", + "version": "str" + }, + "agent_session_id": "str", + "background": bool, + "completed_at": "2020-02-20 00:00:00", + "conversation": { + "id": "str" + }, + "max_output_tokens": 0, + "max_tool_calls": 0, + "metadata": {}, + "model": "str", + "output_text": "str", + "previous_response_id": "str", + "prompt": { + "id": "str", + "variables": {}, + "version": "str" + }, + "prompt_cache_key": "str", + "prompt_cache_retention": "in-memory", + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "safety_identifier": "str", + "service_tier": "auto", + "status": "completed", + "temperature": 0.0, + "text": { + "format": text_response_format_configuration, + "verbosity": "low" + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_logprobs": 0, + "top_p": 0.0, + "truncation": "auto", + "usage": { + "input_tokens": 0, + "input_tokens_details": { + "cached_tokens": 0 + }, + "output_tokens": 0, + "output_tokens_details": { + "reasoning_tokens": 0 + }, + "total_tokens": 0 + }, + "user": "str" + } + """ + + @overload + async def create_response( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _types.ResponseObject: + """Creates a model response. + + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ResponseObject + :rtype: ~azure.ai.agentserver.responses.models.types.ResponseObject + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "json_object": + text_response_format_configuration = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format_configuration = { + "name": "str", + "schema": {}, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format_configuration = { + "type": "text" + } + + # JSON input template you can fill out and use as your body input. + body = { + "agent": { + "name": "str", + "type": "agent_reference", + "version": "str" + }, + "agent_reference": { + "name": "str", + "type": "agent_reference", + "version": "str" + }, + "agent_session_id": "str", + "background": bool, + "context_management": [ + { + "type": "str", + "compact_threshold": 0 + } + ], + "conversation": "str", + "include": [ + "str" + ], + "input": "str", + "instructions": "str", + "max_output_tokens": 0, + "max_tool_calls": 0, + "metadata": {}, + "model": "str", + "parallel_tool_calls": bool, + "previous_response_id": "str", + "prompt": { + "id": "str", + "variables": {}, + "version": "str" + }, + "prompt_cache_key": "str", + "prompt_cache_retention": "in-memory", + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "safety_identifier": "str", + "service_tier": "auto", + "store": bool, + "stream": bool, + "stream_options": { + "include_obfuscation": bool + }, + "structured_inputs": { + "str": {} + }, + "temperature": 0.0, + "text": { + "format": text_response_format_configuration, + "verbosity": "low" + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_logprobs": 0, + "top_p": 0.0, + "truncation": "auto", + "user": "str" + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "json_object": + text_response_format_configuration = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format_configuration = { + "name": "str", + "schema": {}, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format_configuration = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "agent_reference": { + "name": "str", + "type": "agent_reference", + "version": "str" + }, + "created_at": "2020-02-20 00:00:00", + "error": { + "code": "str", + "message": "str" + }, + "id": "str", + "incomplete_details": { + "reason": "max_output_tokens" + }, + "instructions": "str", + "object": "response", + "output": [ + output_item + ], + "parallel_tool_calls": bool, + "agent": { + "name": "str", + "type": "agent_id", + "version": "str" + }, + "agent_session_id": "str", + "background": bool, + "completed_at": "2020-02-20 00:00:00", + "conversation": { + "id": "str" + }, + "max_output_tokens": 0, + "max_tool_calls": 0, + "metadata": {}, + "model": "str", + "output_text": "str", + "previous_response_id": "str", + "prompt": { + "id": "str", + "variables": {}, + "version": "str" + }, + "prompt_cache_key": "str", + "prompt_cache_retention": "in-memory", + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "safety_identifier": "str", + "service_tier": "auto", + "status": "completed", + "temperature": 0.0, + "text": { + "format": text_response_format_configuration, + "verbosity": "low" + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_logprobs": 0, + "top_p": 0.0, + "truncation": "auto", + "usage": { + "input_tokens": 0, + "input_tokens_details": { + "cached_tokens": 0 + }, + "output_tokens": 0, + "output_tokens_details": { + "reasoning_tokens": 0 + }, + "total_tokens": 0 + }, + "user": "str" + } + """ + + @overload + async def create_response( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _types.ResponseObject: + """Creates a model response. + + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ResponseObject + :rtype: ~azure.ai.agentserver.responses.models.types.ResponseObject + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "json_object": + text_response_format_configuration = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format_configuration = { + "name": "str", + "schema": {}, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format_configuration = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "agent_reference": { + "name": "str", + "type": "agent_reference", + "version": "str" + }, + "created_at": "2020-02-20 00:00:00", + "error": { + "code": "str", + "message": "str" + }, + "id": "str", + "incomplete_details": { + "reason": "max_output_tokens" + }, + "instructions": "str", + "object": "response", + "output": [ + output_item + ], + "parallel_tool_calls": bool, + "agent": { + "name": "str", + "type": "agent_id", + "version": "str" + }, + "agent_session_id": "str", + "background": bool, + "completed_at": "2020-02-20 00:00:00", + "conversation": { + "id": "str" + }, + "max_output_tokens": 0, + "max_tool_calls": 0, + "metadata": {}, + "model": "str", + "output_text": "str", + "previous_response_id": "str", + "prompt": { + "id": "str", + "variables": {}, + "version": "str" + }, + "prompt_cache_key": "str", + "prompt_cache_retention": "in-memory", + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "safety_identifier": "str", + "service_tier": "auto", + "status": "completed", + "temperature": 0.0, + "text": { + "format": text_response_format_configuration, + "verbosity": "low" + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_logprobs": 0, + "top_p": 0.0, + "truncation": "auto", + "usage": { + "input_tokens": 0, + "input_tokens_details": { + "cached_tokens": 0 + }, + "output_tokens": 0, + "output_tokens_details": { + "reasoning_tokens": 0 + }, + "total_tokens": 0 + }, + "user": "str" + } + """ + + @distributed_trace_async + async def create_response( # pylint: disable=too-many-locals + self, + body: Union[JSON, IO[bytes]] = _Unset, + metadata: Optional[_types.Metadata] = None, + top_logprobs: Optional[int] = None, + temperature: Optional[float] = None, + top_p: Optional[float] = None, + user: Optional[str] = None, + safety_identifier: Optional[str] = None, + prompt_cache_key: Optional[str] = None, + service_tier: Optional[Literal["auto", "default", "flex", "scale", "priority"]] = None, + prompt_cache_retention: Optional[Literal["in-memory", "24h"]] = None, + previous_response_id: Optional[str] = None, + model: Optional[str] = None, + reasoning: Optional[_types.Reasoning] = None, + background: Optional[bool] = None, + max_output_tokens: Optional[int] = None, + max_tool_calls: Optional[int] = None, + text: Optional[_types.ResponseTextParam] = None, + tools: Optional[list[_types.Tool]] = None, + tool_choice: Optional[Union[types.ToolChoiceOptions, _types.ToolChoiceParam]] = None, + prompt: Optional[_types.Prompt] = None, + truncation: Optional[Literal["auto", "disabled"]] = None, + input: Optional["_unions.InputParam"] = None, + include: Optional[list[types.IncludeEnum]] = None, + parallel_tool_calls: Optional[bool] = None, + store: Optional[bool] = None, + instructions: Optional[str] = None, + stream_parameter: Optional[bool] = None, + stream_options: Optional[_types.ResponseStreamOptions] = None, + conversation: Optional["_unions.ConversationParam"] = None, + context_management: Optional[list[_types.ContextManagementParam]] = None, + agent: Optional[_types.AgentReference] = None, + agent_session_id: Optional[str] = None, + agent_reference: Optional[_types.AgentReference] = None, + structured_inputs: Optional[dict[str, Any]] = None, + **kwargs: Any + ) -> _types.ResponseObject: + """Creates a model response. + + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :param metadata: Default value is None. + :type metadata: ~azure.ai.agentserver.responses.models.types.Metadata + :param top_logprobs: Default value is None. + :type top_logprobs: int + :param temperature: Default value is None. + :type temperature: float + :param top_p: Default value is None. + :type top_p: float + :param user: This field is being replaced by ``safety_identifier`` and ``prompt_cache_key``. + Use ``prompt_cache_key`` instead to maintain caching optimizations. + A stable identifier for your end-users. + Used to boost cache hit rates by better bucketing similar requests and to help OpenAI + detect and prevent abuse. `Learn more + `_. Default value is None. + :type user: str + :param safety_identifier: A stable identifier used to help detect users of your application + that may be violating OpenAI's usage policies. + The IDs should be a string that uniquely identifies each user. We recommend hashing their + username or email address, in order to avoid sending us any identifying information. `Learn + more `_. Default value is None. + :type safety_identifier: str + :param prompt_cache_key: Used by OpenAI to cache responses for similar requests to optimize + your cache hit rates. Replaces the ``user`` field. `Learn more `_. + Default value is None. + :type prompt_cache_key: str + :param service_tier: Is one of the following types: Literal["auto"], Literal["default"], + Literal["flex"], Literal["scale"], Literal["priority"] Default value is None. + :type service_tier: str or str or str or str or str + :param prompt_cache_retention: Is either a Literal["in-memory"] type or a Literal["24h"] type. + Default value is None. + :type prompt_cache_retention: str or str + :param previous_response_id: Default value is None. + :type previous_response_id: str + :param model: The model deployment to use for the creation of this response. Default value is + None. + :type model: str + :param reasoning: Default value is None. + :type reasoning: ~azure.ai.agentserver.responses.models.types.Reasoning + :param background: Default value is None. + :type background: bool + :param max_output_tokens: Default value is None. + :type max_output_tokens: int + :param max_tool_calls: Default value is None. + :type max_tool_calls: int + :param text: Default value is None. + :type text: ~azure.ai.agentserver.responses.models.types.ResponseTextParam + :param tools: Default value is None. + :type tools: list[~azure.ai.agentserver.responses.models.types.Tool] + :param tool_choice: Is either a types.ToolChoiceOptions type or a ToolChoiceParam type. Default + value is None. + :type tool_choice: str or ~azure.ai.agentserver.responses.models.models.ToolChoiceOptions or + ~azure.ai.agentserver.responses.models.types.ToolChoiceParam + :param prompt: Default value is None. + :type prompt: ~azure.ai.agentserver.responses.models.types.Prompt + :param truncation: Is either a Literal["auto"] type or a Literal["disabled"] type. Default + value is None. + :type truncation: str or str + :param input: Is either a str type or a [Item] type. Default value is None. + :type input: str or list[~azure.ai.agentserver.responses.models.types.Item] + :param include: Default value is None. + :type include: list[str or ~azure.ai.agentserver.responses.models.models.IncludeEnum] + :param parallel_tool_calls: Default value is None. + :type parallel_tool_calls: bool + :param store: Default value is None. + :type store: bool + :param instructions: Default value is None. + :type instructions: str + :param stream_parameter: Default value is None. + :type stream_parameter: bool + :param stream_options: Default value is None. + :type stream_options: ~azure.ai.agentserver.responses.models.types.ResponseStreamOptions + :param conversation: Is either a str type or a ConversationParam_2 type. Default value is None. + :type conversation: str or ~azure.ai.agentserver.responses.models.types.ConversationParam_2 + :param context_management: Context management configuration for this request. Default value is + None. + :type context_management: + list[~azure.ai.agentserver.responses.models.types.ContextManagementParam] + :param agent: (Deprecated) Use agent_reference instead. + The agent to use for generating the response. Default value is None. + :type agent: ~azure.ai.agentserver.responses.models.types.AgentReference + :param agent_session_id: Optional session identifier for sandbox affinity. Currently only + relevant for hosted agents. + When provided, the request is routed to the same sandbox. When omitted, auto-derived from + conversation_id/prev_response_id or a new UUID is generated. Default value is None. + :type agent_session_id: str + :param agent_reference: The agent to use for generating the response. Default value is None. + :type agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :param structured_inputs: The structured inputs to the response that can participate in prompt + template substitution or tool argument bindings. Default value is None. + :type structured_inputs: dict[str, any] + :return: ResponseObject + :rtype: ~azure.ai.agentserver.responses.models.types.ResponseObject + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "json_object": + text_response_format_configuration = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format_configuration = { + "name": "str", + "schema": {}, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format_configuration = { + "type": "text" + } + + # JSON input template you can fill out and use as your body input. + body = { + "agent": { + "name": "str", + "type": "agent_reference", + "version": "str" + }, + "agent_reference": { + "name": "str", + "type": "agent_reference", + "version": "str" + }, + "agent_session_id": "str", + "background": bool, + "context_management": [ + { + "type": "str", + "compact_threshold": 0 + } + ], + "conversation": "str", + "include": [ + "str" + ], + "input": "str", + "instructions": "str", + "max_output_tokens": 0, + "max_tool_calls": 0, + "metadata": {}, + "model": "str", + "parallel_tool_calls": bool, + "previous_response_id": "str", + "prompt": { + "id": "str", + "variables": {}, + "version": "str" + }, + "prompt_cache_key": "str", + "prompt_cache_retention": "in-memory", + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "safety_identifier": "str", + "service_tier": "auto", + "store": bool, + "stream": bool, + "stream_options": { + "include_obfuscation": bool + }, + "structured_inputs": { + "str": {} + }, + "temperature": 0.0, + "text": { + "format": text_response_format_configuration, + "verbosity": "low" + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_logprobs": 0, + "top_p": 0.0, + "truncation": "auto", + "user": "str" + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "json_object": + text_response_format_configuration = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format_configuration = { + "name": "str", + "schema": {}, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format_configuration = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "agent_reference": { + "name": "str", + "type": "agent_reference", + "version": "str" + }, + "created_at": "2020-02-20 00:00:00", + "error": { + "code": "str", + "message": "str" + }, + "id": "str", + "incomplete_details": { + "reason": "max_output_tokens" + }, + "instructions": "str", + "object": "response", + "output": [ + output_item + ], + "parallel_tool_calls": bool, + "agent": { + "name": "str", + "type": "agent_id", + "version": "str" + }, + "agent_session_id": "str", + "background": bool, + "completed_at": "2020-02-20 00:00:00", + "conversation": { + "id": "str" + }, + "max_output_tokens": 0, + "max_tool_calls": 0, + "metadata": {}, + "model": "str", + "output_text": "str", + "previous_response_id": "str", + "prompt": { + "id": "str", + "variables": {}, + "version": "str" + }, + "prompt_cache_key": "str", + "prompt_cache_retention": "in-memory", + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "safety_identifier": "str", + "service_tier": "auto", + "status": "completed", + "temperature": 0.0, + "text": { + "format": text_response_format_configuration, + "verbosity": "low" + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_logprobs": 0, + "top_p": 0.0, + "truncation": "auto", + "usage": { + "input_tokens": 0, + "input_tokens_details": { + "cached_tokens": 0 + }, + "output_tokens": 0, + "output_tokens_details": { + "reasoning_tokens": 0 + }, + "total_tokens": 0 + }, + "user": "str" + } + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_types.ResponseObject] = kwargs.pop("cls", None) + + if body is _Unset: + body = { + "agent": agent, + "agent_reference": agent_reference, + "agent_session_id": agent_session_id, + "background": background, + "context_management": context_management, + "conversation": conversation, + "include": include, + "input": input, + "instructions": instructions, + "max_output_tokens": max_output_tokens, + "max_tool_calls": max_tool_calls, + "metadata": metadata, + "model": model, + "parallel_tool_calls": parallel_tool_calls, + "previous_response_id": previous_response_id, + "prompt": prompt, + "prompt_cache_key": prompt_cache_key, + "prompt_cache_retention": prompt_cache_retention, + "reasoning": reasoning, + "safety_identifier": safety_identifier, + "service_tier": service_tier, + "store": store, + "stream": stream_parameter, + "stream_options": stream_options, + "structured_inputs": structured_inputs, + "temperature": temperature, + "text": text, + "tool_choice": tool_choice, + "tools": tools, + "top_logprobs": top_logprobs, + "top_p": top_p, + "truncation": truncation, + "user": user, + } + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_responses_create_response_request( + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _types.ApiErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_response_stream( # pylint: disable=too-many-locals + self, + metadata: Optional[_types.Metadata] = None, + top_logprobs: Optional[int] = None, + temperature: Optional[float] = None, + top_p: Optional[float] = None, + user: Optional[str] = None, + safety_identifier: Optional[str] = None, + prompt_cache_key: Optional[str] = None, + service_tier: Optional[Literal["auto", "default", "flex", "scale", "priority"]] = None, + prompt_cache_retention: Optional[Literal["in-memory", "24h"]] = None, + previous_response_id: Optional[str] = None, + model: Optional[str] = None, + reasoning: Optional[_types.Reasoning] = None, + background: Optional[bool] = None, + max_output_tokens: Optional[int] = None, + max_tool_calls: Optional[int] = None, + text: Optional[_types.ResponseTextParam] = None, + tools: Optional[list[_types.Tool]] = None, + tool_choice: Optional[Union[types.ToolChoiceOptions, _types.ToolChoiceParam]] = None, + prompt: Optional[_types.Prompt] = None, + truncation: Optional[Literal["auto", "disabled"]] = None, + input: Optional["_unions.InputParam"] = None, + include: Optional[list[types.IncludeEnum]] = None, + parallel_tool_calls: Optional[bool] = None, + store: Optional[bool] = None, + instructions: Optional[str] = None, + stream_parameter: Optional[bool] = None, + stream_options: Optional[_types.ResponseStreamOptions] = None, + conversation: Optional["_unions.ConversationParam"] = None, + context_management: Optional[list[_types.ContextManagementParam]] = None, + agent: Optional[_types.AgentReference] = None, + agent_session_id: Optional[str] = None, + agent_reference: Optional[_types.AgentReference] = None, + structured_inputs: Optional[dict[str, Any]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> "_unions.CreateResponseStreamingResponse": + """Creates a model response (streaming response). + + :param metadata: Default value is None. + :type metadata: ~azure.ai.agentserver.responses.models.types.Metadata + :param top_logprobs: Default value is None. + :type top_logprobs: int + :param temperature: Default value is None. + :type temperature: float + :param top_p: Default value is None. + :type top_p: float + :param user: This field is being replaced by ``safety_identifier`` and ``prompt_cache_key``. + Use ``prompt_cache_key`` instead to maintain caching optimizations. + A stable identifier for your end-users. + Used to boost cache hit rates by better bucketing similar requests and to help OpenAI + detect and prevent abuse. `Learn more + `_. Default value is None. + :type user: str + :param safety_identifier: A stable identifier used to help detect users of your application + that may be violating OpenAI's usage policies. + The IDs should be a string that uniquely identifies each user. We recommend hashing their + username or email address, in order to avoid sending us any identifying information. `Learn + more `_. Default value is None. + :type safety_identifier: str + :param prompt_cache_key: Used by OpenAI to cache responses for similar requests to optimize + your cache hit rates. Replaces the ``user`` field. `Learn more `_. + Default value is None. + :type prompt_cache_key: str + :param service_tier: Is one of the following types: Literal["auto"], Literal["default"], + Literal["flex"], Literal["scale"], Literal["priority"] Default value is None. + :type service_tier: str or str or str or str or str + :param prompt_cache_retention: Is either a Literal["in-memory"] type or a Literal["24h"] type. + Default value is None. + :type prompt_cache_retention: str or str + :param previous_response_id: Default value is None. + :type previous_response_id: str + :param model: The model deployment to use for the creation of this response. Default value is + None. + :type model: str + :param reasoning: Default value is None. + :type reasoning: ~azure.ai.agentserver.responses.models.types.Reasoning + :param background: Default value is None. + :type background: bool + :param max_output_tokens: Default value is None. + :type max_output_tokens: int + :param max_tool_calls: Default value is None. + :type max_tool_calls: int + :param text: Default value is None. + :type text: ~azure.ai.agentserver.responses.models.types.ResponseTextParam + :param tools: Default value is None. + :type tools: list[~azure.ai.agentserver.responses.models.types.Tool] + :param tool_choice: Is either a types.ToolChoiceOptions type or a ToolChoiceParam type. Default + value is None. + :type tool_choice: str or ~azure.ai.agentserver.responses.models.models.ToolChoiceOptions or + ~azure.ai.agentserver.responses.models.types.ToolChoiceParam + :param prompt: Default value is None. + :type prompt: ~azure.ai.agentserver.responses.models.types.Prompt + :param truncation: Is either a Literal["auto"] type or a Literal["disabled"] type. Default + value is None. + :type truncation: str or str + :param input: Is either a str type or a [Item] type. Default value is None. + :type input: str or list[~azure.ai.agentserver.responses.models.types.Item] + :param include: Default value is None. + :type include: list[str or ~azure.ai.agentserver.responses.models.models.IncludeEnum] + :param parallel_tool_calls: Default value is None. + :type parallel_tool_calls: bool + :param store: Default value is None. + :type store: bool + :param instructions: Default value is None. + :type instructions: str + :param stream_parameter: Default value is None. + :type stream_parameter: bool + :param stream_options: Default value is None. + :type stream_options: ~azure.ai.agentserver.responses.models.types.ResponseStreamOptions + :param conversation: Is either a str type or a ConversationParam_2 type. Default value is None. + :type conversation: str or ~azure.ai.agentserver.responses.models.types.ConversationParam_2 + :param context_management: Context management configuration for this request. Default value is + None. + :type context_management: + list[~azure.ai.agentserver.responses.models.types.ContextManagementParam] + :param agent: (Deprecated) Use agent_reference instead. + The agent to use for generating the response. Default value is None. + :type agent: ~azure.ai.agentserver.responses.models.types.AgentReference + :param agent_session_id: Optional session identifier for sandbox affinity. Currently only + relevant for hosted agents. + When provided, the request is routed to the same sandbox. When omitted, auto-derived from + conversation_id/prev_response_id or a new UUID is generated. Default value is None. + :type agent_session_id: str + :param agent_reference: The agent to use for generating the response. Default value is None. + :type agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :param structured_inputs: The structured inputs to the response that can participate in prompt + template substitution or tool argument bindings. Default value is None. + :type structured_inputs: dict[str, any] + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ResponseAudioDeltaEvent or ResponseAudioTranscriptDeltaEvent or + ResponseCodeInterpreterCallCodeDeltaEvent or ResponseCodeInterpreterCallInProgressEvent or + ResponseCodeInterpreterCallInterpretingEvent or ResponseContentPartAddedEvent or + ResponseCreatedEvent or ResponseErrorEvent or ResponseFileSearchCallInProgressEvent or + ResponseFileSearchCallSearchingEvent or ResponseFunctionCallArgumentsDeltaEvent or + ResponseInProgressEvent or ResponseFailedEvent or ResponseIncompleteEvent or + ResponseOutputItemAddedEvent or ResponseReasoningSummaryPartAddedEvent or + ResponseReasoningSummaryTextDeltaEvent or ResponseReasoningTextDeltaEvent or + ResponseRefusalDeltaEvent or ResponseTextDeltaEvent or ResponseWebSearchCallInProgressEvent or + ResponseWebSearchCallSearchingEvent or ResponseImageGenCallGeneratingEvent or + ResponseImageGenCallInProgressEvent or ResponseImageGenCallPartialImageEvent or + ResponseMCPCallArgumentsDeltaEvent or ResponseMCPCallFailedEvent or + ResponseMCPCallInProgressEvent or ResponseMCPListToolsFailedEvent or + ResponseMCPListToolsInProgressEvent or ResponseOutputTextAnnotationAddedEvent or + ResponseQueuedEvent or ResponseCustomToolCallInputDeltaEvent or ResponseAudioDoneEvent or + ResponseAudioTranscriptDoneEvent or ResponseCodeInterpreterCallCodeDoneEvent or + ResponseCodeInterpreterCallCompletedEvent or ResponseCompletedEvent or + ResponseContentPartDoneEvent or ResponseFileSearchCallCompletedEvent or + ResponseFunctionCallArgumentsDoneEvent or ResponseOutputItemDoneEvent or + ResponseReasoningSummaryPartDoneEvent or ResponseReasoningSummaryTextDoneEvent or + ResponseReasoningTextDoneEvent or ResponseRefusalDoneEvent or ResponseTextDoneEvent or + ResponseWebSearchCallCompletedEvent or ResponseImageGenCallCompletedEvent or + ResponseMCPCallArgumentsDoneEvent or ResponseMCPCallCompletedEvent or + ResponseMCPListToolsCompletedEvent or ResponseCustomToolCallInputDoneEvent + :rtype: ~azure.ai.agentserver.responses.models.types.ResponseAudioDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseAudioTranscriptDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallCodeDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallInterpretingEvent or + ~azure.ai.agentserver.responses.models.types.ResponseContentPartAddedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCreatedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseErrorEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFileSearchCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFileSearchCallSearchingEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFunctionCallArgumentsDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFailedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseIncompleteEvent or + ~azure.ai.agentserver.responses.models.types.ResponseOutputItemAddedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryPartAddedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryTextDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningTextDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseRefusalDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseTextDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseWebSearchCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseWebSearchCallSearchingEvent or + ~azure.ai.agentserver.responses.models.types.ResponseImageGenCallGeneratingEvent or + ~azure.ai.agentserver.responses.models.types.ResponseImageGenCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseImageGenCallPartialImageEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallArgumentsDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallFailedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPListToolsFailedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPListToolsInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseOutputTextAnnotationAddedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseQueuedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCustomToolCallInputDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseAudioDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseAudioTranscriptDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallCodeDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseContentPartDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFileSearchCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFunctionCallArgumentsDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseOutputItemDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryPartDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryTextDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningTextDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseRefusalDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseTextDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseWebSearchCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseImageGenCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallArgumentsDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPListToolsCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCustomToolCallInputDoneEvent + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "response.audio.delta": + response_stream_event = { + "delta": bytes("bytes", encoding="utf-8"), + "sequence_number": 0, + "type": "response.audio.delta" + } + + # JSON input template for discriminator value "response.audio.transcript.delta": + response_stream_event = { + "delta": "str", + "sequence_number": 0, + "type": "response.audio.transcript.delta" + } + + # JSON input template for discriminator value + "response.code_interpreter_call_code.delta": + response_stream_event = { + "delta": "str", + "item_id": "str", + "output_index": 0, + "sequence_number": 0, + "type": "response.code_interpreter_call_code.delta" + } + + # JSON input template for discriminator value + "response.code_interpreter_call.in_progress": + response_stream_event = { + "item_id": "str", + "output_index": 0, + "sequence_number": 0, + "type": "response.code_interpreter_call.in_progress" + } + + # JSON input template for discriminator value + "response.code_interpreter_call.interpreting": + response_stream_event = { + "item_id": "str", + "output_index": 0, + "sequence_number": 0, + "type": "response.code_interpreter_call.interpreting" + } + """ + + @overload + async def create_response_stream( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> "_unions.CreateResponseStreamingResponse": + """Creates a model response (streaming response). + + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ResponseAudioDeltaEvent or ResponseAudioTranscriptDeltaEvent or + ResponseCodeInterpreterCallCodeDeltaEvent or ResponseCodeInterpreterCallInProgressEvent or + ResponseCodeInterpreterCallInterpretingEvent or ResponseContentPartAddedEvent or + ResponseCreatedEvent or ResponseErrorEvent or ResponseFileSearchCallInProgressEvent or + ResponseFileSearchCallSearchingEvent or ResponseFunctionCallArgumentsDeltaEvent or + ResponseInProgressEvent or ResponseFailedEvent or ResponseIncompleteEvent or + ResponseOutputItemAddedEvent or ResponseReasoningSummaryPartAddedEvent or + ResponseReasoningSummaryTextDeltaEvent or ResponseReasoningTextDeltaEvent or + ResponseRefusalDeltaEvent or ResponseTextDeltaEvent or ResponseWebSearchCallInProgressEvent or + ResponseWebSearchCallSearchingEvent or ResponseImageGenCallGeneratingEvent or + ResponseImageGenCallInProgressEvent or ResponseImageGenCallPartialImageEvent or + ResponseMCPCallArgumentsDeltaEvent or ResponseMCPCallFailedEvent or + ResponseMCPCallInProgressEvent or ResponseMCPListToolsFailedEvent or + ResponseMCPListToolsInProgressEvent or ResponseOutputTextAnnotationAddedEvent or + ResponseQueuedEvent or ResponseCustomToolCallInputDeltaEvent or ResponseAudioDoneEvent or + ResponseAudioTranscriptDoneEvent or ResponseCodeInterpreterCallCodeDoneEvent or + ResponseCodeInterpreterCallCompletedEvent or ResponseCompletedEvent or + ResponseContentPartDoneEvent or ResponseFileSearchCallCompletedEvent or + ResponseFunctionCallArgumentsDoneEvent or ResponseOutputItemDoneEvent or + ResponseReasoningSummaryPartDoneEvent or ResponseReasoningSummaryTextDoneEvent or + ResponseReasoningTextDoneEvent or ResponseRefusalDoneEvent or ResponseTextDoneEvent or + ResponseWebSearchCallCompletedEvent or ResponseImageGenCallCompletedEvent or + ResponseMCPCallArgumentsDoneEvent or ResponseMCPCallCompletedEvent or + ResponseMCPListToolsCompletedEvent or ResponseCustomToolCallInputDoneEvent + :rtype: ~azure.ai.agentserver.responses.models.types.ResponseAudioDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseAudioTranscriptDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallCodeDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallInterpretingEvent or + ~azure.ai.agentserver.responses.models.types.ResponseContentPartAddedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCreatedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseErrorEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFileSearchCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFileSearchCallSearchingEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFunctionCallArgumentsDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFailedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseIncompleteEvent or + ~azure.ai.agentserver.responses.models.types.ResponseOutputItemAddedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryPartAddedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryTextDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningTextDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseRefusalDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseTextDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseWebSearchCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseWebSearchCallSearchingEvent or + ~azure.ai.agentserver.responses.models.types.ResponseImageGenCallGeneratingEvent or + ~azure.ai.agentserver.responses.models.types.ResponseImageGenCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseImageGenCallPartialImageEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallArgumentsDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallFailedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPListToolsFailedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPListToolsInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseOutputTextAnnotationAddedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseQueuedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCustomToolCallInputDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseAudioDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseAudioTranscriptDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallCodeDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseContentPartDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFileSearchCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFunctionCallArgumentsDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseOutputItemDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryPartDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryTextDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningTextDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseRefusalDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseTextDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseWebSearchCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseImageGenCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallArgumentsDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPListToolsCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCustomToolCallInputDoneEvent + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "json_object": + text_response_format_configuration = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format_configuration = { + "name": "str", + "schema": {}, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format_configuration = { + "type": "text" + } + + # JSON input template you can fill out and use as your body input. + body = { + "agent": { + "name": "str", + "type": "agent_reference", + "version": "str" + }, + "agent_reference": { + "name": "str", + "type": "agent_reference", + "version": "str" + }, + "agent_session_id": "str", + "background": bool, + "context_management": [ + { + "type": "str", + "compact_threshold": 0 + } + ], + "conversation": "str", + "include": [ + "str" + ], + "input": "str", + "instructions": "str", + "max_output_tokens": 0, + "max_tool_calls": 0, + "metadata": {}, + "model": "str", + "parallel_tool_calls": bool, + "previous_response_id": "str", + "prompt": { + "id": "str", + "variables": {}, + "version": "str" + }, + "prompt_cache_key": "str", + "prompt_cache_retention": "in-memory", + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "safety_identifier": "str", + "service_tier": "auto", + "store": bool, + "stream": bool, + "stream_options": { + "include_obfuscation": bool + }, + "structured_inputs": { + "str": {} + }, + "temperature": 0.0, + "text": { + "format": text_response_format_configuration, + "verbosity": "low" + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_logprobs": 0, + "top_p": 0.0, + "truncation": "auto", + "user": "str" + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "response.audio.delta": + response_stream_event = { + "delta": bytes("bytes", encoding="utf-8"), + "sequence_number": 0, + "type": "response.audio.delta" + } + + # JSON input template for discriminator value "response.audio.transcript.delta": + response_stream_event = { + "delta": "str", + "sequence_number": 0, + "type": "response.audio.transcript.delta" + } + + # JSON input template for discriminator value + "response.code_interpreter_call_code.delta": + response_stream_event = { + "delta": "str", + "item_id": "str", + "output_index": 0, + "sequence_number": 0, + "type": "response.code_interpreter_call_code.delta" + } + + # JSON input template for discriminator value + "response.code_interpreter_call.in_progress": + response_stream_event = { + "item_id": "str", + "output_index": 0, + "sequence_number": 0, + "type": "response.code_interpreter_call.in_progress" + } + + # JSON input template for discriminator value + "response.code_interpreter_call.interpreting": + response_stream_event = { + "item_id": "str", + "output_index": 0, + "sequence_number": 0, + "type": "response.code_interpreter_call.interpreting" + } + """ + + @overload + async def create_response_stream( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> "_unions.CreateResponseStreamingResponse": + """Creates a model response (streaming response). + + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ResponseAudioDeltaEvent or ResponseAudioTranscriptDeltaEvent or + ResponseCodeInterpreterCallCodeDeltaEvent or ResponseCodeInterpreterCallInProgressEvent or + ResponseCodeInterpreterCallInterpretingEvent or ResponseContentPartAddedEvent or + ResponseCreatedEvent or ResponseErrorEvent or ResponseFileSearchCallInProgressEvent or + ResponseFileSearchCallSearchingEvent or ResponseFunctionCallArgumentsDeltaEvent or + ResponseInProgressEvent or ResponseFailedEvent or ResponseIncompleteEvent or + ResponseOutputItemAddedEvent or ResponseReasoningSummaryPartAddedEvent or + ResponseReasoningSummaryTextDeltaEvent or ResponseReasoningTextDeltaEvent or + ResponseRefusalDeltaEvent or ResponseTextDeltaEvent or ResponseWebSearchCallInProgressEvent or + ResponseWebSearchCallSearchingEvent or ResponseImageGenCallGeneratingEvent or + ResponseImageGenCallInProgressEvent or ResponseImageGenCallPartialImageEvent or + ResponseMCPCallArgumentsDeltaEvent or ResponseMCPCallFailedEvent or + ResponseMCPCallInProgressEvent or ResponseMCPListToolsFailedEvent or + ResponseMCPListToolsInProgressEvent or ResponseOutputTextAnnotationAddedEvent or + ResponseQueuedEvent or ResponseCustomToolCallInputDeltaEvent or ResponseAudioDoneEvent or + ResponseAudioTranscriptDoneEvent or ResponseCodeInterpreterCallCodeDoneEvent or + ResponseCodeInterpreterCallCompletedEvent or ResponseCompletedEvent or + ResponseContentPartDoneEvent or ResponseFileSearchCallCompletedEvent or + ResponseFunctionCallArgumentsDoneEvent or ResponseOutputItemDoneEvent or + ResponseReasoningSummaryPartDoneEvent or ResponseReasoningSummaryTextDoneEvent or + ResponseReasoningTextDoneEvent or ResponseRefusalDoneEvent or ResponseTextDoneEvent or + ResponseWebSearchCallCompletedEvent or ResponseImageGenCallCompletedEvent or + ResponseMCPCallArgumentsDoneEvent or ResponseMCPCallCompletedEvent or + ResponseMCPListToolsCompletedEvent or ResponseCustomToolCallInputDoneEvent + :rtype: ~azure.ai.agentserver.responses.models.types.ResponseAudioDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseAudioTranscriptDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallCodeDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallInterpretingEvent or + ~azure.ai.agentserver.responses.models.types.ResponseContentPartAddedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCreatedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseErrorEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFileSearchCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFileSearchCallSearchingEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFunctionCallArgumentsDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFailedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseIncompleteEvent or + ~azure.ai.agentserver.responses.models.types.ResponseOutputItemAddedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryPartAddedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryTextDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningTextDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseRefusalDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseTextDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseWebSearchCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseWebSearchCallSearchingEvent or + ~azure.ai.agentserver.responses.models.types.ResponseImageGenCallGeneratingEvent or + ~azure.ai.agentserver.responses.models.types.ResponseImageGenCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseImageGenCallPartialImageEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallArgumentsDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallFailedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPListToolsFailedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPListToolsInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseOutputTextAnnotationAddedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseQueuedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCustomToolCallInputDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseAudioDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseAudioTranscriptDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallCodeDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseContentPartDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFileSearchCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFunctionCallArgumentsDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseOutputItemDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryPartDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryTextDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningTextDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseRefusalDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseTextDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseWebSearchCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseImageGenCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallArgumentsDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPListToolsCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCustomToolCallInputDoneEvent + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "response.audio.delta": + response_stream_event = { + "delta": bytes("bytes", encoding="utf-8"), + "sequence_number": 0, + "type": "response.audio.delta" + } + + # JSON input template for discriminator value "response.audio.transcript.delta": + response_stream_event = { + "delta": "str", + "sequence_number": 0, + "type": "response.audio.transcript.delta" + } + + # JSON input template for discriminator value + "response.code_interpreter_call_code.delta": + response_stream_event = { + "delta": "str", + "item_id": "str", + "output_index": 0, + "sequence_number": 0, + "type": "response.code_interpreter_call_code.delta" + } + + # JSON input template for discriminator value + "response.code_interpreter_call.in_progress": + response_stream_event = { + "item_id": "str", + "output_index": 0, + "sequence_number": 0, + "type": "response.code_interpreter_call.in_progress" + } + + # JSON input template for discriminator value + "response.code_interpreter_call.interpreting": + response_stream_event = { + "item_id": "str", + "output_index": 0, + "sequence_number": 0, + "type": "response.code_interpreter_call.interpreting" + } + """ + + @distributed_trace_async + async def create_response_stream( # pylint: disable=too-many-locals + self, + body: Union[JSON, IO[bytes]] = _Unset, + metadata: Optional[_types.Metadata] = None, + top_logprobs: Optional[int] = None, + temperature: Optional[float] = None, + top_p: Optional[float] = None, + user: Optional[str] = None, + safety_identifier: Optional[str] = None, + prompt_cache_key: Optional[str] = None, + service_tier: Optional[Literal["auto", "default", "flex", "scale", "priority"]] = None, + prompt_cache_retention: Optional[Literal["in-memory", "24h"]] = None, + previous_response_id: Optional[str] = None, + model: Optional[str] = None, + reasoning: Optional[_types.Reasoning] = None, + background: Optional[bool] = None, + max_output_tokens: Optional[int] = None, + max_tool_calls: Optional[int] = None, + text: Optional[_types.ResponseTextParam] = None, + tools: Optional[list[_types.Tool]] = None, + tool_choice: Optional[Union[types.ToolChoiceOptions, _types.ToolChoiceParam]] = None, + prompt: Optional[_types.Prompt] = None, + truncation: Optional[Literal["auto", "disabled"]] = None, + input: Optional["_unions.InputParam"] = None, + include: Optional[list[types.IncludeEnum]] = None, + parallel_tool_calls: Optional[bool] = None, + store: Optional[bool] = None, + instructions: Optional[str] = None, + stream_parameter: Optional[bool] = None, + stream_options: Optional[_types.ResponseStreamOptions] = None, + conversation: Optional["_unions.ConversationParam"] = None, + context_management: Optional[list[_types.ContextManagementParam]] = None, + agent: Optional[_types.AgentReference] = None, + agent_session_id: Optional[str] = None, + agent_reference: Optional[_types.AgentReference] = None, + structured_inputs: Optional[dict[str, Any]] = None, + **kwargs: Any + ) -> "_unions.CreateResponseStreamingResponse": + """Creates a model response (streaming response). + + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :param metadata: Default value is None. + :type metadata: ~azure.ai.agentserver.responses.models.types.Metadata + :param top_logprobs: Default value is None. + :type top_logprobs: int + :param temperature: Default value is None. + :type temperature: float + :param top_p: Default value is None. + :type top_p: float + :param user: This field is being replaced by ``safety_identifier`` and ``prompt_cache_key``. + Use ``prompt_cache_key`` instead to maintain caching optimizations. + A stable identifier for your end-users. + Used to boost cache hit rates by better bucketing similar requests and to help OpenAI + detect and prevent abuse. `Learn more + `_. Default value is None. + :type user: str + :param safety_identifier: A stable identifier used to help detect users of your application + that may be violating OpenAI's usage policies. + The IDs should be a string that uniquely identifies each user. We recommend hashing their + username or email address, in order to avoid sending us any identifying information. `Learn + more `_. Default value is None. + :type safety_identifier: str + :param prompt_cache_key: Used by OpenAI to cache responses for similar requests to optimize + your cache hit rates. Replaces the ``user`` field. `Learn more `_. + Default value is None. + :type prompt_cache_key: str + :param service_tier: Is one of the following types: Literal["auto"], Literal["default"], + Literal["flex"], Literal["scale"], Literal["priority"] Default value is None. + :type service_tier: str or str or str or str or str + :param prompt_cache_retention: Is either a Literal["in-memory"] type or a Literal["24h"] type. + Default value is None. + :type prompt_cache_retention: str or str + :param previous_response_id: Default value is None. + :type previous_response_id: str + :param model: The model deployment to use for the creation of this response. Default value is + None. + :type model: str + :param reasoning: Default value is None. + :type reasoning: ~azure.ai.agentserver.responses.models.types.Reasoning + :param background: Default value is None. + :type background: bool + :param max_output_tokens: Default value is None. + :type max_output_tokens: int + :param max_tool_calls: Default value is None. + :type max_tool_calls: int + :param text: Default value is None. + :type text: ~azure.ai.agentserver.responses.models.types.ResponseTextParam + :param tools: Default value is None. + :type tools: list[~azure.ai.agentserver.responses.models.types.Tool] + :param tool_choice: Is either a types.ToolChoiceOptions type or a ToolChoiceParam type. Default + value is None. + :type tool_choice: str or ~azure.ai.agentserver.responses.models.models.ToolChoiceOptions or + ~azure.ai.agentserver.responses.models.types.ToolChoiceParam + :param prompt: Default value is None. + :type prompt: ~azure.ai.agentserver.responses.models.types.Prompt + :param truncation: Is either a Literal["auto"] type or a Literal["disabled"] type. Default + value is None. + :type truncation: str or str + :param input: Is either a str type or a [Item] type. Default value is None. + :type input: str or list[~azure.ai.agentserver.responses.models.types.Item] + :param include: Default value is None. + :type include: list[str or ~azure.ai.agentserver.responses.models.models.IncludeEnum] + :param parallel_tool_calls: Default value is None. + :type parallel_tool_calls: bool + :param store: Default value is None. + :type store: bool + :param instructions: Default value is None. + :type instructions: str + :param stream_parameter: Default value is None. + :type stream_parameter: bool + :param stream_options: Default value is None. + :type stream_options: ~azure.ai.agentserver.responses.models.types.ResponseStreamOptions + :param conversation: Is either a str type or a ConversationParam_2 type. Default value is None. + :type conversation: str or ~azure.ai.agentserver.responses.models.types.ConversationParam_2 + :param context_management: Context management configuration for this request. Default value is + None. + :type context_management: + list[~azure.ai.agentserver.responses.models.types.ContextManagementParam] + :param agent: (Deprecated) Use agent_reference instead. + The agent to use for generating the response. Default value is None. + :type agent: ~azure.ai.agentserver.responses.models.types.AgentReference + :param agent_session_id: Optional session identifier for sandbox affinity. Currently only + relevant for hosted agents. + When provided, the request is routed to the same sandbox. When omitted, auto-derived from + conversation_id/prev_response_id or a new UUID is generated. Default value is None. + :type agent_session_id: str + :param agent_reference: The agent to use for generating the response. Default value is None. + :type agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :param structured_inputs: The structured inputs to the response that can participate in prompt + template substitution or tool argument bindings. Default value is None. + :type structured_inputs: dict[str, any] + :return: ResponseAudioDeltaEvent or ResponseAudioTranscriptDeltaEvent or + ResponseCodeInterpreterCallCodeDeltaEvent or ResponseCodeInterpreterCallInProgressEvent or + ResponseCodeInterpreterCallInterpretingEvent or ResponseContentPartAddedEvent or + ResponseCreatedEvent or ResponseErrorEvent or ResponseFileSearchCallInProgressEvent or + ResponseFileSearchCallSearchingEvent or ResponseFunctionCallArgumentsDeltaEvent or + ResponseInProgressEvent or ResponseFailedEvent or ResponseIncompleteEvent or + ResponseOutputItemAddedEvent or ResponseReasoningSummaryPartAddedEvent or + ResponseReasoningSummaryTextDeltaEvent or ResponseReasoningTextDeltaEvent or + ResponseRefusalDeltaEvent or ResponseTextDeltaEvent or ResponseWebSearchCallInProgressEvent or + ResponseWebSearchCallSearchingEvent or ResponseImageGenCallGeneratingEvent or + ResponseImageGenCallInProgressEvent or ResponseImageGenCallPartialImageEvent or + ResponseMCPCallArgumentsDeltaEvent or ResponseMCPCallFailedEvent or + ResponseMCPCallInProgressEvent or ResponseMCPListToolsFailedEvent or + ResponseMCPListToolsInProgressEvent or ResponseOutputTextAnnotationAddedEvent or + ResponseQueuedEvent or ResponseCustomToolCallInputDeltaEvent or ResponseAudioDoneEvent or + ResponseAudioTranscriptDoneEvent or ResponseCodeInterpreterCallCodeDoneEvent or + ResponseCodeInterpreterCallCompletedEvent or ResponseCompletedEvent or + ResponseContentPartDoneEvent or ResponseFileSearchCallCompletedEvent or + ResponseFunctionCallArgumentsDoneEvent or ResponseOutputItemDoneEvent or + ResponseReasoningSummaryPartDoneEvent or ResponseReasoningSummaryTextDoneEvent or + ResponseReasoningTextDoneEvent or ResponseRefusalDoneEvent or ResponseTextDoneEvent or + ResponseWebSearchCallCompletedEvent or ResponseImageGenCallCompletedEvent or + ResponseMCPCallArgumentsDoneEvent or ResponseMCPCallCompletedEvent or + ResponseMCPListToolsCompletedEvent or ResponseCustomToolCallInputDoneEvent + :rtype: ~azure.ai.agentserver.responses.models.types.ResponseAudioDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseAudioTranscriptDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallCodeDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallInterpretingEvent or + ~azure.ai.agentserver.responses.models.types.ResponseContentPartAddedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCreatedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseErrorEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFileSearchCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFileSearchCallSearchingEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFunctionCallArgumentsDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFailedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseIncompleteEvent or + ~azure.ai.agentserver.responses.models.types.ResponseOutputItemAddedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryPartAddedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryTextDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningTextDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseRefusalDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseTextDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseWebSearchCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseWebSearchCallSearchingEvent or + ~azure.ai.agentserver.responses.models.types.ResponseImageGenCallGeneratingEvent or + ~azure.ai.agentserver.responses.models.types.ResponseImageGenCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseImageGenCallPartialImageEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallArgumentsDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallFailedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPListToolsFailedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPListToolsInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseOutputTextAnnotationAddedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseQueuedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCustomToolCallInputDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseAudioDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseAudioTranscriptDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallCodeDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseContentPartDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFileSearchCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFunctionCallArgumentsDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseOutputItemDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryPartDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryTextDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningTextDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseRefusalDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseTextDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseWebSearchCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseImageGenCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallArgumentsDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPListToolsCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCustomToolCallInputDoneEvent + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "json_object": + text_response_format_configuration = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format_configuration = { + "name": "str", + "schema": {}, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format_configuration = { + "type": "text" + } + + # JSON input template you can fill out and use as your body input. + body = { + "agent": { + "name": "str", + "type": "agent_reference", + "version": "str" + }, + "agent_reference": { + "name": "str", + "type": "agent_reference", + "version": "str" + }, + "agent_session_id": "str", + "background": bool, + "context_management": [ + { + "type": "str", + "compact_threshold": 0 + } + ], + "conversation": "str", + "include": [ + "str" + ], + "input": "str", + "instructions": "str", + "max_output_tokens": 0, + "max_tool_calls": 0, + "metadata": {}, + "model": "str", + "parallel_tool_calls": bool, + "previous_response_id": "str", + "prompt": { + "id": "str", + "variables": {}, + "version": "str" + }, + "prompt_cache_key": "str", + "prompt_cache_retention": "in-memory", + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "safety_identifier": "str", + "service_tier": "auto", + "store": bool, + "stream": bool, + "stream_options": { + "include_obfuscation": bool + }, + "structured_inputs": { + "str": {} + }, + "temperature": 0.0, + "text": { + "format": text_response_format_configuration, + "verbosity": "low" + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_logprobs": 0, + "top_p": 0.0, + "truncation": "auto", + "user": "str" + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "response.audio.delta": + response_stream_event = { + "delta": bytes("bytes", encoding="utf-8"), + "sequence_number": 0, + "type": "response.audio.delta" + } + + # JSON input template for discriminator value "response.audio.transcript.delta": + response_stream_event = { + "delta": "str", + "sequence_number": 0, + "type": "response.audio.transcript.delta" + } + + # JSON input template for discriminator value + "response.code_interpreter_call_code.delta": + response_stream_event = { + "delta": "str", + "item_id": "str", + "output_index": 0, + "sequence_number": 0, + "type": "response.code_interpreter_call_code.delta" + } + + # JSON input template for discriminator value + "response.code_interpreter_call.in_progress": + response_stream_event = { + "item_id": "str", + "output_index": 0, + "sequence_number": 0, + "type": "response.code_interpreter_call.in_progress" + } + + # JSON input template for discriminator value + "response.code_interpreter_call.interpreting": + response_stream_event = { + "item_id": "str", + "output_index": 0, + "sequence_number": 0, + "type": "response.code_interpreter_call.interpreting" + } + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType["_unions.CreateResponseStreamingResponse"] = kwargs.pop("cls", None) + + if body is _Unset: + body = { + "agent": agent, + "agent_reference": agent_reference, + "agent_session_id": agent_session_id, + "background": background, + "context_management": context_management, + "conversation": conversation, + "include": include, + "input": input, + "instructions": instructions, + "max_output_tokens": max_output_tokens, + "max_tool_calls": max_tool_calls, + "metadata": metadata, + "model": model, + "parallel_tool_calls": parallel_tool_calls, + "previous_response_id": previous_response_id, + "prompt": prompt, + "prompt_cache_key": prompt_cache_key, + "prompt_cache_retention": prompt_cache_retention, + "reasoning": reasoning, + "safety_identifier": safety_identifier, + "service_tier": service_tier, + "store": store, + "stream": stream_parameter, + "stream_options": stream_options, + "structured_inputs": structured_inputs, + "temperature": temperature, + "text": text, + "tool_choice": tool_choice, + "tools": tools, + "top_logprobs": top_logprobs, + "top_p": top_p, + "truncation": truncation, + "user": user, + } + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_responses_create_response_stream_request( + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _types.ApiErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_response( + self, + response_id: str, + *, + includables: Optional[list[types.IncludeEnum]] = None, + stream_parameter: Optional[bool] = None, + starting_after: Optional[int] = None, + **kwargs: Any + ) -> _types.ResponseObject: + """Retrieves a model response with the given ID. + + :param response_id: Required. + :type response_id: str + :keyword includables: Default value is None. + :paramtype includables: list[str or ~azure.ai.agentserver.responses.models.models.IncludeEnum] + :keyword stream_parameter: Default value is None. + :paramtype stream_parameter: bool + :keyword starting_after: Default value is None. + :paramtype starting_after: int + :return: ResponseObject + :rtype: ~azure.ai.agentserver.responses.models.types.ResponseObject + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "json_object": + text_response_format_configuration = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format_configuration = { + "name": "str", + "schema": {}, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format_configuration = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "agent_reference": { + "name": "str", + "type": "agent_reference", + "version": "str" + }, + "created_at": "2020-02-20 00:00:00", + "error": { + "code": "str", + "message": "str" + }, + "id": "str", + "incomplete_details": { + "reason": "max_output_tokens" + }, + "instructions": "str", + "object": "response", + "output": [ + output_item + ], + "parallel_tool_calls": bool, + "agent": { + "name": "str", + "type": "agent_id", + "version": "str" + }, + "agent_session_id": "str", + "background": bool, + "completed_at": "2020-02-20 00:00:00", + "conversation": { + "id": "str" + }, + "max_output_tokens": 0, + "max_tool_calls": 0, + "metadata": {}, + "model": "str", + "output_text": "str", + "previous_response_id": "str", + "prompt": { + "id": "str", + "variables": {}, + "version": "str" + }, + "prompt_cache_key": "str", + "prompt_cache_retention": "in-memory", + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "safety_identifier": "str", + "service_tier": "auto", + "status": "completed", + "temperature": 0.0, + "text": { + "format": text_response_format_configuration, + "verbosity": "low" + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_logprobs": 0, + "top_p": 0.0, + "truncation": "auto", + "usage": { + "input_tokens": 0, + "input_tokens_details": { + "cached_tokens": 0 + }, + "output_tokens": 0, + "output_tokens_details": { + "reasoning_tokens": 0 + }, + "total_tokens": 0 + }, + "user": "str" + } + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_types.ResponseObject] = kwargs.pop("cls", None) + + _request = build_responses_get_response_request( + response_id=response_id, + includables=includables, + stream_parameter=stream_parameter, + starting_after=starting_after, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _types.ApiErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_response_stream( + self, + response_id: str, + *, + includables: Optional[list[types.IncludeEnum]] = None, + starting_after: Optional[int] = None, + **kwargs: Any + ) -> "_unions.CreateResponseStreamingResponse": + """Retrieves a model response with the given ID (streaming response). + + :param response_id: Required. + :type response_id: str + :keyword includables: Default value is None. + :paramtype includables: list[str or ~azure.ai.agentserver.responses.models.models.IncludeEnum] + :keyword starting_after: Default value is None. + :paramtype starting_after: int + :return: ResponseAudioDeltaEvent or ResponseAudioTranscriptDeltaEvent or + ResponseCodeInterpreterCallCodeDeltaEvent or ResponseCodeInterpreterCallInProgressEvent or + ResponseCodeInterpreterCallInterpretingEvent or ResponseContentPartAddedEvent or + ResponseCreatedEvent or ResponseErrorEvent or ResponseFileSearchCallInProgressEvent or + ResponseFileSearchCallSearchingEvent or ResponseFunctionCallArgumentsDeltaEvent or + ResponseInProgressEvent or ResponseFailedEvent or ResponseIncompleteEvent or + ResponseOutputItemAddedEvent or ResponseReasoningSummaryPartAddedEvent or + ResponseReasoningSummaryTextDeltaEvent or ResponseReasoningTextDeltaEvent or + ResponseRefusalDeltaEvent or ResponseTextDeltaEvent or ResponseWebSearchCallInProgressEvent or + ResponseWebSearchCallSearchingEvent or ResponseImageGenCallGeneratingEvent or + ResponseImageGenCallInProgressEvent or ResponseImageGenCallPartialImageEvent or + ResponseMCPCallArgumentsDeltaEvent or ResponseMCPCallFailedEvent or + ResponseMCPCallInProgressEvent or ResponseMCPListToolsFailedEvent or + ResponseMCPListToolsInProgressEvent or ResponseOutputTextAnnotationAddedEvent or + ResponseQueuedEvent or ResponseCustomToolCallInputDeltaEvent or ResponseAudioDoneEvent or + ResponseAudioTranscriptDoneEvent or ResponseCodeInterpreterCallCodeDoneEvent or + ResponseCodeInterpreterCallCompletedEvent or ResponseCompletedEvent or + ResponseContentPartDoneEvent or ResponseFileSearchCallCompletedEvent or + ResponseFunctionCallArgumentsDoneEvent or ResponseOutputItemDoneEvent or + ResponseReasoningSummaryPartDoneEvent or ResponseReasoningSummaryTextDoneEvent or + ResponseReasoningTextDoneEvent or ResponseRefusalDoneEvent or ResponseTextDoneEvent or + ResponseWebSearchCallCompletedEvent or ResponseImageGenCallCompletedEvent or + ResponseMCPCallArgumentsDoneEvent or ResponseMCPCallCompletedEvent or + ResponseMCPListToolsCompletedEvent or ResponseCustomToolCallInputDoneEvent + :rtype: ~azure.ai.agentserver.responses.models.types.ResponseAudioDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseAudioTranscriptDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallCodeDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallInterpretingEvent or + ~azure.ai.agentserver.responses.models.types.ResponseContentPartAddedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCreatedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseErrorEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFileSearchCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFileSearchCallSearchingEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFunctionCallArgumentsDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFailedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseIncompleteEvent or + ~azure.ai.agentserver.responses.models.types.ResponseOutputItemAddedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryPartAddedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryTextDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningTextDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseRefusalDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseTextDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseWebSearchCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseWebSearchCallSearchingEvent or + ~azure.ai.agentserver.responses.models.types.ResponseImageGenCallGeneratingEvent or + ~azure.ai.agentserver.responses.models.types.ResponseImageGenCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseImageGenCallPartialImageEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallArgumentsDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallFailedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPListToolsFailedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPListToolsInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseOutputTextAnnotationAddedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseQueuedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCustomToolCallInputDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseAudioDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseAudioTranscriptDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallCodeDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseContentPartDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFileSearchCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFunctionCallArgumentsDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseOutputItemDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryPartDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryTextDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningTextDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseRefusalDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseTextDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseWebSearchCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseImageGenCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallArgumentsDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPListToolsCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCustomToolCallInputDoneEvent + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "response.audio.delta": + response_stream_event = { + "delta": bytes("bytes", encoding="utf-8"), + "sequence_number": 0, + "type": "response.audio.delta" + } + + # JSON input template for discriminator value "response.audio.transcript.delta": + response_stream_event = { + "delta": "str", + "sequence_number": 0, + "type": "response.audio.transcript.delta" + } + + # JSON input template for discriminator value + "response.code_interpreter_call_code.delta": + response_stream_event = { + "delta": "str", + "item_id": "str", + "output_index": 0, + "sequence_number": 0, + "type": "response.code_interpreter_call_code.delta" + } + + # JSON input template for discriminator value + "response.code_interpreter_call.in_progress": + response_stream_event = { + "item_id": "str", + "output_index": 0, + "sequence_number": 0, + "type": "response.code_interpreter_call.in_progress" + } + + # JSON input template for discriminator value + "response.code_interpreter_call.interpreting": + response_stream_event = { + "item_id": "str", + "output_index": 0, + "sequence_number": 0, + "type": "response.code_interpreter_call.interpreting" + } + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + accept: Literal["text/event-stream"] = kwargs.pop("accept", _headers.pop("accept", "text/event-stream")) + cls: ClsType["_unions.CreateResponseStreamingResponse"] = kwargs.pop("cls", None) + + _request = build_responses_get_response_stream_request( + response_id=response_id, + includables=includables, + starting_after=starting_after, + accept=accept, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _types.ApiErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete_response(self, response_id: str, **kwargs: Any) -> _types.DeleteResponseResult: + """Deletes a model response. + + :param response_id: The ID of the response to delete. Required. + :type response_id: str + :return: DeleteResponseResult + :rtype: ~azure.ai.agentserver.responses.models.types.DeleteResponseResult + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "deleted": True, + "id": "str", + "object": "response" + } + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_types.DeleteResponseResult] = kwargs.pop("cls", None) + + _request = build_responses_delete_response_request( + response_id=response_id, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _types.ApiErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def cancel_response(self, response_id: str, **kwargs: Any) -> _types.ResponseObject: + """Cancels a model response. + + :param response_id: The ID of the response to cancel. Required. + :type response_id: str + :return: ResponseObject + :rtype: ~azure.ai.agentserver.responses.models.types.ResponseObject + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "json_object": + text_response_format_configuration = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format_configuration = { + "name": "str", + "schema": {}, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format_configuration = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "agent_reference": { + "name": "str", + "type": "agent_reference", + "version": "str" + }, + "created_at": "2020-02-20 00:00:00", + "error": { + "code": "str", + "message": "str" + }, + "id": "str", + "incomplete_details": { + "reason": "max_output_tokens" + }, + "instructions": "str", + "object": "response", + "output": [ + output_item + ], + "parallel_tool_calls": bool, + "agent": { + "name": "str", + "type": "agent_id", + "version": "str" + }, + "agent_session_id": "str", + "background": bool, + "completed_at": "2020-02-20 00:00:00", + "conversation": { + "id": "str" + }, + "max_output_tokens": 0, + "max_tool_calls": 0, + "metadata": {}, + "model": "str", + "output_text": "str", + "previous_response_id": "str", + "prompt": { + "id": "str", + "variables": {}, + "version": "str" + }, + "prompt_cache_key": "str", + "prompt_cache_retention": "in-memory", + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "safety_identifier": "str", + "service_tier": "auto", + "status": "completed", + "temperature": 0.0, + "text": { + "format": text_response_format_configuration, + "verbosity": "low" + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_logprobs": 0, + "top_p": 0.0, + "truncation": "auto", + "usage": { + "input_tokens": 0, + "input_tokens_details": { + "cached_tokens": 0 + }, + "output_tokens": 0, + "output_tokens_details": { + "reasoning_tokens": 0 + }, + "total_tokens": 0 + }, + "user": "str" + } + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_types.ResponseObject] = kwargs.pop("cls", None) + + _request = build_responses_cancel_response_request( + response_id=response_id, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _types.ApiErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_input_items( + self, + response_id: str, + *, + limit: Optional[int] = None, + order: Optional[types.PageOrder] = None, + before: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_types.OutputItem"]: + """Returns a list of input items for a given response. + + :param response_id: Required. + :type response_id: str + :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and + 100, and the + default is 20. Default value is None. + :paramtype limit: int + :keyword order: Sort order by the ``created_at`` timestamp of the objects. ``asc`` for + ascending order and``desc`` + for descending order. Known values are: "asc" and "desc". Default value is None. + :paramtype order: str or ~azure.ai.agentserver.responses.models.models.PageOrder + :keyword 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. + Default value is None. + :paramtype before: str + :return: An iterator like instance of OutputItem + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agentserver.responses.models.types.OutputItem] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "a2a_preview_call": + output_item = { + "arguments": "str", + "call_id": "str", + "id": "str", + "name": "str", + "status": "str", + "type": "a2a_preview_call", + "agent_reference": { + "name": "str", + "type": "agent_reference", + "version": "str" + }, + "created_by": { + "agent": { + "name": "str", + "type": "agent_id", + "version": "str" + }, + "response_id": "str" + }, + "response_id": "str" + } + + # JSON input template for discriminator value "a2a_preview_call_output": + output_item = { + "call_id": "str", + "id": "str", + "name": "str", + "status": "str", + "type": "a2a_preview_call_output", + "agent_reference": { + "name": "str", + "type": "agent_reference", + "version": "str" + }, + "created_by": { + "agent": { + "name": "str", + "type": "agent_id", + "version": "str" + }, + "response_id": "str" + }, + "output": { + "str": {} + }, + "response_id": "str" + } + + # JSON input template for discriminator value "apply_patch_call": + output_item = { + "call_id": "str", + "id": "str", + "operation": apply_patch_file_operation, + "status": "str", + "type": "apply_patch_call", + "agent_reference": { + "name": "str", + "type": "agent_reference", + "version": "str" + }, + "created_by": { + "agent": { + "name": "str", + "type": "agent_id", + "version": "str" + }, + "response_id": "str" + }, + "response_id": "str" + } + + # JSON input template for discriminator value "create_file": + apply_patch_file_operation = { + "diff": "str", + "path": "str", + "type": "create_file" + } + + # JSON input template for discriminator value "delete_file": + apply_patch_file_operation = { + "path": "str", + "type": "delete_file" + } + + # response body for status code(s): 200 + response == output_item + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_types.OutputItem]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(_continuation_token=None): + + _request = build_responses_list_input_items_request( + response_id=response_id, + limit=limit, + order=order, + after=_continuation_token, + before=before, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized.get("data", []) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("last_id") or None, AsyncList(list_of_elem) + + async def get_next(_continuation_token=None): + _request = prepare_request(_continuation_token) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _types.ApiErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_responses( + self, + *, + limit: Optional[int] = None, + order: Optional[types.PageOrder] = None, + before: Optional[str] = None, + agent_name: Optional[str] = None, + agent_id: Optional[str] = None, + conversation_id: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_types.ResponseObject"]: + """Returns the list of all responses. + + :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and + 100, and the + default is 20. Default value is None. + :paramtype limit: int + :keyword order: Sort order by the ``created_at`` timestamp of the objects. ``asc`` for + ascending order and``desc`` + for descending order. Known values are: "asc" and "desc". Default value is None. + :paramtype order: str or ~azure.ai.agentserver.responses.models.models.PageOrder + :keyword 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. + Default value is None. + :paramtype before: str + :keyword agent_name: Filter by agent name. If provided, only items associated with the + specified agent will be returned. Default value is None. + :paramtype agent_name: str + :keyword agent_id: Filter by agent ID in the format ``name:version``. If provided, only items + associated with the specified agent ID will be returned. Default value is None. + :paramtype agent_id: str + :keyword conversation_id: Filter by conversation ID. If provided, only responses associated + with the specified conversation will be returned. Default value is None. + :paramtype conversation_id: str + :return: An iterator like instance of ResponseObject + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agentserver.responses.models.types.ResponseObject] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "json_object": + text_response_format_configuration = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format_configuration = { + "name": "str", + "schema": {}, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format_configuration = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "agent_reference": { + "name": "str", + "type": "agent_reference", + "version": "str" + }, + "created_at": "2020-02-20 00:00:00", + "error": { + "code": "str", + "message": "str" + }, + "id": "str", + "incomplete_details": { + "reason": "max_output_tokens" + }, + "instructions": "str", + "object": "response", + "output": [ + output_item + ], + "parallel_tool_calls": bool, + "agent": { + "name": "str", + "type": "agent_id", + "version": "str" + }, + "agent_session_id": "str", + "background": bool, + "completed_at": "2020-02-20 00:00:00", + "conversation": { + "id": "str" + }, + "max_output_tokens": 0, + "max_tool_calls": 0, + "metadata": {}, + "model": "str", + "output_text": "str", + "previous_response_id": "str", + "prompt": { + "id": "str", + "variables": {}, + "version": "str" + }, + "prompt_cache_key": "str", + "prompt_cache_retention": "in-memory", + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "safety_identifier": "str", + "service_tier": "auto", + "status": "completed", + "temperature": 0.0, + "text": { + "format": text_response_format_configuration, + "verbosity": "low" + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_logprobs": 0, + "top_p": 0.0, + "truncation": "auto", + "usage": { + "input_tokens": 0, + "input_tokens_details": { + "cached_tokens": 0 + }, + "output_tokens": 0, + "output_tokens_details": { + "reasoning_tokens": 0 + }, + "total_tokens": 0 + }, + "user": "str" + } + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_types.ResponseObject]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(_continuation_token=None): + + _request = build_responses_list_responses_request( + limit=limit, + order=order, + after=_continuation_token, + before=before, + agent_name=agent_name, + agent_id=agent_id, + conversation_id=conversation_id, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized.get("data", []) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("last_id") or None, AsyncList(list_of_elem) + + async def get_next(_continuation_token=None): + _request = prepare_request(_continuation_token) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _types.ApiErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @overload + async def compact_response_conversation( + self, + model: types.ModelIdsCompaction, + input: Optional[Union[str, list[_types.Item]]] = None, + previous_response_id: Optional[str] = None, + instructions: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _types.CompactResource: + """Produces a compaction of a responses conversation. + + :param model: Known values are: "gpt-5.2", "gpt-5.2-2025-12-11", "gpt-5.2-chat-latest", + "gpt-5.2-pro", "gpt-5.2-pro-2025-12-11", "gpt-5.1", "gpt-5.1-2025-11-13", "gpt-5.1-codex", + "gpt-5.1-mini", "gpt-5.1-chat-latest", "gpt-5", "gpt-5-mini", "gpt-5-nano", "gpt-5-2025-08-07", + "gpt-5-mini-2025-08-07", "gpt-5-nano-2025-08-07", "gpt-5-chat-latest", "gpt-4.1", + "gpt-4.1-mini", "gpt-4.1-nano", "gpt-4.1-2025-04-14", "gpt-4.1-mini-2025-04-14", + "gpt-4.1-nano-2025-04-14", "o4-mini", "o4-mini-2025-04-16", "o3", "o3-2025-04-16", "o3-mini", + "o3-mini-2025-01-31", "o1", "o1-2024-12-17", "o1-preview", "o1-preview-2024-09-12", "o1-mini", + "o1-mini-2024-09-12", "gpt-4o", "gpt-4o-2024-11-20", "gpt-4o-2024-08-06", "gpt-4o-2024-05-13", + "gpt-4o-audio-preview", "gpt-4o-audio-preview-2024-10-01", "gpt-4o-audio-preview-2024-12-17", + "gpt-4o-audio-preview-2025-06-03", "gpt-4o-mini-audio-preview", + "gpt-4o-mini-audio-preview-2024-12-17", "gpt-4o-search-preview", "gpt-4o-mini-search-preview", + "gpt-4o-search-preview-2025-03-11", "gpt-4o-mini-search-preview-2025-03-11", + "chatgpt-4o-latest", "codex-mini-latest", "gpt-4o-mini", "gpt-4o-mini-2024-07-18", + "gpt-4-turbo", "gpt-4-turbo-2024-04-09", "gpt-4-0125-preview", "gpt-4-turbo-preview", + "gpt-4-1106-preview", "gpt-4-vision-preview", "gpt-4", "gpt-4-0314", "gpt-4-0613", "gpt-4-32k", + "gpt-4-32k-0314", "gpt-4-32k-0613", "gpt-3.5-turbo", "gpt-3.5-turbo-16k", "gpt-3.5-turbo-0301", + "gpt-3.5-turbo-0613", "gpt-3.5-turbo-1106", "gpt-3.5-turbo-0125", "gpt-3.5-turbo-16k-0613", + "o1-pro", "o1-pro-2025-03-19", "o3-pro", "o3-pro-2025-06-10", "o3-deep-research", + "o3-deep-research-2025-06-26", "o4-mini-deep-research", "o4-mini-deep-research-2025-06-26", + "computer-use-preview", "computer-use-preview-2025-03-11", "gpt-5-codex", "gpt-5-pro", + "gpt-5-pro-2025-10-06", and "gpt-5.1-codex-max". Required. + :type model: str or ~azure.ai.agentserver.responses.models.models.ModelIdsCompaction + :param input: Is either a str type or a [Item] type. Default value is None. + :type input: str or list[~azure.ai.agentserver.responses.models.types.Item] + :param previous_response_id: Default value is None. + :type previous_response_id: str + :param instructions: Default value is None. + :type instructions: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CompactResource + :rtype: ~azure.ai.agentserver.responses.models.types.CompactResource + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "id": "str", + "object": "response.compaction", + "output": [ + item_field + ], + "usage": { + "input_tokens": 0, + "input_tokens_details": { + "cached_tokens": 0 + }, + "output_tokens": 0, + "output_tokens_details": { + "reasoning_tokens": 0 + }, + "total_tokens": 0 + } + } + """ + + @overload + async def compact_response_conversation( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _types.CompactResource: + """Produces a compaction of a responses conversation. + + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CompactResource + :rtype: ~azure.ai.agentserver.responses.models.types.CompactResource + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "model": "str", + "input": "str", + "instructions": "str", + "previous_response_id": "str" + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "id": "str", + "object": "response.compaction", + "output": [ + item_field + ], + "usage": { + "input_tokens": 0, + "input_tokens_details": { + "cached_tokens": 0 + }, + "output_tokens": 0, + "output_tokens_details": { + "reasoning_tokens": 0 + }, + "total_tokens": 0 + } + } + """ + + @overload + async def compact_response_conversation( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _types.CompactResource: + """Produces a compaction of a responses conversation. + + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: CompactResource + :rtype: ~azure.ai.agentserver.responses.models.types.CompactResource + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "id": "str", + "object": "response.compaction", + "output": [ + item_field + ], + "usage": { + "input_tokens": 0, + "input_tokens_details": { + "cached_tokens": 0 + }, + "output_tokens": 0, + "output_tokens_details": { + "reasoning_tokens": 0 + }, + "total_tokens": 0 + } + } + """ + + @distributed_trace_async + async def compact_response_conversation( + self, + model: types.ModelIdsCompaction = _Unset, + body: Union[JSON, IO[bytes]] = _Unset, + input: Optional[Union[str, list[_types.Item]]] = None, + previous_response_id: Optional[str] = None, + instructions: Optional[str] = None, + **kwargs: Any + ) -> _types.CompactResource: + """Produces a compaction of a responses conversation. + + :param model: Known values are: "gpt-5.2", "gpt-5.2-2025-12-11", "gpt-5.2-chat-latest", + "gpt-5.2-pro", "gpt-5.2-pro-2025-12-11", "gpt-5.1", "gpt-5.1-2025-11-13", "gpt-5.1-codex", + "gpt-5.1-mini", "gpt-5.1-chat-latest", "gpt-5", "gpt-5-mini", "gpt-5-nano", "gpt-5-2025-08-07", + "gpt-5-mini-2025-08-07", "gpt-5-nano-2025-08-07", "gpt-5-chat-latest", "gpt-4.1", + "gpt-4.1-mini", "gpt-4.1-nano", "gpt-4.1-2025-04-14", "gpt-4.1-mini-2025-04-14", + "gpt-4.1-nano-2025-04-14", "o4-mini", "o4-mini-2025-04-16", "o3", "o3-2025-04-16", "o3-mini", + "o3-mini-2025-01-31", "o1", "o1-2024-12-17", "o1-preview", "o1-preview-2024-09-12", "o1-mini", + "o1-mini-2024-09-12", "gpt-4o", "gpt-4o-2024-11-20", "gpt-4o-2024-08-06", "gpt-4o-2024-05-13", + "gpt-4o-audio-preview", "gpt-4o-audio-preview-2024-10-01", "gpt-4o-audio-preview-2024-12-17", + "gpt-4o-audio-preview-2025-06-03", "gpt-4o-mini-audio-preview", + "gpt-4o-mini-audio-preview-2024-12-17", "gpt-4o-search-preview", "gpt-4o-mini-search-preview", + "gpt-4o-search-preview-2025-03-11", "gpt-4o-mini-search-preview-2025-03-11", + "chatgpt-4o-latest", "codex-mini-latest", "gpt-4o-mini", "gpt-4o-mini-2024-07-18", + "gpt-4-turbo", "gpt-4-turbo-2024-04-09", "gpt-4-0125-preview", "gpt-4-turbo-preview", + "gpt-4-1106-preview", "gpt-4-vision-preview", "gpt-4", "gpt-4-0314", "gpt-4-0613", "gpt-4-32k", + "gpt-4-32k-0314", "gpt-4-32k-0613", "gpt-3.5-turbo", "gpt-3.5-turbo-16k", "gpt-3.5-turbo-0301", + "gpt-3.5-turbo-0613", "gpt-3.5-turbo-1106", "gpt-3.5-turbo-0125", "gpt-3.5-turbo-16k-0613", + "o1-pro", "o1-pro-2025-03-19", "o3-pro", "o3-pro-2025-06-10", "o3-deep-research", + "o3-deep-research-2025-06-26", "o4-mini-deep-research", "o4-mini-deep-research-2025-06-26", + "computer-use-preview", "computer-use-preview-2025-03-11", "gpt-5-codex", "gpt-5-pro", + "gpt-5-pro-2025-10-06", and "gpt-5.1-codex-max". Required. + :type model: str or ~azure.ai.agentserver.responses.models.models.ModelIdsCompaction + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :param input: Is either a str type or a [Item] type. Default value is None. + :type input: str or list[~azure.ai.agentserver.responses.models.types.Item] + :param previous_response_id: Default value is None. + :type previous_response_id: str + :param instructions: Default value is None. + :type instructions: str + :return: CompactResource + :rtype: ~azure.ai.agentserver.responses.models.types.CompactResource + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "model": "str", + "input": "str", + "instructions": "str", + "previous_response_id": "str" + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "id": "str", + "object": "response.compaction", + "output": [ + item_field + ], + "usage": { + "input_tokens": 0, + "input_tokens_details": { + "cached_tokens": 0 + }, + "output_tokens": 0, + "output_tokens_details": { + "reasoning_tokens": 0 + }, + "total_tokens": 0 + } + } + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_types.CompactResource] = kwargs.pop("cls", None) + + if body is _Unset: + if model is _Unset: + raise TypeError("missing required argument: model") + body = { + "input": input, + "instructions": instructions, + "model": model, + "previous_response_id": previous_response_id, + } + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_responses_compact_response_conversation_request( + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _types.ApiErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/aio/operations/_patch.py b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/aio/operations/_patch.py new file mode 100644 index 000000000000..87676c65a8f0 --- /dev/null +++ b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/aio/operations/_patch.py @@ -0,0 +1,21 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" + + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/models/__init__.py b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/models/__init__.py new file mode 100644 index 000000000000..e3b4c5295f07 --- /dev/null +++ b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/models/__init__.py @@ -0,0 +1,21 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/models/_patch.py b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/models/_patch.py new file mode 100644 index 000000000000..87676c65a8f0 --- /dev/null +++ b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/models/_patch.py @@ -0,0 +1,21 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" + + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/operations/__init__.py b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/operations/__init__.py new file mode 100644 index 000000000000..9b86cda3e392 --- /dev/null +++ b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/operations/__init__.py @@ -0,0 +1,25 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import ResponsesOperations # type: ignore + +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ResponsesOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/operations/_operations.py b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/operations/_operations.py new file mode 100644 index 000000000000..3cc7b1394232 --- /dev/null +++ b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/operations/_operations.py @@ -0,0 +1,3762 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, IO, Literal, Optional, TYPE_CHECKING, TypeVar, Union, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict + +from .. import types, types as _types +from .._configuration import ProjectsClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +if TYPE_CHECKING: + from .. import _unions +JSON = MutableMapping[str, Any] +_Unset: Any = object() +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_responses_create_response_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/openai/v1/responses" + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) + + +def build_responses_create_response_stream_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "text/event-stream") + + # Construct URL + _url = "/openai/v1/responses" + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) + + +def build_responses_get_response_request( + response_id: str, + *, + includables: Optional[list[types.IncludeEnum]] = None, + stream_parameter: Optional[bool] = None, + starting_after: Optional[int] = None, + **kwargs: Any, +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/openai/v1/responses/{response_id}" + path_format_arguments = { + "response_id": _SERIALIZER.url("response_id", response_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if includables is not None: + _params["include[]"] = [ + _SERIALIZER.query("includables", q, "str") if q is not None else "" for q in includables + ] + if stream_parameter is not None: + _params["stream"] = _SERIALIZER.query("stream_parameter", stream_parameter, "bool") + if starting_after is not None: + _params["starting_after"] = _SERIALIZER.query("starting_after", starting_after, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_responses_get_response_stream_request( # pylint: disable=name-too-long + response_id: str, + *, + includables: Optional[list[types.IncludeEnum]] = None, + starting_after: Optional[int] = None, + **kwargs: Any, +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept: Literal["text/event-stream"] = kwargs.pop("accept", _headers.pop("accept", "text/event-stream")) + # Construct URL + _url = "/openai/v1/responses/{response_id}" + path_format_arguments = { + "response_id": _SERIALIZER.url("response_id", response_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if includables is not None: + _params["include[]"] = [ + _SERIALIZER.query("includables", q, "str") if q is not None else "" for q in includables + ] + if starting_after is not None: + _params["starting_after"] = _SERIALIZER.query("starting_after", starting_after, "int") + + # Construct headers + _headers["accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_responses_delete_response_request(response_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/openai/v1/responses/{response_id}" + path_format_arguments = { + "response_id": _SERIALIZER.url("response_id", response_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, headers=_headers, **kwargs) + + +def build_responses_cancel_response_request(response_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/openai/v1/responses/{response_id}/cancel" + path_format_arguments = { + "response_id": _SERIALIZER.url("response_id", response_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) + + +def build_responses_list_input_items_request( + response_id: str, + *, + limit: Optional[int] = None, + order: Optional[types.PageOrder] = None, + after: Optional[str] = None, + before: Optional[str] = None, + **kwargs: Any, +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/openai/v1/responses/{response_id}/input_items" + path_format_arguments = { + "response_id": _SERIALIZER.url("response_id", response_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if limit is not None: + _params["limit"] = _SERIALIZER.query("limit", limit, "int") + if order is not None: + _params["order"] = _SERIALIZER.query("order", order, "str") + if after is not None: + _params["after"] = _SERIALIZER.query("after", after, "str") + if before is not None: + _params["before"] = _SERIALIZER.query("before", before, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_responses_list_responses_request( + *, + limit: Optional[int] = None, + order: Optional[types.PageOrder] = None, + after: Optional[str] = None, + before: Optional[str] = None, + agent_name: Optional[str] = None, + agent_id: Optional[str] = None, + conversation_id: Optional[str] = None, + **kwargs: Any, +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/openai/v1/responses" + + # Construct parameters + if limit is not None: + _params["limit"] = _SERIALIZER.query("limit", limit, "int") + if order is not None: + _params["order"] = _SERIALIZER.query("order", order, "str") + if after is not None: + _params["after"] = _SERIALIZER.query("after", after, "str") + if before is not None: + _params["before"] = _SERIALIZER.query("before", before, "str") + if agent_name is not None: + _params["agent_name"] = _SERIALIZER.query("agent_name", agent_name, "str") + if agent_id is not None: + _params["agent_id"] = _SERIALIZER.query("agent_id", agent_id, "str") + if conversation_id is not None: + _params["conversation_id"] = _SERIALIZER.query("conversation_id", conversation_id, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_responses_compact_response_conversation_request( # pylint: disable=name-too-long + **kwargs: Any, +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/openai/v1/responses/compact" + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) + + +class ResponsesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.agentserver.responses.models.ProjectsClient`'s + :attr:`responses` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ProjectsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + def create_response( # pylint: disable=too-many-locals + self, + metadata: Optional[_types.Metadata] = None, + top_logprobs: Optional[int] = None, + temperature: Optional[float] = None, + top_p: Optional[float] = None, + user: Optional[str] = None, + safety_identifier: Optional[str] = None, + prompt_cache_key: Optional[str] = None, + service_tier: Optional[Literal["auto", "default", "flex", "scale", "priority"]] = None, + prompt_cache_retention: Optional[Literal["in-memory", "24h"]] = None, + previous_response_id: Optional[str] = None, + model: Optional[str] = None, + reasoning: Optional[_types.Reasoning] = None, + background: Optional[bool] = None, + max_output_tokens: Optional[int] = None, + max_tool_calls: Optional[int] = None, + text: Optional[_types.ResponseTextParam] = None, + tools: Optional[list[_types.Tool]] = None, + tool_choice: Optional[Union[types.ToolChoiceOptions, _types.ToolChoiceParam]] = None, + prompt: Optional[_types.Prompt] = None, + truncation: Optional[Literal["auto", "disabled"]] = None, + input: Optional["_unions.InputParam"] = None, + include: Optional[list[types.IncludeEnum]] = None, + parallel_tool_calls: Optional[bool] = None, + store: Optional[bool] = None, + instructions: Optional[str] = None, + stream_parameter: Optional[bool] = None, + stream_options: Optional[_types.ResponseStreamOptions] = None, + conversation: Optional["_unions.ConversationParam"] = None, + context_management: Optional[list[_types.ContextManagementParam]] = None, + agent: Optional[_types.AgentReference] = None, + agent_session_id: Optional[str] = None, + agent_reference: Optional[_types.AgentReference] = None, + structured_inputs: Optional[dict[str, Any]] = None, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> _types.ResponseObject: + """Creates a model response. + + :param metadata: Default value is None. + :type metadata: ~azure.ai.agentserver.responses.models.types.Metadata + :param top_logprobs: Default value is None. + :type top_logprobs: int + :param temperature: Default value is None. + :type temperature: float + :param top_p: Default value is None. + :type top_p: float + :param user: This field is being replaced by ``safety_identifier`` and ``prompt_cache_key``. + Use ``prompt_cache_key`` instead to maintain caching optimizations. + A stable identifier for your end-users. + Used to boost cache hit rates by better bucketing similar requests and to help OpenAI + detect and prevent abuse. `Learn more + `_. Default value is None. + :type user: str + :param safety_identifier: A stable identifier used to help detect users of your application + that may be violating OpenAI's usage policies. + The IDs should be a string that uniquely identifies each user. We recommend hashing their + username or email address, in order to avoid sending us any identifying information. `Learn + more `_. Default value is None. + :type safety_identifier: str + :param prompt_cache_key: Used by OpenAI to cache responses for similar requests to optimize + your cache hit rates. Replaces the ``user`` field. `Learn more `_. + Default value is None. + :type prompt_cache_key: str + :param service_tier: Is one of the following types: Literal["auto"], Literal["default"], + Literal["flex"], Literal["scale"], Literal["priority"] Default value is None. + :type service_tier: str or str or str or str or str + :param prompt_cache_retention: Is either a Literal["in-memory"] type or a Literal["24h"] type. + Default value is None. + :type prompt_cache_retention: str or str + :param previous_response_id: Default value is None. + :type previous_response_id: str + :param model: The model deployment to use for the creation of this response. Default value is + None. + :type model: str + :param reasoning: Default value is None. + :type reasoning: ~azure.ai.agentserver.responses.models.types.Reasoning + :param background: Default value is None. + :type background: bool + :param max_output_tokens: Default value is None. + :type max_output_tokens: int + :param max_tool_calls: Default value is None. + :type max_tool_calls: int + :param text: Default value is None. + :type text: ~azure.ai.agentserver.responses.models.types.ResponseTextParam + :param tools: Default value is None. + :type tools: list[~azure.ai.agentserver.responses.models.types.Tool] + :param tool_choice: Is either a types.ToolChoiceOptions type or a ToolChoiceParam type. Default + value is None. + :type tool_choice: str or ~azure.ai.agentserver.responses.models.models.ToolChoiceOptions or + ~azure.ai.agentserver.responses.models.types.ToolChoiceParam + :param prompt: Default value is None. + :type prompt: ~azure.ai.agentserver.responses.models.types.Prompt + :param truncation: Is either a Literal["auto"] type or a Literal["disabled"] type. Default + value is None. + :type truncation: str or str + :param input: Is either a str type or a [Item] type. Default value is None. + :type input: str or list[~azure.ai.agentserver.responses.models.types.Item] + :param include: Default value is None. + :type include: list[str or ~azure.ai.agentserver.responses.models.models.IncludeEnum] + :param parallel_tool_calls: Default value is None. + :type parallel_tool_calls: bool + :param store: Default value is None. + :type store: bool + :param instructions: Default value is None. + :type instructions: str + :param stream_parameter: Default value is None. + :type stream_parameter: bool + :param stream_options: Default value is None. + :type stream_options: ~azure.ai.agentserver.responses.models.types.ResponseStreamOptions + :param conversation: Is either a str type or a ConversationParam_2 type. Default value is None. + :type conversation: str or ~azure.ai.agentserver.responses.models.types.ConversationParam_2 + :param context_management: Context management configuration for this request. Default value is + None. + :type context_management: + list[~azure.ai.agentserver.responses.models.types.ContextManagementParam] + :param agent: (Deprecated) Use agent_reference instead. + The agent to use for generating the response. Default value is None. + :type agent: ~azure.ai.agentserver.responses.models.types.AgentReference + :param agent_session_id: Optional session identifier for sandbox affinity. Currently only + relevant for hosted agents. + When provided, the request is routed to the same sandbox. When omitted, auto-derived from + conversation_id/prev_response_id or a new UUID is generated. Default value is None. + :type agent_session_id: str + :param agent_reference: The agent to use for generating the response. Default value is None. + :type agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :param structured_inputs: The structured inputs to the response that can participate in prompt + template substitution or tool argument bindings. Default value is None. + :type structured_inputs: dict[str, any] + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ResponseObject + :rtype: ~azure.ai.agentserver.responses.models.types.ResponseObject + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "json_object": + text_response_format_configuration = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format_configuration = { + "name": "str", + "schema": {}, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format_configuration = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "agent_reference": { + "name": "str", + "type": "agent_reference", + "version": "str" + }, + "created_at": "2020-02-20 00:00:00", + "error": { + "code": "str", + "message": "str" + }, + "id": "str", + "incomplete_details": { + "reason": "max_output_tokens" + }, + "instructions": "str", + "object": "response", + "output": [ + output_item + ], + "parallel_tool_calls": bool, + "agent": { + "name": "str", + "type": "agent_id", + "version": "str" + }, + "agent_session_id": "str", + "background": bool, + "completed_at": "2020-02-20 00:00:00", + "conversation": { + "id": "str" + }, + "max_output_tokens": 0, + "max_tool_calls": 0, + "metadata": {}, + "model": "str", + "output_text": "str", + "previous_response_id": "str", + "prompt": { + "id": "str", + "variables": {}, + "version": "str" + }, + "prompt_cache_key": "str", + "prompt_cache_retention": "in-memory", + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "safety_identifier": "str", + "service_tier": "auto", + "status": "completed", + "temperature": 0.0, + "text": { + "format": text_response_format_configuration, + "verbosity": "low" + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_logprobs": 0, + "top_p": 0.0, + "truncation": "auto", + "usage": { + "input_tokens": 0, + "input_tokens_details": { + "cached_tokens": 0 + }, + "output_tokens": 0, + "output_tokens_details": { + "reasoning_tokens": 0 + }, + "total_tokens": 0 + }, + "user": "str" + } + """ + + @overload + def create_response( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _types.ResponseObject: + """Creates a model response. + + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ResponseObject + :rtype: ~azure.ai.agentserver.responses.models.types.ResponseObject + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "json_object": + text_response_format_configuration = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format_configuration = { + "name": "str", + "schema": {}, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format_configuration = { + "type": "text" + } + + # JSON input template you can fill out and use as your body input. + body = { + "agent": { + "name": "str", + "type": "agent_reference", + "version": "str" + }, + "agent_reference": { + "name": "str", + "type": "agent_reference", + "version": "str" + }, + "agent_session_id": "str", + "background": bool, + "context_management": [ + { + "type": "str", + "compact_threshold": 0 + } + ], + "conversation": "str", + "include": [ + "str" + ], + "input": "str", + "instructions": "str", + "max_output_tokens": 0, + "max_tool_calls": 0, + "metadata": {}, + "model": "str", + "parallel_tool_calls": bool, + "previous_response_id": "str", + "prompt": { + "id": "str", + "variables": {}, + "version": "str" + }, + "prompt_cache_key": "str", + "prompt_cache_retention": "in-memory", + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "safety_identifier": "str", + "service_tier": "auto", + "store": bool, + "stream": bool, + "stream_options": { + "include_obfuscation": bool + }, + "structured_inputs": { + "str": {} + }, + "temperature": 0.0, + "text": { + "format": text_response_format_configuration, + "verbosity": "low" + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_logprobs": 0, + "top_p": 0.0, + "truncation": "auto", + "user": "str" + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "json_object": + text_response_format_configuration = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format_configuration = { + "name": "str", + "schema": {}, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format_configuration = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "agent_reference": { + "name": "str", + "type": "agent_reference", + "version": "str" + }, + "created_at": "2020-02-20 00:00:00", + "error": { + "code": "str", + "message": "str" + }, + "id": "str", + "incomplete_details": { + "reason": "max_output_tokens" + }, + "instructions": "str", + "object": "response", + "output": [ + output_item + ], + "parallel_tool_calls": bool, + "agent": { + "name": "str", + "type": "agent_id", + "version": "str" + }, + "agent_session_id": "str", + "background": bool, + "completed_at": "2020-02-20 00:00:00", + "conversation": { + "id": "str" + }, + "max_output_tokens": 0, + "max_tool_calls": 0, + "metadata": {}, + "model": "str", + "output_text": "str", + "previous_response_id": "str", + "prompt": { + "id": "str", + "variables": {}, + "version": "str" + }, + "prompt_cache_key": "str", + "prompt_cache_retention": "in-memory", + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "safety_identifier": "str", + "service_tier": "auto", + "status": "completed", + "temperature": 0.0, + "text": { + "format": text_response_format_configuration, + "verbosity": "low" + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_logprobs": 0, + "top_p": 0.0, + "truncation": "auto", + "usage": { + "input_tokens": 0, + "input_tokens_details": { + "cached_tokens": 0 + }, + "output_tokens": 0, + "output_tokens_details": { + "reasoning_tokens": 0 + }, + "total_tokens": 0 + }, + "user": "str" + } + """ + + @overload + def create_response( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _types.ResponseObject: + """Creates a model response. + + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ResponseObject + :rtype: ~azure.ai.agentserver.responses.models.types.ResponseObject + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "json_object": + text_response_format_configuration = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format_configuration = { + "name": "str", + "schema": {}, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format_configuration = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "agent_reference": { + "name": "str", + "type": "agent_reference", + "version": "str" + }, + "created_at": "2020-02-20 00:00:00", + "error": { + "code": "str", + "message": "str" + }, + "id": "str", + "incomplete_details": { + "reason": "max_output_tokens" + }, + "instructions": "str", + "object": "response", + "output": [ + output_item + ], + "parallel_tool_calls": bool, + "agent": { + "name": "str", + "type": "agent_id", + "version": "str" + }, + "agent_session_id": "str", + "background": bool, + "completed_at": "2020-02-20 00:00:00", + "conversation": { + "id": "str" + }, + "max_output_tokens": 0, + "max_tool_calls": 0, + "metadata": {}, + "model": "str", + "output_text": "str", + "previous_response_id": "str", + "prompt": { + "id": "str", + "variables": {}, + "version": "str" + }, + "prompt_cache_key": "str", + "prompt_cache_retention": "in-memory", + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "safety_identifier": "str", + "service_tier": "auto", + "status": "completed", + "temperature": 0.0, + "text": { + "format": text_response_format_configuration, + "verbosity": "low" + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_logprobs": 0, + "top_p": 0.0, + "truncation": "auto", + "usage": { + "input_tokens": 0, + "input_tokens_details": { + "cached_tokens": 0 + }, + "output_tokens": 0, + "output_tokens_details": { + "reasoning_tokens": 0 + }, + "total_tokens": 0 + }, + "user": "str" + } + """ + + @distributed_trace + def create_response( # pylint: disable=too-many-locals + self, + body: Union[JSON, IO[bytes]] = _Unset, + metadata: Optional[_types.Metadata] = None, + top_logprobs: Optional[int] = None, + temperature: Optional[float] = None, + top_p: Optional[float] = None, + user: Optional[str] = None, + safety_identifier: Optional[str] = None, + prompt_cache_key: Optional[str] = None, + service_tier: Optional[Literal["auto", "default", "flex", "scale", "priority"]] = None, + prompt_cache_retention: Optional[Literal["in-memory", "24h"]] = None, + previous_response_id: Optional[str] = None, + model: Optional[str] = None, + reasoning: Optional[_types.Reasoning] = None, + background: Optional[bool] = None, + max_output_tokens: Optional[int] = None, + max_tool_calls: Optional[int] = None, + text: Optional[_types.ResponseTextParam] = None, + tools: Optional[list[_types.Tool]] = None, + tool_choice: Optional[Union[types.ToolChoiceOptions, _types.ToolChoiceParam]] = None, + prompt: Optional[_types.Prompt] = None, + truncation: Optional[Literal["auto", "disabled"]] = None, + input: Optional["_unions.InputParam"] = None, + include: Optional[list[types.IncludeEnum]] = None, + parallel_tool_calls: Optional[bool] = None, + store: Optional[bool] = None, + instructions: Optional[str] = None, + stream_parameter: Optional[bool] = None, + stream_options: Optional[_types.ResponseStreamOptions] = None, + conversation: Optional["_unions.ConversationParam"] = None, + context_management: Optional[list[_types.ContextManagementParam]] = None, + agent: Optional[_types.AgentReference] = None, + agent_session_id: Optional[str] = None, + agent_reference: Optional[_types.AgentReference] = None, + structured_inputs: Optional[dict[str, Any]] = None, + **kwargs: Any, + ) -> _types.ResponseObject: + """Creates a model response. + + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :param metadata: Default value is None. + :type metadata: ~azure.ai.agentserver.responses.models.types.Metadata + :param top_logprobs: Default value is None. + :type top_logprobs: int + :param temperature: Default value is None. + :type temperature: float + :param top_p: Default value is None. + :type top_p: float + :param user: This field is being replaced by ``safety_identifier`` and ``prompt_cache_key``. + Use ``prompt_cache_key`` instead to maintain caching optimizations. + A stable identifier for your end-users. + Used to boost cache hit rates by better bucketing similar requests and to help OpenAI + detect and prevent abuse. `Learn more + `_. Default value is None. + :type user: str + :param safety_identifier: A stable identifier used to help detect users of your application + that may be violating OpenAI's usage policies. + The IDs should be a string that uniquely identifies each user. We recommend hashing their + username or email address, in order to avoid sending us any identifying information. `Learn + more `_. Default value is None. + :type safety_identifier: str + :param prompt_cache_key: Used by OpenAI to cache responses for similar requests to optimize + your cache hit rates. Replaces the ``user`` field. `Learn more `_. + Default value is None. + :type prompt_cache_key: str + :param service_tier: Is one of the following types: Literal["auto"], Literal["default"], + Literal["flex"], Literal["scale"], Literal["priority"] Default value is None. + :type service_tier: str or str or str or str or str + :param prompt_cache_retention: Is either a Literal["in-memory"] type or a Literal["24h"] type. + Default value is None. + :type prompt_cache_retention: str or str + :param previous_response_id: Default value is None. + :type previous_response_id: str + :param model: The model deployment to use for the creation of this response. Default value is + None. + :type model: str + :param reasoning: Default value is None. + :type reasoning: ~azure.ai.agentserver.responses.models.types.Reasoning + :param background: Default value is None. + :type background: bool + :param max_output_tokens: Default value is None. + :type max_output_tokens: int + :param max_tool_calls: Default value is None. + :type max_tool_calls: int + :param text: Default value is None. + :type text: ~azure.ai.agentserver.responses.models.types.ResponseTextParam + :param tools: Default value is None. + :type tools: list[~azure.ai.agentserver.responses.models.types.Tool] + :param tool_choice: Is either a types.ToolChoiceOptions type or a ToolChoiceParam type. Default + value is None. + :type tool_choice: str or ~azure.ai.agentserver.responses.models.models.ToolChoiceOptions or + ~azure.ai.agentserver.responses.models.types.ToolChoiceParam + :param prompt: Default value is None. + :type prompt: ~azure.ai.agentserver.responses.models.types.Prompt + :param truncation: Is either a Literal["auto"] type or a Literal["disabled"] type. Default + value is None. + :type truncation: str or str + :param input: Is either a str type or a [Item] type. Default value is None. + :type input: str or list[~azure.ai.agentserver.responses.models.types.Item] + :param include: Default value is None. + :type include: list[str or ~azure.ai.agentserver.responses.models.models.IncludeEnum] + :param parallel_tool_calls: Default value is None. + :type parallel_tool_calls: bool + :param store: Default value is None. + :type store: bool + :param instructions: Default value is None. + :type instructions: str + :param stream_parameter: Default value is None. + :type stream_parameter: bool + :param stream_options: Default value is None. + :type stream_options: ~azure.ai.agentserver.responses.models.types.ResponseStreamOptions + :param conversation: Is either a str type or a ConversationParam_2 type. Default value is None. + :type conversation: str or ~azure.ai.agentserver.responses.models.types.ConversationParam_2 + :param context_management: Context management configuration for this request. Default value is + None. + :type context_management: + list[~azure.ai.agentserver.responses.models.types.ContextManagementParam] + :param agent: (Deprecated) Use agent_reference instead. + The agent to use for generating the response. Default value is None. + :type agent: ~azure.ai.agentserver.responses.models.types.AgentReference + :param agent_session_id: Optional session identifier for sandbox affinity. Currently only + relevant for hosted agents. + When provided, the request is routed to the same sandbox. When omitted, auto-derived from + conversation_id/prev_response_id or a new UUID is generated. Default value is None. + :type agent_session_id: str + :param agent_reference: The agent to use for generating the response. Default value is None. + :type agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :param structured_inputs: The structured inputs to the response that can participate in prompt + template substitution or tool argument bindings. Default value is None. + :type structured_inputs: dict[str, any] + :return: ResponseObject + :rtype: ~azure.ai.agentserver.responses.models.types.ResponseObject + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "json_object": + text_response_format_configuration = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format_configuration = { + "name": "str", + "schema": {}, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format_configuration = { + "type": "text" + } + + # JSON input template you can fill out and use as your body input. + body = { + "agent": { + "name": "str", + "type": "agent_reference", + "version": "str" + }, + "agent_reference": { + "name": "str", + "type": "agent_reference", + "version": "str" + }, + "agent_session_id": "str", + "background": bool, + "context_management": [ + { + "type": "str", + "compact_threshold": 0 + } + ], + "conversation": "str", + "include": [ + "str" + ], + "input": "str", + "instructions": "str", + "max_output_tokens": 0, + "max_tool_calls": 0, + "metadata": {}, + "model": "str", + "parallel_tool_calls": bool, + "previous_response_id": "str", + "prompt": { + "id": "str", + "variables": {}, + "version": "str" + }, + "prompt_cache_key": "str", + "prompt_cache_retention": "in-memory", + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "safety_identifier": "str", + "service_tier": "auto", + "store": bool, + "stream": bool, + "stream_options": { + "include_obfuscation": bool + }, + "structured_inputs": { + "str": {} + }, + "temperature": 0.0, + "text": { + "format": text_response_format_configuration, + "verbosity": "low" + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_logprobs": 0, + "top_p": 0.0, + "truncation": "auto", + "user": "str" + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "json_object": + text_response_format_configuration = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format_configuration = { + "name": "str", + "schema": {}, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format_configuration = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "agent_reference": { + "name": "str", + "type": "agent_reference", + "version": "str" + }, + "created_at": "2020-02-20 00:00:00", + "error": { + "code": "str", + "message": "str" + }, + "id": "str", + "incomplete_details": { + "reason": "max_output_tokens" + }, + "instructions": "str", + "object": "response", + "output": [ + output_item + ], + "parallel_tool_calls": bool, + "agent": { + "name": "str", + "type": "agent_id", + "version": "str" + }, + "agent_session_id": "str", + "background": bool, + "completed_at": "2020-02-20 00:00:00", + "conversation": { + "id": "str" + }, + "max_output_tokens": 0, + "max_tool_calls": 0, + "metadata": {}, + "model": "str", + "output_text": "str", + "previous_response_id": "str", + "prompt": { + "id": "str", + "variables": {}, + "version": "str" + }, + "prompt_cache_key": "str", + "prompt_cache_retention": "in-memory", + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "safety_identifier": "str", + "service_tier": "auto", + "status": "completed", + "temperature": 0.0, + "text": { + "format": text_response_format_configuration, + "verbosity": "low" + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_logprobs": 0, + "top_p": 0.0, + "truncation": "auto", + "usage": { + "input_tokens": 0, + "input_tokens_details": { + "cached_tokens": 0 + }, + "output_tokens": 0, + "output_tokens_details": { + "reasoning_tokens": 0 + }, + "total_tokens": 0 + }, + "user": "str" + } + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_types.ResponseObject] = kwargs.pop("cls", None) + + if body is _Unset: + body = { + "agent": agent, + "agent_reference": agent_reference, + "agent_session_id": agent_session_id, + "background": background, + "context_management": context_management, + "conversation": conversation, + "include": include, + "input": input, + "instructions": instructions, + "max_output_tokens": max_output_tokens, + "max_tool_calls": max_tool_calls, + "metadata": metadata, + "model": model, + "parallel_tool_calls": parallel_tool_calls, + "previous_response_id": previous_response_id, + "prompt": prompt, + "prompt_cache_key": prompt_cache_key, + "prompt_cache_retention": prompt_cache_retention, + "reasoning": reasoning, + "safety_identifier": safety_identifier, + "service_tier": service_tier, + "store": store, + "stream": stream_parameter, + "stream_options": stream_options, + "structured_inputs": structured_inputs, + "temperature": temperature, + "text": text, + "tool_choice": tool_choice, + "tools": tools, + "top_logprobs": top_logprobs, + "top_p": top_p, + "truncation": truncation, + "user": user, + } + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_responses_create_response_request( + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _types.ApiErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_response_stream( # pylint: disable=too-many-locals + self, + metadata: Optional[_types.Metadata] = None, + top_logprobs: Optional[int] = None, + temperature: Optional[float] = None, + top_p: Optional[float] = None, + user: Optional[str] = None, + safety_identifier: Optional[str] = None, + prompt_cache_key: Optional[str] = None, + service_tier: Optional[Literal["auto", "default", "flex", "scale", "priority"]] = None, + prompt_cache_retention: Optional[Literal["in-memory", "24h"]] = None, + previous_response_id: Optional[str] = None, + model: Optional[str] = None, + reasoning: Optional[_types.Reasoning] = None, + background: Optional[bool] = None, + max_output_tokens: Optional[int] = None, + max_tool_calls: Optional[int] = None, + text: Optional[_types.ResponseTextParam] = None, + tools: Optional[list[_types.Tool]] = None, + tool_choice: Optional[Union[types.ToolChoiceOptions, _types.ToolChoiceParam]] = None, + prompt: Optional[_types.Prompt] = None, + truncation: Optional[Literal["auto", "disabled"]] = None, + input: Optional["_unions.InputParam"] = None, + include: Optional[list[types.IncludeEnum]] = None, + parallel_tool_calls: Optional[bool] = None, + store: Optional[bool] = None, + instructions: Optional[str] = None, + stream_parameter: Optional[bool] = None, + stream_options: Optional[_types.ResponseStreamOptions] = None, + conversation: Optional["_unions.ConversationParam"] = None, + context_management: Optional[list[_types.ContextManagementParam]] = None, + agent: Optional[_types.AgentReference] = None, + agent_session_id: Optional[str] = None, + agent_reference: Optional[_types.AgentReference] = None, + structured_inputs: Optional[dict[str, Any]] = None, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> "_unions.CreateResponseStreamingResponse": + """Creates a model response (streaming response). + + :param metadata: Default value is None. + :type metadata: ~azure.ai.agentserver.responses.models.types.Metadata + :param top_logprobs: Default value is None. + :type top_logprobs: int + :param temperature: Default value is None. + :type temperature: float + :param top_p: Default value is None. + :type top_p: float + :param user: This field is being replaced by ``safety_identifier`` and ``prompt_cache_key``. + Use ``prompt_cache_key`` instead to maintain caching optimizations. + A stable identifier for your end-users. + Used to boost cache hit rates by better bucketing similar requests and to help OpenAI + detect and prevent abuse. `Learn more + `_. Default value is None. + :type user: str + :param safety_identifier: A stable identifier used to help detect users of your application + that may be violating OpenAI's usage policies. + The IDs should be a string that uniquely identifies each user. We recommend hashing their + username or email address, in order to avoid sending us any identifying information. `Learn + more `_. Default value is None. + :type safety_identifier: str + :param prompt_cache_key: Used by OpenAI to cache responses for similar requests to optimize + your cache hit rates. Replaces the ``user`` field. `Learn more `_. + Default value is None. + :type prompt_cache_key: str + :param service_tier: Is one of the following types: Literal["auto"], Literal["default"], + Literal["flex"], Literal["scale"], Literal["priority"] Default value is None. + :type service_tier: str or str or str or str or str + :param prompt_cache_retention: Is either a Literal["in-memory"] type or a Literal["24h"] type. + Default value is None. + :type prompt_cache_retention: str or str + :param previous_response_id: Default value is None. + :type previous_response_id: str + :param model: The model deployment to use for the creation of this response. Default value is + None. + :type model: str + :param reasoning: Default value is None. + :type reasoning: ~azure.ai.agentserver.responses.models.types.Reasoning + :param background: Default value is None. + :type background: bool + :param max_output_tokens: Default value is None. + :type max_output_tokens: int + :param max_tool_calls: Default value is None. + :type max_tool_calls: int + :param text: Default value is None. + :type text: ~azure.ai.agentserver.responses.models.types.ResponseTextParam + :param tools: Default value is None. + :type tools: list[~azure.ai.agentserver.responses.models.types.Tool] + :param tool_choice: Is either a types.ToolChoiceOptions type or a ToolChoiceParam type. Default + value is None. + :type tool_choice: str or ~azure.ai.agentserver.responses.models.models.ToolChoiceOptions or + ~azure.ai.agentserver.responses.models.types.ToolChoiceParam + :param prompt: Default value is None. + :type prompt: ~azure.ai.agentserver.responses.models.types.Prompt + :param truncation: Is either a Literal["auto"] type or a Literal["disabled"] type. Default + value is None. + :type truncation: str or str + :param input: Is either a str type or a [Item] type. Default value is None. + :type input: str or list[~azure.ai.agentserver.responses.models.types.Item] + :param include: Default value is None. + :type include: list[str or ~azure.ai.agentserver.responses.models.models.IncludeEnum] + :param parallel_tool_calls: Default value is None. + :type parallel_tool_calls: bool + :param store: Default value is None. + :type store: bool + :param instructions: Default value is None. + :type instructions: str + :param stream_parameter: Default value is None. + :type stream_parameter: bool + :param stream_options: Default value is None. + :type stream_options: ~azure.ai.agentserver.responses.models.types.ResponseStreamOptions + :param conversation: Is either a str type or a ConversationParam_2 type. Default value is None. + :type conversation: str or ~azure.ai.agentserver.responses.models.types.ConversationParam_2 + :param context_management: Context management configuration for this request. Default value is + None. + :type context_management: + list[~azure.ai.agentserver.responses.models.types.ContextManagementParam] + :param agent: (Deprecated) Use agent_reference instead. + The agent to use for generating the response. Default value is None. + :type agent: ~azure.ai.agentserver.responses.models.types.AgentReference + :param agent_session_id: Optional session identifier for sandbox affinity. Currently only + relevant for hosted agents. + When provided, the request is routed to the same sandbox. When omitted, auto-derived from + conversation_id/prev_response_id or a new UUID is generated. Default value is None. + :type agent_session_id: str + :param agent_reference: The agent to use for generating the response. Default value is None. + :type agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :param structured_inputs: The structured inputs to the response that can participate in prompt + template substitution or tool argument bindings. Default value is None. + :type structured_inputs: dict[str, any] + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ResponseAudioDeltaEvent or ResponseAudioTranscriptDeltaEvent or + ResponseCodeInterpreterCallCodeDeltaEvent or ResponseCodeInterpreterCallInProgressEvent or + ResponseCodeInterpreterCallInterpretingEvent or ResponseContentPartAddedEvent or + ResponseCreatedEvent or ResponseErrorEvent or ResponseFileSearchCallInProgressEvent or + ResponseFileSearchCallSearchingEvent or ResponseFunctionCallArgumentsDeltaEvent or + ResponseInProgressEvent or ResponseFailedEvent or ResponseIncompleteEvent or + ResponseOutputItemAddedEvent or ResponseReasoningSummaryPartAddedEvent or + ResponseReasoningSummaryTextDeltaEvent or ResponseReasoningTextDeltaEvent or + ResponseRefusalDeltaEvent or ResponseTextDeltaEvent or ResponseWebSearchCallInProgressEvent or + ResponseWebSearchCallSearchingEvent or ResponseImageGenCallGeneratingEvent or + ResponseImageGenCallInProgressEvent or ResponseImageGenCallPartialImageEvent or + ResponseMCPCallArgumentsDeltaEvent or ResponseMCPCallFailedEvent or + ResponseMCPCallInProgressEvent or ResponseMCPListToolsFailedEvent or + ResponseMCPListToolsInProgressEvent or ResponseOutputTextAnnotationAddedEvent or + ResponseQueuedEvent or ResponseCustomToolCallInputDeltaEvent or ResponseAudioDoneEvent or + ResponseAudioTranscriptDoneEvent or ResponseCodeInterpreterCallCodeDoneEvent or + ResponseCodeInterpreterCallCompletedEvent or ResponseCompletedEvent or + ResponseContentPartDoneEvent or ResponseFileSearchCallCompletedEvent or + ResponseFunctionCallArgumentsDoneEvent or ResponseOutputItemDoneEvent or + ResponseReasoningSummaryPartDoneEvent or ResponseReasoningSummaryTextDoneEvent or + ResponseReasoningTextDoneEvent or ResponseRefusalDoneEvent or ResponseTextDoneEvent or + ResponseWebSearchCallCompletedEvent or ResponseImageGenCallCompletedEvent or + ResponseMCPCallArgumentsDoneEvent or ResponseMCPCallCompletedEvent or + ResponseMCPListToolsCompletedEvent or ResponseCustomToolCallInputDoneEvent + :rtype: ~azure.ai.agentserver.responses.models.types.ResponseAudioDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseAudioTranscriptDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallCodeDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallInterpretingEvent or + ~azure.ai.agentserver.responses.models.types.ResponseContentPartAddedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCreatedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseErrorEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFileSearchCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFileSearchCallSearchingEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFunctionCallArgumentsDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFailedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseIncompleteEvent or + ~azure.ai.agentserver.responses.models.types.ResponseOutputItemAddedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryPartAddedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryTextDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningTextDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseRefusalDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseTextDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseWebSearchCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseWebSearchCallSearchingEvent or + ~azure.ai.agentserver.responses.models.types.ResponseImageGenCallGeneratingEvent or + ~azure.ai.agentserver.responses.models.types.ResponseImageGenCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseImageGenCallPartialImageEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallArgumentsDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallFailedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPListToolsFailedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPListToolsInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseOutputTextAnnotationAddedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseQueuedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCustomToolCallInputDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseAudioDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseAudioTranscriptDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallCodeDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseContentPartDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFileSearchCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFunctionCallArgumentsDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseOutputItemDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryPartDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryTextDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningTextDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseRefusalDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseTextDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseWebSearchCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseImageGenCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallArgumentsDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPListToolsCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCustomToolCallInputDoneEvent + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "response.audio.delta": + response_stream_event = { + "delta": bytes("bytes", encoding="utf-8"), + "sequence_number": 0, + "type": "response.audio.delta" + } + + # JSON input template for discriminator value "response.audio.transcript.delta": + response_stream_event = { + "delta": "str", + "sequence_number": 0, + "type": "response.audio.transcript.delta" + } + + # JSON input template for discriminator value + "response.code_interpreter_call_code.delta": + response_stream_event = { + "delta": "str", + "item_id": "str", + "output_index": 0, + "sequence_number": 0, + "type": "response.code_interpreter_call_code.delta" + } + + # JSON input template for discriminator value + "response.code_interpreter_call.in_progress": + response_stream_event = { + "item_id": "str", + "output_index": 0, + "sequence_number": 0, + "type": "response.code_interpreter_call.in_progress" + } + + # JSON input template for discriminator value + "response.code_interpreter_call.interpreting": + response_stream_event = { + "item_id": "str", + "output_index": 0, + "sequence_number": 0, + "type": "response.code_interpreter_call.interpreting" + } + """ + + @overload + def create_response_stream( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> "_unions.CreateResponseStreamingResponse": + """Creates a model response (streaming response). + + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ResponseAudioDeltaEvent or ResponseAudioTranscriptDeltaEvent or + ResponseCodeInterpreterCallCodeDeltaEvent or ResponseCodeInterpreterCallInProgressEvent or + ResponseCodeInterpreterCallInterpretingEvent or ResponseContentPartAddedEvent or + ResponseCreatedEvent or ResponseErrorEvent or ResponseFileSearchCallInProgressEvent or + ResponseFileSearchCallSearchingEvent or ResponseFunctionCallArgumentsDeltaEvent or + ResponseInProgressEvent or ResponseFailedEvent or ResponseIncompleteEvent or + ResponseOutputItemAddedEvent or ResponseReasoningSummaryPartAddedEvent or + ResponseReasoningSummaryTextDeltaEvent or ResponseReasoningTextDeltaEvent or + ResponseRefusalDeltaEvent or ResponseTextDeltaEvent or ResponseWebSearchCallInProgressEvent or + ResponseWebSearchCallSearchingEvent or ResponseImageGenCallGeneratingEvent or + ResponseImageGenCallInProgressEvent or ResponseImageGenCallPartialImageEvent or + ResponseMCPCallArgumentsDeltaEvent or ResponseMCPCallFailedEvent or + ResponseMCPCallInProgressEvent or ResponseMCPListToolsFailedEvent or + ResponseMCPListToolsInProgressEvent or ResponseOutputTextAnnotationAddedEvent or + ResponseQueuedEvent or ResponseCustomToolCallInputDeltaEvent or ResponseAudioDoneEvent or + ResponseAudioTranscriptDoneEvent or ResponseCodeInterpreterCallCodeDoneEvent or + ResponseCodeInterpreterCallCompletedEvent or ResponseCompletedEvent or + ResponseContentPartDoneEvent or ResponseFileSearchCallCompletedEvent or + ResponseFunctionCallArgumentsDoneEvent or ResponseOutputItemDoneEvent or + ResponseReasoningSummaryPartDoneEvent or ResponseReasoningSummaryTextDoneEvent or + ResponseReasoningTextDoneEvent or ResponseRefusalDoneEvent or ResponseTextDoneEvent or + ResponseWebSearchCallCompletedEvent or ResponseImageGenCallCompletedEvent or + ResponseMCPCallArgumentsDoneEvent or ResponseMCPCallCompletedEvent or + ResponseMCPListToolsCompletedEvent or ResponseCustomToolCallInputDoneEvent + :rtype: ~azure.ai.agentserver.responses.models.types.ResponseAudioDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseAudioTranscriptDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallCodeDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallInterpretingEvent or + ~azure.ai.agentserver.responses.models.types.ResponseContentPartAddedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCreatedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseErrorEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFileSearchCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFileSearchCallSearchingEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFunctionCallArgumentsDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFailedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseIncompleteEvent or + ~azure.ai.agentserver.responses.models.types.ResponseOutputItemAddedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryPartAddedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryTextDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningTextDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseRefusalDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseTextDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseWebSearchCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseWebSearchCallSearchingEvent or + ~azure.ai.agentserver.responses.models.types.ResponseImageGenCallGeneratingEvent or + ~azure.ai.agentserver.responses.models.types.ResponseImageGenCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseImageGenCallPartialImageEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallArgumentsDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallFailedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPListToolsFailedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPListToolsInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseOutputTextAnnotationAddedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseQueuedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCustomToolCallInputDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseAudioDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseAudioTranscriptDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallCodeDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseContentPartDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFileSearchCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFunctionCallArgumentsDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseOutputItemDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryPartDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryTextDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningTextDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseRefusalDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseTextDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseWebSearchCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseImageGenCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallArgumentsDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPListToolsCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCustomToolCallInputDoneEvent + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "json_object": + text_response_format_configuration = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format_configuration = { + "name": "str", + "schema": {}, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format_configuration = { + "type": "text" + } + + # JSON input template you can fill out and use as your body input. + body = { + "agent": { + "name": "str", + "type": "agent_reference", + "version": "str" + }, + "agent_reference": { + "name": "str", + "type": "agent_reference", + "version": "str" + }, + "agent_session_id": "str", + "background": bool, + "context_management": [ + { + "type": "str", + "compact_threshold": 0 + } + ], + "conversation": "str", + "include": [ + "str" + ], + "input": "str", + "instructions": "str", + "max_output_tokens": 0, + "max_tool_calls": 0, + "metadata": {}, + "model": "str", + "parallel_tool_calls": bool, + "previous_response_id": "str", + "prompt": { + "id": "str", + "variables": {}, + "version": "str" + }, + "prompt_cache_key": "str", + "prompt_cache_retention": "in-memory", + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "safety_identifier": "str", + "service_tier": "auto", + "store": bool, + "stream": bool, + "stream_options": { + "include_obfuscation": bool + }, + "structured_inputs": { + "str": {} + }, + "temperature": 0.0, + "text": { + "format": text_response_format_configuration, + "verbosity": "low" + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_logprobs": 0, + "top_p": 0.0, + "truncation": "auto", + "user": "str" + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "response.audio.delta": + response_stream_event = { + "delta": bytes("bytes", encoding="utf-8"), + "sequence_number": 0, + "type": "response.audio.delta" + } + + # JSON input template for discriminator value "response.audio.transcript.delta": + response_stream_event = { + "delta": "str", + "sequence_number": 0, + "type": "response.audio.transcript.delta" + } + + # JSON input template for discriminator value + "response.code_interpreter_call_code.delta": + response_stream_event = { + "delta": "str", + "item_id": "str", + "output_index": 0, + "sequence_number": 0, + "type": "response.code_interpreter_call_code.delta" + } + + # JSON input template for discriminator value + "response.code_interpreter_call.in_progress": + response_stream_event = { + "item_id": "str", + "output_index": 0, + "sequence_number": 0, + "type": "response.code_interpreter_call.in_progress" + } + + # JSON input template for discriminator value + "response.code_interpreter_call.interpreting": + response_stream_event = { + "item_id": "str", + "output_index": 0, + "sequence_number": 0, + "type": "response.code_interpreter_call.interpreting" + } + """ + + @overload + def create_response_stream( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> "_unions.CreateResponseStreamingResponse": + """Creates a model response (streaming response). + + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ResponseAudioDeltaEvent or ResponseAudioTranscriptDeltaEvent or + ResponseCodeInterpreterCallCodeDeltaEvent or ResponseCodeInterpreterCallInProgressEvent or + ResponseCodeInterpreterCallInterpretingEvent or ResponseContentPartAddedEvent or + ResponseCreatedEvent or ResponseErrorEvent or ResponseFileSearchCallInProgressEvent or + ResponseFileSearchCallSearchingEvent or ResponseFunctionCallArgumentsDeltaEvent or + ResponseInProgressEvent or ResponseFailedEvent or ResponseIncompleteEvent or + ResponseOutputItemAddedEvent or ResponseReasoningSummaryPartAddedEvent or + ResponseReasoningSummaryTextDeltaEvent or ResponseReasoningTextDeltaEvent or + ResponseRefusalDeltaEvent or ResponseTextDeltaEvent or ResponseWebSearchCallInProgressEvent or + ResponseWebSearchCallSearchingEvent or ResponseImageGenCallGeneratingEvent or + ResponseImageGenCallInProgressEvent or ResponseImageGenCallPartialImageEvent or + ResponseMCPCallArgumentsDeltaEvent or ResponseMCPCallFailedEvent or + ResponseMCPCallInProgressEvent or ResponseMCPListToolsFailedEvent or + ResponseMCPListToolsInProgressEvent or ResponseOutputTextAnnotationAddedEvent or + ResponseQueuedEvent or ResponseCustomToolCallInputDeltaEvent or ResponseAudioDoneEvent or + ResponseAudioTranscriptDoneEvent or ResponseCodeInterpreterCallCodeDoneEvent or + ResponseCodeInterpreterCallCompletedEvent or ResponseCompletedEvent or + ResponseContentPartDoneEvent or ResponseFileSearchCallCompletedEvent or + ResponseFunctionCallArgumentsDoneEvent or ResponseOutputItemDoneEvent or + ResponseReasoningSummaryPartDoneEvent or ResponseReasoningSummaryTextDoneEvent or + ResponseReasoningTextDoneEvent or ResponseRefusalDoneEvent or ResponseTextDoneEvent or + ResponseWebSearchCallCompletedEvent or ResponseImageGenCallCompletedEvent or + ResponseMCPCallArgumentsDoneEvent or ResponseMCPCallCompletedEvent or + ResponseMCPListToolsCompletedEvent or ResponseCustomToolCallInputDoneEvent + :rtype: ~azure.ai.agentserver.responses.models.types.ResponseAudioDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseAudioTranscriptDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallCodeDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallInterpretingEvent or + ~azure.ai.agentserver.responses.models.types.ResponseContentPartAddedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCreatedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseErrorEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFileSearchCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFileSearchCallSearchingEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFunctionCallArgumentsDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFailedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseIncompleteEvent or + ~azure.ai.agentserver.responses.models.types.ResponseOutputItemAddedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryPartAddedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryTextDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningTextDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseRefusalDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseTextDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseWebSearchCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseWebSearchCallSearchingEvent or + ~azure.ai.agentserver.responses.models.types.ResponseImageGenCallGeneratingEvent or + ~azure.ai.agentserver.responses.models.types.ResponseImageGenCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseImageGenCallPartialImageEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallArgumentsDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallFailedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPListToolsFailedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPListToolsInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseOutputTextAnnotationAddedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseQueuedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCustomToolCallInputDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseAudioDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseAudioTranscriptDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallCodeDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseContentPartDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFileSearchCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFunctionCallArgumentsDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseOutputItemDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryPartDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryTextDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningTextDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseRefusalDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseTextDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseWebSearchCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseImageGenCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallArgumentsDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPListToolsCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCustomToolCallInputDoneEvent + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "response.audio.delta": + response_stream_event = { + "delta": bytes("bytes", encoding="utf-8"), + "sequence_number": 0, + "type": "response.audio.delta" + } + + # JSON input template for discriminator value "response.audio.transcript.delta": + response_stream_event = { + "delta": "str", + "sequence_number": 0, + "type": "response.audio.transcript.delta" + } + + # JSON input template for discriminator value + "response.code_interpreter_call_code.delta": + response_stream_event = { + "delta": "str", + "item_id": "str", + "output_index": 0, + "sequence_number": 0, + "type": "response.code_interpreter_call_code.delta" + } + + # JSON input template for discriminator value + "response.code_interpreter_call.in_progress": + response_stream_event = { + "item_id": "str", + "output_index": 0, + "sequence_number": 0, + "type": "response.code_interpreter_call.in_progress" + } + + # JSON input template for discriminator value + "response.code_interpreter_call.interpreting": + response_stream_event = { + "item_id": "str", + "output_index": 0, + "sequence_number": 0, + "type": "response.code_interpreter_call.interpreting" + } + """ + + @distributed_trace + def create_response_stream( # pylint: disable=too-many-locals + self, + body: Union[JSON, IO[bytes]] = _Unset, + metadata: Optional[_types.Metadata] = None, + top_logprobs: Optional[int] = None, + temperature: Optional[float] = None, + top_p: Optional[float] = None, + user: Optional[str] = None, + safety_identifier: Optional[str] = None, + prompt_cache_key: Optional[str] = None, + service_tier: Optional[Literal["auto", "default", "flex", "scale", "priority"]] = None, + prompt_cache_retention: Optional[Literal["in-memory", "24h"]] = None, + previous_response_id: Optional[str] = None, + model: Optional[str] = None, + reasoning: Optional[_types.Reasoning] = None, + background: Optional[bool] = None, + max_output_tokens: Optional[int] = None, + max_tool_calls: Optional[int] = None, + text: Optional[_types.ResponseTextParam] = None, + tools: Optional[list[_types.Tool]] = None, + tool_choice: Optional[Union[types.ToolChoiceOptions, _types.ToolChoiceParam]] = None, + prompt: Optional[_types.Prompt] = None, + truncation: Optional[Literal["auto", "disabled"]] = None, + input: Optional["_unions.InputParam"] = None, + include: Optional[list[types.IncludeEnum]] = None, + parallel_tool_calls: Optional[bool] = None, + store: Optional[bool] = None, + instructions: Optional[str] = None, + stream_parameter: Optional[bool] = None, + stream_options: Optional[_types.ResponseStreamOptions] = None, + conversation: Optional["_unions.ConversationParam"] = None, + context_management: Optional[list[_types.ContextManagementParam]] = None, + agent: Optional[_types.AgentReference] = None, + agent_session_id: Optional[str] = None, + agent_reference: Optional[_types.AgentReference] = None, + structured_inputs: Optional[dict[str, Any]] = None, + **kwargs: Any, + ) -> "_unions.CreateResponseStreamingResponse": + """Creates a model response (streaming response). + + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :param metadata: Default value is None. + :type metadata: ~azure.ai.agentserver.responses.models.types.Metadata + :param top_logprobs: Default value is None. + :type top_logprobs: int + :param temperature: Default value is None. + :type temperature: float + :param top_p: Default value is None. + :type top_p: float + :param user: This field is being replaced by ``safety_identifier`` and ``prompt_cache_key``. + Use ``prompt_cache_key`` instead to maintain caching optimizations. + A stable identifier for your end-users. + Used to boost cache hit rates by better bucketing similar requests and to help OpenAI + detect and prevent abuse. `Learn more + `_. Default value is None. + :type user: str + :param safety_identifier: A stable identifier used to help detect users of your application + that may be violating OpenAI's usage policies. + The IDs should be a string that uniquely identifies each user. We recommend hashing their + username or email address, in order to avoid sending us any identifying information. `Learn + more `_. Default value is None. + :type safety_identifier: str + :param prompt_cache_key: Used by OpenAI to cache responses for similar requests to optimize + your cache hit rates. Replaces the ``user`` field. `Learn more `_. + Default value is None. + :type prompt_cache_key: str + :param service_tier: Is one of the following types: Literal["auto"], Literal["default"], + Literal["flex"], Literal["scale"], Literal["priority"] Default value is None. + :type service_tier: str or str or str or str or str + :param prompt_cache_retention: Is either a Literal["in-memory"] type or a Literal["24h"] type. + Default value is None. + :type prompt_cache_retention: str or str + :param previous_response_id: Default value is None. + :type previous_response_id: str + :param model: The model deployment to use for the creation of this response. Default value is + None. + :type model: str + :param reasoning: Default value is None. + :type reasoning: ~azure.ai.agentserver.responses.models.types.Reasoning + :param background: Default value is None. + :type background: bool + :param max_output_tokens: Default value is None. + :type max_output_tokens: int + :param max_tool_calls: Default value is None. + :type max_tool_calls: int + :param text: Default value is None. + :type text: ~azure.ai.agentserver.responses.models.types.ResponseTextParam + :param tools: Default value is None. + :type tools: list[~azure.ai.agentserver.responses.models.types.Tool] + :param tool_choice: Is either a types.ToolChoiceOptions type or a ToolChoiceParam type. Default + value is None. + :type tool_choice: str or ~azure.ai.agentserver.responses.models.models.ToolChoiceOptions or + ~azure.ai.agentserver.responses.models.types.ToolChoiceParam + :param prompt: Default value is None. + :type prompt: ~azure.ai.agentserver.responses.models.types.Prompt + :param truncation: Is either a Literal["auto"] type or a Literal["disabled"] type. Default + value is None. + :type truncation: str or str + :param input: Is either a str type or a [Item] type. Default value is None. + :type input: str or list[~azure.ai.agentserver.responses.models.types.Item] + :param include: Default value is None. + :type include: list[str or ~azure.ai.agentserver.responses.models.models.IncludeEnum] + :param parallel_tool_calls: Default value is None. + :type parallel_tool_calls: bool + :param store: Default value is None. + :type store: bool + :param instructions: Default value is None. + :type instructions: str + :param stream_parameter: Default value is None. + :type stream_parameter: bool + :param stream_options: Default value is None. + :type stream_options: ~azure.ai.agentserver.responses.models.types.ResponseStreamOptions + :param conversation: Is either a str type or a ConversationParam_2 type. Default value is None. + :type conversation: str or ~azure.ai.agentserver.responses.models.types.ConversationParam_2 + :param context_management: Context management configuration for this request. Default value is + None. + :type context_management: + list[~azure.ai.agentserver.responses.models.types.ContextManagementParam] + :param agent: (Deprecated) Use agent_reference instead. + The agent to use for generating the response. Default value is None. + :type agent: ~azure.ai.agentserver.responses.models.types.AgentReference + :param agent_session_id: Optional session identifier for sandbox affinity. Currently only + relevant for hosted agents. + When provided, the request is routed to the same sandbox. When omitted, auto-derived from + conversation_id/prev_response_id or a new UUID is generated. Default value is None. + :type agent_session_id: str + :param agent_reference: The agent to use for generating the response. Default value is None. + :type agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :param structured_inputs: The structured inputs to the response that can participate in prompt + template substitution or tool argument bindings. Default value is None. + :type structured_inputs: dict[str, any] + :return: ResponseAudioDeltaEvent or ResponseAudioTranscriptDeltaEvent or + ResponseCodeInterpreterCallCodeDeltaEvent or ResponseCodeInterpreterCallInProgressEvent or + ResponseCodeInterpreterCallInterpretingEvent or ResponseContentPartAddedEvent or + ResponseCreatedEvent or ResponseErrorEvent or ResponseFileSearchCallInProgressEvent or + ResponseFileSearchCallSearchingEvent or ResponseFunctionCallArgumentsDeltaEvent or + ResponseInProgressEvent or ResponseFailedEvent or ResponseIncompleteEvent or + ResponseOutputItemAddedEvent or ResponseReasoningSummaryPartAddedEvent or + ResponseReasoningSummaryTextDeltaEvent or ResponseReasoningTextDeltaEvent or + ResponseRefusalDeltaEvent or ResponseTextDeltaEvent or ResponseWebSearchCallInProgressEvent or + ResponseWebSearchCallSearchingEvent or ResponseImageGenCallGeneratingEvent or + ResponseImageGenCallInProgressEvent or ResponseImageGenCallPartialImageEvent or + ResponseMCPCallArgumentsDeltaEvent or ResponseMCPCallFailedEvent or + ResponseMCPCallInProgressEvent or ResponseMCPListToolsFailedEvent or + ResponseMCPListToolsInProgressEvent or ResponseOutputTextAnnotationAddedEvent or + ResponseQueuedEvent or ResponseCustomToolCallInputDeltaEvent or ResponseAudioDoneEvent or + ResponseAudioTranscriptDoneEvent or ResponseCodeInterpreterCallCodeDoneEvent or + ResponseCodeInterpreterCallCompletedEvent or ResponseCompletedEvent or + ResponseContentPartDoneEvent or ResponseFileSearchCallCompletedEvent or + ResponseFunctionCallArgumentsDoneEvent or ResponseOutputItemDoneEvent or + ResponseReasoningSummaryPartDoneEvent or ResponseReasoningSummaryTextDoneEvent or + ResponseReasoningTextDoneEvent or ResponseRefusalDoneEvent or ResponseTextDoneEvent or + ResponseWebSearchCallCompletedEvent or ResponseImageGenCallCompletedEvent or + ResponseMCPCallArgumentsDoneEvent or ResponseMCPCallCompletedEvent or + ResponseMCPListToolsCompletedEvent or ResponseCustomToolCallInputDoneEvent + :rtype: ~azure.ai.agentserver.responses.models.types.ResponseAudioDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseAudioTranscriptDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallCodeDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallInterpretingEvent or + ~azure.ai.agentserver.responses.models.types.ResponseContentPartAddedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCreatedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseErrorEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFileSearchCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFileSearchCallSearchingEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFunctionCallArgumentsDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFailedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseIncompleteEvent or + ~azure.ai.agentserver.responses.models.types.ResponseOutputItemAddedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryPartAddedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryTextDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningTextDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseRefusalDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseTextDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseWebSearchCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseWebSearchCallSearchingEvent or + ~azure.ai.agentserver.responses.models.types.ResponseImageGenCallGeneratingEvent or + ~azure.ai.agentserver.responses.models.types.ResponseImageGenCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseImageGenCallPartialImageEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallArgumentsDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallFailedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPListToolsFailedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPListToolsInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseOutputTextAnnotationAddedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseQueuedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCustomToolCallInputDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseAudioDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseAudioTranscriptDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallCodeDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseContentPartDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFileSearchCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFunctionCallArgumentsDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseOutputItemDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryPartDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryTextDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningTextDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseRefusalDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseTextDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseWebSearchCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseImageGenCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallArgumentsDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPListToolsCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCustomToolCallInputDoneEvent + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "type": + + # JSON input template for discriminator value "json_object": + text_response_format_configuration = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format_configuration = { + "name": "str", + "schema": {}, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format_configuration = { + "type": "text" + } + + # JSON input template you can fill out and use as your body input. + body = { + "agent": { + "name": "str", + "type": "agent_reference", + "version": "str" + }, + "agent_reference": { + "name": "str", + "type": "agent_reference", + "version": "str" + }, + "agent_session_id": "str", + "background": bool, + "context_management": [ + { + "type": "str", + "compact_threshold": 0 + } + ], + "conversation": "str", + "include": [ + "str" + ], + "input": "str", + "instructions": "str", + "max_output_tokens": 0, + "max_tool_calls": 0, + "metadata": {}, + "model": "str", + "parallel_tool_calls": bool, + "previous_response_id": "str", + "prompt": { + "id": "str", + "variables": {}, + "version": "str" + }, + "prompt_cache_key": "str", + "prompt_cache_retention": "in-memory", + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "safety_identifier": "str", + "service_tier": "auto", + "store": bool, + "stream": bool, + "stream_options": { + "include_obfuscation": bool + }, + "structured_inputs": { + "str": {} + }, + "temperature": 0.0, + "text": { + "format": text_response_format_configuration, + "verbosity": "low" + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_logprobs": 0, + "top_p": 0.0, + "truncation": "auto", + "user": "str" + } + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "response.audio.delta": + response_stream_event = { + "delta": bytes("bytes", encoding="utf-8"), + "sequence_number": 0, + "type": "response.audio.delta" + } + + # JSON input template for discriminator value "response.audio.transcript.delta": + response_stream_event = { + "delta": "str", + "sequence_number": 0, + "type": "response.audio.transcript.delta" + } + + # JSON input template for discriminator value + "response.code_interpreter_call_code.delta": + response_stream_event = { + "delta": "str", + "item_id": "str", + "output_index": 0, + "sequence_number": 0, + "type": "response.code_interpreter_call_code.delta" + } + + # JSON input template for discriminator value + "response.code_interpreter_call.in_progress": + response_stream_event = { + "item_id": "str", + "output_index": 0, + "sequence_number": 0, + "type": "response.code_interpreter_call.in_progress" + } + + # JSON input template for discriminator value + "response.code_interpreter_call.interpreting": + response_stream_event = { + "item_id": "str", + "output_index": 0, + "sequence_number": 0, + "type": "response.code_interpreter_call.interpreting" + } + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType["_unions.CreateResponseStreamingResponse"] = kwargs.pop("cls", None) + + if body is _Unset: + body = { + "agent": agent, + "agent_reference": agent_reference, + "agent_session_id": agent_session_id, + "background": background, + "context_management": context_management, + "conversation": conversation, + "include": include, + "input": input, + "instructions": instructions, + "max_output_tokens": max_output_tokens, + "max_tool_calls": max_tool_calls, + "metadata": metadata, + "model": model, + "parallel_tool_calls": parallel_tool_calls, + "previous_response_id": previous_response_id, + "prompt": prompt, + "prompt_cache_key": prompt_cache_key, + "prompt_cache_retention": prompt_cache_retention, + "reasoning": reasoning, + "safety_identifier": safety_identifier, + "service_tier": service_tier, + "store": store, + "stream": stream_parameter, + "stream_options": stream_options, + "structured_inputs": structured_inputs, + "temperature": temperature, + "text": text, + "tool_choice": tool_choice, + "tools": tools, + "top_logprobs": top_logprobs, + "top_p": top_p, + "truncation": truncation, + "user": user, + } + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_responses_create_response_stream_request( + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _types.ApiErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_response( + self, + response_id: str, + *, + includables: Optional[list[types.IncludeEnum]] = None, + stream_parameter: Optional[bool] = None, + starting_after: Optional[int] = None, + **kwargs: Any, + ) -> _types.ResponseObject: + """Retrieves a model response with the given ID. + + :param response_id: Required. + :type response_id: str + :keyword includables: Default value is None. + :paramtype includables: list[str or ~azure.ai.agentserver.responses.models.models.IncludeEnum] + :keyword stream_parameter: Default value is None. + :paramtype stream_parameter: bool + :keyword starting_after: Default value is None. + :paramtype starting_after: int + :return: ResponseObject + :rtype: ~azure.ai.agentserver.responses.models.types.ResponseObject + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "json_object": + text_response_format_configuration = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format_configuration = { + "name": "str", + "schema": {}, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format_configuration = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "agent_reference": { + "name": "str", + "type": "agent_reference", + "version": "str" + }, + "created_at": "2020-02-20 00:00:00", + "error": { + "code": "str", + "message": "str" + }, + "id": "str", + "incomplete_details": { + "reason": "max_output_tokens" + }, + "instructions": "str", + "object": "response", + "output": [ + output_item + ], + "parallel_tool_calls": bool, + "agent": { + "name": "str", + "type": "agent_id", + "version": "str" + }, + "agent_session_id": "str", + "background": bool, + "completed_at": "2020-02-20 00:00:00", + "conversation": { + "id": "str" + }, + "max_output_tokens": 0, + "max_tool_calls": 0, + "metadata": {}, + "model": "str", + "output_text": "str", + "previous_response_id": "str", + "prompt": { + "id": "str", + "variables": {}, + "version": "str" + }, + "prompt_cache_key": "str", + "prompt_cache_retention": "in-memory", + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "safety_identifier": "str", + "service_tier": "auto", + "status": "completed", + "temperature": 0.0, + "text": { + "format": text_response_format_configuration, + "verbosity": "low" + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_logprobs": 0, + "top_p": 0.0, + "truncation": "auto", + "usage": { + "input_tokens": 0, + "input_tokens_details": { + "cached_tokens": 0 + }, + "output_tokens": 0, + "output_tokens_details": { + "reasoning_tokens": 0 + }, + "total_tokens": 0 + }, + "user": "str" + } + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_types.ResponseObject] = kwargs.pop("cls", None) + + _request = build_responses_get_response_request( + response_id=response_id, + includables=includables, + stream_parameter=stream_parameter, + starting_after=starting_after, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _types.ApiErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_response_stream( + self, + response_id: str, + *, + includables: Optional[list[types.IncludeEnum]] = None, + starting_after: Optional[int] = None, + **kwargs: Any, + ) -> "_unions.CreateResponseStreamingResponse": + """Retrieves a model response with the given ID (streaming response). + + :param response_id: Required. + :type response_id: str + :keyword includables: Default value is None. + :paramtype includables: list[str or ~azure.ai.agentserver.responses.models.models.IncludeEnum] + :keyword starting_after: Default value is None. + :paramtype starting_after: int + :return: ResponseAudioDeltaEvent or ResponseAudioTranscriptDeltaEvent or + ResponseCodeInterpreterCallCodeDeltaEvent or ResponseCodeInterpreterCallInProgressEvent or + ResponseCodeInterpreterCallInterpretingEvent or ResponseContentPartAddedEvent or + ResponseCreatedEvent or ResponseErrorEvent or ResponseFileSearchCallInProgressEvent or + ResponseFileSearchCallSearchingEvent or ResponseFunctionCallArgumentsDeltaEvent or + ResponseInProgressEvent or ResponseFailedEvent or ResponseIncompleteEvent or + ResponseOutputItemAddedEvent or ResponseReasoningSummaryPartAddedEvent or + ResponseReasoningSummaryTextDeltaEvent or ResponseReasoningTextDeltaEvent or + ResponseRefusalDeltaEvent or ResponseTextDeltaEvent or ResponseWebSearchCallInProgressEvent or + ResponseWebSearchCallSearchingEvent or ResponseImageGenCallGeneratingEvent or + ResponseImageGenCallInProgressEvent or ResponseImageGenCallPartialImageEvent or + ResponseMCPCallArgumentsDeltaEvent or ResponseMCPCallFailedEvent or + ResponseMCPCallInProgressEvent or ResponseMCPListToolsFailedEvent or + ResponseMCPListToolsInProgressEvent or ResponseOutputTextAnnotationAddedEvent or + ResponseQueuedEvent or ResponseCustomToolCallInputDeltaEvent or ResponseAudioDoneEvent or + ResponseAudioTranscriptDoneEvent or ResponseCodeInterpreterCallCodeDoneEvent or + ResponseCodeInterpreterCallCompletedEvent or ResponseCompletedEvent or + ResponseContentPartDoneEvent or ResponseFileSearchCallCompletedEvent or + ResponseFunctionCallArgumentsDoneEvent or ResponseOutputItemDoneEvent or + ResponseReasoningSummaryPartDoneEvent or ResponseReasoningSummaryTextDoneEvent or + ResponseReasoningTextDoneEvent or ResponseRefusalDoneEvent or ResponseTextDoneEvent or + ResponseWebSearchCallCompletedEvent or ResponseImageGenCallCompletedEvent or + ResponseMCPCallArgumentsDoneEvent or ResponseMCPCallCompletedEvent or + ResponseMCPListToolsCompletedEvent or ResponseCustomToolCallInputDoneEvent + :rtype: ~azure.ai.agentserver.responses.models.types.ResponseAudioDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseAudioTranscriptDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallCodeDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallInterpretingEvent or + ~azure.ai.agentserver.responses.models.types.ResponseContentPartAddedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCreatedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseErrorEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFileSearchCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFileSearchCallSearchingEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFunctionCallArgumentsDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFailedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseIncompleteEvent or + ~azure.ai.agentserver.responses.models.types.ResponseOutputItemAddedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryPartAddedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryTextDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningTextDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseRefusalDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseTextDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseWebSearchCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseWebSearchCallSearchingEvent or + ~azure.ai.agentserver.responses.models.types.ResponseImageGenCallGeneratingEvent or + ~azure.ai.agentserver.responses.models.types.ResponseImageGenCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseImageGenCallPartialImageEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallArgumentsDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallFailedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPListToolsFailedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPListToolsInProgressEvent or + ~azure.ai.agentserver.responses.models.types.ResponseOutputTextAnnotationAddedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseQueuedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCustomToolCallInputDeltaEvent or + ~azure.ai.agentserver.responses.models.types.ResponseAudioDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseAudioTranscriptDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallCodeDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCodeInterpreterCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseContentPartDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFileSearchCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseFunctionCallArgumentsDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseOutputItemDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryPartDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryTextDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseReasoningTextDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseRefusalDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseTextDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseWebSearchCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseImageGenCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallArgumentsDoneEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPCallCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseMCPListToolsCompletedEvent or + ~azure.ai.agentserver.responses.models.types.ResponseCustomToolCallInputDoneEvent + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "response.audio.delta": + response_stream_event = { + "delta": bytes("bytes", encoding="utf-8"), + "sequence_number": 0, + "type": "response.audio.delta" + } + + # JSON input template for discriminator value "response.audio.transcript.delta": + response_stream_event = { + "delta": "str", + "sequence_number": 0, + "type": "response.audio.transcript.delta" + } + + # JSON input template for discriminator value + "response.code_interpreter_call_code.delta": + response_stream_event = { + "delta": "str", + "item_id": "str", + "output_index": 0, + "sequence_number": 0, + "type": "response.code_interpreter_call_code.delta" + } + + # JSON input template for discriminator value + "response.code_interpreter_call.in_progress": + response_stream_event = { + "item_id": "str", + "output_index": 0, + "sequence_number": 0, + "type": "response.code_interpreter_call.in_progress" + } + + # JSON input template for discriminator value + "response.code_interpreter_call.interpreting": + response_stream_event = { + "item_id": "str", + "output_index": 0, + "sequence_number": 0, + "type": "response.code_interpreter_call.interpreting" + } + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + accept: Literal["text/event-stream"] = kwargs.pop("accept", _headers.pop("accept", "text/event-stream")) + cls: ClsType["_unions.CreateResponseStreamingResponse"] = kwargs.pop("cls", None) + + _request = build_responses_get_response_stream_request( + response_id=response_id, + includables=includables, + starting_after=starting_after, + accept=accept, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _types.ApiErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete_response(self, response_id: str, **kwargs: Any) -> _types.DeleteResponseResult: + """Deletes a model response. + + :param response_id: The ID of the response to delete. Required. + :type response_id: str + :return: DeleteResponseResult + :rtype: ~azure.ai.agentserver.responses.models.types.DeleteResponseResult + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "deleted": True, + "id": "str", + "object": "response" + } + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_types.DeleteResponseResult] = kwargs.pop("cls", None) + + _request = build_responses_delete_response_request( + response_id=response_id, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _types.ApiErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def cancel_response(self, response_id: str, **kwargs: Any) -> _types.ResponseObject: + """Cancels a model response. + + :param response_id: The ID of the response to cancel. Required. + :type response_id: str + :return: ResponseObject + :rtype: ~azure.ai.agentserver.responses.models.types.ResponseObject + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "json_object": + text_response_format_configuration = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format_configuration = { + "name": "str", + "schema": {}, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format_configuration = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "agent_reference": { + "name": "str", + "type": "agent_reference", + "version": "str" + }, + "created_at": "2020-02-20 00:00:00", + "error": { + "code": "str", + "message": "str" + }, + "id": "str", + "incomplete_details": { + "reason": "max_output_tokens" + }, + "instructions": "str", + "object": "response", + "output": [ + output_item + ], + "parallel_tool_calls": bool, + "agent": { + "name": "str", + "type": "agent_id", + "version": "str" + }, + "agent_session_id": "str", + "background": bool, + "completed_at": "2020-02-20 00:00:00", + "conversation": { + "id": "str" + }, + "max_output_tokens": 0, + "max_tool_calls": 0, + "metadata": {}, + "model": "str", + "output_text": "str", + "previous_response_id": "str", + "prompt": { + "id": "str", + "variables": {}, + "version": "str" + }, + "prompt_cache_key": "str", + "prompt_cache_retention": "in-memory", + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "safety_identifier": "str", + "service_tier": "auto", + "status": "completed", + "temperature": 0.0, + "text": { + "format": text_response_format_configuration, + "verbosity": "low" + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_logprobs": 0, + "top_p": 0.0, + "truncation": "auto", + "usage": { + "input_tokens": 0, + "input_tokens_details": { + "cached_tokens": 0 + }, + "output_tokens": 0, + "output_tokens_details": { + "reasoning_tokens": 0 + }, + "total_tokens": 0 + }, + "user": "str" + } + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_types.ResponseObject] = kwargs.pop("cls", None) + + _request = build_responses_cancel_response_request( + response_id=response_id, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _types.ApiErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_input_items( + self, + response_id: str, + *, + limit: Optional[int] = None, + order: Optional[types.PageOrder] = None, + before: Optional[str] = None, + **kwargs: Any, + ) -> ItemPaged["_types.OutputItem"]: + """Returns a list of input items for a given response. + + :param response_id: Required. + :type response_id: str + :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and + 100, and the + default is 20. Default value is None. + :paramtype limit: int + :keyword order: Sort order by the ``created_at`` timestamp of the objects. ``asc`` for + ascending order and``desc`` + for descending order. Known values are: "asc" and "desc". Default value is None. + :paramtype order: str or ~azure.ai.agentserver.responses.models.models.PageOrder + :keyword 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. + Default value is None. + :paramtype before: str + :return: An iterator like instance of OutputItem + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agentserver.responses.models.types.OutputItem] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "a2a_preview_call": + output_item = { + "arguments": "str", + "call_id": "str", + "id": "str", + "name": "str", + "status": "str", + "type": "a2a_preview_call", + "agent_reference": { + "name": "str", + "type": "agent_reference", + "version": "str" + }, + "created_by": { + "agent": { + "name": "str", + "type": "agent_id", + "version": "str" + }, + "response_id": "str" + }, + "response_id": "str" + } + + # JSON input template for discriminator value "a2a_preview_call_output": + output_item = { + "call_id": "str", + "id": "str", + "name": "str", + "status": "str", + "type": "a2a_preview_call_output", + "agent_reference": { + "name": "str", + "type": "agent_reference", + "version": "str" + }, + "created_by": { + "agent": { + "name": "str", + "type": "agent_id", + "version": "str" + }, + "response_id": "str" + }, + "output": { + "str": {} + }, + "response_id": "str" + } + + # JSON input template for discriminator value "apply_patch_call": + output_item = { + "call_id": "str", + "id": "str", + "operation": apply_patch_file_operation, + "status": "str", + "type": "apply_patch_call", + "agent_reference": { + "name": "str", + "type": "agent_reference", + "version": "str" + }, + "created_by": { + "agent": { + "name": "str", + "type": "agent_id", + "version": "str" + }, + "response_id": "str" + }, + "response_id": "str" + } + + # JSON input template for discriminator value "create_file": + apply_patch_file_operation = { + "diff": "str", + "path": "str", + "type": "create_file" + } + + # JSON input template for discriminator value "delete_file": + apply_patch_file_operation = { + "path": "str", + "type": "delete_file" + } + + # response body for status code(s): 200 + response == output_item + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_types.OutputItem]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(_continuation_token=None): + + _request = build_responses_list_input_items_request( + response_id=response_id, + limit=limit, + order=order, + after=_continuation_token, + before=before, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized.get("data", []) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("last_id") or None, iter(list_of_elem) + + def get_next(_continuation_token=None): + _request = prepare_request(_continuation_token) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _types.ApiErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_responses( + self, + *, + limit: Optional[int] = None, + order: Optional[types.PageOrder] = None, + before: Optional[str] = None, + agent_name: Optional[str] = None, + agent_id: Optional[str] = None, + conversation_id: Optional[str] = None, + **kwargs: Any, + ) -> ItemPaged["_types.ResponseObject"]: + """Returns the list of all responses. + + :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and + 100, and the + default is 20. Default value is None. + :paramtype limit: int + :keyword order: Sort order by the ``created_at`` timestamp of the objects. ``asc`` for + ascending order and``desc`` + for descending order. Known values are: "asc" and "desc". Default value is None. + :paramtype order: str or ~azure.ai.agentserver.responses.models.models.PageOrder + :keyword 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. + Default value is None. + :paramtype before: str + :keyword agent_name: Filter by agent name. If provided, only items associated with the + specified agent will be returned. Default value is None. + :paramtype agent_name: str + :keyword agent_id: Filter by agent ID in the format ``name:version``. If provided, only items + associated with the specified agent ID will be returned. Default value is None. + :paramtype agent_id: str + :keyword conversation_id: Filter by conversation ID. If provided, only responses associated + with the specified conversation will be returned. Default value is None. + :paramtype conversation_id: str + :return: An iterator like instance of ResponseObject + :rtype: + ~azure.core.paging.ItemPaged[~azure.ai.agentserver.responses.models.types.ResponseObject] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "type": + + # JSON input template for discriminator value "json_object": + text_response_format_configuration = { + "type": "json_object" + } + + # JSON input template for discriminator value "json_schema": + text_response_format_configuration = { + "name": "str", + "schema": {}, + "type": "json_schema", + "description": "str", + "strict": bool + } + + # JSON input template for discriminator value "text": + text_response_format_configuration = { + "type": "text" + } + + # response body for status code(s): 200 + response == { + "agent_reference": { + "name": "str", + "type": "agent_reference", + "version": "str" + }, + "created_at": "2020-02-20 00:00:00", + "error": { + "code": "str", + "message": "str" + }, + "id": "str", + "incomplete_details": { + "reason": "max_output_tokens" + }, + "instructions": "str", + "object": "response", + "output": [ + output_item + ], + "parallel_tool_calls": bool, + "agent": { + "name": "str", + "type": "agent_id", + "version": "str" + }, + "agent_session_id": "str", + "background": bool, + "completed_at": "2020-02-20 00:00:00", + "conversation": { + "id": "str" + }, + "max_output_tokens": 0, + "max_tool_calls": 0, + "metadata": {}, + "model": "str", + "output_text": "str", + "previous_response_id": "str", + "prompt": { + "id": "str", + "variables": {}, + "version": "str" + }, + "prompt_cache_key": "str", + "prompt_cache_retention": "in-memory", + "reasoning": { + "effort": "none", + "generate_summary": "auto", + "summary": "auto" + }, + "safety_identifier": "str", + "service_tier": "auto", + "status": "completed", + "temperature": 0.0, + "text": { + "format": text_response_format_configuration, + "verbosity": "low" + }, + "tool_choice": "str", + "tools": [ + tool + ], + "top_logprobs": 0, + "top_p": 0.0, + "truncation": "auto", + "usage": { + "input_tokens": 0, + "input_tokens_details": { + "cached_tokens": 0 + }, + "output_tokens": 0, + "output_tokens_details": { + "reasoning_tokens": 0 + }, + "total_tokens": 0 + }, + "user": "str" + } + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_types.ResponseObject]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(_continuation_token=None): + + _request = build_responses_list_responses_request( + limit=limit, + order=order, + after=_continuation_token, + before=before, + agent_name=agent_name, + agent_id=agent_id, + conversation_id=conversation_id, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized.get("data", []) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("last_id") or None, iter(list_of_elem) + + def get_next(_continuation_token=None): + _request = prepare_request(_continuation_token) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _types.ApiErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @overload + def compact_response_conversation( + self, + model: types.ModelIdsCompaction, + input: Optional[Union[str, list[_types.Item]]] = None, + previous_response_id: Optional[str] = None, + instructions: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> _types.CompactResource: + """Produces a compaction of a responses conversation. + + :param model: Known values are: "gpt-5.2", "gpt-5.2-2025-12-11", "gpt-5.2-chat-latest", + "gpt-5.2-pro", "gpt-5.2-pro-2025-12-11", "gpt-5.1", "gpt-5.1-2025-11-13", "gpt-5.1-codex", + "gpt-5.1-mini", "gpt-5.1-chat-latest", "gpt-5", "gpt-5-mini", "gpt-5-nano", "gpt-5-2025-08-07", + "gpt-5-mini-2025-08-07", "gpt-5-nano-2025-08-07", "gpt-5-chat-latest", "gpt-4.1", + "gpt-4.1-mini", "gpt-4.1-nano", "gpt-4.1-2025-04-14", "gpt-4.1-mini-2025-04-14", + "gpt-4.1-nano-2025-04-14", "o4-mini", "o4-mini-2025-04-16", "o3", "o3-2025-04-16", "o3-mini", + "o3-mini-2025-01-31", "o1", "o1-2024-12-17", "o1-preview", "o1-preview-2024-09-12", "o1-mini", + "o1-mini-2024-09-12", "gpt-4o", "gpt-4o-2024-11-20", "gpt-4o-2024-08-06", "gpt-4o-2024-05-13", + "gpt-4o-audio-preview", "gpt-4o-audio-preview-2024-10-01", "gpt-4o-audio-preview-2024-12-17", + "gpt-4o-audio-preview-2025-06-03", "gpt-4o-mini-audio-preview", + "gpt-4o-mini-audio-preview-2024-12-17", "gpt-4o-search-preview", "gpt-4o-mini-search-preview", + "gpt-4o-search-preview-2025-03-11", "gpt-4o-mini-search-preview-2025-03-11", + "chatgpt-4o-latest", "codex-mini-latest", "gpt-4o-mini", "gpt-4o-mini-2024-07-18", + "gpt-4-turbo", "gpt-4-turbo-2024-04-09", "gpt-4-0125-preview", "gpt-4-turbo-preview", + "gpt-4-1106-preview", "gpt-4-vision-preview", "gpt-4", "gpt-4-0314", "gpt-4-0613", "gpt-4-32k", + "gpt-4-32k-0314", "gpt-4-32k-0613", "gpt-3.5-turbo", "gpt-3.5-turbo-16k", "gpt-3.5-turbo-0301", + "gpt-3.5-turbo-0613", "gpt-3.5-turbo-1106", "gpt-3.5-turbo-0125", "gpt-3.5-turbo-16k-0613", + "o1-pro", "o1-pro-2025-03-19", "o3-pro", "o3-pro-2025-06-10", "o3-deep-research", + "o3-deep-research-2025-06-26", "o4-mini-deep-research", "o4-mini-deep-research-2025-06-26", + "computer-use-preview", "computer-use-preview-2025-03-11", "gpt-5-codex", "gpt-5-pro", + "gpt-5-pro-2025-10-06", and "gpt-5.1-codex-max". Required. + :type model: str or ~azure.ai.agentserver.responses.models.models.ModelIdsCompaction + :param input: Is either a str type or a [Item] type. Default value is None. + :type input: str or list[~azure.ai.agentserver.responses.models.types.Item] + :param previous_response_id: Default value is None. + :type previous_response_id: str + :param instructions: Default value is None. + :type instructions: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CompactResource + :rtype: ~azure.ai.agentserver.responses.models.types.CompactResource + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "id": "str", + "object": "response.compaction", + "output": [ + item_field + ], + "usage": { + "input_tokens": 0, + "input_tokens_details": { + "cached_tokens": 0 + }, + "output_tokens": 0, + "output_tokens_details": { + "reasoning_tokens": 0 + }, + "total_tokens": 0 + } + } + """ + + @overload + def compact_response_conversation( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _types.CompactResource: + """Produces a compaction of a responses conversation. + + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CompactResource + :rtype: ~azure.ai.agentserver.responses.models.types.CompactResource + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "model": "str", + "input": "str", + "instructions": "str", + "previous_response_id": "str" + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "id": "str", + "object": "response.compaction", + "output": [ + item_field + ], + "usage": { + "input_tokens": 0, + "input_tokens_details": { + "cached_tokens": 0 + }, + "output_tokens": 0, + "output_tokens_details": { + "reasoning_tokens": 0 + }, + "total_tokens": 0 + } + } + """ + + @overload + def compact_response_conversation( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _types.CompactResource: + """Produces a compaction of a responses conversation. + + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: CompactResource + :rtype: ~azure.ai.agentserver.responses.models.types.CompactResource + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "id": "str", + "object": "response.compaction", + "output": [ + item_field + ], + "usage": { + "input_tokens": 0, + "input_tokens_details": { + "cached_tokens": 0 + }, + "output_tokens": 0, + "output_tokens_details": { + "reasoning_tokens": 0 + }, + "total_tokens": 0 + } + } + """ + + @distributed_trace + def compact_response_conversation( + self, + model: types.ModelIdsCompaction = _Unset, + body: Union[JSON, IO[bytes]] = _Unset, + input: Optional[Union[str, list[_types.Item]]] = None, + previous_response_id: Optional[str] = None, + instructions: Optional[str] = None, + **kwargs: Any, + ) -> _types.CompactResource: + """Produces a compaction of a responses conversation. + + :param model: Known values are: "gpt-5.2", "gpt-5.2-2025-12-11", "gpt-5.2-chat-latest", + "gpt-5.2-pro", "gpt-5.2-pro-2025-12-11", "gpt-5.1", "gpt-5.1-2025-11-13", "gpt-5.1-codex", + "gpt-5.1-mini", "gpt-5.1-chat-latest", "gpt-5", "gpt-5-mini", "gpt-5-nano", "gpt-5-2025-08-07", + "gpt-5-mini-2025-08-07", "gpt-5-nano-2025-08-07", "gpt-5-chat-latest", "gpt-4.1", + "gpt-4.1-mini", "gpt-4.1-nano", "gpt-4.1-2025-04-14", "gpt-4.1-mini-2025-04-14", + "gpt-4.1-nano-2025-04-14", "o4-mini", "o4-mini-2025-04-16", "o3", "o3-2025-04-16", "o3-mini", + "o3-mini-2025-01-31", "o1", "o1-2024-12-17", "o1-preview", "o1-preview-2024-09-12", "o1-mini", + "o1-mini-2024-09-12", "gpt-4o", "gpt-4o-2024-11-20", "gpt-4o-2024-08-06", "gpt-4o-2024-05-13", + "gpt-4o-audio-preview", "gpt-4o-audio-preview-2024-10-01", "gpt-4o-audio-preview-2024-12-17", + "gpt-4o-audio-preview-2025-06-03", "gpt-4o-mini-audio-preview", + "gpt-4o-mini-audio-preview-2024-12-17", "gpt-4o-search-preview", "gpt-4o-mini-search-preview", + "gpt-4o-search-preview-2025-03-11", "gpt-4o-mini-search-preview-2025-03-11", + "chatgpt-4o-latest", "codex-mini-latest", "gpt-4o-mini", "gpt-4o-mini-2024-07-18", + "gpt-4-turbo", "gpt-4-turbo-2024-04-09", "gpt-4-0125-preview", "gpt-4-turbo-preview", + "gpt-4-1106-preview", "gpt-4-vision-preview", "gpt-4", "gpt-4-0314", "gpt-4-0613", "gpt-4-32k", + "gpt-4-32k-0314", "gpt-4-32k-0613", "gpt-3.5-turbo", "gpt-3.5-turbo-16k", "gpt-3.5-turbo-0301", + "gpt-3.5-turbo-0613", "gpt-3.5-turbo-1106", "gpt-3.5-turbo-0125", "gpt-3.5-turbo-16k-0613", + "o1-pro", "o1-pro-2025-03-19", "o3-pro", "o3-pro-2025-06-10", "o3-deep-research", + "o3-deep-research-2025-06-26", "o4-mini-deep-research", "o4-mini-deep-research-2025-06-26", + "computer-use-preview", "computer-use-preview-2025-03-11", "gpt-5-codex", "gpt-5-pro", + "gpt-5-pro-2025-10-06", and "gpt-5.1-codex-max". Required. + :type model: str or ~azure.ai.agentserver.responses.models.models.ModelIdsCompaction + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :param input: Is either a str type or a [Item] type. Default value is None. + :type input: str or list[~azure.ai.agentserver.responses.models.types.Item] + :param previous_response_id: Default value is None. + :type previous_response_id: str + :param instructions: Default value is None. + :type instructions: str + :return: CompactResource + :rtype: ~azure.ai.agentserver.responses.models.types.CompactResource + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "model": "str", + "input": "str", + "instructions": "str", + "previous_response_id": "str" + } + + # response body for status code(s): 200 + response == { + "created_at": "2020-02-20 00:00:00", + "id": "str", + "object": "response.compaction", + "output": [ + item_field + ], + "usage": { + "input_tokens": 0, + "input_tokens_details": { + "cached_tokens": 0 + }, + "output_tokens": 0, + "output_tokens_details": { + "reasoning_tokens": 0 + }, + "total_tokens": 0 + } + } + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_types.CompactResource] = kwargs.pop("cls", None) + + if body is _Unset: + if model is _Unset: + raise TypeError("missing required argument: model") + body = { + "input": input, + "instructions": instructions, + "model": model, + "previous_response_id": previous_response_id, + } + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_responses_compact_response_conversation_request( + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _types.ApiErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/operations/_patch.py b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/operations/_patch.py new file mode 100644 index 000000000000..87676c65a8f0 --- /dev/null +++ b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/operations/_patch.py @@ -0,0 +1,21 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" + + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/py.typed b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/types.py b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/types.py new file mode 100644 index 000000000000..f914f1437874 --- /dev/null +++ b/sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/types.py @@ -0,0 +1,10134 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Literal, Optional, TYPE_CHECKING, Union +from typing_extensions import Required, TypedDict + +from .models._enums import ( + AnnotationType, + ApplyPatchFileOperationType, + ApplyPatchOperationParamType, + ComputerActionType, + ContainerNetworkPolicyParamType, + ContainerSkillType, + CustomToolParamFormatType, + FunctionAndCustomToolCallOutputType, + FunctionShellCallEnvironmentType, + FunctionShellCallItemParamEnvironmentType, + FunctionShellCallOutputOutcomeParamType, + FunctionShellCallOutputOutcomeType, + FunctionShellToolParamEnvironmentType, + ItemFieldType, + ItemType, + MemoryItemKind, + MessageContentType, + OpenApiAuthType, + OutputContentType, + OutputItemType, + OutputMessageContentType, + ResponseStreamEventType, + TextResponseFormatConfigurationType, + ToolChoiceParamType, + ToolType, +) + +if TYPE_CHECKING: + from . import _unions + +AnnotationType = Literal["file_citation", "url_citation", "container_file_citation", "file_path"] +"""Type of AnnotationType.""" + +ApplyPatchCallOutputStatus = Literal["completed", "failed"] +"""Type of ApplyPatchCallOutputStatus.""" + +ApplyPatchCallOutputStatusParam = Literal["completed", "failed"] +"""Apply patch call output status.""" + +ApplyPatchCallStatus = Literal["in_progress", "completed"] +"""Type of ApplyPatchCallStatus.""" + +ApplyPatchCallStatusParam = Literal["in_progress", "completed"] +"""Apply patch call status.""" + +ApplyPatchFileOperationType = Literal["create_file", "delete_file", "update_file"] +"""Type of ApplyPatchFileOperationType.""" + +ApplyPatchOperationParamType = Literal["create_file", "delete_file", "update_file"] +"""Type of ApplyPatchOperationParamType.""" + +AzureAISearchQueryType = Literal["simple", "semantic", "vector", "vector_simple_hybrid", "vector_semantic_hybrid"] +"""Available query types for Azure AI Search tool.""" + +ClickButtonType = Literal["left", "right", "wheel", "back", "forward"] +"""Type of ClickButtonType.""" + +ComputerActionType = Literal[ + "click", "double_click", "drag", "keypress", "move", "screenshot", "scroll", "type", "wait" +] +"""Type of ComputerActionType.""" + +ComputerEnvironment = Literal["windows", "mac", "linux", "ubuntu", "browser"] +"""Type of ComputerEnvironment.""" + +ContainerMemoryLimit = Literal["1g", "4g", "16g", "64g"] +"""Type of ContainerMemoryLimit.""" + +ContainerNetworkPolicyParamType = Literal["disabled", "allowlist"] +"""Type of ContainerNetworkPolicyParamType.""" + +ContainerSkillType = Literal["skill_reference", "inline"] +"""Type of ContainerSkillType.""" + +CustomToolParamFormatType = Literal["text", "grammar"] +"""Type of CustomToolParamFormatType.""" + +DetailEnum = Literal["low", "high", "auto"] +"""Type of DetailEnum.""" + +FunctionAndCustomToolCallOutputType = Literal["input_text", "input_image", "input_file"] +"""Type of FunctionAndCustomToolCallOutputType.""" + +FunctionCallItemStatus = Literal["in_progress", "completed", "incomplete"] +"""Type of FunctionCallItemStatus.""" + +FunctionShellCallEnvironmentType = Literal["local", "container_reference"] +"""Type of FunctionShellCallEnvironmentType.""" + +FunctionShellCallItemParamEnvironmentType = Literal["local", "container_reference"] +"""Type of FunctionShellCallItemParamEnvironmentType.""" + +FunctionShellCallItemStatus = Literal["in_progress", "completed", "incomplete"] +"""Shell call status.""" + +FunctionShellCallOutputOutcomeParamType = Literal["timeout", "exit"] +"""Type of FunctionShellCallOutputOutcomeParamType.""" + +FunctionShellCallOutputOutcomeType = Literal["timeout", "exit"] +"""Type of FunctionShellCallOutputOutcomeType.""" + +FunctionShellToolParamEnvironmentType = Literal["container_auto", "local", "container_reference"] +"""Type of FunctionShellToolParamEnvironmentType.""" + +GrammarSyntax1 = Literal["lark", "regex"] +"""Type of GrammarSyntax1.""" + +ImageDetail = Literal["low", "high", "auto"] +"""Type of ImageDetail.""" + +ImageGenActionEnum = Literal["generate", "edit", "auto"] +"""Type of ImageGenActionEnum.""" + +IncludeEnum = Literal[ + "file_search_call.results", + "web_search_call.results", + "web_search_call.action.sources", + "message.input_image.image_url", + "computer_call_output.output.image_url", + "code_interpreter_call.outputs", + "reasoning.encrypted_content", + "message.output_text.logprobs", + "memory_search_call.results", +] +"""Specify additional output data to include in the model response. Currently supported values +are: + +* `web_search_call.action.sources`: Include the sources of the web search tool call. +* `code_interpreter_call.outputs`: Includes the outputs of python code execution in code +interpreter tool call items. +* `computer_call_output.output.image_url`: Include image urls from the computer call output. +* `file_search_call.results`: Include the search results of the file search tool call. +* `message.input_image.image_url`: Include image urls from the input message. +* `message.output_text.logprobs`: Include logprobs with assistant messages. +* `reasoning.encrypted_content`: Includes an encrypted version of reasoning tokens in reasoning +item outputs. This enables reasoning items to be used in multi-turn conversations when using +the Responses API statelessly (like when the `store` parameter is set to `false`, or when an +organization is enrolled in the zero data retention program).""" + +InputFidelity = Literal["high", "low"] +"""Control how much effort the model will exert to match the style and features, especially facial +features, of input images. This parameter is only supported for ``gpt-image-1`` and +``gpt-image-1.5`` and later models, unsupported for ``gpt-image-1-mini``. Supports ``high`` and +``low``. Defaults to ``low``.""" + +ItemFieldType = Literal[ + "message", + "function_call", + "function_call_output", + "file_search_call", + "web_search_call", + "image_generation_call", + "computer_call", + "computer_call_output", + "reasoning", + "compaction", + "code_interpreter_call", + "local_shell_call", + "local_shell_call_output", + "shell_call", + "shell_call_output", + "apply_patch_call", + "apply_patch_call_output", + "mcp_list_tools", + "mcp_approval_request", + "mcp_approval_response", + "mcp_call", + "custom_tool_call", + "custom_tool_call_output", +] +"""Type of ItemFieldType.""" + +ItemType = Literal[ + "message", + "output_message", + "file_search_call", + "computer_call", + "computer_call_output", + "web_search_call", + "function_call", + "function_call_output", + "reasoning", + "compaction", + "image_generation_call", + "code_interpreter_call", + "local_shell_call", + "local_shell_call_output", + "shell_call", + "shell_call_output", + "apply_patch_call", + "apply_patch_call_output", + "mcp_list_tools", + "mcp_approval_request", + "mcp_approval_response", + "mcp_call", + "custom_tool_call_output", + "custom_tool_call", + "item_reference", + "structured_outputs", + "oauth_consent_request", + "memory_search_call", + "workflow_action", + "a2a_preview_call", + "a2a_preview_call_output", + "bing_grounding_call", + "bing_grounding_call_output", + "sharepoint_grounding_preview_call", + "sharepoint_grounding_preview_call_output", + "azure_ai_search_call", + "azure_ai_search_call_output", + "bing_custom_search_preview_call", + "bing_custom_search_preview_call_output", + "openapi_call", + "openapi_call_output", + "browser_automation_preview_call", + "browser_automation_preview_call_output", + "fabric_dataagent_preview_call", + "fabric_dataagent_preview_call_output", + "azure_function_call", + "azure_function_call_output", +] +"""Type of ItemType.""" + +LocalShellCallOutputStatusEnum = Literal["in_progress", "completed", "incomplete"] +"""Type of LocalShellCallOutputStatusEnum.""" + +LocalShellCallStatus = Literal["in_progress", "completed", "incomplete"] +"""Type of LocalShellCallStatus.""" + +MCPToolCallStatus = Literal["in_progress", "completed", "incomplete", "calling", "failed"] +"""Type of MCPToolCallStatus.""" + +MemoryItemKind = Literal["user_profile", "chat_summary"] +"""Memory item kind.""" + +MessageContentType = Literal[ + "input_text", + "output_text", + "text", + "summary_text", + "reasoning_text", + "refusal", + "input_image", + "computer_screenshot", + "input_file", +] +"""Type of MessageContentType.""" + +MessageRole = Literal["unknown", "user", "assistant", "system", "critic", "discriminator", "developer", "tool"] +"""Type of MessageRole.""" + +MessageStatus = Literal["in_progress", "completed", "incomplete"] +"""Type of MessageStatus.""" + +ModelIdsCompaction = Literal[ + "gpt-5.2", + "gpt-5.2-2025-12-11", + "gpt-5.2-chat-latest", + "gpt-5.2-pro", + "gpt-5.2-pro-2025-12-11", + "gpt-5.1", + "gpt-5.1-2025-11-13", + "gpt-5.1-codex", + "gpt-5.1-mini", + "gpt-5.1-chat-latest", + "gpt-5", + "gpt-5-mini", + "gpt-5-nano", + "gpt-5-2025-08-07", + "gpt-5-mini-2025-08-07", + "gpt-5-nano-2025-08-07", + "gpt-5-chat-latest", + "gpt-4.1", + "gpt-4.1-mini", + "gpt-4.1-nano", + "gpt-4.1-2025-04-14", + "gpt-4.1-mini-2025-04-14", + "gpt-4.1-nano-2025-04-14", + "o4-mini", + "o4-mini-2025-04-16", + "o3", + "o3-2025-04-16", + "o3-mini", + "o3-mini-2025-01-31", + "o1", + "o1-2024-12-17", + "o1-preview", + "o1-preview-2024-09-12", + "o1-mini", + "o1-mini-2024-09-12", + "gpt-4o", + "gpt-4o-2024-11-20", + "gpt-4o-2024-08-06", + "gpt-4o-2024-05-13", + "gpt-4o-audio-preview", + "gpt-4o-audio-preview-2024-10-01", + "gpt-4o-audio-preview-2024-12-17", + "gpt-4o-audio-preview-2025-06-03", + "gpt-4o-mini-audio-preview", + "gpt-4o-mini-audio-preview-2024-12-17", + "gpt-4o-search-preview", + "gpt-4o-mini-search-preview", + "gpt-4o-search-preview-2025-03-11", + "gpt-4o-mini-search-preview-2025-03-11", + "chatgpt-4o-latest", + "codex-mini-latest", + "gpt-4o-mini", + "gpt-4o-mini-2024-07-18", + "gpt-4-turbo", + "gpt-4-turbo-2024-04-09", + "gpt-4-0125-preview", + "gpt-4-turbo-preview", + "gpt-4-1106-preview", + "gpt-4-vision-preview", + "gpt-4", + "gpt-4-0314", + "gpt-4-0613", + "gpt-4-32k", + "gpt-4-32k-0314", + "gpt-4-32k-0613", + "gpt-3.5-turbo", + "gpt-3.5-turbo-16k", + "gpt-3.5-turbo-0301", + "gpt-3.5-turbo-0613", + "gpt-3.5-turbo-1106", + "gpt-3.5-turbo-0125", + "gpt-3.5-turbo-16k-0613", + "o1-pro", + "o1-pro-2025-03-19", + "o3-pro", + "o3-pro-2025-06-10", + "o3-deep-research", + "o3-deep-research-2025-06-26", + "o4-mini-deep-research", + "o4-mini-deep-research-2025-06-26", + "computer-use-preview", + "computer-use-preview-2025-03-11", + "gpt-5-codex", + "gpt-5-pro", + "gpt-5-pro-2025-10-06", + "gpt-5.1-codex-max", +] +"""Model ID used to generate the response, like ``gpt-5`` or ``o3``. OpenAI offers a wide range of +models with different capabilities, performance characteristics, and price points. Refer to the +`model guide `_ to browse and compare available models.""" + +OpenApiAuthType = Literal["anonymous", "project_connection", "managed_identity"] +"""Authentication type for OpenApi endpoint. Allowed types are: + +* Anonymous (no authentication required) +* Project Connection (requires project_connection_id to endpoint, as setup in AI Foundry) +* Managed_Identity (requires audience for identity based auth).""" + +OutputContentType = Literal["output_text", "refusal", "reasoning_text"] +"""Type of OutputContentType.""" + +OutputItemType = Literal[ + "output_message", + "file_search_call", + "function_call", + "web_search_call", + "computer_call", + "reasoning", + "compaction", + "image_generation_call", + "code_interpreter_call", + "local_shell_call", + "shell_call", + "shell_call_output", + "apply_patch_call", + "apply_patch_call_output", + "mcp_call", + "mcp_list_tools", + "mcp_approval_request", + "custom_tool_call", + "message", + "computer_call_output", + "function_call_output", + "local_shell_call_output", + "mcp_approval_response", + "custom_tool_call_output", + "structured_outputs", + "oauth_consent_request", + "memory_search_call", + "workflow_action", + "a2a_preview_call", + "a2a_preview_call_output", + "bing_grounding_call", + "bing_grounding_call_output", + "sharepoint_grounding_preview_call", + "sharepoint_grounding_preview_call_output", + "azure_ai_search_call", + "azure_ai_search_call_output", + "bing_custom_search_preview_call", + "bing_custom_search_preview_call_output", + "openapi_call", + "openapi_call_output", + "browser_automation_preview_call", + "browser_automation_preview_call_output", + "fabric_dataagent_preview_call", + "fabric_dataagent_preview_call_output", + "azure_function_call", + "azure_function_call_output", +] +"""Type of OutputItemType.""" + +OutputMessageContentType = Literal["output_text", "refusal"] +"""Type of OutputMessageContentType.""" + +PageOrder = Literal["asc", "desc"] +"""Type of PageOrder.""" + +RankerVersionType = Literal["auto", "default-2024-11-15"] +"""Type of RankerVersionType.""" + +ResponseErrorCode = Literal[ + "server_error", + "rate_limit_exceeded", + "invalid_prompt", + "vector_store_timeout", + "invalid_image", + "invalid_image_format", + "invalid_base64_image", + "invalid_image_url", + "image_too_large", + "image_too_small", + "image_parse_error", + "image_content_policy_violation", + "invalid_image_mode", + "image_file_too_large", + "unsupported_image_media_type", + "empty_image_file", + "failed_to_download_image", + "image_file_not_found", +] +"""The error code for the response.""" + +ResponseStreamEventType = Literal[ + "response.audio.delta", + "response.audio.done", + "response.audio.transcript.delta", + "response.audio.transcript.done", + "response.code_interpreter_call_code.delta", + "response.code_interpreter_call_code.done", + "response.code_interpreter_call.completed", + "response.code_interpreter_call.in_progress", + "response.code_interpreter_call.interpreting", + "response.completed", + "response.content_part.added", + "response.content_part.done", + "response.created", + "error", + "response.file_search_call.completed", + "response.file_search_call.in_progress", + "response.file_search_call.searching", + "response.function_call_arguments.delta", + "response.function_call_arguments.done", + "response.in_progress", + "response.failed", + "response.incomplete", + "response.output_item.added", + "response.output_item.done", + "response.reasoning_summary_part.added", + "response.reasoning_summary_part.done", + "response.reasoning_summary_text.delta", + "response.reasoning_summary_text.done", + "response.reasoning_text.delta", + "response.reasoning_text.done", + "response.refusal.delta", + "response.refusal.done", + "response.output_text.delta", + "response.output_text.done", + "response.web_search_call.completed", + "response.web_search_call.in_progress", + "response.web_search_call.searching", + "response.image_generation_call.completed", + "response.image_generation_call.generating", + "response.image_generation_call.in_progress", + "response.image_generation_call.partial_image", + "response.mcp_call_arguments.delta", + "response.mcp_call_arguments.done", + "response.mcp_call.completed", + "response.mcp_call.failed", + "response.mcp_call.in_progress", + "response.mcp_list_tools.completed", + "response.mcp_list_tools.failed", + "response.mcp_list_tools.in_progress", + "response.output_text.annotation.added", + "response.queued", + "response.custom_tool_call_input.delta", + "response.custom_tool_call_input.done", +] +"""Type of ResponseStreamEventType.""" + +SearchContextSize = Literal["low", "medium", "high"] +"""Type of SearchContextSize.""" + +TextResponseFormatConfigurationType = Literal["text", "json_schema", "json_object"] +"""Type of TextResponseFormatConfigurationType.""" + +ToolCallStatus = Literal["in_progress", "completed", "incomplete", "failed"] +"""The status of a tool call.""" + +ToolChoiceOptions = Literal["none", "auto", "required"] +"""Tool choice mode.""" + +ToolChoiceParamType = Literal[ + "allowed_tools", + "function", + "mcp", + "custom", + "apply_patch", + "shell", + "file_search", + "web_search_preview", + "computer_use_preview", + "web_search_preview_2025_03_11", + "image_generation", + "code_interpreter", +] +"""Type of ToolChoiceParamType.""" + +ToolType = Literal[ + "function", + "file_search", + "computer_use_preview", + "web_search", + "mcp", + "code_interpreter", + "image_generation", + "local_shell", + "shell", + "custom", + "web_search_preview", + "apply_patch", + "a2a_preview", + "bing_custom_search_preview", + "browser_automation_preview", + "fabric_dataagent_preview", + "sharepoint_grounding_preview", + "memory_search_preview", + "work_iq_preview", + "azure_ai_search", + "azure_function", + "bing_grounding", + "capture_structured_outputs", + "openapi", + "memory_search", +] +"""Type of ToolType.""" + + +class A2APreviewTool(TypedDict, total=False): + """An agent implementing the A2A protocol. + + :ivar type: The type of the tool. Always ``"a2a_preview``. Required. A2_A_PREVIEW. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.A2_A_PREVIEW + :ivar name: Optional user-defined name for this tool or configuration. + :vartype name: str + :ivar description: Optional user-defined description for this tool or configuration. + :vartype description: str + :ivar base_url: Base URL of the agent. + :vartype base_url: str + :ivar agent_card_path: The path to the agent card relative to the ``base_url``. If not + provided, defaults to ``/.well-known/agent-card.json``. + :vartype agent_card_path: str + :ivar project_connection_id: The connection ID in the project for the A2A server. The + connection stores authentication and other connection details needed to connect to the A2A + server. + :vartype project_connection_id: str + """ + + type: Required[Literal[ToolType.A2_A_PREVIEW]] + """The type of the tool. Always ``\"a2a_preview``. Required. A2_A_PREVIEW.""" + name: str + """Optional user-defined name for this tool or configuration.""" + description: str + """Optional user-defined description for this tool or configuration.""" + base_url: str + """Base URL of the agent.""" + agent_card_path: str + """The path to the agent card relative to the ``base_url``. If not provided, defaults to + ``/.well-known/agent-card.json``.""" + project_connection_id: str + """The connection ID in the project for the A2A server. The connection stores authentication and + other connection details needed to connect to the A2A server.""" + + +class A2AToolCall(TypedDict, total=False): + """An A2A (Agent-to-Agent) tool call. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar type: Required. A2_A_PREVIEW_CALL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.A2_A_PREVIEW_CALL + :ivar call_id: The unique ID of the tool call generated by the model. Required. + :vartype call_id: str + :ivar name: The name of the A2A agent card being called. Required. + :vartype name: str + :ivar arguments: A JSON string of the arguments to pass to the tool. Required. + :vartype arguments: str + :ivar status: The status of the tool call. Required. Known values are: "in_progress", + "completed", "incomplete", and "failed". + :vartype status: str or ~azure.ai.agentserver.responses.models.models.ToolCallStatus + :ivar id: Required. + :vartype id: str + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + type: Required[Literal[OutputItemType.A2_A_PREVIEW_CALL]] + """Required. A2_A_PREVIEW_CALL.""" + call_id: Required[str] + """The unique ID of the tool call generated by the model. Required.""" + name: Required[str] + """The name of the A2A agent card being called. Required.""" + arguments: Required[str] + """A JSON string of the arguments to pass to the tool. Required.""" + status: Required[ToolCallStatus] + """The status of the tool call. Required. Known values are: \"in_progress\", \"completed\", + \"incomplete\", and \"failed\".""" + id: Required[str] + """Required.""" + + +class A2AToolCallOutput(TypedDict, total=False): + """The output of an A2A (Agent-to-Agent) tool call. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar type: Required. A2_A_PREVIEW_CALL_OUTPUT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.A2_A_PREVIEW_CALL_OUTPUT + :ivar call_id: The unique ID of the tool call generated by the model. Required. + :vartype call_id: str + :ivar name: The name of the A2A agent card that was called. Required. + :vartype name: str + :ivar output: The output from the A2A tool call. Is one of the following types: {str: Any}, + str, [Any] + :vartype output: dict[str, any] or str or list[any] + :ivar status: The status of the tool call. Required. Known values are: "in_progress", + "completed", "incomplete", and "failed". + :vartype status: str or ~azure.ai.agentserver.responses.models.models.ToolCallStatus + :ivar id: Required. + :vartype id: str + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + type: Required[Literal[OutputItemType.A2_A_PREVIEW_CALL_OUTPUT]] + """Required. A2_A_PREVIEW_CALL_OUTPUT.""" + call_id: Required[str] + """The unique ID of the tool call generated by the model. Required.""" + name: Required[str] + """The name of the A2A agent card that was called. Required.""" + output: "_unions.ToolCallOutputContent" + """The output from the A2A tool call. Is one of the following types: {str: Any}, str, [Any]""" + status: Required[ToolCallStatus] + """The status of the tool call. Required. Known values are: \"in_progress\", \"completed\", + \"incomplete\", and \"failed\".""" + id: Required[str] + """Required.""" + + +class AgentId(TypedDict, total=False): + """AgentId. + + :ivar type: Required. Default value is "agent_id". + :vartype type: str + :ivar name: The name of the agent. Required. + :vartype name: str + :ivar version: The version identifier of the agent. Required. + :vartype version: str + """ + + type: Required[Literal["agent_id"]] + """Required. Default value is \"agent_id\".""" + name: Required[str] + """The name of the agent. Required.""" + version: Required[str] + """The version identifier of the agent. Required.""" + + +class AgentReference(TypedDict, total=False): + """AgentReference. + + :ivar type: Required. Default value is "agent_reference". + :vartype type: str + :ivar name: The name of the agent. Required. + :vartype name: str + :ivar version: The version identifier of the agent. + :vartype version: str + """ + + type: Required[Literal["agent_reference"]] + """Required. Default value is \"agent_reference\".""" + name: Required[str] + """The name of the agent. Required.""" + version: str + """The version identifier of the agent.""" + + +class AISearchIndexResource(TypedDict, total=False): + """A AI Search Index resource. + + :ivar project_connection_id: An index connection ID in an IndexResource attached to this agent. + :vartype project_connection_id: str + :ivar index_name: The name of an index in an IndexResource attached to this agent. + :vartype index_name: str + :ivar name: Optional user-defined name for this tool or configuration. + :vartype name: str + :ivar description: Optional user-defined description for this tool or configuration. + :vartype description: str + :ivar query_type: Type of query in an AIIndexResource attached to this agent. Known values are: + "simple", "semantic", "vector", "vector_simple_hybrid", and "vector_semantic_hybrid". + :vartype query_type: str or + ~azure.ai.agentserver.responses.models.models.AzureAISearchQueryType + :ivar top_k: Number of documents to retrieve from search and present to the model. + :vartype top_k: int + :ivar filter: filter string for search resource. `Learn more here + `_. + :vartype filter: str + :ivar index_asset_id: Index asset id for search resource. + :vartype index_asset_id: str + """ + + project_connection_id: str + """An index connection ID in an IndexResource attached to this agent.""" + index_name: str + """The name of an index in an IndexResource attached to this agent.""" + name: str + """Optional user-defined name for this tool or configuration.""" + description: str + """Optional user-defined description for this tool or configuration.""" + query_type: AzureAISearchQueryType + """Type of query in an AIIndexResource attached to this agent. Known values are: \"simple\", + \"semantic\", \"vector\", \"vector_simple_hybrid\", and \"vector_semantic_hybrid\".""" + top_k: int + """Number of documents to retrieve from search and present to the model.""" + filter: str + """filter string for search resource. `Learn more here + `_.""" + index_asset_id: str + """Index asset id for search resource.""" + + +class ApiErrorResponse(TypedDict, total=False): + """Error response for API failures. + + :ivar error: Required. + :vartype error: ~azure.ai.agentserver.responses.models.types.Error + """ + + error: Required["Error"] + """Required.""" + + +class ApplyPatchCreateFileOperation(TypedDict, total=False): + """Apply patch create file operation. + + :ivar type: Create a new file with the provided diff. Required. CREATE_FILE. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.CREATE_FILE + :ivar path: Path of the file to create. Required. + :vartype path: str + :ivar diff: Diff to apply. Required. + :vartype diff: str + """ + + type: Required[Literal[ApplyPatchFileOperationType.CREATE_FILE]] + """Create a new file with the provided diff. Required. CREATE_FILE.""" + path: Required[str] + """Path of the file to create. Required.""" + diff: Required[str] + """Diff to apply. Required.""" + + +class ApplyPatchCreateFileOperationParam(TypedDict, total=False): + """Apply patch create file operation. + + :ivar type: The operation type. Always ``create_file``. Required. CREATE_FILE. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.CREATE_FILE + :ivar path: Path of the file to create relative to the workspace root. Required. + :vartype path: str + :ivar diff: Unified diff content to apply when creating the file. Required. + :vartype diff: str + """ + + type: Required[Literal[ApplyPatchOperationParamType.CREATE_FILE]] + """The operation type. Always ``create_file``. Required. CREATE_FILE.""" + path: Required[str] + """Path of the file to create relative to the workspace root. Required.""" + diff: Required[str] + """Unified diff content to apply when creating the file. Required.""" + + +class ApplyPatchDeleteFileOperation(TypedDict, total=False): + """Apply patch delete file operation. + + :ivar type: Delete the specified file. Required. DELETE_FILE. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.DELETE_FILE + :ivar path: Path of the file to delete. Required. + :vartype path: str + """ + + type: Required[Literal[ApplyPatchFileOperationType.DELETE_FILE]] + """Delete the specified file. Required. DELETE_FILE.""" + path: Required[str] + """Path of the file to delete. Required.""" + + +class ApplyPatchDeleteFileOperationParam(TypedDict, total=False): + """Apply patch delete file operation. + + :ivar type: The operation type. Always ``delete_file``. Required. DELETE_FILE. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.DELETE_FILE + :ivar path: Path of the file to delete relative to the workspace root. Required. + :vartype path: str + """ + + type: Required[Literal[ApplyPatchOperationParamType.DELETE_FILE]] + """The operation type. Always ``delete_file``. Required. DELETE_FILE.""" + path: Required[str] + """Path of the file to delete relative to the workspace root. Required.""" + + +class ApplyPatchToolCallItemParam(TypedDict, total=False): + """Apply patch tool call. + + :ivar type: The type of the item. Always ``apply_patch_call``. Required. APPLY_PATCH_CALL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.APPLY_PATCH_CALL + :ivar id: + :vartype id: str + :ivar call_id: The unique ID of the apply patch tool call generated by the model. Required. + :vartype call_id: str + :ivar status: The status of the apply patch tool call. One of ``in_progress`` or ``completed``. + Required. Known values are: "in_progress" and "completed". + :vartype status: str or ~azure.ai.agentserver.responses.models.models.ApplyPatchCallStatusParam + :ivar operation: The specific create, delete, or update instruction for the apply_patch tool + call. Required. + :vartype operation: ~azure.ai.agentserver.responses.models.types.ApplyPatchOperationParam + """ + + type: Required[Literal[ItemType.APPLY_PATCH_CALL]] + """The type of the item. Always ``apply_patch_call``. Required. APPLY_PATCH_CALL.""" + id: Optional[str] + call_id: Required[str] + """The unique ID of the apply patch tool call generated by the model. Required.""" + status: Required[ApplyPatchCallStatusParam] + """The status of the apply patch tool call. One of ``in_progress`` or ``completed``. Required. + Known values are: \"in_progress\" and \"completed\".""" + operation: Required["ApplyPatchOperationParam"] + """The specific create, delete, or update instruction for the apply_patch tool call. Required.""" + + +class ApplyPatchToolCallOutputItemParam(TypedDict, total=False): + """Apply patch tool call output. + + :ivar type: The type of the item. Always ``apply_patch_call_output``. Required. + APPLY_PATCH_CALL_OUTPUT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.APPLY_PATCH_CALL_OUTPUT + :ivar id: + :vartype id: str + :ivar call_id: The unique ID of the apply patch tool call generated by the model. Required. + :vartype call_id: str + :ivar status: The status of the apply patch tool call output. One of ``completed`` or + ``failed``. Required. Known values are: "completed" and "failed". + :vartype status: str or + ~azure.ai.agentserver.responses.models.models.ApplyPatchCallOutputStatusParam + :ivar output: + :vartype output: str + """ + + type: Required[Literal[ItemType.APPLY_PATCH_CALL_OUTPUT]] + """The type of the item. Always ``apply_patch_call_output``. Required. APPLY_PATCH_CALL_OUTPUT.""" + id: Optional[str] + call_id: Required[str] + """The unique ID of the apply patch tool call generated by the model. Required.""" + status: Required[ApplyPatchCallOutputStatusParam] + """The status of the apply patch tool call output. One of ``completed`` or ``failed``. Required. + Known values are: \"completed\" and \"failed\".""" + output: Optional[str] + + +class ApplyPatchToolParam(TypedDict, total=False): + """Apply patch tool. + + :ivar type: The type of the tool. Always ``apply_patch``. Required. APPLY_PATCH. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.APPLY_PATCH + """ + + type: Required[Literal[ToolType.APPLY_PATCH]] + """The type of the tool. Always ``apply_patch``. Required. APPLY_PATCH.""" + + +class ApplyPatchUpdateFileOperation(TypedDict, total=False): + """Apply patch update file operation. + + :ivar type: Update an existing file with the provided diff. Required. UPDATE_FILE. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.UPDATE_FILE + :ivar path: Path of the file to update. Required. + :vartype path: str + :ivar diff: Diff to apply. Required. + :vartype diff: str + """ + + type: Required[Literal[ApplyPatchFileOperationType.UPDATE_FILE]] + """Update an existing file with the provided diff. Required. UPDATE_FILE.""" + path: Required[str] + """Path of the file to update. Required.""" + diff: Required[str] + """Diff to apply. Required.""" + + +class ApplyPatchUpdateFileOperationParam(TypedDict, total=False): + """Apply patch update file operation. + + :ivar type: The operation type. Always ``update_file``. Required. UPDATE_FILE. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.UPDATE_FILE + :ivar path: Path of the file to update relative to the workspace root. Required. + :vartype path: str + :ivar diff: Unified diff content to apply to the existing file. Required. + :vartype diff: str + """ + + type: Required[Literal[ApplyPatchOperationParamType.UPDATE_FILE]] + """The operation type. Always ``update_file``. Required. UPDATE_FILE.""" + path: Required[str] + """Path of the file to update relative to the workspace root. Required.""" + diff: Required[str] + """Unified diff content to apply to the existing file. Required.""" + + +class ApproximateLocation(TypedDict, total=False): + """ApproximateLocation. + + :ivar type: The type of location approximation. Always ``approximate``. Required. Default value + is "approximate". + :vartype type: str + :ivar country: + :vartype country: str + :ivar region: + :vartype region: str + :ivar city: + :vartype city: str + :ivar timezone: + :vartype timezone: str + """ + + type: Required[Literal["approximate"]] + """The type of location approximation. Always ``approximate``. Required. Default value is + \"approximate\".""" + country: Optional[str] + region: Optional[str] + city: Optional[str] + timezone: Optional[str] + + +class AutoCodeInterpreterToolParam(TypedDict, total=False): + """Automatic Code Interpreter Tool Parameters. + + :ivar type: Always ``auto``. Required. Default value is "auto". + :vartype type: str + :ivar file_ids: An optional list of uploaded files to make available to your code. + :vartype file_ids: list[str] + :ivar memory_limit: Known values are: "1g", "4g", "16g", and "64g". + :vartype memory_limit: str or + ~azure.ai.agentserver.responses.models.models.ContainerMemoryLimit + :ivar network_policy: + :vartype network_policy: + ~azure.ai.agentserver.responses.models.types.ContainerNetworkPolicyParam + """ + + type: Required[Literal["auto"]] + """Always ``auto``. Required. Default value is \"auto\".""" + file_ids: list[str] + """An optional list of uploaded files to make available to your code.""" + memory_limit: Optional[ContainerMemoryLimit] + """Known values are: \"1g\", \"4g\", \"16g\", and \"64g\".""" + network_policy: "ContainerNetworkPolicyParam" + + +class AzureAISearchTool(TypedDict, total=False): + """The input definition information for an Azure AI search tool as used to configure an agent. + + :ivar type: The object type, which is always 'azure_ai_search'. Required. AZURE_AI_SEARCH. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.AZURE_AI_SEARCH + :ivar name: Optional user-defined name for this tool or configuration. + :vartype name: str + :ivar description: Optional user-defined description for this tool or configuration. + :vartype description: str + :ivar azure_ai_search: The azure ai search index resource. Required. + :vartype azure_ai_search: + ~azure.ai.agentserver.responses.models.types.AzureAISearchToolResource + """ + + type: Required[Literal[ToolType.AZURE_AI_SEARCH]] + """The object type, which is always 'azure_ai_search'. Required. AZURE_AI_SEARCH.""" + name: str + """Optional user-defined name for this tool or configuration.""" + description: str + """Optional user-defined description for this tool or configuration.""" + azure_ai_search: Required["AzureAISearchToolResource"] + """The azure ai search index resource. Required.""" + + +class AzureAISearchToolCall(TypedDict, total=False): + """An Azure AI Search tool call. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar type: Required. AZURE_AI_SEARCH_CALL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.AZURE_AI_SEARCH_CALL + :ivar call_id: The unique ID of the tool call generated by the model. Required. + :vartype call_id: str + :ivar arguments: A JSON string of the arguments to pass to the tool. Required. + :vartype arguments: str + :ivar status: The status of the tool call. Required. Known values are: "in_progress", + "completed", "incomplete", and "failed". + :vartype status: str or ~azure.ai.agentserver.responses.models.models.ToolCallStatus + :ivar id: Required. + :vartype id: str + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + type: Required[Literal[OutputItemType.AZURE_AI_SEARCH_CALL]] + """Required. AZURE_AI_SEARCH_CALL.""" + call_id: Required[str] + """The unique ID of the tool call generated by the model. Required.""" + arguments: Required[str] + """A JSON string of the arguments to pass to the tool. Required.""" + status: Required[ToolCallStatus] + """The status of the tool call. Required. Known values are: \"in_progress\", \"completed\", + \"incomplete\", and \"failed\".""" + id: Required[str] + """Required.""" + + +class AzureAISearchToolCallOutput(TypedDict, total=False): + """The output of an Azure AI Search tool call. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar type: Required. AZURE_AI_SEARCH_CALL_OUTPUT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.AZURE_AI_SEARCH_CALL_OUTPUT + :ivar call_id: The unique ID of the tool call generated by the model. Required. + :vartype call_id: str + :ivar output: The output from the Azure AI Search tool call. Is one of the following types: + {str: Any}, str, [Any] + :vartype output: dict[str, any] or str or list[any] + :ivar status: The status of the tool call. Required. Known values are: "in_progress", + "completed", "incomplete", and "failed". + :vartype status: str or ~azure.ai.agentserver.responses.models.models.ToolCallStatus + :ivar id: Required. + :vartype id: str + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + type: Required[Literal[OutputItemType.AZURE_AI_SEARCH_CALL_OUTPUT]] + """Required. AZURE_AI_SEARCH_CALL_OUTPUT.""" + call_id: Required[str] + """The unique ID of the tool call generated by the model. Required.""" + output: "_unions.ToolCallOutputContent" + """The output from the Azure AI Search tool call. Is one of the following types: {str: Any}, str, + [Any]""" + status: Required[ToolCallStatus] + """The status of the tool call. Required. Known values are: \"in_progress\", \"completed\", + \"incomplete\", and \"failed\".""" + id: Required[str] + """Required.""" + + +class AzureAISearchToolResource(TypedDict, total=False): + """A set of index resources used by the ``azure_ai_search`` tool. + + :ivar name: Optional user-defined name for this tool or configuration. + :vartype name: str + :ivar description: Optional user-defined description for this tool or configuration. + :vartype description: str + :ivar indexes: The indices attached to this agent. There can be a maximum of 1 index resource + attached to the agent. Required. + :vartype indexes: list[~azure.ai.agentserver.responses.models.types.AISearchIndexResource] + """ + + name: str + """Optional user-defined name for this tool or configuration.""" + description: str + """Optional user-defined description for this tool or configuration.""" + indexes: Required[list["AISearchIndexResource"]] + """The indices attached to this agent. There can be a maximum of 1 index resource attached to the + agent. Required.""" + + +class AzureFunctionBinding(TypedDict, total=False): + """The structure for keeping storage queue name and URI. + + :ivar type: The type of binding, which is always 'storage_queue'. Required. Default value is + "storage_queue". + :vartype type: str + :ivar storage_queue: Storage queue. Required. + :vartype storage_queue: ~azure.ai.agentserver.responses.models.types.AzureFunctionStorageQueue + """ + + type: Required[Literal["storage_queue"]] + """The type of binding, which is always 'storage_queue'. Required. Default value is + \"storage_queue\".""" + storage_queue: Required["AzureFunctionStorageQueue"] + """Storage queue. Required.""" + + +class AzureFunctionDefinition(TypedDict, total=False): + """The definition of Azure function. + + :ivar function: The definition of azure function and its parameters. Required. + :vartype function: ~azure.ai.agentserver.responses.models.types.AzureFunctionDefinitionFunction + :ivar input_binding: Input storage queue. The queue storage trigger runs a function as messages + are added to it. Required. + :vartype input_binding: ~azure.ai.agentserver.responses.models.types.AzureFunctionBinding + :ivar output_binding: Output storage queue. The function writes output to this queue when the + input items are processed. Required. + :vartype output_binding: ~azure.ai.agentserver.responses.models.types.AzureFunctionBinding + """ + + function: Required["AzureFunctionDefinitionFunction"] + """The definition of azure function and its parameters. Required.""" + input_binding: Required["AzureFunctionBinding"] + """Input storage queue. The queue storage trigger runs a function as messages are added to it. + Required.""" + output_binding: Required["AzureFunctionBinding"] + """Output storage queue. The function writes output to this queue when the input items are + processed. Required.""" + + +class AzureFunctionDefinitionFunction(TypedDict, total=False): + """AzureFunctionDefinitionFunction. + + :ivar name: The name of the function to be called. Required. + :vartype name: str + :ivar description: A description of what the function does, used by the model to choose when + and how to call the function. + :vartype description: str + :ivar parameters: The parameters the functions accepts, described as a JSON Schema object. + Required. + :vartype parameters: dict[str, any] + """ + + name: Required[str] + """The name of the function to be called. Required.""" + description: str + """A description of what the function does, used by the model to choose when and how to call the + function.""" + parameters: Required[dict[str, Any]] + """The parameters the functions accepts, described as a JSON Schema object. Required.""" + + +class AzureFunctionStorageQueue(TypedDict, total=False): + """The structure for keeping storage queue name and URI. + + :ivar queue_service_endpoint: URI to the Azure Storage Queue service allowing you to manipulate + a queue. Required. + :vartype queue_service_endpoint: str + :ivar queue_name: The name of an Azure function storage queue. Required. + :vartype queue_name: str + """ + + queue_service_endpoint: Required[str] + """URI to the Azure Storage Queue service allowing you to manipulate a queue. Required.""" + queue_name: Required[str] + """The name of an Azure function storage queue. Required.""" + + +class AzureFunctionTool(TypedDict, total=False): + """The input definition information for an Azure Function Tool, as used to configure an Agent. + + :ivar type: The object type, which is always 'browser_automation'. Required. AZURE_FUNCTION. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.AZURE_FUNCTION + :ivar azure_function: The Azure Function Tool definition. Required. + :vartype azure_function: ~azure.ai.agentserver.responses.models.types.AzureFunctionDefinition + """ + + type: Required[Literal[ToolType.AZURE_FUNCTION]] + """The object type, which is always 'browser_automation'. Required. AZURE_FUNCTION.""" + azure_function: Required["AzureFunctionDefinition"] + """The Azure Function Tool definition. Required.""" + + +class AzureFunctionToolCall(TypedDict, total=False): + """An Azure Function tool call. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar type: Required. AZURE_FUNCTION_CALL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.AZURE_FUNCTION_CALL + :ivar call_id: The unique ID of the tool call generated by the model. Required. + :vartype call_id: str + :ivar name: The name of the Azure Function being called. Required. + :vartype name: str + :ivar arguments: A JSON string of the arguments to pass to the tool. Required. + :vartype arguments: str + :ivar status: The status of the tool call. Required. Known values are: "in_progress", + "completed", "incomplete", and "failed". + :vartype status: str or ~azure.ai.agentserver.responses.models.models.ToolCallStatus + :ivar id: Required. + :vartype id: str + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + type: Required[Literal[OutputItemType.AZURE_FUNCTION_CALL]] + """Required. AZURE_FUNCTION_CALL.""" + call_id: Required[str] + """The unique ID of the tool call generated by the model. Required.""" + name: Required[str] + """The name of the Azure Function being called. Required.""" + arguments: Required[str] + """A JSON string of the arguments to pass to the tool. Required.""" + status: Required[ToolCallStatus] + """The status of the tool call. Required. Known values are: \"in_progress\", \"completed\", + \"incomplete\", and \"failed\".""" + id: Required[str] + """Required.""" + + +class AzureFunctionToolCallOutput(TypedDict, total=False): + """The output of an Azure Function tool call. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar type: Required. AZURE_FUNCTION_CALL_OUTPUT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.AZURE_FUNCTION_CALL_OUTPUT + :ivar call_id: The unique ID of the tool call generated by the model. Required. + :vartype call_id: str + :ivar name: The name of the Azure Function that was called. Required. + :vartype name: str + :ivar output: The output from the Azure Function tool call. Is one of the following types: + {str: Any}, str, [Any] + :vartype output: dict[str, any] or str or list[any] + :ivar status: The status of the tool call. Required. Known values are: "in_progress", + "completed", "incomplete", and "failed". + :vartype status: str or ~azure.ai.agentserver.responses.models.models.ToolCallStatus + :ivar id: Required. + :vartype id: str + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + type: Required[Literal[OutputItemType.AZURE_FUNCTION_CALL_OUTPUT]] + """Required. AZURE_FUNCTION_CALL_OUTPUT.""" + call_id: Required[str] + """The unique ID of the tool call generated by the model. Required.""" + name: Required[str] + """The name of the Azure Function that was called. Required.""" + output: "_unions.ToolCallOutputContent" + """The output from the Azure Function tool call. Is one of the following types: {str: Any}, str, + [Any]""" + status: Required[ToolCallStatus] + """The status of the tool call. Required. Known values are: \"in_progress\", \"completed\", + \"incomplete\", and \"failed\".""" + id: Required[str] + """Required.""" + + +class BingCustomSearchConfiguration(TypedDict, total=False): + """A bing custom search configuration. + + :ivar name: Optional user-defined name for this tool or configuration. + :vartype name: str + :ivar description: Optional user-defined description for this tool or configuration. + :vartype description: str + :ivar project_connection_id: Project connection id for grounding with bing search. Required. + :vartype project_connection_id: str + :ivar instance_name: Name of the custom configuration instance given to config. Required. + :vartype instance_name: str + :ivar market: The market where the results come from. + :vartype market: str + :ivar set_lang: The language to use for user interface strings when calling Bing API. + :vartype set_lang: str + :ivar count: The number of search results to return in the bing api response. + :vartype count: int + :ivar freshness: Filter search results by a specific time range. See `accepted values here + `_. + :vartype freshness: str + """ + + name: str + """Optional user-defined name for this tool or configuration.""" + description: str + """Optional user-defined description for this tool or configuration.""" + project_connection_id: Required[str] + """Project connection id for grounding with bing search. Required.""" + instance_name: Required[str] + """Name of the custom configuration instance given to config. Required.""" + market: str + """The market where the results come from.""" + set_lang: str + """The language to use for user interface strings when calling Bing API.""" + count: int + """The number of search results to return in the bing api response.""" + freshness: str + """Filter search results by a specific time range. See `accepted values here + `_.""" + + +class BingCustomSearchPreviewTool(TypedDict, total=False): + """The input definition information for a Bing custom search tool as used to configure an agent. + + :ivar type: The object type, which is always 'bing_custom_search_preview'. Required. + BING_CUSTOM_SEARCH_PREVIEW. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.BING_CUSTOM_SEARCH_PREVIEW + :ivar name: Optional user-defined name for this tool or configuration. + :vartype name: str + :ivar description: Optional user-defined description for this tool or configuration. + :vartype description: str + :ivar bing_custom_search_preview: The bing custom search tool parameters. Required. + :vartype bing_custom_search_preview: + ~azure.ai.agentserver.responses.models.types.BingCustomSearchToolParameters + """ + + type: Required[Literal[ToolType.BING_CUSTOM_SEARCH_PREVIEW]] + """The object type, which is always 'bing_custom_search_preview'. Required. + BING_CUSTOM_SEARCH_PREVIEW.""" + name: str + """Optional user-defined name for this tool or configuration.""" + description: str + """Optional user-defined description for this tool or configuration.""" + bing_custom_search_preview: Required["BingCustomSearchToolParameters"] + """The bing custom search tool parameters. Required.""" + + +class BingCustomSearchToolCall(TypedDict, total=False): + """A Bing custom search tool call. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar type: Required. BING_CUSTOM_SEARCH_PREVIEW_CALL. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.BING_CUSTOM_SEARCH_PREVIEW_CALL + :ivar call_id: The unique ID of the tool call generated by the model. Required. + :vartype call_id: str + :ivar arguments: A JSON string of the arguments to pass to the tool. Required. + :vartype arguments: str + :ivar status: The status of the tool call. Required. Known values are: "in_progress", + "completed", "incomplete", and "failed". + :vartype status: str or ~azure.ai.agentserver.responses.models.models.ToolCallStatus + :ivar id: Required. + :vartype id: str + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + type: Required[Literal[OutputItemType.BING_CUSTOM_SEARCH_PREVIEW_CALL]] + """Required. BING_CUSTOM_SEARCH_PREVIEW_CALL.""" + call_id: Required[str] + """The unique ID of the tool call generated by the model. Required.""" + arguments: Required[str] + """A JSON string of the arguments to pass to the tool. Required.""" + status: Required[ToolCallStatus] + """The status of the tool call. Required. Known values are: \"in_progress\", \"completed\", + \"incomplete\", and \"failed\".""" + id: Required[str] + """Required.""" + + +class BingCustomSearchToolCallOutput(TypedDict, total=False): + """The output of a Bing custom search tool call. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar type: Required. BING_CUSTOM_SEARCH_PREVIEW_CALL_OUTPUT. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.BING_CUSTOM_SEARCH_PREVIEW_CALL_OUTPUT + :ivar call_id: The unique ID of the tool call generated by the model. Required. + :vartype call_id: str + :ivar output: The output from the Bing custom search tool call. Is one of the following types: + {str: Any}, str, [Any] + :vartype output: dict[str, any] or str or list[any] + :ivar status: The status of the tool call. Required. Known values are: "in_progress", + "completed", "incomplete", and "failed". + :vartype status: str or ~azure.ai.agentserver.responses.models.models.ToolCallStatus + :ivar id: Required. + :vartype id: str + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + type: Required[Literal[OutputItemType.BING_CUSTOM_SEARCH_PREVIEW_CALL_OUTPUT]] + """Required. BING_CUSTOM_SEARCH_PREVIEW_CALL_OUTPUT.""" + call_id: Required[str] + """The unique ID of the tool call generated by the model. Required.""" + output: "_unions.ToolCallOutputContent" + """The output from the Bing custom search tool call. Is one of the following types: {str: Any}, + str, [Any]""" + status: Required[ToolCallStatus] + """The status of the tool call. Required. Known values are: \"in_progress\", \"completed\", + \"incomplete\", and \"failed\".""" + id: Required[str] + """Required.""" + + +class BingCustomSearchToolParameters(TypedDict, total=False): + """The bing custom search tool parameters. + + :ivar name: Optional user-defined name for this tool or configuration. + :vartype name: str + :ivar description: Optional user-defined description for this tool or configuration. + :vartype description: str + :ivar search_configurations: The project connections attached to this tool. There can be a + maximum of 1 connection resource attached to the tool. Required. + :vartype search_configurations: + list[~azure.ai.agentserver.responses.models.types.BingCustomSearchConfiguration] + """ + + name: str + """Optional user-defined name for this tool or configuration.""" + description: str + """Optional user-defined description for this tool or configuration.""" + search_configurations: Required[list["BingCustomSearchConfiguration"]] + """The project connections attached to this tool. There can be a maximum of 1 connection resource + attached to the tool. Required.""" + + +class BingGroundingSearchConfiguration(TypedDict, total=False): + """Search configuration for Bing Grounding. + + :ivar name: Optional user-defined name for this tool or configuration. + :vartype name: str + :ivar description: Optional user-defined description for this tool or configuration. + :vartype description: str + :ivar project_connection_id: Project connection id for grounding with bing search. Required. + :vartype project_connection_id: str + :ivar market: The market where the results come from. + :vartype market: str + :ivar set_lang: The language to use for user interface strings when calling Bing API. + :vartype set_lang: str + :ivar count: The number of search results to return in the bing api response. + :vartype count: int + :ivar freshness: Filter search results by a specific time range. See `accepted values here + `_. + :vartype freshness: str + """ + + name: str + """Optional user-defined name for this tool or configuration.""" + description: str + """Optional user-defined description for this tool or configuration.""" + project_connection_id: Required[str] + """Project connection id for grounding with bing search. Required.""" + market: str + """The market where the results come from.""" + set_lang: str + """The language to use for user interface strings when calling Bing API.""" + count: int + """The number of search results to return in the bing api response.""" + freshness: str + """Filter search results by a specific time range. See `accepted values here + `_.""" + + +class BingGroundingSearchToolParameters(TypedDict, total=False): + """The bing grounding search tool parameters. + + :ivar name: Optional user-defined name for this tool or configuration. + :vartype name: str + :ivar description: Optional user-defined description for this tool or configuration. + :vartype description: str + :ivar search_configurations: The search configurations attached to this tool. There can be a + maximum of 1 search configuration resource attached to the tool. Required. + :vartype search_configurations: + list[~azure.ai.agentserver.responses.models.types.BingGroundingSearchConfiguration] + """ + + name: str + """Optional user-defined name for this tool or configuration.""" + description: str + """Optional user-defined description for this tool or configuration.""" + search_configurations: Required[list["BingGroundingSearchConfiguration"]] + """The search configurations attached to this tool. There can be a maximum of 1 search + configuration resource attached to the tool. Required.""" + + +class BingGroundingTool(TypedDict, total=False): + """The input definition information for a bing grounding search tool as used to configure an + agent. + + :ivar type: The object type, which is always 'bing_grounding'. Required. BING_GROUNDING. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.BING_GROUNDING + :ivar name: Optional user-defined name for this tool or configuration. + :vartype name: str + :ivar description: Optional user-defined description for this tool or configuration. + :vartype description: str + :ivar bing_grounding: The bing grounding search tool parameters. Required. + :vartype bing_grounding: + ~azure.ai.agentserver.responses.models.types.BingGroundingSearchToolParameters + """ + + type: Required[Literal[ToolType.BING_GROUNDING]] + """The object type, which is always 'bing_grounding'. Required. BING_GROUNDING.""" + name: str + """Optional user-defined name for this tool or configuration.""" + description: str + """Optional user-defined description for this tool or configuration.""" + bing_grounding: Required["BingGroundingSearchToolParameters"] + """The bing grounding search tool parameters. Required.""" + + +class BingGroundingToolCall(TypedDict, total=False): + """A Bing grounding tool call. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar type: Required. BING_GROUNDING_CALL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.BING_GROUNDING_CALL + :ivar call_id: The unique ID of the tool call generated by the model. Required. + :vartype call_id: str + :ivar arguments: A JSON string of the arguments to pass to the tool. Required. + :vartype arguments: str + :ivar status: The status of the tool call. Required. Known values are: "in_progress", + "completed", "incomplete", and "failed". + :vartype status: str or ~azure.ai.agentserver.responses.models.models.ToolCallStatus + :ivar id: Required. + :vartype id: str + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + type: Required[Literal[OutputItemType.BING_GROUNDING_CALL]] + """Required. BING_GROUNDING_CALL.""" + call_id: Required[str] + """The unique ID of the tool call generated by the model. Required.""" + arguments: Required[str] + """A JSON string of the arguments to pass to the tool. Required.""" + status: Required[ToolCallStatus] + """The status of the tool call. Required. Known values are: \"in_progress\", \"completed\", + \"incomplete\", and \"failed\".""" + id: Required[str] + """Required.""" + + +class BingGroundingToolCallOutput(TypedDict, total=False): + """The output of a Bing grounding tool call. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar type: Required. BING_GROUNDING_CALL_OUTPUT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.BING_GROUNDING_CALL_OUTPUT + :ivar call_id: The unique ID of the tool call generated by the model. Required. + :vartype call_id: str + :ivar output: The output from the Bing grounding tool call. Is one of the following types: + {str: Any}, str, [Any] + :vartype output: dict[str, any] or str or list[any] + :ivar status: The status of the tool call. Required. Known values are: "in_progress", + "completed", "incomplete", and "failed". + :vartype status: str or ~azure.ai.agentserver.responses.models.models.ToolCallStatus + :ivar id: Required. + :vartype id: str + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + type: Required[Literal[OutputItemType.BING_GROUNDING_CALL_OUTPUT]] + """Required. BING_GROUNDING_CALL_OUTPUT.""" + call_id: Required[str] + """The unique ID of the tool call generated by the model. Required.""" + output: "_unions.ToolCallOutputContent" + """The output from the Bing grounding tool call. Is one of the following types: {str: Any}, str, + [Any]""" + status: Required[ToolCallStatus] + """The status of the tool call. Required. Known values are: \"in_progress\", \"completed\", + \"incomplete\", and \"failed\".""" + id: Required[str] + """Required.""" + + +class BrowserAutomationPreviewTool(TypedDict, total=False): + """The input definition information for a Browser Automation Tool, as used to configure an Agent. + + :ivar type: The object type, which is always 'browser_automation_preview'. Required. + BROWSER_AUTOMATION_PREVIEW. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.BROWSER_AUTOMATION_PREVIEW + :ivar name: Optional user-defined name for this tool or configuration. + :vartype name: str + :ivar description: Optional user-defined description for this tool or configuration. + :vartype description: str + :ivar browser_automation_preview: The Browser Automation Tool parameters. Required. + :vartype browser_automation_preview: + ~azure.ai.agentserver.responses.models.types.BrowserAutomationToolParameters + """ + + type: Required[Literal[ToolType.BROWSER_AUTOMATION_PREVIEW]] + """The object type, which is always 'browser_automation_preview'. Required. + BROWSER_AUTOMATION_PREVIEW.""" + name: str + """Optional user-defined name for this tool or configuration.""" + description: str + """Optional user-defined description for this tool or configuration.""" + browser_automation_preview: Required["BrowserAutomationToolParameters"] + """The Browser Automation Tool parameters. Required.""" + + +class BrowserAutomationToolCall(TypedDict, total=False): + """A browser automation tool call. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar type: Required. BROWSER_AUTOMATION_PREVIEW_CALL. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.BROWSER_AUTOMATION_PREVIEW_CALL + :ivar call_id: The unique ID of the tool call generated by the model. Required. + :vartype call_id: str + :ivar arguments: A JSON string of the arguments to pass to the tool. Required. + :vartype arguments: str + :ivar status: The status of the tool call. Required. Known values are: "in_progress", + "completed", "incomplete", and "failed". + :vartype status: str or ~azure.ai.agentserver.responses.models.models.ToolCallStatus + :ivar id: Required. + :vartype id: str + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + type: Required[Literal[OutputItemType.BROWSER_AUTOMATION_PREVIEW_CALL]] + """Required. BROWSER_AUTOMATION_PREVIEW_CALL.""" + call_id: Required[str] + """The unique ID of the tool call generated by the model. Required.""" + arguments: Required[str] + """A JSON string of the arguments to pass to the tool. Required.""" + status: Required[ToolCallStatus] + """The status of the tool call. Required. Known values are: \"in_progress\", \"completed\", + \"incomplete\", and \"failed\".""" + id: Required[str] + """Required.""" + + +class BrowserAutomationToolCallOutput(TypedDict, total=False): + """The output of a browser automation tool call. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar type: Required. BROWSER_AUTOMATION_PREVIEW_CALL_OUTPUT. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.BROWSER_AUTOMATION_PREVIEW_CALL_OUTPUT + :ivar call_id: The unique ID of the tool call generated by the model. Required. + :vartype call_id: str + :ivar output: The output from the browser automation tool call. Is one of the following types: + {str: Any}, str, [Any] + :vartype output: dict[str, any] or str or list[any] + :ivar status: The status of the tool call. Required. Known values are: "in_progress", + "completed", "incomplete", and "failed". + :vartype status: str or ~azure.ai.agentserver.responses.models.models.ToolCallStatus + :ivar id: Required. + :vartype id: str + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + type: Required[Literal[OutputItemType.BROWSER_AUTOMATION_PREVIEW_CALL_OUTPUT]] + """Required. BROWSER_AUTOMATION_PREVIEW_CALL_OUTPUT.""" + call_id: Required[str] + """The unique ID of the tool call generated by the model. Required.""" + output: "_unions.ToolCallOutputContent" + """The output from the browser automation tool call. Is one of the following types: {str: Any}, + str, [Any]""" + status: Required[ToolCallStatus] + """The status of the tool call. Required. Known values are: \"in_progress\", \"completed\", + \"incomplete\", and \"failed\".""" + id: Required[str] + """Required.""" + + +class BrowserAutomationToolConnectionParameters(TypedDict, total=False): # pylint: disable=name-too-long + """Definition of input parameters for the connection used by the Browser Automation Tool. + + :ivar name: Optional user-defined name for this tool or configuration. + :vartype name: str + :ivar description: Optional user-defined description for this tool or configuration. + :vartype description: str + :ivar project_connection_id: The ID of the project connection to your Azure Playwright + resource. Required. + :vartype project_connection_id: str + """ + + name: str + """Optional user-defined name for this tool or configuration.""" + description: str + """Optional user-defined description for this tool or configuration.""" + project_connection_id: Required[str] + """The ID of the project connection to your Azure Playwright resource. Required.""" + + +class BrowserAutomationToolParameters(TypedDict, total=False): + """Definition of input parameters for the Browser Automation Tool. + + :ivar name: Optional user-defined name for this tool or configuration. + :vartype name: str + :ivar description: Optional user-defined description for this tool or configuration. + :vartype description: str + :ivar connection: The project connection parameters associated with the Browser Automation + Tool. Required. + :vartype connection: + ~azure.ai.agentserver.responses.models.types.BrowserAutomationToolConnectionParameters + """ + + name: str + """Optional user-defined name for this tool or configuration.""" + description: str + """Optional user-defined description for this tool or configuration.""" + connection: Required["BrowserAutomationToolConnectionParameters"] + """The project connection parameters associated with the Browser Automation Tool. Required.""" + + +class CaptureStructuredOutputsTool(TypedDict, total=False): + """A tool for capturing structured outputs. + + :ivar type: The type of the tool. Always ``capture_structured_outputs``. Required. + CAPTURE_STRUCTURED_OUTPUTS. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.CAPTURE_STRUCTURED_OUTPUTS + :ivar outputs: The structured outputs to capture from the model. Required. + :vartype outputs: ~azure.ai.agentserver.responses.models.types.StructuredOutputDefinition + """ + + type: Required[Literal[ToolType.CAPTURE_STRUCTURED_OUTPUTS]] + """The type of the tool. Always ``capture_structured_outputs``. Required. + CAPTURE_STRUCTURED_OUTPUTS.""" + outputs: Required["StructuredOutputDefinition"] + """The structured outputs to capture from the model. Required.""" + + +class ChatSummaryMemoryItem(TypedDict, total=False): + """A memory item containing a summary extracted from conversations. + + :ivar memory_id: The unique ID of the memory item. Required. + :vartype memory_id: str + :ivar updated_at: The last update time of the memory item. Required. + :vartype updated_at: ~datetime.datetime + :ivar scope: The namespace that logically groups and isolates memories, such as a user ID. + Required. + :vartype scope: str + :ivar content: The content of the memory. Required. + :vartype content: str + :ivar kind: The kind of the memory item. Required. Summary of chat conversations. + :vartype kind: str or ~azure.ai.agentserver.responses.models.models.CHAT_SUMMARY + """ + + memory_id: Required[str] + """The unique ID of the memory item. Required.""" + updated_at: Required[int] + """The last update time of the memory item. Required.""" + scope: Required[str] + """The namespace that logically groups and isolates memories, such as a user ID. Required.""" + content: Required[str] + """The content of the memory. Required.""" + kind: Required[Literal[MemoryItemKind.CHAT_SUMMARY]] + """The kind of the memory item. Required. Summary of chat conversations.""" + + +class ClickParam(TypedDict, total=False): + """Click. + + :ivar type: Specifies the event type. For a click action, this property is always ``click``. + Required. CLICK. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.CLICK + :ivar button: Indicates which mouse button was pressed during the click. One of ``left``, + ``right``, ``wheel``, ``back``, or ``forward``. Required. Known values are: "left", "right", + "wheel", "back", and "forward". + :vartype button: str or ~azure.ai.agentserver.responses.models.models.ClickButtonType + :ivar x: The x-coordinate where the click occurred. Required. + :vartype x: int + :ivar y: The y-coordinate where the click occurred. Required. + :vartype y: int + """ + + type: Required[Literal[ComputerActionType.CLICK]] + """Specifies the event type. For a click action, this property is always ``click``. Required. + CLICK.""" + button: Required[ClickButtonType] + """Indicates which mouse button was pressed during the click. One of ``left``, ``right``, + ``wheel``, ``back``, or ``forward``. Required. Known values are: \"left\", \"right\", + \"wheel\", \"back\", and \"forward\".""" + x: Required[int] + """The x-coordinate where the click occurred. Required.""" + y: Required[int] + """The y-coordinate where the click occurred. Required.""" + + +class CodeInterpreterOutputImage(TypedDict, total=False): + """Code interpreter output image. + + :ivar type: The type of the output. Always ``image``. Required. Default value is "image". + :vartype type: str + :ivar url: The URL of the image output from the code interpreter. Required. + :vartype url: str + """ + + type: Required[Literal["image"]] + """The type of the output. Always ``image``. Required. Default value is \"image\".""" + url: Required[str] + """The URL of the image output from the code interpreter. Required.""" + + +class CodeInterpreterOutputLogs(TypedDict, total=False): + """Code interpreter output logs. + + :ivar type: The type of the output. Always ``logs``. Required. Default value is "logs". + :vartype type: str + :ivar logs: The logs output from the code interpreter. Required. + :vartype logs: str + """ + + type: Required[Literal["logs"]] + """The type of the output. Always ``logs``. Required. Default value is \"logs\".""" + logs: Required[str] + """The logs output from the code interpreter. Required.""" + + +class CodeInterpreterTool(TypedDict, total=False): + """Code interpreter. + + :ivar type: The type of the code interpreter tool. Always ``code_interpreter``. Required. + CODE_INTERPRETER. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.CODE_INTERPRETER + :ivar name: Optional user-defined name for this tool or configuration. + :vartype name: str + :ivar description: Optional user-defined description for this tool or configuration. + :vartype description: str + :ivar container: The code interpreter container. Can be a container ID or an object that + specifies uploaded file IDs to make available to your code, along with an optional + ``memory_limit`` setting. If not provided, the service assumes auto. Is either a str type or a + AutoCodeInterpreterToolParam type. + :vartype container: str or + ~azure.ai.agentserver.responses.models.types.AutoCodeInterpreterToolParam + """ + + type: Required[Literal[ToolType.CODE_INTERPRETER]] + """The type of the code interpreter tool. Always ``code_interpreter``. Required. CODE_INTERPRETER.""" + name: str + """Optional user-defined name for this tool or configuration.""" + description: str + """Optional user-defined description for this tool or configuration.""" + container: Union[str, "AutoCodeInterpreterToolParam"] + """The code interpreter container. Can be a container ID or an object that specifies uploaded file + IDs to make available to your code, along with an optional ``memory_limit`` setting. If not + provided, the service assumes auto. Is either a str type or a AutoCodeInterpreterToolParam + type.""" + + +class CompactionSummaryItemParam(TypedDict, total=False): + """Compaction item. + + :ivar id: + :vartype id: str + :ivar type: The type of the item. Always ``compaction``. Required. COMPACTION. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.COMPACTION + :ivar encrypted_content: The encrypted content of the compaction summary. Required. + :vartype encrypted_content: str + """ + + id: Optional[str] + type: Required[Literal[ItemType.COMPACTION]] + """The type of the item. Always ``compaction``. Required. COMPACTION.""" + encrypted_content: Required[str] + """The encrypted content of the compaction summary. Required.""" + + +class CompactResource(TypedDict, total=False): + """The compacted response object. + + :ivar id: The unique identifier for the compacted response. Required. + :vartype id: str + :ivar object: The object type. Always ``response.compaction``. Required. Default value is + "response.compaction". + :vartype object: str + :ivar output: The compacted list of output items. Required. + :vartype output: list[~azure.ai.agentserver.responses.models.types.ItemField] + :ivar created_at: Unix timestamp (in seconds) when the compacted conversation was created. + Required. + :vartype created_at: ~datetime.datetime + :ivar usage: Token accounting for the compaction pass, including cached, reasoning, and total + tokens. Required. + :vartype usage: ~azure.ai.agentserver.responses.models.types.ResponseUsage + """ + + id: Required[str] + """The unique identifier for the compacted response. Required.""" + object: Required[Literal["response.compaction"]] + """The object type. Always ``response.compaction``. Required. Default value is + \"response.compaction\".""" + output: Required[list["ItemField"]] + """The compacted list of output items. Required.""" + created_at: Required[int] + """Unix timestamp (in seconds) when the compacted conversation was created. Required.""" + usage: Required["ResponseUsage"] + """Token accounting for the compaction pass, including cached, reasoning, and total tokens. + Required.""" + + +class ComparisonFilter(TypedDict, total=False): + """Comparison Filter. + + :ivar type: Specifies the comparison operator: ``eq``, ``ne``, ``gt``, ``gte``, ``lt``, + ``lte``, ``in``, ``nin``. + + * `eq`: equals + * `ne`: not equal + * `gt`: greater than + * `gte`: greater than or equal + * `lt`: less than + * `lte`: less than or equal + * `in`: in + * `nin`: not in. Required. Is one of the following types: Literal["eq"], Literal["ne"], + Literal["gt"], Literal["gte"], Literal["lt"], Literal["lte"] + :vartype type: str or str or str or str or str or str + :ivar key: The key to compare against the value. Required. + :vartype key: str + :ivar value: The value to compare against the attribute key; supports string, number, or + boolean types. Required. Is one of the following types: str, float, bool, [Union[str, float]] + :vartype value: str or float or bool or list[str or float] + """ + + type: Required[Literal["eq", "ne", "gt", "gte", "lt", "lte"]] + """Specifies the comparison operator: ``eq``, ``ne``, ``gt``, ``gte``, ``lt``, ``lte``, ``in``, + ``nin``. + + * `eq`: equals + * `ne`: not equal + * `gt`: greater than + * `gte`: greater than or equal + * `lt`: less than + * `lte`: less than or equal + * `in`: in + * `nin`: not in. Required. Is one of the following types: Literal[\"eq\"], + Literal[\"ne\"], Literal[\"gt\"], Literal[\"gte\"], Literal[\"lt\"], Literal[\"lte\"]""" + key: Required[str] + """The key to compare against the value. Required.""" + value: Required[Union[str, float, bool, list[Union[str, float]]]] + """The value to compare against the attribute key; supports string, number, or boolean types. + Required. Is one of the following types: str, float, bool, [Union[str, float]]""" + + +class CompoundFilter(TypedDict, total=False): + """Compound Filter. + + :ivar type: Type of operation: ``and`` or ``or``. Required. Is either a Literal["and"] type or + a Literal["or"] type. + :vartype type: str or str + :ivar filters: Array of filters to combine. Items can be ``ComparisonFilter`` or + ``CompoundFilter``. Required. + :vartype filters: list[~azure.ai.agentserver.responses.models.types.ComparisonFilter or any] + """ + + type: Required[Literal["and", "or"]] + """Type of operation: ``and`` or ``or``. Required. Is either a Literal[\"and\"] type or a + Literal[\"or\"] type.""" + filters: Required[list[Union["ComparisonFilter", Any]]] + """Array of filters to combine. Items can be ``ComparisonFilter`` or ``CompoundFilter``. Required.""" + + +class ComputerCallOutputItemParam(TypedDict, total=False): + """Computer tool call output. + + :ivar id: + :vartype id: str + :ivar call_id: The ID of the computer tool call that produced the output. Required. + :vartype call_id: str + :ivar type: The type of the computer tool call output. Always ``computer_call_output``. + Required. COMPUTER_CALL_OUTPUT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.COMPUTER_CALL_OUTPUT + :ivar output: Required. + :vartype output: ~azure.ai.agentserver.responses.models.types.ComputerScreenshotImage + :ivar acknowledged_safety_checks: + :vartype acknowledged_safety_checks: + list[~azure.ai.agentserver.responses.models.types.ComputerCallSafetyCheckParam] + :ivar status: Known values are: "in_progress", "completed", and "incomplete". + :vartype status: str or ~azure.ai.agentserver.responses.models.models.FunctionCallItemStatus + """ + + id: Optional[str] + call_id: Required[str] + """The ID of the computer tool call that produced the output. Required.""" + type: Required[Literal[ItemType.COMPUTER_CALL_OUTPUT]] + """The type of the computer tool call output. Always ``computer_call_output``. Required. + COMPUTER_CALL_OUTPUT.""" + output: Required["ComputerScreenshotImage"] + """Required.""" + acknowledged_safety_checks: Optional[list["ComputerCallSafetyCheckParam"]] + status: Optional[FunctionCallItemStatus] + """Known values are: \"in_progress\", \"completed\", and \"incomplete\".""" + + +class ComputerCallSafetyCheckParam(TypedDict, total=False): + """A pending safety check for the computer call. + + :ivar id: The ID of the pending safety check. Required. + :vartype id: str + :ivar code: + :vartype code: str + :ivar message: + :vartype message: str + """ + + id: Required[str] + """The ID of the pending safety check. Required.""" + code: Optional[str] + message: Optional[str] + + +class ComputerScreenshotContent(TypedDict, total=False): + """Computer screenshot. + + :ivar type: Specifies the event type. For a computer screenshot, this property is always set to + ``computer_screenshot``. Required. COMPUTER_SCREENSHOT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.COMPUTER_SCREENSHOT + :ivar image_url: Required. + :vartype image_url: str + :ivar file_id: Required. + :vartype file_id: str + """ + + type: Required[Literal[MessageContentType.COMPUTER_SCREENSHOT]] + """Specifies the event type. For a computer screenshot, this property is always set to + ``computer_screenshot``. Required. COMPUTER_SCREENSHOT.""" + image_url: Required[Optional[str]] + """Required.""" + file_id: Required[Optional[str]] + """Required.""" + + +class ComputerScreenshotImage(TypedDict, total=False): + """A computer screenshot image used with the computer use tool. + + :ivar type: Specifies the event type. For a computer screenshot, this property is always set to + ``computer_screenshot``. Required. Default value is "computer_screenshot". + :vartype type: str + :ivar image_url: The URL of the screenshot image. + :vartype image_url: str + :ivar file_id: The identifier of an uploaded file that contains the screenshot. + :vartype file_id: str + """ + + type: Required[Literal["computer_screenshot"]] + """Specifies the event type. For a computer screenshot, this property is always set to + ``computer_screenshot``. Required. Default value is \"computer_screenshot\".""" + image_url: str + """The URL of the screenshot image.""" + file_id: str + """The identifier of an uploaded file that contains the screenshot.""" + + +class ComputerUsePreviewTool(TypedDict, total=False): + """Computer use preview. + + :ivar type: The type of the computer use tool. Always ``computer_use_preview``. Required. + COMPUTER_USE_PREVIEW. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.COMPUTER_USE_PREVIEW + :ivar environment: The type of computer environment to control. Required. Known values are: + "windows", "mac", "linux", "ubuntu", and "browser". + :vartype environment: str or ~azure.ai.agentserver.responses.models.models.ComputerEnvironment + :ivar display_width: The width of the computer display. Required. + :vartype display_width: int + :ivar display_height: The height of the computer display. Required. + :vartype display_height: int + """ + + type: Required[Literal[ToolType.COMPUTER_USE_PREVIEW]] + """The type of the computer use tool. Always ``computer_use_preview``. Required. + COMPUTER_USE_PREVIEW.""" + environment: Required[ComputerEnvironment] + """The type of computer environment to control. Required. Known values are: \"windows\", \"mac\", + \"linux\", \"ubuntu\", and \"browser\".""" + display_width: Required[int] + """The width of the computer display. Required.""" + display_height: Required[int] + """The height of the computer display. Required.""" + + +class ContainerAutoParam(TypedDict, total=False): + """ContainerAutoParam. + + :ivar type: Automatically creates a container for this request. Required. CONTAINER_AUTO. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.CONTAINER_AUTO + :ivar file_ids: An optional list of uploaded files to make available to your code. + :vartype file_ids: list[str] + :ivar memory_limit: Known values are: "1g", "4g", "16g", and "64g". + :vartype memory_limit: str or + ~azure.ai.agentserver.responses.models.models.ContainerMemoryLimit + :ivar skills: An optional list of skills referenced by id or inline data. + :vartype skills: list[~azure.ai.agentserver.responses.models.types.ContainerSkill] + :ivar network_policy: + :vartype network_policy: + ~azure.ai.agentserver.responses.models.types.ContainerNetworkPolicyParam + """ + + type: Required[Literal[FunctionShellToolParamEnvironmentType.CONTAINER_AUTO]] + """Automatically creates a container for this request. Required. CONTAINER_AUTO.""" + file_ids: list[str] + """An optional list of uploaded files to make available to your code.""" + memory_limit: Optional[ContainerMemoryLimit] + """Known values are: \"1g\", \"4g\", \"16g\", and \"64g\".""" + skills: list["ContainerSkill"] + """An optional list of skills referenced by id or inline data.""" + network_policy: "ContainerNetworkPolicyParam" + + +class ContainerFileCitationBody(TypedDict, total=False): + """Container file citation. + + :ivar type: The type of the container file citation. Always ``container_file_citation``. + Required. CONTAINER_FILE_CITATION. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.CONTAINER_FILE_CITATION + :ivar container_id: The ID of the container file. Required. + :vartype container_id: str + :ivar file_id: The ID of the file. Required. + :vartype file_id: str + :ivar start_index: The index of the first character of the container file citation in the + message. Required. + :vartype start_index: int + :ivar end_index: The index of the last character of the container file citation in the message. + Required. + :vartype end_index: int + :ivar filename: The filename of the container file cited. Required. + :vartype filename: str + """ + + type: Required[Literal[AnnotationType.CONTAINER_FILE_CITATION]] + """The type of the container file citation. Always ``container_file_citation``. Required. + CONTAINER_FILE_CITATION.""" + container_id: Required[str] + """The ID of the container file. Required.""" + file_id: Required[str] + """The ID of the file. Required.""" + start_index: Required[int] + """The index of the first character of the container file citation in the message. Required.""" + end_index: Required[int] + """The index of the last character of the container file citation in the message. Required.""" + filename: Required[str] + """The filename of the container file cited. Required.""" + + +class ContainerNetworkPolicyAllowlistParam(TypedDict, total=False): + """ContainerNetworkPolicyAllowlistParam. + + :ivar type: Allow outbound network access only to specified domains. Always ``allowlist``. + Required. ALLOWLIST. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.ALLOWLIST + :ivar allowed_domains: A list of allowed domains when type is ``allowlist``. Required. + :vartype allowed_domains: list[str] + :ivar domain_secrets: Optional domain-scoped secrets for allowlisted domains. + :vartype domain_secrets: + list[~azure.ai.agentserver.responses.models.types.ContainerNetworkPolicyDomainSecretParam] + """ + + type: Required[Literal[ContainerNetworkPolicyParamType.ALLOWLIST]] + """Allow outbound network access only to specified domains. Always ``allowlist``. Required. + ALLOWLIST.""" + allowed_domains: Required[list[str]] + """A list of allowed domains when type is ``allowlist``. Required.""" + domain_secrets: list["ContainerNetworkPolicyDomainSecretParam"] + """Optional domain-scoped secrets for allowlisted domains.""" + + +class ContainerNetworkPolicyDisabledParam(TypedDict, total=False): + """ContainerNetworkPolicyDisabledParam. + + :ivar type: Disable outbound network access. Always ``disabled``. Required. DISABLED. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.DISABLED + """ + + type: Required[Literal[ContainerNetworkPolicyParamType.DISABLED]] + """Disable outbound network access. Always ``disabled``. Required. DISABLED.""" + + +class ContainerNetworkPolicyDomainSecretParam(TypedDict, total=False): + """ContainerNetworkPolicyDomainSecretParam. + + :ivar domain: The domain associated with the secret. Required. + :vartype domain: str + :ivar name: The name of the secret to inject for the domain. Required. + :vartype name: str + :ivar value: The secret value to inject for the domain. Required. + :vartype value: str + """ + + domain: Required[str] + """The domain associated with the secret. Required.""" + name: Required[str] + """The name of the secret to inject for the domain. Required.""" + value: Required[str] + """The secret value to inject for the domain. Required.""" + + +class ContainerReferenceResource(TypedDict, total=False): + """Container Reference. + + :ivar type: The environment type. Always ``container_reference``. Required. + CONTAINER_REFERENCE. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.CONTAINER_REFERENCE + :ivar container_id: Required. + :vartype container_id: str + """ + + type: Required[Literal[FunctionShellCallEnvironmentType.CONTAINER_REFERENCE]] + """The environment type. Always ``container_reference``. Required. CONTAINER_REFERENCE.""" + container_id: Required[str] + """Required.""" + + +class ContextManagementParam(TypedDict, total=False): + """ContextManagementParam. + + :ivar type: The context management entry type. Currently only 'compaction' is supported. + Required. + :vartype type: str + :ivar compact_threshold: + :vartype compact_threshold: int + """ + + type: Required[str] + """The context management entry type. Currently only 'compaction' is supported. Required.""" + compact_threshold: Optional[int] + + +class ConversationParam_2(TypedDict, total=False): + """Conversation object. + + :ivar id: The unique ID of the conversation. Required. + :vartype id: str + """ + + id: Required[str] + """The unique ID of the conversation. Required.""" + + +class ConversationReference(TypedDict, total=False): + """Conversation. + + :ivar id: The unique ID of the conversation that this response was associated with. Required. + :vartype id: str + """ + + id: Required[str] + """The unique ID of the conversation that this response was associated with. Required.""" + + +class CoordParam(TypedDict, total=False): + """Coordinate. + + :ivar x: The x-coordinate. Required. + :vartype x: int + :ivar y: The y-coordinate. Required. + :vartype y: int + """ + + x: Required[int] + """The x-coordinate. Required.""" + y: Required[int] + """The y-coordinate. Required.""" + + +class CreatedBy(TypedDict, total=False): + """CreatedBy. + + :ivar agent: The agent that created the item. + :vartype agent: ~azure.ai.agentserver.responses.models.types.AgentId + :ivar response_id: The response on which the item is created. + :vartype response_id: str + """ + + agent: "AgentId" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + + +class CreateResponse(TypedDict, total=False): + """CreateResponse. + + :ivar metadata: + :vartype metadata: ~azure.ai.agentserver.responses.models.types.Metadata + :ivar top_logprobs: + :vartype top_logprobs: int + :ivar temperature: + :vartype temperature: float + :ivar top_p: + :vartype top_p: float + :ivar user: This field is being replaced by ``safety_identifier`` and ``prompt_cache_key``. Use + ``prompt_cache_key`` instead to maintain caching optimizations. A stable identifier for your + end-users. Used to boost cache hit rates by better bucketing similar requests and to help + OpenAI detect and prevent abuse. `Learn more + `_. + :vartype user: str + :ivar safety_identifier: A stable identifier used to help detect users of your application that + may be violating OpenAI's usage policies. The IDs should be a string that uniquely identifies + each user. We recommend hashing their username or email address, in order to avoid sending us + any identifying information. `Learn more + `_. + :vartype safety_identifier: str + :ivar prompt_cache_key: Used by OpenAI to cache responses for similar requests to optimize your + cache hit rates. Replaces the ``user`` field. `Learn more `_. + :vartype prompt_cache_key: str + :ivar service_tier: Is one of the following types: Literal["auto"], Literal["default"], + Literal["flex"], Literal["scale"], Literal["priority"] + :vartype service_tier: str or str or str or str or str + :ivar prompt_cache_retention: Is either a Literal["in-memory"] type or a Literal["24h"] type. + :vartype prompt_cache_retention: str or str + :ivar previous_response_id: + :vartype previous_response_id: str + :ivar model: The model deployment to use for the creation of this response. + :vartype model: str + :ivar reasoning: + :vartype reasoning: ~azure.ai.agentserver.responses.models.types.Reasoning + :ivar background: + :vartype background: bool + :ivar max_output_tokens: + :vartype max_output_tokens: int + :ivar max_tool_calls: + :vartype max_tool_calls: int + :ivar text: + :vartype text: ~azure.ai.agentserver.responses.models.types.ResponseTextParam + :ivar tools: + :vartype tools: list[~azure.ai.agentserver.responses.models.types.Tool] + :ivar tool_choice: Is either a types.ToolChoiceOptions type or a ToolChoiceParam type. + :vartype tool_choice: str or ~azure.ai.agentserver.responses.models.models.ToolChoiceOptions or + ~azure.ai.agentserver.responses.models.types.ToolChoiceParam + :ivar prompt: + :vartype prompt: ~azure.ai.agentserver.responses.models.types.Prompt + :ivar truncation: Is either a Literal["auto"] type or a Literal["disabled"] type. + :vartype truncation: str or str + :ivar input: Is either a str type or a [Item] type. + :vartype input: str or list[~azure.ai.agentserver.responses.models.types.Item] + :ivar include: + :vartype include: list[str or ~azure.ai.agentserver.responses.models.models.IncludeEnum] + :ivar parallel_tool_calls: + :vartype parallel_tool_calls: bool + :ivar store: + :vartype store: bool + :ivar instructions: + :vartype instructions: str + :ivar stream: + :vartype stream: bool + :ivar stream_options: + :vartype stream_options: ~azure.ai.agentserver.responses.models.types.ResponseStreamOptions + :ivar conversation: Is either a str type or a ConversationParam_2 type. + :vartype conversation: str or ~azure.ai.agentserver.responses.models.types.ConversationParam_2 + :ivar context_management: Context management configuration for this request. + :vartype context_management: + list[~azure.ai.agentserver.responses.models.types.ContextManagementParam] + :ivar agent: (Deprecated) Use agent_reference instead. The agent to use for generating the + response. + :vartype agent: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar agent_session_id: Optional session identifier for sandbox affinity. Currently only + relevant for hosted agents. When provided, the request is routed to the same sandbox. When + omitted, auto-derived from conversation_id/prev_response_id or a new UUID is generated. + :vartype agent_session_id: str + :ivar agent_reference: The agent to use for generating the response. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar structured_inputs: The structured inputs to the response that can participate in prompt + template substitution or tool argument bindings. + :vartype structured_inputs: dict[str, any] + """ + + metadata: Optional["Metadata"] + top_logprobs: Optional[int] + temperature: Optional[float] + top_p: Optional[float] + user: str + """This field is being replaced by ``safety_identifier`` and ``prompt_cache_key``. Use + ``prompt_cache_key`` instead to maintain caching optimizations. A stable identifier for your + end-users. Used to boost cache hit rates by better bucketing similar requests and to help + OpenAI detect and prevent abuse. `Learn more + `_.""" + safety_identifier: str + """A stable identifier used to help detect users of your application that may be violating + OpenAI's usage policies. The IDs should be a string that uniquely identifies each user. We + recommend hashing their username or email address, in order to avoid sending us any identifying + information. `Learn more `_.""" + prompt_cache_key: str + """Used by OpenAI to cache responses for similar requests to optimize your cache hit rates. + Replaces the ``user`` field. `Learn more `_.""" + service_tier: Optional[Literal["auto", "default", "flex", "scale", "priority"]] + """Is one of the following types: Literal[\"auto\"], Literal[\"default\"], Literal[\"flex\"], + Literal[\"scale\"], Literal[\"priority\"]""" + prompt_cache_retention: Optional[Literal["in-memory", "24h"]] + """Is either a Literal[\"in-memory\"] type or a Literal[\"24h\"] type.""" + previous_response_id: Optional[str] + model: str + """The model deployment to use for the creation of this response.""" + reasoning: Optional["Reasoning"] + background: Optional[bool] + max_output_tokens: Optional[int] + max_tool_calls: Optional[int] + text: "ResponseTextParam" + tools: list["Tool"] + tool_choice: Union[ToolChoiceOptions, "ToolChoiceParam"] + """Is either a types.ToolChoiceOptions type or a ToolChoiceParam type.""" + prompt: "Prompt" + truncation: Optional[Literal["auto", "disabled"]] + """Is either a Literal[\"auto\"] type or a Literal[\"disabled\"] type.""" + input: "_unions.InputParam" + """Is either a str type or a [Item] type.""" + include: Optional[list[IncludeEnum]] + parallel_tool_calls: Optional[bool] + store: Optional[bool] + instructions: Optional[str] + stream: Optional[bool] + stream_options: Optional["ResponseStreamOptions"] + conversation: Optional["_unions.ConversationParam"] + """Is either a str type or a ConversationParam_2 type.""" + context_management: Optional[list["ContextManagementParam"]] + """Context management configuration for this request.""" + agent: "AgentReference" + """(Deprecated) Use agent_reference instead. The agent to use for generating the response.""" + agent_session_id: str + """Optional session identifier for sandbox affinity. Currently only relevant for hosted agents. + When provided, the request is routed to the same sandbox. When omitted, auto-derived from + conversation_id/prev_response_id or a new UUID is generated.""" + agent_reference: "AgentReference" + """The agent to use for generating the response.""" + structured_inputs: dict[str, Any] + """The structured inputs to the response that can participate in prompt template substitution or + tool argument bindings.""" + + +class CustomGrammarFormatParam(TypedDict, total=False): + """Grammar format. + + :ivar type: Grammar format. Always ``grammar``. Required. GRAMMAR. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.GRAMMAR + :ivar syntax: The syntax of the grammar definition. One of ``lark`` or ``regex``. Required. + Known values are: "lark" and "regex". + :vartype syntax: str or ~azure.ai.agentserver.responses.models.models.GrammarSyntax1 + :ivar definition: The grammar definition. Required. + :vartype definition: str + """ + + type: Required[Literal[CustomToolParamFormatType.GRAMMAR]] + """Grammar format. Always ``grammar``. Required. GRAMMAR.""" + syntax: Required[GrammarSyntax1] + """The syntax of the grammar definition. One of ``lark`` or ``regex``. Required. Known values are: + \"lark\" and \"regex\".""" + definition: Required[str] + """The grammar definition. Required.""" + + +class CustomTextFormatParam(TypedDict, total=False): + """Text format. + + :ivar type: Unconstrained text format. Always ``text``. Required. TEXT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.TEXT + """ + + type: Required[Literal[CustomToolParamFormatType.TEXT]] + """Unconstrained text format. Always ``text``. Required. TEXT.""" + + +class CustomToolParam(TypedDict, total=False): + """Custom tool. + + :ivar type: The type of the custom tool. Always ``custom``. Required. CUSTOM. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.CUSTOM + :ivar name: The name of the custom tool, used to identify it in tool calls. Required. + :vartype name: str + :ivar description: Optional description of the custom tool, used to provide more context. + :vartype description: str + :ivar format: The input format for the custom tool. Default is unconstrained text. + :vartype format: ~azure.ai.agentserver.responses.models.types.CustomToolParamFormat + """ + + type: Required[Literal[ToolType.CUSTOM]] + """The type of the custom tool. Always ``custom``. Required. CUSTOM.""" + name: Required[str] + """The name of the custom tool, used to identify it in tool calls. Required.""" + description: str + """Optional description of the custom tool, used to provide more context.""" + format: "CustomToolParamFormat" + """The input format for the custom tool. Default is unconstrained text.""" + + +class DeleteResponseResult(TypedDict, total=False): + """The result of a delete response operation. + + :ivar id: The operation ID. Required. + :vartype id: str + :ivar deleted: Always return true. Required. Default value is True. + :vartype deleted: bool + :ivar object: Required. Default value is "response". + :vartype object: str + """ + + id: Required[str] + """The operation ID. Required.""" + deleted: Required[Literal[True]] + """Always return true. Required. Default value is True.""" + object: Required[Literal["response"]] + """Required. Default value is \"response\".""" + + +class DoubleClickAction(TypedDict, total=False): + """DoubleClick. + + :ivar type: Specifies the event type. For a double click action, this property is always set to + ``double_click``. Required. DOUBLE_CLICK. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.DOUBLE_CLICK + :ivar x: The x-coordinate where the double click occurred. Required. + :vartype x: int + :ivar y: The y-coordinate where the double click occurred. Required. + :vartype y: int + """ + + type: Required[Literal[ComputerActionType.DOUBLE_CLICK]] + """Specifies the event type. For a double click action, this property is always set to + ``double_click``. Required. DOUBLE_CLICK.""" + x: Required[int] + """The x-coordinate where the double click occurred. Required.""" + y: Required[int] + """The y-coordinate where the double click occurred. Required.""" + + +class DragParam(TypedDict, total=False): + """Drag. + + :ivar type: Specifies the event type. For a drag action, this property is always set to + ``drag``. Required. DRAG. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.DRAG + :ivar path: An array of coordinates representing the path of the drag action. Coordinates will + appear as an array of objects, eg + + .. code-block:: + + [ + { x: 100, y: 200 }, + { x: 200, y: 300 } + ]. Required. + :vartype path: list[~azure.ai.agentserver.responses.models.types.CoordParam] + """ + + type: Required[Literal[ComputerActionType.DRAG]] + """Specifies the event type. For a drag action, this property is always set to ``drag``. Required. + DRAG.""" + path: Required[list["CoordParam"]] + """An array of coordinates representing the path of the drag action. Coordinates will appear as an + array of objects, eg + + .. code-block:: + + [ + { x: 100, y: 200 }, + { x: 200, y: 300 } + ]. Required.""" + + +class Error(TypedDict, total=False): + """Error. + + :ivar code: Required. + :vartype code: str + :ivar message: Required. + :vartype message: str + :ivar param: + :vartype param: str + :ivar type: + :vartype type: str + :ivar details: + :vartype details: list[~azure.ai.agentserver.responses.models.types.Error] + :ivar additional_info: + :vartype additional_info: dict[str, any] + :ivar debug_info: + :vartype debug_info: dict[str, any] + """ + + code: Required[Optional[str]] + """Required.""" + message: Required[str] + """Required.""" + param: Optional[str] + type: str + details: list["Error"] + additionalInfo: dict[str, Any] + debugInfo: dict[str, Any] + + +class FabricDataAgentToolCall(TypedDict, total=False): + """A Fabric data agent tool call. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar type: Required. FABRIC_DATAAGENT_PREVIEW_CALL. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.FABRIC_DATAAGENT_PREVIEW_CALL + :ivar call_id: The unique ID of the tool call generated by the model. Required. + :vartype call_id: str + :ivar arguments: A JSON string of the arguments to pass to the tool. Required. + :vartype arguments: str + :ivar status: The status of the tool call. Required. Known values are: "in_progress", + "completed", "incomplete", and "failed". + :vartype status: str or ~azure.ai.agentserver.responses.models.models.ToolCallStatus + :ivar id: Required. + :vartype id: str + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + type: Required[Literal[OutputItemType.FABRIC_DATAAGENT_PREVIEW_CALL]] + """Required. FABRIC_DATAAGENT_PREVIEW_CALL.""" + call_id: Required[str] + """The unique ID of the tool call generated by the model. Required.""" + arguments: Required[str] + """A JSON string of the arguments to pass to the tool. Required.""" + status: Required[ToolCallStatus] + """The status of the tool call. Required. Known values are: \"in_progress\", \"completed\", + \"incomplete\", and \"failed\".""" + id: Required[str] + """Required.""" + + +class FabricDataAgentToolCallOutput(TypedDict, total=False): + """The output of a Fabric data agent tool call. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar type: Required. FABRIC_DATAAGENT_PREVIEW_CALL_OUTPUT. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.FABRIC_DATAAGENT_PREVIEW_CALL_OUTPUT + :ivar call_id: The unique ID of the tool call generated by the model. Required. + :vartype call_id: str + :ivar output: The output from the Fabric data agent tool call. Is one of the following types: + {str: Any}, str, [Any] + :vartype output: dict[str, any] or str or list[any] + :ivar status: The status of the tool call. Required. Known values are: "in_progress", + "completed", "incomplete", and "failed". + :vartype status: str or ~azure.ai.agentserver.responses.models.models.ToolCallStatus + :ivar id: Required. + :vartype id: str + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + type: Required[Literal[OutputItemType.FABRIC_DATAAGENT_PREVIEW_CALL_OUTPUT]] + """Required. FABRIC_DATAAGENT_PREVIEW_CALL_OUTPUT.""" + call_id: Required[str] + """The unique ID of the tool call generated by the model. Required.""" + output: "_unions.ToolCallOutputContent" + """The output from the Fabric data agent tool call. Is one of the following types: {str: Any}, + str, [Any]""" + status: Required[ToolCallStatus] + """The status of the tool call. Required. Known values are: \"in_progress\", \"completed\", + \"incomplete\", and \"failed\".""" + id: Required[str] + """Required.""" + + +class FabricDataAgentToolParameters(TypedDict, total=False): + """The fabric data agent tool parameters. + + :ivar name: Optional user-defined name for this tool or configuration. + :vartype name: str + :ivar description: Optional user-defined description for this tool or configuration. + :vartype description: str + :ivar project_connections: The project connections attached to this tool. There can be a + maximum of 1 connection resource attached to the tool. + :vartype project_connections: + list[~azure.ai.agentserver.responses.models.types.ToolProjectConnection] + """ + + name: str + """Optional user-defined name for this tool or configuration.""" + description: str + """Optional user-defined description for this tool or configuration.""" + project_connections: list["ToolProjectConnection"] + """The project connections attached to this tool. There can be a maximum of 1 connection resource + attached to the tool.""" + + +class FileCitationBody(TypedDict, total=False): + """File citation. + + :ivar type: The type of the file citation. Always ``file_citation``. Required. FILE_CITATION. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.FILE_CITATION + :ivar file_id: The ID of the file. Required. + :vartype file_id: str + :ivar index: The index of the file in the list of files. Required. + :vartype index: int + :ivar filename: The filename of the file cited. Required. + :vartype filename: str + """ + + type: Required[Literal[AnnotationType.FILE_CITATION]] + """The type of the file citation. Always ``file_citation``. Required. FILE_CITATION.""" + file_id: Required[str] + """The ID of the file. Required.""" + index: Required[int] + """The index of the file in the list of files. Required.""" + filename: Required[str] + """The filename of the file cited. Required.""" + + +class FilePath(TypedDict, total=False): + """File path. + + :ivar type: The type of the file path. Always ``file_path``. Required. FILE_PATH. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.FILE_PATH + :ivar file_id: The ID of the file. Required. + :vartype file_id: str + :ivar index: The index of the file in the list of files. Required. + :vartype index: int + """ + + type: Required[Literal[AnnotationType.FILE_PATH]] + """The type of the file path. Always ``file_path``. Required. FILE_PATH.""" + file_id: Required[str] + """The ID of the file. Required.""" + index: Required[int] + """The index of the file in the list of files. Required.""" + + +class FileSearchTool(TypedDict, total=False): + """File search. + + :ivar type: The type of the file search tool. Always ``file_search``. Required. FILE_SEARCH. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.FILE_SEARCH + :ivar vector_store_ids: The IDs of the vector stores to search. Required. + :vartype vector_store_ids: list[str] + :ivar max_num_results: The maximum number of results to return. This number should be between 1 + and 50 inclusive. + :vartype max_num_results: int + :ivar ranking_options: Ranking options for search. + :vartype ranking_options: ~azure.ai.agentserver.responses.models.types.RankingOptions + :ivar filters: Is either a ComparisonFilter type or a CompoundFilter type. + :vartype filters: ~azure.ai.agentserver.responses.models.types.ComparisonFilter or + ~azure.ai.agentserver.responses.models.types.CompoundFilter + :ivar name: Optional user-defined name for this tool or configuration. + :vartype name: str + :ivar description: Optional user-defined description for this tool or configuration. + :vartype description: str + """ + + type: Required[Literal[ToolType.FILE_SEARCH]] + """The type of the file search tool. Always ``file_search``. Required. FILE_SEARCH.""" + vector_store_ids: Required[list[str]] + """The IDs of the vector stores to search. Required.""" + max_num_results: int + """The maximum number of results to return. This number should be between 1 and 50 inclusive.""" + ranking_options: "RankingOptions" + """Ranking options for search.""" + filters: Optional["_unions.Filters"] + """Is either a ComparisonFilter type or a CompoundFilter type.""" + name: str + """Optional user-defined name for this tool or configuration.""" + description: str + """Optional user-defined description for this tool or configuration.""" + + +class FileSearchToolCallResults(TypedDict, total=False): + """FileSearchToolCallResults. + + :ivar file_id: + :vartype file_id: str + :ivar text: + :vartype text: str + :ivar filename: + :vartype filename: str + :ivar attributes: + :vartype attributes: ~azure.ai.agentserver.responses.models.types.VectorStoreFileAttributes + :ivar score: + :vartype score: float + """ + + file_id: str + text: str + filename: str + attributes: Optional["VectorStoreFileAttributes"] + score: float + + +class FunctionAndCustomToolCallOutputInputFileContent(TypedDict, total=False): # pylint: disable=name-too-long + """Input file. + + :ivar type: The type of the input item. Always ``input_file``. Required. INPUT_FILE. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.INPUT_FILE + :ivar file_id: + :vartype file_id: str + :ivar filename: The name of the file to be sent to the model. + :vartype filename: str + :ivar file_url: The URL of the file to be sent to the model. + :vartype file_url: str + :ivar file_data: The content of the file to be sent to the model. + :vartype file_data: str + """ + + type: Required[Literal[FunctionAndCustomToolCallOutputType.INPUT_FILE]] + """The type of the input item. Always ``input_file``. Required. INPUT_FILE.""" + file_id: Optional[str] + filename: str + """The name of the file to be sent to the model.""" + file_url: str + """The URL of the file to be sent to the model.""" + file_data: str + """The content of the file to be sent to the model.""" + + +class FunctionAndCustomToolCallOutputInputImageContent(TypedDict, total=False): # pylint: disable=name-too-long + """Input image. + + :ivar type: The type of the input item. Always ``input_image``. Required. INPUT_IMAGE. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.INPUT_IMAGE + :ivar image_url: + :vartype image_url: str + :ivar file_id: + :vartype file_id: str + :ivar detail: The detail level of the image to be sent to the model. One of ``high``, ``low``, + or ``auto``. Defaults to ``auto``. Required. Known values are: "low", "high", and "auto". + :vartype detail: str or ~azure.ai.agentserver.responses.models.models.ImageDetail + """ + + type: Required[Literal[FunctionAndCustomToolCallOutputType.INPUT_IMAGE]] + """The type of the input item. Always ``input_image``. Required. INPUT_IMAGE.""" + image_url: Optional[str] + file_id: Optional[str] + detail: Required[ImageDetail] + """The detail level of the image to be sent to the model. One of ``high``, ``low``, or ``auto``. + Defaults to ``auto``. Required. Known values are: \"low\", \"high\", and \"auto\".""" + + +class FunctionAndCustomToolCallOutputInputTextContent(TypedDict, total=False): # pylint: disable=name-too-long + """Input text. + + :ivar type: The type of the input item. Always ``input_text``. Required. INPUT_TEXT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.INPUT_TEXT + :ivar text: The text input to the model. Required. + :vartype text: str + """ + + type: Required[Literal[FunctionAndCustomToolCallOutputType.INPUT_TEXT]] + """The type of the input item. Always ``input_text``. Required. INPUT_TEXT.""" + text: Required[str] + """The text input to the model. Required.""" + + +class FunctionCallOutputItemParam(TypedDict, total=False): + """Function tool call output. + + :ivar id: + :vartype id: str + :ivar call_id: The unique ID of the function tool call generated by the model. Required. + :vartype call_id: str + :ivar type: The type of the function tool call output. Always ``function_call_output``. + Required. FUNCTION_CALL_OUTPUT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.FUNCTION_CALL_OUTPUT + :ivar output: Text, image, or file output of the function tool call. Required. Is either a str + type or a [Union["_types.InputTextContentParam", "_types.InputImageContentParamAutoParam", + "_types.InputFileContentParam"]] type. + :vartype output: str or list[~azure.ai.agentserver.responses.models.types.InputTextContentParam + or ~azure.ai.agentserver.responses.models.types.InputImageContentParamAutoParam or + ~azure.ai.agentserver.responses.models.types.InputFileContentParam] + :ivar status: Known values are: "in_progress", "completed", and "incomplete". + :vartype status: str or ~azure.ai.agentserver.responses.models.models.FunctionCallItemStatus + """ + + id: Optional[str] + call_id: Required[str] + """The unique ID of the function tool call generated by the model. Required.""" + type: Required[Literal[ItemType.FUNCTION_CALL_OUTPUT]] + """The type of the function tool call output. Always ``function_call_output``. Required. + FUNCTION_CALL_OUTPUT.""" + output: Required[ + Union[str, list[Union["InputTextContentParam", "InputImageContentParamAutoParam", "InputFileContentParam"]]] + ] + """Text, image, or file output of the function tool call. Required. Is either a str type or a + [Union[\"_types.InputTextContentParam\", \"_types.InputImageContentParamAutoParam\", + \"_types.InputFileContentParam\"]] type.""" + status: Optional[FunctionCallItemStatus] + """Known values are: \"in_progress\", \"completed\", and \"incomplete\".""" + + +class FunctionShellAction(TypedDict, total=False): + """Shell exec action. + + :ivar commands: Required. + :vartype commands: list[str] + :ivar timeout_ms: Required. + :vartype timeout_ms: int + :ivar max_output_length: Required. + :vartype max_output_length: int + """ + + commands: Required[list[str]] + """Required.""" + timeout_ms: Required[Optional[int]] + """Required.""" + max_output_length: Required[Optional[int]] + """Required.""" + + +class FunctionShellActionParam(TypedDict, total=False): + """Shell action. + + :ivar commands: Ordered shell commands for the execution environment to run. Required. + :vartype commands: list[str] + :ivar timeout_ms: + :vartype timeout_ms: int + :ivar max_output_length: + :vartype max_output_length: int + """ + + commands: Required[list[str]] + """Ordered shell commands for the execution environment to run. Required.""" + timeout_ms: Optional[int] + max_output_length: Optional[int] + + +class FunctionShellCallItemParam(TypedDict, total=False): + """Shell tool call. + + :ivar id: + :vartype id: str + :ivar call_id: The unique ID of the shell tool call generated by the model. Required. + :vartype call_id: str + :ivar type: The type of the item. Always ``shell_call``. Required. SHELL_CALL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.SHELL_CALL + :ivar action: The shell commands and limits that describe how to run the tool call. Required. + :vartype action: ~azure.ai.agentserver.responses.models.types.FunctionShellActionParam + :ivar status: Known values are: "in_progress", "completed", and "incomplete". + :vartype status: str or + ~azure.ai.agentserver.responses.models.models.FunctionShellCallItemStatus + :ivar environment: + :vartype environment: + ~azure.ai.agentserver.responses.models.types.FunctionShellCallItemParamEnvironment + """ + + id: Optional[str] + call_id: Required[str] + """The unique ID of the shell tool call generated by the model. Required.""" + type: Required[Literal[ItemType.SHELL_CALL]] + """The type of the item. Always ``shell_call``. Required. SHELL_CALL.""" + action: Required["FunctionShellActionParam"] + """The shell commands and limits that describe how to run the tool call. Required.""" + status: Optional[FunctionShellCallItemStatus] + """Known values are: \"in_progress\", \"completed\", and \"incomplete\".""" + environment: Optional["FunctionShellCallItemParamEnvironment"] + + +class FunctionShellCallItemParamEnvironmentContainerReferenceParam( + TypedDict, total=False +): # pylint: disable=name-too-long + """FunctionShellCallItemParamEnvironmentContainerReferenceParam. + + :ivar type: References a container created with the /v1/containers endpoint. Required. + CONTAINER_REFERENCE. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.CONTAINER_REFERENCE + :ivar container_id: The ID of the referenced container. Required. + :vartype container_id: str + """ + + type: Required[Literal[FunctionShellCallItemParamEnvironmentType.CONTAINER_REFERENCE]] + """References a container created with the /v1/containers endpoint. Required. CONTAINER_REFERENCE.""" + container_id: Required[str] + """The ID of the referenced container. Required.""" + + +class FunctionShellCallItemParamEnvironmentLocalEnvironmentParam( + TypedDict, total=False +): # pylint: disable=name-too-long + """FunctionShellCallItemParamEnvironmentLocalEnvironmentParam. + + :ivar type: Use a local computer environment. Required. LOCAL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.LOCAL + :ivar skills: An optional list of skills. + :vartype skills: list[~azure.ai.agentserver.responses.models.types.LocalSkillParam] + """ + + type: Required[Literal[FunctionShellCallItemParamEnvironmentType.LOCAL]] + """Use a local computer environment. Required. LOCAL.""" + skills: list["LocalSkillParam"] + """An optional list of skills.""" + + +class FunctionShellCallOutputContent(TypedDict, total=False): + """Shell call output content. + + :ivar stdout: The standard output that was captured. Required. + :vartype stdout: str + :ivar stderr: The standard error output that was captured. Required. + :vartype stderr: str + :ivar outcome: Shell call outcome. Required. + :vartype outcome: ~azure.ai.agentserver.responses.models.types.FunctionShellCallOutputOutcome + :ivar created_by: The identifier of the actor that created the item. + :vartype created_by: str + """ + + stdout: Required[str] + """The standard output that was captured. Required.""" + stderr: Required[str] + """The standard error output that was captured. Required.""" + outcome: Required["FunctionShellCallOutputOutcome"] + """Shell call outcome. Required.""" + created_by: str + """The identifier of the actor that created the item.""" + + +class FunctionShellCallOutputContentParam(TypedDict, total=False): + """Shell output content. + + :ivar stdout: Captured stdout output for the shell call. Required. + :vartype stdout: str + :ivar stderr: Captured stderr output for the shell call. Required. + :vartype stderr: str + :ivar outcome: The exit or timeout outcome associated with this shell call. Required. + :vartype outcome: + ~azure.ai.agentserver.responses.models.types.FunctionShellCallOutputOutcomeParam + """ + + stdout: Required[str] + """Captured stdout output for the shell call. Required.""" + stderr: Required[str] + """Captured stderr output for the shell call. Required.""" + outcome: Required["FunctionShellCallOutputOutcomeParam"] + """The exit or timeout outcome associated with this shell call. Required.""" + + +class FunctionShellCallOutputExitOutcome(TypedDict, total=False): + """Shell call exit outcome. + + :ivar type: The outcome type. Always ``exit``. Required. EXIT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.EXIT + :ivar exit_code: Exit code from the shell process. Required. + :vartype exit_code: int + """ + + type: Required[Literal[FunctionShellCallOutputOutcomeType.EXIT]] + """The outcome type. Always ``exit``. Required. EXIT.""" + exit_code: Required[int] + """Exit code from the shell process. Required.""" + + +class FunctionShellCallOutputExitOutcomeParam(TypedDict, total=False): + """Shell call exit outcome. + + :ivar type: The outcome type. Always ``exit``. Required. EXIT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.EXIT + :ivar exit_code: The exit code returned by the shell process. Required. + :vartype exit_code: int + """ + + type: Required[Literal[FunctionShellCallOutputOutcomeParamType.EXIT]] + """The outcome type. Always ``exit``. Required. EXIT.""" + exit_code: Required[int] + """The exit code returned by the shell process. Required.""" + + +class FunctionShellCallOutputItemParam(TypedDict, total=False): + """Shell tool call output. + + :ivar id: + :vartype id: str + :ivar call_id: The unique ID of the shell tool call generated by the model. Required. + :vartype call_id: str + :ivar type: The type of the item. Always ``shell_call_output``. Required. SHELL_CALL_OUTPUT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.SHELL_CALL_OUTPUT + :ivar output: Captured chunks of stdout and stderr output, along with their associated + outcomes. Required. + :vartype output: + list[~azure.ai.agentserver.responses.models.types.FunctionShellCallOutputContentParam] + :ivar status: Known values are: "in_progress", "completed", and "incomplete". + :vartype status: str or + ~azure.ai.agentserver.responses.models.models.FunctionShellCallItemStatus + :ivar max_output_length: + :vartype max_output_length: int + """ + + id: Optional[str] + call_id: Required[str] + """The unique ID of the shell tool call generated by the model. Required.""" + type: Required[Literal[ItemType.SHELL_CALL_OUTPUT]] + """The type of the item. Always ``shell_call_output``. Required. SHELL_CALL_OUTPUT.""" + output: Required[list["FunctionShellCallOutputContentParam"]] + """Captured chunks of stdout and stderr output, along with their associated outcomes. Required.""" + status: Optional[FunctionShellCallItemStatus] + """Known values are: \"in_progress\", \"completed\", and \"incomplete\".""" + max_output_length: Optional[int] + + +class FunctionShellCallOutputTimeoutOutcome(TypedDict, total=False): + """Shell call timeout outcome. + + :ivar type: The outcome type. Always ``timeout``. Required. TIMEOUT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.TIMEOUT + """ + + type: Required[Literal[FunctionShellCallOutputOutcomeType.TIMEOUT]] + """The outcome type. Always ``timeout``. Required. TIMEOUT.""" + + +class FunctionShellCallOutputTimeoutOutcomeParam(TypedDict, total=False): # pylint: disable=name-too-long + """Shell call timeout outcome. + + :ivar type: The outcome type. Always ``timeout``. Required. TIMEOUT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.TIMEOUT + """ + + type: Required[Literal[FunctionShellCallOutputOutcomeParamType.TIMEOUT]] + """The outcome type. Always ``timeout``. Required. TIMEOUT.""" + + +class FunctionShellToolParam(TypedDict, total=False): + """Shell tool. + + :ivar type: The type of the shell tool. Always ``shell``. Required. SHELL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.SHELL + :ivar environment: + :vartype environment: + ~azure.ai.agentserver.responses.models.types.FunctionShellToolParamEnvironment + :ivar name: Optional user-defined name for this tool or configuration. + :vartype name: str + :ivar description: Optional user-defined description for this tool or configuration. + :vartype description: str + """ + + type: Required[Literal[ToolType.SHELL]] + """The type of the shell tool. Always ``shell``. Required. SHELL.""" + environment: Optional["FunctionShellToolParamEnvironment"] + name: str + """Optional user-defined name for this tool or configuration.""" + description: str + """Optional user-defined description for this tool or configuration.""" + + +class FunctionShellToolParamEnvironmentContainerReferenceParam(TypedDict, total=False): # pylint: disable=name-too-long + """FunctionShellToolParamEnvironmentContainerReferenceParam. + + :ivar type: References a container created with the /v1/containers endpoint. Required. + CONTAINER_REFERENCE. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.CONTAINER_REFERENCE + :ivar container_id: The ID of the referenced container. Required. + :vartype container_id: str + """ + + type: Required[Literal[FunctionShellToolParamEnvironmentType.CONTAINER_REFERENCE]] + """References a container created with the /v1/containers endpoint. Required. CONTAINER_REFERENCE.""" + container_id: Required[str] + """The ID of the referenced container. Required.""" + + +class FunctionShellToolParamEnvironmentLocalEnvironmentParam(TypedDict, total=False): # pylint: disable=name-too-long + """FunctionShellToolParamEnvironmentLocalEnvironmentParam. + + :ivar type: Use a local computer environment. Required. LOCAL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.LOCAL + :ivar skills: An optional list of skills. + :vartype skills: list[~azure.ai.agentserver.responses.models.types.LocalSkillParam] + """ + + type: Required[Literal[FunctionShellToolParamEnvironmentType.LOCAL]] + """Use a local computer environment. Required. LOCAL.""" + skills: list["LocalSkillParam"] + """An optional list of skills.""" + + +class FunctionTool(TypedDict, total=False): + """Function. + + :ivar type: The type of the function tool. Always ``function``. Required. FUNCTION. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.FUNCTION + :ivar name: The name of the function to call. Required. + :vartype name: str + :ivar description: + :vartype description: str + :ivar parameters: Required. + :vartype parameters: dict[str, any] + :ivar strict: Required. + :vartype strict: bool + """ + + type: Required[Literal[ToolType.FUNCTION]] + """The type of the function tool. Always ``function``. Required. FUNCTION.""" + name: Required[str] + """The name of the function to call. Required.""" + description: Optional[str] + parameters: Required[Optional[dict[str, Any]]] + """Required.""" + strict: Required[Optional[bool]] + """Required.""" + + +class FunctionToolCallOutput(TypedDict, total=False): + """Function tool call output. + + :ivar id: The unique ID of the function tool call output. Populated when this item is returned + via API. + :vartype id: str + :ivar type: The type of the function tool call output. Always ``function_call_output``. + Required. FUNCTION_CALL_OUTPUT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.FUNCTION_CALL_OUTPUT + :ivar call_id: The unique ID of the function tool call generated by the model. Required. + :vartype call_id: str + :ivar output: The output from the function call generated by your code. Can be a string or an + list of output content. Required. Is either a str type or a [FunctionAndCustomToolCallOutput] + type. + :vartype output: str or + list[~azure.ai.agentserver.responses.models.types.FunctionAndCustomToolCallOutput] + :ivar status: The status of the item. One of ``in_progress``, ``completed``, or ``incomplete``. + Populated when items are returned via API. Is one of the following types: + Literal["in_progress"], Literal["completed"], Literal["incomplete"] + :vartype status: str or str or str + """ + + id: str + """The unique ID of the function tool call output. Populated when this item is returned via API.""" + type: Required[Literal[ItemFieldType.FUNCTION_CALL_OUTPUT]] + """The type of the function tool call output. Always ``function_call_output``. Required. + FUNCTION_CALL_OUTPUT.""" + call_id: Required[str] + """The unique ID of the function tool call generated by the model. Required.""" + output: Required[Union[str, list["FunctionAndCustomToolCallOutput"]]] + """The output from the function call generated by your code. Can be a string or an list of output + content. Required. Is either a str type or a [FunctionAndCustomToolCallOutput] type.""" + status: Literal["in_progress", "completed", "incomplete"] + """The status of the item. One of ``in_progress``, ``completed``, or ``incomplete``. Populated + when items are returned via API. Is one of the following types: Literal[\"in_progress\"], + Literal[\"completed\"], Literal[\"incomplete\"]""" + + +class FunctionToolCallOutputResource(TypedDict, total=False): + """FunctionToolCallOutputResource. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar id: The unique ID of the function tool call output. Populated when this item is returned + via API. + :vartype id: str + :ivar type: The type of the function tool call output. Always ``function_call_output``. + Required. FUNCTION_CALL_OUTPUT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.FUNCTION_CALL_OUTPUT + :ivar call_id: The unique ID of the function tool call generated by the model. Required. + :vartype call_id: str + :ivar output: The output from the function call generated by your code. Can be a string or an + list of output content. Required. Is either a str type or a [FunctionAndCustomToolCallOutput] + type. + :vartype output: str or + list[~azure.ai.agentserver.responses.models.types.FunctionAndCustomToolCallOutput] + :ivar status: The status of the item. One of ``in_progress``, ``completed``, or ``incomplete``. + Populated when items are returned via API. Is one of the following types: + Literal["in_progress"], Literal["completed"], Literal["incomplete"] + :vartype status: str or str or str + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + id: str + """The unique ID of the function tool call output. Populated when this item is returned via API.""" + type: Required[Literal[OutputItemType.FUNCTION_CALL_OUTPUT]] + """The type of the function tool call output. Always ``function_call_output``. Required. + FUNCTION_CALL_OUTPUT.""" + call_id: Required[str] + """The unique ID of the function tool call generated by the model. Required.""" + output: Required[Union[str, list["FunctionAndCustomToolCallOutput"]]] + """The output from the function call generated by your code. Can be a string or an list of output + content. Required. Is either a str type or a [FunctionAndCustomToolCallOutput] type.""" + status: Literal["in_progress", "completed", "incomplete"] + """The status of the item. One of ``in_progress``, ``completed``, or ``incomplete``. Populated + when items are returned via API. Is one of the following types: Literal[\"in_progress\"], + Literal[\"completed\"], Literal[\"incomplete\"]""" + + +class HybridSearchOptions(TypedDict, total=False): + """HybridSearchOptions. + + :ivar embedding_weight: The weight of the embedding in the reciprocal ranking fusion. Required. + :vartype embedding_weight: float + :ivar text_weight: The weight of the text in the reciprocal ranking fusion. Required. + :vartype text_weight: float + """ + + embedding_weight: Required[float] + """The weight of the embedding in the reciprocal ranking fusion. Required.""" + text_weight: Required[float] + """The weight of the text in the reciprocal ranking fusion. Required.""" + + +class ImageGenTool(TypedDict, total=False): + """Image generation tool. + + :ivar type: The type of the image generation tool. Always ``image_generation``. Required. + IMAGE_GENERATION. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.IMAGE_GENERATION + :ivar model: Is one of the following types: Literal["gpt-image-1"], + Literal["gpt-image-1-mini"], Literal["gpt-image-1.5"], str + :vartype model: str or str or str or str + :ivar quality: The quality of the generated image. One of ``low``, ``medium``, ``high``, or + ``auto``. Default: ``auto``. Is one of the following types: Literal["low"], Literal["medium"], + Literal["high"], Literal["auto"] + :vartype quality: str or str or str or str + :ivar size: The size of the generated image. One of ``1024x1024``, ``1024x1536``, + ``1536x1024``, or ``auto``. Default: ``auto``. Is one of the following types: + Literal["1024x1024"], Literal["1024x1536"], Literal["1536x1024"], Literal["auto"] + :vartype size: str or str or str or str + :ivar output_format: The output format of the generated image. One of ``png``, ``webp``, or + ``jpeg``. Default: ``png``. Is one of the following types: Literal["png"], Literal["webp"], + Literal["jpeg"] + :vartype output_format: str or str or str + :ivar output_compression: Compression level for the output image. Default: 100. + :vartype output_compression: int + :ivar moderation: Moderation level for the generated image. Default: ``auto``. Is either a + Literal["auto"] type or a Literal["low"] type. + :vartype moderation: str or str + :ivar background: Background type for the generated image. One of ``transparent``, ``opaque``, + or ``auto``. Default: ``auto``. Is one of the following types: Literal["transparent"], + Literal["opaque"], Literal["auto"] + :vartype background: str or str or str + :ivar input_fidelity: Known values are: "high" and "low". + :vartype input_fidelity: str or ~azure.ai.agentserver.responses.models.models.InputFidelity + :ivar input_image_mask: Optional mask for inpainting. Contains ``image_url`` (string, optional) + and ``file_id`` (string, optional). + :vartype input_image_mask: + ~azure.ai.agentserver.responses.models.types.ImageGenToolInputImageMask + :ivar partial_images: Number of partial images to generate in streaming mode, from 0 (default + value) to 3. + :vartype partial_images: int + :ivar action: Whether to generate a new image or edit an existing image. Default: ``auto``. + Known values are: "generate", "edit", and "auto". + :vartype action: str or ~azure.ai.agentserver.responses.models.models.ImageGenActionEnum + :ivar name: Optional user-defined name for this tool or configuration. + :vartype name: str + :ivar description: Optional user-defined description for this tool or configuration. + :vartype description: str + """ + + type: Required[Literal[ToolType.IMAGE_GENERATION]] + """The type of the image generation tool. Always ``image_generation``. Required. IMAGE_GENERATION.""" + model: Union[Literal["gpt-image-1"], Literal["gpt-image-1-mini"], Literal["gpt-image-1.5"], str] + """Is one of the following types: Literal[\"gpt-image-1\"], Literal[\"gpt-image-1-mini\"], + Literal[\"gpt-image-1.5\"], str""" + quality: Literal["low", "medium", "high", "auto"] + """The quality of the generated image. One of ``low``, ``medium``, ``high``, or ``auto``. Default: + ``auto``. Is one of the following types: Literal[\"low\"], Literal[\"medium\"], + Literal[\"high\"], Literal[\"auto\"]""" + size: Literal["1024x1024", "1024x1536", "1536x1024", "auto"] + """The size of the generated image. One of ``1024x1024``, ``1024x1536``, ``1536x1024``, or + ``auto``. Default: ``auto``. Is one of the following types: Literal[\"1024x1024\"], + Literal[\"1024x1536\"], Literal[\"1536x1024\"], Literal[\"auto\"]""" + output_format: Literal["png", "webp", "jpeg"] + """The output format of the generated image. One of ``png``, ``webp``, or ``jpeg``. Default: + ``png``. Is one of the following types: Literal[\"png\"], Literal[\"webp\"], Literal[\"jpeg\"]""" + output_compression: int + """Compression level for the output image. Default: 100.""" + moderation: Literal["auto", "low"] + """Moderation level for the generated image. Default: ``auto``. Is either a Literal[\"auto\"] type + or a Literal[\"low\"] type.""" + background: Literal["transparent", "opaque", "auto"] + """Background type for the generated image. One of ``transparent``, ``opaque``, or ``auto``. + Default: ``auto``. Is one of the following types: Literal[\"transparent\"], + Literal[\"opaque\"], Literal[\"auto\"]""" + input_fidelity: Optional[InputFidelity] + """Known values are: \"high\" and \"low\".""" + input_image_mask: "ImageGenToolInputImageMask" + """Optional mask for inpainting. Contains ``image_url`` (string, optional) and ``file_id`` + (string, optional).""" + partial_images: int + """Number of partial images to generate in streaming mode, from 0 (default value) to 3.""" + action: ImageGenActionEnum + """Whether to generate a new image or edit an existing image. Default: ``auto``. Known values are: + \"generate\", \"edit\", and \"auto\".""" + name: str + """Optional user-defined name for this tool or configuration.""" + description: str + """Optional user-defined description for this tool or configuration.""" + + +class ImageGenToolInputImageMask(TypedDict, total=False): + """ImageGenToolInputImageMask. + + :ivar image_url: + :vartype image_url: str + :ivar file_id: + :vartype file_id: str + """ + + image_url: str + file_id: str + + +class InlineSkillParam(TypedDict, total=False): + """InlineSkillParam. + + :ivar type: Defines an inline skill for this request. Required. INLINE. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.INLINE + :ivar name: The name of the skill. Required. + :vartype name: str + :ivar description: The description of the skill. Required. + :vartype description: str + :ivar source: Inline skill payload. Required. + :vartype source: ~azure.ai.agentserver.responses.models.types.InlineSkillSourceParam + """ + + type: Required[Literal[ContainerSkillType.INLINE]] + """Defines an inline skill for this request. Required. INLINE.""" + name: Required[str] + """The name of the skill. Required.""" + description: Required[str] + """The description of the skill. Required.""" + source: Required["InlineSkillSourceParam"] + """Inline skill payload. Required.""" + + +class InlineSkillSourceParam(TypedDict, total=False): + """Inline skill payload. + + :ivar type: The type of the inline skill source. Must be ``base64``. Required. Default value is + "base64". + :vartype type: str + :ivar media_type: The media type of the inline skill payload. Must be ``application/zip``. + Required. Default value is "application/zip". + :vartype media_type: str + :ivar data: Base64-encoded skill zip bundle. Required. + :vartype data: str + """ + + type: Required[Literal["base64"]] + """The type of the inline skill source. Must be ``base64``. Required. Default value is \"base64\".""" + media_type: Required[Literal["application/zip"]] + """The media type of the inline skill payload. Must be ``application/zip``. Required. Default + value is \"application/zip\".""" + data: Required[str] + """Base64-encoded skill zip bundle. Required.""" + + +class InputFileContent(TypedDict, total=False): + """Input file. + + :ivar type: The type of the input item. Always ``input_file``. Required. Default value is + "input_file". + :vartype type: str + :ivar file_id: + :vartype file_id: str + :ivar filename: The name of the file to be sent to the model. + :vartype filename: str + :ivar file_url: The URL of the file to be sent to the model. + :vartype file_url: str + :ivar file_data: The content of the file to be sent to the model. + :vartype file_data: str + """ + + type: Required[Literal["input_file"]] + """The type of the input item. Always ``input_file``. Required. Default value is \"input_file\".""" + file_id: Optional[str] + filename: str + """The name of the file to be sent to the model.""" + file_url: str + """The URL of the file to be sent to the model.""" + file_data: str + """The content of the file to be sent to the model.""" + + +class InputFileContentParam(TypedDict, total=False): + """Input file. + + :ivar type: The type of the input item. Always ``input_file``. Required. Default value is + "input_file". + :vartype type: str + :ivar file_id: + :vartype file_id: str + :ivar filename: + :vartype filename: str + :ivar file_data: + :vartype file_data: str + :ivar file_url: + :vartype file_url: str + """ + + type: Required[Literal["input_file"]] + """The type of the input item. Always ``input_file``. Required. Default value is \"input_file\".""" + file_id: Optional[str] + filename: Optional[str] + file_data: Optional[str] + file_url: Optional[str] + + +class InputImageContent(TypedDict, total=False): + """Input image. + + :ivar type: The type of the input item. Always ``input_image``. Required. Default value is + "input_image". + :vartype type: str + :ivar image_url: + :vartype image_url: str + :ivar file_id: + :vartype file_id: str + :ivar detail: The detail level of the image to be sent to the model. One of ``high``, ``low``, + or ``auto``. Defaults to ``auto``. Required. Known values are: "low", "high", and "auto". + :vartype detail: str or ~azure.ai.agentserver.responses.models.models.ImageDetail + """ + + type: Required[Literal["input_image"]] + """The type of the input item. Always ``input_image``. Required. Default value is \"input_image\".""" + image_url: Optional[str] + file_id: Optional[str] + detail: Required[ImageDetail] + """The detail level of the image to be sent to the model. One of ``high``, ``low``, or ``auto``. + Defaults to ``auto``. Required. Known values are: \"low\", \"high\", and \"auto\".""" + + +class InputImageContentParamAutoParam(TypedDict, total=False): + """Input image. + + :ivar type: The type of the input item. Always ``input_image``. Required. Default value is + "input_image". + :vartype type: str + :ivar image_url: + :vartype image_url: str + :ivar file_id: + :vartype file_id: str + :ivar detail: Known values are: "low", "high", and "auto". + :vartype detail: str or ~azure.ai.agentserver.responses.models.models.DetailEnum + """ + + type: Required[Literal["input_image"]] + """The type of the input item. Always ``input_image``. Required. Default value is \"input_image\".""" + image_url: Optional[str] + file_id: Optional[str] + detail: Optional[DetailEnum] + """Known values are: \"low\", \"high\", and \"auto\".""" + + +class InputTextContent(TypedDict, total=False): + """Input text. + + :ivar type: The type of the input item. Always ``input_text``. Required. Default value is + "input_text". + :vartype type: str + :ivar text: The text input to the model. Required. + :vartype text: str + """ + + type: Required[Literal["input_text"]] + """The type of the input item. Always ``input_text``. Required. Default value is \"input_text\".""" + text: Required[str] + """The text input to the model. Required.""" + + +class InputTextContentParam(TypedDict, total=False): + """Input text. + + :ivar type: The type of the input item. Always ``input_text``. Required. Default value is + "input_text". + :vartype type: str + :ivar text: The text input to the model. Required. + :vartype text: str + """ + + type: Required[Literal["input_text"]] + """The type of the input item. Always ``input_text``. Required. Default value is \"input_text\".""" + text: Required[str] + """The text input to the model. Required.""" + + +class ItemCodeInterpreterToolCall(TypedDict, total=False): + """Code interpreter tool call. + + :ivar type: The type of the code interpreter tool call. Always ``code_interpreter_call``. + Required. CODE_INTERPRETER_CALL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.CODE_INTERPRETER_CALL + :ivar id: The unique ID of the code interpreter tool call. Required. + :vartype id: str + :ivar status: The status of the code interpreter tool call. Valid values are ``in_progress``, + ``completed``, ``incomplete``, ``interpreting``, and ``failed``. Required. Is one of the + following types: Literal["in_progress"], Literal["completed"], Literal["incomplete"], + Literal["interpreting"], Literal["failed"] + :vartype status: str or str or str or str or str + :ivar container_id: The ID of the container used to run the code. Required. + :vartype container_id: str + :ivar code: Required. + :vartype code: str + :ivar outputs: Required. + :vartype outputs: list[~azure.ai.agentserver.responses.models.types.CodeInterpreterOutputLogs + or ~azure.ai.agentserver.responses.models.types.CodeInterpreterOutputImage] + """ + + type: Required[Literal[ItemType.CODE_INTERPRETER_CALL]] + """The type of the code interpreter tool call. Always ``code_interpreter_call``. Required. + CODE_INTERPRETER_CALL.""" + id: Required[str] + """The unique ID of the code interpreter tool call. Required.""" + status: Required[Literal["in_progress", "completed", "incomplete", "interpreting", "failed"]] + """The status of the code interpreter tool call. Valid values are ``in_progress``, ``completed``, + ``incomplete``, ``interpreting``, and ``failed``. Required. Is one of the following types: + Literal[\"in_progress\"], Literal[\"completed\"], Literal[\"incomplete\"], + Literal[\"interpreting\"], Literal[\"failed\"]""" + container_id: Required[str] + """The ID of the container used to run the code. Required.""" + code: Required[Optional[str]] + """Required.""" + outputs: Required[Optional[list[Union["CodeInterpreterOutputLogs", "CodeInterpreterOutputImage"]]]] + """Required.""" + + +class ItemComputerToolCall(TypedDict, total=False): + """Computer tool call. + + :ivar type: The type of the computer call. Always ``computer_call``. Required. COMPUTER_CALL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.COMPUTER_CALL + :ivar id: The unique ID of the computer call. Required. + :vartype id: str + :ivar call_id: An identifier used when responding to the tool call with output. Required. + :vartype call_id: str + :ivar action: Required. + :vartype action: ~azure.ai.agentserver.responses.models.types.ComputerAction + :ivar pending_safety_checks: The pending safety checks for the computer call. Required. + :vartype pending_safety_checks: + list[~azure.ai.agentserver.responses.models.types.ComputerCallSafetyCheckParam] + :ivar status: The status of the item. One of ``in_progress``, ``completed``, or ``incomplete``. + Populated when items are returned via API. Required. Is one of the following types: + Literal["in_progress"], Literal["completed"], Literal["incomplete"] + :vartype status: str or str or str + """ + + type: Required[Literal[ItemType.COMPUTER_CALL]] + """The type of the computer call. Always ``computer_call``. Required. COMPUTER_CALL.""" + id: Required[str] + """The unique ID of the computer call. Required.""" + call_id: Required[str] + """An identifier used when responding to the tool call with output. Required.""" + action: Required["ComputerAction"] + """Required.""" + pending_safety_checks: Required[list["ComputerCallSafetyCheckParam"]] + """The pending safety checks for the computer call. Required.""" + status: Required[Literal["in_progress", "completed", "incomplete"]] + """The status of the item. One of ``in_progress``, ``completed``, or ``incomplete``. Populated + when items are returned via API. Required. Is one of the following types: + Literal[\"in_progress\"], Literal[\"completed\"], Literal[\"incomplete\"]""" + + +class ItemCustomToolCall(TypedDict, total=False): + """Custom tool call. + + :ivar type: The type of the custom tool call. Always ``custom_tool_call``. Required. + CUSTOM_TOOL_CALL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.CUSTOM_TOOL_CALL + :ivar id: The unique ID of the custom tool call in the OpenAI platform. + :vartype id: str + :ivar call_id: An identifier used to map this custom tool call to a tool call output. Required. + :vartype call_id: str + :ivar name: The name of the custom tool being called. Required. + :vartype name: str + :ivar input: The input for the custom tool call generated by the model. Required. + :vartype input: str + """ + + type: Required[Literal[ItemType.CUSTOM_TOOL_CALL]] + """The type of the custom tool call. Always ``custom_tool_call``. Required. CUSTOM_TOOL_CALL.""" + id: str + """The unique ID of the custom tool call in the OpenAI platform.""" + call_id: Required[str] + """An identifier used to map this custom tool call to a tool call output. Required.""" + name: Required[str] + """The name of the custom tool being called. Required.""" + input: Required[str] + """The input for the custom tool call generated by the model. Required.""" + + +class ItemCustomToolCallOutput(TypedDict, total=False): + """Custom tool call output. + + :ivar type: The type of the custom tool call output. Always ``custom_tool_call_output``. + Required. CUSTOM_TOOL_CALL_OUTPUT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.CUSTOM_TOOL_CALL_OUTPUT + :ivar id: The unique ID of the custom tool call output in the OpenAI platform. + :vartype id: str + :ivar call_id: The call ID, used to map this custom tool call output to a custom tool call. + Required. + :vartype call_id: str + :ivar output: The output from the custom tool call generated by your code. Can be a string or + an list of output content. Required. Is either a str type or a + [FunctionAndCustomToolCallOutput] type. + :vartype output: str or + list[~azure.ai.agentserver.responses.models.types.FunctionAndCustomToolCallOutput] + """ + + type: Required[Literal[ItemType.CUSTOM_TOOL_CALL_OUTPUT]] + """The type of the custom tool call output. Always ``custom_tool_call_output``. Required. + CUSTOM_TOOL_CALL_OUTPUT.""" + id: str + """The unique ID of the custom tool call output in the OpenAI platform.""" + call_id: Required[str] + """The call ID, used to map this custom tool call output to a custom tool call. Required.""" + output: Required[Union[str, list["FunctionAndCustomToolCallOutput"]]] + """The output from the custom tool call generated by your code. Can be a string or an list of + output content. Required. Is either a str type or a [FunctionAndCustomToolCallOutput] type.""" + + +class ItemFieldApplyPatchToolCall(TypedDict, total=False): + """Apply patch tool call. + + :ivar type: The type of the item. Always ``apply_patch_call``. Required. APPLY_PATCH_CALL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.APPLY_PATCH_CALL + :ivar id: The unique ID of the apply patch tool call. Populated when this item is returned via + API. Required. + :vartype id: str + :ivar call_id: The unique ID of the apply patch tool call generated by the model. Required. + :vartype call_id: str + :ivar status: The status of the apply patch tool call. One of ``in_progress`` or ``completed``. + Required. Known values are: "in_progress" and "completed". + :vartype status: str or ~azure.ai.agentserver.responses.models.models.ApplyPatchCallStatus + :ivar operation: Apply patch operation. Required. + :vartype operation: ~azure.ai.agentserver.responses.models.types.ApplyPatchFileOperation + :ivar created_by: The ID of the entity that created this tool call. + :vartype created_by: str + """ + + type: Required[Literal[ItemFieldType.APPLY_PATCH_CALL]] + """The type of the item. Always ``apply_patch_call``. Required. APPLY_PATCH_CALL.""" + id: Required[str] + """The unique ID of the apply patch tool call. Populated when this item is returned via API. + Required.""" + call_id: Required[str] + """The unique ID of the apply patch tool call generated by the model. Required.""" + status: Required[ApplyPatchCallStatus] + """The status of the apply patch tool call. One of ``in_progress`` or ``completed``. Required. + Known values are: \"in_progress\" and \"completed\".""" + operation: Required["ApplyPatchFileOperation"] + """Apply patch operation. Required.""" + created_by: str + """The ID of the entity that created this tool call.""" + + +class ItemFieldApplyPatchToolCallOutput(TypedDict, total=False): + """Apply patch tool call output. + + :ivar type: The type of the item. Always ``apply_patch_call_output``. Required. + APPLY_PATCH_CALL_OUTPUT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.APPLY_PATCH_CALL_OUTPUT + :ivar id: The unique ID of the apply patch tool call output. Populated when this item is + returned via API. Required. + :vartype id: str + :ivar call_id: The unique ID of the apply patch tool call generated by the model. Required. + :vartype call_id: str + :ivar status: The status of the apply patch tool call output. One of ``completed`` or + ``failed``. Required. Known values are: "completed" and "failed". + :vartype status: str or + ~azure.ai.agentserver.responses.models.models.ApplyPatchCallOutputStatus + :ivar output: + :vartype output: str + :ivar created_by: The ID of the entity that created this tool call output. + :vartype created_by: str + """ + + type: Required[Literal[ItemFieldType.APPLY_PATCH_CALL_OUTPUT]] + """The type of the item. Always ``apply_patch_call_output``. Required. APPLY_PATCH_CALL_OUTPUT.""" + id: Required[str] + """The unique ID of the apply patch tool call output. Populated when this item is returned via + API. Required.""" + call_id: Required[str] + """The unique ID of the apply patch tool call generated by the model. Required.""" + status: Required[ApplyPatchCallOutputStatus] + """The status of the apply patch tool call output. One of ``completed`` or ``failed``. Required. + Known values are: \"completed\" and \"failed\".""" + output: Optional[str] + created_by: str + """The ID of the entity that created this tool call output.""" + + +class ItemFieldCodeInterpreterToolCall(TypedDict, total=False): + """Code interpreter tool call. + + :ivar type: The type of the code interpreter tool call. Always ``code_interpreter_call``. + Required. CODE_INTERPRETER_CALL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.CODE_INTERPRETER_CALL + :ivar id: The unique ID of the code interpreter tool call. Required. + :vartype id: str + :ivar status: The status of the code interpreter tool call. Valid values are ``in_progress``, + ``completed``, ``incomplete``, ``interpreting``, and ``failed``. Required. Is one of the + following types: Literal["in_progress"], Literal["completed"], Literal["incomplete"], + Literal["interpreting"], Literal["failed"] + :vartype status: str or str or str or str or str + :ivar container_id: The ID of the container used to run the code. Required. + :vartype container_id: str + :ivar code: Required. + :vartype code: str + :ivar outputs: Required. + :vartype outputs: list[~azure.ai.agentserver.responses.models.types.CodeInterpreterOutputLogs + or ~azure.ai.agentserver.responses.models.types.CodeInterpreterOutputImage] + """ + + type: Required[Literal[ItemFieldType.CODE_INTERPRETER_CALL]] + """The type of the code interpreter tool call. Always ``code_interpreter_call``. Required. + CODE_INTERPRETER_CALL.""" + id: Required[str] + """The unique ID of the code interpreter tool call. Required.""" + status: Required[Literal["in_progress", "completed", "incomplete", "interpreting", "failed"]] + """The status of the code interpreter tool call. Valid values are ``in_progress``, ``completed``, + ``incomplete``, ``interpreting``, and ``failed``. Required. Is one of the following types: + Literal[\"in_progress\"], Literal[\"completed\"], Literal[\"incomplete\"], + Literal[\"interpreting\"], Literal[\"failed\"]""" + container_id: Required[str] + """The ID of the container used to run the code. Required.""" + code: Required[Optional[str]] + """Required.""" + outputs: Required[Optional[list[Union["CodeInterpreterOutputLogs", "CodeInterpreterOutputImage"]]]] + """Required.""" + + +class ItemFieldCompactionBody(TypedDict, total=False): + """Compaction item. + + :ivar type: The type of the item. Always ``compaction``. Required. COMPACTION. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.COMPACTION + :ivar id: The unique ID of the compaction item. Required. + :vartype id: str + :ivar encrypted_content: The encrypted content that was produced by compaction. Required. + :vartype encrypted_content: str + :ivar created_by: The identifier of the actor that created the item. + :vartype created_by: str + """ + + type: Required[Literal[ItemFieldType.COMPACTION]] + """The type of the item. Always ``compaction``. Required. COMPACTION.""" + id: Required[str] + """The unique ID of the compaction item. Required.""" + encrypted_content: Required[str] + """The encrypted content that was produced by compaction. Required.""" + created_by: str + """The identifier of the actor that created the item.""" + + +class ItemFieldComputerToolCall(TypedDict, total=False): + """Computer tool call. + + :ivar type: The type of the computer call. Always ``computer_call``. Required. COMPUTER_CALL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.COMPUTER_CALL + :ivar id: The unique ID of the computer call. Required. + :vartype id: str + :ivar call_id: An identifier used when responding to the tool call with output. Required. + :vartype call_id: str + :ivar action: Required. + :vartype action: ~azure.ai.agentserver.responses.models.types.ComputerAction + :ivar pending_safety_checks: The pending safety checks for the computer call. Required. + :vartype pending_safety_checks: + list[~azure.ai.agentserver.responses.models.types.ComputerCallSafetyCheckParam] + :ivar status: The status of the item. One of ``in_progress``, ``completed``, or ``incomplete``. + Populated when items are returned via API. Required. Is one of the following types: + Literal["in_progress"], Literal["completed"], Literal["incomplete"] + :vartype status: str or str or str + """ + + type: Required[Literal[ItemFieldType.COMPUTER_CALL]] + """The type of the computer call. Always ``computer_call``. Required. COMPUTER_CALL.""" + id: Required[str] + """The unique ID of the computer call. Required.""" + call_id: Required[str] + """An identifier used when responding to the tool call with output. Required.""" + action: Required["ComputerAction"] + """Required.""" + pending_safety_checks: Required[list["ComputerCallSafetyCheckParam"]] + """The pending safety checks for the computer call. Required.""" + status: Required[Literal["in_progress", "completed", "incomplete"]] + """The status of the item. One of ``in_progress``, ``completed``, or ``incomplete``. Populated + when items are returned via API. Required. Is one of the following types: + Literal[\"in_progress\"], Literal[\"completed\"], Literal[\"incomplete\"]""" + + +class ItemFieldComputerToolCallOutputResource(TypedDict, total=False): + """ItemFieldComputerToolCallOutputResource. + + :ivar type: The type of the computer tool call output. Always ``computer_call_output``. + Required. COMPUTER_CALL_OUTPUT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.COMPUTER_CALL_OUTPUT + :ivar id: The ID of the computer tool call output. + :vartype id: str + :ivar call_id: The ID of the computer tool call that produced the output. Required. + :vartype call_id: str + :ivar acknowledged_safety_checks: The safety checks reported by the API that have been + acknowledged by the developer. + :vartype acknowledged_safety_checks: + list[~azure.ai.agentserver.responses.models.types.ComputerCallSafetyCheckParam] + :ivar output: Required. + :vartype output: ~azure.ai.agentserver.responses.models.types.ComputerScreenshotImage + :ivar status: The status of the message input. One of ``in_progress``, ``completed``, or + ``incomplete``. Populated when input items are returned via API. Is one of the following types: + Literal["in_progress"], Literal["completed"], Literal["incomplete"] + :vartype status: str or str or str + """ + + type: Required[Literal[ItemFieldType.COMPUTER_CALL_OUTPUT]] + """The type of the computer tool call output. Always ``computer_call_output``. Required. + COMPUTER_CALL_OUTPUT.""" + id: str + """The ID of the computer tool call output.""" + call_id: Required[str] + """The ID of the computer tool call that produced the output. Required.""" + acknowledged_safety_checks: list["ComputerCallSafetyCheckParam"] + """The safety checks reported by the API that have been acknowledged by the developer.""" + output: Required["ComputerScreenshotImage"] + """Required.""" + status: Literal["in_progress", "completed", "incomplete"] + """The status of the message input. One of ``in_progress``, ``completed``, or ``incomplete``. + Populated when input items are returned via API. Is one of the following types: + Literal[\"in_progress\"], Literal[\"completed\"], Literal[\"incomplete\"]""" + + +class ItemFieldCustomToolCall(TypedDict, total=False): + """Custom tool call. + + :ivar type: The type of the custom tool call. Always ``custom_tool_call``. Required. + CUSTOM_TOOL_CALL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.CUSTOM_TOOL_CALL + :ivar id: The unique ID of the custom tool call in the OpenAI platform. + :vartype id: str + :ivar call_id: An identifier used to map this custom tool call to a tool call output. Required. + :vartype call_id: str + :ivar name: The name of the custom tool being called. Required. + :vartype name: str + :ivar input: The input for the custom tool call generated by the model. Required. + :vartype input: str + """ + + type: Required[Literal[ItemFieldType.CUSTOM_TOOL_CALL]] + """The type of the custom tool call. Always ``custom_tool_call``. Required. CUSTOM_TOOL_CALL.""" + id: str + """The unique ID of the custom tool call in the OpenAI platform.""" + call_id: Required[str] + """An identifier used to map this custom tool call to a tool call output. Required.""" + name: Required[str] + """The name of the custom tool being called. Required.""" + input: Required[str] + """The input for the custom tool call generated by the model. Required.""" + + +class ItemFieldCustomToolCallOutput(TypedDict, total=False): + """Custom tool call output. + + :ivar type: The type of the custom tool call output. Always ``custom_tool_call_output``. + Required. CUSTOM_TOOL_CALL_OUTPUT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.CUSTOM_TOOL_CALL_OUTPUT + :ivar id: The unique ID of the custom tool call output in the OpenAI platform. + :vartype id: str + :ivar call_id: The call ID, used to map this custom tool call output to a custom tool call. + Required. + :vartype call_id: str + :ivar output: The output from the custom tool call generated by your code. Can be a string or + an list of output content. Required. Is either a str type or a + [FunctionAndCustomToolCallOutput] type. + :vartype output: str or + list[~azure.ai.agentserver.responses.models.types.FunctionAndCustomToolCallOutput] + """ + + type: Required[Literal[ItemFieldType.CUSTOM_TOOL_CALL_OUTPUT]] + """The type of the custom tool call output. Always ``custom_tool_call_output``. Required. + CUSTOM_TOOL_CALL_OUTPUT.""" + id: str + """The unique ID of the custom tool call output in the OpenAI platform.""" + call_id: Required[str] + """The call ID, used to map this custom tool call output to a custom tool call. Required.""" + output: Required[Union[str, list["FunctionAndCustomToolCallOutput"]]] + """The output from the custom tool call generated by your code. Can be a string or an list of + output content. Required. Is either a str type or a [FunctionAndCustomToolCallOutput] type.""" + + +class ItemFieldFileSearchToolCall(TypedDict, total=False): + """File search tool call. + + :ivar id: The unique ID of the file search tool call. Required. + :vartype id: str + :ivar type: The type of the file search tool call. Always ``file_search_call``. Required. + FILE_SEARCH_CALL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.FILE_SEARCH_CALL + :ivar status: The status of the file search tool call. One of ``in_progress``, ``searching``, + ``incomplete`` or ``failed``,. Required. Is one of the following types: Literal["in_progress"], + Literal["searching"], Literal["completed"], Literal["incomplete"], Literal["failed"] + :vartype status: str or str or str or str or str + :ivar queries: The queries used to search for files. Required. + :vartype queries: list[str] + :ivar results: + :vartype results: list[~azure.ai.agentserver.responses.models.types.FileSearchToolCallResults] + """ + + id: Required[str] + """The unique ID of the file search tool call. Required.""" + type: Required[Literal[ItemFieldType.FILE_SEARCH_CALL]] + """The type of the file search tool call. Always ``file_search_call``. Required. FILE_SEARCH_CALL.""" + status: Required[Literal["in_progress", "searching", "completed", "incomplete", "failed"]] + """The status of the file search tool call. One of ``in_progress``, ``searching``, ``incomplete`` + or ``failed``,. Required. Is one of the following types: Literal[\"in_progress\"], + Literal[\"searching\"], Literal[\"completed\"], Literal[\"incomplete\"], Literal[\"failed\"]""" + queries: Required[list[str]] + """The queries used to search for files. Required.""" + results: Optional[list["FileSearchToolCallResults"]] + + +class ItemFieldFunctionShellCall(TypedDict, total=False): + """Shell tool call. + + :ivar type: The type of the item. Always ``shell_call``. Required. SHELL_CALL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.SHELL_CALL + :ivar id: The unique ID of the shell tool call. Populated when this item is returned via API. + Required. + :vartype id: str + :ivar call_id: The unique ID of the shell tool call generated by the model. Required. + :vartype call_id: str + :ivar action: The shell commands and limits that describe how to run the tool call. Required. + :vartype action: ~azure.ai.agentserver.responses.models.types.FunctionShellAction + :ivar status: The status of the shell call. One of ``in_progress``, ``completed``, or + ``incomplete``. Required. Known values are: "in_progress", "completed", and "incomplete". + :vartype status: str or ~azure.ai.agentserver.responses.models.models.LocalShellCallStatus + :ivar environment: Required. + :vartype environment: ~azure.ai.agentserver.responses.models.types.FunctionShellCallEnvironment + :ivar created_by: The ID of the entity that created this tool call. + :vartype created_by: str + """ + + type: Required[Literal[ItemFieldType.SHELL_CALL]] + """The type of the item. Always ``shell_call``. Required. SHELL_CALL.""" + id: Required[str] + """The unique ID of the shell tool call. Populated when this item is returned via API. Required.""" + call_id: Required[str] + """The unique ID of the shell tool call generated by the model. Required.""" + action: Required["FunctionShellAction"] + """The shell commands and limits that describe how to run the tool call. Required.""" + status: Required[LocalShellCallStatus] + """The status of the shell call. One of ``in_progress``, ``completed``, or ``incomplete``. + Required. Known values are: \"in_progress\", \"completed\", and \"incomplete\".""" + environment: Required[Optional["FunctionShellCallEnvironment"]] + """Required.""" + created_by: str + """The ID of the entity that created this tool call.""" + + +class ItemFieldFunctionShellCallOutput(TypedDict, total=False): + """Shell call output. + + :ivar type: The type of the shell call output. Always ``shell_call_output``. Required. + SHELL_CALL_OUTPUT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.SHELL_CALL_OUTPUT + :ivar id: The unique ID of the shell call output. Populated when this item is returned via API. + Required. + :vartype id: str + :ivar call_id: The unique ID of the shell tool call generated by the model. Required. + :vartype call_id: str + :ivar status: The status of the shell call output. One of ``in_progress``, ``completed``, or + ``incomplete``. Required. Known values are: "in_progress", "completed", and "incomplete". + :vartype status: str or + ~azure.ai.agentserver.responses.models.models.LocalShellCallOutputStatusEnum + :ivar output: An array of shell call output contents. Required. + :vartype output: + list[~azure.ai.agentserver.responses.models.types.FunctionShellCallOutputContent] + :ivar max_output_length: Required. + :vartype max_output_length: int + :ivar created_by: The identifier of the actor that created the item. + :vartype created_by: str + """ + + type: Required[Literal[ItemFieldType.SHELL_CALL_OUTPUT]] + """The type of the shell call output. Always ``shell_call_output``. Required. SHELL_CALL_OUTPUT.""" + id: Required[str] + """The unique ID of the shell call output. Populated when this item is returned via API. Required.""" + call_id: Required[str] + """The unique ID of the shell tool call generated by the model. Required.""" + status: Required[LocalShellCallOutputStatusEnum] + """The status of the shell call output. One of ``in_progress``, ``completed``, or ``incomplete``. + Required. Known values are: \"in_progress\", \"completed\", and \"incomplete\".""" + output: Required[list["FunctionShellCallOutputContent"]] + """An array of shell call output contents. Required.""" + max_output_length: Required[Optional[int]] + """Required.""" + created_by: str + """The identifier of the actor that created the item.""" + + +class ItemFieldFunctionToolCall(TypedDict, total=False): + """Function tool call. + + :ivar id: The unique ID of the function tool call. + :vartype id: str + :ivar type: The type of the function tool call. Always ``function_call``. Required. + FUNCTION_CALL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.FUNCTION_CALL + :ivar call_id: The unique ID of the function tool call generated by the model. Required. + :vartype call_id: str + :ivar name: The name of the function to run. Required. + :vartype name: str + :ivar arguments: A JSON string of the arguments to pass to the function. Required. + :vartype arguments: str + :ivar status: The status of the item. One of ``in_progress``, ``completed``, or ``incomplete``. + Populated when items are returned via API. Is one of the following types: + Literal["in_progress"], Literal["completed"], Literal["incomplete"] + :vartype status: str or str or str + """ + + id: str + """The unique ID of the function tool call.""" + type: Required[Literal[ItemFieldType.FUNCTION_CALL]] + """The type of the function tool call. Always ``function_call``. Required. FUNCTION_CALL.""" + call_id: Required[str] + """The unique ID of the function tool call generated by the model. Required.""" + name: Required[str] + """The name of the function to run. Required.""" + arguments: Required[str] + """A JSON string of the arguments to pass to the function. Required.""" + status: Literal["in_progress", "completed", "incomplete"] + """The status of the item. One of ``in_progress``, ``completed``, or ``incomplete``. Populated + when items are returned via API. Is one of the following types: Literal[\"in_progress\"], + Literal[\"completed\"], Literal[\"incomplete\"]""" + + +class ItemFieldImageGenToolCall(TypedDict, total=False): + """Image generation call. + + :ivar type: The type of the image generation call. Always ``image_generation_call``. Required. + IMAGE_GENERATION_CALL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.IMAGE_GENERATION_CALL + :ivar id: The unique ID of the image generation call. Required. + :vartype id: str + :ivar status: The status of the image generation call. Required. Is one of the following types: + Literal["in_progress"], Literal["completed"], Literal["generating"], Literal["failed"] + :vartype status: str or str or str or str + :ivar result: Required. + :vartype result: str + """ + + type: Required[Literal[ItemFieldType.IMAGE_GENERATION_CALL]] + """The type of the image generation call. Always ``image_generation_call``. Required. + IMAGE_GENERATION_CALL.""" + id: Required[str] + """The unique ID of the image generation call. Required.""" + status: Required[Literal["in_progress", "completed", "generating", "failed"]] + """The status of the image generation call. Required. Is one of the following types: + Literal[\"in_progress\"], Literal[\"completed\"], Literal[\"generating\"], Literal[\"failed\"]""" + result: Required[Optional[str]] + """Required.""" + + +class ItemFieldLocalShellToolCall(TypedDict, total=False): + """Local shell call. + + :ivar type: The type of the local shell call. Always ``local_shell_call``. Required. + LOCAL_SHELL_CALL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.LOCAL_SHELL_CALL + :ivar id: The unique ID of the local shell call. Required. + :vartype id: str + :ivar call_id: The unique ID of the local shell tool call generated by the model. Required. + :vartype call_id: str + :ivar action: Required. + :vartype action: ~azure.ai.agentserver.responses.models.types.LocalShellExecAction + :ivar status: The status of the local shell call. Required. Is one of the following types: + Literal["in_progress"], Literal["completed"], Literal["incomplete"] + :vartype status: str or str or str + """ + + type: Required[Literal[ItemFieldType.LOCAL_SHELL_CALL]] + """The type of the local shell call. Always ``local_shell_call``. Required. LOCAL_SHELL_CALL.""" + id: Required[str] + """The unique ID of the local shell call. Required.""" + call_id: Required[str] + """The unique ID of the local shell tool call generated by the model. Required.""" + action: Required["LocalShellExecAction"] + """Required.""" + status: Required[Literal["in_progress", "completed", "incomplete"]] + """The status of the local shell call. Required. Is one of the following types: + Literal[\"in_progress\"], Literal[\"completed\"], Literal[\"incomplete\"]""" + + +class ItemFieldLocalShellToolCallOutput(TypedDict, total=False): + """Local shell call output. + + :ivar type: The type of the local shell tool call output. Always ``local_shell_call_output``. + Required. LOCAL_SHELL_CALL_OUTPUT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.LOCAL_SHELL_CALL_OUTPUT + :ivar id: The unique ID of the local shell tool call generated by the model. Required. + :vartype id: str + :ivar output: A JSON string of the output of the local shell tool call. Required. + :vartype output: str + :ivar status: Is one of the following types: Literal["in_progress"], Literal["completed"], + Literal["incomplete"] + :vartype status: str or str or str + """ + + type: Required[Literal[ItemFieldType.LOCAL_SHELL_CALL_OUTPUT]] + """The type of the local shell tool call output. Always ``local_shell_call_output``. Required. + LOCAL_SHELL_CALL_OUTPUT.""" + id: Required[str] + """The unique ID of the local shell tool call generated by the model. Required.""" + output: Required[str] + """A JSON string of the output of the local shell tool call. Required.""" + status: Optional[Literal["in_progress", "completed", "incomplete"]] + """Is one of the following types: Literal[\"in_progress\"], Literal[\"completed\"], + Literal[\"incomplete\"]""" + + +class ItemFieldMcpApprovalRequest(TypedDict, total=False): + """MCP approval request. + + :ivar type: The type of the item. Always ``mcp_approval_request``. Required. + MCP_APPROVAL_REQUEST. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.MCP_APPROVAL_REQUEST + :ivar id: The unique ID of the approval request. Required. + :vartype id: str + :ivar server_label: The label of the MCP server making the request. Required. + :vartype server_label: str + :ivar name: The name of the tool to run. Required. + :vartype name: str + :ivar arguments: A JSON string of arguments for the tool. Required. + :vartype arguments: str + """ + + type: Required[Literal[ItemFieldType.MCP_APPROVAL_REQUEST]] + """The type of the item. Always ``mcp_approval_request``. Required. MCP_APPROVAL_REQUEST.""" + id: Required[str] + """The unique ID of the approval request. Required.""" + server_label: Required[str] + """The label of the MCP server making the request. Required.""" + name: Required[str] + """The name of the tool to run. Required.""" + arguments: Required[str] + """A JSON string of arguments for the tool. Required.""" + + +class ItemFieldMcpApprovalResponseResource(TypedDict, total=False): + """MCP approval response. + + :ivar type: The type of the item. Always ``mcp_approval_response``. Required. + MCP_APPROVAL_RESPONSE. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.MCP_APPROVAL_RESPONSE + :ivar id: The unique ID of the approval response. Required. + :vartype id: str + :ivar approval_request_id: The ID of the approval request being answered. Required. + :vartype approval_request_id: str + :ivar approve: Whether the request was approved. Required. + :vartype approve: bool + :ivar reason: + :vartype reason: str + """ + + type: Required[Literal[ItemFieldType.MCP_APPROVAL_RESPONSE]] + """The type of the item. Always ``mcp_approval_response``. Required. MCP_APPROVAL_RESPONSE.""" + id: Required[str] + """The unique ID of the approval response. Required.""" + approval_request_id: Required[str] + """The ID of the approval request being answered. Required.""" + approve: Required[bool] + """Whether the request was approved. Required.""" + reason: Optional[str] + + +class ItemFieldMcpListTools(TypedDict, total=False): + """MCP list tools. + + :ivar type: The type of the item. Always ``mcp_list_tools``. Required. MCP_LIST_TOOLS. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.MCP_LIST_TOOLS + :ivar id: The unique ID of the list. Required. + :vartype id: str + :ivar server_label: The label of the MCP server. Required. + :vartype server_label: str + :ivar tools: The tools available on the server. Required. + :vartype tools: list[~azure.ai.agentserver.responses.models.types.MCPListToolsTool] + :ivar error: + :vartype error: str + """ + + type: Required[Literal[ItemFieldType.MCP_LIST_TOOLS]] + """The type of the item. Always ``mcp_list_tools``. Required. MCP_LIST_TOOLS.""" + id: Required[str] + """The unique ID of the list. Required.""" + server_label: Required[str] + """The label of the MCP server. Required.""" + tools: Required[list["MCPListToolsTool"]] + """The tools available on the server. Required.""" + error: Optional[str] + + +class ItemFieldMcpToolCall(TypedDict, total=False): + """MCP tool call. + + :ivar type: The type of the item. Always ``mcp_call``. Required. MCP_CALL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.MCP_CALL + :ivar id: The unique ID of the tool call. Required. + :vartype id: str + :ivar server_label: The label of the MCP server running the tool. Required. + :vartype server_label: str + :ivar name: The name of the tool that was run. Required. + :vartype name: str + :ivar arguments: A JSON string of the arguments passed to the tool. Required. + :vartype arguments: str + :ivar output: + :vartype output: str + :ivar error: + :vartype error: dict[str, any] + :ivar status: The status of the tool call. One of ``in_progress``, ``completed``, + ``incomplete``, ``calling``, or ``failed``. Known values are: "in_progress", "completed", + "incomplete", "calling", and "failed". + :vartype status: str or ~azure.ai.agentserver.responses.models.models.MCPToolCallStatus + :ivar approval_request_id: + :vartype approval_request_id: str + """ + + type: Required[Literal[ItemFieldType.MCP_CALL]] + """The type of the item. Always ``mcp_call``. Required. MCP_CALL.""" + id: Required[str] + """The unique ID of the tool call. Required.""" + server_label: Required[str] + """The label of the MCP server running the tool. Required.""" + name: Required[str] + """The name of the tool that was run. Required.""" + arguments: Required[str] + """A JSON string of the arguments passed to the tool. Required.""" + output: Optional[str] + error: dict[str, Any] + status: MCPToolCallStatus + """The status of the tool call. One of ``in_progress``, ``completed``, ``incomplete``, + ``calling``, or ``failed``. Known values are: \"in_progress\", \"completed\", \"incomplete\", + \"calling\", and \"failed\".""" + approval_request_id: Optional[str] + + +class ItemFieldMessage(TypedDict, total=False): + """Message. + + :ivar type: The type of the message. Always set to ``message``. Required. MESSAGE. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.MESSAGE + :ivar id: The unique ID of the message. Required. + :vartype id: str + :ivar status: The status of item. One of ``in_progress``, ``completed``, or ``incomplete``. + Populated when items are returned via API. Required. Known values are: "in_progress", + "completed", and "incomplete". + :vartype status: str or ~azure.ai.agentserver.responses.models.models.MessageStatus + :ivar role: The role of the message. One of ``unknown``, ``user``, ``assistant``, ``system``, + ``critic``, ``discriminator``, ``developer``, or ``tool``. Required. Known values are: + "unknown", "user", "assistant", "system", "critic", "discriminator", "developer", and "tool". + :vartype role: str or ~azure.ai.agentserver.responses.models.models.MessageRole + :ivar content: The content of the message. Required. + :vartype content: list[~azure.ai.agentserver.responses.models.types.MessageContent] + """ + + type: Required[Literal[ItemFieldType.MESSAGE]] + """The type of the message. Always set to ``message``. Required. MESSAGE.""" + id: Required[str] + """The unique ID of the message. Required.""" + status: Required[MessageStatus] + """The status of item. One of ``in_progress``, ``completed``, or ``incomplete``. Populated when + items are returned via API. Required. Known values are: \"in_progress\", \"completed\", and + \"incomplete\".""" + role: Required[MessageRole] + """The role of the message. One of ``unknown``, ``user``, ``assistant``, ``system``, ``critic``, + ``discriminator``, ``developer``, or ``tool``. Required. Known values are: \"unknown\", + \"user\", \"assistant\", \"system\", \"critic\", \"discriminator\", \"developer\", and + \"tool\".""" + content: Required[list["MessageContent"]] + """The content of the message. Required.""" + + +class ItemFieldReasoningItem(TypedDict, total=False): + """Reasoning. + + :ivar type: The type of the object. Always ``reasoning``. Required. REASONING. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.REASONING + :ivar id: The unique identifier of the reasoning content. Required. + :vartype id: str + :ivar encrypted_content: + :vartype encrypted_content: str + :ivar summary: Reasoning summary content. Required. + :vartype summary: list[~azure.ai.agentserver.responses.models.types.SummaryTextContent] + :ivar content: Reasoning text content. + :vartype content: list[~azure.ai.agentserver.responses.models.types.ReasoningTextContent] + :ivar status: The status of the item. One of ``in_progress``, ``completed``, or ``incomplete``. + Populated when items are returned via API. Is one of the following types: + Literal["in_progress"], Literal["completed"], Literal["incomplete"] + :vartype status: str or str or str + """ + + type: Required[Literal[ItemFieldType.REASONING]] + """The type of the object. Always ``reasoning``. Required. REASONING.""" + id: Required[str] + """The unique identifier of the reasoning content. Required.""" + encrypted_content: Optional[str] + summary: Required[list["SummaryTextContent"]] + """Reasoning summary content. Required.""" + content: list["ReasoningTextContent"] + """Reasoning text content.""" + status: Literal["in_progress", "completed", "incomplete"] + """The status of the item. One of ``in_progress``, ``completed``, or ``incomplete``. Populated + when items are returned via API. Is one of the following types: Literal[\"in_progress\"], + Literal[\"completed\"], Literal[\"incomplete\"]""" + + +class ItemFieldWebSearchToolCall(TypedDict, total=False): + """Web search tool call. + + :ivar id: The unique ID of the web search tool call. Required. + :vartype id: str + :ivar type: The type of the web search tool call. Always ``web_search_call``. Required. + WEB_SEARCH_CALL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.WEB_SEARCH_CALL + :ivar status: The status of the web search tool call. Required. Is one of the following types: + Literal["in_progress"], Literal["searching"], Literal["completed"], Literal["failed"] + :vartype status: str or str or str or str + :ivar action: An object describing the specific action taken in this web search call. Includes + details on how the model used the web (search, open_page, find_in_page). Required. Is one of + the following types: WebSearchActionSearch, WebSearchActionOpenPage, WebSearchActionFind + :vartype action: ~azure.ai.agentserver.responses.models.types.WebSearchActionSearch or + ~azure.ai.agentserver.responses.models.types.WebSearchActionOpenPage or + ~azure.ai.agentserver.responses.models.types.WebSearchActionFind + """ + + id: Required[str] + """The unique ID of the web search tool call. Required.""" + type: Required[Literal[ItemFieldType.WEB_SEARCH_CALL]] + """The type of the web search tool call. Always ``web_search_call``. Required. WEB_SEARCH_CALL.""" + status: Required[Literal["in_progress", "searching", "completed", "failed"]] + """The status of the web search tool call. Required. Is one of the following types: + Literal[\"in_progress\"], Literal[\"searching\"], Literal[\"completed\"], Literal[\"failed\"]""" + action: Required[Union["WebSearchActionSearch", "WebSearchActionOpenPage", "WebSearchActionFind"]] + """An object describing the specific action taken in this web search call. Includes details on how + the model used the web (search, open_page, find_in_page). Required. Is one of the following + types: WebSearchActionSearch, WebSearchActionOpenPage, WebSearchActionFind""" + + +class ItemFileSearchToolCall(TypedDict, total=False): + """File search tool call. + + :ivar id: The unique ID of the file search tool call. Required. + :vartype id: str + :ivar type: The type of the file search tool call. Always ``file_search_call``. Required. + FILE_SEARCH_CALL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.FILE_SEARCH_CALL + :ivar status: The status of the file search tool call. One of ``in_progress``, ``searching``, + ``incomplete`` or ``failed``,. Required. Is one of the following types: Literal["in_progress"], + Literal["searching"], Literal["completed"], Literal["incomplete"], Literal["failed"] + :vartype status: str or str or str or str or str + :ivar queries: The queries used to search for files. Required. + :vartype queries: list[str] + :ivar results: + :vartype results: list[~azure.ai.agentserver.responses.models.types.FileSearchToolCallResults] + """ + + id: Required[str] + """The unique ID of the file search tool call. Required.""" + type: Required[Literal[ItemType.FILE_SEARCH_CALL]] + """The type of the file search tool call. Always ``file_search_call``. Required. FILE_SEARCH_CALL.""" + status: Required[Literal["in_progress", "searching", "completed", "incomplete", "failed"]] + """The status of the file search tool call. One of ``in_progress``, ``searching``, ``incomplete`` + or ``failed``,. Required. Is one of the following types: Literal[\"in_progress\"], + Literal[\"searching\"], Literal[\"completed\"], Literal[\"incomplete\"], Literal[\"failed\"]""" + queries: Required[list[str]] + """The queries used to search for files. Required.""" + results: Optional[list["FileSearchToolCallResults"]] + + +class ItemFunctionToolCall(TypedDict, total=False): + """Function tool call. + + :ivar id: The unique ID of the function tool call. + :vartype id: str + :ivar type: The type of the function tool call. Always ``function_call``. Required. + FUNCTION_CALL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.FUNCTION_CALL + :ivar call_id: The unique ID of the function tool call generated by the model. Required. + :vartype call_id: str + :ivar name: The name of the function to run. Required. + :vartype name: str + :ivar arguments: A JSON string of the arguments to pass to the function. Required. + :vartype arguments: str + :ivar status: The status of the item. One of ``in_progress``, ``completed``, or ``incomplete``. + Populated when items are returned via API. Is one of the following types: + Literal["in_progress"], Literal["completed"], Literal["incomplete"] + :vartype status: str or str or str + """ + + id: str + """The unique ID of the function tool call.""" + type: Required[Literal[ItemType.FUNCTION_CALL]] + """The type of the function tool call. Always ``function_call``. Required. FUNCTION_CALL.""" + call_id: Required[str] + """The unique ID of the function tool call generated by the model. Required.""" + name: Required[str] + """The name of the function to run. Required.""" + arguments: Required[str] + """A JSON string of the arguments to pass to the function. Required.""" + status: Literal["in_progress", "completed", "incomplete"] + """The status of the item. One of ``in_progress``, ``completed``, or ``incomplete``. Populated + when items are returned via API. Is one of the following types: Literal[\"in_progress\"], + Literal[\"completed\"], Literal[\"incomplete\"]""" + + +class ItemImageGenToolCall(TypedDict, total=False): + """Image generation call. + + :ivar type: The type of the image generation call. Always ``image_generation_call``. Required. + IMAGE_GENERATION_CALL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.IMAGE_GENERATION_CALL + :ivar id: The unique ID of the image generation call. Required. + :vartype id: str + :ivar status: The status of the image generation call. Required. Is one of the following types: + Literal["in_progress"], Literal["completed"], Literal["generating"], Literal["failed"] + :vartype status: str or str or str or str + :ivar result: Required. + :vartype result: str + """ + + type: Required[Literal[ItemType.IMAGE_GENERATION_CALL]] + """The type of the image generation call. Always ``image_generation_call``. Required. + IMAGE_GENERATION_CALL.""" + id: Required[str] + """The unique ID of the image generation call. Required.""" + status: Required[Literal["in_progress", "completed", "generating", "failed"]] + """The status of the image generation call. Required. Is one of the following types: + Literal[\"in_progress\"], Literal[\"completed\"], Literal[\"generating\"], Literal[\"failed\"]""" + result: Required[Optional[str]] + """Required.""" + + +class ItemLocalShellToolCall(TypedDict, total=False): + """Local shell call. + + :ivar type: The type of the local shell call. Always ``local_shell_call``. Required. + LOCAL_SHELL_CALL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.LOCAL_SHELL_CALL + :ivar id: The unique ID of the local shell call. Required. + :vartype id: str + :ivar call_id: The unique ID of the local shell tool call generated by the model. Required. + :vartype call_id: str + :ivar action: Required. + :vartype action: ~azure.ai.agentserver.responses.models.types.LocalShellExecAction + :ivar status: The status of the local shell call. Required. Is one of the following types: + Literal["in_progress"], Literal["completed"], Literal["incomplete"] + :vartype status: str or str or str + """ + + type: Required[Literal[ItemType.LOCAL_SHELL_CALL]] + """The type of the local shell call. Always ``local_shell_call``. Required. LOCAL_SHELL_CALL.""" + id: Required[str] + """The unique ID of the local shell call. Required.""" + call_id: Required[str] + """The unique ID of the local shell tool call generated by the model. Required.""" + action: Required["LocalShellExecAction"] + """Required.""" + status: Required[Literal["in_progress", "completed", "incomplete"]] + """The status of the local shell call. Required. Is one of the following types: + Literal[\"in_progress\"], Literal[\"completed\"], Literal[\"incomplete\"]""" + + +class ItemLocalShellToolCallOutput(TypedDict, total=False): + """Local shell call output. + + :ivar type: The type of the local shell tool call output. Always ``local_shell_call_output``. + Required. LOCAL_SHELL_CALL_OUTPUT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.LOCAL_SHELL_CALL_OUTPUT + :ivar id: The unique ID of the local shell tool call generated by the model. Required. + :vartype id: str + :ivar output: A JSON string of the output of the local shell tool call. Required. + :vartype output: str + :ivar status: Is one of the following types: Literal["in_progress"], Literal["completed"], + Literal["incomplete"] + :vartype status: str or str or str + """ + + type: Required[Literal[ItemType.LOCAL_SHELL_CALL_OUTPUT]] + """The type of the local shell tool call output. Always ``local_shell_call_output``. Required. + LOCAL_SHELL_CALL_OUTPUT.""" + id: Required[str] + """The unique ID of the local shell tool call generated by the model. Required.""" + output: Required[str] + """A JSON string of the output of the local shell tool call. Required.""" + status: Optional[Literal["in_progress", "completed", "incomplete"]] + """Is one of the following types: Literal[\"in_progress\"], Literal[\"completed\"], + Literal[\"incomplete\"]""" + + +class ItemMcpApprovalRequest(TypedDict, total=False): + """MCP approval request. + + :ivar type: The type of the item. Always ``mcp_approval_request``. Required. + MCP_APPROVAL_REQUEST. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.MCP_APPROVAL_REQUEST + :ivar id: The unique ID of the approval request. Required. + :vartype id: str + :ivar server_label: The label of the MCP server making the request. Required. + :vartype server_label: str + :ivar name: The name of the tool to run. Required. + :vartype name: str + :ivar arguments: A JSON string of arguments for the tool. Required. + :vartype arguments: str + """ + + type: Required[Literal[ItemType.MCP_APPROVAL_REQUEST]] + """The type of the item. Always ``mcp_approval_request``. Required. MCP_APPROVAL_REQUEST.""" + id: Required[str] + """The unique ID of the approval request. Required.""" + server_label: Required[str] + """The label of the MCP server making the request. Required.""" + name: Required[str] + """The name of the tool to run. Required.""" + arguments: Required[str] + """A JSON string of arguments for the tool. Required.""" + + +class ItemMcpListTools(TypedDict, total=False): + """MCP list tools. + + :ivar type: The type of the item. Always ``mcp_list_tools``. Required. MCP_LIST_TOOLS. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.MCP_LIST_TOOLS + :ivar id: The unique ID of the list. Required. + :vartype id: str + :ivar server_label: The label of the MCP server. Required. + :vartype server_label: str + :ivar tools: The tools available on the server. Required. + :vartype tools: list[~azure.ai.agentserver.responses.models.types.MCPListToolsTool] + :ivar error: + :vartype error: str + """ + + type: Required[Literal[ItemType.MCP_LIST_TOOLS]] + """The type of the item. Always ``mcp_list_tools``. Required. MCP_LIST_TOOLS.""" + id: Required[str] + """The unique ID of the list. Required.""" + server_label: Required[str] + """The label of the MCP server. Required.""" + tools: Required[list["MCPListToolsTool"]] + """The tools available on the server. Required.""" + error: Optional[str] + + +class ItemMcpToolCall(TypedDict, total=False): + """MCP tool call. + + :ivar type: The type of the item. Always ``mcp_call``. Required. MCP_CALL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.MCP_CALL + :ivar id: The unique ID of the tool call. Required. + :vartype id: str + :ivar server_label: The label of the MCP server running the tool. Required. + :vartype server_label: str + :ivar name: The name of the tool that was run. Required. + :vartype name: str + :ivar arguments: A JSON string of the arguments passed to the tool. Required. + :vartype arguments: str + :ivar output: + :vartype output: str + :ivar error: + :vartype error: dict[str, any] + :ivar status: The status of the tool call. One of ``in_progress``, ``completed``, + ``incomplete``, ``calling``, or ``failed``. Known values are: "in_progress", "completed", + "incomplete", "calling", and "failed". + :vartype status: str or ~azure.ai.agentserver.responses.models.models.MCPToolCallStatus + :ivar approval_request_id: + :vartype approval_request_id: str + """ + + type: Required[Literal[ItemType.MCP_CALL]] + """The type of the item. Always ``mcp_call``. Required. MCP_CALL.""" + id: Required[str] + """The unique ID of the tool call. Required.""" + server_label: Required[str] + """The label of the MCP server running the tool. Required.""" + name: Required[str] + """The name of the tool that was run. Required.""" + arguments: Required[str] + """A JSON string of the arguments passed to the tool. Required.""" + output: Optional[str] + error: dict[str, Any] + status: MCPToolCallStatus + """The status of the tool call. One of ``in_progress``, ``completed``, ``incomplete``, + ``calling``, or ``failed``. Known values are: \"in_progress\", \"completed\", \"incomplete\", + \"calling\", and \"failed\".""" + approval_request_id: Optional[str] + + +class ItemMessage(TypedDict, total=False): + """Message. + + :ivar type: The type of the message. Always set to ``message``. Required. MESSAGE. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.MESSAGE + :ivar role: The role of the message. One of ``unknown``, ``user``, ``assistant``, ``system``, + ``critic``, ``discriminator``, ``developer``, or ``tool``. Required. Known values are: + "unknown", "user", "assistant", "system", "critic", "discriminator", "developer", and "tool". + :vartype role: str or ~azure.ai.agentserver.responses.models.models.MessageRole + :ivar content: Required. Is either a str type or a [MessageContent] type. + :vartype content: str or list[~azure.ai.agentserver.responses.models.types.MessageContent] + """ + + type: Required[Literal[ItemType.MESSAGE]] + """The type of the message. Always set to ``message``. Required. MESSAGE.""" + role: Required[MessageRole] + """The role of the message. One of ``unknown``, ``user``, ``assistant``, ``system``, ``critic``, + ``discriminator``, ``developer``, or ``tool``. Required. Known values are: \"unknown\", + \"user\", \"assistant\", \"system\", \"critic\", \"discriminator\", \"developer\", and + \"tool\".""" + content: Required[Union[str, list["MessageContent"]]] + """Required. Is either a str type or a [MessageContent] type.""" + + +class ItemOutputMessage(TypedDict, total=False): + """Output message. + + :ivar id: The unique ID of the output message. Required. + :vartype id: str + :ivar type: The type of the output message. Always ``message``. Required. OUTPUT_MESSAGE. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.OUTPUT_MESSAGE + :ivar role: The role of the output message. Always ``assistant``. Required. Default value is + "assistant". + :vartype role: str + :ivar content: The content of the output message. Required. + :vartype content: list[~azure.ai.agentserver.responses.models.types.OutputMessageContent] + :ivar status: The status of the message input. One of ``in_progress``, ``completed``, or + ``incomplete``. Populated when input items are returned via API. Required. Is one of the + following types: Literal["in_progress"], Literal["completed"], Literal["incomplete"] + :vartype status: str or str or str + """ + + id: Required[str] + """The unique ID of the output message. Required.""" + type: Required[Literal[ItemType.OUTPUT_MESSAGE]] + """The type of the output message. Always ``message``. Required. OUTPUT_MESSAGE.""" + role: Required[Literal["assistant"]] + """The role of the output message. Always ``assistant``. Required. Default value is \"assistant\".""" + content: Required[list["OutputMessageContent"]] + """The content of the output message. Required.""" + status: Required[Literal["in_progress", "completed", "incomplete"]] + """The status of the message input. One of ``in_progress``, ``completed``, or ``incomplete``. + Populated when input items are returned via API. Required. Is one of the following types: + Literal[\"in_progress\"], Literal[\"completed\"], Literal[\"incomplete\"]""" + + +class ItemReasoningItem(TypedDict, total=False): + """Reasoning. + + :ivar type: The type of the object. Always ``reasoning``. Required. REASONING. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.REASONING + :ivar id: The unique identifier of the reasoning content. Required. + :vartype id: str + :ivar encrypted_content: + :vartype encrypted_content: str + :ivar summary: Reasoning summary content. Required. + :vartype summary: list[~azure.ai.agentserver.responses.models.types.SummaryTextContent] + :ivar content: Reasoning text content. + :vartype content: list[~azure.ai.agentserver.responses.models.types.ReasoningTextContent] + :ivar status: The status of the item. One of ``in_progress``, ``completed``, or ``incomplete``. + Populated when items are returned via API. Is one of the following types: + Literal["in_progress"], Literal["completed"], Literal["incomplete"] + :vartype status: str or str or str + """ + + type: Required[Literal[ItemType.REASONING]] + """The type of the object. Always ``reasoning``. Required. REASONING.""" + id: Required[str] + """The unique identifier of the reasoning content. Required.""" + encrypted_content: Optional[str] + summary: Required[list["SummaryTextContent"]] + """Reasoning summary content. Required.""" + content: list["ReasoningTextContent"] + """Reasoning text content.""" + status: Literal["in_progress", "completed", "incomplete"] + """The status of the item. One of ``in_progress``, ``completed``, or ``incomplete``. Populated + when items are returned via API. Is one of the following types: Literal[\"in_progress\"], + Literal[\"completed\"], Literal[\"incomplete\"]""" + + +class ItemReferenceParam(TypedDict, total=False): + """Item reference. + + :ivar type: The type of item to reference. Always ``item_reference``. Required. ITEM_REFERENCE. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.ITEM_REFERENCE + :ivar id: The ID of the item to reference. Required. + :vartype id: str + """ + + type: Required[Literal[ItemType.ITEM_REFERENCE]] + """The type of item to reference. Always ``item_reference``. Required. ITEM_REFERENCE.""" + id: Required[str] + """The ID of the item to reference. Required.""" + + +class ItemWebSearchToolCall(TypedDict, total=False): + """Web search tool call. + + :ivar id: The unique ID of the web search tool call. Required. + :vartype id: str + :ivar type: The type of the web search tool call. Always ``web_search_call``. Required. + WEB_SEARCH_CALL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.WEB_SEARCH_CALL + :ivar status: The status of the web search tool call. Required. Is one of the following types: + Literal["in_progress"], Literal["searching"], Literal["completed"], Literal["failed"] + :vartype status: str or str or str or str + :ivar action: An object describing the specific action taken in this web search call. Includes + details on how the model used the web (search, open_page, find_in_page). Required. Is one of + the following types: WebSearchActionSearch, WebSearchActionOpenPage, WebSearchActionFind + :vartype action: ~azure.ai.agentserver.responses.models.types.WebSearchActionSearch or + ~azure.ai.agentserver.responses.models.types.WebSearchActionOpenPage or + ~azure.ai.agentserver.responses.models.types.WebSearchActionFind + """ + + id: Required[str] + """The unique ID of the web search tool call. Required.""" + type: Required[Literal[ItemType.WEB_SEARCH_CALL]] + """The type of the web search tool call. Always ``web_search_call``. Required. WEB_SEARCH_CALL.""" + status: Required[Literal["in_progress", "searching", "completed", "failed"]] + """The status of the web search tool call. Required. Is one of the following types: + Literal[\"in_progress\"], Literal[\"searching\"], Literal[\"completed\"], Literal[\"failed\"]""" + action: Required[Union["WebSearchActionSearch", "WebSearchActionOpenPage", "WebSearchActionFind"]] + """An object describing the specific action taken in this web search call. Includes details on how + the model used the web (search, open_page, find_in_page). Required. Is one of the following + types: WebSearchActionSearch, WebSearchActionOpenPage, WebSearchActionFind""" + + +class KeyPressAction(TypedDict, total=False): + """KeyPress. + + :ivar type: Specifies the event type. For a keypress action, this property is always set to + ``keypress``. Required. KEYPRESS. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.KEYPRESS + :ivar keys_property: The combination of keys the model is requesting to be pressed. This is an + array of strings, each representing a key. Required. + :vartype keys_property: list[str] + """ + + type: Required[Literal[ComputerActionType.KEYPRESS]] + """Specifies the event type. For a keypress action, this property is always set to ``keypress``. + Required. KEYPRESS.""" + keys: Required[list[str]] + """The combination of keys the model is requesting to be pressed. This is an array of strings, + each representing a key. Required.""" + + +class LocalEnvironmentResource(TypedDict, total=False): + """Local Environment. + + :ivar type: The environment type. Always ``local``. Required. LOCAL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.LOCAL + """ + + type: Required[Literal[FunctionShellCallEnvironmentType.LOCAL]] + """The environment type. Always ``local``. Required. LOCAL.""" + + +class LocalShellExecAction(TypedDict, total=False): + """Local shell exec action. + + :ivar type: The type of the local shell action. Always ``exec``. Required. Default value is + "exec". + :vartype type: str + :ivar command: The command to run. Required. + :vartype command: list[str] + :ivar timeout_ms: + :vartype timeout_ms: int + :ivar working_directory: + :vartype working_directory: str + :ivar env: Environment variables to set for the command. Required. + :vartype env: dict[str, str] + :ivar user: + :vartype user: str + """ + + type: Required[Literal["exec"]] + """The type of the local shell action. Always ``exec``. Required. Default value is \"exec\".""" + command: Required[list[str]] + """The command to run. Required.""" + timeout_ms: Optional[int] + working_directory: Optional[str] + env: Required[dict[str, str]] + """Environment variables to set for the command. Required.""" + user: Optional[str] + + +class LocalShellToolParam(TypedDict, total=False): + """Local shell tool. + + :ivar type: The type of the local shell tool. Always ``local_shell``. Required. LOCAL_SHELL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.LOCAL_SHELL + :ivar name: Optional user-defined name for this tool or configuration. + :vartype name: str + :ivar description: Optional user-defined description for this tool or configuration. + :vartype description: str + """ + + type: Required[Literal[ToolType.LOCAL_SHELL]] + """The type of the local shell tool. Always ``local_shell``. Required. LOCAL_SHELL.""" + name: str + """Optional user-defined name for this tool or configuration.""" + description: str + """Optional user-defined description for this tool or configuration.""" + + +class LocalSkillParam(TypedDict, total=False): + """LocalSkillParam. + + :ivar name: The name of the skill. Required. + :vartype name: str + :ivar description: The description of the skill. Required. + :vartype description: str + :ivar path: The path to the directory containing the skill. Required. + :vartype path: str + """ + + name: Required[str] + """The name of the skill. Required.""" + description: Required[str] + """The description of the skill. Required.""" + path: Required[str] + """The path to the directory containing the skill. Required.""" + + +class LogProb(TypedDict, total=False): + """Log probability. + + :ivar token: Required. + :vartype token: str + :ivar logprob: Required. + :vartype logprob: float + :ivar bytes: Required. + :vartype bytes: list[int] + :ivar top_logprobs: Required. + :vartype top_logprobs: list[~azure.ai.agentserver.responses.models.types.TopLogProb] + """ + + token: Required[str] + """Required.""" + logprob: Required[float] + """Required.""" + bytes: Required[list[int]] + """Required.""" + top_logprobs: Required[list["TopLogProb"]] + """Required.""" + + +class MCPApprovalResponse(TypedDict, total=False): + """MCP approval response. + + :ivar type: The type of the item. Always ``mcp_approval_response``. Required. + MCP_APPROVAL_RESPONSE. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.MCP_APPROVAL_RESPONSE + :ivar id: + :vartype id: str + :ivar approval_request_id: The ID of the approval request being answered. Required. + :vartype approval_request_id: str + :ivar approve: Whether the request was approved. Required. + :vartype approve: bool + :ivar reason: + :vartype reason: str + """ + + type: Required[Literal[ItemType.MCP_APPROVAL_RESPONSE]] + """The type of the item. Always ``mcp_approval_response``. Required. MCP_APPROVAL_RESPONSE.""" + id: Optional[str] + approval_request_id: Required[str] + """The ID of the approval request being answered. Required.""" + approve: Required[bool] + """Whether the request was approved. Required.""" + reason: Optional[str] + + +class MCPListToolsTool(TypedDict, total=False): + """MCP list tools tool. + + :ivar name: The name of the tool. Required. + :vartype name: str + :ivar description: + :vartype description: str + :ivar input_schema: The JSON schema describing the tool's input. Required. + :vartype input_schema: ~azure.ai.agentserver.responses.models.types.MCPListToolsToolInputSchema + :ivar annotations: + :vartype annotations: ~azure.ai.agentserver.responses.models.types.MCPListToolsToolAnnotations + """ + + name: Required[str] + """The name of the tool. Required.""" + description: Optional[str] + input_schema: Required["MCPListToolsToolInputSchema"] + """The JSON schema describing the tool's input. Required.""" + annotations: Optional["MCPListToolsToolAnnotations"] + + +class MCPListToolsToolAnnotations(TypedDict, total=False): + """MCPListToolsToolAnnotations.""" + + +class MCPListToolsToolInputSchema(TypedDict, total=False): + """MCPListToolsToolInputSchema.""" + + +class MCPTool(TypedDict, total=False): + """MCP tool. + + :ivar type: The type of the MCP tool. Always ``mcp``. Required. MCP. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.MCP + :ivar server_label: A label for this MCP server, used to identify it in tool calls. Required. + :vartype server_label: str + :ivar server_url: The URL for the MCP server. One of ``server_url`` or ``connector_id`` must be + provided. + :vartype server_url: str + :ivar connector_id: Identifier for service connectors, like those available in ChatGPT. One of + ``server_url`` or ``connector_id`` must be provided. Learn more about service connectors `here + `_. Currently supported ``connector_id`` values are: + + * Dropbox: `connector_dropbox` + * Gmail: `connector_gmail` + * Google Calendar: `connector_googlecalendar` + * Google Drive: `connector_googledrive` + * Microsoft Teams: `connector_microsoftteams` + * Outlook Calendar: `connector_outlookcalendar` + * Outlook Email: `connector_outlookemail` + * SharePoint: `connector_sharepoint`. Is one of the following types: + Literal["connector_dropbox"], Literal["connector_gmail"], Literal["connector_googlecalendar"], + Literal["connector_googledrive"], Literal["connector_microsoftteams"], + Literal["connector_outlookcalendar"], Literal["connector_outlookemail"], + Literal["connector_sharepoint"] + :vartype connector_id: str or str or str or str or str or str or str or str + :ivar authorization: An OAuth access token that can be used with a remote MCP server, either + with a custom MCP server URL or a service connector. Your application must handle the OAuth + authorization flow and provide the token here. + :vartype authorization: str + :ivar server_description: Optional description of the MCP server, used to provide more context. + :vartype server_description: str + :ivar headers: + :vartype headers: dict[str, str] + :ivar allowed_tools: Is either a [str] type or a MCPToolFilter type. + :vartype allowed_tools: list[str] or ~azure.ai.agentserver.responses.models.types.MCPToolFilter + :ivar require_approval: Is one of the following types: MCPToolRequireApproval, + Literal["always"], Literal["never"] + :vartype require_approval: ~azure.ai.agentserver.responses.models.types.MCPToolRequireApproval + or str or str + :ivar project_connection_id: The connection ID in the project for the MCP server. The + connection stores authentication and other connection details needed to connect to the MCP + server. + :vartype project_connection_id: str + """ + + type: Required[Literal[ToolType.MCP]] + """The type of the MCP tool. Always ``mcp``. Required. MCP.""" + server_label: Required[str] + """A label for this MCP server, used to identify it in tool calls. Required.""" + server_url: str + """The URL for the MCP server. One of ``server_url`` or ``connector_id`` must be provided.""" + connector_id: Literal[ + "connector_dropbox", + "connector_gmail", + "connector_googlecalendar", + "connector_googledrive", + "connector_microsoftteams", + "connector_outlookcalendar", + "connector_outlookemail", + "connector_sharepoint", + ] + """Identifier for service connectors, like those available in ChatGPT. One of ``server_url`` or + ``connector_id`` must be provided. Learn more about service connectors `here + `_. Currently supported ``connector_id`` values are: + + * Dropbox: `connector_dropbox` + * Gmail: `connector_gmail` + * Google Calendar: `connector_googlecalendar` + * Google Drive: `connector_googledrive` + * Microsoft Teams: `connector_microsoftteams` + * Outlook Calendar: `connector_outlookcalendar` + * Outlook Email: `connector_outlookemail` + * SharePoint: `connector_sharepoint`. Is one of the following types: + Literal[\"connector_dropbox\"], Literal[\"connector_gmail\"], + Literal[\"connector_googlecalendar\"], Literal[\"connector_googledrive\"], + Literal[\"connector_microsoftteams\"], Literal[\"connector_outlookcalendar\"], + Literal[\"connector_outlookemail\"], Literal[\"connector_sharepoint\"]""" + authorization: str + """An OAuth access token that can be used with a remote MCP server, either with a custom MCP + server URL or a service connector. Your application must handle the OAuth authorization flow + and provide the token here.""" + server_description: str + """Optional description of the MCP server, used to provide more context.""" + headers: Optional[dict[str, str]] + allowed_tools: Optional[Union[list[str], "MCPToolFilter"]] + """Is either a [str] type or a MCPToolFilter type.""" + require_approval: Optional[Union["MCPToolRequireApproval", Literal["always"], Literal["never"]]] + """Is one of the following types: MCPToolRequireApproval, Literal[\"always\"], Literal[\"never\"]""" + project_connection_id: str + """The connection ID in the project for the MCP server. The connection stores authentication and + other connection details needed to connect to the MCP server.""" + + +class MCPToolFilter(TypedDict, total=False): + """MCP tool filter. + + :ivar tool_names: MCP allowed tools. + :vartype tool_names: list[str] + :ivar read_only: Indicates whether or not a tool modifies data or is read-only. If an MCP + server is `annotated with `readOnlyHint` + `_, + it will match this filter. + :vartype read_only: bool + """ + + tool_names: list[str] + """MCP allowed tools.""" + read_only: bool + """Indicates whether or not a tool modifies data or is read-only. If an MCP server is `annotated + with `readOnlyHint` + `_, + it will match this filter.""" + + +class MCPToolRequireApproval(TypedDict, total=False): + """MCPToolRequireApproval. + + :ivar always: + :vartype always: ~azure.ai.agentserver.responses.models.types.MCPToolFilter + :ivar never: + :vartype never: ~azure.ai.agentserver.responses.models.types.MCPToolFilter + """ + + always: "MCPToolFilter" + never: "MCPToolFilter" + + +class MemorySearchItem(TypedDict, total=False): + """A retrieved memory item from memory search. + + :ivar memory_item: Retrieved memory item. Required. + :vartype memory_item: ~azure.ai.agentserver.responses.models.types.MemoryItem + """ + + memory_item: Required["MemoryItem"] + """Retrieved memory item. Required.""" + + +class MemorySearchOptions(TypedDict, total=False): + """Memory search options. + + :ivar max_memories: Maximum number of memory items to return. + :vartype max_memories: int + """ + + max_memories: int + """Maximum number of memory items to return.""" + + +class MemorySearchPreviewTool(TypedDict, total=False): + """A tool for integrating memories into the agent. + + :ivar type: The type of the tool. Always ``memory_search_preview``. Required. + MEMORY_SEARCH_PREVIEW. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.MEMORY_SEARCH_PREVIEW + :ivar name: Optional user-defined name for this tool or configuration. + :vartype name: str + :ivar description: Optional user-defined description for this tool or configuration. + :vartype description: str + :ivar memory_store_name: The name of the memory store to use. Required. + :vartype memory_store_name: str + :ivar scope: The namespace used to group and isolate memories, such as a user ID. Limits which + memories can be retrieved or updated. Use special variable ``{{$userId}}`` to scope memories to + the current signed-in user. Required. + :vartype scope: str + :ivar search_options: Options for searching the memory store. + :vartype search_options: ~azure.ai.agentserver.responses.models.types.MemorySearchOptions + :ivar update_delay: Time to wait before updating memories after inactivity (seconds). Default + 300. + :vartype update_delay: int + """ + + type: Required[Literal[ToolType.MEMORY_SEARCH_PREVIEW]] + """The type of the tool. Always ``memory_search_preview``. Required. MEMORY_SEARCH_PREVIEW.""" + name: str + """Optional user-defined name for this tool or configuration.""" + description: str + """Optional user-defined description for this tool or configuration.""" + memory_store_name: Required[str] + """The name of the memory store to use. Required.""" + scope: Required[str] + """The namespace used to group and isolate memories, such as a user ID. Limits which memories can + be retrieved or updated. Use special variable ``{{$userId}}`` to scope memories to the current + signed-in user. Required.""" + search_options: "MemorySearchOptions" + """Options for searching the memory store.""" + update_delay: int + """Time to wait before updating memories after inactivity (seconds). Default 300.""" + + +class MemorySearchTool(TypedDict, total=False): + """A tool for integrating memories into the agent. + + :ivar type: The type of the tool. Always ``memory_search_preview``. Required. MEMORY_SEARCH. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.MEMORY_SEARCH + :ivar name: Optional user-defined name for this tool or configuration. + :vartype name: str + :ivar description: Optional user-defined description for this tool or configuration. + :vartype description: str + :ivar memory_store_name: The name of the memory store to use. Required. + :vartype memory_store_name: str + :ivar scope: The namespace used to group and isolate memories, such as a user ID. Limits which + memories can be retrieved or updated. Use special variable ``{{$userId}}`` to scope memories to + the current signed-in user. Required. + :vartype scope: str + :ivar search_options: Options for searching the memory store. + :vartype search_options: ~azure.ai.agentserver.responses.models.types.MemorySearchOptions + :ivar update_delay: Time to wait before updating memories after inactivity (seconds). Default + 300. + :vartype update_delay: int + """ + + type: Required[Literal[ToolType.MEMORY_SEARCH]] + """The type of the tool. Always ``memory_search_preview``. Required. MEMORY_SEARCH.""" + name: str + """Optional user-defined name for this tool or configuration.""" + description: str + """Optional user-defined description for this tool or configuration.""" + memory_store_name: Required[str] + """The name of the memory store to use. Required.""" + scope: Required[str] + """The namespace used to group and isolate memories, such as a user ID. Limits which memories can + be retrieved or updated. Use special variable ``{{$userId}}`` to scope memories to the current + signed-in user. Required.""" + search_options: "MemorySearchOptions" + """Options for searching the memory store.""" + update_delay: int + """Time to wait before updating memories after inactivity (seconds). Default 300.""" + + +class MemorySearchToolCallItemParam(TypedDict, total=False): + """MemorySearchToolCallItemParam. + + :ivar type: Required. MEMORY_SEARCH_CALL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.MEMORY_SEARCH_CALL + :ivar results: The results returned from the memory search. + :vartype results: list[~azure.ai.agentserver.responses.models.types.MemorySearchItem] + """ + + type: Required[Literal[ItemType.MEMORY_SEARCH_CALL]] + """Required. MEMORY_SEARCH_CALL.""" + results: Optional[list["MemorySearchItem"]] + """The results returned from the memory search.""" + + +class MemorySearchToolCallItemResource(TypedDict, total=False): + """MemorySearchToolCallItemResource. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar type: Required. MEMORY_SEARCH_CALL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.MEMORY_SEARCH_CALL + :ivar status: The status of the memory search tool call. One of ``in_progress``, ``searching``, + ``completed``, ``incomplete`` or ``failed``,. Required. Is one of the following types: + Literal["in_progress"], Literal["searching"], Literal["completed"], Literal["incomplete"], + Literal["failed"] + :vartype status: str or str or str or str or str + :ivar results: The results returned from the memory search. + :vartype results: list[~azure.ai.agentserver.responses.models.types.MemorySearchItem] + :ivar id: Required. + :vartype id: str + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + type: Required[Literal[OutputItemType.MEMORY_SEARCH_CALL]] + """Required. MEMORY_SEARCH_CALL.""" + status: Required[Literal["in_progress", "searching", "completed", "incomplete", "failed"]] + """The status of the memory search tool call. One of ``in_progress``, ``searching``, + ``completed``, ``incomplete`` or ``failed``,. Required. Is one of the following types: + Literal[\"in_progress\"], Literal[\"searching\"], Literal[\"completed\"], + Literal[\"incomplete\"], Literal[\"failed\"]""" + results: Optional[list["MemorySearchItem"]] + """The results returned from the memory search.""" + id: Required[str] + """Required.""" + + +class MessageContentInputFileContent(TypedDict, total=False): + """Input file. + + :ivar type: The type of the input item. Always ``input_file``. Required. INPUT_FILE. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.INPUT_FILE + :ivar file_id: + :vartype file_id: str + :ivar filename: The name of the file to be sent to the model. + :vartype filename: str + :ivar file_url: The URL of the file to be sent to the model. + :vartype file_url: str + :ivar file_data: The content of the file to be sent to the model. + :vartype file_data: str + """ + + type: Required[Literal[MessageContentType.INPUT_FILE]] + """The type of the input item. Always ``input_file``. Required. INPUT_FILE.""" + file_id: Optional[str] + filename: str + """The name of the file to be sent to the model.""" + file_url: str + """The URL of the file to be sent to the model.""" + file_data: str + """The content of the file to be sent to the model.""" + + +class MessageContentInputImageContent(TypedDict, total=False): + """Input image. + + :ivar type: The type of the input item. Always ``input_image``. Required. INPUT_IMAGE. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.INPUT_IMAGE + :ivar image_url: + :vartype image_url: str + :ivar file_id: + :vartype file_id: str + :ivar detail: The detail level of the image to be sent to the model. One of ``high``, ``low``, + or ``auto``. Defaults to ``auto``. Required. Known values are: "low", "high", and "auto". + :vartype detail: str or ~azure.ai.agentserver.responses.models.models.ImageDetail + """ + + type: Required[Literal[MessageContentType.INPUT_IMAGE]] + """The type of the input item. Always ``input_image``. Required. INPUT_IMAGE.""" + image_url: Optional[str] + file_id: Optional[str] + detail: Required[ImageDetail] + """The detail level of the image to be sent to the model. One of ``high``, ``low``, or ``auto``. + Defaults to ``auto``. Required. Known values are: \"low\", \"high\", and \"auto\".""" + + +class MessageContentInputTextContent(TypedDict, total=False): + """Input text. + + :ivar type: The type of the input item. Always ``input_text``. Required. INPUT_TEXT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.INPUT_TEXT + :ivar text: The text input to the model. Required. + :vartype text: str + """ + + type: Required[Literal[MessageContentType.INPUT_TEXT]] + """The type of the input item. Always ``input_text``. Required. INPUT_TEXT.""" + text: Required[str] + """The text input to the model. Required.""" + + +class MessageContentOutputTextContent(TypedDict, total=False): + """Output text. + + :ivar type: The type of the output text. Always ``output_text``. Required. OUTPUT_TEXT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.OUTPUT_TEXT + :ivar text: The text output from the model. Required. + :vartype text: str + :ivar annotations: The annotations of the text output. Required. + :vartype annotations: list[~azure.ai.agentserver.responses.models.types.Annotation] + :ivar logprobs: Required. + :vartype logprobs: list[~azure.ai.agentserver.responses.models.types.LogProb] + """ + + type: Required[Literal[MessageContentType.OUTPUT_TEXT]] + """The type of the output text. Always ``output_text``. Required. OUTPUT_TEXT.""" + text: Required[str] + """The text output from the model. Required.""" + annotations: Required[list["Annotation"]] + """The annotations of the text output. Required.""" + logprobs: Required[list["LogProb"]] + """Required.""" + + +class MessageContentReasoningTextContent(TypedDict, total=False): + """Reasoning text. + + :ivar type: The type of the reasoning text. Always ``reasoning_text``. Required. + REASONING_TEXT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.REASONING_TEXT + :ivar text: The reasoning text from the model. Required. + :vartype text: str + """ + + type: Required[Literal[MessageContentType.REASONING_TEXT]] + """The type of the reasoning text. Always ``reasoning_text``. Required. REASONING_TEXT.""" + text: Required[str] + """The reasoning text from the model. Required.""" + + +class MessageContentRefusalContent(TypedDict, total=False): + """Refusal. + + :ivar type: The type of the refusal. Always ``refusal``. Required. REFUSAL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.REFUSAL + :ivar refusal: The refusal explanation from the model. Required. + :vartype refusal: str + """ + + type: Required[Literal[MessageContentType.REFUSAL]] + """The type of the refusal. Always ``refusal``. Required. REFUSAL.""" + refusal: Required[str] + """The refusal explanation from the model. Required.""" + + +class Metadata(TypedDict, total=False): + """Set of 16 key-value pairs that can be attached to an object. This can be useful for storing + additional information about the object in a structured format, and querying for objects via + API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are + strings with a maximum length of 512 characters. + + """ + + +class MicrosoftFabricPreviewTool(TypedDict, total=False): + """The input definition information for a Microsoft Fabric tool as used to configure an agent. + + :ivar type: The object type, which is always 'fabric_dataagent_preview'. Required. + FABRIC_DATAAGENT_PREVIEW. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.FABRIC_DATAAGENT_PREVIEW + :ivar name: Optional user-defined name for this tool or configuration. + :vartype name: str + :ivar description: Optional user-defined description for this tool or configuration. + :vartype description: str + :ivar fabric_dataagent_preview: The fabric data agent tool parameters. Required. + :vartype fabric_dataagent_preview: + ~azure.ai.agentserver.responses.models.types.FabricDataAgentToolParameters + """ + + type: Required[Literal[ToolType.FABRIC_DATAAGENT_PREVIEW]] + """The object type, which is always 'fabric_dataagent_preview'. Required. + FABRIC_DATAAGENT_PREVIEW.""" + name: str + """Optional user-defined name for this tool or configuration.""" + description: str + """Optional user-defined description for this tool or configuration.""" + fabric_dataagent_preview: Required["FabricDataAgentToolParameters"] + """The fabric data agent tool parameters. Required.""" + + +class MoveParam(TypedDict, total=False): + """Move. + + :ivar type: Specifies the event type. For a move action, this property is always set to + ``move``. Required. MOVE. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.MOVE + :ivar x: The x-coordinate to move to. Required. + :vartype x: int + :ivar y: The y-coordinate to move to. Required. + :vartype y: int + """ + + type: Required[Literal[ComputerActionType.MOVE]] + """Specifies the event type. For a move action, this property is always set to ``move``. Required. + MOVE.""" + x: Required[int] + """The x-coordinate to move to. Required.""" + y: Required[int] + """The y-coordinate to move to. Required.""" + + +class OAuthConsentRequestOutputItem(TypedDict, total=False): + """Request from the service for the user to perform OAuth consent. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar id: Required. + :vartype id: str + :ivar type: Required. OAUTH_CONSENT_REQUEST. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.OAUTH_CONSENT_REQUEST + :ivar consent_link: The link the user can use to perform OAuth consent. Required. + :vartype consent_link: str + :ivar server_label: The server label for the OAuth consent request. Required. + :vartype server_label: str + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + id: Required[str] + """Required.""" + type: Required[Literal[OutputItemType.OAUTH_CONSENT_REQUEST]] + """Required. OAUTH_CONSENT_REQUEST.""" + consent_link: Required[str] + """The link the user can use to perform OAuth consent. Required.""" + server_label: Required[str] + """The server label for the OAuth consent request. Required.""" + + +class OpenApiAnonymousAuthDetails(TypedDict, total=False): + """Security details for OpenApi anonymous authentication. + + :ivar type: The object type, which is always 'anonymous'. Required. ANONYMOUS. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.ANONYMOUS + """ + + type: Required[Literal[OpenApiAuthType.ANONYMOUS]] + """The object type, which is always 'anonymous'. Required. ANONYMOUS.""" + + +class OpenApiFunctionDefinition(TypedDict, total=False): + """The input definition information for an openapi function. + + :ivar name: The name of the function to be called. Required. + :vartype name: str + :ivar description: A description of what the function does, used by the model to choose when + and how to call the function. + :vartype description: str + :ivar spec: The openapi function shape, described as a JSON Schema object. Required. + :vartype spec: dict[str, any] + :ivar auth: Open API authentication details. Required. + :vartype auth: ~azure.ai.agentserver.responses.models.types.OpenApiAuthDetails + :ivar default_params: List of OpenAPI spec parameters that will use user-provided defaults. + :vartype default_params: list[str] + :ivar functions: List of function definitions used by OpenApi tool. + :vartype functions: + list[~azure.ai.agentserver.responses.models.types.OpenApiFunctionDefinitionFunction] + """ + + name: Required[str] + """The name of the function to be called. Required.""" + description: str + """A description of what the function does, used by the model to choose when and how to call the + function.""" + spec: Required[dict[str, Any]] + """The openapi function shape, described as a JSON Schema object. Required.""" + auth: Required["OpenApiAuthDetails"] + """Open API authentication details. Required.""" + default_params: list[str] + """List of OpenAPI spec parameters that will use user-provided defaults.""" + functions: list["OpenApiFunctionDefinitionFunction"] + """List of function definitions used by OpenApi tool.""" + + +class OpenApiFunctionDefinitionFunction(TypedDict, total=False): + """OpenApiFunctionDefinitionFunction. + + :ivar name: The name of the function to be called. Required. + :vartype name: str + :ivar description: A description of what the function does, used by the model to choose when + and how to call the function. + :vartype description: str + :ivar parameters: The parameters the functions accepts, described as a JSON Schema object. + Required. + :vartype parameters: dict[str, any] + """ + + name: Required[str] + """The name of the function to be called. Required.""" + description: str + """A description of what the function does, used by the model to choose when and how to call the + function.""" + parameters: Required[dict[str, Any]] + """The parameters the functions accepts, described as a JSON Schema object. Required.""" + + +class OpenApiManagedAuthDetails(TypedDict, total=False): + """Security details for OpenApi managed_identity authentication. + + :ivar type: The object type, which is always 'managed_identity'. Required. MANAGED_IDENTITY. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.MANAGED_IDENTITY + :ivar security_scheme: Connection auth security details. Required. + :vartype security_scheme: + ~azure.ai.agentserver.responses.models.types.OpenApiManagedSecurityScheme + """ + + type: Required[Literal[OpenApiAuthType.MANAGED_IDENTITY]] + """The object type, which is always 'managed_identity'. Required. MANAGED_IDENTITY.""" + security_scheme: Required["OpenApiManagedSecurityScheme"] + """Connection auth security details. Required.""" + + +class OpenApiManagedSecurityScheme(TypedDict, total=False): + """Security scheme for OpenApi managed_identity authentication. + + :ivar audience: Authentication scope for managed_identity auth type. Required. + :vartype audience: str + """ + + audience: Required[str] + """Authentication scope for managed_identity auth type. Required.""" + + +class OpenApiProjectConnectionAuthDetails(TypedDict, total=False): + """Security details for OpenApi project connection authentication. + + :ivar type: The object type, which is always 'project_connection'. Required. + PROJECT_CONNECTION. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.PROJECT_CONNECTION + :ivar security_scheme: Project connection auth security details. Required. + :vartype security_scheme: + ~azure.ai.agentserver.responses.models.types.OpenApiProjectConnectionSecurityScheme + """ + + type: Required[Literal[OpenApiAuthType.PROJECT_CONNECTION]] + """The object type, which is always 'project_connection'. Required. PROJECT_CONNECTION.""" + security_scheme: Required["OpenApiProjectConnectionSecurityScheme"] + """Project connection auth security details. Required.""" + + +class OpenApiProjectConnectionSecurityScheme(TypedDict, total=False): + """Security scheme for OpenApi managed_identity authentication. + + :ivar project_connection_id: Project connection id for Project Connection auth type. Required. + :vartype project_connection_id: str + """ + + project_connection_id: Required[str] + """Project connection id for Project Connection auth type. Required.""" + + +class OpenApiTool(TypedDict, total=False): + """The input definition information for an OpenAPI tool as used to configure an agent. + + :ivar type: The object type, which is always 'openapi'. Required. OPENAPI. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.OPENAPI + :ivar openapi: The openapi function definition. Required. + :vartype openapi: ~azure.ai.agentserver.responses.models.types.OpenApiFunctionDefinition + """ + + type: Required[Literal[ToolType.OPENAPI]] + """The object type, which is always 'openapi'. Required. OPENAPI.""" + openapi: Required["OpenApiFunctionDefinition"] + """The openapi function definition. Required.""" + + +class OpenApiToolCall(TypedDict, total=False): + """An OpenAPI tool call. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar type: Required. OPENAPI_CALL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.OPENAPI_CALL + :ivar call_id: The unique ID of the tool call generated by the model. Required. + :vartype call_id: str + :ivar name: The name of the OpenAPI operation being called. Required. + :vartype name: str + :ivar arguments: A JSON string of the arguments to pass to the tool. Required. + :vartype arguments: str + :ivar status: The status of the tool call. Required. Known values are: "in_progress", + "completed", "incomplete", and "failed". + :vartype status: str or ~azure.ai.agentserver.responses.models.models.ToolCallStatus + :ivar id: Required. + :vartype id: str + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + type: Required[Literal[OutputItemType.OPENAPI_CALL]] + """Required. OPENAPI_CALL.""" + call_id: Required[str] + """The unique ID of the tool call generated by the model. Required.""" + name: Required[str] + """The name of the OpenAPI operation being called. Required.""" + arguments: Required[str] + """A JSON string of the arguments to pass to the tool. Required.""" + status: Required[ToolCallStatus] + """The status of the tool call. Required. Known values are: \"in_progress\", \"completed\", + \"incomplete\", and \"failed\".""" + id: Required[str] + """Required.""" + + +class OpenApiToolCallOutput(TypedDict, total=False): + """The output of an OpenAPI tool call. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar type: Required. OPENAPI_CALL_OUTPUT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.OPENAPI_CALL_OUTPUT + :ivar call_id: The unique ID of the tool call generated by the model. Required. + :vartype call_id: str + :ivar name: The name of the OpenAPI operation that was called. Required. + :vartype name: str + :ivar output: The output from the OpenAPI tool call. Is one of the following types: {str: Any}, + str, [Any] + :vartype output: dict[str, any] or str or list[any] + :ivar status: The status of the tool call. Required. Known values are: "in_progress", + "completed", "incomplete", and "failed". + :vartype status: str or ~azure.ai.agentserver.responses.models.models.ToolCallStatus + :ivar id: Required. + :vartype id: str + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + type: Required[Literal[OutputItemType.OPENAPI_CALL_OUTPUT]] + """Required. OPENAPI_CALL_OUTPUT.""" + call_id: Required[str] + """The unique ID of the tool call generated by the model. Required.""" + name: Required[str] + """The name of the OpenAPI operation that was called. Required.""" + output: "_unions.ToolCallOutputContent" + """The output from the OpenAPI tool call. Is one of the following types: {str: Any}, str, [Any]""" + status: Required[ToolCallStatus] + """The status of the tool call. Required. Known values are: \"in_progress\", \"completed\", + \"incomplete\", and \"failed\".""" + id: Required[str] + """Required.""" + + +class OutputContentOutputTextContent(TypedDict, total=False): + """Output text. + + :ivar type: The type of the output text. Always ``output_text``. Required. OUTPUT_TEXT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.OUTPUT_TEXT + :ivar text: The text output from the model. Required. + :vartype text: str + :ivar annotations: The annotations of the text output. Required. + :vartype annotations: list[~azure.ai.agentserver.responses.models.types.Annotation] + :ivar logprobs: Required. + :vartype logprobs: list[~azure.ai.agentserver.responses.models.types.LogProb] + """ + + type: Required[Literal[OutputContentType.OUTPUT_TEXT]] + """The type of the output text. Always ``output_text``. Required. OUTPUT_TEXT.""" + text: Required[str] + """The text output from the model. Required.""" + annotations: Required[list["Annotation"]] + """The annotations of the text output. Required.""" + logprobs: Required[list["LogProb"]] + """Required.""" + + +class OutputContentReasoningTextContent(TypedDict, total=False): + """Reasoning text. + + :ivar type: The type of the reasoning text. Always ``reasoning_text``. Required. + REASONING_TEXT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.REASONING_TEXT + :ivar text: The reasoning text from the model. Required. + :vartype text: str + """ + + type: Required[Literal[OutputContentType.REASONING_TEXT]] + """The type of the reasoning text. Always ``reasoning_text``. Required. REASONING_TEXT.""" + text: Required[str] + """The reasoning text from the model. Required.""" + + +class OutputContentRefusalContent(TypedDict, total=False): + """Refusal. + + :ivar type: The type of the refusal. Always ``refusal``. Required. REFUSAL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.REFUSAL + :ivar refusal: The refusal explanation from the model. Required. + :vartype refusal: str + """ + + type: Required[Literal[OutputContentType.REFUSAL]] + """The type of the refusal. Always ``refusal``. Required. REFUSAL.""" + refusal: Required[str] + """The refusal explanation from the model. Required.""" + + +class OutputItemApplyPatchToolCall(TypedDict, total=False): + """Apply patch tool call. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar type: The type of the item. Always ``apply_patch_call``. Required. APPLY_PATCH_CALL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.APPLY_PATCH_CALL + :ivar id: The unique ID of the apply patch tool call. Populated when this item is returned via + API. Required. + :vartype id: str + :ivar call_id: The unique ID of the apply patch tool call generated by the model. Required. + :vartype call_id: str + :ivar status: The status of the apply patch tool call. One of ``in_progress`` or ``completed``. + Required. Known values are: "in_progress" and "completed". + :vartype status: str or ~azure.ai.agentserver.responses.models.models.ApplyPatchCallStatus + :ivar operation: Apply patch operation. Required. + :vartype operation: ~azure.ai.agentserver.responses.models.types.ApplyPatchFileOperation + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + type: Required[Literal[OutputItemType.APPLY_PATCH_CALL]] + """The type of the item. Always ``apply_patch_call``. Required. APPLY_PATCH_CALL.""" + id: Required[str] + """The unique ID of the apply patch tool call. Populated when this item is returned via API. + Required.""" + call_id: Required[str] + """The unique ID of the apply patch tool call generated by the model. Required.""" + status: Required[ApplyPatchCallStatus] + """The status of the apply patch tool call. One of ``in_progress`` or ``completed``. Required. + Known values are: \"in_progress\" and \"completed\".""" + operation: Required["ApplyPatchFileOperation"] + """Apply patch operation. Required.""" + + +class OutputItemApplyPatchToolCallOutput(TypedDict, total=False): + """Apply patch tool call output. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar type: The type of the item. Always ``apply_patch_call_output``. Required. + APPLY_PATCH_CALL_OUTPUT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.APPLY_PATCH_CALL_OUTPUT + :ivar id: The unique ID of the apply patch tool call output. Populated when this item is + returned via API. Required. + :vartype id: str + :ivar call_id: The unique ID of the apply patch tool call generated by the model. Required. + :vartype call_id: str + :ivar status: The status of the apply patch tool call output. One of ``completed`` or + ``failed``. Required. Known values are: "completed" and "failed". + :vartype status: str or + ~azure.ai.agentserver.responses.models.models.ApplyPatchCallOutputStatus + :ivar output: + :vartype output: str + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + type: Required[Literal[OutputItemType.APPLY_PATCH_CALL_OUTPUT]] + """The type of the item. Always ``apply_patch_call_output``. Required. APPLY_PATCH_CALL_OUTPUT.""" + id: Required[str] + """The unique ID of the apply patch tool call output. Populated when this item is returned via + API. Required.""" + call_id: Required[str] + """The unique ID of the apply patch tool call generated by the model. Required.""" + status: Required[ApplyPatchCallOutputStatus] + """The status of the apply patch tool call output. One of ``completed`` or ``failed``. Required. + Known values are: \"completed\" and \"failed\".""" + output: Optional[str] + + +class OutputItemCodeInterpreterToolCall(TypedDict, total=False): + """Code interpreter tool call. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar type: The type of the code interpreter tool call. Always ``code_interpreter_call``. + Required. CODE_INTERPRETER_CALL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.CODE_INTERPRETER_CALL + :ivar id: The unique ID of the code interpreter tool call. Required. + :vartype id: str + :ivar status: The status of the code interpreter tool call. Valid values are ``in_progress``, + ``completed``, ``incomplete``, ``interpreting``, and ``failed``. Required. Is one of the + following types: Literal["in_progress"], Literal["completed"], Literal["incomplete"], + Literal["interpreting"], Literal["failed"] + :vartype status: str or str or str or str or str + :ivar container_id: The ID of the container used to run the code. Required. + :vartype container_id: str + :ivar code: Required. + :vartype code: str + :ivar outputs: Required. + :vartype outputs: list[~azure.ai.agentserver.responses.models.types.CodeInterpreterOutputLogs + or ~azure.ai.agentserver.responses.models.types.CodeInterpreterOutputImage] + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + type: Required[Literal[OutputItemType.CODE_INTERPRETER_CALL]] + """The type of the code interpreter tool call. Always ``code_interpreter_call``. Required. + CODE_INTERPRETER_CALL.""" + id: Required[str] + """The unique ID of the code interpreter tool call. Required.""" + status: Required[Literal["in_progress", "completed", "incomplete", "interpreting", "failed"]] + """The status of the code interpreter tool call. Valid values are ``in_progress``, ``completed``, + ``incomplete``, ``interpreting``, and ``failed``. Required. Is one of the following types: + Literal[\"in_progress\"], Literal[\"completed\"], Literal[\"incomplete\"], + Literal[\"interpreting\"], Literal[\"failed\"]""" + container_id: Required[str] + """The ID of the container used to run the code. Required.""" + code: Required[Optional[str]] + """Required.""" + outputs: Required[Optional[list[Union["CodeInterpreterOutputLogs", "CodeInterpreterOutputImage"]]]] + """Required.""" + + +class OutputItemCompactionBody(TypedDict, total=False): + """Compaction item. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar type: The type of the item. Always ``compaction``. Required. COMPACTION. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.COMPACTION + :ivar id: The unique ID of the compaction item. Required. + :vartype id: str + :ivar encrypted_content: The encrypted content that was produced by compaction. Required. + :vartype encrypted_content: str + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + type: Required[Literal[OutputItemType.COMPACTION]] + """The type of the item. Always ``compaction``. Required. COMPACTION.""" + id: Required[str] + """The unique ID of the compaction item. Required.""" + encrypted_content: Required[str] + """The encrypted content that was produced by compaction. Required.""" + + +class OutputItemComputerToolCall(TypedDict, total=False): + """Computer tool call. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar type: The type of the computer call. Always ``computer_call``. Required. COMPUTER_CALL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.COMPUTER_CALL + :ivar id: The unique ID of the computer call. Required. + :vartype id: str + :ivar call_id: An identifier used when responding to the tool call with output. Required. + :vartype call_id: str + :ivar action: Required. + :vartype action: ~azure.ai.agentserver.responses.models.types.ComputerAction + :ivar pending_safety_checks: The pending safety checks for the computer call. Required. + :vartype pending_safety_checks: + list[~azure.ai.agentserver.responses.models.types.ComputerCallSafetyCheckParam] + :ivar status: The status of the item. One of ``in_progress``, ``completed``, or ``incomplete``. + Populated when items are returned via API. Required. Is one of the following types: + Literal["in_progress"], Literal["completed"], Literal["incomplete"] + :vartype status: str or str or str + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + type: Required[Literal[OutputItemType.COMPUTER_CALL]] + """The type of the computer call. Always ``computer_call``. Required. COMPUTER_CALL.""" + id: Required[str] + """The unique ID of the computer call. Required.""" + call_id: Required[str] + """An identifier used when responding to the tool call with output. Required.""" + action: Required["ComputerAction"] + """Required.""" + pending_safety_checks: Required[list["ComputerCallSafetyCheckParam"]] + """The pending safety checks for the computer call. Required.""" + status: Required[Literal["in_progress", "completed", "incomplete"]] + """The status of the item. One of ``in_progress``, ``completed``, or ``incomplete``. Populated + when items are returned via API. Required. Is one of the following types: + Literal[\"in_progress\"], Literal[\"completed\"], Literal[\"incomplete\"]""" + + +class OutputItemComputerToolCallOutputResource(TypedDict, total=False): + """OutputItemComputerToolCallOutputResource. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar type: The type of the computer tool call output. Always ``computer_call_output``. + Required. COMPUTER_CALL_OUTPUT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.COMPUTER_CALL_OUTPUT + :ivar id: The ID of the computer tool call output. + :vartype id: str + :ivar call_id: The ID of the computer tool call that produced the output. Required. + :vartype call_id: str + :ivar acknowledged_safety_checks: The safety checks reported by the API that have been + acknowledged by the developer. + :vartype acknowledged_safety_checks: + list[~azure.ai.agentserver.responses.models.types.ComputerCallSafetyCheckParam] + :ivar output: Required. + :vartype output: ~azure.ai.agentserver.responses.models.types.ComputerScreenshotImage + :ivar status: The status of the message input. One of ``in_progress``, ``completed``, or + ``incomplete``. Populated when input items are returned via API. Is one of the following types: + Literal["in_progress"], Literal["completed"], Literal["incomplete"] + :vartype status: str or str or str + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + type: Required[Literal[OutputItemType.COMPUTER_CALL_OUTPUT]] + """The type of the computer tool call output. Always ``computer_call_output``. Required. + COMPUTER_CALL_OUTPUT.""" + id: str + """The ID of the computer tool call output.""" + call_id: Required[str] + """The ID of the computer tool call that produced the output. Required.""" + acknowledged_safety_checks: list["ComputerCallSafetyCheckParam"] + """The safety checks reported by the API that have been acknowledged by the developer.""" + output: Required["ComputerScreenshotImage"] + """Required.""" + status: Literal["in_progress", "completed", "incomplete"] + """The status of the message input. One of ``in_progress``, ``completed``, or ``incomplete``. + Populated when input items are returned via API. Is one of the following types: + Literal[\"in_progress\"], Literal[\"completed\"], Literal[\"incomplete\"]""" + + +class OutputItemCustomToolCall(TypedDict, total=False): + """Custom tool call. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar type: The type of the custom tool call. Always ``custom_tool_call``. Required. + CUSTOM_TOOL_CALL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.CUSTOM_TOOL_CALL + :ivar id: The unique ID of the custom tool call in the OpenAI platform. + :vartype id: str + :ivar call_id: An identifier used to map this custom tool call to a tool call output. Required. + :vartype call_id: str + :ivar name: The name of the custom tool being called. Required. + :vartype name: str + :ivar input: The input for the custom tool call generated by the model. Required. + :vartype input: str + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + type: Required[Literal[OutputItemType.CUSTOM_TOOL_CALL]] + """The type of the custom tool call. Always ``custom_tool_call``. Required. CUSTOM_TOOL_CALL.""" + id: str + """The unique ID of the custom tool call in the OpenAI platform.""" + call_id: Required[str] + """An identifier used to map this custom tool call to a tool call output. Required.""" + name: Required[str] + """The name of the custom tool being called. Required.""" + input: Required[str] + """The input for the custom tool call generated by the model. Required.""" + + +class OutputItemCustomToolCallOutput(TypedDict, total=False): + """Custom tool call output. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar type: The type of the custom tool call output. Always ``custom_tool_call_output``. + Required. CUSTOM_TOOL_CALL_OUTPUT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.CUSTOM_TOOL_CALL_OUTPUT + :ivar id: The unique ID of the custom tool call output in the OpenAI platform. + :vartype id: str + :ivar call_id: The call ID, used to map this custom tool call output to a custom tool call. + Required. + :vartype call_id: str + :ivar output: The output from the custom tool call generated by your code. Can be a string or + an list of output content. Required. Is either a str type or a + [FunctionAndCustomToolCallOutput] type. + :vartype output: str or + list[~azure.ai.agentserver.responses.models.types.FunctionAndCustomToolCallOutput] + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + type: Required[Literal[OutputItemType.CUSTOM_TOOL_CALL_OUTPUT]] + """The type of the custom tool call output. Always ``custom_tool_call_output``. Required. + CUSTOM_TOOL_CALL_OUTPUT.""" + id: str + """The unique ID of the custom tool call output in the OpenAI platform.""" + call_id: Required[str] + """The call ID, used to map this custom tool call output to a custom tool call. Required.""" + output: Required[Union[str, list["FunctionAndCustomToolCallOutput"]]] + """The output from the custom tool call generated by your code. Can be a string or an list of + output content. Required. Is either a str type or a [FunctionAndCustomToolCallOutput] type.""" + + +class OutputItemFileSearchToolCall(TypedDict, total=False): + """File search tool call. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar id: The unique ID of the file search tool call. Required. + :vartype id: str + :ivar type: The type of the file search tool call. Always ``file_search_call``. Required. + FILE_SEARCH_CALL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.FILE_SEARCH_CALL + :ivar status: The status of the file search tool call. One of ``in_progress``, ``searching``, + ``incomplete`` or ``failed``,. Required. Is one of the following types: Literal["in_progress"], + Literal["searching"], Literal["completed"], Literal["incomplete"], Literal["failed"] + :vartype status: str or str or str or str or str + :ivar queries: The queries used to search for files. Required. + :vartype queries: list[str] + :ivar results: + :vartype results: list[~azure.ai.agentserver.responses.models.types.FileSearchToolCallResults] + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + id: Required[str] + """The unique ID of the file search tool call. Required.""" + type: Required[Literal[OutputItemType.FILE_SEARCH_CALL]] + """The type of the file search tool call. Always ``file_search_call``. Required. FILE_SEARCH_CALL.""" + status: Required[Literal["in_progress", "searching", "completed", "incomplete", "failed"]] + """The status of the file search tool call. One of ``in_progress``, ``searching``, ``incomplete`` + or ``failed``,. Required. Is one of the following types: Literal[\"in_progress\"], + Literal[\"searching\"], Literal[\"completed\"], Literal[\"incomplete\"], Literal[\"failed\"]""" + queries: Required[list[str]] + """The queries used to search for files. Required.""" + results: Optional[list["FileSearchToolCallResults"]] + + +class OutputItemFunctionShellCall(TypedDict, total=False): + """Shell tool call. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar type: The type of the item. Always ``shell_call``. Required. SHELL_CALL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.SHELL_CALL + :ivar id: The unique ID of the shell tool call. Populated when this item is returned via API. + Required. + :vartype id: str + :ivar call_id: The unique ID of the shell tool call generated by the model. Required. + :vartype call_id: str + :ivar action: The shell commands and limits that describe how to run the tool call. Required. + :vartype action: ~azure.ai.agentserver.responses.models.types.FunctionShellAction + :ivar status: The status of the shell call. One of ``in_progress``, ``completed``, or + ``incomplete``. Required. Known values are: "in_progress", "completed", and "incomplete". + :vartype status: str or ~azure.ai.agentserver.responses.models.models.LocalShellCallStatus + :ivar environment: Required. + :vartype environment: ~azure.ai.agentserver.responses.models.types.FunctionShellCallEnvironment + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + type: Required[Literal[OutputItemType.SHELL_CALL]] + """The type of the item. Always ``shell_call``. Required. SHELL_CALL.""" + id: Required[str] + """The unique ID of the shell tool call. Populated when this item is returned via API. Required.""" + call_id: Required[str] + """The unique ID of the shell tool call generated by the model. Required.""" + action: Required["FunctionShellAction"] + """The shell commands and limits that describe how to run the tool call. Required.""" + status: Required[LocalShellCallStatus] + """The status of the shell call. One of ``in_progress``, ``completed``, or ``incomplete``. + Required. Known values are: \"in_progress\", \"completed\", and \"incomplete\".""" + environment: Required[Optional["FunctionShellCallEnvironment"]] + """Required.""" + + +class OutputItemFunctionShellCallOutput(TypedDict, total=False): + """Shell call output. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar type: The type of the shell call output. Always ``shell_call_output``. Required. + SHELL_CALL_OUTPUT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.SHELL_CALL_OUTPUT + :ivar id: The unique ID of the shell call output. Populated when this item is returned via API. + Required. + :vartype id: str + :ivar call_id: The unique ID of the shell tool call generated by the model. Required. + :vartype call_id: str + :ivar status: The status of the shell call output. One of ``in_progress``, ``completed``, or + ``incomplete``. Required. Known values are: "in_progress", "completed", and "incomplete". + :vartype status: str or + ~azure.ai.agentserver.responses.models.models.LocalShellCallOutputStatusEnum + :ivar output: An array of shell call output contents. Required. + :vartype output: + list[~azure.ai.agentserver.responses.models.types.FunctionShellCallOutputContent] + :ivar max_output_length: Required. + :vartype max_output_length: int + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + type: Required[Literal[OutputItemType.SHELL_CALL_OUTPUT]] + """The type of the shell call output. Always ``shell_call_output``. Required. SHELL_CALL_OUTPUT.""" + id: Required[str] + """The unique ID of the shell call output. Populated when this item is returned via API. Required.""" + call_id: Required[str] + """The unique ID of the shell tool call generated by the model. Required.""" + status: Required[LocalShellCallOutputStatusEnum] + """The status of the shell call output. One of ``in_progress``, ``completed``, or ``incomplete``. + Required. Known values are: \"in_progress\", \"completed\", and \"incomplete\".""" + output: Required[list["FunctionShellCallOutputContent"]] + """An array of shell call output contents. Required.""" + max_output_length: Required[Optional[int]] + """Required.""" + + +class OutputItemFunctionToolCall(TypedDict, total=False): + """Function tool call. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar id: The unique ID of the function tool call. + :vartype id: str + :ivar type: The type of the function tool call. Always ``function_call``. Required. + FUNCTION_CALL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.FUNCTION_CALL + :ivar call_id: The unique ID of the function tool call generated by the model. Required. + :vartype call_id: str + :ivar name: The name of the function to run. Required. + :vartype name: str + :ivar arguments: A JSON string of the arguments to pass to the function. Required. + :vartype arguments: str + :ivar status: The status of the item. One of ``in_progress``, ``completed``, or ``incomplete``. + Populated when items are returned via API. Is one of the following types: + Literal["in_progress"], Literal["completed"], Literal["incomplete"] + :vartype status: str or str or str + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + id: str + """The unique ID of the function tool call.""" + type: Required[Literal[OutputItemType.FUNCTION_CALL]] + """The type of the function tool call. Always ``function_call``. Required. FUNCTION_CALL.""" + call_id: Required[str] + """The unique ID of the function tool call generated by the model. Required.""" + name: Required[str] + """The name of the function to run. Required.""" + arguments: Required[str] + """A JSON string of the arguments to pass to the function. Required.""" + status: Literal["in_progress", "completed", "incomplete"] + """The status of the item. One of ``in_progress``, ``completed``, or ``incomplete``. Populated + when items are returned via API. Is one of the following types: Literal[\"in_progress\"], + Literal[\"completed\"], Literal[\"incomplete\"]""" + + +class OutputItemImageGenToolCall(TypedDict, total=False): + """Image generation call. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar type: The type of the image generation call. Always ``image_generation_call``. Required. + IMAGE_GENERATION_CALL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.IMAGE_GENERATION_CALL + :ivar id: The unique ID of the image generation call. Required. + :vartype id: str + :ivar status: The status of the image generation call. Required. Is one of the following types: + Literal["in_progress"], Literal["completed"], Literal["generating"], Literal["failed"] + :vartype status: str or str or str or str + :ivar result: Required. + :vartype result: str + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + type: Required[Literal[OutputItemType.IMAGE_GENERATION_CALL]] + """The type of the image generation call. Always ``image_generation_call``. Required. + IMAGE_GENERATION_CALL.""" + id: Required[str] + """The unique ID of the image generation call. Required.""" + status: Required[Literal["in_progress", "completed", "generating", "failed"]] + """The status of the image generation call. Required. Is one of the following types: + Literal[\"in_progress\"], Literal[\"completed\"], Literal[\"generating\"], Literal[\"failed\"]""" + result: Required[Optional[str]] + """Required.""" + + +class OutputItemLocalShellToolCall(TypedDict, total=False): + """Local shell call. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar type: The type of the local shell call. Always ``local_shell_call``. Required. + LOCAL_SHELL_CALL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.LOCAL_SHELL_CALL + :ivar id: The unique ID of the local shell call. Required. + :vartype id: str + :ivar call_id: The unique ID of the local shell tool call generated by the model. Required. + :vartype call_id: str + :ivar action: Required. + :vartype action: ~azure.ai.agentserver.responses.models.types.LocalShellExecAction + :ivar status: The status of the local shell call. Required. Is one of the following types: + Literal["in_progress"], Literal["completed"], Literal["incomplete"] + :vartype status: str or str or str + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + type: Required[Literal[OutputItemType.LOCAL_SHELL_CALL]] + """The type of the local shell call. Always ``local_shell_call``. Required. LOCAL_SHELL_CALL.""" + id: Required[str] + """The unique ID of the local shell call. Required.""" + call_id: Required[str] + """The unique ID of the local shell tool call generated by the model. Required.""" + action: Required["LocalShellExecAction"] + """Required.""" + status: Required[Literal["in_progress", "completed", "incomplete"]] + """The status of the local shell call. Required. Is one of the following types: + Literal[\"in_progress\"], Literal[\"completed\"], Literal[\"incomplete\"]""" + + +class OutputItemLocalShellToolCallOutput(TypedDict, total=False): + """Local shell call output. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar type: The type of the local shell tool call output. Always ``local_shell_call_output``. + Required. LOCAL_SHELL_CALL_OUTPUT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.LOCAL_SHELL_CALL_OUTPUT + :ivar id: The unique ID of the local shell tool call generated by the model. Required. + :vartype id: str + :ivar output: A JSON string of the output of the local shell tool call. Required. + :vartype output: str + :ivar status: Is one of the following types: Literal["in_progress"], Literal["completed"], + Literal["incomplete"] + :vartype status: str or str or str + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + type: Required[Literal[OutputItemType.LOCAL_SHELL_CALL_OUTPUT]] + """The type of the local shell tool call output. Always ``local_shell_call_output``. Required. + LOCAL_SHELL_CALL_OUTPUT.""" + id: Required[str] + """The unique ID of the local shell tool call generated by the model. Required.""" + output: Required[str] + """A JSON string of the output of the local shell tool call. Required.""" + status: Optional[Literal["in_progress", "completed", "incomplete"]] + """Is one of the following types: Literal[\"in_progress\"], Literal[\"completed\"], + Literal[\"incomplete\"]""" + + +class OutputItemMcpApprovalRequest(TypedDict, total=False): + """MCP approval request. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar type: The type of the item. Always ``mcp_approval_request``. Required. + MCP_APPROVAL_REQUEST. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.MCP_APPROVAL_REQUEST + :ivar id: The unique ID of the approval request. Required. + :vartype id: str + :ivar server_label: The label of the MCP server making the request. Required. + :vartype server_label: str + :ivar name: The name of the tool to run. Required. + :vartype name: str + :ivar arguments: A JSON string of arguments for the tool. Required. + :vartype arguments: str + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + type: Required[Literal[OutputItemType.MCP_APPROVAL_REQUEST]] + """The type of the item. Always ``mcp_approval_request``. Required. MCP_APPROVAL_REQUEST.""" + id: Required[str] + """The unique ID of the approval request. Required.""" + server_label: Required[str] + """The label of the MCP server making the request. Required.""" + name: Required[str] + """The name of the tool to run. Required.""" + arguments: Required[str] + """A JSON string of arguments for the tool. Required.""" + + +class OutputItemMcpApprovalResponseResource(TypedDict, total=False): + """MCP approval response. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar type: The type of the item. Always ``mcp_approval_response``. Required. + MCP_APPROVAL_RESPONSE. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.MCP_APPROVAL_RESPONSE + :ivar id: The unique ID of the approval response. Required. + :vartype id: str + :ivar approval_request_id: The ID of the approval request being answered. Required. + :vartype approval_request_id: str + :ivar approve: Whether the request was approved. Required. + :vartype approve: bool + :ivar reason: + :vartype reason: str + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + type: Required[Literal[OutputItemType.MCP_APPROVAL_RESPONSE]] + """The type of the item. Always ``mcp_approval_response``. Required. MCP_APPROVAL_RESPONSE.""" + id: Required[str] + """The unique ID of the approval response. Required.""" + approval_request_id: Required[str] + """The ID of the approval request being answered. Required.""" + approve: Required[bool] + """Whether the request was approved. Required.""" + reason: Optional[str] + + +class OutputItemMcpListTools(TypedDict, total=False): + """MCP list tools. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar type: The type of the item. Always ``mcp_list_tools``. Required. MCP_LIST_TOOLS. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.MCP_LIST_TOOLS + :ivar id: The unique ID of the list. Required. + :vartype id: str + :ivar server_label: The label of the MCP server. Required. + :vartype server_label: str + :ivar tools: The tools available on the server. Required. + :vartype tools: list[~azure.ai.agentserver.responses.models.types.MCPListToolsTool] + :ivar error: + :vartype error: str + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + type: Required[Literal[OutputItemType.MCP_LIST_TOOLS]] + """The type of the item. Always ``mcp_list_tools``. Required. MCP_LIST_TOOLS.""" + id: Required[str] + """The unique ID of the list. Required.""" + server_label: Required[str] + """The label of the MCP server. Required.""" + tools: Required[list["MCPListToolsTool"]] + """The tools available on the server. Required.""" + error: Optional[str] + + +class OutputItemMcpToolCall(TypedDict, total=False): + """MCP tool call. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar type: The type of the item. Always ``mcp_call``. Required. MCP_CALL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.MCP_CALL + :ivar id: The unique ID of the tool call. Required. + :vartype id: str + :ivar server_label: The label of the MCP server running the tool. Required. + :vartype server_label: str + :ivar name: The name of the tool that was run. Required. + :vartype name: str + :ivar arguments: A JSON string of the arguments passed to the tool. Required. + :vartype arguments: str + :ivar output: + :vartype output: str + :ivar error: + :vartype error: dict[str, any] + :ivar status: The status of the tool call. One of ``in_progress``, ``completed``, + ``incomplete``, ``calling``, or ``failed``. Known values are: "in_progress", "completed", + "incomplete", "calling", and "failed". + :vartype status: str or ~azure.ai.agentserver.responses.models.models.MCPToolCallStatus + :ivar approval_request_id: + :vartype approval_request_id: str + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + type: Required[Literal[OutputItemType.MCP_CALL]] + """The type of the item. Always ``mcp_call``. Required. MCP_CALL.""" + id: Required[str] + """The unique ID of the tool call. Required.""" + server_label: Required[str] + """The label of the MCP server running the tool. Required.""" + name: Required[str] + """The name of the tool that was run. Required.""" + arguments: Required[str] + """A JSON string of the arguments passed to the tool. Required.""" + output: Optional[str] + error: dict[str, Any] + status: MCPToolCallStatus + """The status of the tool call. One of ``in_progress``, ``completed``, ``incomplete``, + ``calling``, or ``failed``. Known values are: \"in_progress\", \"completed\", \"incomplete\", + \"calling\", and \"failed\".""" + approval_request_id: Optional[str] + + +class OutputItemMessage(TypedDict, total=False): + """Message. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar type: The type of the message. Always set to ``message``. Required. MESSAGE. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.MESSAGE + :ivar id: The unique ID of the message. Required. + :vartype id: str + :ivar status: The status of item. One of ``in_progress``, ``completed``, or ``incomplete``. + Populated when items are returned via API. Required. Known values are: "in_progress", + "completed", and "incomplete". + :vartype status: str or ~azure.ai.agentserver.responses.models.models.MessageStatus + :ivar role: The role of the message. One of ``unknown``, ``user``, ``assistant``, ``system``, + ``critic``, ``discriminator``, ``developer``, or ``tool``. Required. Known values are: + "unknown", "user", "assistant", "system", "critic", "discriminator", "developer", and "tool". + :vartype role: str or ~azure.ai.agentserver.responses.models.models.MessageRole + :ivar content: The content of the message. Required. + :vartype content: list[~azure.ai.agentserver.responses.models.types.MessageContent] + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + type: Required[Literal[OutputItemType.MESSAGE]] + """The type of the message. Always set to ``message``. Required. MESSAGE.""" + id: Required[str] + """The unique ID of the message. Required.""" + status: Required[MessageStatus] + """The status of item. One of ``in_progress``, ``completed``, or ``incomplete``. Populated when + items are returned via API. Required. Known values are: \"in_progress\", \"completed\", and + \"incomplete\".""" + role: Required[MessageRole] + """The role of the message. One of ``unknown``, ``user``, ``assistant``, ``system``, ``critic``, + ``discriminator``, ``developer``, or ``tool``. Required. Known values are: \"unknown\", + \"user\", \"assistant\", \"system\", \"critic\", \"discriminator\", \"developer\", and + \"tool\".""" + content: Required[list["MessageContent"]] + """The content of the message. Required.""" + + +class OutputItemOutputMessage(TypedDict, total=False): + """Output message. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar id: The unique ID of the output message. Required. + :vartype id: str + :ivar type: The type of the output message. Always ``message``. Required. OUTPUT_MESSAGE. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.OUTPUT_MESSAGE + :ivar role: The role of the output message. Always ``assistant``. Required. Default value is + "assistant". + :vartype role: str + :ivar content: The content of the output message. Required. + :vartype content: list[~azure.ai.agentserver.responses.models.types.OutputMessageContent] + :ivar status: The status of the message input. One of ``in_progress``, ``completed``, or + ``incomplete``. Populated when input items are returned via API. Required. Is one of the + following types: Literal["in_progress"], Literal["completed"], Literal["incomplete"] + :vartype status: str or str or str + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + id: Required[str] + """The unique ID of the output message. Required.""" + type: Required[Literal[OutputItemType.OUTPUT_MESSAGE]] + """The type of the output message. Always ``message``. Required. OUTPUT_MESSAGE.""" + role: Required[Literal["assistant"]] + """The role of the output message. Always ``assistant``. Required. Default value is \"assistant\".""" + content: Required[list["OutputMessageContent"]] + """The content of the output message. Required.""" + status: Required[Literal["in_progress", "completed", "incomplete"]] + """The status of the message input. One of ``in_progress``, ``completed``, or ``incomplete``. + Populated when input items are returned via API. Required. Is one of the following types: + Literal[\"in_progress\"], Literal[\"completed\"], Literal[\"incomplete\"]""" + + +class OutputItemReasoningItem(TypedDict, total=False): + """Reasoning. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar type: The type of the object. Always ``reasoning``. Required. REASONING. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.REASONING + :ivar id: The unique identifier of the reasoning content. Required. + :vartype id: str + :ivar encrypted_content: + :vartype encrypted_content: str + :ivar summary: Reasoning summary content. Required. + :vartype summary: list[~azure.ai.agentserver.responses.models.types.SummaryTextContent] + :ivar content: Reasoning text content. + :vartype content: list[~azure.ai.agentserver.responses.models.types.ReasoningTextContent] + :ivar status: The status of the item. One of ``in_progress``, ``completed``, or ``incomplete``. + Populated when items are returned via API. Is one of the following types: + Literal["in_progress"], Literal["completed"], Literal["incomplete"] + :vartype status: str or str or str + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + type: Required[Literal[OutputItemType.REASONING]] + """The type of the object. Always ``reasoning``. Required. REASONING.""" + id: Required[str] + """The unique identifier of the reasoning content. Required.""" + encrypted_content: Optional[str] + summary: Required[list["SummaryTextContent"]] + """Reasoning summary content. Required.""" + content: list["ReasoningTextContent"] + """Reasoning text content.""" + status: Literal["in_progress", "completed", "incomplete"] + """The status of the item. One of ``in_progress``, ``completed``, or ``incomplete``. Populated + when items are returned via API. Is one of the following types: Literal[\"in_progress\"], + Literal[\"completed\"], Literal[\"incomplete\"]""" + + +class OutputItemWebSearchToolCall(TypedDict, total=False): + """Web search tool call. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar id: The unique ID of the web search tool call. Required. + :vartype id: str + :ivar type: The type of the web search tool call. Always ``web_search_call``. Required. + WEB_SEARCH_CALL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.WEB_SEARCH_CALL + :ivar status: The status of the web search tool call. Required. Is one of the following types: + Literal["in_progress"], Literal["searching"], Literal["completed"], Literal["failed"] + :vartype status: str or str or str or str + :ivar action: An object describing the specific action taken in this web search call. Includes + details on how the model used the web (search, open_page, find_in_page). Required. Is one of + the following types: WebSearchActionSearch, WebSearchActionOpenPage, WebSearchActionFind + :vartype action: ~azure.ai.agentserver.responses.models.types.WebSearchActionSearch or + ~azure.ai.agentserver.responses.models.types.WebSearchActionOpenPage or + ~azure.ai.agentserver.responses.models.types.WebSearchActionFind + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + id: Required[str] + """The unique ID of the web search tool call. Required.""" + type: Required[Literal[OutputItemType.WEB_SEARCH_CALL]] + """The type of the web search tool call. Always ``web_search_call``. Required. WEB_SEARCH_CALL.""" + status: Required[Literal["in_progress", "searching", "completed", "failed"]] + """The status of the web search tool call. Required. Is one of the following types: + Literal[\"in_progress\"], Literal[\"searching\"], Literal[\"completed\"], Literal[\"failed\"]""" + action: Required[Union["WebSearchActionSearch", "WebSearchActionOpenPage", "WebSearchActionFind"]] + """An object describing the specific action taken in this web search call. Includes details on how + the model used the web (search, open_page, find_in_page). Required. Is one of the following + types: WebSearchActionSearch, WebSearchActionOpenPage, WebSearchActionFind""" + + +class OutputMessageContentOutputTextContent(TypedDict, total=False): + """Output text. + + :ivar type: The type of the output text. Always ``output_text``. Required. OUTPUT_TEXT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.OUTPUT_TEXT + :ivar text: The text output from the model. Required. + :vartype text: str + :ivar annotations: The annotations of the text output. Required. + :vartype annotations: list[~azure.ai.agentserver.responses.models.types.Annotation] + :ivar logprobs: Required. + :vartype logprobs: list[~azure.ai.agentserver.responses.models.types.LogProb] + """ + + type: Required[Literal[OutputMessageContentType.OUTPUT_TEXT]] + """The type of the output text. Always ``output_text``. Required. OUTPUT_TEXT.""" + text: Required[str] + """The text output from the model. Required.""" + annotations: Required[list["Annotation"]] + """The annotations of the text output. Required.""" + logprobs: Required[list["LogProb"]] + """Required.""" + + +class OutputMessageContentRefusalContent(TypedDict, total=False): + """Refusal. + + :ivar type: The type of the refusal. Always ``refusal``. Required. REFUSAL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.REFUSAL + :ivar refusal: The refusal explanation from the model. Required. + :vartype refusal: str + """ + + type: Required[Literal[OutputMessageContentType.REFUSAL]] + """The type of the refusal. Always ``refusal``. Required. REFUSAL.""" + refusal: Required[str] + """The refusal explanation from the model. Required.""" + + +class Prompt(TypedDict, total=False): + """Reference to a prompt template and its variables. `Learn more + `_. + + :ivar id: The unique identifier of the prompt template to use. Required. + :vartype id: str + :ivar version: + :vartype version: str + :ivar variables: + :vartype variables: ~azure.ai.agentserver.responses.models.types.ResponsePromptVariables + """ + + id: Required[str] + """The unique identifier of the prompt template to use. Required.""" + version: Optional[str] + variables: Optional["ResponsePromptVariables"] + + +class RankingOptions(TypedDict, total=False): + """RankingOptions. + + :ivar ranker: The ranker to use for the file search. Known values are: "auto" and + "default-2024-11-15". + :vartype ranker: str or ~azure.ai.agentserver.responses.models.models.RankerVersionType + :ivar score_threshold: The score threshold for the file search, a number between 0 and 1. + Numbers closer to 1 will attempt to return only the most relevant results, but may return fewer + results. + :vartype score_threshold: float + :ivar hybrid_search: Weights that control how reciprocal rank fusion balances semantic + embedding matches versus sparse keyword matches when hybrid search is enabled. + :vartype hybrid_search: ~azure.ai.agentserver.responses.models.types.HybridSearchOptions + """ + + ranker: RankerVersionType + """The ranker to use for the file search. Known values are: \"auto\" and \"default-2024-11-15\".""" + score_threshold: float + """The score threshold for the file search, a number between 0 and 1. Numbers closer to 1 will + attempt to return only the most relevant results, but may return fewer results.""" + hybrid_search: "HybridSearchOptions" + """Weights that control how reciprocal rank fusion balances semantic embedding matches versus + sparse keyword matches when hybrid search is enabled.""" + + +class Reasoning(TypedDict, total=False): + """Reasoning. + + :ivar effort: Is one of the following types: Literal["none"], Literal["minimal"], + Literal["low"], Literal["medium"], Literal["high"], Literal["xhigh"] + :vartype effort: str or str or str or str or str or str + :ivar summary: Is one of the following types: Literal["auto"], Literal["concise"], + Literal["detailed"] + :vartype summary: str or str or str + :ivar generate_summary: Is one of the following types: Literal["auto"], Literal["concise"], + Literal["detailed"] + :vartype generate_summary: str or str or str + """ + + effort: Optional[Literal["none", "minimal", "low", "medium", "high", "xhigh"]] + """Is one of the following types: Literal[\"none\"], Literal[\"minimal\"], Literal[\"low\"], + Literal[\"medium\"], Literal[\"high\"], Literal[\"xhigh\"]""" + summary: Optional[Literal["auto", "concise", "detailed"]] + """Is one of the following types: Literal[\"auto\"], Literal[\"concise\"], Literal[\"detailed\"]""" + generate_summary: Optional[Literal["auto", "concise", "detailed"]] + """Is one of the following types: Literal[\"auto\"], Literal[\"concise\"], Literal[\"detailed\"]""" + + +class ReasoningTextContent(TypedDict, total=False): + """Reasoning text. + + :ivar type: The type of the reasoning text. Always ``reasoning_text``. Required. Default value + is "reasoning_text". + :vartype type: str + :ivar text: The reasoning text from the model. Required. + :vartype text: str + """ + + type: Required[Literal["reasoning_text"]] + """The type of the reasoning text. Always ``reasoning_text``. Required. Default value is + \"reasoning_text\".""" + text: Required[str] + """The reasoning text from the model. Required.""" + + +class ResponseAudioDeltaEvent(TypedDict, total=False): + """Emitted when there is a partial audio response. + + :ivar type: The type of the event. Always ``response.audio.delta``. Required. + RESPONSE_AUDIO_DELTA. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.RESPONSE_AUDIO_DELTA + :ivar sequence_number: A sequence number for this chunk of the stream response. Required. + :vartype sequence_number: int + :ivar delta: A chunk of Base64 encoded response audio bytes. Required. + :vartype delta: bytes + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_AUDIO_DELTA]] + """The type of the event. Always ``response.audio.delta``. Required. RESPONSE_AUDIO_DELTA.""" + sequence_number: Required[int] + """A sequence number for this chunk of the stream response. Required.""" + delta: Required[str] + """A chunk of Base64 encoded response audio bytes. Required.""" + + +class ResponseAudioDoneEvent(TypedDict, total=False): + """Emitted when the audio response is complete. + + :ivar type: The type of the event. Always ``response.audio.done``. Required. + RESPONSE_AUDIO_DONE. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.RESPONSE_AUDIO_DONE + :ivar sequence_number: The sequence number of the delta. Required. + :vartype sequence_number: int + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_AUDIO_DONE]] + """The type of the event. Always ``response.audio.done``. Required. RESPONSE_AUDIO_DONE.""" + sequence_number: Required[int] + """The sequence number of the delta. Required.""" + + +class ResponseAudioTranscriptDeltaEvent(TypedDict, total=False): + """Emitted when there is a partial transcript of audio. + + :ivar type: The type of the event. Always ``response.audio.transcript.delta``. Required. + RESPONSE_AUDIO_TRANSCRIPT_DELTA. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.RESPONSE_AUDIO_TRANSCRIPT_DELTA + :ivar delta: The partial transcript of the audio response. Required. + :vartype delta: str + :ivar sequence_number: The sequence number of this event. Required. + :vartype sequence_number: int + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_AUDIO_TRANSCRIPT_DELTA]] + """The type of the event. Always ``response.audio.transcript.delta``. Required. + RESPONSE_AUDIO_TRANSCRIPT_DELTA.""" + delta: Required[str] + """The partial transcript of the audio response. Required.""" + sequence_number: Required[int] + """The sequence number of this event. Required.""" + + +class ResponseAudioTranscriptDoneEvent(TypedDict, total=False): + """Emitted when the full audio transcript is completed. + + :ivar type: The type of the event. Always ``response.audio.transcript.done``. Required. + RESPONSE_AUDIO_TRANSCRIPT_DONE. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.RESPONSE_AUDIO_TRANSCRIPT_DONE + :ivar sequence_number: The sequence number of this event. Required. + :vartype sequence_number: int + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_AUDIO_TRANSCRIPT_DONE]] + """The type of the event. Always ``response.audio.transcript.done``. Required. + RESPONSE_AUDIO_TRANSCRIPT_DONE.""" + sequence_number: Required[int] + """The sequence number of this event. Required.""" + + +class ResponseCodeInterpreterCallCodeDeltaEvent(TypedDict, total=False): # pylint: disable=name-too-long + """Emitted when a partial code snippet is streamed by the code interpreter. + + :ivar type: The type of the event. Always ``response.code_interpreter_call_code.delta``. + Required. RESPONSE_CODE_INTERPRETER_CALL_CODE_DELTA. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.RESPONSE_CODE_INTERPRETER_CALL_CODE_DELTA + :ivar output_index: The index of the output item in the response for which the code is being + streamed. Required. + :vartype output_index: int + :ivar item_id: The unique identifier of the code interpreter tool call item. Required. + :vartype item_id: str + :ivar delta: The partial code snippet being streamed by the code interpreter. Required. + :vartype delta: str + :ivar sequence_number: The sequence number of this event, used to order streaming events. + Required. + :vartype sequence_number: int + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_CODE_INTERPRETER_CALL_CODE_DELTA]] + """The type of the event. Always ``response.code_interpreter_call_code.delta``. Required. + RESPONSE_CODE_INTERPRETER_CALL_CODE_DELTA.""" + output_index: Required[int] + """The index of the output item in the response for which the code is being streamed. Required.""" + item_id: Required[str] + """The unique identifier of the code interpreter tool call item. Required.""" + delta: Required[str] + """The partial code snippet being streamed by the code interpreter. Required.""" + sequence_number: Required[int] + """The sequence number of this event, used to order streaming events. Required.""" + + +class ResponseCodeInterpreterCallCodeDoneEvent(TypedDict, total=False): + """Emitted when the code snippet is finalized by the code interpreter. + + :ivar type: The type of the event. Always ``response.code_interpreter_call_code.done``. + Required. RESPONSE_CODE_INTERPRETER_CALL_CODE_DONE. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.RESPONSE_CODE_INTERPRETER_CALL_CODE_DONE + :ivar output_index: The index of the output item in the response for which the code is + finalized. Required. + :vartype output_index: int + :ivar item_id: The unique identifier of the code interpreter tool call item. Required. + :vartype item_id: str + :ivar code: The final code snippet output by the code interpreter. Required. + :vartype code: str + :ivar sequence_number: The sequence number of this event, used to order streaming events. + Required. + :vartype sequence_number: int + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_CODE_INTERPRETER_CALL_CODE_DONE]] + """The type of the event. Always ``response.code_interpreter_call_code.done``. Required. + RESPONSE_CODE_INTERPRETER_CALL_CODE_DONE.""" + output_index: Required[int] + """The index of the output item in the response for which the code is finalized. Required.""" + item_id: Required[str] + """The unique identifier of the code interpreter tool call item. Required.""" + code: Required[str] + """The final code snippet output by the code interpreter. Required.""" + sequence_number: Required[int] + """The sequence number of this event, used to order streaming events. Required.""" + + +class ResponseCodeInterpreterCallCompletedEvent(TypedDict, total=False): # pylint: disable=name-too-long + """Emitted when the code interpreter call is completed. + + :ivar type: The type of the event. Always ``response.code_interpreter_call.completed``. + Required. RESPONSE_CODE_INTERPRETER_CALL_COMPLETED. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.RESPONSE_CODE_INTERPRETER_CALL_COMPLETED + :ivar output_index: The index of the output item in the response for which the code interpreter + call is completed. Required. + :vartype output_index: int + :ivar item_id: The unique identifier of the code interpreter tool call item. Required. + :vartype item_id: str + :ivar sequence_number: The sequence number of this event, used to order streaming events. + Required. + :vartype sequence_number: int + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_CODE_INTERPRETER_CALL_COMPLETED]] + """The type of the event. Always ``response.code_interpreter_call.completed``. Required. + RESPONSE_CODE_INTERPRETER_CALL_COMPLETED.""" + output_index: Required[int] + """The index of the output item in the response for which the code interpreter call is completed. + Required.""" + item_id: Required[str] + """The unique identifier of the code interpreter tool call item. Required.""" + sequence_number: Required[int] + """The sequence number of this event, used to order streaming events. Required.""" + + +class ResponseCodeInterpreterCallInProgressEvent(TypedDict, total=False): # pylint: disable=name-too-long + """Emitted when a code interpreter call is in progress. + + :ivar type: The type of the event. Always ``response.code_interpreter_call.in_progress``. + Required. RESPONSE_CODE_INTERPRETER_CALL_IN_PROGRESS. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.RESPONSE_CODE_INTERPRETER_CALL_IN_PROGRESS + :ivar output_index: The index of the output item in the response for which the code interpreter + call is in progress. Required. + :vartype output_index: int + :ivar item_id: The unique identifier of the code interpreter tool call item. Required. + :vartype item_id: str + :ivar sequence_number: The sequence number of this event, used to order streaming events. + Required. + :vartype sequence_number: int + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_CODE_INTERPRETER_CALL_IN_PROGRESS]] + """The type of the event. Always ``response.code_interpreter_call.in_progress``. Required. + RESPONSE_CODE_INTERPRETER_CALL_IN_PROGRESS.""" + output_index: Required[int] + """The index of the output item in the response for which the code interpreter call is in + progress. Required.""" + item_id: Required[str] + """The unique identifier of the code interpreter tool call item. Required.""" + sequence_number: Required[int] + """The sequence number of this event, used to order streaming events. Required.""" + + +class ResponseCodeInterpreterCallInterpretingEvent(TypedDict, total=False): # pylint: disable=name-too-long + """Emitted when the code interpreter is actively interpreting the code snippet. + + :ivar type: The type of the event. Always ``response.code_interpreter_call.interpreting``. + Required. RESPONSE_CODE_INTERPRETER_CALL_INTERPRETING. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.RESPONSE_CODE_INTERPRETER_CALL_INTERPRETING + :ivar output_index: The index of the output item in the response for which the code interpreter + is interpreting code. Required. + :vartype output_index: int + :ivar item_id: The unique identifier of the code interpreter tool call item. Required. + :vartype item_id: str + :ivar sequence_number: The sequence number of this event, used to order streaming events. + Required. + :vartype sequence_number: int + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_CODE_INTERPRETER_CALL_INTERPRETING]] + """The type of the event. Always ``response.code_interpreter_call.interpreting``. Required. + RESPONSE_CODE_INTERPRETER_CALL_INTERPRETING.""" + output_index: Required[int] + """The index of the output item in the response for which the code interpreter is interpreting + code. Required.""" + item_id: Required[str] + """The unique identifier of the code interpreter tool call item. Required.""" + sequence_number: Required[int] + """The sequence number of this event, used to order streaming events. Required.""" + + +class ResponseCompletedEvent(TypedDict, total=False): + """Emitted when the model response is complete. + + :ivar type: The type of the event. Always ``response.completed``. Required. RESPONSE_COMPLETED. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.RESPONSE_COMPLETED + :ivar response: Properties of the completed response. Required. + :vartype response: ~azure.ai.agentserver.responses.models.types.ResponseObject + :ivar sequence_number: The sequence number for this event. Required. + :vartype sequence_number: int + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_COMPLETED]] + """The type of the event. Always ``response.completed``. Required. RESPONSE_COMPLETED.""" + response: Required["ResponseObject"] + """Properties of the completed response. Required.""" + sequence_number: Required[int] + """The sequence number for this event. Required.""" + + +class ResponseContentPartAddedEvent(TypedDict, total=False): + """Emitted when a new content part is added. + + :ivar type: The type of the event. Always ``response.content_part.added``. Required. + RESPONSE_CONTENT_PART_ADDED. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.RESPONSE_CONTENT_PART_ADDED + :ivar item_id: The ID of the output item that the content part was added to. Required. + :vartype item_id: str + :ivar output_index: The index of the output item that the content part was added to. Required. + :vartype output_index: int + :ivar content_index: The index of the content part that was added. Required. + :vartype content_index: int + :ivar part: The content part that was added. Required. + :vartype part: ~azure.ai.agentserver.responses.models.types.OutputContent + :ivar sequence_number: The sequence number of this event. Required. + :vartype sequence_number: int + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_CONTENT_PART_ADDED]] + """The type of the event. Always ``response.content_part.added``. Required. + RESPONSE_CONTENT_PART_ADDED.""" + item_id: Required[str] + """The ID of the output item that the content part was added to. Required.""" + output_index: Required[int] + """The index of the output item that the content part was added to. Required.""" + content_index: Required[int] + """The index of the content part that was added. Required.""" + part: Required["OutputContent"] + """The content part that was added. Required.""" + sequence_number: Required[int] + """The sequence number of this event. Required.""" + + +class ResponseContentPartDoneEvent(TypedDict, total=False): + """Emitted when a content part is done. + + :ivar type: The type of the event. Always ``response.content_part.done``. Required. + RESPONSE_CONTENT_PART_DONE. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.RESPONSE_CONTENT_PART_DONE + :ivar item_id: The ID of the output item that the content part was added to. Required. + :vartype item_id: str + :ivar output_index: The index of the output item that the content part was added to. Required. + :vartype output_index: int + :ivar content_index: The index of the content part that is done. Required. + :vartype content_index: int + :ivar sequence_number: The sequence number of this event. Required. + :vartype sequence_number: int + :ivar part: The content part that is done. Required. + :vartype part: ~azure.ai.agentserver.responses.models.types.OutputContent + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_CONTENT_PART_DONE]] + """The type of the event. Always ``response.content_part.done``. Required. + RESPONSE_CONTENT_PART_DONE.""" + item_id: Required[str] + """The ID of the output item that the content part was added to. Required.""" + output_index: Required[int] + """The index of the output item that the content part was added to. Required.""" + content_index: Required[int] + """The index of the content part that is done. Required.""" + sequence_number: Required[int] + """The sequence number of this event. Required.""" + part: Required["OutputContent"] + """The content part that is done. Required.""" + + +class ResponseCreatedEvent(TypedDict, total=False): + """An event that is emitted when a response is created. + + :ivar type: The type of the event. Always ``response.created``. Required. RESPONSE_CREATED. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.RESPONSE_CREATED + :ivar response: The response that was created. Required. + :vartype response: ~azure.ai.agentserver.responses.models.types.ResponseObject + :ivar sequence_number: The sequence number for this event. Required. + :vartype sequence_number: int + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_CREATED]] + """The type of the event. Always ``response.created``. Required. RESPONSE_CREATED.""" + response: Required["ResponseObject"] + """The response that was created. Required.""" + sequence_number: Required[int] + """The sequence number for this event. Required.""" + + +class ResponseCustomToolCallInputDeltaEvent(TypedDict, total=False): + """ResponseCustomToolCallInputDelta. + + :ivar type: The event type identifier. Required. RESPONSE_CUSTOM_TOOL_CALL_INPUT_DELTA. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.RESPONSE_CUSTOM_TOOL_CALL_INPUT_DELTA + :ivar sequence_number: The sequence number of this event. Required. + :vartype sequence_number: int + :ivar output_index: The index of the output this delta applies to. Required. + :vartype output_index: int + :ivar item_id: Unique identifier for the API item associated with this event. Required. + :vartype item_id: str + :ivar delta: The incremental input data (delta) for the custom tool call. Required. + :vartype delta: str + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_CUSTOM_TOOL_CALL_INPUT_DELTA]] + """The event type identifier. Required. RESPONSE_CUSTOM_TOOL_CALL_INPUT_DELTA.""" + sequence_number: Required[int] + """The sequence number of this event. Required.""" + output_index: Required[int] + """The index of the output this delta applies to. Required.""" + item_id: Required[str] + """Unique identifier for the API item associated with this event. Required.""" + delta: Required[str] + """The incremental input data (delta) for the custom tool call. Required.""" + + +class ResponseCustomToolCallInputDoneEvent(TypedDict, total=False): + """ResponseCustomToolCallInputDone. + + :ivar type: The event type identifier. Required. RESPONSE_CUSTOM_TOOL_CALL_INPUT_DONE. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.RESPONSE_CUSTOM_TOOL_CALL_INPUT_DONE + :ivar sequence_number: The sequence number of this event. Required. + :vartype sequence_number: int + :ivar output_index: The index of the output this event applies to. Required. + :vartype output_index: int + :ivar item_id: Unique identifier for the API item associated with this event. Required. + :vartype item_id: str + :ivar input: The complete input data for the custom tool call. Required. + :vartype input: str + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_CUSTOM_TOOL_CALL_INPUT_DONE]] + """The event type identifier. Required. RESPONSE_CUSTOM_TOOL_CALL_INPUT_DONE.""" + sequence_number: Required[int] + """The sequence number of this event. Required.""" + output_index: Required[int] + """The index of the output this event applies to. Required.""" + item_id: Required[str] + """Unique identifier for the API item associated with this event. Required.""" + input: Required[str] + """The complete input data for the custom tool call. Required.""" + + +class ResponseErrorEvent(TypedDict, total=False): + """Emitted when an error occurs. + + :ivar type: The type of the event. Always ``error``. Required. ERROR. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.ERROR + :ivar code: Required. + :vartype code: str + :ivar message: The error message. Required. + :vartype message: str + :ivar param: Required. + :vartype param: str + :ivar sequence_number: The sequence number of this event. Required. + :vartype sequence_number: int + """ + + type: Required[Literal[ResponseStreamEventType.ERROR]] + """The type of the event. Always ``error``. Required. ERROR.""" + code: Required[Optional[str]] + """Required.""" + message: Required[str] + """The error message. Required.""" + param: Required[Optional[str]] + """Required.""" + sequence_number: Required[int] + """The sequence number of this event. Required.""" + + +class ResponseErrorInfo(TypedDict, total=False): + """An error object returned when the model fails to generate a Response. + + :ivar code: Required. Known values are: "server_error", "rate_limit_exceeded", + "invalid_prompt", "vector_store_timeout", "invalid_image", "invalid_image_format", + "invalid_base64_image", "invalid_image_url", "image_too_large", "image_too_small", + "image_parse_error", "image_content_policy_violation", "invalid_image_mode", + "image_file_too_large", "unsupported_image_media_type", "empty_image_file", + "failed_to_download_image", and "image_file_not_found". + :vartype code: str or ~azure.ai.agentserver.responses.models.models.ResponseErrorCode + :ivar message: A human-readable description of the error. Required. + :vartype message: str + """ + + code: Required[ResponseErrorCode] + """Required. Known values are: \"server_error\", \"rate_limit_exceeded\", \"invalid_prompt\", + \"vector_store_timeout\", \"invalid_image\", \"invalid_image_format\", + \"invalid_base64_image\", \"invalid_image_url\", \"image_too_large\", \"image_too_small\", + \"image_parse_error\", \"image_content_policy_violation\", \"invalid_image_mode\", + \"image_file_too_large\", \"unsupported_image_media_type\", \"empty_image_file\", + \"failed_to_download_image\", and \"image_file_not_found\".""" + message: Required[str] + """A human-readable description of the error. Required.""" + + +class ResponseFailedEvent(TypedDict, total=False): + """An event that is emitted when a response fails. + + :ivar type: The type of the event. Always ``response.failed``. Required. RESPONSE_FAILED. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.RESPONSE_FAILED + :ivar sequence_number: The sequence number of this event. Required. + :vartype sequence_number: int + :ivar response: The response that failed. Required. + :vartype response: ~azure.ai.agentserver.responses.models.types.ResponseObject + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_FAILED]] + """The type of the event. Always ``response.failed``. Required. RESPONSE_FAILED.""" + sequence_number: Required[int] + """The sequence number of this event. Required.""" + response: Required["ResponseObject"] + """The response that failed. Required.""" + + +class ResponseFileSearchCallCompletedEvent(TypedDict, total=False): + """Emitted when a file search call is completed (results found). + + :ivar type: The type of the event. Always ``response.file_search_call.completed``. Required. + RESPONSE_FILE_SEARCH_CALL_COMPLETED. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.RESPONSE_FILE_SEARCH_CALL_COMPLETED + :ivar output_index: The index of the output item that the file search call is initiated. + Required. + :vartype output_index: int + :ivar item_id: The ID of the output item that the file search call is initiated. Required. + :vartype item_id: str + :ivar sequence_number: The sequence number of this event. Required. + :vartype sequence_number: int + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_FILE_SEARCH_CALL_COMPLETED]] + """The type of the event. Always ``response.file_search_call.completed``. Required. + RESPONSE_FILE_SEARCH_CALL_COMPLETED.""" + output_index: Required[int] + """The index of the output item that the file search call is initiated. Required.""" + item_id: Required[str] + """The ID of the output item that the file search call is initiated. Required.""" + sequence_number: Required[int] + """The sequence number of this event. Required.""" + + +class ResponseFileSearchCallInProgressEvent(TypedDict, total=False): + """Emitted when a file search call is initiated. + + :ivar type: The type of the event. Always ``response.file_search_call.in_progress``. Required. + RESPONSE_FILE_SEARCH_CALL_IN_PROGRESS. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.RESPONSE_FILE_SEARCH_CALL_IN_PROGRESS + :ivar output_index: The index of the output item that the file search call is initiated. + Required. + :vartype output_index: int + :ivar item_id: The ID of the output item that the file search call is initiated. Required. + :vartype item_id: str + :ivar sequence_number: The sequence number of this event. Required. + :vartype sequence_number: int + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_FILE_SEARCH_CALL_IN_PROGRESS]] + """The type of the event. Always ``response.file_search_call.in_progress``. Required. + RESPONSE_FILE_SEARCH_CALL_IN_PROGRESS.""" + output_index: Required[int] + """The index of the output item that the file search call is initiated. Required.""" + item_id: Required[str] + """The ID of the output item that the file search call is initiated. Required.""" + sequence_number: Required[int] + """The sequence number of this event. Required.""" + + +class ResponseFileSearchCallSearchingEvent(TypedDict, total=False): + """Emitted when a file search is currently searching. + + :ivar type: The type of the event. Always ``response.file_search_call.searching``. Required. + RESPONSE_FILE_SEARCH_CALL_SEARCHING. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.RESPONSE_FILE_SEARCH_CALL_SEARCHING + :ivar output_index: The index of the output item that the file search call is searching. + Required. + :vartype output_index: int + :ivar item_id: The ID of the output item that the file search call is initiated. Required. + :vartype item_id: str + :ivar sequence_number: The sequence number of this event. Required. + :vartype sequence_number: int + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_FILE_SEARCH_CALL_SEARCHING]] + """The type of the event. Always ``response.file_search_call.searching``. Required. + RESPONSE_FILE_SEARCH_CALL_SEARCHING.""" + output_index: Required[int] + """The index of the output item that the file search call is searching. Required.""" + item_id: Required[str] + """The ID of the output item that the file search call is initiated. Required.""" + sequence_number: Required[int] + """The sequence number of this event. Required.""" + + +class ResponseFormatJsonSchemaSchema(TypedDict, total=False): + """JSON schema.""" + + +class ResponseFunctionCallArgumentsDeltaEvent(TypedDict, total=False): + """Emitted when there is a partial function-call arguments delta. + + :ivar type: The type of the event. Always ``response.function_call_arguments.delta``. Required. + RESPONSE_FUNCTION_CALL_ARGUMENTS_DELTA. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.RESPONSE_FUNCTION_CALL_ARGUMENTS_DELTA + :ivar item_id: The ID of the output item that the function-call arguments delta is added to. + Required. + :vartype item_id: str + :ivar output_index: The index of the output item that the function-call arguments delta is + added to. Required. + :vartype output_index: int + :ivar sequence_number: The sequence number of this event. Required. + :vartype sequence_number: int + :ivar delta: The function-call arguments delta that is added. Required. + :vartype delta: str + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_FUNCTION_CALL_ARGUMENTS_DELTA]] + """The type of the event. Always ``response.function_call_arguments.delta``. Required. + RESPONSE_FUNCTION_CALL_ARGUMENTS_DELTA.""" + item_id: Required[str] + """The ID of the output item that the function-call arguments delta is added to. Required.""" + output_index: Required[int] + """The index of the output item that the function-call arguments delta is added to. Required.""" + sequence_number: Required[int] + """The sequence number of this event. Required.""" + delta: Required[str] + """The function-call arguments delta that is added. Required.""" + + +class ResponseFunctionCallArgumentsDoneEvent(TypedDict, total=False): + """Emitted when function-call arguments are finalized. + + :ivar type: Required. RESPONSE_FUNCTION_CALL_ARGUMENTS_DONE. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.RESPONSE_FUNCTION_CALL_ARGUMENTS_DONE + :ivar item_id: The ID of the item. Required. + :vartype item_id: str + :ivar name: The name of the function that was called. Required. + :vartype name: str + :ivar output_index: The index of the output item. Required. + :vartype output_index: int + :ivar sequence_number: The sequence number of this event. Required. + :vartype sequence_number: int + :ivar arguments: The function-call arguments. Required. + :vartype arguments: str + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_FUNCTION_CALL_ARGUMENTS_DONE]] + """Required. RESPONSE_FUNCTION_CALL_ARGUMENTS_DONE.""" + item_id: Required[str] + """The ID of the item. Required.""" + name: Required[str] + """The name of the function that was called. Required.""" + output_index: Required[int] + """The index of the output item. Required.""" + sequence_number: Required[int] + """The sequence number of this event. Required.""" + arguments: Required[str] + """The function-call arguments. Required.""" + + +class ResponseImageGenCallCompletedEvent(TypedDict, total=False): + """ResponseImageGenCallCompletedEvent. + + :ivar type: The type of the event. Always 'response.image_generation_call.completed'. Required. + RESPONSE_IMAGE_GENERATION_CALL_COMPLETED. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.RESPONSE_IMAGE_GENERATION_CALL_COMPLETED + :ivar output_index: The index of the output item in the response's output array. Required. + :vartype output_index: int + :ivar sequence_number: The sequence number of this event. Required. + :vartype sequence_number: int + :ivar item_id: The unique identifier of the image generation item being processed. Required. + :vartype item_id: str + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_IMAGE_GENERATION_CALL_COMPLETED]] + """The type of the event. Always 'response.image_generation_call.completed'. Required. + RESPONSE_IMAGE_GENERATION_CALL_COMPLETED.""" + output_index: Required[int] + """The index of the output item in the response's output array. Required.""" + sequence_number: Required[int] + """The sequence number of this event. Required.""" + item_id: Required[str] + """The unique identifier of the image generation item being processed. Required.""" + + +class ResponseImageGenCallGeneratingEvent(TypedDict, total=False): + """ResponseImageGenCallGeneratingEvent. + + :ivar type: The type of the event. Always 'response.image_generation_call.generating'. + Required. RESPONSE_IMAGE_GENERATION_CALL_GENERATING. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.RESPONSE_IMAGE_GENERATION_CALL_GENERATING + :ivar output_index: The index of the output item in the response's output array. Required. + :vartype output_index: int + :ivar item_id: The unique identifier of the image generation item being processed. Required. + :vartype item_id: str + :ivar sequence_number: The sequence number of the image generation item being processed. + Required. + :vartype sequence_number: int + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_IMAGE_GENERATION_CALL_GENERATING]] + """The type of the event. Always 'response.image_generation_call.generating'. Required. + RESPONSE_IMAGE_GENERATION_CALL_GENERATING.""" + output_index: Required[int] + """The index of the output item in the response's output array. Required.""" + item_id: Required[str] + """The unique identifier of the image generation item being processed. Required.""" + sequence_number: Required[int] + """The sequence number of the image generation item being processed. Required.""" + + +class ResponseImageGenCallInProgressEvent(TypedDict, total=False): + """ResponseImageGenCallInProgressEvent. + + :ivar type: The type of the event. Always 'response.image_generation_call.in_progress'. + Required. RESPONSE_IMAGE_GENERATION_CALL_IN_PROGRESS. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.RESPONSE_IMAGE_GENERATION_CALL_IN_PROGRESS + :ivar output_index: The index of the output item in the response's output array. Required. + :vartype output_index: int + :ivar item_id: The unique identifier of the image generation item being processed. Required. + :vartype item_id: str + :ivar sequence_number: The sequence number of the image generation item being processed. + Required. + :vartype sequence_number: int + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_IMAGE_GENERATION_CALL_IN_PROGRESS]] + """The type of the event. Always 'response.image_generation_call.in_progress'. Required. + RESPONSE_IMAGE_GENERATION_CALL_IN_PROGRESS.""" + output_index: Required[int] + """The index of the output item in the response's output array. Required.""" + item_id: Required[str] + """The unique identifier of the image generation item being processed. Required.""" + sequence_number: Required[int] + """The sequence number of the image generation item being processed. Required.""" + + +class ResponseImageGenCallPartialImageEvent(TypedDict, total=False): + """ResponseImageGenCallPartialImageEvent. + + :ivar type: The type of the event. Always 'response.image_generation_call.partial_image'. + Required. RESPONSE_IMAGE_GENERATION_CALL_PARTIAL_IMAGE. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.RESPONSE_IMAGE_GENERATION_CALL_PARTIAL_IMAGE + :ivar output_index: The index of the output item in the response's output array. Required. + :vartype output_index: int + :ivar item_id: The unique identifier of the image generation item being processed. Required. + :vartype item_id: str + :ivar sequence_number: The sequence number of the image generation item being processed. + Required. + :vartype sequence_number: int + :ivar partial_image_index: 0-based index for the partial image (backend is 1-based, but this is + 0-based for the user). Required. + :vartype partial_image_index: int + :ivar partial_image_b64: Base64-encoded partial image data, suitable for rendering as an image. + Required. + :vartype partial_image_b64: str + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_IMAGE_GENERATION_CALL_PARTIAL_IMAGE]] + """The type of the event. Always 'response.image_generation_call.partial_image'. Required. + RESPONSE_IMAGE_GENERATION_CALL_PARTIAL_IMAGE.""" + output_index: Required[int] + """The index of the output item in the response's output array. Required.""" + item_id: Required[str] + """The unique identifier of the image generation item being processed. Required.""" + sequence_number: Required[int] + """The sequence number of the image generation item being processed. Required.""" + partial_image_index: Required[int] + """0-based index for the partial image (backend is 1-based, but this is 0-based for the user). + Required.""" + partial_image_b64: Required[str] + """Base64-encoded partial image data, suitable for rendering as an image. Required.""" + + +class ResponseIncompleteDetails(TypedDict, total=False): + """ResponseIncompleteDetails. + + :ivar reason: Is either a Literal["max_output_tokens"] type or a Literal["content_filter"] + type. + :vartype reason: str or str + """ + + reason: Literal["max_output_tokens", "content_filter"] + """Is either a Literal[\"max_output_tokens\"] type or a Literal[\"content_filter\"] type.""" + + +class ResponseIncompleteEvent(TypedDict, total=False): + """An event that is emitted when a response finishes as incomplete. + + :ivar type: The type of the event. Always ``response.incomplete``. Required. + RESPONSE_INCOMPLETE. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.RESPONSE_INCOMPLETE + :ivar response: The response that was incomplete. Required. + :vartype response: ~azure.ai.agentserver.responses.models.types.ResponseObject + :ivar sequence_number: The sequence number of this event. Required. + :vartype sequence_number: int + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_INCOMPLETE]] + """The type of the event. Always ``response.incomplete``. Required. RESPONSE_INCOMPLETE.""" + response: Required["ResponseObject"] + """The response that was incomplete. Required.""" + sequence_number: Required[int] + """The sequence number of this event. Required.""" + + +class ResponseInProgressEvent(TypedDict, total=False): + """Emitted when the response is in progress. + + :ivar type: The type of the event. Always ``response.in_progress``. Required. + RESPONSE_IN_PROGRESS. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.RESPONSE_IN_PROGRESS + :ivar response: The response that is in progress. Required. + :vartype response: ~azure.ai.agentserver.responses.models.types.ResponseObject + :ivar sequence_number: The sequence number of this event. Required. + :vartype sequence_number: int + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_IN_PROGRESS]] + """The type of the event. Always ``response.in_progress``. Required. RESPONSE_IN_PROGRESS.""" + response: Required["ResponseObject"] + """The response that is in progress. Required.""" + sequence_number: Required[int] + """The sequence number of this event. Required.""" + + +class ResponseLogProb(TypedDict, total=False): + """A logprob is the logarithmic probability that the model assigns to producing a particular token + at a given position in the sequence. Less-negative (higher) logprob values indicate greater + model confidence in that token choice. + + :ivar token: A possible text token. Required. + :vartype token: str + :ivar logprob: The log probability of this token. Required. + :vartype logprob: float + :ivar top_logprobs: The log probability of the top 20 most likely tokens. + :vartype top_logprobs: + list[~azure.ai.agentserver.responses.models.types.ResponseLogProbTopLogprobs] + """ + + token: Required[str] + """A possible text token. Required.""" + logprob: Required[float] + """The log probability of this token. Required.""" + top_logprobs: list["ResponseLogProbTopLogprobs"] + """The log probability of the top 20 most likely tokens.""" + + +class ResponseLogProbTopLogprobs(TypedDict, total=False): + """ResponseLogProbTopLogprobs. + + :ivar token: + :vartype token: str + :ivar logprob: + :vartype logprob: float + """ + + token: str + logprob: float + + +class ResponseMCPCallArgumentsDeltaEvent(TypedDict, total=False): + """ResponseMCPCallArgumentsDeltaEvent. + + :ivar type: The type of the event. Always 'response.mcp_call_arguments.delta'. Required. + RESPONSE_MCP_CALL_ARGUMENTS_DELTA. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.RESPONSE_MCP_CALL_ARGUMENTS_DELTA + :ivar output_index: The index of the output item in the response's output array. Required. + :vartype output_index: int + :ivar item_id: The unique identifier of the MCP tool call item being processed. Required. + :vartype item_id: str + :ivar delta: A JSON string containing the partial update to the arguments for the MCP tool + call. Required. + :vartype delta: str + :ivar sequence_number: The sequence number of this event. Required. + :vartype sequence_number: int + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_MCP_CALL_ARGUMENTS_DELTA]] + """The type of the event. Always 'response.mcp_call_arguments.delta'. Required. + RESPONSE_MCP_CALL_ARGUMENTS_DELTA.""" + output_index: Required[int] + """The index of the output item in the response's output array. Required.""" + item_id: Required[str] + """The unique identifier of the MCP tool call item being processed. Required.""" + delta: Required[str] + """A JSON string containing the partial update to the arguments for the MCP tool call. Required.""" + sequence_number: Required[int] + """The sequence number of this event. Required.""" + + +class ResponseMCPCallArgumentsDoneEvent(TypedDict, total=False): + """ResponseMCPCallArgumentsDoneEvent. + + :ivar type: The type of the event. Always 'response.mcp_call_arguments.done'. Required. + RESPONSE_MCP_CALL_ARGUMENTS_DONE. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.RESPONSE_MCP_CALL_ARGUMENTS_DONE + :ivar output_index: The index of the output item in the response's output array. Required. + :vartype output_index: int + :ivar item_id: The unique identifier of the MCP tool call item being processed. Required. + :vartype item_id: str + :ivar arguments: A JSON string containing the finalized arguments for the MCP tool call. + Required. + :vartype arguments: str + :ivar sequence_number: The sequence number of this event. Required. + :vartype sequence_number: int + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_MCP_CALL_ARGUMENTS_DONE]] + """The type of the event. Always 'response.mcp_call_arguments.done'. Required. + RESPONSE_MCP_CALL_ARGUMENTS_DONE.""" + output_index: Required[int] + """The index of the output item in the response's output array. Required.""" + item_id: Required[str] + """The unique identifier of the MCP tool call item being processed. Required.""" + arguments: Required[str] + """A JSON string containing the finalized arguments for the MCP tool call. Required.""" + sequence_number: Required[int] + """The sequence number of this event. Required.""" + + +class ResponseMCPCallCompletedEvent(TypedDict, total=False): + """ResponseMCPCallCompletedEvent. + + :ivar type: The type of the event. Always 'response.mcp_call.completed'. Required. + RESPONSE_MCP_CALL_COMPLETED. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.RESPONSE_MCP_CALL_COMPLETED + :ivar item_id: The ID of the MCP tool call item that completed. Required. + :vartype item_id: str + :ivar output_index: The index of the output item that completed. Required. + :vartype output_index: int + :ivar sequence_number: The sequence number of this event. Required. + :vartype sequence_number: int + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_MCP_CALL_COMPLETED]] + """The type of the event. Always 'response.mcp_call.completed'. Required. + RESPONSE_MCP_CALL_COMPLETED.""" + item_id: Required[str] + """The ID of the MCP tool call item that completed. Required.""" + output_index: Required[int] + """The index of the output item that completed. Required.""" + sequence_number: Required[int] + """The sequence number of this event. Required.""" + + +class ResponseMCPCallFailedEvent(TypedDict, total=False): + """ResponseMCPCallFailedEvent. + + :ivar type: The type of the event. Always 'response.mcp_call.failed'. Required. + RESPONSE_MCP_CALL_FAILED. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.RESPONSE_MCP_CALL_FAILED + :ivar item_id: The ID of the MCP tool call item that failed. Required. + :vartype item_id: str + :ivar output_index: The index of the output item that failed. Required. + :vartype output_index: int + :ivar sequence_number: The sequence number of this event. Required. + :vartype sequence_number: int + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_MCP_CALL_FAILED]] + """The type of the event. Always 'response.mcp_call.failed'. Required. RESPONSE_MCP_CALL_FAILED.""" + item_id: Required[str] + """The ID of the MCP tool call item that failed. Required.""" + output_index: Required[int] + """The index of the output item that failed. Required.""" + sequence_number: Required[int] + """The sequence number of this event. Required.""" + + +class ResponseMCPCallInProgressEvent(TypedDict, total=False): + """ResponseMCPCallInProgressEvent. + + :ivar type: The type of the event. Always 'response.mcp_call.in_progress'. Required. + RESPONSE_MCP_CALL_IN_PROGRESS. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.RESPONSE_MCP_CALL_IN_PROGRESS + :ivar sequence_number: The sequence number of this event. Required. + :vartype sequence_number: int + :ivar output_index: The index of the output item in the response's output array. Required. + :vartype output_index: int + :ivar item_id: The unique identifier of the MCP tool call item being processed. Required. + :vartype item_id: str + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_MCP_CALL_IN_PROGRESS]] + """The type of the event. Always 'response.mcp_call.in_progress'. Required. + RESPONSE_MCP_CALL_IN_PROGRESS.""" + sequence_number: Required[int] + """The sequence number of this event. Required.""" + output_index: Required[int] + """The index of the output item in the response's output array. Required.""" + item_id: Required[str] + """The unique identifier of the MCP tool call item being processed. Required.""" + + +class ResponseMCPListToolsCompletedEvent(TypedDict, total=False): + """ResponseMCPListToolsCompletedEvent. + + :ivar type: The type of the event. Always 'response.mcp_list_tools.completed'. Required. + RESPONSE_MCP_LIST_TOOLS_COMPLETED. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.RESPONSE_MCP_LIST_TOOLS_COMPLETED + :ivar item_id: The ID of the MCP tool call item that produced this output. Required. + :vartype item_id: str + :ivar output_index: The index of the output item that was processed. Required. + :vartype output_index: int + :ivar sequence_number: The sequence number of this event. Required. + :vartype sequence_number: int + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_MCP_LIST_TOOLS_COMPLETED]] + """The type of the event. Always 'response.mcp_list_tools.completed'. Required. + RESPONSE_MCP_LIST_TOOLS_COMPLETED.""" + item_id: Required[str] + """The ID of the MCP tool call item that produced this output. Required.""" + output_index: Required[int] + """The index of the output item that was processed. Required.""" + sequence_number: Required[int] + """The sequence number of this event. Required.""" + + +class ResponseMCPListToolsFailedEvent(TypedDict, total=False): + """ResponseMCPListToolsFailedEvent. + + :ivar type: The type of the event. Always 'response.mcp_list_tools.failed'. Required. + RESPONSE_MCP_LIST_TOOLS_FAILED. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.RESPONSE_MCP_LIST_TOOLS_FAILED + :ivar item_id: The ID of the MCP tool call item that failed. Required. + :vartype item_id: str + :ivar output_index: The index of the output item that failed. Required. + :vartype output_index: int + :ivar sequence_number: The sequence number of this event. Required. + :vartype sequence_number: int + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_MCP_LIST_TOOLS_FAILED]] + """The type of the event. Always 'response.mcp_list_tools.failed'. Required. + RESPONSE_MCP_LIST_TOOLS_FAILED.""" + item_id: Required[str] + """The ID of the MCP tool call item that failed. Required.""" + output_index: Required[int] + """The index of the output item that failed. Required.""" + sequence_number: Required[int] + """The sequence number of this event. Required.""" + + +class ResponseMCPListToolsInProgressEvent(TypedDict, total=False): + """ResponseMCPListToolsInProgressEvent. + + :ivar type: The type of the event. Always 'response.mcp_list_tools.in_progress'. Required. + RESPONSE_MCP_LIST_TOOLS_IN_PROGRESS. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.RESPONSE_MCP_LIST_TOOLS_IN_PROGRESS + :ivar item_id: The ID of the MCP tool call item that is being processed. Required. + :vartype item_id: str + :ivar output_index: The index of the output item that is being processed. Required. + :vartype output_index: int + :ivar sequence_number: The sequence number of this event. Required. + :vartype sequence_number: int + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_MCP_LIST_TOOLS_IN_PROGRESS]] + """The type of the event. Always 'response.mcp_list_tools.in_progress'. Required. + RESPONSE_MCP_LIST_TOOLS_IN_PROGRESS.""" + item_id: Required[str] + """The ID of the MCP tool call item that is being processed. Required.""" + output_index: Required[int] + """The index of the output item that is being processed. Required.""" + sequence_number: Required[int] + """The sequence number of this event. Required.""" + + +class ResponseObject(TypedDict, total=False): + """The response object. + + :ivar metadata: + :vartype metadata: ~azure.ai.agentserver.responses.models.types.Metadata + :ivar top_logprobs: + :vartype top_logprobs: int + :ivar temperature: + :vartype temperature: float + :ivar top_p: + :vartype top_p: float + :ivar user: This field is being replaced by ``safety_identifier`` and ``prompt_cache_key``. Use + ``prompt_cache_key`` instead to maintain caching optimizations. A stable identifier for your + end-users. Used to boost cache hit rates by better bucketing similar requests and to help + OpenAI detect and prevent abuse. `Learn more + `_. + :vartype user: str + :ivar safety_identifier: A stable identifier used to help detect users of your application that + may be violating OpenAI's usage policies. The IDs should be a string that uniquely identifies + each user. We recommend hashing their username or email address, in order to avoid sending us + any identifying information. `Learn more + `_. + :vartype safety_identifier: str + :ivar prompt_cache_key: Used by OpenAI to cache responses for similar requests to optimize your + cache hit rates. Replaces the ``user`` field. `Learn more `_. + :vartype prompt_cache_key: str + :ivar service_tier: Is one of the following types: Literal["auto"], Literal["default"], + Literal["flex"], Literal["scale"], Literal["priority"] + :vartype service_tier: str or str or str or str or str + :ivar prompt_cache_retention: Is either a Literal["in-memory"] type or a Literal["24h"] type. + :vartype prompt_cache_retention: str or str + :ivar previous_response_id: + :vartype previous_response_id: str + :ivar model: The model deployment to use for the creation of this response. + :vartype model: str + :ivar reasoning: + :vartype reasoning: ~azure.ai.agentserver.responses.models.types.Reasoning + :ivar background: + :vartype background: bool + :ivar max_output_tokens: + :vartype max_output_tokens: int + :ivar max_tool_calls: + :vartype max_tool_calls: int + :ivar text: + :vartype text: ~azure.ai.agentserver.responses.models.types.ResponseTextParam + :ivar tools: + :vartype tools: list[~azure.ai.agentserver.responses.models.types.Tool] + :ivar tool_choice: Is either a types.ToolChoiceOptions type or a ToolChoiceParam type. + :vartype tool_choice: str or ~azure.ai.agentserver.responses.models.models.ToolChoiceOptions or + ~azure.ai.agentserver.responses.models.types.ToolChoiceParam + :ivar prompt: + :vartype prompt: ~azure.ai.agentserver.responses.models.types.Prompt + :ivar truncation: Is either a Literal["auto"] type or a Literal["disabled"] type. + :vartype truncation: str or str + :ivar id: Unique identifier for this Response. Required. + :vartype id: str + :ivar object: The object type of this resource - always set to ``response``. Required. Default + value is "response". + :vartype object: str + :ivar status: The status of the response generation. One of ``completed``, ``failed``, + ``in_progress``, ``cancelled``, ``queued``, or ``incomplete``. Is one of the following types: + Literal["completed"], Literal["failed"], Literal["in_progress"], Literal["cancelled"], + Literal["queued"], Literal["incomplete"] + :vartype status: str or str or str or str or str or str + :ivar created_at: Unix timestamp (in seconds) of when this Response was created. Required. + :vartype created_at: ~datetime.datetime + :ivar completed_at: + :vartype completed_at: ~datetime.datetime + :ivar error: Required. + :vartype error: ~azure.ai.agentserver.responses.models.types.ResponseErrorInfo + :ivar incomplete_details: Required. + :vartype incomplete_details: + ~azure.ai.agentserver.responses.models.types.ResponseIncompleteDetails + :ivar output: An array of content items generated by the model. + + * The length and order of items in the `output` array is dependent + on the model's response. + * Rather than accessing the first item in the `output` array and + assuming it's an `assistant` message with the content generated by + the model, you might consider using the `output_text` property where + supported in SDKs. Required. + :vartype output: list[~azure.ai.agentserver.responses.models.types.OutputItem] + :ivar instructions: Required. Is either a str type or a [Item] type. + :vartype instructions: str or list[~azure.ai.agentserver.responses.models.types.Item] + :ivar output_text: + :vartype output_text: str + :ivar usage: + :vartype usage: ~azure.ai.agentserver.responses.models.types.ResponseUsage + :ivar parallel_tool_calls: Whether to allow the model to run tool calls in parallel. Required. + :vartype parallel_tool_calls: bool + :ivar conversation: + :vartype conversation: ~azure.ai.agentserver.responses.models.types.ConversationReference + :ivar agent: (Deprecated) Use agent_reference instead. The agent used for this response. + :vartype agent: ~azure.ai.agentserver.responses.models.types.AgentId + :ivar agent_session_id: The session identifier for this response. Currently only relevant for + hosted agents. Always returned for hosted agents — either the caller-provided value, the + auto-derived value, or an auto-generated UUID. Use for session-scoped operations and to + maintain sandbox affinity in follow-up calls. + :vartype agent_session_id: str + :ivar agent_reference: The agent used for this response. Required. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + """ + + metadata: Optional["Metadata"] + top_logprobs: Optional[int] + temperature: Optional[float] + top_p: Optional[float] + user: str + """This field is being replaced by ``safety_identifier`` and ``prompt_cache_key``. Use + ``prompt_cache_key`` instead to maintain caching optimizations. A stable identifier for your + end-users. Used to boost cache hit rates by better bucketing similar requests and to help + OpenAI detect and prevent abuse. `Learn more + `_.""" + safety_identifier: str + """A stable identifier used to help detect users of your application that may be violating + OpenAI's usage policies. The IDs should be a string that uniquely identifies each user. We + recommend hashing their username or email address, in order to avoid sending us any identifying + information. `Learn more `_.""" + prompt_cache_key: str + """Used by OpenAI to cache responses for similar requests to optimize your cache hit rates. + Replaces the ``user`` field. `Learn more `_.""" + service_tier: Optional[Literal["auto", "default", "flex", "scale", "priority"]] + """Is one of the following types: Literal[\"auto\"], Literal[\"default\"], Literal[\"flex\"], + Literal[\"scale\"], Literal[\"priority\"]""" + prompt_cache_retention: Optional[Literal["in-memory", "24h"]] + """Is either a Literal[\"in-memory\"] type or a Literal[\"24h\"] type.""" + previous_response_id: Optional[str] + model: str + """The model deployment to use for the creation of this response.""" + reasoning: Optional["Reasoning"] + background: Optional[bool] + max_output_tokens: Optional[int] + max_tool_calls: Optional[int] + text: "ResponseTextParam" + tools: list["Tool"] + tool_choice: Union[ToolChoiceOptions, "ToolChoiceParam"] + """Is either a types.ToolChoiceOptions type or a ToolChoiceParam type.""" + prompt: "Prompt" + truncation: Optional[Literal["auto", "disabled"]] + """Is either a Literal[\"auto\"] type or a Literal[\"disabled\"] type.""" + id: Required[str] + """Unique identifier for this Response. Required.""" + object: Required[Literal["response"]] + """The object type of this resource - always set to ``response``. Required. Default value is + \"response\".""" + status: Literal["completed", "failed", "in_progress", "cancelled", "queued", "incomplete"] + """The status of the response generation. One of ``completed``, ``failed``, ``in_progress``, + ``cancelled``, ``queued``, or ``incomplete``. Is one of the following types: + Literal[\"completed\"], Literal[\"failed\"], Literal[\"in_progress\"], Literal[\"cancelled\"], + Literal[\"queued\"], Literal[\"incomplete\"]""" + created_at: Required[int] + """Unix timestamp (in seconds) of when this Response was created. Required.""" + completed_at: Optional[int] + error: Required[Optional["ResponseErrorInfo"]] + """Required.""" + incomplete_details: Required[Optional["ResponseIncompleteDetails"]] + """Required.""" + output: Required[list["OutputItem"]] + """An array of content items generated by the model. + + * The length and order of items in the `output` array is dependent + on the model's response. + * Rather than accessing the first item in the `output` array and + assuming it's an `assistant` message with the content generated by + the model, you might consider using the `output_text` property where + supported in SDKs. Required.""" + instructions: Required[Optional[Union[str, list["Item"]]]] + """Required. Is either a str type or a [Item] type.""" + output_text: Optional[str] + usage: "ResponseUsage" + parallel_tool_calls: Required[bool] + """Whether to allow the model to run tool calls in parallel. Required.""" + conversation: Optional["ConversationReference"] + agent: "AgentId" + """(Deprecated) Use agent_reference instead. The agent used for this response.""" + agent_session_id: str + """The session identifier for this response. Currently only relevant for hosted agents. Always + returned for hosted agents — either the caller-provided value, the auto-derived value, or an + auto-generated UUID. Use for session-scoped operations and to maintain sandbox affinity in + follow-up calls.""" + agent_reference: Required[Optional["AgentReference"]] + """The agent used for this response. Required.""" + + +class ResponseOutputItemAddedEvent(TypedDict, total=False): + """Emitted when a new output item is added. + + :ivar type: The type of the event. Always ``response.output_item.added``. Required. + RESPONSE_OUTPUT_ITEM_ADDED. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.RESPONSE_OUTPUT_ITEM_ADDED + :ivar output_index: The index of the output item that was added. Required. + :vartype output_index: int + :ivar sequence_number: The sequence number of this event. Required. + :vartype sequence_number: int + :ivar item: The output item that was added. Required. + :vartype item: ~azure.ai.agentserver.responses.models.types.OutputItem + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_OUTPUT_ITEM_ADDED]] + """The type of the event. Always ``response.output_item.added``. Required. + RESPONSE_OUTPUT_ITEM_ADDED.""" + output_index: Required[int] + """The index of the output item that was added. Required.""" + sequence_number: Required[int] + """The sequence number of this event. Required.""" + item: Required["OutputItem"] + """The output item that was added. Required.""" + + +class ResponseOutputItemDoneEvent(TypedDict, total=False): + """Emitted when an output item is marked done. + + :ivar type: The type of the event. Always ``response.output_item.done``. Required. + RESPONSE_OUTPUT_ITEM_DONE. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.RESPONSE_OUTPUT_ITEM_DONE + :ivar output_index: The index of the output item that was marked done. Required. + :vartype output_index: int + :ivar sequence_number: The sequence number of this event. Required. + :vartype sequence_number: int + :ivar item: The output item that was marked done. Required. + :vartype item: ~azure.ai.agentserver.responses.models.types.OutputItem + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_OUTPUT_ITEM_DONE]] + """The type of the event. Always ``response.output_item.done``. Required. + RESPONSE_OUTPUT_ITEM_DONE.""" + output_index: Required[int] + """The index of the output item that was marked done. Required.""" + sequence_number: Required[int] + """The sequence number of this event. Required.""" + item: Required["OutputItem"] + """The output item that was marked done. Required.""" + + +class ResponseOutputTextAnnotationAddedEvent(TypedDict, total=False): + """ResponseOutputTextAnnotationAddedEvent. + + :ivar type: The type of the event. Always 'response.output_text.annotation.added'. Required. + RESPONSE_OUTPUT_TEXT_ANNOTATION_ADDED. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.RESPONSE_OUTPUT_TEXT_ANNOTATION_ADDED + :ivar item_id: The unique identifier of the item to which the annotation is being added. + Required. + :vartype item_id: str + :ivar output_index: The index of the output item in the response's output array. Required. + :vartype output_index: int + :ivar content_index: The index of the content part within the output item. Required. + :vartype content_index: int + :ivar annotation_index: The index of the annotation within the content part. Required. + :vartype annotation_index: int + :ivar sequence_number: The sequence number of this event. Required. + :vartype sequence_number: int + :ivar annotation: The annotation object being added. (See annotation schema for details.). + Required. + :vartype annotation: ~azure.ai.agentserver.responses.models.types.Annotation + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_OUTPUT_TEXT_ANNOTATION_ADDED]] + """The type of the event. Always 'response.output_text.annotation.added'. Required. + RESPONSE_OUTPUT_TEXT_ANNOTATION_ADDED.""" + item_id: Required[str] + """The unique identifier of the item to which the annotation is being added. Required.""" + output_index: Required[int] + """The index of the output item in the response's output array. Required.""" + content_index: Required[int] + """The index of the content part within the output item. Required.""" + annotation_index: Required[int] + """The index of the annotation within the content part. Required.""" + sequence_number: Required[int] + """The sequence number of this event. Required.""" + annotation: Required["Annotation"] + """The annotation object being added. (See annotation schema for details.). Required.""" + + +class ResponsePromptVariables(TypedDict, total=False): + """Prompt Variables.""" + + +class ResponseQueuedEvent(TypedDict, total=False): + """ResponseQueuedEvent. + + :ivar type: The type of the event. Always 'response.queued'. Required. RESPONSE_QUEUED. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.RESPONSE_QUEUED + :ivar response: The full response object that is queued. Required. + :vartype response: ~azure.ai.agentserver.responses.models.types.ResponseObject + :ivar sequence_number: The sequence number for this event. Required. + :vartype sequence_number: int + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_QUEUED]] + """The type of the event. Always 'response.queued'. Required. RESPONSE_QUEUED.""" + response: Required["ResponseObject"] + """The full response object that is queued. Required.""" + sequence_number: Required[int] + """The sequence number for this event. Required.""" + + +class ResponseReasoningSummaryPartAddedEvent(TypedDict, total=False): + """Emitted when a new reasoning summary part is added. + + :ivar type: The type of the event. Always ``response.reasoning_summary_part.added``. Required. + RESPONSE_REASONING_SUMMARY_PART_ADDED. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.RESPONSE_REASONING_SUMMARY_PART_ADDED + :ivar item_id: The ID of the item this summary part is associated with. Required. + :vartype item_id: str + :ivar output_index: The index of the output item this summary part is associated with. + Required. + :vartype output_index: int + :ivar summary_index: The index of the summary part within the reasoning summary. Required. + :vartype summary_index: int + :ivar sequence_number: The sequence number of this event. Required. + :vartype sequence_number: int + :ivar part: The summary part that was added. Required. + :vartype part: + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryPartAddedEventPart + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_REASONING_SUMMARY_PART_ADDED]] + """The type of the event. Always ``response.reasoning_summary_part.added``. Required. + RESPONSE_REASONING_SUMMARY_PART_ADDED.""" + item_id: Required[str] + """The ID of the item this summary part is associated with. Required.""" + output_index: Required[int] + """The index of the output item this summary part is associated with. Required.""" + summary_index: Required[int] + """The index of the summary part within the reasoning summary. Required.""" + sequence_number: Required[int] + """The sequence number of this event. Required.""" + part: Required["ResponseReasoningSummaryPartAddedEventPart"] + """The summary part that was added. Required.""" + + +class ResponseReasoningSummaryPartAddedEventPart(TypedDict, total=False): # pylint: disable=name-too-long + """ResponseReasoningSummaryPartAddedEventPart. + + :ivar type: Required. Default value is "summary_text". + :vartype type: str + :ivar text: Required. + :vartype text: str + """ + + type: Required[Literal["summary_text"]] + """Required. Default value is \"summary_text\".""" + text: Required[str] + """Required.""" + + +class ResponseReasoningSummaryPartDoneEvent(TypedDict, total=False): + """Emitted when a reasoning summary part is completed. + + :ivar type: The type of the event. Always ``response.reasoning_summary_part.done``. Required. + RESPONSE_REASONING_SUMMARY_PART_DONE. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.RESPONSE_REASONING_SUMMARY_PART_DONE + :ivar item_id: The ID of the item this summary part is associated with. Required. + :vartype item_id: str + :ivar output_index: The index of the output item this summary part is associated with. + Required. + :vartype output_index: int + :ivar summary_index: The index of the summary part within the reasoning summary. Required. + :vartype summary_index: int + :ivar sequence_number: The sequence number of this event. Required. + :vartype sequence_number: int + :ivar part: The completed summary part. Required. + :vartype part: + ~azure.ai.agentserver.responses.models.types.ResponseReasoningSummaryPartDoneEventPart + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_REASONING_SUMMARY_PART_DONE]] + """The type of the event. Always ``response.reasoning_summary_part.done``. Required. + RESPONSE_REASONING_SUMMARY_PART_DONE.""" + item_id: Required[str] + """The ID of the item this summary part is associated with. Required.""" + output_index: Required[int] + """The index of the output item this summary part is associated with. Required.""" + summary_index: Required[int] + """The index of the summary part within the reasoning summary. Required.""" + sequence_number: Required[int] + """The sequence number of this event. Required.""" + part: Required["ResponseReasoningSummaryPartDoneEventPart"] + """The completed summary part. Required.""" + + +class ResponseReasoningSummaryPartDoneEventPart(TypedDict, total=False): # pylint: disable=name-too-long + """ResponseReasoningSummaryPartDoneEventPart. + + :ivar type: Required. Default value is "summary_text". + :vartype type: str + :ivar text: Required. + :vartype text: str + """ + + type: Required[Literal["summary_text"]] + """Required. Default value is \"summary_text\".""" + text: Required[str] + """Required.""" + + +class ResponseReasoningSummaryTextDeltaEvent(TypedDict, total=False): + """Emitted when a delta is added to a reasoning summary text. + + :ivar type: The type of the event. Always ``response.reasoning_summary_text.delta``. Required. + RESPONSE_REASONING_SUMMARY_TEXT_DELTA. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.RESPONSE_REASONING_SUMMARY_TEXT_DELTA + :ivar item_id: The ID of the item this summary text delta is associated with. Required. + :vartype item_id: str + :ivar output_index: The index of the output item this summary text delta is associated with. + Required. + :vartype output_index: int + :ivar summary_index: The index of the summary part within the reasoning summary. Required. + :vartype summary_index: int + :ivar delta: The text delta that was added to the summary. Required. + :vartype delta: str + :ivar sequence_number: The sequence number of this event. Required. + :vartype sequence_number: int + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_REASONING_SUMMARY_TEXT_DELTA]] + """The type of the event. Always ``response.reasoning_summary_text.delta``. Required. + RESPONSE_REASONING_SUMMARY_TEXT_DELTA.""" + item_id: Required[str] + """The ID of the item this summary text delta is associated with. Required.""" + output_index: Required[int] + """The index of the output item this summary text delta is associated with. Required.""" + summary_index: Required[int] + """The index of the summary part within the reasoning summary. Required.""" + delta: Required[str] + """The text delta that was added to the summary. Required.""" + sequence_number: Required[int] + """The sequence number of this event. Required.""" + + +class ResponseReasoningSummaryTextDoneEvent(TypedDict, total=False): + """Emitted when a reasoning summary text is completed. + + :ivar type: The type of the event. Always ``response.reasoning_summary_text.done``. Required. + RESPONSE_REASONING_SUMMARY_TEXT_DONE. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.RESPONSE_REASONING_SUMMARY_TEXT_DONE + :ivar item_id: The ID of the item this summary text is associated with. Required. + :vartype item_id: str + :ivar output_index: The index of the output item this summary text is associated with. + Required. + :vartype output_index: int + :ivar summary_index: The index of the summary part within the reasoning summary. Required. + :vartype summary_index: int + :ivar text: The full text of the completed reasoning summary. Required. + :vartype text: str + :ivar sequence_number: The sequence number of this event. Required. + :vartype sequence_number: int + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_REASONING_SUMMARY_TEXT_DONE]] + """The type of the event. Always ``response.reasoning_summary_text.done``. Required. + RESPONSE_REASONING_SUMMARY_TEXT_DONE.""" + item_id: Required[str] + """The ID of the item this summary text is associated with. Required.""" + output_index: Required[int] + """The index of the output item this summary text is associated with. Required.""" + summary_index: Required[int] + """The index of the summary part within the reasoning summary. Required.""" + text: Required[str] + """The full text of the completed reasoning summary. Required.""" + sequence_number: Required[int] + """The sequence number of this event. Required.""" + + +class ResponseReasoningTextDeltaEvent(TypedDict, total=False): + """Emitted when a delta is added to a reasoning text. + + :ivar type: The type of the event. Always ``response.reasoning_text.delta``. Required. + RESPONSE_REASONING_TEXT_DELTA. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.RESPONSE_REASONING_TEXT_DELTA + :ivar item_id: The ID of the item this reasoning text delta is associated with. Required. + :vartype item_id: str + :ivar output_index: The index of the output item this reasoning text delta is associated with. + Required. + :vartype output_index: int + :ivar content_index: The index of the reasoning content part this delta is associated with. + Required. + :vartype content_index: int + :ivar delta: The text delta that was added to the reasoning content. Required. + :vartype delta: str + :ivar sequence_number: The sequence number of this event. Required. + :vartype sequence_number: int + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_REASONING_TEXT_DELTA]] + """The type of the event. Always ``response.reasoning_text.delta``. Required. + RESPONSE_REASONING_TEXT_DELTA.""" + item_id: Required[str] + """The ID of the item this reasoning text delta is associated with. Required.""" + output_index: Required[int] + """The index of the output item this reasoning text delta is associated with. Required.""" + content_index: Required[int] + """The index of the reasoning content part this delta is associated with. Required.""" + delta: Required[str] + """The text delta that was added to the reasoning content. Required.""" + sequence_number: Required[int] + """The sequence number of this event. Required.""" + + +class ResponseReasoningTextDoneEvent(TypedDict, total=False): + """Emitted when a reasoning text is completed. + + :ivar type: The type of the event. Always ``response.reasoning_text.done``. Required. + RESPONSE_REASONING_TEXT_DONE. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.RESPONSE_REASONING_TEXT_DONE + :ivar item_id: The ID of the item this reasoning text is associated with. Required. + :vartype item_id: str + :ivar output_index: The index of the output item this reasoning text is associated with. + Required. + :vartype output_index: int + :ivar content_index: The index of the reasoning content part. Required. + :vartype content_index: int + :ivar text: The full text of the completed reasoning content. Required. + :vartype text: str + :ivar sequence_number: The sequence number of this event. Required. + :vartype sequence_number: int + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_REASONING_TEXT_DONE]] + """The type of the event. Always ``response.reasoning_text.done``. Required. + RESPONSE_REASONING_TEXT_DONE.""" + item_id: Required[str] + """The ID of the item this reasoning text is associated with. Required.""" + output_index: Required[int] + """The index of the output item this reasoning text is associated with. Required.""" + content_index: Required[int] + """The index of the reasoning content part. Required.""" + text: Required[str] + """The full text of the completed reasoning content. Required.""" + sequence_number: Required[int] + """The sequence number of this event. Required.""" + + +class ResponseRefusalDeltaEvent(TypedDict, total=False): + """Emitted when there is a partial refusal text. + + :ivar type: The type of the event. Always ``response.refusal.delta``. Required. + RESPONSE_REFUSAL_DELTA. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.RESPONSE_REFUSAL_DELTA + :ivar item_id: The ID of the output item that the refusal text is added to. Required. + :vartype item_id: str + :ivar output_index: The index of the output item that the refusal text is added to. Required. + :vartype output_index: int + :ivar content_index: The index of the content part that the refusal text is added to. Required. + :vartype content_index: int + :ivar delta: The refusal text that is added. Required. + :vartype delta: str + :ivar sequence_number: The sequence number of this event. Required. + :vartype sequence_number: int + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_REFUSAL_DELTA]] + """The type of the event. Always ``response.refusal.delta``. Required. RESPONSE_REFUSAL_DELTA.""" + item_id: Required[str] + """The ID of the output item that the refusal text is added to. Required.""" + output_index: Required[int] + """The index of the output item that the refusal text is added to. Required.""" + content_index: Required[int] + """The index of the content part that the refusal text is added to. Required.""" + delta: Required[str] + """The refusal text that is added. Required.""" + sequence_number: Required[int] + """The sequence number of this event. Required.""" + + +class ResponseRefusalDoneEvent(TypedDict, total=False): + """Emitted when refusal text is finalized. + + :ivar type: The type of the event. Always ``response.refusal.done``. Required. + RESPONSE_REFUSAL_DONE. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.RESPONSE_REFUSAL_DONE + :ivar item_id: The ID of the output item that the refusal text is finalized. Required. + :vartype item_id: str + :ivar output_index: The index of the output item that the refusal text is finalized. Required. + :vartype output_index: int + :ivar content_index: The index of the content part that the refusal text is finalized. + Required. + :vartype content_index: int + :ivar refusal: The refusal text that is finalized. Required. + :vartype refusal: str + :ivar sequence_number: The sequence number of this event. Required. + :vartype sequence_number: int + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_REFUSAL_DONE]] + """The type of the event. Always ``response.refusal.done``. Required. RESPONSE_REFUSAL_DONE.""" + item_id: Required[str] + """The ID of the output item that the refusal text is finalized. Required.""" + output_index: Required[int] + """The index of the output item that the refusal text is finalized. Required.""" + content_index: Required[int] + """The index of the content part that the refusal text is finalized. Required.""" + refusal: Required[str] + """The refusal text that is finalized. Required.""" + sequence_number: Required[int] + """The sequence number of this event. Required.""" + + +class ResponseStreamOptions(TypedDict, total=False): + """Options for streaming responses. Only set this when you set ``stream: true``. + + :ivar include_obfuscation: When true, stream obfuscation will be enabled. Stream obfuscation + adds random characters to an ``obfuscation`` field on streaming delta events to normalize + payload sizes as a mitigation to certain side-channel attacks. These obfuscation fields are + included by default, but add a small amount of overhead to the data stream. You can set + ``include_obfuscation`` to false to optimize for bandwidth if you trust the network links + between your application and the OpenAI API. + :vartype include_obfuscation: bool + """ + + include_obfuscation: bool + """When true, stream obfuscation will be enabled. Stream obfuscation adds random characters to an + ``obfuscation`` field on streaming delta events to normalize payload sizes as a mitigation to + certain side-channel attacks. These obfuscation fields are included by default, but add a small + amount of overhead to the data stream. You can set ``include_obfuscation`` to false to optimize + for bandwidth if you trust the network links between your application and the OpenAI API.""" + + +class ResponseTextDeltaEvent(TypedDict, total=False): + """Emitted when there is an additional text delta. + + :ivar type: The type of the event. Always ``response.output_text.delta``. Required. + RESPONSE_OUTPUT_TEXT_DELTA. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.RESPONSE_OUTPUT_TEXT_DELTA + :ivar item_id: The ID of the output item that the text delta was added to. Required. + :vartype item_id: str + :ivar output_index: The index of the output item that the text delta was added to. Required. + :vartype output_index: int + :ivar content_index: The index of the content part that the text delta was added to. Required. + :vartype content_index: int + :ivar delta: The text delta that was added. Required. + :vartype delta: str + :ivar sequence_number: The sequence number for this event. Required. + :vartype sequence_number: int + :ivar logprobs: The log probabilities of the tokens in the delta. Required. + :vartype logprobs: list[~azure.ai.agentserver.responses.models.types.ResponseLogProb] + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_OUTPUT_TEXT_DELTA]] + """The type of the event. Always ``response.output_text.delta``. Required. + RESPONSE_OUTPUT_TEXT_DELTA.""" + item_id: Required[str] + """The ID of the output item that the text delta was added to. Required.""" + output_index: Required[int] + """The index of the output item that the text delta was added to. Required.""" + content_index: Required[int] + """The index of the content part that the text delta was added to. Required.""" + delta: Required[str] + """The text delta that was added. Required.""" + sequence_number: Required[int] + """The sequence number for this event. Required.""" + logprobs: Required[list["ResponseLogProb"]] + """The log probabilities of the tokens in the delta. Required.""" + + +class ResponseTextDoneEvent(TypedDict, total=False): + """Emitted when text content is finalized. + + :ivar type: The type of the event. Always ``response.output_text.done``. Required. + RESPONSE_OUTPUT_TEXT_DONE. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.RESPONSE_OUTPUT_TEXT_DONE + :ivar item_id: The ID of the output item that the text content is finalized. Required. + :vartype item_id: str + :ivar output_index: The index of the output item that the text content is finalized. Required. + :vartype output_index: int + :ivar content_index: The index of the content part that the text content is finalized. + Required. + :vartype content_index: int + :ivar text: The text content that is finalized. Required. + :vartype text: str + :ivar sequence_number: The sequence number for this event. Required. + :vartype sequence_number: int + :ivar logprobs: The log probabilities of the tokens in the delta. Required. + :vartype logprobs: list[~azure.ai.agentserver.responses.models.types.ResponseLogProb] + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_OUTPUT_TEXT_DONE]] + """The type of the event. Always ``response.output_text.done``. Required. + RESPONSE_OUTPUT_TEXT_DONE.""" + item_id: Required[str] + """The ID of the output item that the text content is finalized. Required.""" + output_index: Required[int] + """The index of the output item that the text content is finalized. Required.""" + content_index: Required[int] + """The index of the content part that the text content is finalized. Required.""" + text: Required[str] + """The text content that is finalized. Required.""" + sequence_number: Required[int] + """The sequence number for this event. Required.""" + logprobs: Required[list["ResponseLogProb"]] + """The log probabilities of the tokens in the delta. Required.""" + + +class ResponseTextParam(TypedDict, total=False): + """Configuration options for a text response from the model. Can be plain + text or structured JSON data. Learn more: + + * [Text inputs and outputs](/docs/guides/text) + * [Structured Outputs](/docs/guides/structured-outputs). + + :ivar format: + :vartype format: ~azure.ai.agentserver.responses.models.types.TextResponseFormatConfiguration + :ivar verbosity: Is one of the following types: Literal["low"], Literal["medium"], + Literal["high"] + :vartype verbosity: str or str or str + """ + + format: "TextResponseFormatConfiguration" + verbosity: Optional[Literal["low", "medium", "high"]] + """Is one of the following types: Literal[\"low\"], Literal[\"medium\"], Literal[\"high\"]""" + + +class ResponseUsage(TypedDict, total=False): + """Represents token usage details including input tokens, output tokens, a breakdown of output + tokens, and the total tokens used. + + :ivar input_tokens: The number of input tokens. Required. + :vartype input_tokens: int + :ivar input_tokens_details: A detailed breakdown of the input tokens. Required. + :vartype input_tokens_details: + ~azure.ai.agentserver.responses.models.types.ResponseUsageInputTokensDetails + :ivar output_tokens: The number of output tokens. Required. + :vartype output_tokens: int + :ivar output_tokens_details: A detailed breakdown of the output tokens. Required. + :vartype output_tokens_details: + ~azure.ai.agentserver.responses.models.types.ResponseUsageOutputTokensDetails + :ivar total_tokens: The total number of tokens used. Required. + :vartype total_tokens: int + """ + + input_tokens: Required[int] + """The number of input tokens. Required.""" + input_tokens_details: Required["ResponseUsageInputTokensDetails"] + """A detailed breakdown of the input tokens. Required.""" + output_tokens: Required[int] + """The number of output tokens. Required.""" + output_tokens_details: Required["ResponseUsageOutputTokensDetails"] + """A detailed breakdown of the output tokens. Required.""" + total_tokens: Required[int] + """The total number of tokens used. Required.""" + + +class ResponseUsageInputTokensDetails(TypedDict, total=False): + """ResponseUsageInputTokensDetails. + + :ivar cached_tokens: Required. + :vartype cached_tokens: int + """ + + cached_tokens: Required[int] + """Required.""" + + +class ResponseUsageOutputTokensDetails(TypedDict, total=False): + """ResponseUsageOutputTokensDetails. + + :ivar reasoning_tokens: Required. + :vartype reasoning_tokens: int + """ + + reasoning_tokens: Required[int] + """Required.""" + + +class ResponseWebSearchCallCompletedEvent(TypedDict, total=False): + """Emitted when a web search call is completed. + + :ivar type: The type of the event. Always ``response.web_search_call.completed``. Required. + RESPONSE_WEB_SEARCH_CALL_COMPLETED. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.RESPONSE_WEB_SEARCH_CALL_COMPLETED + :ivar output_index: The index of the output item that the web search call is associated with. + Required. + :vartype output_index: int + :ivar item_id: Unique ID for the output item associated with the web search call. Required. + :vartype item_id: str + :ivar sequence_number: The sequence number of the web search call being processed. Required. + :vartype sequence_number: int + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_WEB_SEARCH_CALL_COMPLETED]] + """The type of the event. Always ``response.web_search_call.completed``. Required. + RESPONSE_WEB_SEARCH_CALL_COMPLETED.""" + output_index: Required[int] + """The index of the output item that the web search call is associated with. Required.""" + item_id: Required[str] + """Unique ID for the output item associated with the web search call. Required.""" + sequence_number: Required[int] + """The sequence number of the web search call being processed. Required.""" + + +class ResponseWebSearchCallInProgressEvent(TypedDict, total=False): + """Emitted when a web search call is initiated. + + :ivar type: The type of the event. Always ``response.web_search_call.in_progress``. Required. + RESPONSE_WEB_SEARCH_CALL_IN_PROGRESS. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.RESPONSE_WEB_SEARCH_CALL_IN_PROGRESS + :ivar output_index: The index of the output item that the web search call is associated with. + Required. + :vartype output_index: int + :ivar item_id: Unique ID for the output item associated with the web search call. Required. + :vartype item_id: str + :ivar sequence_number: The sequence number of the web search call being processed. Required. + :vartype sequence_number: int + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_WEB_SEARCH_CALL_IN_PROGRESS]] + """The type of the event. Always ``response.web_search_call.in_progress``. Required. + RESPONSE_WEB_SEARCH_CALL_IN_PROGRESS.""" + output_index: Required[int] + """The index of the output item that the web search call is associated with. Required.""" + item_id: Required[str] + """Unique ID for the output item associated with the web search call. Required.""" + sequence_number: Required[int] + """The sequence number of the web search call being processed. Required.""" + + +class ResponseWebSearchCallSearchingEvent(TypedDict, total=False): + """Emitted when a web search call is executing. + + :ivar type: The type of the event. Always ``response.web_search_call.searching``. Required. + RESPONSE_WEB_SEARCH_CALL_SEARCHING. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.RESPONSE_WEB_SEARCH_CALL_SEARCHING + :ivar output_index: The index of the output item that the web search call is associated with. + Required. + :vartype output_index: int + :ivar item_id: Unique ID for the output item associated with the web search call. Required. + :vartype item_id: str + :ivar sequence_number: The sequence number of the web search call being processed. Required. + :vartype sequence_number: int + """ + + type: Required[Literal[ResponseStreamEventType.RESPONSE_WEB_SEARCH_CALL_SEARCHING]] + """The type of the event. Always ``response.web_search_call.searching``. Required. + RESPONSE_WEB_SEARCH_CALL_SEARCHING.""" + output_index: Required[int] + """The index of the output item that the web search call is associated with. Required.""" + item_id: Required[str] + """Unique ID for the output item associated with the web search call. Required.""" + sequence_number: Required[int] + """The sequence number of the web search call being processed. Required.""" + + +class ScreenshotParam(TypedDict, total=False): + """Screenshot. + + :ivar type: Specifies the event type. For a screenshot action, this property is always set to + ``screenshot``. Required. SCREENSHOT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.SCREENSHOT + """ + + type: Required[Literal[ComputerActionType.SCREENSHOT]] + """Specifies the event type. For a screenshot action, this property is always set to + ``screenshot``. Required. SCREENSHOT.""" + + +class ScrollParam(TypedDict, total=False): + """Scroll. + + :ivar type: Specifies the event type. For a scroll action, this property is always set to + ``scroll``. Required. SCROLL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.SCROLL + :ivar x: The x-coordinate where the scroll occurred. Required. + :vartype x: int + :ivar y: The y-coordinate where the scroll occurred. Required. + :vartype y: int + :ivar scroll_x: The horizontal scroll distance. Required. + :vartype scroll_x: int + :ivar scroll_y: The vertical scroll distance. Required. + :vartype scroll_y: int + """ + + type: Required[Literal[ComputerActionType.SCROLL]] + """Specifies the event type. For a scroll action, this property is always set to ``scroll``. + Required. SCROLL.""" + x: Required[int] + """The x-coordinate where the scroll occurred. Required.""" + y: Required[int] + """The y-coordinate where the scroll occurred. Required.""" + scroll_x: Required[int] + """The horizontal scroll distance. Required.""" + scroll_y: Required[int] + """The vertical scroll distance. Required.""" + + +class SharepointGroundingToolCall(TypedDict, total=False): + """A SharePoint grounding tool call. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar type: Required. SHAREPOINT_GROUNDING_PREVIEW_CALL. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.SHAREPOINT_GROUNDING_PREVIEW_CALL + :ivar call_id: The unique ID of the tool call generated by the model. Required. + :vartype call_id: str + :ivar arguments: A JSON string of the arguments to pass to the tool. Required. + :vartype arguments: str + :ivar status: The status of the tool call. Required. Known values are: "in_progress", + "completed", "incomplete", and "failed". + :vartype status: str or ~azure.ai.agentserver.responses.models.models.ToolCallStatus + :ivar id: Required. + :vartype id: str + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + type: Required[Literal[OutputItemType.SHAREPOINT_GROUNDING_PREVIEW_CALL]] + """Required. SHAREPOINT_GROUNDING_PREVIEW_CALL.""" + call_id: Required[str] + """The unique ID of the tool call generated by the model. Required.""" + arguments: Required[str] + """A JSON string of the arguments to pass to the tool. Required.""" + status: Required[ToolCallStatus] + """The status of the tool call. Required. Known values are: \"in_progress\", \"completed\", + \"incomplete\", and \"failed\".""" + id: Required[str] + """Required.""" + + +class SharepointGroundingToolCallOutput(TypedDict, total=False): + """The output of a SharePoint grounding tool call. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar type: Required. SHAREPOINT_GROUNDING_PREVIEW_CALL_OUTPUT. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.SHAREPOINT_GROUNDING_PREVIEW_CALL_OUTPUT + :ivar call_id: The unique ID of the tool call generated by the model. Required. + :vartype call_id: str + :ivar output: The output from the SharePoint grounding tool call. Is one of the following + types: {str: Any}, str, [Any] + :vartype output: dict[str, any] or str or list[any] + :ivar status: The status of the tool call. Required. Known values are: "in_progress", + "completed", "incomplete", and "failed". + :vartype status: str or ~azure.ai.agentserver.responses.models.models.ToolCallStatus + :ivar id: Required. + :vartype id: str + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + type: Required[Literal[OutputItemType.SHAREPOINT_GROUNDING_PREVIEW_CALL_OUTPUT]] + """Required. SHAREPOINT_GROUNDING_PREVIEW_CALL_OUTPUT.""" + call_id: Required[str] + """The unique ID of the tool call generated by the model. Required.""" + output: "_unions.ToolCallOutputContent" + """The output from the SharePoint grounding tool call. Is one of the following types: {str: Any}, + str, [Any]""" + status: Required[ToolCallStatus] + """The status of the tool call. Required. Known values are: \"in_progress\", \"completed\", + \"incomplete\", and \"failed\".""" + id: Required[str] + """Required.""" + + +class SharepointGroundingToolParameters(TypedDict, total=False): + """The sharepoint grounding tool parameters. + + :ivar name: Optional user-defined name for this tool or configuration. + :vartype name: str + :ivar description: Optional user-defined description for this tool or configuration. + :vartype description: str + :ivar project_connections: The project connections attached to this tool. There can be a + maximum of 1 connection resource attached to the tool. + :vartype project_connections: + list[~azure.ai.agentserver.responses.models.types.ToolProjectConnection] + """ + + name: str + """Optional user-defined name for this tool or configuration.""" + description: str + """Optional user-defined description for this tool or configuration.""" + project_connections: list["ToolProjectConnection"] + """The project connections attached to this tool. There can be a maximum of 1 connection resource + attached to the tool.""" + + +class SharepointPreviewTool(TypedDict, total=False): + """The input definition information for a sharepoint tool as used to configure an agent. + + :ivar type: The object type, which is always 'sharepoint_grounding_preview'. Required. + SHAREPOINT_GROUNDING_PREVIEW. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.SHAREPOINT_GROUNDING_PREVIEW + :ivar name: Optional user-defined name for this tool or configuration. + :vartype name: str + :ivar description: Optional user-defined description for this tool or configuration. + :vartype description: str + :ivar sharepoint_grounding_preview: The sharepoint grounding tool parameters. Required. + :vartype sharepoint_grounding_preview: + ~azure.ai.agentserver.responses.models.types.SharepointGroundingToolParameters + """ + + type: Required[Literal[ToolType.SHAREPOINT_GROUNDING_PREVIEW]] + """The object type, which is always 'sharepoint_grounding_preview'. Required. + SHAREPOINT_GROUNDING_PREVIEW.""" + name: str + """Optional user-defined name for this tool or configuration.""" + description: str + """Optional user-defined description for this tool or configuration.""" + sharepoint_grounding_preview: Required["SharepointGroundingToolParameters"] + """The sharepoint grounding tool parameters. Required.""" + + +class SkillReferenceParam(TypedDict, total=False): + """SkillReferenceParam. + + :ivar type: References a skill created with the /v1/skills endpoint. Required. SKILL_REFERENCE. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.SKILL_REFERENCE + :ivar skill_id: The ID of the referenced skill. Required. + :vartype skill_id: str + :ivar version: Optional skill version. Use a positive integer or 'latest'. Omit for default. + :vartype version: str + """ + + type: Required[Literal[ContainerSkillType.SKILL_REFERENCE]] + """References a skill created with the /v1/skills endpoint. Required. SKILL_REFERENCE.""" + skill_id: Required[str] + """The ID of the referenced skill. Required.""" + version: str + """Optional skill version. Use a positive integer or 'latest'. Omit for default.""" + + +class SpecificApplyPatchParam(TypedDict, total=False): + """Specific apply patch tool choice. + + :ivar type: The tool to call. Always ``apply_patch``. Required. APPLY_PATCH. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.APPLY_PATCH + """ + + type: Required[Literal[ToolChoiceParamType.APPLY_PATCH]] + """The tool to call. Always ``apply_patch``. Required. APPLY_PATCH.""" + + +class SpecificFunctionShellParam(TypedDict, total=False): + """Specific shell tool choice. + + :ivar type: The tool to call. Always ``shell``. Required. SHELL. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.SHELL + """ + + type: Required[Literal[ToolChoiceParamType.SHELL]] + """The tool to call. Always ``shell``. Required. SHELL.""" + + +class StructuredOutputDefinition(TypedDict, total=False): + """A structured output that can be produced by the agent. + + :ivar name: The name of the structured output. Required. + :vartype name: str + :ivar description: A description of the output to emit. Used by the model to determine when to + emit the output. Required. + :vartype description: str + :ivar schema: The JSON schema for the structured output. Required. + :vartype schema: dict[str, any] + :ivar strict: Whether to enforce strict validation. Default ``true``. Required. + :vartype strict: bool + """ + + name: Required[str] + """The name of the structured output. Required.""" + description: Required[str] + """A description of the output to emit. Used by the model to determine when to emit the output. + Required.""" + schema: Required[dict[str, Any]] + """The JSON schema for the structured output. Required.""" + strict: Required[Optional[bool]] + """Whether to enforce strict validation. Default ``true``. Required.""" + + +class StructuredOutputsOutputItem(TypedDict, total=False): + """StructuredOutputsOutputItem. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar type: Required. STRUCTURED_OUTPUTS. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.STRUCTURED_OUTPUTS + :ivar output: The structured output captured during the response. Required. + :vartype output: any + :ivar id: Required. + :vartype id: str + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + type: Required[Literal[OutputItemType.STRUCTURED_OUTPUTS]] + """Required. STRUCTURED_OUTPUTS.""" + output: Required[Any] + """The structured output captured during the response. Required.""" + id: Required[str] + """Required.""" + + +class SummaryTextContent(TypedDict, total=False): + """Summary text. + + :ivar type: The type of the object. Always ``summary_text``. Required. SUMMARY_TEXT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.SUMMARY_TEXT + :ivar text: A summary of the reasoning output from the model so far. Required. + :vartype text: str + """ + + type: Required[Literal[MessageContentType.SUMMARY_TEXT]] + """The type of the object. Always ``summary_text``. Required. SUMMARY_TEXT.""" + text: Required[str] + """A summary of the reasoning output from the model so far. Required.""" + + +class TextContent(TypedDict, total=False): + """Text Content. + + :ivar type: Required. TEXT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.TEXT + :ivar text: Required. + :vartype text: str + """ + + type: Required[Literal[MessageContentType.TEXT]] + """Required. TEXT.""" + text: Required[str] + """Required.""" + + +class TextResponseFormatConfigurationResponseFormatJsonObject(TypedDict, total=False): # pylint: disable=name-too-long + """JSON object. + + :ivar type: The type of response format being defined. Always ``json_object``. Required. + JSON_OBJECT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.JSON_OBJECT + """ + + type: Required[Literal[TextResponseFormatConfigurationType.JSON_OBJECT]] + """The type of response format being defined. Always ``json_object``. Required. JSON_OBJECT.""" + + +class TextResponseFormatConfigurationResponseFormatText(TypedDict, total=False): # pylint: disable=name-too-long + """Text. + + :ivar type: The type of response format being defined. Always ``text``. Required. TEXT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.TEXT + """ + + type: Required[Literal[TextResponseFormatConfigurationType.TEXT]] + """The type of response format being defined. Always ``text``. Required. TEXT.""" + + +class TextResponseFormatJsonSchema(TypedDict, total=False): + """JSON schema. + + :ivar type: The type of response format being defined. Always ``json_schema``. Required. + JSON_SCHEMA. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.JSON_SCHEMA + :ivar description: A description of what the response format is for, used by the model to + determine how to respond in the format. + :vartype description: str + :ivar name: The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and + dashes, with a maximum length of 64. Required. + :vartype name: str + :ivar schema: Required. + :vartype schema: ~azure.ai.agentserver.responses.models.types.ResponseFormatJsonSchemaSchema + :ivar strict: + :vartype strict: bool + """ + + type: Required[Literal[TextResponseFormatConfigurationType.JSON_SCHEMA]] + """The type of response format being defined. Always ``json_schema``. Required. JSON_SCHEMA.""" + description: str + """A description of what the response format is for, used by the model to determine how to respond + in the format.""" + name: Required[str] + """The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with + a maximum length of 64. Required.""" + schema: Required["ResponseFormatJsonSchemaSchema"] + """Required.""" + strict: Optional[bool] + + +class ToolChoiceAllowed(TypedDict, total=False): + """Allowed tools. + + :ivar type: Allowed tool configuration type. Always ``allowed_tools``. Required. ALLOWED_TOOLS. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.ALLOWED_TOOLS + :ivar mode: Constrains the tools available to the model to a pre-defined set. ``auto`` allows + the model to pick from among the allowed tools and generate a message. ``required`` requires + the model to call one or more of the allowed tools. Required. Is either a Literal["auto"] type + or a Literal["required"] type. + :vartype mode: str or str + :ivar tools: A list of tool definitions that the model should be allowed to call. For the + Responses API, the list of tool definitions might look like: + + .. code-block:: json + + [ + { "type": "function", "name": "get_weather" }, + { "type": "mcp", "server_label": "deepwiki" }, + { "type": "image_generation" } + ]. Required. + :vartype tools: list[dict[str, any]] + """ + + type: Required[Literal[ToolChoiceParamType.ALLOWED_TOOLS]] + """Allowed tool configuration type. Always ``allowed_tools``. Required. ALLOWED_TOOLS.""" + mode: Required[Literal["auto", "required"]] + """Constrains the tools available to the model to a pre-defined set. ``auto`` allows the model to + pick from among the allowed tools and generate a message. ``required`` requires the model to + call one or more of the allowed tools. Required. Is either a Literal[\"auto\"] type or a + Literal[\"required\"] type.""" + tools: Required[list[dict[str, Any]]] + """A list of tool definitions that the model should be allowed to call. For the Responses API, the + list of tool definitions might look like: + + .. code-block:: json + + [ + { \"type\": \"function\", \"name\": \"get_weather\" }, + { \"type\": \"mcp\", \"server_label\": \"deepwiki\" }, + { \"type\": \"image_generation\" } + ]. Required.""" + + +class ToolChoiceCodeInterpreter(TypedDict, total=False): + """Indicates that the model should use a built-in tool to generate a response. `Learn more about + built-in tools `_. + + :ivar type: Required. CODE_INTERPRETER. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.CODE_INTERPRETER + """ + + type: Required[Literal[ToolChoiceParamType.CODE_INTERPRETER]] + """Required. CODE_INTERPRETER.""" + + +class ToolChoiceComputerUsePreview(TypedDict, total=False): + """Indicates that the model should use a built-in tool to generate a response. `Learn more about + built-in tools `_. + + :ivar type: Required. COMPUTER_USE_PREVIEW. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.COMPUTER_USE_PREVIEW + """ + + type: Required[Literal[ToolChoiceParamType.COMPUTER_USE_PREVIEW]] + """Required. COMPUTER_USE_PREVIEW.""" + + +class ToolChoiceCustom(TypedDict, total=False): + """Custom tool. + + :ivar type: For custom tool calling, the type is always ``custom``. Required. CUSTOM. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.CUSTOM + :ivar name: The name of the custom tool to call. Required. + :vartype name: str + """ + + type: Required[Literal[ToolChoiceParamType.CUSTOM]] + """For custom tool calling, the type is always ``custom``. Required. CUSTOM.""" + name: Required[str] + """The name of the custom tool to call. Required.""" + + +class ToolChoiceFileSearch(TypedDict, total=False): + """Indicates that the model should use a built-in tool to generate a response. `Learn more about + built-in tools `_. + + :ivar type: Required. FILE_SEARCH. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.FILE_SEARCH + """ + + type: Required[Literal[ToolChoiceParamType.FILE_SEARCH]] + """Required. FILE_SEARCH.""" + + +class ToolChoiceFunction(TypedDict, total=False): + """Function tool. + + :ivar type: For function calling, the type is always ``function``. Required. FUNCTION. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.FUNCTION + :ivar name: The name of the function to call. Required. + :vartype name: str + """ + + type: Required[Literal[ToolChoiceParamType.FUNCTION]] + """For function calling, the type is always ``function``. Required. FUNCTION.""" + name: Required[str] + """The name of the function to call. Required.""" + + +class ToolChoiceImageGeneration(TypedDict, total=False): + """Indicates that the model should use a built-in tool to generate a response. `Learn more about + built-in tools `_. + + :ivar type: Required. IMAGE_GENERATION. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.IMAGE_GENERATION + """ + + type: Required[Literal[ToolChoiceParamType.IMAGE_GENERATION]] + """Required. IMAGE_GENERATION.""" + + +class ToolChoiceMCP(TypedDict, total=False): + """MCP tool. + + :ivar type: For MCP tools, the type is always ``mcp``. Required. MCP. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.MCP + :ivar server_label: The label of the MCP server to use. Required. + :vartype server_label: str + :ivar name: + :vartype name: str + """ + + type: Required[Literal[ToolChoiceParamType.MCP]] + """For MCP tools, the type is always ``mcp``. Required. MCP.""" + server_label: Required[str] + """The label of the MCP server to use. Required.""" + name: Optional[str] + + +class ToolChoiceWebSearchPreview(TypedDict, total=False): + """Indicates that the model should use a built-in tool to generate a response. `Learn more about + built-in tools `_. + + :ivar type: Required. WEB_SEARCH_PREVIEW. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.WEB_SEARCH_PREVIEW + """ + + type: Required[Literal[ToolChoiceParamType.WEB_SEARCH_PREVIEW]] + """Required. WEB_SEARCH_PREVIEW.""" + + +class ToolChoiceWebSearchPreview20250311(TypedDict, total=False): + """Indicates that the model should use a built-in tool to generate a response. `Learn more about + built-in tools `_. + + :ivar type: Required. WEB_SEARCH_PREVIEW2025_03_11. + :vartype type: str or + ~azure.ai.agentserver.responses.models.models.WEB_SEARCH_PREVIEW2025_03_11 + """ + + type: Required[Literal[ToolChoiceParamType.WEB_SEARCH_PREVIEW2025_03_11]] + """Required. WEB_SEARCH_PREVIEW2025_03_11.""" + + +class ToolProjectConnection(TypedDict, total=False): + """A project connection resource. + + :ivar name: Optional user-defined name for this tool or configuration. + :vartype name: str + :ivar description: Optional user-defined description for this tool or configuration. + :vartype description: str + :ivar project_connection_id: A project connection in a ToolProjectConnectionList attached to + this tool. Required. + :vartype project_connection_id: str + """ + + name: str + """Optional user-defined name for this tool or configuration.""" + description: str + """Optional user-defined description for this tool or configuration.""" + project_connection_id: Required[str] + """A project connection in a ToolProjectConnectionList attached to this tool. Required.""" + + +class TopLogProb(TypedDict, total=False): + """Top log probability. + + :ivar token: Required. + :vartype token: str + :ivar logprob: Required. + :vartype logprob: float + :ivar bytes: Required. + :vartype bytes: list[int] + """ + + token: Required[str] + """Required.""" + logprob: Required[float] + """Required.""" + bytes: Required[list[int]] + """Required.""" + + +class TypeParam(TypedDict, total=False): + """Type. + + :ivar type: Specifies the event type. For a type action, this property is always set to + ``type``. Required. TYPE. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.TYPE + :ivar text: The text to type. Required. + :vartype text: str + """ + + type: Required[Literal[ComputerActionType.TYPE]] + """Specifies the event type. For a type action, this property is always set to ``type``. Required. + TYPE.""" + text: Required[str] + """The text to type. Required.""" + + +class UrlCitationBody(TypedDict, total=False): + """URL citation. + + :ivar type: The type of the URL citation. Always ``url_citation``. Required. URL_CITATION. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.URL_CITATION + :ivar url: The URL of the web resource. Required. + :vartype url: str + :ivar start_index: The index of the first character of the URL citation in the message. + Required. + :vartype start_index: int + :ivar end_index: The index of the last character of the URL citation in the message. Required. + :vartype end_index: int + :ivar title: The title of the web resource. Required. + :vartype title: str + """ + + type: Required[Literal[AnnotationType.URL_CITATION]] + """The type of the URL citation. Always ``url_citation``. Required. URL_CITATION.""" + url: Required[str] + """The URL of the web resource. Required.""" + start_index: Required[int] + """The index of the first character of the URL citation in the message. Required.""" + end_index: Required[int] + """The index of the last character of the URL citation in the message. Required.""" + title: Required[str] + """The title of the web resource. Required.""" + + +class UserProfileMemoryItem(TypedDict, total=False): + """A memory item specifically containing user profile information extracted from conversations, + such as preferences, interests, and personal details. + + :ivar memory_id: The unique ID of the memory item. Required. + :vartype memory_id: str + :ivar updated_at: The last update time of the memory item. Required. + :vartype updated_at: ~datetime.datetime + :ivar scope: The namespace that logically groups and isolates memories, such as a user ID. + Required. + :vartype scope: str + :ivar content: The content of the memory. Required. + :vartype content: str + :ivar kind: The kind of the memory item. Required. User profile information extracted from + conversations. + :vartype kind: str or ~azure.ai.agentserver.responses.models.models.USER_PROFILE + """ + + memory_id: Required[str] + """The unique ID of the memory item. Required.""" + updated_at: Required[int] + """The last update time of the memory item. Required.""" + scope: Required[str] + """The namespace that logically groups and isolates memories, such as a user ID. Required.""" + content: Required[str] + """The content of the memory. Required.""" + kind: Required[Literal[MemoryItemKind.USER_PROFILE]] + """The kind of the memory item. Required. User profile information extracted from conversations.""" + + +class VectorStoreFileAttributes(TypedDict, total=False): + """Set of 16 key-value pairs that can be attached to an object. This can be useful for storing + additional information about the object in a structured format, and querying for objects via + API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are + strings with a maximum length of 512 characters, booleans, or numbers. + + """ + + +class WaitParam(TypedDict, total=False): + """Wait. + + :ivar type: Specifies the event type. For a wait action, this property is always set to + ``wait``. Required. WAIT. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.WAIT + """ + + type: Required[Literal[ComputerActionType.WAIT]] + """Specifies the event type. For a wait action, this property is always set to ``wait``. Required. + WAIT.""" + + +class WebSearchActionFind(TypedDict, total=False): + """Find action. + + :ivar type: The action type. Required. Default value is "find_in_page". + :vartype type: str + :ivar url: The URL of the page searched for the pattern. Required. + :vartype url: str + :ivar pattern: The pattern or text to search for within the page. Required. + :vartype pattern: str + """ + + type: Required[Literal["find_in_page"]] + """The action type. Required. Default value is \"find_in_page\".""" + url: Required[str] + """The URL of the page searched for the pattern. Required.""" + pattern: Required[str] + """The pattern or text to search for within the page. Required.""" + + +class WebSearchActionOpenPage(TypedDict, total=False): + """Open page action. + + :ivar type: The action type. Required. Default value is "open_page". + :vartype type: str + :ivar url: The URL opened by the model. + :vartype url: str + """ + + type: Required[Literal["open_page"]] + """The action type. Required. Default value is \"open_page\".""" + url: Optional[str] + """The URL opened by the model.""" + + +class WebSearchActionSearch(TypedDict, total=False): + """Search action. + + :ivar type: The action type. Required. Default value is "search". + :vartype type: str + :ivar query: [DEPRECATED] The search query. Required. + :vartype query: str + :ivar queries: Search queries. + :vartype queries: list[str] + :ivar sources: Web search sources. + :vartype sources: + list[~azure.ai.agentserver.responses.models.types.WebSearchActionSearchSources] + """ + + type: Required[Literal["search"]] + """The action type. Required. Default value is \"search\".""" + query: Required[str] + """[DEPRECATED] The search query. Required.""" + queries: list[str] + """Search queries.""" + sources: list["WebSearchActionSearchSources"] + """Web search sources.""" + + +class WebSearchActionSearchSources(TypedDict, total=False): + """WebSearchActionSearchSources. + + :ivar type: Required. Default value is "url". + :vartype type: str + :ivar url: Required. + :vartype url: str + """ + + type: Required[Literal["url"]] + """Required. Default value is \"url\".""" + url: Required[str] + """Required.""" + + +class WebSearchApproximateLocation(TypedDict, total=False): + """Web search approximate location. + + :ivar type: The type of location approximation. Always ``approximate``. Required. Default value + is "approximate". + :vartype type: str + :ivar country: + :vartype country: str + :ivar region: + :vartype region: str + :ivar city: + :vartype city: str + :ivar timezone: + :vartype timezone: str + """ + + type: Required[Literal["approximate"]] + """The type of location approximation. Always ``approximate``. Required. Default value is + \"approximate\".""" + country: Optional[str] + region: Optional[str] + city: Optional[str] + timezone: Optional[str] + + +class WebSearchConfiguration(TypedDict, total=False): + """A web search configuration for bing custom search. + + :ivar name: Optional user-defined name for this tool or configuration. + :vartype name: str + :ivar description: Optional user-defined description for this tool or configuration. + :vartype description: str + :ivar project_connection_id: Project connection id for grounding with bing custom search. + Required. + :vartype project_connection_id: str + :ivar instance_name: Name of the custom configuration instance given to config. Required. + :vartype instance_name: str + """ + + name: str + """Optional user-defined name for this tool or configuration.""" + description: str + """Optional user-defined description for this tool or configuration.""" + project_connection_id: Required[str] + """Project connection id for grounding with bing custom search. Required.""" + instance_name: Required[str] + """Name of the custom configuration instance given to config. Required.""" + + +class WebSearchPreviewTool(TypedDict, total=False): + """Web search preview. + + :ivar type: The type of the web search tool. One of ``web_search_preview`` or + ``web_search_preview_2025_03_11``. Required. WEB_SEARCH_PREVIEW. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.WEB_SEARCH_PREVIEW + :ivar user_location: + :vartype user_location: ~azure.ai.agentserver.responses.models.types.ApproximateLocation + :ivar search_context_size: High level guidance for the amount of context window space to use + for the search. One of ``low``, ``medium``, or ``high``. ``medium`` is the default. Known + values are: "low", "medium", and "high". + :vartype search_context_size: str or + ~azure.ai.agentserver.responses.models.models.SearchContextSize + """ + + type: Required[Literal[ToolType.WEB_SEARCH_PREVIEW]] + """The type of the web search tool. One of ``web_search_preview`` or + ``web_search_preview_2025_03_11``. Required. WEB_SEARCH_PREVIEW.""" + user_location: Optional["ApproximateLocation"] + search_context_size: SearchContextSize + """High level guidance for the amount of context window space to use for the search. One of + ``low``, ``medium``, or ``high``. ``medium`` is the default. Known values are: \"low\", + \"medium\", and \"high\".""" + + +class WebSearchTool(TypedDict, total=False): + """Web search. + + :ivar type: The type of the web search tool. One of ``web_search`` or + ``web_search_2025_08_26``. Required. WEB_SEARCH. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.WEB_SEARCH + :ivar filters: + :vartype filters: ~azure.ai.agentserver.responses.models.types.WebSearchToolFilters + :ivar user_location: + :vartype user_location: + ~azure.ai.agentserver.responses.models.types.WebSearchApproximateLocation + :ivar search_context_size: High level guidance for the amount of context window space to use + for the search. One of ``low``, ``medium``, or ``high``. ``medium`` is the default. Is one of + the following types: Literal["low"], Literal["medium"], Literal["high"] + :vartype search_context_size: str or str or str + :ivar name: Optional user-defined name for this tool or configuration. + :vartype name: str + :ivar description: Optional user-defined description for this tool or configuration. + :vartype description: str + :ivar custom_search_configuration: The project connections attached to this tool. There can be + a maximum of 1 connection resource attached to the tool. + :vartype custom_search_configuration: + ~azure.ai.agentserver.responses.models.types.WebSearchConfiguration + """ + + type: Required[Literal[ToolType.WEB_SEARCH]] + """The type of the web search tool. One of ``web_search`` or ``web_search_2025_08_26``. Required. + WEB_SEARCH.""" + filters: Optional["WebSearchToolFilters"] + user_location: Optional["WebSearchApproximateLocation"] + search_context_size: Literal["low", "medium", "high"] + """High level guidance for the amount of context window space to use for the search. One of + ``low``, ``medium``, or ``high``. ``medium`` is the default. Is one of the following types: + Literal[\"low\"], Literal[\"medium\"], Literal[\"high\"]""" + name: str + """Optional user-defined name for this tool or configuration.""" + description: str + """Optional user-defined description for this tool or configuration.""" + custom_search_configuration: "WebSearchConfiguration" + """The project connections attached to this tool. There can be a maximum of 1 connection resource + attached to the tool.""" + + +class WebSearchToolFilters(TypedDict, total=False): + """WebSearchToolFilters. + + :ivar allowed_domains: + :vartype allowed_domains: list[str] + """ + + allowed_domains: Optional[list[str]] + + +class WorkflowActionOutputItem(TypedDict, total=False): + """WorkflowActionOutputItem. + + :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or + a str type. + :vartype created_by: ~azure.ai.agentserver.responses.models.types.CreatedBy or str + :ivar agent_reference: The agent that created the item. + :vartype agent_reference: ~azure.ai.agentserver.responses.models.types.AgentReference + :ivar response_id: The response on which the item is created. + :vartype response_id: str + :ivar type: Required. WORKFLOW_ACTION. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.WORKFLOW_ACTION + :ivar kind: The kind of CSDL action (e.g., 'SetVariable', 'InvokeAzureAgent'). Required. + :vartype kind: str + :ivar action_id: Unique identifier for the action. Required. + :vartype action_id: str + :ivar parent_action_id: ID of the parent action if this is a nested action. + :vartype parent_action_id: str + :ivar previous_action_id: ID of the previous action if this action follows another. + :vartype previous_action_id: str + :ivar status: Status of the action (e.g., 'in_progress', 'completed', 'failed', 'cancelled'). + Required. Is one of the following types: Literal["completed"], Literal["failed"], + Literal["in_progress"], Literal["cancelled"] + :vartype status: str or str or str or str + :ivar id: Required. + :vartype id: str + """ + + created_by: Union["CreatedBy", str] + """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + agent_reference: "AgentReference" + """The agent that created the item.""" + response_id: str + """The response on which the item is created.""" + type: Required[Literal[OutputItemType.WORKFLOW_ACTION]] + """Required. WORKFLOW_ACTION.""" + kind: Required[str] + """The kind of CSDL action (e.g., 'SetVariable', 'InvokeAzureAgent'). Required.""" + action_id: Required[str] + """Unique identifier for the action. Required.""" + parent_action_id: str + """ID of the parent action if this is a nested action.""" + previous_action_id: str + """ID of the previous action if this action follows another.""" + status: Required[Literal["completed", "failed", "in_progress", "cancelled"]] + """Status of the action (e.g., 'in_progress', 'completed', 'failed', 'cancelled'). Required. Is + one of the following types: Literal[\"completed\"], Literal[\"failed\"], + Literal[\"in_progress\"], Literal[\"cancelled\"]""" + id: Required[str] + """Required.""" + + +class WorkIQPreviewTool(TypedDict, total=False): + """A WorkIQ server-side tool. + + :ivar type: The object type, which is always 'work_iq_preview'. Required. WORK_IQ_PREVIEW. + :vartype type: str or ~azure.ai.agentserver.responses.models.models.WORK_IQ_PREVIEW + :ivar work_iq_preview: The WorkIQ tool parameters. Required. + :vartype work_iq_preview: + ~azure.ai.agentserver.responses.models.types.WorkIQPreviewToolParameters + """ + + type: Required[Literal[ToolType.WORK_IQ_PREVIEW]] + """The object type, which is always 'work_iq_preview'. Required. WORK_IQ_PREVIEW.""" + work_iq_preview: Required["WorkIQPreviewToolParameters"] + """The WorkIQ tool parameters. Required.""" + + +class WorkIQPreviewToolParameters(TypedDict, total=False): + """The WorkIQ tool parameters. + + :ivar project_connection_id: The ID of the WorkIQ project connection. Required. + :vartype project_connection_id: str + """ + + project_connection_id: Required[str] + """The ID of the WorkIQ project connection. Required.""" + + +Tool = Union[ + A2APreviewTool, + ApplyPatchToolParam, + AzureAISearchTool, + AzureFunctionTool, + BingCustomSearchPreviewTool, + BingGroundingTool, + BrowserAutomationPreviewTool, + CaptureStructuredOutputsTool, + CodeInterpreterTool, + ComputerUsePreviewTool, + CustomToolParam, + MicrosoftFabricPreviewTool, + FileSearchTool, + FunctionTool, + ImageGenTool, + LocalShellToolParam, + MCPTool, + MemorySearchTool, + MemorySearchPreviewTool, + OpenApiTool, + SharepointPreviewTool, + FunctionShellToolParam, + WebSearchTool, + WebSearchPreviewTool, + WorkIQPreviewTool, +] +OutputItem = Union[ + A2AToolCall, + A2AToolCallOutput, + OutputItemApplyPatchToolCall, + OutputItemApplyPatchToolCallOutput, + AzureAISearchToolCall, + AzureAISearchToolCallOutput, + AzureFunctionToolCall, + AzureFunctionToolCallOutput, + BingCustomSearchToolCall, + BingCustomSearchToolCallOutput, + BingGroundingToolCall, + BingGroundingToolCallOutput, + BrowserAutomationToolCall, + BrowserAutomationToolCallOutput, + OutputItemCodeInterpreterToolCall, + OutputItemCompactionBody, + OutputItemComputerToolCall, + OutputItemComputerToolCallOutputResource, + OutputItemCustomToolCall, + OutputItemCustomToolCallOutput, + FabricDataAgentToolCall, + FabricDataAgentToolCallOutput, + OutputItemFileSearchToolCall, + OutputItemFunctionToolCall, + FunctionToolCallOutputResource, + OutputItemImageGenToolCall, + OutputItemLocalShellToolCall, + OutputItemLocalShellToolCallOutput, + OutputItemMcpApprovalRequest, + OutputItemMcpApprovalResponseResource, + OutputItemMcpToolCall, + OutputItemMcpListTools, + MemorySearchToolCallItemResource, + OutputItemMessage, + OAuthConsentRequestOutputItem, + OpenApiToolCall, + OpenApiToolCallOutput, + OutputItemOutputMessage, + OutputItemReasoningItem, + SharepointGroundingToolCall, + SharepointGroundingToolCallOutput, + OutputItemFunctionShellCall, + OutputItemFunctionShellCallOutput, + StructuredOutputsOutputItem, + OutputItemWebSearchToolCall, + WorkflowActionOutputItem, +] +Annotation = Union[ContainerFileCitationBody, FileCitationBody, FilePath, UrlCitationBody] +ApplyPatchFileOperation = Union[ + ApplyPatchCreateFileOperation, ApplyPatchDeleteFileOperation, ApplyPatchUpdateFileOperation +] +ApplyPatchOperationParam = Union[ + ApplyPatchCreateFileOperationParam, ApplyPatchDeleteFileOperationParam, ApplyPatchUpdateFileOperationParam +] +Item = Union[ + ApplyPatchToolCallItemParam, + ApplyPatchToolCallOutputItemParam, + ItemCodeInterpreterToolCall, + CompactionSummaryItemParam, + ItemComputerToolCall, + ComputerCallOutputItemParam, + ItemCustomToolCall, + ItemCustomToolCallOutput, + ItemFileSearchToolCall, + ItemFunctionToolCall, + FunctionCallOutputItemParam, + ItemImageGenToolCall, + ItemReferenceParam, + ItemLocalShellToolCall, + ItemLocalShellToolCallOutput, + ItemMcpApprovalRequest, + MCPApprovalResponse, + ItemMcpToolCall, + ItemMcpListTools, + MemorySearchToolCallItemParam, + ItemMessage, + ItemOutputMessage, + ItemReasoningItem, + FunctionShellCallItemParam, + FunctionShellCallOutputItemParam, + ItemWebSearchToolCall, +] +MemoryItem = Union[ChatSummaryMemoryItem, UserProfileMemoryItem] +ComputerAction = Union[ + ClickParam, + DoubleClickAction, + DragParam, + KeyPressAction, + MoveParam, + ScreenshotParam, + ScrollParam, + TypeParam, + WaitParam, +] +MessageContent = Union[ + ComputerScreenshotContent, + MessageContentInputFileContent, + MessageContentInputImageContent, + MessageContentInputTextContent, + MessageContentOutputTextContent, + MessageContentReasoningTextContent, + MessageContentRefusalContent, + SummaryTextContent, + TextContent, +] +FunctionShellToolParamEnvironment = Union[ + ContainerAutoParam, + FunctionShellToolParamEnvironmentContainerReferenceParam, + FunctionShellToolParamEnvironmentLocalEnvironmentParam, +] +ContainerNetworkPolicyParam = Union[ContainerNetworkPolicyAllowlistParam, ContainerNetworkPolicyDisabledParam] +FunctionShellCallEnvironment = Union[ContainerReferenceResource, LocalEnvironmentResource] +ContainerSkill = Union[InlineSkillParam, SkillReferenceParam] +CustomToolParamFormat = Union[CustomGrammarFormatParam, CustomTextFormatParam] +FunctionAndCustomToolCallOutput = Union[ + FunctionAndCustomToolCallOutputInputFileContent, + FunctionAndCustomToolCallOutputInputImageContent, + FunctionAndCustomToolCallOutputInputTextContent, +] +FunctionShellCallItemParamEnvironment = Union[ + FunctionShellCallItemParamEnvironmentContainerReferenceParam, + FunctionShellCallItemParamEnvironmentLocalEnvironmentParam, +] +FunctionShellCallOutputOutcome = Union[FunctionShellCallOutputExitOutcome, FunctionShellCallOutputTimeoutOutcome] +FunctionShellCallOutputOutcomeParam = Union[ + FunctionShellCallOutputExitOutcomeParam, FunctionShellCallOutputTimeoutOutcomeParam +] +ItemField = Union[ + ItemFieldApplyPatchToolCall, + ItemFieldApplyPatchToolCallOutput, + ItemFieldCodeInterpreterToolCall, + ItemFieldCompactionBody, + ItemFieldComputerToolCall, + ItemFieldComputerToolCallOutputResource, + ItemFieldCustomToolCall, + ItemFieldCustomToolCallOutput, + ItemFieldFileSearchToolCall, + ItemFieldFunctionToolCall, + FunctionToolCallOutput, + ItemFieldImageGenToolCall, + ItemFieldLocalShellToolCall, + ItemFieldLocalShellToolCallOutput, + ItemFieldMcpApprovalRequest, + ItemFieldMcpApprovalResponseResource, + ItemFieldMcpToolCall, + ItemFieldMcpListTools, + ItemFieldMessage, + ItemFieldReasoningItem, + ItemFieldFunctionShellCall, + ItemFieldFunctionShellCallOutput, + ItemFieldWebSearchToolCall, +] +OpenApiAuthDetails = Union[OpenApiAnonymousAuthDetails, OpenApiManagedAuthDetails, OpenApiProjectConnectionAuthDetails] +OutputContent = Union[OutputContentOutputTextContent, OutputContentReasoningTextContent, OutputContentRefusalContent] +OutputMessageContent = Union[OutputMessageContentOutputTextContent, OutputMessageContentRefusalContent] +ResponseStreamEvent = Union[ + ResponseErrorEvent, + ResponseAudioDeltaEvent, + ResponseAudioDoneEvent, + ResponseAudioTranscriptDeltaEvent, + ResponseAudioTranscriptDoneEvent, + ResponseCodeInterpreterCallCompletedEvent, + ResponseCodeInterpreterCallInProgressEvent, + ResponseCodeInterpreterCallInterpretingEvent, + ResponseCodeInterpreterCallCodeDeltaEvent, + ResponseCodeInterpreterCallCodeDoneEvent, + ResponseCompletedEvent, + ResponseContentPartAddedEvent, + ResponseContentPartDoneEvent, + ResponseCreatedEvent, + ResponseCustomToolCallInputDeltaEvent, + ResponseCustomToolCallInputDoneEvent, + ResponseFailedEvent, + ResponseFileSearchCallCompletedEvent, + ResponseFileSearchCallInProgressEvent, + ResponseFileSearchCallSearchingEvent, + ResponseFunctionCallArgumentsDeltaEvent, + ResponseFunctionCallArgumentsDoneEvent, + ResponseImageGenCallCompletedEvent, + ResponseImageGenCallGeneratingEvent, + ResponseImageGenCallInProgressEvent, + ResponseImageGenCallPartialImageEvent, + ResponseInProgressEvent, + ResponseIncompleteEvent, + ResponseMCPCallCompletedEvent, + ResponseMCPCallFailedEvent, + ResponseMCPCallInProgressEvent, + ResponseMCPCallArgumentsDeltaEvent, + ResponseMCPCallArgumentsDoneEvent, + ResponseMCPListToolsCompletedEvent, + ResponseMCPListToolsFailedEvent, + ResponseMCPListToolsInProgressEvent, + ResponseOutputItemAddedEvent, + ResponseOutputItemDoneEvent, + ResponseOutputTextAnnotationAddedEvent, + ResponseTextDeltaEvent, + ResponseTextDoneEvent, + ResponseQueuedEvent, + ResponseReasoningSummaryPartAddedEvent, + ResponseReasoningSummaryPartDoneEvent, + ResponseReasoningSummaryTextDeltaEvent, + ResponseReasoningSummaryTextDoneEvent, + ResponseReasoningTextDeltaEvent, + ResponseReasoningTextDoneEvent, + ResponseRefusalDeltaEvent, + ResponseRefusalDoneEvent, + ResponseWebSearchCallCompletedEvent, + ResponseWebSearchCallInProgressEvent, + ResponseWebSearchCallSearchingEvent, +] +ToolChoiceParam = Union[ + ToolChoiceAllowed, + SpecificApplyPatchParam, + ToolChoiceCodeInterpreter, + ToolChoiceComputerUsePreview, + ToolChoiceCustom, + ToolChoiceFileSearch, + ToolChoiceFunction, + ToolChoiceImageGeneration, + ToolChoiceMCP, + SpecificFunctionShellParam, + ToolChoiceWebSearchPreview, + ToolChoiceWebSearchPreview20250311, +] +TextResponseFormatConfiguration = Union[ + TextResponseFormatConfigurationResponseFormatJsonObject, + TextResponseFormatJsonSchema, + TextResponseFormatConfigurationResponseFormatText, +] From 9911eb44f6fe445d551fab00b99b609389d1fd90 Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Wed, 17 Jun 2026 15:18:01 -0400 Subject: [PATCH 4/5] revert changed files --- sdk/ai/azure-ai-agents/_metadata.json | 5 +- .../azure-ai-agents/apiview-properties.json | 440 +- .../azure/ai/agents/__init__.py | 5 +- .../azure/ai/agents/_client.py | 105 +- .../azure/ai/agents/_configuration.py | 29 +- .../azure/ai/agents/_utils/model_base.py | 13 +- .../azure/ai/agents/_utils/serialization.py | 46 +- .../azure/ai/agents/_utils/utils.py | 44 +- .../azure/ai/agents/aio/__init__.py | 5 +- .../azure/ai/agents/aio/_client.py | 106 +- .../azure/ai/agents/aio/_configuration.py | 29 +- .../ai/agents/aio/operations/__init__.py | 32 +- .../ai/agents/aio/operations/_operations.py | 16075 +++----------- .../azure/ai/agents/models/__init__.py | 527 +- .../azure/ai/agents/models/_models.py | 1 - .../azure/ai/agents/operations/__init__.py | 32 +- .../azure/ai/agents/operations/_operations.py | 17680 +++------------- sdk/ai/azure-ai-agents/pyproject.toml | 79 +- ...gents_basics_with_console_tracing_async.py | 7 +- sdk/ai/azure-ai-agents/setup.py | 80 + 20 files changed, 7457 insertions(+), 27883 deletions(-) create mode 100644 sdk/ai/azure-ai-agents/setup.py diff --git a/sdk/ai/azure-ai-agents/_metadata.json b/sdk/ai/azure-ai-agents/_metadata.json index 3a000fe50d57..253921f335be 100644 --- a/sdk/ai/azure-ai-agents/_metadata.json +++ b/sdk/ai/azure-ai-agents/_metadata.json @@ -1,6 +1,3 @@ { - "apiVersion": "v1", - "apiVersions": { - "Azure.AI.Projects": "v1" - } + "apiVersion": "2025-05-15-preview" } \ No newline at end of file diff --git a/sdk/ai/azure-ai-agents/apiview-properties.json b/sdk/ai/azure-ai-agents/apiview-properties.json index 94e4052093de..823c94f6b76f 100644 --- a/sdk/ai/azure-ai-agents/apiview-properties.json +++ b/sdk/ai/azure-ai-agents/apiview-properties.json @@ -1,114 +1,332 @@ { - "CrossLanguagePackageId": "Azure.AI.Projects", + "CrossLanguagePackageId": "Azure.AI.Agents", "CrossLanguageDefinitionId": { - "azure.ai.agents.models.EvaluationTaxonomyInputType": "Azure.AI.Projects.EvaluationTaxonomyInputType", - "azure.ai.agents.models.RiskCategory": "Azure.AI.Projects.RiskCategory", - "azure.ai.agents.models.FoundryFeaturesOptInKeys": "Azure.AI.Projects.FoundryFeaturesOptInKeys", - "azure.ai.agents.models.EvaluatorType": "Azure.AI.Projects.EvaluatorType", - "azure.ai.agents.models.EvaluatorCategory": "Azure.AI.Projects.EvaluatorCategory", - "azure.ai.agents.models.EvaluatorDefinitionType": "Azure.AI.Projects.EvaluatorDefinitionType", - "azure.ai.agents.models.EvaluatorMetricType": "Azure.AI.Projects.EvaluatorMetricType", - "azure.ai.agents.models.EvaluatorMetricDirection": "Azure.AI.Projects.EvaluatorMetricDirection", - "azure.ai.agents.models.OperationState": "Azure.Core.Foundations.OperationState", - "azure.ai.agents.models.InsightType": "Azure.AI.Projects.InsightType", - "azure.ai.agents.models.SampleType": "Azure.AI.Projects.SampleType", - "azure.ai.agents.models.TreatmentEffectType": "Azure.AI.Projects.TreatmentEffectType", - "azure.ai.agents.models.MemoryStoreObjectType": "Azure.AI.Projects.MemoryStoreObjectType", - "azure.ai.agents.models.MemoryStoreKind": "Azure.AI.Projects.MemoryStoreKind", - "azure.ai.agents.models.PageOrder": "Azure.AI.Projects.PageOrder", - "azure.ai.agents.models.MemoryItemKind": "Azure.AI.Projects.MemoryItemKind", - "azure.ai.agents.models.MemoryOperationKind": "Azure.AI.Projects.MemoryOperationKind", - "azure.ai.agents.models.AttackStrategy": "Azure.AI.Projects.AttackStrategy", - "azure.ai.agents.models.ScheduleProvisioningStatus": "Azure.AI.Projects.ScheduleProvisioningStatus", - "azure.ai.agents.models.TriggerType": "Azure.AI.Projects.TriggerType", - "azure.ai.agents.models.RecurrenceType": "Azure.AI.Projects.RecurrenceType", - "azure.ai.agents.models.DayOfWeek": "Azure.AI.Projects.DayOfWeek", - "azure.ai.agents.models.ScheduleTaskType": "Azure.AI.Projects.ScheduleTaskType", - "azure.ai.agents.models.AgentObjectType": "Azure.AI.Projects.AgentObjectType", - "azure.ai.agents.models.AgentKind": "Azure.AI.Projects.AgentKind", - "azure.ai.agents.models.ToolType": "OpenAI.ToolType", - "azure.ai.agents.models.AzureAISearchQueryType": "Azure.AI.Projects.AzureAISearchQueryType", - "azure.ai.agents.models.ContainerMemoryLimit": "OpenAI.ContainerMemoryLimit", - "azure.ai.agents.models.ContainerNetworkPolicyParamType": "OpenAI.ContainerNetworkPolicyParamType", - "azure.ai.agents.models.ComputerEnvironment": "OpenAI.ComputerEnvironment", - "azure.ai.agents.models.CustomToolParamFormatType": "OpenAI.CustomToolParamFormatType", - "azure.ai.agents.models.GrammarSyntax1": "OpenAI.GrammarSyntax1", - "azure.ai.agents.models.RankerVersionType": "OpenAI.RankerVersionType", - "azure.ai.agents.models.InputFidelity": "OpenAI.InputFidelity", - "azure.ai.agents.models.ImageGenAction": "OpenAI.ImageGenActionEnum", - "azure.ai.agents.models.OpenApiAuthType": "Azure.AI.Projects.OpenApiAuthType", - "azure.ai.agents.models.FunctionShellToolParamEnvironmentType": "OpenAI.FunctionShellToolParamEnvironmentType", - "azure.ai.agents.models.ContainerSkillType": "OpenAI.ContainerSkillType", - "azure.ai.agents.models.SearchContextSize": "OpenAI.SearchContextSize", - "azure.ai.agents.models.AgentProtocol": "Azure.AI.Projects.AgentProtocol", - "azure.ai.agents.models.ToolChoiceParamType": "OpenAI.ToolChoiceParamType", - "azure.ai.agents.models.TextResponseFormatConfigurationType": "OpenAI.TextResponseFormatConfigurationType", - "azure.ai.agents.models.AgentDefinitionOptInKeys": "Azure.AI.Projects.AgentDefinitionOptInKeys", - "azure.ai.agents.models.EvaluationRuleActionType": "Azure.AI.Projects.EvaluationRuleActionType", - "azure.ai.agents.models.EvaluationRuleEventType": "Azure.AI.Projects.EvaluationRuleEventType", - "azure.ai.agents.models.ConnectionType": "Azure.AI.Projects.ConnectionType", - "azure.ai.agents.models.CredentialType": "Azure.AI.Projects.CredentialType", - "azure.ai.agents.models.DatasetType": "Azure.AI.Projects.DatasetType", - "azure.ai.agents.models.PendingUploadType": "Azure.AI.Projects.PendingUploadType", - "azure.ai.agents.models.DeploymentType": "Azure.AI.Projects.DeploymentType", - "azure.ai.agents.models.IndexType": "Azure.AI.Projects.IndexType", - "azure.ai.agents.models.MemoryStoreUpdateStatus": "Azure.AI.Projects.MemoryStoreUpdateStatus", - "azure.ai.agents.operations.AgentsOperations.get": "Azure.AI.Projects.Agents.getAgent", - "azure.ai.agents.aio.operations.AgentsOperations.get": "Azure.AI.Projects.Agents.getAgent", - "azure.ai.agents.operations.AgentsOperations.delete": "Azure.AI.Projects.Agents.deleteAgent", - "azure.ai.agents.aio.operations.AgentsOperations.delete": "Azure.AI.Projects.Agents.deleteAgent", - "azure.ai.agents.operations.AgentsOperations.list": "Azure.AI.Projects.Agents.listAgents", - "azure.ai.agents.aio.operations.AgentsOperations.list": "Azure.AI.Projects.Agents.listAgents", - "azure.ai.agents.operations.AgentsOperations.create_version": "Azure.AI.Projects.Agents.createAgentVersion", - "azure.ai.agents.aio.operations.AgentsOperations.create_version": "Azure.AI.Projects.Agents.createAgentVersion", - "azure.ai.agents.operations.AgentsOperations.create_version_from_manifest": "Azure.AI.Projects.Agents.createAgentVersionFromManifest", - "azure.ai.agents.aio.operations.AgentsOperations.create_version_from_manifest": "Azure.AI.Projects.Agents.createAgentVersionFromManifest", - "azure.ai.agents.operations.AgentsOperations.get_version": "Azure.AI.Projects.Agents.getAgentVersion", - "azure.ai.agents.aio.operations.AgentsOperations.get_version": "Azure.AI.Projects.Agents.getAgentVersion", - "azure.ai.agents.operations.AgentsOperations.delete_version": "Azure.AI.Projects.Agents.deleteAgentVersion", - "azure.ai.agents.aio.operations.AgentsOperations.delete_version": "Azure.AI.Projects.Agents.deleteAgentVersion", - "azure.ai.agents.operations.AgentsOperations.list_versions": "Azure.AI.Projects.Agents.listAgentVersions", - "azure.ai.agents.aio.operations.AgentsOperations.list_versions": "Azure.AI.Projects.Agents.listAgentVersions", - "azure.ai.agents.operations.EvaluationRulesOperations.get": "Azure.AI.Projects.EvaluationRules.get", - "azure.ai.agents.aio.operations.EvaluationRulesOperations.get": "Azure.AI.Projects.EvaluationRules.get", - "azure.ai.agents.operations.EvaluationRulesOperations.delete": "Azure.AI.Projects.EvaluationRules.delete", - "azure.ai.agents.aio.operations.EvaluationRulesOperations.delete": "Azure.AI.Projects.EvaluationRules.delete", - "azure.ai.agents.operations.EvaluationRulesOperations.create_or_update": "Azure.AI.Projects.EvaluationRules.createOrUpdate", - "azure.ai.agents.aio.operations.EvaluationRulesOperations.create_or_update": "Azure.AI.Projects.EvaluationRules.createOrUpdate", - "azure.ai.agents.operations.EvaluationRulesOperations.list": "Azure.AI.Projects.EvaluationRules.list", - "azure.ai.agents.aio.operations.EvaluationRulesOperations.list": "Azure.AI.Projects.EvaluationRules.list", - "azure.ai.agents.operations.ConnectionsOperations.list": "Azure.AI.Projects.Connections.list", - "azure.ai.agents.aio.operations.ConnectionsOperations.list": "Azure.AI.Projects.Connections.list", - "azure.ai.agents.operations.DatasetsOperations.list_versions": "Azure.AI.Projects.Datasets.listVersions", - "azure.ai.agents.aio.operations.DatasetsOperations.list_versions": "Azure.AI.Projects.Datasets.listVersions", - "azure.ai.agents.operations.DatasetsOperations.list": "Azure.AI.Projects.Datasets.listLatest", - "azure.ai.agents.aio.operations.DatasetsOperations.list": "Azure.AI.Projects.Datasets.listLatest", - "azure.ai.agents.operations.DatasetsOperations.get": "Azure.AI.Projects.Datasets.getVersion", - "azure.ai.agents.aio.operations.DatasetsOperations.get": "Azure.AI.Projects.Datasets.getVersion", - "azure.ai.agents.operations.DatasetsOperations.delete": "Azure.AI.Projects.Datasets.deleteVersion", - "azure.ai.agents.aio.operations.DatasetsOperations.delete": "Azure.AI.Projects.Datasets.deleteVersion", - "azure.ai.agents.operations.DatasetsOperations.create_or_update": "Azure.AI.Projects.Datasets.createOrUpdateVersion", - "azure.ai.agents.aio.operations.DatasetsOperations.create_or_update": "Azure.AI.Projects.Datasets.createOrUpdateVersion", - "azure.ai.agents.operations.DatasetsOperations.pending_upload": "Azure.AI.Projects.Datasets.startPendingUploadVersion", - "azure.ai.agents.aio.operations.DatasetsOperations.pending_upload": "Azure.AI.Projects.Datasets.startPendingUploadVersion", - "azure.ai.agents.operations.DatasetsOperations.get_credentials": "Azure.AI.Projects.Datasets.getCredentials", - "azure.ai.agents.aio.operations.DatasetsOperations.get_credentials": "Azure.AI.Projects.Datasets.getCredentials", - "azure.ai.agents.operations.DeploymentsOperations.get": "Azure.AI.Projects.Deployments.get", - "azure.ai.agents.aio.operations.DeploymentsOperations.get": "Azure.AI.Projects.Deployments.get", - "azure.ai.agents.operations.DeploymentsOperations.list": "Azure.AI.Projects.Deployments.list", - "azure.ai.agents.aio.operations.DeploymentsOperations.list": "Azure.AI.Projects.Deployments.list", - "azure.ai.agents.operations.IndexesOperations.list_versions": "Azure.AI.Projects.Indexes.listVersions", - "azure.ai.agents.aio.operations.IndexesOperations.list_versions": "Azure.AI.Projects.Indexes.listVersions", - "azure.ai.agents.operations.IndexesOperations.list": "Azure.AI.Projects.Indexes.listLatest", - "azure.ai.agents.aio.operations.IndexesOperations.list": "Azure.AI.Projects.Indexes.listLatest", - "azure.ai.agents.operations.IndexesOperations.get": "Azure.AI.Projects.Indexes.getVersion", - "azure.ai.agents.aio.operations.IndexesOperations.get": "Azure.AI.Projects.Indexes.getVersion", - "azure.ai.agents.operations.IndexesOperations.delete": "Azure.AI.Projects.Indexes.deleteVersion", - "azure.ai.agents.aio.operations.IndexesOperations.delete": "Azure.AI.Projects.Indexes.deleteVersion", - "azure.ai.agents.operations.IndexesOperations.create_or_update": "Azure.AI.Projects.Indexes.createOrUpdateVersion", - "azure.ai.agents.aio.operations.IndexesOperations.create_or_update": "Azure.AI.Projects.Indexes.createOrUpdateVersion", - "azure.ai.agents.AIProjectClient.delete_job": "Azure.AI.Projects.deleteJob", - "azure.ai.agents.aio.AIProjectClient.delete_job": "Azure.AI.Projects.deleteJob" - }, - "CrossLanguageVersion": "57c7f7bb54d2" + "azure.ai.agents.models.ActivityFunctionDefinition": "Azure.AI.Agents.ActivityFunctionDefinition", + "azure.ai.agents.models.ActivityFunctionParameters": "Azure.AI.Agents.ActivityFunctionParameters", + "azure.ai.agents.models.Agent": "Azure.AI.Agents.Agent", + "azure.ai.agents.models.AgentErrorDetail": "Azure.AI.Agents.AgentErrorDetail", + "azure.ai.agents.models.AgentsNamedToolChoice": "Azure.AI.Agents.AgentsNamedToolChoice", + "azure.ai.agents.models.AgentsResponseFormat": "Azure.AI.Agents.AgentsResponseFormat", + "azure.ai.agents.models.AgentThread": "Azure.AI.Agents.AgentThread", + "azure.ai.agents.models.AgentThreadCreationOptions": "Azure.AI.Agents.AgentThreadCreationOptions", + "azure.ai.agents.models.AgentV1Error": "Azure.AI.Agents.AgentV1Error", + "azure.ai.agents.models.AISearchIndexResource": "Azure.AI.Agents.AISearchIndexResource", + "azure.ai.agents.models.ToolDefinition": "Azure.AI.Agents.ToolDefinition", + "azure.ai.agents.models.AzureAISearchToolDefinition": "Azure.AI.Agents.AzureAISearchToolDefinition", + "azure.ai.agents.models.AzureAISearchToolResource": "Azure.AI.Agents.AzureAISearchToolResource", + "azure.ai.agents.models.AzureFunctionBinding": "Azure.AI.Agents.AzureFunctionBinding", + "azure.ai.agents.models.AzureFunctionDefinition": "Azure.AI.Agents.AzureFunctionDefinition", + "azure.ai.agents.models.AzureFunctionStorageQueue": "Azure.AI.Agents.AzureFunctionStorageQueue", + "azure.ai.agents.models.AzureFunctionToolCallDetails": "Azure.AI.Agents.AzureFunctionToolCallDetails", + "azure.ai.agents.models.AzureFunctionToolDefinition": "Azure.AI.Agents.AzureFunctionToolDefinition", + "azure.ai.agents.models.BingCustomSearchConfiguration": "Azure.AI.Agents.BingCustomSearchConfiguration", + "azure.ai.agents.models.BingCustomSearchToolDefinition": "Azure.AI.Agents.BingCustomSearchToolDefinition", + "azure.ai.agents.models.BingCustomSearchToolParameters": "Azure.AI.Agents.BingCustomSearchToolParameters", + "azure.ai.agents.models.BingGroundingSearchConfiguration": "Azure.AI.Agents.BingGroundingSearchConfiguration", + "azure.ai.agents.models.BingGroundingSearchToolParameters": "Azure.AI.Agents.BingGroundingSearchToolParameters", + "azure.ai.agents.models.BingGroundingToolDefinition": "Azure.AI.Agents.BingGroundingToolDefinition", + "azure.ai.agents.models.BrowserAutomationToolCallDetails": "Azure.AI.Agents.BrowserAutomationToolCallDetails", + "azure.ai.agents.models.BrowserAutomationToolCallStep": "Azure.AI.Agents.BrowserAutomationToolCallStep", + "azure.ai.agents.models.BrowserAutomationToolConnectionParameters": "Azure.AI.Agents.BrowserAutomationToolConnectionParameters", + "azure.ai.agents.models.BrowserAutomationToolDefinition": "Azure.AI.Agents.BrowserAutomationToolDefinition", + "azure.ai.agents.models.BrowserAutomationToolParameters": "Azure.AI.Agents.BrowserAutomationToolParameters", + "azure.ai.agents.models.ComputerUseAction": "Azure.AI.Agents.ComputerUseAction", + "azure.ai.agents.models.ClickAction": "Azure.AI.Agents.ClickAction", + "azure.ai.agents.models.CodeInterpreterToolDefinition": "Azure.AI.Agents.CodeInterpreterToolDefinition", + "azure.ai.agents.models.CodeInterpreterToolResource": "Azure.AI.Agents.CodeInterpreterToolResource", + "azure.ai.agents.models.ComputerScreenshot": "Azure.AI.Agents.ComputerScreenshot", + "azure.ai.agents.models.StructuredToolOutput": "Azure.AI.Agents.StructuredToolOutput", + "azure.ai.agents.models.ComputerToolOutput": "Azure.AI.Agents.ComputerToolOutput", + "azure.ai.agents.models.ComputerUseToolDefinition": "Azure.AI.Agents.ComputerUseToolDefinition", + "azure.ai.agents.models.ComputerUseToolParameters": "Azure.AI.Agents.ComputerUseToolParameters", + "azure.ai.agents.models.ConnectedAgentDetails": "Azure.AI.Agents.ConnectedAgentDetails", + "azure.ai.agents.models.ConnectedAgentToolDefinition": "Azure.AI.Agents.ConnectedAgentToolDefinition", + "azure.ai.agents.models.CoordinatePoint": "Azure.AI.Agents.CoordinatePoint", + "azure.ai.agents.models.DeepResearchBingGroundingConnection": "Azure.AI.Agents.DeepResearchBingGroundingConnection", + "azure.ai.agents.models.DeepResearchDetails": "Azure.AI.Agents.DeepResearchDetails", + "azure.ai.agents.models.DeepResearchToolDefinition": "Azure.AI.Agents.DeepResearchToolDefinition", + "azure.ai.agents.models.DoubleClickAction": "Azure.AI.Agents.DoubleClickAction", + "azure.ai.agents.models.DragAction": "Azure.AI.Agents.DragAction", + "azure.ai.agents.models.FabricDataAgentToolParameters": "Azure.AI.Agents.FabricDataAgentToolParameters", + "azure.ai.agents.models.FileInfo": "Azure.AI.Agents.FileInfo", + "azure.ai.agents.models.FileListResponse": "Azure.AI.Agents.FileListResponse", + "azure.ai.agents.models.FileSearchRankingOptions": "Azure.AI.Agents.FileSearchRankingOptions", + "azure.ai.agents.models.FileSearchToolCallContent": "Azure.AI.Agents.FileSearchToolCallContent", + "azure.ai.agents.models.FileSearchToolDefinition": "Azure.AI.Agents.FileSearchToolDefinition", + "azure.ai.agents.models.FileSearchToolDefinitionDetails": "Azure.AI.Agents.FileSearchToolDefinitionDetails", + "azure.ai.agents.models.FileSearchToolResource": "Azure.AI.Agents.FileSearchToolResource", + "azure.ai.agents.models.FunctionArgument": "Azure.AI.Agents.FunctionArgument", + "azure.ai.agents.models.FunctionDefinition": "Azure.AI.Agents.FunctionDefinition", + "azure.ai.agents.models.FunctionName": "Azure.AI.Agents.FunctionName", + "azure.ai.agents.models.FunctionToolDefinition": "Azure.AI.Agents.FunctionToolDefinition", + "azure.ai.agents.models.IncompleteRunDetails": "Azure.AI.Agents.IncompleteRunDetails", + "azure.ai.agents.models.KeyPressAction": "Azure.AI.Agents.KeyPressAction", + "azure.ai.agents.models.MCPApprovalPerTool": "Azure.AI.Agents.MCPApprovalPerTool", + "azure.ai.agents.models.MCPToolDefinition": "Azure.AI.Agents.MCPToolDefinition", + "azure.ai.agents.models.MCPToolList": "Azure.AI.Agents.MCPToolList", + "azure.ai.agents.models.MCPToolResource": "Azure.AI.Agents.MCPToolResource", + "azure.ai.agents.models.MessageAttachment": "Azure.AI.Agents.MessageAttachment", + "azure.ai.agents.models.MessageContent": "Azure.AI.Agents.MessageContent", + "azure.ai.agents.models.MessageDelta": "Azure.AI.Agents.MessageDelta", + "azure.ai.agents.models.MessageDeltaChunk": "Azure.AI.Agents.MessageDeltaChunk", + "azure.ai.agents.models.MessageDeltaContent": "Azure.AI.Agents.MessageDeltaContent", + "azure.ai.agents.models.MessageDeltaImageFileContent": "Azure.AI.Agents.MessageDeltaImageFileContent", + "azure.ai.agents.models.MessageDeltaImageFileContentObject": "Azure.AI.Agents.MessageDeltaImageFileContentObject", + "azure.ai.agents.models.MessageDeltaTextAnnotation": "Azure.AI.Agents.MessageDeltaTextAnnotation", + "azure.ai.agents.models.MessageDeltaTextContent": "Azure.AI.Agents.MessageDeltaTextContent", + "azure.ai.agents.models.MessageDeltaTextContentObject": "Azure.AI.Agents.MessageDeltaTextContentObject", + "azure.ai.agents.models.MessageDeltaTextFileCitationAnnotation": "Azure.AI.Agents.MessageDeltaTextFileCitationAnnotation", + "azure.ai.agents.models.MessageDeltaTextFileCitationAnnotationObject": "Azure.AI.Agents.MessageDeltaTextFileCitationAnnotationObject", + "azure.ai.agents.models.MessageDeltaTextFilePathAnnotation": "Azure.AI.Agents.MessageDeltaTextFilePathAnnotation", + "azure.ai.agents.models.MessageDeltaTextFilePathAnnotationObject": "Azure.AI.Agents.MessageDeltaTextFilePathAnnotationObject", + "azure.ai.agents.models.MessageDeltaTextUrlCitationAnnotation": "Azure.AI.Agents.MessageDeltaTextUrlCitationAnnotation", + "azure.ai.agents.models.MessageDeltaTextUrlCitationDetails": "Azure.AI.Agents.MessageDeltaTextUrlCitationDetails", + "azure.ai.agents.models.MessageImageFileContent": "Azure.AI.Agents.MessageImageFileContent", + "azure.ai.agents.models.MessageImageFileDetails": "Azure.AI.Agents.MessageImageFileDetails", + "azure.ai.agents.models.MessageImageFileParam": "Azure.AI.Agents.MessageImageFileParam", + "azure.ai.agents.models.MessageImageUrlParam": "Azure.AI.Agents.MessageImageUrlParam", + "azure.ai.agents.models.MessageIncompleteDetails": "Azure.AI.Agents.MessageIncompleteDetails", + "azure.ai.agents.models.MessageInputContentBlock": "Azure.AI.Agents.MessageInputContentBlock", + "azure.ai.agents.models.MessageInputImageFileBlock": "Azure.AI.Agents.MessageInputImageFileBlock", + "azure.ai.agents.models.MessageInputImageUrlBlock": "Azure.AI.Agents.MessageInputImageUrlBlock", + "azure.ai.agents.models.MessageInputTextBlock": "Azure.AI.Agents.MessageInputTextBlock", + "azure.ai.agents.models.MessageTextAnnotation": "Azure.AI.Agents.MessageTextAnnotation", + "azure.ai.agents.models.MessageTextContent": "Azure.AI.Agents.MessageTextContent", + "azure.ai.agents.models.MessageTextDetails": "Azure.AI.Agents.MessageTextDetails", + "azure.ai.agents.models.MessageTextFileCitationAnnotation": "Azure.AI.Agents.MessageTextFileCitationAnnotation", + "azure.ai.agents.models.MessageTextFileCitationDetails": "Azure.AI.Agents.MessageTextFileCitationDetails", + "azure.ai.agents.models.MessageTextFilePathAnnotation": "Azure.AI.Agents.MessageTextFilePathAnnotation", + "azure.ai.agents.models.MessageTextFilePathDetails": "Azure.AI.Agents.MessageTextFilePathDetails", + "azure.ai.agents.models.MessageTextUrlCitationAnnotation": "Azure.AI.Agents.MessageTextUrlCitationAnnotation", + "azure.ai.agents.models.MessageTextUrlCitationDetails": "Azure.AI.Agents.MessageTextUrlCitationDetails", + "azure.ai.agents.models.MicrosoftFabricToolDefinition": "Azure.AI.Agents.MicrosoftFabricToolDefinition", + "azure.ai.agents.models.MoveAction": "Azure.AI.Agents.MoveAction", + "azure.ai.agents.models.OpenApiAuthDetails": "Azure.AI.Agents.OpenApiAuthDetails", + "azure.ai.agents.models.OpenApiAnonymousAuthDetails": "Azure.AI.Agents.OpenApiAnonymousAuthDetails", + "azure.ai.agents.models.OpenApiConnectionAuthDetails": "Azure.AI.Agents.OpenApiConnectionAuthDetails", + "azure.ai.agents.models.OpenApiConnectionSecurityScheme": "Azure.AI.Agents.OpenApiConnectionSecurityScheme", + "azure.ai.agents.models.OpenApiFunctionDefinition": "Azure.AI.Agents.OpenApiFunctionDefinition", + "azure.ai.agents.models.OpenApiManagedAuthDetails": "Azure.AI.Agents.OpenApiManagedAuthDetails", + "azure.ai.agents.models.OpenApiManagedSecurityScheme": "Azure.AI.Agents.OpenApiManagedSecurityScheme", + "azure.ai.agents.models.OpenApiToolDefinition": "Azure.AI.Agents.OpenApiToolDefinition", + "azure.ai.agents.models.RequiredAction": "Azure.AI.Agents.RequiredAction", + "azure.ai.agents.models.RequiredToolCall": "Azure.AI.Agents.RequiredToolCall", + "azure.ai.agents.models.RequiredComputerUseToolCall": "Azure.AI.Agents.RequiredComputerUseToolCall", + "azure.ai.agents.models.RequiredComputerUseToolCallDetails": "Azure.AI.Agents.RequiredComputerUseToolCallDetails", + "azure.ai.agents.models.RequiredFunctionToolCall": "Azure.AI.Agents.RequiredFunctionToolCall", + "azure.ai.agents.models.RequiredFunctionToolCallDetails": "Azure.AI.Agents.RequiredFunctionToolCallDetails", + "azure.ai.agents.models.RequiredMcpToolCall": "Azure.AI.Agents.RequiredMcpToolCall", + "azure.ai.agents.models.ResponseFormatJsonSchema": "Azure.AI.Agents.ResponseFormatJsonSchema", + "azure.ai.agents.models.ResponseFormatJsonSchemaType": "Azure.AI.Agents.ResponseFormatJsonSchemaType", + "azure.ai.agents.models.RunCompletionUsage": "Azure.AI.Agents.RunCompletionUsage", + "azure.ai.agents.models.RunError": "Azure.AI.Agents.RunError", + "azure.ai.agents.models.RunStep": "Azure.AI.Agents.RunStep", + "azure.ai.agents.models.RunStepDetails": "Azure.AI.Agents.RunStepDetails", + "azure.ai.agents.models.RunStepActivityDetails": "Azure.AI.Agents.RunStepActivityDetails", + "azure.ai.agents.models.RunStepToolCall": "Azure.AI.Agents.RunStepToolCall", + "azure.ai.agents.models.RunStepAzureAISearchToolCall": "Azure.AI.Agents.RunStepAzureAISearchToolCall", + "azure.ai.agents.models.RunStepAzureFunctionToolCall": "Azure.AI.Agents.RunStepAzureFunctionToolCall", + "azure.ai.agents.models.RunStepBingCustomSearchToolCall": "Azure.AI.Agents.RunStepBingCustomSearchToolCall", + "azure.ai.agents.models.RunStepBingGroundingToolCall": "Azure.AI.Agents.RunStepBingGroundingToolCall", + "azure.ai.agents.models.RunStepBrowserAutomationToolCall": "Azure.AI.Agents.RunStepBrowserAutomationToolCall", + "azure.ai.agents.models.RunStepCodeInterpreterToolCallOutput": "Azure.AI.Agents.RunStepCodeInterpreterToolCallOutput", + "azure.ai.agents.models.RunStepCodeInterpreterImageOutput": "Azure.AI.Agents.RunStepCodeInterpreterImageOutput", + "azure.ai.agents.models.RunStepCodeInterpreterImageReference": "Azure.AI.Agents.RunStepCodeInterpreterImageReference", + "azure.ai.agents.models.RunStepCodeInterpreterLogOutput": "Azure.AI.Agents.RunStepCodeInterpreterLogOutput", + "azure.ai.agents.models.RunStepCodeInterpreterToolCall": "Azure.AI.Agents.RunStepCodeInterpreterToolCall", + "azure.ai.agents.models.RunStepCodeInterpreterToolCallDetails": "Azure.AI.Agents.RunStepCodeInterpreterToolCallDetails", + "azure.ai.agents.models.RunStepCompletionUsage": "Azure.AI.Agents.RunStepCompletionUsage", + "azure.ai.agents.models.RunStepComputerUseToolCall": "Azure.AI.Agents.RunStepComputerUseToolCall", + "azure.ai.agents.models.RunStepComputerUseToolCallDetails": "Azure.AI.Agents.RunStepComputerUseToolCallDetails", + "azure.ai.agents.models.RunStepConnectedAgent": "Azure.AI.Agents.RunStepConnectedAgent", + "azure.ai.agents.models.RunStepConnectedAgentToolCall": "Azure.AI.Agents.RunStepConnectedAgentToolCall", + "azure.ai.agents.models.RunStepDeepResearchToolCall": "Azure.AI.Agents.RunStepDeepResearchToolCall", + "azure.ai.agents.models.RunStepDeepResearchToolCallDetails": "Azure.AI.Agents.RunStepDeepResearchToolCallDetails", + "azure.ai.agents.models.RunStepDelta": "Azure.AI.Agents.RunStepDelta", + "azure.ai.agents.models.RunStepDeltaToolCall": "Azure.AI.Agents.RunStepDeltaToolCall", + "azure.ai.agents.models.RunStepDeltaAzureAISearchToolCall": "Azure.AI.Agents.RunStepDeltaAzureAISearchToolCall", + "azure.ai.agents.models.RunStepDeltaAzureFunctionToolCall": "Azure.AI.Agents.RunStepDeltaAzureFunctionToolCall", + "azure.ai.agents.models.RunStepDeltaBingGroundingToolCall": "Azure.AI.Agents.RunStepDeltaBingGroundingToolCall", + "azure.ai.agents.models.RunStepDeltaChunk": "Azure.AI.Agents.RunStepDeltaChunk", + "azure.ai.agents.models.RunStepDeltaCodeInterpreterDetailItemObject": "Azure.AI.Agents.RunStepDeltaCodeInterpreterDetailItemObject", + "azure.ai.agents.models.RunStepDeltaCodeInterpreterOutput": "Azure.AI.Agents.RunStepDeltaCodeInterpreterOutput", + "azure.ai.agents.models.RunStepDeltaCodeInterpreterImageOutput": "Azure.AI.Agents.RunStepDeltaCodeInterpreterImageOutput", + "azure.ai.agents.models.RunStepDeltaCodeInterpreterImageOutputObject": "Azure.AI.Agents.RunStepDeltaCodeInterpreterImageOutputObject", + "azure.ai.agents.models.RunStepDeltaCodeInterpreterLogOutput": "Azure.AI.Agents.RunStepDeltaCodeInterpreterLogOutput", + "azure.ai.agents.models.RunStepDeltaCodeInterpreterToolCall": "Azure.AI.Agents.RunStepDeltaCodeInterpreterToolCall", + "azure.ai.agents.models.RunStepDeltaComputerUseDetails": "Azure.AI.Agents.RunStepDeltaComputerUseDetails", + "azure.ai.agents.models.RunStepDeltaComputerUseToolCall": "Azure.AI.Agents.RunStepDeltaComputerUseToolCall", + "azure.ai.agents.models.RunStepDeltaConnectedAgentToolCall": "Azure.AI.Agents.RunStepDeltaConnectedAgentToolCall", + "azure.ai.agents.models.RunStepDeltaCustomBingGroundingToolCall": "Azure.AI.Agents.RunStepDeltaCustomBingGroundingToolCall", + "azure.ai.agents.models.RunStepDeltaDeepResearchToolCall": "Azure.AI.Agents.RunStepDeltaDeepResearchToolCall", + "azure.ai.agents.models.RunStepDeltaDetail": "Azure.AI.Agents.RunStepDeltaDetail", + "azure.ai.agents.models.RunStepDeltaFileSearchToolCall": "Azure.AI.Agents.RunStepDeltaFileSearchToolCall", + "azure.ai.agents.models.RunStepDeltaFunction": "Azure.AI.Agents.RunStepDeltaFunction", + "azure.ai.agents.models.RunStepDeltaFunctionToolCall": "Azure.AI.Agents.RunStepDeltaFunctionToolCall", + "azure.ai.agents.models.RunStepDeltaMCPObject": "Azure.AI.Agents.RunStepDeltaMCPObject", + "azure.ai.agents.models.RunStepDeltaMcpToolCall": "Azure.AI.Agents.RunStepDeltaMcpToolCall", + "azure.ai.agents.models.RunStepDeltaMessageCreation": "Azure.AI.Agents.RunStepDeltaMessageCreation", + "azure.ai.agents.models.RunStepDeltaMessageCreationObject": "Azure.AI.Agents.RunStepDeltaMessageCreationObject", + "azure.ai.agents.models.RunStepDeltaMicrosoftFabricToolCall": "Azure.AI.Agents.RunStepDeltaMicrosoftFabricToolCall", + "azure.ai.agents.models.RunStepDeltaOpenAPIObject": "Azure.AI.Agents.RunStepDeltaOpenAPIObject", + "azure.ai.agents.models.RunStepDeltaOpenAPIToolCall": "Azure.AI.Agents.RunStepDeltaOpenAPIToolCall", + "azure.ai.agents.models.RunStepDeltaSharepointToolCall": "Azure.AI.Agents.RunStepDeltaSharepointToolCall", + "azure.ai.agents.models.RunStepDeltaToolCallObject": "Azure.AI.Agents.RunStepDeltaToolCallObject", + "azure.ai.agents.models.RunStepDetailsActivity": "Azure.AI.Agents.RunStepDetailsActivity", + "azure.ai.agents.models.RunStepError": "Azure.AI.Agents.RunStepError", + "azure.ai.agents.models.RunStepFileSearchToolCall": "Azure.AI.Agents.RunStepFileSearchToolCall", + "azure.ai.agents.models.RunStepFileSearchToolCallResult": "Azure.AI.Agents.RunStepFileSearchToolCallResult", + "azure.ai.agents.models.RunStepFileSearchToolCallResults": "Azure.AI.Agents.RunStepFileSearchToolCallResults", + "azure.ai.agents.models.RunStepFunctionToolCall": "Azure.AI.Agents.RunStepFunctionToolCall", + "azure.ai.agents.models.RunStepFunctionToolCallDetails": "Azure.AI.Agents.RunStepFunctionToolCallDetails", + "azure.ai.agents.models.RunStepMcpToolCall": "Azure.AI.Agents.RunStepMcpToolCall", + "azure.ai.agents.models.RunStepMessageCreationDetails": "Azure.AI.Agents.RunStepMessageCreationDetails", + "azure.ai.agents.models.RunStepMessageCreationReference": "Azure.AI.Agents.RunStepMessageCreationReference", + "azure.ai.agents.models.RunStepMicrosoftFabricToolCall": "Azure.AI.Agents.RunStepMicrosoftFabricToolCall", + "azure.ai.agents.models.RunStepOpenAPIToolCall": "Azure.AI.Agents.RunStepOpenAPIToolCall", + "azure.ai.agents.models.RunStepSharepointToolCall": "Azure.AI.Agents.RunStepSharepointToolCall", + "azure.ai.agents.models.RunStepToolCallDetails": "Azure.AI.Agents.RunStepToolCallDetails", + "azure.ai.agents.models.SafetyCheck": "Azure.AI.Agents.SafetyCheck", + "azure.ai.agents.models.ScreenshotAction": "Azure.AI.Agents.ScreenshotAction", + "azure.ai.agents.models.ScrollAction": "Azure.AI.Agents.ScrollAction", + "azure.ai.agents.models.SharepointGroundingToolParameters": "Azure.AI.Agents.SharepointGroundingToolParameters", + "azure.ai.agents.models.SharepointToolDefinition": "Azure.AI.Agents.SharepointToolDefinition", + "azure.ai.agents.models.SubmitToolApprovalAction": "Azure.AI.Agents.SubmitToolApprovalAction", + "azure.ai.agents.models.SubmitToolApprovalDetails": "Azure.AI.Agents.SubmitToolApprovalDetails", + "azure.ai.agents.models.SubmitToolOutputsAction": "Azure.AI.Agents.SubmitToolOutputsAction", + "azure.ai.agents.models.SubmitToolOutputsDetails": "Azure.AI.Agents.SubmitToolOutputsDetails", + "azure.ai.agents.models.ThreadMessage": "Azure.AI.Agents.ThreadMessage", + "azure.ai.agents.models.ThreadMessageOptions": "Azure.AI.Agents.ThreadMessageOptions", + "azure.ai.agents.models.ThreadRun": "Azure.AI.Agents.ThreadRun", + "azure.ai.agents.models.ToolApproval": "Azure.AI.Agents.ToolApproval", + "azure.ai.agents.models.ToolConnection": "Azure.AI.Agents.ToolConnection", + "azure.ai.agents.models.ToolOutput": "Azure.AI.Agents.ToolOutput", + "azure.ai.agents.models.ToolResources": "Azure.AI.Agents.ToolResources", + "azure.ai.agents.models.TruncationObject": "Azure.AI.Agents.TruncationObject", + "azure.ai.agents.models.TypeAction": "Azure.AI.Agents.TypeAction", + "azure.ai.agents.models.VectorStore": "Azure.AI.Agents.VectorStore", + "azure.ai.agents.models.VectorStoreChunkingStrategyRequest": "Azure.AI.Agents.VectorStoreChunkingStrategyRequest", + "azure.ai.agents.models.VectorStoreAutoChunkingStrategyRequest": "Azure.AI.Agents.VectorStoreAutoChunkingStrategyRequest", + "azure.ai.agents.models.VectorStoreChunkingStrategyResponse": "Azure.AI.Agents.VectorStoreChunkingStrategyResponse", + "azure.ai.agents.models.VectorStoreAutoChunkingStrategyResponse": "Azure.AI.Agents.VectorStoreAutoChunkingStrategyResponse", + "azure.ai.agents.models.VectorStoreConfiguration": "Azure.AI.Agents.VectorStoreConfiguration", + "azure.ai.agents.models.VectorStoreConfigurations": "Azure.AI.Agents.VectorStoreConfigurations", + "azure.ai.agents.models.VectorStoreDataSource": "Azure.AI.Agents.VectorStoreDataSource", + "azure.ai.agents.models.VectorStoreExpirationPolicy": "Azure.AI.Agents.VectorStoreExpirationPolicy", + "azure.ai.agents.models.VectorStoreFile": "Azure.AI.Agents.VectorStoreFile", + "azure.ai.agents.models.VectorStoreFileBatch": "Azure.AI.Agents.VectorStoreFileBatch", + "azure.ai.agents.models.VectorStoreFileCount": "Azure.AI.Agents.VectorStoreFileCount", + "azure.ai.agents.models.VectorStoreFileError": "Azure.AI.Agents.VectorStoreFileError", + "azure.ai.agents.models.VectorStoreStaticChunkingStrategyOptions": "Azure.AI.Agents.VectorStoreStaticChunkingStrategyOptions", + "azure.ai.agents.models.VectorStoreStaticChunkingStrategyRequest": "Azure.AI.Agents.VectorStoreStaticChunkingStrategyRequest", + "azure.ai.agents.models.VectorStoreStaticChunkingStrategyResponse": "Azure.AI.Agents.VectorStoreStaticChunkingStrategyResponse", + "azure.ai.agents.models.WaitAction": "Azure.AI.Agents.WaitAction", + "azure.ai.agents.models.VectorStoreDataSourceAssetType": "Azure.AI.Agents.VectorStoreDataSourceAssetType", + "azure.ai.agents.models.AzureAISearchQueryType": "Azure.AI.Agents.AzureAISearchQueryType", + "azure.ai.agents.models.MessageRole": "Azure.AI.Agents.MessageRole", + "azure.ai.agents.models.MessageBlockType": "Azure.AI.Agents.MessageBlockType", + "azure.ai.agents.models.ImageDetailLevel": "Azure.AI.Agents.ImageDetailLevel", + "azure.ai.agents.models.ComputerUseEnvironment": "Azure.AI.Agents.ComputerUseEnvironment", + "azure.ai.agents.models.OpenApiAuthType": "Azure.AI.Agents.OpenApiAuthType", + "azure.ai.agents.models.ListSortOrder": "Azure.AI.Agents.ListSortOrder", + "azure.ai.agents.models.MessageStatus": "Azure.AI.Agents.MessageStatus", + "azure.ai.agents.models.MessageIncompleteDetailsReason": "Azure.AI.Agents.MessageIncompleteDetailsReason", + "azure.ai.agents.models.RunStatus": "Azure.AI.Agents.RunStatus", + "azure.ai.agents.models.MouseButton": "Azure.AI.Agents.MouseButton", + "azure.ai.agents.models.IncompleteDetailsReason": "Azure.AI.Agents.IncompleteDetailsReason", + "azure.ai.agents.models.TruncationStrategy": "Azure.AI.Agents.TruncationStrategy", + "azure.ai.agents.models.AgentsToolChoiceOptionMode": "Azure.AI.Agents.AgentsToolChoiceOptionMode", + "azure.ai.agents.models.AgentsNamedToolChoiceType": "Azure.AI.Agents.AgentsNamedToolChoiceType", + "azure.ai.agents.models.AgentsResponseFormatMode": "Azure.AI.Agents.AgentsResponseFormatMode", + "azure.ai.agents.models.ResponseFormat": "Azure.AI.Agents.ResponseFormat", + "azure.ai.agents.models.RunAdditionalFieldList": "Azure.AI.Agents.RunAdditionalFieldList", + "azure.ai.agents.models.RunStepType": "Azure.AI.Agents.RunStepType", + "azure.ai.agents.models.RunStepStatus": "Azure.AI.Agents.RunStepStatus", + "azure.ai.agents.models.RunStepErrorCode": "Azure.AI.Agents.RunStepErrorCode", + "azure.ai.agents.models.FilePurpose": "Azure.AI.Agents.FilePurpose", + "azure.ai.agents.models.FileState": "Azure.AI.Agents.FileState", + "azure.ai.agents.models.VectorStoreStatus": "Azure.AI.Agents.VectorStoreStatus", + "azure.ai.agents.models.VectorStoreExpirationPolicyAnchor": "Azure.AI.Agents.VectorStoreExpirationPolicyAnchor", + "azure.ai.agents.models.VectorStoreChunkingStrategyRequestType": "Azure.AI.Agents.VectorStoreChunkingStrategyRequestType", + "azure.ai.agents.models.VectorStoreFileStatus": "Azure.AI.Agents.VectorStoreFileStatus", + "azure.ai.agents.models.VectorStoreFileErrorCode": "Azure.AI.Agents.VectorStoreFileErrorCode", + "azure.ai.agents.models.VectorStoreChunkingStrategyResponseType": "Azure.AI.Agents.VectorStoreChunkingStrategyResponseType", + "azure.ai.agents.models.VectorStoreFileStatusFilter": "Azure.AI.Agents.VectorStoreFileStatusFilter", + "azure.ai.agents.models.VectorStoreFileBatchStatus": "Azure.AI.Agents.VectorStoreFileBatchStatus", + "azure.ai.agents.models.ThreadStreamEvent": "Azure.AI.Agents.ThreadStreamEvent", + "azure.ai.agents.models.RunStreamEvent": "Azure.AI.Agents.RunStreamEvent", + "azure.ai.agents.models.RunStepStreamEvent": "Azure.AI.Agents.RunStepStreamEvent", + "azure.ai.agents.models.MessageStreamEvent": "Azure.AI.Agents.MessageStreamEvent", + "azure.ai.agents.models.ErrorEvent": "Azure.AI.Agents.ErrorEvent", + "azure.ai.agents.models.DoneEvent": "Azure.AI.Agents.DoneEvent", + "azure.ai.agents.models.AgentStreamEvent": "Azure.AI.Agents.AgentStreamEvent", + "azure.ai.agents.operations.ThreadsOperations.create": "Azure.AI.Agents.Threads.createThread", + "azure.ai.agents.aio.operations.ThreadsOperations.create": "Azure.AI.Agents.Threads.createThread", + "azure.ai.agents.operations.ThreadsOperations.list": "Azure.AI.Agents.Threads.listThreads", + "azure.ai.agents.aio.operations.ThreadsOperations.list": "Azure.AI.Agents.Threads.listThreads", + "azure.ai.agents.operations.ThreadsOperations.get": "Azure.AI.Agents.Threads.getThread", + "azure.ai.agents.aio.operations.ThreadsOperations.get": "Azure.AI.Agents.Threads.getThread", + "azure.ai.agents.operations.ThreadsOperations.update": "Azure.AI.Agents.Threads.updateThread", + "azure.ai.agents.aio.operations.ThreadsOperations.update": "Azure.AI.Agents.Threads.updateThread", + "azure.ai.agents.operations.MessagesOperations.create": "Azure.AI.Agents.Messages.createMessage", + "azure.ai.agents.aio.operations.MessagesOperations.create": "Azure.AI.Agents.Messages.createMessage", + "azure.ai.agents.operations.MessagesOperations.list": "Azure.AI.Agents.Messages.listMessages", + "azure.ai.agents.aio.operations.MessagesOperations.list": "Azure.AI.Agents.Messages.listMessages", + "azure.ai.agents.operations.MessagesOperations.get": "Azure.AI.Agents.Messages.getMessage", + "azure.ai.agents.aio.operations.MessagesOperations.get": "Azure.AI.Agents.Messages.getMessage", + "azure.ai.agents.operations.MessagesOperations.update": "Azure.AI.Agents.Messages.updateMessage", + "azure.ai.agents.aio.operations.MessagesOperations.update": "Azure.AI.Agents.Messages.updateMessage", + "azure.ai.agents.operations.RunsOperations.create": "Azure.AI.Agents.Runs.createRun", + "azure.ai.agents.aio.operations.RunsOperations.create": "Azure.AI.Agents.Runs.createRun", + "azure.ai.agents.operations.RunsOperations.list": "Azure.AI.Agents.Runs.listRuns", + "azure.ai.agents.aio.operations.RunsOperations.list": "Azure.AI.Agents.Runs.listRuns", + "azure.ai.agents.operations.RunsOperations.get": "Azure.AI.Agents.Runs.getRun", + "azure.ai.agents.aio.operations.RunsOperations.get": "Azure.AI.Agents.Runs.getRun", + "azure.ai.agents.operations.RunsOperations.update": "Azure.AI.Agents.Runs.updateRun", + "azure.ai.agents.aio.operations.RunsOperations.update": "Azure.AI.Agents.Runs.updateRun", + "azure.ai.agents.operations.RunsOperations.submit_tool_outputs": "Azure.AI.Agents.Runs.submitToolOutputsToRun", + "azure.ai.agents.aio.operations.RunsOperations.submit_tool_outputs": "Azure.AI.Agents.Runs.submitToolOutputsToRun", + "azure.ai.agents.operations.RunsOperations.cancel": "Azure.AI.Agents.Runs.cancelRun", + "azure.ai.agents.aio.operations.RunsOperations.cancel": "Azure.AI.Agents.Runs.cancelRun", + "azure.ai.agents.operations.RunStepsOperations.get": "Azure.AI.Agents.RunSteps.getRunStep", + "azure.ai.agents.aio.operations.RunStepsOperations.get": "Azure.AI.Agents.RunSteps.getRunStep", + "azure.ai.agents.operations.RunStepsOperations.list": "Azure.AI.Agents.RunSteps.listRunSteps", + "azure.ai.agents.aio.operations.RunStepsOperations.list": "Azure.AI.Agents.RunSteps.listRunSteps", + "azure.ai.agents.operations.FilesOperations.list": "Azure.AI.Agents.Files.listFiles", + "azure.ai.agents.aio.operations.FilesOperations.list": "Azure.AI.Agents.Files.listFiles", + "azure.ai.agents.operations.FilesOperations.get": "Azure.AI.Agents.Files.getFile", + "azure.ai.agents.aio.operations.FilesOperations.get": "Azure.AI.Agents.Files.getFile", + "azure.ai.agents.operations.VectorStoresOperations.list": "Azure.AI.Agents.VectorStores.listVectorStores", + "azure.ai.agents.aio.operations.VectorStoresOperations.list": "Azure.AI.Agents.VectorStores.listVectorStores", + "azure.ai.agents.operations.VectorStoresOperations.create": "Azure.AI.Agents.VectorStores.createVectorStore", + "azure.ai.agents.aio.operations.VectorStoresOperations.create": "Azure.AI.Agents.VectorStores.createVectorStore", + "azure.ai.agents.operations.VectorStoresOperations.get": "Azure.AI.Agents.VectorStores.getVectorStore", + "azure.ai.agents.aio.operations.VectorStoresOperations.get": "Azure.AI.Agents.VectorStores.getVectorStore", + "azure.ai.agents.operations.VectorStoresOperations.modify": "Azure.AI.Agents.VectorStores.modifyVectorStore", + "azure.ai.agents.aio.operations.VectorStoresOperations.modify": "Azure.AI.Agents.VectorStores.modifyVectorStore", + "azure.ai.agents.operations.VectorStoreFilesOperations.list": "Azure.AI.Agents.VectorStoreFiles.listVectorStoreFiles", + "azure.ai.agents.aio.operations.VectorStoreFilesOperations.list": "Azure.AI.Agents.VectorStoreFiles.listVectorStoreFiles", + "azure.ai.agents.operations.VectorStoreFilesOperations.create": "Azure.AI.Agents.VectorStoreFiles.createVectorStoreFile", + "azure.ai.agents.aio.operations.VectorStoreFilesOperations.create": "Azure.AI.Agents.VectorStoreFiles.createVectorStoreFile", + "azure.ai.agents.operations.VectorStoreFilesOperations.get": "Azure.AI.Agents.VectorStoreFiles.getVectorStoreFile", + "azure.ai.agents.aio.operations.VectorStoreFilesOperations.get": "Azure.AI.Agents.VectorStoreFiles.getVectorStoreFile", + "azure.ai.agents.operations.VectorStoreFileBatchesOperations.create": "Azure.AI.Agents.VectorStoreFileBatches.createVectorStoreFileBatch", + "azure.ai.agents.aio.operations.VectorStoreFileBatchesOperations.create": "Azure.AI.Agents.VectorStoreFileBatches.createVectorStoreFileBatch", + "azure.ai.agents.operations.VectorStoreFileBatchesOperations.get": "Azure.AI.Agents.VectorStoreFileBatches.getVectorStoreFileBatch", + "azure.ai.agents.aio.operations.VectorStoreFileBatchesOperations.get": "Azure.AI.Agents.VectorStoreFileBatches.getVectorStoreFileBatch", + "azure.ai.agents.operations.VectorStoreFileBatchesOperations.cancel": "Azure.AI.Agents.VectorStoreFileBatches.cancelVectorStoreFileBatch", + "azure.ai.agents.aio.operations.VectorStoreFileBatchesOperations.cancel": "Azure.AI.Agents.VectorStoreFileBatches.cancelVectorStoreFileBatch", + "azure.ai.agents.operations.VectorStoreFileBatchesOperations.list_files": "Azure.AI.Agents.VectorStoreFileBatches.listVectorStoreFileBatchFiles", + "azure.ai.agents.aio.operations.VectorStoreFileBatchesOperations.list_files": "Azure.AI.Agents.VectorStoreFileBatches.listVectorStoreFileBatchFiles", + "azure.ai.agents.AgentsClient.create_agent": "Azure.AI.Agents.createAgent", + "azure.ai.agents.aio.AgentsClient.create_agent": "Azure.AI.Agents.createAgent", + "azure.ai.agents.AgentsClient.list_agents": "Azure.AI.Agents.listAgents", + "azure.ai.agents.aio.AgentsClient.list_agents": "Azure.AI.Agents.listAgents", + "azure.ai.agents.AgentsClient.get_agent": "Azure.AI.Agents.getAgent", + "azure.ai.agents.aio.AgentsClient.get_agent": "Azure.AI.Agents.getAgent", + "azure.ai.agents.AgentsClient.update_agent": "Azure.AI.Agents.updateAgent", + "azure.ai.agents.aio.AgentsClient.update_agent": "Azure.AI.Agents.updateAgent", + "azure.ai.agents.AgentsClient.create_thread_and_run": "Azure.AI.Agents.createThreadAndRun", + "azure.ai.agents.aio.AgentsClient.create_thread_and_run": "Azure.AI.Agents.createThreadAndRun" + } } \ No newline at end of file diff --git a/sdk/ai/azure-ai-agents/azure/ai/agents/__init__.py b/sdk/ai/azure-ai-agents/azure/ai/agents/__init__.py index 36b145c29e94..1be1a824dda7 100644 --- a/sdk/ai/azure-ai-agents/azure/ai/agents/__init__.py +++ b/sdk/ai/azure-ai-agents/azure/ai/agents/__init__.py @@ -12,8 +12,7 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._client import AIProjectClient # type: ignore -from . import types # type: ignore +from ._client import AgentsClient # type: ignore from ._version import VERSION __version__ = VERSION @@ -26,7 +25,7 @@ from ._patch import patch_sdk as _patch_sdk __all__ = [ - "AIProjectClient", + "AgentsClient", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore diff --git a/sdk/ai/azure-ai-agents/azure/ai/agents/_client.py b/sdk/ai/azure-ai-agents/azure/ai/agents/_client.py index 481e5bb5812f..487de2156cf1 100644 --- a/sdk/ai/azure-ai-agents/azure/ai/agents/_client.py +++ b/sdk/ai/azure-ai-agents/azure/ai/agents/_client.py @@ -7,76 +7,64 @@ # -------------------------------------------------------------------------- from copy import deepcopy -import sys -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING +from typing_extensions import Self from azure.core import PipelineClient from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse -from ._configuration import AIProjectClientConfiguration +from ._configuration import AgentsClientConfiguration from ._utils.serialization import Deserializer, Serializer from .operations import ( - AgentsOperations, - BetaOperations, - ConnectionsOperations, - DatasetsOperations, - DeploymentsOperations, - EvaluationRulesOperations, - IndexesOperations, - _AIProjectClientOperationsMixin, + FilesOperations, + MessagesOperations, + RunStepsOperations, + RunsOperations, + ThreadsOperations, + VectorStoreFileBatchesOperations, + VectorStoreFilesOperations, + VectorStoresOperations, + _AgentsClientOperationsMixin, ) -if sys.version_info >= (3, 11): - from typing import Self -else: - from typing_extensions import Self # type: ignore - if TYPE_CHECKING: from azure.core.credentials import TokenCredential -class AIProjectClient(_AIProjectClientOperationsMixin): # pylint: disable=too-many-instance-attributes - """AIProjectClient. - - :ivar beta: BetaOperations operations - :vartype beta: azure.ai.agents.operations.BetaOperations - :ivar agents: AgentsOperations operations - :vartype agents: azure.ai.agents.operations.AgentsOperations - :ivar evaluation_rules: EvaluationRulesOperations operations - :vartype evaluation_rules: azure.ai.agents.operations.EvaluationRulesOperations - :ivar connections: ConnectionsOperations operations - :vartype connections: azure.ai.agents.operations.ConnectionsOperations - :ivar datasets: DatasetsOperations operations - :vartype datasets: azure.ai.agents.operations.DatasetsOperations - :ivar deployments: DeploymentsOperations operations - :vartype deployments: azure.ai.agents.operations.DeploymentsOperations - :ivar indexes: IndexesOperations operations - :vartype indexes: azure.ai.agents.operations.IndexesOperations - :param endpoint: Foundry Project endpoint in the form - "https://{ai-services-account-name}.services.ai.azure.com/api/projects/{project-name}". If you - only have one Project in your Foundry Hub, or to target the default Project in your Hub, use - the form "https://{ai-services-account-name}.services.ai.azure.com/api/projects/_project". - Required. +class AgentsClient(_AgentsClientOperationsMixin): # pylint: disable=too-many-instance-attributes + """AgentsClient. + + :ivar threads: ThreadsOperations operations + :vartype threads: azure.ai.agents.operations.ThreadsOperations + :ivar messages: MessagesOperations operations + :vartype messages: azure.ai.agents.operations.MessagesOperations + :ivar runs: RunsOperations operations + :vartype runs: azure.ai.agents.operations.RunsOperations + :ivar run_steps: RunStepsOperations operations + :vartype run_steps: azure.ai.agents.operations.RunStepsOperations + :ivar files: FilesOperations operations + :vartype files: azure.ai.agents.operations.FilesOperations + :ivar vector_stores: VectorStoresOperations operations + :vartype vector_stores: azure.ai.agents.operations.VectorStoresOperations + :ivar vector_store_files: VectorStoreFilesOperations operations + :vartype vector_store_files: azure.ai.agents.operations.VectorStoreFilesOperations + :ivar vector_store_file_batches: VectorStoreFileBatchesOperations operations + :vartype vector_store_file_batches: azure.ai.agents.operations.VectorStoreFileBatchesOperations + :param endpoint: Project endpoint in the form of: + https://.services.ai.azure.com/api/projects/. Required. :type endpoint: str :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials.TokenCredential - :param allow_preview: Whether to enable preview features. Must be specified and set to True to - enable preview features. Default value is None. - :type allow_preview: bool - :keyword api_version: The API version to use for this operation. Known values are "v1" and - None. Default value is None. If not set, the operation's default API version will be used. Note - that overriding this default value may result in unsupported behavior. + :keyword api_version: The API version to use for this operation. Default value is + "2025-05-15-preview". Note that overriding this default value may result in unsupported + behavior. :paramtype api_version: str """ - def __init__( - self, endpoint: str, credential: "TokenCredential", allow_preview: Optional[bool] = None, **kwargs: Any - ) -> None: + def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None: _endpoint = "{endpoint}" - self._config = AIProjectClientConfiguration( - endpoint=endpoint, credential=credential, allow_preview=allow_preview, **kwargs - ) + self._config = AgentsClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) _policies = kwargs.pop("policies", None) if _policies is None: @@ -100,15 +88,18 @@ def __init__( self._serialize = Serializer() self._deserialize = Deserializer() self._serialize.client_side_validation = False - self.beta = BetaOperations(self._client, self._config, self._serialize, self._deserialize) - self.agents = AgentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.evaluation_rules = EvaluationRulesOperations( + self.threads = ThreadsOperations(self._client, self._config, self._serialize, self._deserialize) + self.messages = MessagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.runs = RunsOperations(self._client, self._config, self._serialize, self._deserialize) + self.run_steps = RunStepsOperations(self._client, self._config, self._serialize, self._deserialize) + self.files = FilesOperations(self._client, self._config, self._serialize, self._deserialize) + self.vector_stores = VectorStoresOperations(self._client, self._config, self._serialize, self._deserialize) + self.vector_store_files = VectorStoreFilesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.vector_store_file_batches = VectorStoreFileBatchesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.connections = ConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.datasets = DatasetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.indexes = IndexesOperations(self._client, self._config, self._serialize, self._deserialize) def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/ai/azure-ai-agents/azure/ai/agents/_configuration.py b/sdk/ai/azure-ai-agents/azure/ai/agents/_configuration.py index 7f07e99af21f..2df2bf2aeb78 100644 --- a/sdk/ai/azure-ai-agents/azure/ai/agents/_configuration.py +++ b/sdk/ai/azure-ai-agents/azure/ai/agents/_configuration.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.pipeline import policies @@ -16,33 +16,25 @@ from azure.core.credentials import TokenCredential -class AIProjectClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for AIProjectClient. +class AgentsClientConfiguration: # pylint: disable=too-many-instance-attributes + """Configuration for AgentsClient. Note that all parameters used to create this instance are saved as instance attributes. - :param endpoint: Foundry Project endpoint in the form - "https://{ai-services-account-name}.services.ai.azure.com/api/projects/{project-name}". If you - only have one Project in your Foundry Hub, or to target the default Project in your Hub, use - the form "https://{ai-services-account-name}.services.ai.azure.com/api/projects/_project". - Required. + :param endpoint: Project endpoint in the form of: + https://.services.ai.azure.com/api/projects/. Required. :type endpoint: str :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials.TokenCredential - :param allow_preview: Whether to enable preview features. Must be specified and set to True to - enable preview features. Default value is None. - :type allow_preview: bool - :keyword api_version: The API version to use for this operation. Known values are "v1" and - None. Default value is None. If not set, the operation's default API version will be used. Note - that overriding this default value may result in unsupported behavior. + :keyword api_version: The API version to use for this operation. Default value is + "2025-05-15-preview". Note that overriding this default value may result in unsupported + behavior. :paramtype api_version: str """ - def __init__( - self, endpoint: str, credential: "TokenCredential", allow_preview: Optional[bool] = None, **kwargs: Any - ) -> None: - api_version: str = kwargs.pop("api_version", "v1") + def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None: + api_version: str = kwargs.pop("api_version", "2025-05-15-preview") if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") @@ -51,7 +43,6 @@ def __init__( self.endpoint = endpoint self.credential = credential - self.allow_preview = allow_preview self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://ai.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "ai-agents/{}".format(VERSION)) diff --git a/sdk/ai/azure-ai-agents/azure/ai/agents/_utils/model_base.py b/sdk/ai/azure-ai-agents/azure/ai/agents/_utils/model_base.py index 4acca0207287..7ec44978519b 100644 --- a/sdk/ai/azure-ai-agents/azure/ai/agents/_utils/model_base.py +++ b/sdk/ai/azure-ai-agents/azure/ai/agents/_utils/model_base.py @@ -1,4 +1,3 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -817,22 +816,16 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-retur # is it optional? try: - if any( - a for a in annotation.__args__ if a == type(None) - ): # pyright: ignore # pylint: disable=unidiomatic-typecheck + if any(a for a in annotation.__args__ if a == type(None)): # pyright: ignore # pylint: disable=unidiomatic-typecheck if len(annotation.__args__) <= 2: # pyright: ignore if_obj_deserializer = _get_deserialize_callable_from_annotation( - next(a for a in annotation.__args__ if a != type(None)), - module, - rf, # pyright: ignore # pylint: disable=unidiomatic-typecheck + next(a for a in annotation.__args__ if a != type(None)), module, rf # pyright: ignore # pylint: disable=unidiomatic-typecheck ) return functools.partial(_deserialize_with_optional, if_obj_deserializer) # the type is Optional[Union[...]], we need to remove the None type from the Union annotation_copy = copy.copy(annotation) - annotation_copy.__args__ = [ - a for a in annotation_copy.__args__ if a != type(None) - ] # pyright: ignore # pylint: disable=unidiomatic-typecheck + annotation_copy.__args__ = [a for a in annotation_copy.__args__ if a != type(None)] # pyright: ignore # pylint: disable=unidiomatic-typecheck return _get_deserialize_callable_from_annotation(annotation_copy, module, rf) except AttributeError: pass diff --git a/sdk/ai/azure-ai-agents/azure/ai/agents/_utils/serialization.py b/sdk/ai/azure-ai-agents/azure/ai/agents/_utils/serialization.py index a088671e9c51..45a3e44e45cb 100644 --- a/sdk/ai/azure-ai-agents/azure/ai/agents/_utils/serialization.py +++ b/sdk/ai/azure-ai-agents/azure/ai/agents/_utils/serialization.py @@ -39,15 +39,11 @@ import xml.etree.ElementTree as ET import isodate # type: ignore +from typing_extensions import Self from azure.core.exceptions import DeserializationError, SerializationError from azure.core.serialization import NULL as CoreNull -if sys.version_info >= (3, 11): - from typing import Self -else: - from typing_extensions import Self - _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") JSON = MutableMapping[str, Any] @@ -825,20 +821,13 @@ def serialize_basic(cls, data, data_type, **kwargs): :param str data_type: Type of object in the iterable. :rtype: str, int, float, bool :return: serialized object - :raises TypeError: raise if data_type is not one of str, int, float, bool. """ custom_serializer = cls._get_custom_serializers(data_type, **kwargs) if custom_serializer: return custom_serializer(data) if data_type == "str": return cls.serialize_unicode(data) - if data_type == "int": - return int(data) - if data_type == "float": - return float(data) - if data_type == "bool": - return bool(data) - raise TypeError("Unknown basic data type: {}".format(data_type)) + return eval(data_type)(data) # nosec # pylint: disable=eval-used @classmethod def serialize_unicode(cls, data): @@ -1405,7 +1394,7 @@ def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: # Otherwise, result are unexpected self.additional_properties_detection = True - def __call__(self, target_obj, response_data, content_type=None): # pylint: disable=too-many-return-statements + def __call__(self, target_obj, response_data, content_type=None): """Call the deserializer to process a REST response. :param str target_obj: Target data type to deserialize to. @@ -1415,27 +1404,6 @@ def __call__(self, target_obj, response_data, content_type=None): # pylint: dis :return: Deserialized object. :rtype: object """ - # Fast path for header deserialization: response_data is a plain str or None - # and target_obj is a simple scalar type. This avoids the expensive - # _unpack_content → _deserialize → _classify_target → deserialize_data chain. - if response_data is None: - return None - if target_obj == "str" and isinstance(response_data, str): - return response_data - if isinstance(response_data, str): - if target_obj == "int": - return int(response_data) - if target_obj == "bool": - if response_data in ("true", "1", "True"): - return True - if response_data in ("false", "0", "False"): - return False - return bool(response_data) - if target_obj == "rfc-1123": - return Deserializer.deserialize_rfc(response_data) - if target_obj == "bytearray": - return Deserializer.deserialize_bytearray(response_data) - data = self._unpack_content(response_data, content_type) return self._deserialize(target_obj, data) @@ -1789,7 +1757,7 @@ def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return :param str data_type: deserialization data type. :return: Deserialized basic type. :rtype: str, int, float or bool - :raises TypeError: if string format is not valid or data_type is not one of str, int, float, bool. + :raises TypeError: if string format is not valid. """ # If we're here, data is supposed to be a basic type. # If it's still an XML node, take the text @@ -1815,11 +1783,7 @@ def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return if data_type == "str": return self.deserialize_unicode(attr) - if data_type == "int": - return int(attr) - if data_type == "float": - return float(attr) - raise TypeError("Unknown basic data type: {}".format(data_type)) + return eval(data_type)(attr) # nosec # pylint: disable=eval-used @staticmethod def deserialize_unicode(data): diff --git a/sdk/ai/azure-ai-agents/azure/ai/agents/_utils/utils.py b/sdk/ai/azure-ai-agents/azure/ai/agents/_utils/utils.py index 35c9c836f85f..4c029bd3dfa5 100644 --- a/sdk/ai/azure-ai-agents/azure/ai/agents/_utils/utils.py +++ b/sdk/ai/azure-ai-agents/azure/ai/agents/_utils/utils.py @@ -6,7 +6,10 @@ # -------------------------------------------------------------------------- from abc import ABC -from typing import Generic, TYPE_CHECKING, TypeVar +import json +from typing import Any, Generic, IO, Mapping, Optional, TYPE_CHECKING, TypeVar, Union + +from .._utils.model_base import Model, SdkJSONEncoder if TYPE_CHECKING: from .serialization import Deserializer, Serializer @@ -23,3 +26,42 @@ class ClientMixinABC(ABC, Generic[TClient, TConfig]): _config: TConfig _serialize: "Serializer" _deserialize: "Deserializer" + + +# file-like tuple could be `(filename, IO (or bytes))` or `(filename, IO (or bytes), content_type)` +FileContent = Union[str, bytes, IO[str], IO[bytes]] + +FileType = Union[ + # file (or bytes) + FileContent, + # (filename, file (or bytes)) + tuple[Optional[str], FileContent], + # (filename, file (or bytes), content_type) + tuple[Optional[str], FileContent, Optional[str]], +] + + +def serialize_multipart_data_entry(data_entry: Any) -> Any: + if isinstance(data_entry, (list, tuple, dict, Model)): + return json.dumps(data_entry, cls=SdkJSONEncoder, exclude_readonly=True) + return data_entry + + +def prepare_multipart_form_data( + body: Mapping[str, Any], multipart_fields: list[str], data_fields: list[str] +) -> tuple[list[FileType], dict[str, Any]]: + files: list[FileType] = [] + data: dict[str, Any] = {} + for multipart_field in multipart_fields: + multipart_entry = body.get(multipart_field) + if isinstance(multipart_entry, list): + files.extend([(multipart_field, e) for e in multipart_entry]) + elif multipart_entry: + files.append((multipart_field, multipart_entry)) + + for data_field in data_fields: + data_entry = body.get(data_field) + if data_entry: + data[data_field] = serialize_multipart_data_entry(data_entry) + + return files, data diff --git a/sdk/ai/azure-ai-agents/azure/ai/agents/aio/__init__.py b/sdk/ai/azure-ai-agents/azure/ai/agents/aio/__init__.py index d138e250b1bc..65a7176b2fbb 100644 --- a/sdk/ai/azure-ai-agents/azure/ai/agents/aio/__init__.py +++ b/sdk/ai/azure-ai-agents/azure/ai/agents/aio/__init__.py @@ -12,8 +12,7 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._client import AIProjectClient # type: ignore -from . import types # type: ignore +from ._client import AgentsClient # type: ignore try: from ._patch import __all__ as _patch_all @@ -23,7 +22,7 @@ from ._patch import patch_sdk as _patch_sdk __all__ = [ - "AIProjectClient", + "AgentsClient", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore diff --git a/sdk/ai/azure-ai-agents/azure/ai/agents/aio/_client.py b/sdk/ai/azure-ai-agents/azure/ai/agents/aio/_client.py index 4b39c6e3c110..64180964eb5b 100644 --- a/sdk/ai/azure-ai-agents/azure/ai/agents/aio/_client.py +++ b/sdk/ai/azure-ai-agents/azure/ai/agents/aio/_client.py @@ -7,76 +7,65 @@ # -------------------------------------------------------------------------- from copy import deepcopy -import sys -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self from azure.core import AsyncPipelineClient from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from .._utils.serialization import Deserializer, Serializer -from ._configuration import AIProjectClientConfiguration +from ._configuration import AgentsClientConfiguration from .operations import ( - AgentsOperations, - BetaOperations, - ConnectionsOperations, - DatasetsOperations, - DeploymentsOperations, - EvaluationRulesOperations, - IndexesOperations, - _AIProjectClientOperationsMixin, + FilesOperations, + MessagesOperations, + RunStepsOperations, + RunsOperations, + ThreadsOperations, + VectorStoreFileBatchesOperations, + VectorStoreFilesOperations, + VectorStoresOperations, + _AgentsClientOperationsMixin, ) -if sys.version_info >= (3, 11): - from typing import Self -else: - from typing_extensions import Self # type: ignore - if TYPE_CHECKING: from azure.core.credentials_async import AsyncTokenCredential -class AIProjectClient(_AIProjectClientOperationsMixin): # pylint: disable=too-many-instance-attributes - """AIProjectClient. - - :ivar beta: BetaOperations operations - :vartype beta: azure.ai.agents.aio.operations.BetaOperations - :ivar agents: AgentsOperations operations - :vartype agents: azure.ai.agents.aio.operations.AgentsOperations - :ivar evaluation_rules: EvaluationRulesOperations operations - :vartype evaluation_rules: azure.ai.agents.aio.operations.EvaluationRulesOperations - :ivar connections: ConnectionsOperations operations - :vartype connections: azure.ai.agents.aio.operations.ConnectionsOperations - :ivar datasets: DatasetsOperations operations - :vartype datasets: azure.ai.agents.aio.operations.DatasetsOperations - :ivar deployments: DeploymentsOperations operations - :vartype deployments: azure.ai.agents.aio.operations.DeploymentsOperations - :ivar indexes: IndexesOperations operations - :vartype indexes: azure.ai.agents.aio.operations.IndexesOperations - :param endpoint: Foundry Project endpoint in the form - "https://{ai-services-account-name}.services.ai.azure.com/api/projects/{project-name}". If you - only have one Project in your Foundry Hub, or to target the default Project in your Hub, use - the form "https://{ai-services-account-name}.services.ai.azure.com/api/projects/_project". - Required. +class AgentsClient(_AgentsClientOperationsMixin): # pylint: disable=too-many-instance-attributes + """AgentsClient. + + :ivar threads: ThreadsOperations operations + :vartype threads: azure.ai.agents.aio.operations.ThreadsOperations + :ivar messages: MessagesOperations operations + :vartype messages: azure.ai.agents.aio.operations.MessagesOperations + :ivar runs: RunsOperations operations + :vartype runs: azure.ai.agents.aio.operations.RunsOperations + :ivar run_steps: RunStepsOperations operations + :vartype run_steps: azure.ai.agents.aio.operations.RunStepsOperations + :ivar files: FilesOperations operations + :vartype files: azure.ai.agents.aio.operations.FilesOperations + :ivar vector_stores: VectorStoresOperations operations + :vartype vector_stores: azure.ai.agents.aio.operations.VectorStoresOperations + :ivar vector_store_files: VectorStoreFilesOperations operations + :vartype vector_store_files: azure.ai.agents.aio.operations.VectorStoreFilesOperations + :ivar vector_store_file_batches: VectorStoreFileBatchesOperations operations + :vartype vector_store_file_batches: + azure.ai.agents.aio.operations.VectorStoreFileBatchesOperations + :param endpoint: Project endpoint in the form of: + https://.services.ai.azure.com/api/projects/. Required. :type endpoint: str :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param allow_preview: Whether to enable preview features. Must be specified and set to True to - enable preview features. Default value is None. - :type allow_preview: bool - :keyword api_version: The API version to use for this operation. Known values are "v1" and - None. Default value is None. If not set, the operation's default API version will be used. Note - that overriding this default value may result in unsupported behavior. + :keyword api_version: The API version to use for this operation. Default value is + "2025-05-15-preview". Note that overriding this default value may result in unsupported + behavior. :paramtype api_version: str """ - def __init__( - self, endpoint: str, credential: "AsyncTokenCredential", allow_preview: Optional[bool] = None, **kwargs: Any - ) -> None: + def __init__(self, endpoint: str, credential: "AsyncTokenCredential", **kwargs: Any) -> None: _endpoint = "{endpoint}" - self._config = AIProjectClientConfiguration( - endpoint=endpoint, credential=credential, allow_preview=allow_preview, **kwargs - ) + self._config = AgentsClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) _policies = kwargs.pop("policies", None) if _policies is None: @@ -100,15 +89,18 @@ def __init__( self._serialize = Serializer() self._deserialize = Deserializer() self._serialize.client_side_validation = False - self.beta = BetaOperations(self._client, self._config, self._serialize, self._deserialize) - self.agents = AgentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.evaluation_rules = EvaluationRulesOperations( + self.threads = ThreadsOperations(self._client, self._config, self._serialize, self._deserialize) + self.messages = MessagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.runs = RunsOperations(self._client, self._config, self._serialize, self._deserialize) + self.run_steps = RunStepsOperations(self._client, self._config, self._serialize, self._deserialize) + self.files = FilesOperations(self._client, self._config, self._serialize, self._deserialize) + self.vector_stores = VectorStoresOperations(self._client, self._config, self._serialize, self._deserialize) + self.vector_store_files = VectorStoreFilesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.vector_store_file_batches = VectorStoreFileBatchesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.connections = ConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.datasets = DatasetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.indexes = IndexesOperations(self._client, self._config, self._serialize, self._deserialize) def send_request( self, request: HttpRequest, *, stream: bool = False, **kwargs: Any diff --git a/sdk/ai/azure-ai-agents/azure/ai/agents/aio/_configuration.py b/sdk/ai/azure-ai-agents/azure/ai/agents/aio/_configuration.py index efb1b7ba634d..fe400db8ca67 100644 --- a/sdk/ai/azure-ai-agents/azure/ai/agents/aio/_configuration.py +++ b/sdk/ai/azure-ai-agents/azure/ai/agents/aio/_configuration.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.pipeline import policies @@ -16,33 +16,25 @@ from azure.core.credentials_async import AsyncTokenCredential -class AIProjectClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for AIProjectClient. +class AgentsClientConfiguration: # pylint: disable=too-many-instance-attributes + """Configuration for AgentsClient. Note that all parameters used to create this instance are saved as instance attributes. - :param endpoint: Foundry Project endpoint in the form - "https://{ai-services-account-name}.services.ai.azure.com/api/projects/{project-name}". If you - only have one Project in your Foundry Hub, or to target the default Project in your Hub, use - the form "https://{ai-services-account-name}.services.ai.azure.com/api/projects/_project". - Required. + :param endpoint: Project endpoint in the form of: + https://.services.ai.azure.com/api/projects/. Required. :type endpoint: str :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param allow_preview: Whether to enable preview features. Must be specified and set to True to - enable preview features. Default value is None. - :type allow_preview: bool - :keyword api_version: The API version to use for this operation. Known values are "v1" and - None. Default value is None. If not set, the operation's default API version will be used. Note - that overriding this default value may result in unsupported behavior. + :keyword api_version: The API version to use for this operation. Default value is + "2025-05-15-preview". Note that overriding this default value may result in unsupported + behavior. :paramtype api_version: str """ - def __init__( - self, endpoint: str, credential: "AsyncTokenCredential", allow_preview: Optional[bool] = None, **kwargs: Any - ) -> None: - api_version: str = kwargs.pop("api_version", "v1") + def __init__(self, endpoint: str, credential: "AsyncTokenCredential", **kwargs: Any) -> None: + api_version: str = kwargs.pop("api_version", "2025-05-15-preview") if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") @@ -51,7 +43,6 @@ def __init__( self.endpoint = endpoint self.credential = credential - self.allow_preview = allow_preview self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://ai.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "ai-agents/{}".format(VERSION)) diff --git a/sdk/ai/azure-ai-agents/azure/ai/agents/aio/operations/__init__.py b/sdk/ai/azure-ai-agents/azure/ai/agents/aio/operations/__init__.py index ac09c02d32cd..a3f2341966aa 100644 --- a/sdk/ai/azure-ai-agents/azure/ai/agents/aio/operations/__init__.py +++ b/sdk/ai/azure-ai-agents/azure/ai/agents/aio/operations/__init__.py @@ -12,27 +12,29 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._operations import BetaOperations # type: ignore -from ._operations import AgentsOperations # type: ignore -from ._operations import EvaluationRulesOperations # type: ignore -from ._operations import ConnectionsOperations # type: ignore -from ._operations import DatasetsOperations # type: ignore -from ._operations import DeploymentsOperations # type: ignore -from ._operations import IndexesOperations # type: ignore -from ._operations import _AIProjectClientOperationsMixin # type: ignore # pylint: disable=unused-import +from ._operations import ThreadsOperations # type: ignore +from ._operations import MessagesOperations # type: ignore +from ._operations import RunsOperations # type: ignore +from ._operations import RunStepsOperations # type: ignore +from ._operations import FilesOperations # type: ignore +from ._operations import VectorStoresOperations # type: ignore +from ._operations import VectorStoreFilesOperations # type: ignore +from ._operations import VectorStoreFileBatchesOperations # type: ignore +from ._operations import _AgentsClientOperationsMixin # type: ignore # pylint: disable=unused-import from ._patch import __all__ as _patch_all from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ - "BetaOperations", - "AgentsOperations", - "EvaluationRulesOperations", - "ConnectionsOperations", - "DatasetsOperations", - "DeploymentsOperations", - "IndexesOperations", + "ThreadsOperations", + "MessagesOperations", + "RunsOperations", + "RunStepsOperations", + "FilesOperations", + "VectorStoresOperations", + "VectorStoreFilesOperations", + "VectorStoreFileBatchesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/ai/azure-ai-agents/azure/ai/agents/aio/operations/_operations.py b/sdk/ai/azure-ai-agents/azure/ai/agents/aio/operations/_operations.py index 8d7b168ab914..8151b09585e2 100644 --- a/sdk/ai/azure-ai-agents/azure/ai/agents/aio/operations/_operations.py +++ b/sdk/ai/azure-ai-agents/azure/ai/agents/aio/operations/_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,8 @@ # -------------------------------------------------------------------------- from collections.abc import MutableMapping from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Literal, Optional, TypeVar, Union, cast, overload +import json +from typing import Any, AsyncIterator, Callable, IO, Optional, TYPE_CHECKING, TypeVar, Union, overload import urllib.parse from azure.core import AsyncPipelineClient @@ -24,251 +24,183 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.polling.async_base_polling import AsyncLROBasePolling from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict -from ... import types, types as _types_models2 +from ... import models as _models +from ..._utils.model_base import Model as _Model, SdkJSONEncoder, _deserialize, _failsafe_deserialize from ..._utils.serialization import Deserializer, Serializer -from ..._utils.utils import ClientMixinABC -from ...models._enums import FoundryFeaturesOptInKeys +from ..._utils.utils import ClientMixinABC, prepare_multipart_form_data +from ..._validation import api_version_validation from ...operations._operations import ( - build_agents_create_agent_from_manifest_request, build_agents_create_agent_request, - build_agents_create_version_from_manifest_request, - build_agents_create_version_request, - build_agents_delete_request, - build_agents_delete_version_request, - build_agents_get_request, - build_agents_get_version_request, - build_agents_list_request, - build_agents_list_versions_request, - build_agents_update_agent_from_manifest_request, + build_agents_create_thread_and_run_request, + build_agents_delete_agent_request, + build_agents_get_agent_request, + build_agents_list_agents_request, build_agents_update_agent_request, - build_ai_project_delete_job_request, - build_beta_evaluation_taxonomies_create_request, - build_beta_evaluation_taxonomies_delete_request, - build_beta_evaluation_taxonomies_get_request, - build_beta_evaluation_taxonomies_list_request, - build_beta_evaluation_taxonomies_update_request, - build_beta_evaluators_create_version_request, - build_beta_evaluators_delete_version_request, - build_beta_evaluators_get_version_request, - build_beta_evaluators_list_request, - build_beta_evaluators_list_versions_request, - build_beta_evaluators_update_version_request, - build_beta_insights_generate_request, - build_beta_insights_get_request, - build_beta_insights_list_request, - build_beta_memory_stores_create_request, - build_beta_memory_stores_delete_request, - build_beta_memory_stores_delete_scope_request, - build_beta_memory_stores_get_request, - build_beta_memory_stores_list_request, - build_beta_memory_stores_search_memories_request, - build_beta_memory_stores_update_memories_request, - build_beta_memory_stores_update_request, - build_beta_red_teams_create_request, - build_beta_red_teams_get_request, - build_beta_red_teams_list_request, - build_beta_schedules_create_or_update_request, - build_beta_schedules_delete_request, - build_beta_schedules_get_request, - build_beta_schedules_get_run_request, - build_beta_schedules_list_request, - build_beta_schedules_list_runs_request, - build_connections_get_request, - build_connections_get_with_credentials_request, - build_connections_list_request, - build_datasets_create_or_update_request, - build_datasets_delete_request, - build_datasets_get_credentials_request, - build_datasets_get_request, - build_datasets_list_request, - build_datasets_list_versions_request, - build_datasets_pending_upload_request, - build_deployments_get_request, - build_deployments_list_request, - build_evaluation_rules_create_or_update_request, - build_evaluation_rules_delete_request, - build_evaluation_rules_get_request, - build_evaluation_rules_list_request, - build_indexes_create_or_update_request, - build_indexes_delete_request, - build_indexes_get_request, - build_indexes_list_request, - build_indexes_list_versions_request, + build_files_delete_file_request, + build_files_get_file_content_request, + build_files_get_request, + build_files_list_request, + build_files_upload_file_request, + build_messages_create_request, + build_messages_delete_request, + build_messages_get_request, + build_messages_list_request, + build_messages_update_request, + build_run_steps_get_request, + build_run_steps_list_request, + build_runs_cancel_request, + build_runs_create_request, + build_runs_get_request, + build_runs_list_request, + build_runs_submit_tool_outputs_request, + build_runs_update_request, + build_threads_create_request, + build_threads_delete_thread_request, + build_threads_get_request, + build_threads_list_request, + build_threads_update_request, + build_vector_store_file_batches_cancel_request, + build_vector_store_file_batches_create_request, + build_vector_store_file_batches_get_request, + build_vector_store_file_batches_list_files_request, + build_vector_store_files_create_request, + build_vector_store_files_delete_vector_store_file_request, + build_vector_store_files_get_request, + build_vector_store_files_list_request, + build_vector_stores_create_request, + build_vector_stores_delete_vector_store_request, + build_vector_stores_get_request, + build_vector_stores_list_request, + build_vector_stores_modify_request, ) -from .._configuration import AIProjectClientConfiguration +from .._configuration import AgentsClientConfiguration -_Unset: Any = object() +if TYPE_CHECKING: + from ... import _types JSON = MutableMapping[str, Any] +_Unset: Any = object() T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] List = list -class BetaOperations: +class ThreadsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.ai.agents.aio.AIProjectClient`'s - :attr:`beta` attribute. + :class:`~azure.ai.agents.aio.AgentsClient`'s + :attr:`threads` attribute. """ def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._config: AgentsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self.evaluation_taxonomies = BetaEvaluationTaxonomiesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.evaluators = BetaEvaluatorsOperations(self._client, self._config, self._serialize, self._deserialize) - self.insights = BetaInsightsOperations(self._client, self._config, self._serialize, self._deserialize) - self.memory_stores = BetaMemoryStoresOperations(self._client, self._config, self._serialize, self._deserialize) - self.red_teams = BetaRedTeamsOperations(self._client, self._config, self._serialize, self._deserialize) - self.schedules = BetaSchedulesOperations(self._client, self._config, self._serialize, self._deserialize) + @overload + async def create( + self, + *, + content_type: str = "application/json", + messages: Optional[List[_models.ThreadMessageOptions]] = None, + tool_resources: Optional[_models.ToolResources] = None, + metadata: Optional[dict[str, str]] = None, + **kwargs: Any + ) -> _models.AgentThread: + """Creates a new thread. Threads contain messages and can be run by agents. + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword messages: The initial messages to associate with the new thread. Default value is + None. + :paramtype messages: list[~azure.ai.agents.models.ThreadMessageOptions] + :keyword tool_resources: 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. Default value is None. + :paramtype tool_resources: ~azure.ai.agents.models.ToolResources + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: AgentThread. The AgentThread is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.AgentThread + :raises ~azure.core.exceptions.HttpResponseError: + """ -class AgentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. + @overload + async def create(self, body: JSON, *, content_type: str = "application/json", **kwargs: Any) -> _models.AgentThread: + """Creates a new thread. Threads contain messages and can be run by agents. - Instead, you should access the following operations through - :class:`~azure.ai.agents.aio.AIProjectClient`'s - :attr:`agents` attribute. - """ + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AgentThread. The AgentThread is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.AgentThread + :raises ~azure.core.exceptions.HttpResponseError: + """ - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @overload + async def create( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.AgentThread: + """Creates a new thread. Threads contain messages and can be run by agents. + + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: AgentThread. The AgentThread is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.AgentThread + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async - async def get(self, agent_name: str, **kwargs: Any) -> _types_models2.AgentDetails: - """Retrieves the agent. + async def create( + self, + body: Union[JSON, IO[bytes]] = _Unset, + *, + messages: Optional[List[_models.ThreadMessageOptions]] = None, + tool_resources: Optional[_models.ToolResources] = None, + metadata: Optional[dict[str, str]] = None, + **kwargs: Any + ) -> _models.AgentThread: + """Creates a new thread. Threads contain messages and can be run by agents. - :param agent_name: The name of the agent to retrieve. Required. - :type agent_name: str - :return: AgentDetails - :rtype: ~azure.ai.agents.types.AgentDetails + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword messages: The initial messages to associate with the new thread. Default value is + None. + :paramtype messages: list[~azure.ai.agents.models.ThreadMessageOptions] + :keyword tool_resources: 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. Default value is None. + :paramtype tool_resources: ~azure.ai.agents.models.ToolResources + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: AgentThread. The AgentThread is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.AgentThread :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "hosted": - agent_definition = { - "container_protocol_versions": [ - { - "protocol": "str", - "version": "str" - } - ], - "cpu": "str", - "kind": "hosted", - "memory": "str", - "environment_variables": { - "str": "str" - }, - "image": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "tools": [ - tool - ] - } - - # JSON input template for discriminator value "prompt": - agent_definition = { - "kind": "prompt", - "model": "str", - "instructions": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "reasoning": { - "effort": "none", - "generate_summary": "auto", - "summary": "auto" - }, - "structured_inputs": { - "str": { - "default_value": {}, - "description": "str", - "required": bool, - "schema": { - "str": {} - } - } - }, - "temperature": 0.0, - "text": { - "format": text_response_format - }, - "tool_choice": "str", - "tools": [ - tool - ], - "top_p": 0.0 - } - - # JSON input template for discriminator value "json_object": - text_response_format = { - "type": "json_object" - } - - # JSON input template for discriminator value "json_schema": - text_response_format = { - "name": "str", - "schema": { - "str": {} - }, - "type": "json_schema", - "description": "str", - "strict": bool - } - - # JSON input template for discriminator value "text": - text_response_format = { - "type": "text" - } - - # response body for status code(s): 200 - response == { - "id": "str", - "name": "str", - "object": "str", - "versions": { - "latest": { - "created_at": "2020-02-20 00:00:00", - "definition": agent_definition, - "id": "str", - "metadata": { - "str": "str" - }, - "name": "str", - "object": "str", - "version": "str", - "description": "str" - } - } - } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -278,14 +210,26 @@ async def get(self, agent_name: str, **kwargs: Any) -> _types_models2.AgentDetai } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_types_models2.AgentDetails] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AgentThread] = kwargs.pop("cls", None) + + if body is _Unset: + body = {"messages": messages, "metadata": metadata, "tool_resources": tool_resources} + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_agents_get_request( - agent_name=agent_name, + _request = build_threads_create_request( + content_type=content_type, api_version=self._config.api_version, + content=_content, headers=_headers, params=_params, ) @@ -294,7 +238,6 @@ async def get(self, agent_name: str, **kwargs: Any) -> _types_models2.AgentDetai } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -309,294 +252,109 @@ async def get(self, agent_name: str, **kwargs: Any) -> _types_models2.AgentDetai except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models2.ApiErrorResponse, - pipeline_response, - ) + error = _failsafe_deserialize(_models.AgentV1Error, response) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.AgentThread, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - async def _create_agent( - self, - name: str, - definition: _types_models2.AgentDefinition, - metadata: Optional[dict[str, str]] = None, - description: Optional[str] = None, - *, - foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models2.AgentDetails: ... - @overload - async def _create_agent( - self, - body: JSON, - *, - foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models2.AgentDetails: ... - @overload - async def _create_agent( + @distributed_trace + def list( self, - body: IO[bytes], *, - foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, - content_type: str = "application/json", + limit: Optional[int] = None, + order: Optional[Union[str, _models.ListSortOrder]] = None, + before: Optional[str] = None, **kwargs: Any - ) -> _types_models2.AgentDetails: ... + ) -> AsyncItemPaged["_models.AgentThread"]: + """Gets a list of threads that were previously created. - @distributed_trace_async - async def _create_agent( - self, - name: str = _Unset, - definition: _types_models2.AgentDefinition = _Unset, - body: Union[JSON, IO[bytes]] = _Unset, - metadata: Optional[dict[str, str]] = None, - description: Optional[str] = None, - *, - foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, - **kwargs: Any - ) -> _types_models2.AgentDetails: - """Creates the agent. - - :param name: The unique name that identifies the agent. Name can be used to - retrieve/update/delete the agent. - - * Must start and end with alphanumeric characters, - * Can contain hyphens in the middle - * Must not exceed 63 characters. Required. - :type name: str - :param definition: The agent definition. This can be a workflow, hosted agent, or a simple - agent definition. Required. - :type definition: ~azure.ai.agents.types.AgentDefinition - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :param metadata: Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. Default value is None. - :type metadata: dict[str, str] - :param description: A human-readable description of the agent. Default value is None. - :type description: str - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. Known values are: "HostedAgents=V1Preview" and - "WorkflowAgents=V1Preview". Default value is None. - :paramtype foundry_features: str or ~azure.ai.agents.models.AgentDefinitionOptInKeys - :return: AgentDetails - :rtype: ~azure.ai.agents.types.AgentDetails + :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and + 100, and the default is 20. Default value is None. + :paramtype limit: int + :keyword order: Sort order by the created_at timestamp of the objects. asc for ascending order + and desc for descending order. Known values are: "asc" and "desc". Default value is None. + :paramtype order: str or ~azure.ai.agents.models.ListSortOrder + :keyword 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. Default value is None. + :paramtype before: str + :return: An iterator like instance of AgentThread + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.models.AgentThread] :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AgentThread]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(_continuation_token=None): + + _request = build_threads_list_request( + limit=limit, + order=order, + after=_continuation_token, + before=before, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.AgentThread], deserialized.get("data", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("last_id") or None, AsyncList(list_of_elem) + + async def get_next(_continuation_token=None): + _request = prepare_request(_continuation_token) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get(self, thread_id: str, **kwargs: Any) -> _models.AgentThread: + """Gets information about an existing thread. - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "kind": - - # JSON input template for discriminator value "hosted": - agent_definition = { - "container_protocol_versions": [ - { - "protocol": "str", - "version": "str" - } - ], - "cpu": "str", - "kind": "hosted", - "memory": "str", - "environment_variables": { - "str": "str" - }, - "image": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "tools": [ - tool - ] - } - - # JSON input template for discriminator value "prompt": - agent_definition = { - "kind": "prompt", - "model": "str", - "instructions": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "reasoning": { - "effort": "none", - "generate_summary": "auto", - "summary": "auto" - }, - "structured_inputs": { - "str": { - "default_value": {}, - "description": "str", - "required": bool, - "schema": { - "str": {} - } - } - }, - "temperature": 0.0, - "text": { - "format": text_response_format - }, - "tool_choice": "str", - "tools": [ - tool - ], - "top_p": 0.0 - } - - # JSON input template for discriminator value "json_object": - text_response_format = { - "type": "json_object" - } - - # JSON input template for discriminator value "json_schema": - text_response_format = { - "name": "str", - "schema": { - "str": {} - }, - "type": "json_schema", - "description": "str", - "strict": bool - } - - # JSON input template for discriminator value "text": - text_response_format = { - "type": "text" - } - - # JSON input template you can fill out and use as your body input. - body = { - "definition": agent_definition, - "name": "str", - "description": "str", - "metadata": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "hosted": - agent_definition = { - "container_protocol_versions": [ - { - "protocol": "str", - "version": "str" - } - ], - "cpu": "str", - "kind": "hosted", - "memory": "str", - "environment_variables": { - "str": "str" - }, - "image": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "tools": [ - tool - ] - } - - # JSON input template for discriminator value "prompt": - agent_definition = { - "kind": "prompt", - "model": "str", - "instructions": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "reasoning": { - "effort": "none", - "generate_summary": "auto", - "summary": "auto" - }, - "structured_inputs": { - "str": { - "default_value": {}, - "description": "str", - "required": bool, - "schema": { - "str": {} - } - } - }, - "temperature": 0.0, - "text": { - "format": text_response_format - }, - "tool_choice": "str", - "tools": [ - tool - ], - "top_p": 0.0 - } - - # JSON input template for discriminator value "json_object": - text_response_format = { - "type": "json_object" - } - - # JSON input template for discriminator value "json_schema": - text_response_format = { - "name": "str", - "schema": { - "str": {} - }, - "type": "json_schema", - "description": "str", - "strict": bool - } - - # JSON input template for discriminator value "text": - text_response_format = { - "type": "text" - } - - # response body for status code(s): 200 - response == { - "id": "str", - "name": "str", - "object": "str", - "versions": { - "latest": { - "created_at": "2020-02-20 00:00:00", - "definition": agent_definition, - "id": "str", - "metadata": { - "str": "str" - }, - "name": "str", - "object": "str", - "version": "str", - "description": "str" - } - } - } + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :return: AgentThread. The AgentThread is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.AgentThread + :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -606,33 +364,14 @@ async def _create_agent( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models2.AgentDetails] = kwargs.pop("cls", None) - - if body is _Unset: - if name is _Unset: - raise TypeError("missing required argument: name") - if definition is _Unset: - raise TypeError("missing required argument: definition") - body = {"definition": definition, "description": description, "metadata": metadata, "name": name} - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _json = body + cls: ClsType[_models.AgentThread] = kwargs.pop("cls", None) - _request = build_agents_create_agent_request( - foundry_features=foundry_features, - content_type=content_type, + _request = build_threads_get_request( + thread_id=thread_id, api_version=self._config.api_version, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -641,7 +380,6 @@ async def _create_agent( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -656,19 +394,13 @@ async def _create_agent( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models2.ApiErrorResponse, - pipeline_response, - ) + error = _failsafe_deserialize(_models.AgentV1Error, response) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.AgentThread, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -676,271 +408,104 @@ async def _create_agent( return deserialized # type: ignore @overload - async def _update_agent( + async def update( self, - agent_name: str, - definition: _types_models2.AgentDefinition, - metadata: Optional[dict[str, str]] = None, - description: Optional[str] = None, + thread_id: str, *, - foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, content_type: str = "application/json", + tool_resources: Optional[_models.ToolResources] = None, + metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> _types_models2.AgentDetails: ... + ) -> _models.AgentThread: + """Modifies an existing thread. + + :param thread_id: The ID of the thread to modify. Required. + :type thread_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword tool_resources: 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. Default value is None. + :paramtype tool_resources: ~azure.ai.agents.models.ToolResources + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: AgentThread. The AgentThread is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.AgentThread + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload - async def _update_agent( - self, - agent_name: str, - body: JSON, - *, - foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models2.AgentDetails: ... + async def update( + self, thread_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.AgentThread: + """Modifies an existing thread. + + :param thread_id: The ID of the thread to modify. Required. + :type thread_id: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AgentThread. The AgentThread is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.AgentThread + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload - async def _update_agent( - self, - agent_name: str, - body: IO[bytes], - *, - foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models2.AgentDetails: ... + async def update( + self, thread_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.AgentThread: + """Modifies an existing thread. + + :param thread_id: The ID of the thread to modify. Required. + :type thread_id: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: AgentThread. The AgentThread is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.AgentThread + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async - async def _update_agent( + async def update( self, - agent_name: str, - definition: _types_models2.AgentDefinition = _Unset, + thread_id: str, body: Union[JSON, IO[bytes]] = _Unset, - metadata: Optional[dict[str, str]] = None, - description: Optional[str] = None, *, - foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, + tool_resources: Optional[_models.ToolResources] = None, + metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> _types_models2.AgentDetails: - """Updates the agent by adding a new version if there are any changes to the agent definition. If - no changes, returns the existing agent version. - - :param agent_name: The name of the agent to retrieve. Required. - :type agent_name: str - :param definition: The agent definition. This can be a workflow, hosted agent, or a simple - agent definition. Required. - :type definition: ~azure.ai.agents.types.AgentDefinition + ) -> _models.AgentThread: + """Modifies an existing thread. + + :param thread_id: The ID of the thread to modify. Required. + :type thread_id: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :param metadata: Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. Default value is None. - :type metadata: dict[str, str] - :param description: A human-readable description of the agent. Default value is None. - :type description: str - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. Known values are: "HostedAgents=V1Preview" and - "WorkflowAgents=V1Preview". Default value is None. - :paramtype foundry_features: str or ~azure.ai.agents.models.AgentDefinitionOptInKeys - :return: AgentDetails - :rtype: ~azure.ai.agents.types.AgentDetails + :keyword tool_resources: 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. Default value is None. + :paramtype tool_resources: ~azure.ai.agents.models.ToolResources + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: AgentThread. The AgentThread is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.AgentThread :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "kind": - - # JSON input template for discriminator value "hosted": - agent_definition = { - "container_protocol_versions": [ - { - "protocol": "str", - "version": "str" - } - ], - "cpu": "str", - "kind": "hosted", - "memory": "str", - "environment_variables": { - "str": "str" - }, - "image": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "tools": [ - tool - ] - } - - # JSON input template for discriminator value "prompt": - agent_definition = { - "kind": "prompt", - "model": "str", - "instructions": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "reasoning": { - "effort": "none", - "generate_summary": "auto", - "summary": "auto" - }, - "structured_inputs": { - "str": { - "default_value": {}, - "description": "str", - "required": bool, - "schema": { - "str": {} - } - } - }, - "temperature": 0.0, - "text": { - "format": text_response_format - }, - "tool_choice": "str", - "tools": [ - tool - ], - "top_p": 0.0 - } - - # JSON input template for discriminator value "json_object": - text_response_format = { - "type": "json_object" - } - - # JSON input template for discriminator value "json_schema": - text_response_format = { - "name": "str", - "schema": { - "str": {} - }, - "type": "json_schema", - "description": "str", - "strict": bool - } - - # JSON input template for discriminator value "text": - text_response_format = { - "type": "text" - } - - # JSON input template you can fill out and use as your body input. - body = { - "definition": agent_definition, - "description": "str", - "metadata": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "hosted": - agent_definition = { - "container_protocol_versions": [ - { - "protocol": "str", - "version": "str" - } - ], - "cpu": "str", - "kind": "hosted", - "memory": "str", - "environment_variables": { - "str": "str" - }, - "image": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "tools": [ - tool - ] - } - - # JSON input template for discriminator value "prompt": - agent_definition = { - "kind": "prompt", - "model": "str", - "instructions": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "reasoning": { - "effort": "none", - "generate_summary": "auto", - "summary": "auto" - }, - "structured_inputs": { - "str": { - "default_value": {}, - "description": "str", - "required": bool, - "schema": { - "str": {} - } - } - }, - "temperature": 0.0, - "text": { - "format": text_response_format - }, - "tool_choice": "str", - "tools": [ - tool - ], - "top_p": 0.0 - } - - # JSON input template for discriminator value "json_object": - text_response_format = { - "type": "json_object" - } - - # JSON input template for discriminator value "json_schema": - text_response_format = { - "name": "str", - "schema": { - "str": {} - }, - "type": "json_schema", - "description": "str", - "strict": bool - } - - # JSON input template for discriminator value "text": - text_response_format = { - "type": "text" - } - - # response body for status code(s): 200 - response == { - "id": "str", - "name": "str", - "object": "str", - "versions": { - "latest": { - "created_at": "2020-02-20 00:00:00", - "definition": agent_definition, - "id": "str", - "metadata": { - "str": "str" - }, - "name": "str", - "object": "str", - "version": "str", - "description": "str" - } - } - } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -954,27 +519,22 @@ async def _update_agent( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models2.AgentDetails] = kwargs.pop("cls", None) + cls: ClsType[_models.AgentThread] = kwargs.pop("cls", None) if body is _Unset: - if definition is _Unset: - raise TypeError("missing required argument: definition") - body = {"definition": definition, "description": description, "metadata": metadata} + body = {"metadata": metadata, "tool_resources": tool_resources} body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" - _json = None _content = None if isinstance(body, (IOBase, bytes)): _content = body else: - _json = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_agents_update_agent_request( - agent_name=agent_name, - foundry_features=foundry_features, + _request = build_threads_update_request( + thread_id=thread_id, content_type=content_type, api_version=self._config.api_version, - json=_json, content=_content, headers=_headers, params=_params, @@ -984,7 +544,6 @@ async def _update_agent( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -999,203 +558,28 @@ async def _update_agent( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models2.ApiErrorResponse, - pipeline_response, - ) + error = _failsafe_deserialize(_models.AgentV1Error, response) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.AgentThread, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - async def _create_agent_from_manifest( - self, - name: str, - manifest_id: str, - parameter_values: dict[str, Any], - metadata: Optional[dict[str, str]] = None, - description: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models2.AgentDetails: ... - @overload - async def _create_agent_from_manifest( - self, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _types_models2.AgentDetails: ... - @overload - async def _create_agent_from_manifest( - self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _types_models2.AgentDetails: ... - @distributed_trace_async - async def _create_agent_from_manifest( - self, - name: str = _Unset, - manifest_id: str = _Unset, - parameter_values: dict[str, Any] = _Unset, - body: Union[JSON, IO[bytes]] = _Unset, - metadata: Optional[dict[str, str]] = None, - description: Optional[str] = None, - **kwargs: Any - ) -> _types_models2.AgentDetails: - """Creates an agent from a manifest. - - :param name: The unique name that identifies the agent. Name can be used to - retrieve/update/delete the agent. - - * Must start and end with alphanumeric characters, - * Can contain hyphens in the middle - * Must not exceed 63 characters. Required. - :type name: str - :param manifest_id: The manifest ID to import the agent version from. Required. - :type manifest_id: str - :param parameter_values: The inputs to the manifest that will result in a fully materialized - Agent. Required. - :type parameter_values: dict[str, any] - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :param metadata: Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. Default value is None. - :type metadata: dict[str, str] - :param description: A human-readable description of the agent. Default value is None. - :type description: str - :return: AgentDetails - :rtype: ~azure.ai.agents.types.AgentDetails - :raises ~azure.core.exceptions.HttpResponseError: + async def _delete_thread(self, thread_id: str, **kwargs: Any) -> _models._models.ThreadDeletionStatus: + """Deletes an existing thread. - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "manifest_id": "str", - "name": "str", - "parameter_values": { - "str": {} - }, - "description": "str", - "metadata": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "hosted": - agent_definition = { - "container_protocol_versions": [ - { - "protocol": "str", - "version": "str" - } - ], - "cpu": "str", - "kind": "hosted", - "memory": "str", - "environment_variables": { - "str": "str" - }, - "image": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "tools": [ - tool - ] - } - - # JSON input template for discriminator value "prompt": - agent_definition = { - "kind": "prompt", - "model": "str", - "instructions": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "reasoning": { - "effort": "none", - "generate_summary": "auto", - "summary": "auto" - }, - "structured_inputs": { - "str": { - "default_value": {}, - "description": "str", - "required": bool, - "schema": { - "str": {} - } - } - }, - "temperature": 0.0, - "text": { - "format": text_response_format - }, - "tool_choice": "str", - "tools": [ - tool - ], - "top_p": 0.0 - } - - # JSON input template for discriminator value "json_object": - text_response_format = { - "type": "json_object" - } - - # JSON input template for discriminator value "json_schema": - text_response_format = { - "name": "str", - "schema": { - "str": {} - }, - "type": "json_schema", - "description": "str", - "strict": bool - } - - # JSON input template for discriminator value "text": - text_response_format = { - "type": "text" - } - - # response body for status code(s): 200 - response == { - "id": "str", - "name": "str", - "object": "str", - "versions": { - "latest": { - "created_at": "2020-02-20 00:00:00", - "definition": agent_definition, - "id": "str", - "metadata": { - "str": "str" - }, - "name": "str", - "object": "str", - "version": "str", - "description": "str" - } - } - } + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :return: ThreadDeletionStatus. The ThreadDeletionStatus is compatible with MutableMapping + :rtype: ~azure.ai.agents.models._models.ThreadDeletionStatus + :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1205,40 +589,14 @@ async def _create_agent_from_manifest( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models2.AgentDetails] = kwargs.pop("cls", None) + cls: ClsType[_models._models.ThreadDeletionStatus] = kwargs.pop("cls", None) - if body is _Unset: - if name is _Unset: - raise TypeError("missing required argument: name") - if manifest_id is _Unset: - raise TypeError("missing required argument: manifest_id") - if parameter_values is _Unset: - raise TypeError("missing required argument: parameter_values") - body = { - "description": description, - "manifest_id": manifest_id, - "metadata": metadata, - "name": name, - "parameter_values": parameter_values, - } - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _json = body - - _request = build_agents_create_agent_from_manifest_request( - content_type=content_type, + _request = build_threads_delete_thread_request( + thread_id=thread_id, api_version=self._config.api_version, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -1247,7 +605,6 @@ async def _create_agent_from_manifest( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1262,198 +619,158 @@ async def _create_agent_from_manifest( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models2.ApiErrorResponse, - pipeline_response, - ) + error = _failsafe_deserialize(_models.AgentV1Error, response) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize( + _models._models.ThreadDeletionStatus, response.json() # pylint: disable=protected-access + ) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + +class MessagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.agents.aio.AgentsClient`'s + :attr:`messages` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AgentsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @overload - async def _update_agent_from_manifest( + async def create( self, - agent_name: str, - manifest_id: str, - parameter_values: dict[str, Any], - metadata: Optional[dict[str, str]] = None, - description: Optional[str] = None, + thread_id: str, *, + role: Union[str, _models.MessageRole], + content: "_types.MessageInputContent", content_type: str = "application/json", + attachments: Optional[List[_models.MessageAttachment]] = None, + metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> _types_models2.AgentDetails: ... + ) -> _models.ThreadMessage: + """Creates a new message on a specified thread. + + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :keyword 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). Known values are: "user" and "assistant". + Required. + :paramtype role: str or ~azure.ai.agents.models.MessageRole + :keyword 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). Is either a str type or a [MessageInputContentBlock] type. Required. + :paramtype content: str or list[~azure.ai.agents.models.MessageInputContentBlock] + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword attachments: A list of files attached to the message, and the tools they should be + added to. Default value is None. + :paramtype attachments: list[~azure.ai.agents.models.MessageAttachment] + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: ThreadMessage. The ThreadMessage is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadMessage + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload - async def _update_agent_from_manifest( - self, agent_name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _types_models2.AgentDetails: ... + async def create( + self, thread_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ThreadMessage: + """Creates a new message on a specified thread. + + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ThreadMessage. The ThreadMessage is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadMessage + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload - async def _update_agent_from_manifest( - self, agent_name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _types_models2.AgentDetails: ... + async def create( + self, thread_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ThreadMessage: + """Creates a new message on a specified thread. + + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ThreadMessage. The ThreadMessage is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadMessage + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async - async def _update_agent_from_manifest( + async def create( self, - agent_name: str, - manifest_id: str = _Unset, - parameter_values: dict[str, Any] = _Unset, + thread_id: str, body: Union[JSON, IO[bytes]] = _Unset, + *, + role: Union[str, _models.MessageRole] = _Unset, + content: "_types.MessageInputContent" = _Unset, + attachments: Optional[List[_models.MessageAttachment]] = None, metadata: Optional[dict[str, str]] = None, - description: Optional[str] = None, **kwargs: Any - ) -> _types_models2.AgentDetails: - """Updates the agent from a manifest by adding a new version if there are any changes to the agent - definition. If no changes, returns the existing agent version. - - :param agent_name: The name of the agent to update. Required. - :type agent_name: str - :param manifest_id: The manifest ID to import the agent version from. Required. - :type manifest_id: str - :param parameter_values: The inputs to the manifest that will result in a fully materialized - Agent. Required. - :type parameter_values: dict[str, any] + ) -> _models.ThreadMessage: + """Creates a new message on a specified thread. + + :param thread_id: Identifier of the thread. Required. + :type thread_id: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :param metadata: Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. Default value is None. - :type metadata: dict[str, str] - :param description: A human-readable description of the agent. Default value is None. - :type description: str - :return: AgentDetails - :rtype: ~azure.ai.agents.types.AgentDetails + :keyword 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). Known values are: "user" and "assistant". + Required. + :paramtype role: str or ~azure.ai.agents.models.MessageRole + :keyword 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). Is either a str type or a [MessageInputContentBlock] type. Required. + :paramtype content: str or list[~azure.ai.agents.models.MessageInputContentBlock] + :keyword attachments: A list of files attached to the message, and the tools they should be + added to. Default value is None. + :paramtype attachments: list[~azure.ai.agents.models.MessageAttachment] + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: ThreadMessage. The ThreadMessage is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadMessage :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "manifest_id": "str", - "parameter_values": { - "str": {} - }, - "description": "str", - "metadata": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "hosted": - agent_definition = { - "container_protocol_versions": [ - { - "protocol": "str", - "version": "str" - } - ], - "cpu": "str", - "kind": "hosted", - "memory": "str", - "environment_variables": { - "str": "str" - }, - "image": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "tools": [ - tool - ] - } - - # JSON input template for discriminator value "prompt": - agent_definition = { - "kind": "prompt", - "model": "str", - "instructions": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "reasoning": { - "effort": "none", - "generate_summary": "auto", - "summary": "auto" - }, - "structured_inputs": { - "str": { - "default_value": {}, - "description": "str", - "required": bool, - "schema": { - "str": {} - } - } - }, - "temperature": 0.0, - "text": { - "format": text_response_format - }, - "tool_choice": "str", - "tools": [ - tool - ], - "top_p": 0.0 - } - - # JSON input template for discriminator value "json_object": - text_response_format = { - "type": "json_object" - } - - # JSON input template for discriminator value "json_schema": - text_response_format = { - "name": "str", - "schema": { - "str": {} - }, - "type": "json_schema", - "description": "str", - "strict": bool - } - - # JSON input template for discriminator value "text": - text_response_format = { - "type": "text" - } - - # response body for status code(s): 200 - response == { - "id": "str", - "name": "str", - "object": "str", - "versions": { - "latest": { - "created_at": "2020-02-20 00:00:00", - "definition": agent_definition, - "id": "str", - "metadata": { - "str": "str" - }, - "name": "str", - "object": "str", - "version": "str", - "description": "str" - } - } - } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1467,33 +784,26 @@ async def _update_agent_from_manifest( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models2.AgentDetails] = kwargs.pop("cls", None) + cls: ClsType[_models.ThreadMessage] = kwargs.pop("cls", None) if body is _Unset: - if manifest_id is _Unset: - raise TypeError("missing required argument: manifest_id") - if parameter_values is _Unset: - raise TypeError("missing required argument: parameter_values") - body = { - "description": description, - "manifest_id": manifest_id, - "metadata": metadata, - "parameter_values": parameter_values, - } + if role is _Unset: + raise TypeError("missing required argument: role") + if content is _Unset: + raise TypeError("missing required argument: content") + body = {"attachments": attachments, "content": content, "metadata": metadata, "role": role} body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" - _json = None _content = None if isinstance(body, (IOBase, bytes)): _content = body else: - _json = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_agents_update_agent_from_manifest_request( - agent_name=agent_name, + _request = build_messages_create_request( + thread_id=thread_id, content_type=content_type, api_version=self._config.api_version, - json=_json, content=_content, headers=_headers, params=_params, @@ -1503,7 +813,6 @@ async def _update_agent_from_manifest( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1518,97 +827,13 @@ async def _update_agent_from_manifest( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models2.ApiErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete(self, agent_name: str, **kwargs: Any) -> _types_models2.DeleteAgentResponse: - """Deletes an agent. - - :param agent_name: The name of the agent to delete. Required. - :type agent_name: str - :return: DeleteAgentResponse - :rtype: ~azure.ai.agents.types.DeleteAgentResponse - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "deleted": bool, - "name": "str", - "object": "str" - } - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_types_models2.DeleteAgentResponse] = kwargs.pop("cls", None) - - _request = build_agents_delete_request( - agent_name=agent_name, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models2.ApiErrorResponse, - pipeline_response, - ) + error = _failsafe_deserialize(_models.AgentV1Error, response) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.ThreadMessage, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1618,145 +843,39 @@ async def delete(self, agent_name: str, **kwargs: Any) -> _types_models2.DeleteA @distributed_trace def list( self, + thread_id: str, *, - kind: Optional[types.AgentKind] = None, + run_id: Optional[str] = None, limit: Optional[int] = None, - order: Optional[types.PageOrder] = None, + order: Optional[Union[str, _models.ListSortOrder]] = None, before: Optional[str] = None, **kwargs: Any - ) -> AsyncItemPaged["_types_models2.AgentDetails"]: - """Returns the list of all agents. + ) -> AsyncItemPaged["_models.ThreadMessage"]: + """Gets a list of messages that exist on a thread. - :keyword kind: Filter agents by kind. If not provided, all agents are returned. Known values - are: "prompt", "hosted", and "workflow". Default value is None. - :paramtype kind: str or ~azure.ai.agents.models.AgentKind + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :keyword run_id: Filter messages by the run ID that generated them. Default value is None. + :paramtype run_id: str :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and - 100, and the - default is 20. Default value is None. + 100, and the default is 20. Default value is None. :paramtype limit: int - :keyword order: Sort order by the ``created_at`` timestamp of the objects. ``asc`` for - ascending order and``desc`` - for descending order. Known values are: "asc" and "desc". Default value is None. - :paramtype order: str or ~azure.ai.agents.models.PageOrder - :keyword 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. - Default value is None. + :keyword order: Sort order by the created_at timestamp of the objects. asc for ascending order + and desc for descending order. Known values are: "asc" and "desc". Default value is None. + :paramtype order: str or ~azure.ai.agents.models.ListSortOrder + :keyword 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. Default value is None. :paramtype before: str - :return: An iterator like instance of AgentDetails - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.types.AgentDetails] + :return: An iterator like instance of ThreadMessage + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.models.ThreadMessage] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "hosted": - agent_definition = { - "container_protocol_versions": [ - { - "protocol": "str", - "version": "str" - } - ], - "cpu": "str", - "kind": "hosted", - "memory": "str", - "environment_variables": { - "str": "str" - }, - "image": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "tools": [ - tool - ] - } - - # JSON input template for discriminator value "prompt": - agent_definition = { - "kind": "prompt", - "model": "str", - "instructions": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "reasoning": { - "effort": "none", - "generate_summary": "auto", - "summary": "auto" - }, - "structured_inputs": { - "str": { - "default_value": {}, - "description": "str", - "required": bool, - "schema": { - "str": {} - } - } - }, - "temperature": 0.0, - "text": { - "format": text_response_format - }, - "tool_choice": "str", - "tools": [ - tool - ], - "top_p": 0.0 - } - - # JSON input template for discriminator value "json_object": - text_response_format = { - "type": "json_object" - } - - # JSON input template for discriminator value "json_schema": - text_response_format = { - "name": "str", - "schema": { - "str": {} - }, - "type": "json_schema", - "description": "str", - "strict": bool - } - - # JSON input template for discriminator value "text": - text_response_format = { - "type": "text" - } - - # response body for status code(s): 200 - response == { - "id": "str", - "name": "str", - "object": "str", - "versions": { - "latest": { - "created_at": "2020-02-20 00:00:00", - "definition": agent_definition, - "id": "str", - "metadata": { - "str": "str" - }, - "name": "str", - "object": "str", - "version": "str", - "description": "str" - } - } - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_types_models2.AgentDetails]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.ThreadMessage]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1768,8 +887,9 @@ def list( def prepare_request(_continuation_token=None): - _request = build_agents_list_request( - kind=kind, + _request = build_messages_list_request( + thread_id=thread_id, + run_id=run_id, limit=limit, order=order, after=_continuation_token, @@ -1786,7 +906,7 @@ def prepare_request(_continuation_token=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized.get("data", []) + list_of_elem = _deserialize(List[_models.ThreadMessage], deserialized.get("data", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("last_id") or None, AsyncList(list_of_elem) @@ -1802,741 +922,23 @@ async def get_next(_continuation_token=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models2.ApiErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) return pipeline_response return AsyncItemPaged(get_next, extract_data) - @overload - async def create_version( - self, - agent_name: str, - definition: _types_models2.AgentDefinition, - metadata: Optional[dict[str, str]] = None, - description: Optional[str] = None, - *, - foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models2.AgentVersionDetails: - """Create a new agent version. - - :param agent_name: The unique name that identifies the agent. Name can be used to - retrieve/update/delete the agent. - - * Must start and end with alphanumeric characters, - * Can contain hyphens in the middle - * Must not exceed 63 characters. Required. - :type agent_name: str - :param definition: The agent definition. This can be a workflow, hosted agent, or a simple - agent definition. Required. - :type definition: ~azure.ai.agents.types.AgentDefinition - :param metadata: Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. Default value is None. - :type metadata: dict[str, str] - :param description: A human-readable description of the agent. Default value is None. - :type description: str - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. Known values are: "HostedAgents=V1Preview" and - "WorkflowAgents=V1Preview". Default value is None. - :paramtype foundry_features: str or ~azure.ai.agents.models.AgentDefinitionOptInKeys - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AgentVersionDetails - :rtype: ~azure.ai.agents.types.AgentVersionDetails - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "hosted": - agent_definition = { - "container_protocol_versions": [ - { - "protocol": "str", - "version": "str" - } - ], - "cpu": "str", - "kind": "hosted", - "memory": "str", - "environment_variables": { - "str": "str" - }, - "image": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "tools": [ - tool - ] - } - - # JSON input template for discriminator value "prompt": - agent_definition = { - "kind": "prompt", - "model": "str", - "instructions": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "reasoning": { - "effort": "none", - "generate_summary": "auto", - "summary": "auto" - }, - "structured_inputs": { - "str": { - "default_value": {}, - "description": "str", - "required": bool, - "schema": { - "str": {} - } - } - }, - "temperature": 0.0, - "text": { - "format": text_response_format - }, - "tool_choice": "str", - "tools": [ - tool - ], - "top_p": 0.0 - } - - # JSON input template for discriminator value "json_object": - text_response_format = { - "type": "json_object" - } - - # JSON input template for discriminator value "json_schema": - text_response_format = { - "name": "str", - "schema": { - "str": {} - }, - "type": "json_schema", - "description": "str", - "strict": bool - } - - # JSON input template for discriminator value "text": - text_response_format = { - "type": "text" - } - - # response body for status code(s): 200 - response == { - "created_at": "2020-02-20 00:00:00", - "definition": agent_definition, - "id": "str", - "metadata": { - "str": "str" - }, - "name": "str", - "object": "str", - "version": "str", - "description": "str" - } - """ - - @overload - async def create_version( - self, - agent_name: str, - body: JSON, - *, - foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models2.AgentVersionDetails: - """Create a new agent version. - - :param agent_name: The unique name that identifies the agent. Name can be used to - retrieve/update/delete the agent. - - * Must start and end with alphanumeric characters, - * Can contain hyphens in the middle - * Must not exceed 63 characters. Required. - :type agent_name: str - :param body: Required. - :type body: JSON - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. Known values are: "HostedAgents=V1Preview" and - "WorkflowAgents=V1Preview". Default value is None. - :paramtype foundry_features: str or ~azure.ai.agents.models.AgentDefinitionOptInKeys - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AgentVersionDetails - :rtype: ~azure.ai.agents.types.AgentVersionDetails - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "kind": - - # JSON input template for discriminator value "hosted": - agent_definition = { - "container_protocol_versions": [ - { - "protocol": "str", - "version": "str" - } - ], - "cpu": "str", - "kind": "hosted", - "memory": "str", - "environment_variables": { - "str": "str" - }, - "image": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "tools": [ - tool - ] - } - - # JSON input template for discriminator value "prompt": - agent_definition = { - "kind": "prompt", - "model": "str", - "instructions": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "reasoning": { - "effort": "none", - "generate_summary": "auto", - "summary": "auto" - }, - "structured_inputs": { - "str": { - "default_value": {}, - "description": "str", - "required": bool, - "schema": { - "str": {} - } - } - }, - "temperature": 0.0, - "text": { - "format": text_response_format - }, - "tool_choice": "str", - "tools": [ - tool - ], - "top_p": 0.0 - } - - # JSON input template for discriminator value "json_object": - text_response_format = { - "type": "json_object" - } - - # JSON input template for discriminator value "json_schema": - text_response_format = { - "name": "str", - "schema": { - "str": {} - }, - "type": "json_schema", - "description": "str", - "strict": bool - } - - # JSON input template for discriminator value "text": - text_response_format = { - "type": "text" - } - - # JSON input template you can fill out and use as your body input. - body = { - "definition": agent_definition, - "description": "str", - "metadata": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "hosted": - agent_definition = { - "container_protocol_versions": [ - { - "protocol": "str", - "version": "str" - } - ], - "cpu": "str", - "kind": "hosted", - "memory": "str", - "environment_variables": { - "str": "str" - }, - "image": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "tools": [ - tool - ] - } - - # JSON input template for discriminator value "prompt": - agent_definition = { - "kind": "prompt", - "model": "str", - "instructions": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "reasoning": { - "effort": "none", - "generate_summary": "auto", - "summary": "auto" - }, - "structured_inputs": { - "str": { - "default_value": {}, - "description": "str", - "required": bool, - "schema": { - "str": {} - } - } - }, - "temperature": 0.0, - "text": { - "format": text_response_format - }, - "tool_choice": "str", - "tools": [ - tool - ], - "top_p": 0.0 - } - - # JSON input template for discriminator value "json_object": - text_response_format = { - "type": "json_object" - } - - # JSON input template for discriminator value "json_schema": - text_response_format = { - "name": "str", - "schema": { - "str": {} - }, - "type": "json_schema", - "description": "str", - "strict": bool - } - - # JSON input template for discriminator value "text": - text_response_format = { - "type": "text" - } - - # response body for status code(s): 200 - response == { - "created_at": "2020-02-20 00:00:00", - "definition": agent_definition, - "id": "str", - "metadata": { - "str": "str" - }, - "name": "str", - "object": "str", - "version": "str", - "description": "str" - } - """ - - @overload - async def create_version( - self, - agent_name: str, - body: IO[bytes], - *, - foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models2.AgentVersionDetails: - """Create a new agent version. - - :param agent_name: The unique name that identifies the agent. Name can be used to - retrieve/update/delete the agent. - - * Must start and end with alphanumeric characters, - * Can contain hyphens in the middle - * Must not exceed 63 characters. Required. - :type agent_name: str - :param body: Required. - :type body: IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. Known values are: "HostedAgents=V1Preview" and - "WorkflowAgents=V1Preview". Default value is None. - :paramtype foundry_features: str or ~azure.ai.agents.models.AgentDefinitionOptInKeys - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: AgentVersionDetails - :rtype: ~azure.ai.agents.types.AgentVersionDetails - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "hosted": - agent_definition = { - "container_protocol_versions": [ - { - "protocol": "str", - "version": "str" - } - ], - "cpu": "str", - "kind": "hosted", - "memory": "str", - "environment_variables": { - "str": "str" - }, - "image": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "tools": [ - tool - ] - } - - # JSON input template for discriminator value "prompt": - agent_definition = { - "kind": "prompt", - "model": "str", - "instructions": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "reasoning": { - "effort": "none", - "generate_summary": "auto", - "summary": "auto" - }, - "structured_inputs": { - "str": { - "default_value": {}, - "description": "str", - "required": bool, - "schema": { - "str": {} - } - } - }, - "temperature": 0.0, - "text": { - "format": text_response_format - }, - "tool_choice": "str", - "tools": [ - tool - ], - "top_p": 0.0 - } - - # JSON input template for discriminator value "json_object": - text_response_format = { - "type": "json_object" - } - - # JSON input template for discriminator value "json_schema": - text_response_format = { - "name": "str", - "schema": { - "str": {} - }, - "type": "json_schema", - "description": "str", - "strict": bool - } - - # JSON input template for discriminator value "text": - text_response_format = { - "type": "text" - } - - # response body for status code(s): 200 - response == { - "created_at": "2020-02-20 00:00:00", - "definition": agent_definition, - "id": "str", - "metadata": { - "str": "str" - }, - "name": "str", - "object": "str", - "version": "str", - "description": "str" - } - """ - @distributed_trace_async - async def create_version( - self, - agent_name: str, - definition: _types_models2.AgentDefinition = _Unset, - body: Union[JSON, IO[bytes]] = _Unset, - metadata: Optional[dict[str, str]] = None, - description: Optional[str] = None, - *, - foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, - **kwargs: Any - ) -> _types_models2.AgentVersionDetails: - """Create a new agent version. - - :param agent_name: The unique name that identifies the agent. Name can be used to - retrieve/update/delete the agent. - - * Must start and end with alphanumeric characters, - * Can contain hyphens in the middle - * Must not exceed 63 characters. Required. - :type agent_name: str - :param definition: The agent definition. This can be a workflow, hosted agent, or a simple - agent definition. Required. - :type definition: ~azure.ai.agents.types.AgentDefinition - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :param metadata: Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. Default value is None. - :type metadata: dict[str, str] - :param description: A human-readable description of the agent. Default value is None. - :type description: str - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. Known values are: "HostedAgents=V1Preview" and - "WorkflowAgents=V1Preview". Default value is None. - :paramtype foundry_features: str or ~azure.ai.agents.models.AgentDefinitionOptInKeys - :return: AgentVersionDetails - :rtype: ~azure.ai.agents.types.AgentVersionDetails + async def get(self, thread_id: str, message_id: str, **kwargs: Any) -> _models.ThreadMessage: + """Retrieves an existing message. + + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param message_id: Identifier of the message. Required. + :type message_id: str + :return: ThreadMessage. The ThreadMessage is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadMessage :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "kind": - - # JSON input template for discriminator value "hosted": - agent_definition = { - "container_protocol_versions": [ - { - "protocol": "str", - "version": "str" - } - ], - "cpu": "str", - "kind": "hosted", - "memory": "str", - "environment_variables": { - "str": "str" - }, - "image": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "tools": [ - tool - ] - } - - # JSON input template for discriminator value "prompt": - agent_definition = { - "kind": "prompt", - "model": "str", - "instructions": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "reasoning": { - "effort": "none", - "generate_summary": "auto", - "summary": "auto" - }, - "structured_inputs": { - "str": { - "default_value": {}, - "description": "str", - "required": bool, - "schema": { - "str": {} - } - } - }, - "temperature": 0.0, - "text": { - "format": text_response_format - }, - "tool_choice": "str", - "tools": [ - tool - ], - "top_p": 0.0 - } - - # JSON input template for discriminator value "json_object": - text_response_format = { - "type": "json_object" - } - - # JSON input template for discriminator value "json_schema": - text_response_format = { - "name": "str", - "schema": { - "str": {} - }, - "type": "json_schema", - "description": "str", - "strict": bool - } - - # JSON input template for discriminator value "text": - text_response_format = { - "type": "text" - } - - # JSON input template you can fill out and use as your body input. - body = { - "definition": agent_definition, - "description": "str", - "metadata": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "hosted": - agent_definition = { - "container_protocol_versions": [ - { - "protocol": "str", - "version": "str" - } - ], - "cpu": "str", - "kind": "hosted", - "memory": "str", - "environment_variables": { - "str": "str" - }, - "image": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "tools": [ - tool - ] - } - - # JSON input template for discriminator value "prompt": - agent_definition = { - "kind": "prompt", - "model": "str", - "instructions": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "reasoning": { - "effort": "none", - "generate_summary": "auto", - "summary": "auto" - }, - "structured_inputs": { - "str": { - "default_value": {}, - "description": "str", - "required": bool, - "schema": { - "str": {} - } - } - }, - "temperature": 0.0, - "text": { - "format": text_response_format - }, - "tool_choice": "str", - "tools": [ - tool - ], - "top_p": 0.0 - } - - # JSON input template for discriminator value "json_object": - text_response_format = { - "type": "json_object" - } - - # JSON input template for discriminator value "json_schema": - text_response_format = { - "name": "str", - "schema": { - "str": {} - }, - "type": "json_schema", - "description": "str", - "strict": bool - } - - # JSON input template for discriminator value "text": - text_response_format = { - "type": "text" - } - - # response body for status code(s): 200 - response == { - "created_at": "2020-02-20 00:00:00", - "definition": agent_definition, - "id": "str", - "metadata": { - "str": "str" - }, - "name": "str", - "object": "str", - "version": "str", - "description": "str" - } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2546,32 +948,15 @@ async def create_version( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models2.AgentVersionDetails] = kwargs.pop("cls", None) - - if body is _Unset: - if definition is _Unset: - raise TypeError("missing required argument: definition") - body = {"definition": definition, "description": description, "metadata": metadata} - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _json = body + cls: ClsType[_models.ThreadMessage] = kwargs.pop("cls", None) - _request = build_agents_create_version_request( - agent_name=agent_name, - foundry_features=foundry_features, - content_type=content_type, + _request = build_messages_get_request( + thread_id=thread_id, + message_id=message_id, api_version=self._config.api_version, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -2580,7 +965,6 @@ async def create_version( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -2595,19 +979,13 @@ async def create_version( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models2.ApiErrorResponse, - pipeline_response, - ) + error = _failsafe_deserialize(_models.AgentV1Error, response) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.ThreadMessage, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -2615,549 +993,100 @@ async def create_version( return deserialized # type: ignore @overload - async def create_version_from_manifest( + async def update( self, - agent_name: str, - manifest_id: str, - parameter_values: dict[str, Any], - metadata: Optional[dict[str, str]] = None, - description: Optional[str] = None, + thread_id: str, + message_id: str, *, content_type: str = "application/json", + metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> _types_models2.AgentVersionDetails: - """Create a new agent version from a manifest. - - :param agent_name: The unique name that identifies the agent. Name can be used to - retrieve/update/delete the agent. - - * Must start and end with alphanumeric characters, - * Can contain hyphens in the middle - * Must not exceed 63 characters. Required. - :type agent_name: str - :param manifest_id: The manifest ID to import the agent version from. Required. - :type manifest_id: str - :param parameter_values: The inputs to the manifest that will result in a fully materialized - Agent. Required. - :type parameter_values: dict[str, any] - :param metadata: Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. Default value is None. - :type metadata: dict[str, str] - :param description: A human-readable description of the agent. Default value is None. - :type description: str + ) -> _models.ThreadMessage: + """Modifies an existing message on an existing thread. + + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param message_id: Identifier of the message. Required. + :type message_id: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: AgentVersionDetails - :rtype: ~azure.ai.agents.types.AgentVersionDetails + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: ThreadMessage. The ThreadMessage is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadMessage :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "hosted": - agent_definition = { - "container_protocol_versions": [ - { - "protocol": "str", - "version": "str" - } - ], - "cpu": "str", - "kind": "hosted", - "memory": "str", - "environment_variables": { - "str": "str" - }, - "image": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "tools": [ - tool - ] - } - - # JSON input template for discriminator value "prompt": - agent_definition = { - "kind": "prompt", - "model": "str", - "instructions": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "reasoning": { - "effort": "none", - "generate_summary": "auto", - "summary": "auto" - }, - "structured_inputs": { - "str": { - "default_value": {}, - "description": "str", - "required": bool, - "schema": { - "str": {} - } - } - }, - "temperature": 0.0, - "text": { - "format": text_response_format - }, - "tool_choice": "str", - "tools": [ - tool - ], - "top_p": 0.0 - } - - # JSON input template for discriminator value "json_object": - text_response_format = { - "type": "json_object" - } - - # JSON input template for discriminator value "json_schema": - text_response_format = { - "name": "str", - "schema": { - "str": {} - }, - "type": "json_schema", - "description": "str", - "strict": bool - } - - # JSON input template for discriminator value "text": - text_response_format = { - "type": "text" - } - - # response body for status code(s): 200 - response == { - "created_at": "2020-02-20 00:00:00", - "definition": agent_definition, - "id": "str", - "metadata": { - "str": "str" - }, - "name": "str", - "object": "str", - "version": "str", - "description": "str" - } """ @overload - async def create_version_from_manifest( - self, agent_name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _types_models2.AgentVersionDetails: - """Create a new agent version from a manifest. - - :param agent_name: The unique name that identifies the agent. Name can be used to - retrieve/update/delete the agent. - - * Must start and end with alphanumeric characters, - * Can contain hyphens in the middle - * Must not exceed 63 characters. Required. - :type agent_name: str + async def update( + self, thread_id: str, message_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ThreadMessage: + """Modifies an existing message on an existing thread. + + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param message_id: Identifier of the message. Required. + :type message_id: str :param body: Required. :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: AgentVersionDetails - :rtype: ~azure.ai.agents.types.AgentVersionDetails + :return: ThreadMessage. The ThreadMessage is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadMessage :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "manifest_id": "str", - "parameter_values": { - "str": {} - }, - "description": "str", - "metadata": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "hosted": - agent_definition = { - "container_protocol_versions": [ - { - "protocol": "str", - "version": "str" - } - ], - "cpu": "str", - "kind": "hosted", - "memory": "str", - "environment_variables": { - "str": "str" - }, - "image": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "tools": [ - tool - ] - } - - # JSON input template for discriminator value "prompt": - agent_definition = { - "kind": "prompt", - "model": "str", - "instructions": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "reasoning": { - "effort": "none", - "generate_summary": "auto", - "summary": "auto" - }, - "structured_inputs": { - "str": { - "default_value": {}, - "description": "str", - "required": bool, - "schema": { - "str": {} - } - } - }, - "temperature": 0.0, - "text": { - "format": text_response_format - }, - "tool_choice": "str", - "tools": [ - tool - ], - "top_p": 0.0 - } - - # JSON input template for discriminator value "json_object": - text_response_format = { - "type": "json_object" - } - - # JSON input template for discriminator value "json_schema": - text_response_format = { - "name": "str", - "schema": { - "str": {} - }, - "type": "json_schema", - "description": "str", - "strict": bool - } - - # JSON input template for discriminator value "text": - text_response_format = { - "type": "text" - } - - # response body for status code(s): 200 - response == { - "created_at": "2020-02-20 00:00:00", - "definition": agent_definition, - "id": "str", - "metadata": { - "str": "str" - }, - "name": "str", - "object": "str", - "version": "str", - "description": "str" - } """ @overload - async def create_version_from_manifest( - self, agent_name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _types_models2.AgentVersionDetails: - """Create a new agent version from a manifest. - - :param agent_name: The unique name that identifies the agent. Name can be used to - retrieve/update/delete the agent. - - * Must start and end with alphanumeric characters, - * Can contain hyphens in the middle - * Must not exceed 63 characters. Required. - :type agent_name: str + async def update( + self, thread_id: str, message_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ThreadMessage: + """Modifies an existing message on an existing thread. + + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param message_id: Identifier of the message. Required. + :type message_id: str :param body: Required. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: AgentVersionDetails - :rtype: ~azure.ai.agents.types.AgentVersionDetails + :return: ThreadMessage. The ThreadMessage is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadMessage :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "hosted": - agent_definition = { - "container_protocol_versions": [ - { - "protocol": "str", - "version": "str" - } - ], - "cpu": "str", - "kind": "hosted", - "memory": "str", - "environment_variables": { - "str": "str" - }, - "image": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "tools": [ - tool - ] - } - - # JSON input template for discriminator value "prompt": - agent_definition = { - "kind": "prompt", - "model": "str", - "instructions": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "reasoning": { - "effort": "none", - "generate_summary": "auto", - "summary": "auto" - }, - "structured_inputs": { - "str": { - "default_value": {}, - "description": "str", - "required": bool, - "schema": { - "str": {} - } - } - }, - "temperature": 0.0, - "text": { - "format": text_response_format - }, - "tool_choice": "str", - "tools": [ - tool - ], - "top_p": 0.0 - } - - # JSON input template for discriminator value "json_object": - text_response_format = { - "type": "json_object" - } - - # JSON input template for discriminator value "json_schema": - text_response_format = { - "name": "str", - "schema": { - "str": {} - }, - "type": "json_schema", - "description": "str", - "strict": bool - } - - # JSON input template for discriminator value "text": - text_response_format = { - "type": "text" - } - - # response body for status code(s): 200 - response == { - "created_at": "2020-02-20 00:00:00", - "definition": agent_definition, - "id": "str", - "metadata": { - "str": "str" - }, - "name": "str", - "object": "str", - "version": "str", - "description": "str" - } """ @distributed_trace_async - async def create_version_from_manifest( + async def update( self, - agent_name: str, - manifest_id: str = _Unset, - parameter_values: dict[str, Any] = _Unset, + thread_id: str, + message_id: str, body: Union[JSON, IO[bytes]] = _Unset, + *, metadata: Optional[dict[str, str]] = None, - description: Optional[str] = None, **kwargs: Any - ) -> _types_models2.AgentVersionDetails: - """Create a new agent version from a manifest. - - :param agent_name: The unique name that identifies the agent. Name can be used to - retrieve/update/delete the agent. - - * Must start and end with alphanumeric characters, - * Can contain hyphens in the middle - * Must not exceed 63 characters. Required. - :type agent_name: str - :param manifest_id: The manifest ID to import the agent version from. Required. - :type manifest_id: str - :param parameter_values: The inputs to the manifest that will result in a fully materialized - Agent. Required. - :type parameter_values: dict[str, any] + ) -> _models.ThreadMessage: + """Modifies an existing message on an existing thread. + + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param message_id: Identifier of the message. Required. + :type message_id: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :param metadata: Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. Default value is None. - :type metadata: dict[str, str] - :param description: A human-readable description of the agent. Default value is None. - :type description: str - :return: AgentVersionDetails - :rtype: ~azure.ai.agents.types.AgentVersionDetails + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: ThreadMessage. The ThreadMessage is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadMessage :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "manifest_id": "str", - "parameter_values": { - "str": {} - }, - "description": "str", - "metadata": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "hosted": - agent_definition = { - "container_protocol_versions": [ - { - "protocol": "str", - "version": "str" - } - ], - "cpu": "str", - "kind": "hosted", - "memory": "str", - "environment_variables": { - "str": "str" - }, - "image": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "tools": [ - tool - ] - } - - # JSON input template for discriminator value "prompt": - agent_definition = { - "kind": "prompt", - "model": "str", - "instructions": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "reasoning": { - "effort": "none", - "generate_summary": "auto", - "summary": "auto" - }, - "structured_inputs": { - "str": { - "default_value": {}, - "description": "str", - "required": bool, - "schema": { - "str": {} - } - } - }, - "temperature": 0.0, - "text": { - "format": text_response_format - }, - "tool_choice": "str", - "tools": [ - tool - ], - "top_p": 0.0 - } - - # JSON input template for discriminator value "json_object": - text_response_format = { - "type": "json_object" - } - - # JSON input template for discriminator value "json_schema": - text_response_format = { - "name": "str", - "schema": { - "str": {} - }, - "type": "json_schema", - "description": "str", - "strict": bool - } - - # JSON input template for discriminator value "text": - text_response_format = { - "type": "text" - } - - # response body for status code(s): 200 - response == { - "created_at": "2020-02-20 00:00:00", - "definition": agent_definition, - "id": "str", - "metadata": { - "str": "str" - }, - "name": "str", - "object": "str", - "version": "str", - "description": "str" - } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3171,33 +1100,23 @@ async def create_version_from_manifest( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models2.AgentVersionDetails] = kwargs.pop("cls", None) + cls: ClsType[_models.ThreadMessage] = kwargs.pop("cls", None) if body is _Unset: - if manifest_id is _Unset: - raise TypeError("missing required argument: manifest_id") - if parameter_values is _Unset: - raise TypeError("missing required argument: parameter_values") - body = { - "description": description, - "manifest_id": manifest_id, - "metadata": metadata, - "parameter_values": parameter_values, - } + body = {"metadata": metadata} body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" - _json = None _content = None if isinstance(body, (IOBase, bytes)): _content = body else: - _json = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_agents_create_version_from_manifest_request( - agent_name=agent_name, + _request = build_messages_update_request( + thread_id=thread_id, + message_id=message_id, content_type=content_type, api_version=self._config.api_version, - json=_json, content=_content, headers=_headers, params=_params, @@ -3207,7 +1126,6 @@ async def create_version_from_manifest( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -3222,19 +1140,13 @@ async def create_version_from_manifest( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models2.ApiErrorResponse, - pipeline_response, - ) + error = _failsafe_deserialize(_models.AgentV1Error, response) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.ThreadMessage, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -3242,116 +1154,21 @@ async def create_version_from_manifest( return deserialized # type: ignore @distributed_trace_async - async def get_version( - self, agent_name: str, agent_version: str, **kwargs: Any - ) -> _types_models2.AgentVersionDetails: - """Retrieves a specific version of an agent. - - :param agent_name: The name of the agent to retrieve. Required. - :type agent_name: str - :param agent_version: The version of the agent to retrieve. Required. - :type agent_version: str - :return: AgentVersionDetails - :rtype: ~azure.ai.agents.types.AgentVersionDetails + @api_version_validation( + method_added_on="v1", + params_added_on={"v1": ["api_version", "thread_id", "message_id", "accept"]}, + api_versions_list=["v1", "2025-05-15-preview"], + ) + async def _delete(self, thread_id: str, message_id: str, **kwargs: Any) -> _models._models.MessageDeletionStatus: + """Deletes an existing message on an existing thread. + + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param message_id: Identifier of the message. Required. + :type message_id: str + :return: MessageDeletionStatus. The MessageDeletionStatus is compatible with MutableMapping + :rtype: ~azure.ai.agents.models._models.MessageDeletionStatus :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "hosted": - agent_definition = { - "container_protocol_versions": [ - { - "protocol": "str", - "version": "str" - } - ], - "cpu": "str", - "kind": "hosted", - "memory": "str", - "environment_variables": { - "str": "str" - }, - "image": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "tools": [ - tool - ] - } - - # JSON input template for discriminator value "prompt": - agent_definition = { - "kind": "prompt", - "model": "str", - "instructions": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "reasoning": { - "effort": "none", - "generate_summary": "auto", - "summary": "auto" - }, - "structured_inputs": { - "str": { - "default_value": {}, - "description": "str", - "required": bool, - "schema": { - "str": {} - } - } - }, - "temperature": 0.0, - "text": { - "format": text_response_format - }, - "tool_choice": "str", - "tools": [ - tool - ], - "top_p": 0.0 - } - - # JSON input template for discriminator value "json_object": - text_response_format = { - "type": "json_object" - } - - # JSON input template for discriminator value "json_schema": - text_response_format = { - "name": "str", - "schema": { - "str": {} - }, - "type": "json_schema", - "description": "str", - "strict": bool - } - - # JSON input template for discriminator value "text": - text_response_format = { - "type": "text" - } - - # response body for status code(s): 200 - response == { - "created_at": "2020-02-20 00:00:00", - "definition": agent_definition, - "id": "str", - "metadata": { - "str": "str" - }, - "name": "str", - "object": "str", - "version": "str", - "description": "str" - } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3364,11 +1181,11 @@ async def get_version( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_types_models2.AgentVersionDetails] = kwargs.pop("cls", None) + cls: ClsType[_models._models.MessageDeletionStatus] = kwargs.pop("cls", None) - _request = build_agents_get_version_request( - agent_name=agent_name, - agent_version=agent_version, + _request = build_messages_delete_request( + thread_id=thread_id, + message_id=message_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -3378,7 +1195,6 @@ async def get_version( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -3393,79 +1209,390 @@ async def get_version( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models2.ApiErrorResponse, - pipeline_response, - ) + error = _failsafe_deserialize(_models.AgentV1Error, response) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize( + _models._models.MessageDeletionStatus, response.json() # pylint: disable=protected-access + ) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace_async - async def delete_version( - self, agent_name: str, agent_version: str, **kwargs: Any - ) -> _types_models2.DeleteAgentVersionResponse: - """Deletes a specific version of an agent. - - :param agent_name: The name of the agent to delete. Required. - :type agent_name: str - :param agent_version: The version of the agent to delete. Required. - :type agent_version: str - :return: DeleteAgentVersionResponse - :rtype: ~azure.ai.agents.types.DeleteAgentVersionResponse - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - # response body for status code(s): 200 - response == { - "deleted": bool, - "name": "str", - "object": "str", - "version": "str" - } - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} +class RunsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - cls: ClsType[_types_models2.DeleteAgentVersionResponse] = kwargs.pop("cls", None) + Instead, you should access the following operations through + :class:`~azure.ai.agents.aio.AgentsClient`'s + :attr:`runs` attribute. + """ - _request = build_agents_delete_version_request( - agent_name=agent_name, - agent_version=agent_version, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AgentsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + @overload + async def create( + self, + thread_id: str, + *, + agent_id: str, + include: Optional[List[Union[str, _models.RunAdditionalFieldList]]] = None, + content_type: str = "application/json", + model: Optional[str] = None, + instructions: Optional[str] = None, + additional_instructions: Optional[str] = None, + additional_messages: Optional[List[_models.ThreadMessageOptions]] = None, + tools: Optional[List[_models.ToolDefinition]] = None, + tool_resources: Optional[_models.ToolResources] = None, + stream_parameter: Optional[bool] = None, + temperature: Optional[float] = None, + top_p: Optional[float] = None, + max_prompt_tokens: Optional[int] = None, + max_completion_tokens: Optional[int] = None, + truncation_strategy: Optional[_models.TruncationObject] = None, + tool_choice: Optional["_types.AgentsToolChoiceOption"] = None, + response_format: Optional["_types.AgentsResponseFormatOption"] = None, + parallel_tool_calls: Optional[bool] = None, + metadata: Optional[dict[str, str]] = None, + **kwargs: Any + ) -> _models.ThreadRun: + """Creates a new run for an agent thread. + + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :keyword agent_id: The ID of the agent that should run the thread. Required. + :paramtype agent_id: str + :keyword 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. Default value is None. + :paramtype include: list[str or ~azure.ai.agents.models.RunAdditionalFieldList] + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword model: The overridden model name that the agent should use to run the thread. Default + value is None. + :paramtype model: str + :keyword instructions: The overridden system instructions that the agent should use to run the + thread. Default value is None. + :paramtype instructions: str + :keyword additional_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. Default value is None. + :paramtype additional_instructions: str + :keyword additional_messages: Adds additional messages to the thread before creating the run. + Default value is None. + :paramtype additional_messages: list[~azure.ai.agents.models.ThreadMessageOptions] + :keyword tools: The overridden list of enabled tools that the agent should use to run the + thread. Default value is None. + :paramtype tools: list[~azure.ai.agents.models.ToolDefinition] + :keyword tool_resources: The overridden enabled tool resources that the agent should use to run + the thread. Default value is None. + :paramtype tool_resources: ~azure.ai.agents.models.ToolResources + :keyword stream_parameter: 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. Default + value is None. + :paramtype stream_parameter: bool + :keyword temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 + will make the output + more random, while lower values like 0.2 will make it more focused and deterministic. Default + value is None. + :paramtype temperature: float + :keyword top_p: An alternative to sampling with temperature, called nucleus sampling, where the + model + considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens + comprising the top 10% probability mass are considered. + + We generally recommend altering this or temperature but not both. Default value is None. + :paramtype top_p: float + :keyword max_prompt_tokens: 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. Default + value is None. + :paramtype max_prompt_tokens: int + :keyword max_completion_tokens: 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. Default value is None. + :paramtype max_completion_tokens: int + :keyword truncation_strategy: The strategy to use for dropping messages as the context windows + moves forward. Default value is None. + :paramtype truncation_strategy: ~azure.ai.agents.models.TruncationObject + :keyword tool_choice: Controls whether or not and which tool is called by the model. Is one of + the following types: str, Union[str, "_models.AgentsToolChoiceOptionMode"], + AgentsNamedToolChoice Default value is None. + :paramtype tool_choice: str or str or ~azure.ai.agents.models.AgentsToolChoiceOptionMode or + ~azure.ai.agents.models.AgentsNamedToolChoice + :keyword response_format: Specifies the format that the model must output. Is one of the + following types: str, Union[str, "_models.AgentsResponseFormatMode"], AgentsResponseFormat, + ResponseFormatJsonSchemaType Default value is None. + :paramtype response_format: str or str or ~azure.ai.agents.models.AgentsResponseFormatMode or + ~azure.ai.agents.models.AgentsResponseFormat or + ~azure.ai.agents.models.ResponseFormatJsonSchemaType + :keyword parallel_tool_calls: If ``true`` functions will run in parallel during tool use. + Default value is None. + :paramtype parallel_tool_calls: bool + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: ThreadRun. The ThreadRun is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadRun + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + thread_id: str, + body: JSON, + *, + include: Optional[List[Union[str, _models.RunAdditionalFieldList]]] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ThreadRun: + """Creates a new run for an agent thread. + + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param body: Required. + :type body: JSON + :keyword 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. Default value is None. + :paramtype include: list[str or ~azure.ai.agents.models.RunAdditionalFieldList] + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ThreadRun. The ThreadRun is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadRun + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + thread_id: str, + body: IO[bytes], + *, + include: Optional[List[Union[str, _models.RunAdditionalFieldList]]] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ThreadRun: + """Creates a new run for an agent thread. + + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param body: Required. + :type body: IO[bytes] + :keyword 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. Default value is None. + :paramtype include: list[str or ~azure.ai.agents.models.RunAdditionalFieldList] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ThreadRun. The ThreadRun is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadRun + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + thread_id: str, + body: Union[JSON, IO[bytes]] = _Unset, + *, + agent_id: str = _Unset, + include: Optional[List[Union[str, _models.RunAdditionalFieldList]]] = None, + model: Optional[str] = None, + instructions: Optional[str] = None, + additional_instructions: Optional[str] = None, + additional_messages: Optional[List[_models.ThreadMessageOptions]] = None, + tools: Optional[List[_models.ToolDefinition]] = None, + tool_resources: Optional[_models.ToolResources] = None, + stream_parameter: Optional[bool] = None, + temperature: Optional[float] = None, + top_p: Optional[float] = None, + max_prompt_tokens: Optional[int] = None, + max_completion_tokens: Optional[int] = None, + truncation_strategy: Optional[_models.TruncationObject] = None, + tool_choice: Optional["_types.AgentsToolChoiceOption"] = None, + response_format: Optional["_types.AgentsResponseFormatOption"] = None, + parallel_tool_calls: Optional[bool] = None, + metadata: Optional[dict[str, str]] = None, + **kwargs: Any + ) -> _models.ThreadRun: + """Creates a new run for an agent thread. + + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword agent_id: The ID of the agent that should run the thread. Required. + :paramtype agent_id: str + :keyword 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. Default value is None. + :paramtype include: list[str or ~azure.ai.agents.models.RunAdditionalFieldList] + :keyword model: The overridden model name that the agent should use to run the thread. Default + value is None. + :paramtype model: str + :keyword instructions: The overridden system instructions that the agent should use to run the + thread. Default value is None. + :paramtype instructions: str + :keyword additional_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. Default value is None. + :paramtype additional_instructions: str + :keyword additional_messages: Adds additional messages to the thread before creating the run. + Default value is None. + :paramtype additional_messages: list[~azure.ai.agents.models.ThreadMessageOptions] + :keyword tools: The overridden list of enabled tools that the agent should use to run the + thread. Default value is None. + :paramtype tools: list[~azure.ai.agents.models.ToolDefinition] + :keyword tool_resources: The overridden enabled tool resources that the agent should use to run + the thread. Default value is None. + :paramtype tool_resources: ~azure.ai.agents.models.ToolResources + :keyword stream_parameter: 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. Default + value is None. + :paramtype stream_parameter: bool + :keyword temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 + will make the output + more random, while lower values like 0.2 will make it more focused and deterministic. Default + value is None. + :paramtype temperature: float + :keyword top_p: An alternative to sampling with temperature, called nucleus sampling, where the + model + considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens + comprising the top 10% probability mass are considered. + + We generally recommend altering this or temperature but not both. Default value is None. + :paramtype top_p: float + :keyword max_prompt_tokens: 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. Default + value is None. + :paramtype max_prompt_tokens: int + :keyword max_completion_tokens: 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. Default value is None. + :paramtype max_completion_tokens: int + :keyword truncation_strategy: The strategy to use for dropping messages as the context windows + moves forward. Default value is None. + :paramtype truncation_strategy: ~azure.ai.agents.models.TruncationObject + :keyword tool_choice: Controls whether or not and which tool is called by the model. Is one of + the following types: str, Union[str, "_models.AgentsToolChoiceOptionMode"], + AgentsNamedToolChoice Default value is None. + :paramtype tool_choice: str or str or ~azure.ai.agents.models.AgentsToolChoiceOptionMode or + ~azure.ai.agents.models.AgentsNamedToolChoice + :keyword response_format: Specifies the format that the model must output. Is one of the + following types: str, Union[str, "_models.AgentsResponseFormatMode"], AgentsResponseFormat, + ResponseFormatJsonSchemaType Default value is None. + :paramtype response_format: str or str or ~azure.ai.agents.models.AgentsResponseFormatMode or + ~azure.ai.agents.models.AgentsResponseFormat or + ~azure.ai.agents.models.ResponseFormatJsonSchemaType + :keyword parallel_tool_calls: If ``true`` functions will run in parallel during tool use. + Default value is None. + :paramtype parallel_tool_calls: bool + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: ThreadRun. The ThreadRun is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadRun + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ThreadRun] = kwargs.pop("cls", None) + + if body is _Unset: + if agent_id is _Unset: + raise TypeError("missing required argument: agent_id") + body = { + "additional_instructions": additional_instructions, + "additional_messages": additional_messages, + "assistant_id": agent_id, + "instructions": instructions, + "max_completion_tokens": max_completion_tokens, + "max_prompt_tokens": max_prompt_tokens, + "metadata": metadata, + "model": model, + "parallel_tool_calls": parallel_tool_calls, + "response_format": response_format, + "stream": stream_parameter, + "temperature": temperature, + "tool_choice": tool_choice, + "tool_resources": tool_resources, + "tools": tools, + "top_p": top_p, + "truncation_strategy": truncation_strategy, + } + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_runs_create_request( + thread_id=thread_id, + include=include, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -3477,19 +1604,13 @@ async def delete_version( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models2.ApiErrorResponse, - pipeline_response, - ) + error = _failsafe_deserialize(_models.AgentV1Error, response) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.ThreadRun, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -3497,139 +1618,38 @@ async def delete_version( return deserialized # type: ignore @distributed_trace - def list_versions( + def list( self, - agent_name: str, + thread_id: str, *, limit: Optional[int] = None, - order: Optional[types.PageOrder] = None, + order: Optional[Union[str, _models.ListSortOrder]] = None, before: Optional[str] = None, **kwargs: Any - ) -> AsyncItemPaged["_types_models2.AgentVersionDetails"]: - """Returns the list of versions of an agent. + ) -> AsyncItemPaged["_models.ThreadRun"]: + """Gets a list of runs for a specified thread. - :param agent_name: The name of the agent to retrieve versions for. Required. - :type agent_name: str + :param thread_id: Identifier of the thread. Required. + :type thread_id: str :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and - 100, and the - default is 20. Default value is None. + 100, and the default is 20. Default value is None. :paramtype limit: int - :keyword order: Sort order by the ``created_at`` timestamp of the objects. ``asc`` for - ascending order and``desc`` - for descending order. Known values are: "asc" and "desc". Default value is None. - :paramtype order: str or ~azure.ai.agents.models.PageOrder - :keyword 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. - Default value is None. + :keyword order: Sort order by the created_at timestamp of the objects. asc for ascending order + and desc for descending order. Known values are: "asc" and "desc". Default value is None. + :paramtype order: str or ~azure.ai.agents.models.ListSortOrder + :keyword 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. Default value is None. :paramtype before: str - :return: An iterator like instance of AgentVersionDetails - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.types.AgentVersionDetails] + :return: An iterator like instance of ThreadRun + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.models.ThreadRun] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "hosted": - agent_definition = { - "container_protocol_versions": [ - { - "protocol": "str", - "version": "str" - } - ], - "cpu": "str", - "kind": "hosted", - "memory": "str", - "environment_variables": { - "str": "str" - }, - "image": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "tools": [ - tool - ] - } - - # JSON input template for discriminator value "prompt": - agent_definition = { - "kind": "prompt", - "model": "str", - "instructions": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "reasoning": { - "effort": "none", - "generate_summary": "auto", - "summary": "auto" - }, - "structured_inputs": { - "str": { - "default_value": {}, - "description": "str", - "required": bool, - "schema": { - "str": {} - } - } - }, - "temperature": 0.0, - "text": { - "format": text_response_format - }, - "tool_choice": "str", - "tools": [ - tool - ], - "top_p": 0.0 - } - - # JSON input template for discriminator value "json_object": - text_response_format = { - "type": "json_object" - } - - # JSON input template for discriminator value "json_schema": - text_response_format = { - "name": "str", - "schema": { - "str": {} - }, - "type": "json_schema", - "description": "str", - "strict": bool - } - - # JSON input template for discriminator value "text": - text_response_format = { - "type": "text" - } - - # response body for status code(s): 200 - response == { - "created_at": "2020-02-20 00:00:00", - "definition": agent_definition, - "id": "str", - "metadata": { - "str": "str" - }, - "name": "str", - "object": "str", - "version": "str", - "description": "str" - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_types_models2.AgentVersionDetails]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.ThreadRun]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3641,8 +1661,8 @@ def list_versions( def prepare_request(_continuation_token=None): - _request = build_agents_list_versions_request( - agent_name=agent_name, + _request = build_runs_list_request( + thread_id=thread_id, limit=limit, order=order, after=_continuation_token, @@ -3659,7 +1679,7 @@ def prepare_request(_continuation_token=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized.get("data", []) + list_of_elem = _deserialize(List[_models.ThreadRun], deserialized.get("data", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("last_id") or None, AsyncList(list_of_elem) @@ -3675,78 +1695,24 @@ async def get_next(_continuation_token=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models2.ApiErrorResponse, - pipeline_response, - ) + error = _failsafe_deserialize(_models.AgentV1Error, response) raise HttpResponseError(response=response, model=error) return pipeline_response return AsyncItemPaged(get_next, extract_data) - -class EvaluationRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.agents.aio.AIProjectClient`'s - :attr:`evaluation_rules` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def get(self, id: str, **kwargs: Any) -> _types_models2.EvaluationRule: - """Get an evaluation rule. + async def get(self, thread_id: str, run_id: str, **kwargs: Any) -> _models.ThreadRun: + """Gets an existing run from an existing thread. - :param id: Unique identifier for the evaluation rule. Required. - :type id: str - :return: EvaluationRule - :rtype: ~azure.ai.agents.types.EvaluationRule + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param run_id: Identifier of the run. Required. + :type run_id: str + :return: ThreadRun. The ThreadRun is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadRun :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "continuousEvaluation": - evaluation_rule_action = { - "evalId": "str", - "type": "continuousEvaluation", - "maxHourlyRuns": 0 - } - - # JSON input template for discriminator value "humanEvaluationPreview": - evaluation_rule_action = { - "templateId": "str", - "type": "humanEvaluationPreview" - } - - # response body for status code(s): 200 - response == { - "action": evaluation_rule_action, - "enabled": bool, - "eventType": "str", - "id": "str", - "systemData": { - "str": "str" - }, - "description": "str", - "displayName": "str", - "filter": { - "agentName": "str" - } - } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3759,10 +1725,11 @@ async def get(self, id: str, **kwargs: Any) -> _types_models2.EvaluationRule: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_types_models2.EvaluationRule] = kwargs.pop("cls", None) + cls: ClsType[_models.ThreadRun] = kwargs.pop("cls", None) - _request = build_evaluation_rules_get_request( - id=id, + _request = build_runs_get_request( + thread_id=thread_id, + run_id=run_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -3772,7 +1739,6 @@ async def get(self, id: str, **kwargs: Any) -> _types_models2.EvaluationRule: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -3787,362 +1753,114 @@ async def get(self, id: str, **kwargs: Any) -> _types_models2.EvaluationRule: except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.ThreadRun, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace_async - async def delete(self, id: str, **kwargs: Any) -> None: - """Delete an evaluation rule. - - :param id: Unique identifier for the evaluation rule. Required. - :type id: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_evaluation_rules_delete_request( - id=id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - @overload - async def create_or_update( + async def update( self, - id: str, - evaluation_rule: _types_models2.EvaluationRule, + thread_id: str, + run_id: str, *, - foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW]] = None, content_type: str = "application/json", + metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> _types_models2.EvaluationRule: - """Create or update an evaluation rule. - - :param id: Unique identifier for the evaluation rule. Required. - :type id: str - :param evaluation_rule: Evaluation rule resource. Required. - :type evaluation_rule: ~azure.ai.agents.types.EvaluationRule - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Default value is None. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + ) -> _models.ThreadRun: + """Modifies an existing thread run. + + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param run_id: Identifier of the run. Required. + :type run_id: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: EvaluationRule - :rtype: ~azure.ai.agents.types.EvaluationRule + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: ThreadRun. The ThreadRun is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadRun :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, thread_id: str, run_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ThreadRun: + """Modifies an existing thread run. - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "type": - - # JSON input template for discriminator value "continuousEvaluation": - evaluation_rule_action = { - "evalId": "str", - "type": "continuousEvaluation", - "maxHourlyRuns": 0 - } - - # JSON input template for discriminator value "humanEvaluationPreview": - evaluation_rule_action = { - "templateId": "str", - "type": "humanEvaluationPreview" - } - - # JSON input template you can fill out and use as your body input. - evaluation_rule = { - "action": evaluation_rule_action, - "enabled": bool, - "eventType": "str", - "id": "str", - "systemData": { - "str": "str" - }, - "description": "str", - "displayName": "str", - "filter": { - "agentName": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "continuousEvaluation": - evaluation_rule_action = { - "evalId": "str", - "type": "continuousEvaluation", - "maxHourlyRuns": 0 - } - - # JSON input template for discriminator value "humanEvaluationPreview": - evaluation_rule_action = { - "templateId": "str", - "type": "humanEvaluationPreview" - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "continuousEvaluation": - evaluation_rule_action = { - "evalId": "str", - "type": "continuousEvaluation", - "maxHourlyRuns": 0 - } - - # JSON input template for discriminator value "humanEvaluationPreview": - evaluation_rule_action = { - "templateId": "str", - "type": "humanEvaluationPreview" - } - - # response body for status code(s): 201, 200 - response == { - "action": evaluation_rule_action, - "enabled": bool, - "eventType": "str", - "id": "str", - "systemData": { - "str": "str" - }, - "description": "str", - "displayName": "str", - "filter": { - "agentName": "str" - } - } + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param run_id: Identifier of the run. Required. + :type run_id: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ThreadRun. The ThreadRun is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadRun + :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def create_or_update( - self, - id: str, - evaluation_rule: IO[bytes], - *, - foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW]] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models2.EvaluationRule: - """Create or update an evaluation rule. - - :param id: Unique identifier for the evaluation rule. Required. - :type id: str - :param evaluation_rule: Evaluation rule resource. Required. - :type evaluation_rule: IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Default value is None. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + async def update( + self, thread_id: str, run_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ThreadRun: + """Modifies an existing thread run. + + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param run_id: Identifier of the run. Required. + :type run_id: str + :param body: Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: EvaluationRule - :rtype: ~azure.ai.agents.types.EvaluationRule + :return: ThreadRun. The ThreadRun is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadRun :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "continuousEvaluation": - evaluation_rule_action = { - "evalId": "str", - "type": "continuousEvaluation", - "maxHourlyRuns": 0 - } - - # JSON input template for discriminator value "humanEvaluationPreview": - evaluation_rule_action = { - "templateId": "str", - "type": "humanEvaluationPreview" - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "continuousEvaluation": - evaluation_rule_action = { - "evalId": "str", - "type": "continuousEvaluation", - "maxHourlyRuns": 0 - } - - # JSON input template for discriminator value "humanEvaluationPreview": - evaluation_rule_action = { - "templateId": "str", - "type": "humanEvaluationPreview" - } - - # response body for status code(s): 201, 200 - response == { - "action": evaluation_rule_action, - "enabled": bool, - "eventType": "str", - "id": "str", - "systemData": { - "str": "str" - }, - "description": "str", - "displayName": "str", - "filter": { - "agentName": "str" - } - } """ @distributed_trace_async - async def create_or_update( + async def update( self, - id: str, - evaluation_rule: Union[_types_models2.EvaluationRule, IO[bytes]], + thread_id: str, + run_id: str, + body: Union[JSON, IO[bytes]] = _Unset, *, - foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW]] = None, + metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> _types_models2.EvaluationRule: - """Create or update an evaluation rule. - - :param id: Unique identifier for the evaluation rule. Required. - :type id: str - :param evaluation_rule: Evaluation rule resource. Is either a EvaluationRule type or a - IO[bytes] type. Required. - :type evaluation_rule: ~azure.ai.agents.types.EvaluationRule or IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Default value is None. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW - :return: EvaluationRule - :rtype: ~azure.ai.agents.types.EvaluationRule - :raises ~azure.core.exceptions.HttpResponseError: + ) -> _models.ThreadRun: + """Modifies an existing thread run. - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "type": - - # JSON input template for discriminator value "continuousEvaluation": - evaluation_rule_action = { - "evalId": "str", - "type": "continuousEvaluation", - "maxHourlyRuns": 0 - } - - # JSON input template for discriminator value "humanEvaluationPreview": - evaluation_rule_action = { - "templateId": "str", - "type": "humanEvaluationPreview" - } - - # JSON input template you can fill out and use as your body input. - evaluation_rule = { - "action": evaluation_rule_action, - "enabled": bool, - "eventType": "str", - "id": "str", - "systemData": { - "str": "str" - }, - "description": "str", - "displayName": "str", - "filter": { - "agentName": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "continuousEvaluation": - evaluation_rule_action = { - "evalId": "str", - "type": "continuousEvaluation", - "maxHourlyRuns": 0 - } - - # JSON input template for discriminator value "humanEvaluationPreview": - evaluation_rule_action = { - "templateId": "str", - "type": "humanEvaluationPreview" - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "continuousEvaluation": - evaluation_rule_action = { - "evalId": "str", - "type": "continuousEvaluation", - "maxHourlyRuns": 0 - } - - # JSON input template for discriminator value "humanEvaluationPreview": - evaluation_rule_action = { - "templateId": "str", - "type": "humanEvaluationPreview" - } - - # response body for status code(s): 201, 200 - response == { - "action": evaluation_rule_action, - "enabled": bool, - "eventType": "str", - "id": "str", - "systemData": { - "str": "str" - }, - "description": "str", - "displayName": "str", - "filter": { - "agentName": "str" - } - } + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param run_id: Identifier of the run. Required. + :type run_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: ThreadRun. The ThreadRun is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadRun + :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4156,22 +1874,23 @@ async def create_or_update( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models2.EvaluationRule] = kwargs.pop("cls", None) + cls: ClsType[_models.ThreadRun] = kwargs.pop("cls", None) + if body is _Unset: + body = {"metadata": metadata} + body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" - _json = None _content = None - if isinstance(evaluation_rule, (IOBase, bytes)): - _content = evaluation_rule + if isinstance(body, (IOBase, bytes)): + _content = body else: - _json = evaluation_rule + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_evaluation_rules_create_or_update_request( - id=id, - foundry_features=foundry_features, + _request = build_runs_update_request( + thread_id=thread_id, + run_id=run_id, content_type=content_type, api_version=self._config.api_version, - json=_json, content=_content, headers=_headers, params=_params, @@ -4181,7 +1900,6 @@ async def create_or_update( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -4189,4303 +1907,133 @@ async def create_or_update( response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200]: if _stream: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.ThreadRun, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized # type: ignore - - @distributed_trace - def list( - self, - *, - action_type: Optional[types.EvaluationRuleActionType] = None, - agent_name: Optional[str] = None, - enabled: Optional[bool] = None, - **kwargs: Any - ) -> AsyncItemPaged["_types_models2.EvaluationRule"]: - """List all evaluation rules. - - :keyword action_type: Filter by the type of evaluation rule. Known values are: - "continuousEvaluation" and "humanEvaluationPreview". Default value is None. - :paramtype action_type: str or ~azure.ai.agents.models.EvaluationRuleActionType - :keyword agent_name: Filter by the agent name. Default value is None. - :paramtype agent_name: str - :keyword enabled: Filter by the enabled status. Default value is None. - :paramtype enabled: bool - :return: An iterator like instance of EvaluationRule - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.types.EvaluationRule] - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "continuousEvaluation": - evaluation_rule_action = { - "evalId": "str", - "type": "continuousEvaluation", - "maxHourlyRuns": 0 - } - - # JSON input template for discriminator value "humanEvaluationPreview": - evaluation_rule_action = { - "templateId": "str", - "type": "humanEvaluationPreview" - } - - # response body for status code(s): 200 - response == { - "action": evaluation_rule_action, - "enabled": bool, - "eventType": "str", - "id": "str", - "systemData": { - "str": "str" - }, - "description": "str", - "displayName": "str", - "filter": { - "agentName": "str" - } - } - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_types_models2.EvaluationRule]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_evaluation_rules_list_request( - action_type=action_type, - agent_name=agent_name, - enabled=enabled, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized.get("value", []) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - -class ConnectionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.agents.aio.AIProjectClient`'s - :attr:`connections` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def _get(self, name: str, **kwargs: Any) -> _types_models2.Connection: - """Get a connection by name, without populating connection credentials. - - :param name: The friendly name of the connection, provided by the user. Required. - :type name: str - :return: Connection - :rtype: ~azure.ai.agents.types.Connection - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AAD": - base_credentials = { - "type": "AAD" - } - - # JSON input template for discriminator value "AgenticIdentityToken_Preview": - base_credentials = { - "type": "AgenticIdentityToken_Preview" - } - - # JSON input template for discriminator value "ApiKey": - base_credentials = { - "type": "ApiKey", - "key": "str" - } - - # JSON input template for discriminator value "CustomKeys": - base_credentials = { - "type": "CustomKeys" - } - - # JSON input template for discriminator value "None": - base_credentials = { - "type": "None" - } - - # response body for status code(s): 200 - response == { - "credentials": base_credentials, - "id": "str", - "isDefault": bool, - "metadata": { - "str": "str" - }, - "name": "str", - "target": "str", - "type": "str" - } - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_types_models2.Connection] = kwargs.pop("cls", None) - - _request = build_connections_get_request( - name=name, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - response_headers = {} - response_headers["x-ms-client-request-id"] = self._deserialize( - "str", response.headers.get("x-ms-client-request-id") - ) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def _get_with_credentials(self, name: str, **kwargs: Any) -> _types_models2.Connection: - """Get a connection by name, with its connection credentials. - - :param name: The friendly name of the connection, provided by the user. Required. - :type name: str - :return: Connection - :rtype: ~azure.ai.agents.types.Connection - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AAD": - base_credentials = { - "type": "AAD" - } - - # JSON input template for discriminator value "AgenticIdentityToken_Preview": - base_credentials = { - "type": "AgenticIdentityToken_Preview" - } - - # JSON input template for discriminator value "ApiKey": - base_credentials = { - "type": "ApiKey", - "key": "str" - } - - # JSON input template for discriminator value "CustomKeys": - base_credentials = { - "type": "CustomKeys" - } - - # JSON input template for discriminator value "None": - base_credentials = { - "type": "None" - } - - # response body for status code(s): 200 - response == { - "credentials": base_credentials, - "id": "str", - "isDefault": bool, - "metadata": { - "str": "str" - }, - "name": "str", - "target": "str", - "type": "str" - } - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_types_models2.Connection] = kwargs.pop("cls", None) - - _request = build_connections_get_with_credentials_request( - name=name, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - response_headers = {} - response_headers["x-ms-client-request-id"] = self._deserialize( - "str", response.headers.get("x-ms-client-request-id") - ) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, - *, - connection_type: Optional[types.ConnectionType] = None, - default_connection: Optional[bool] = None, - **kwargs: Any - ) -> AsyncItemPaged["_types_models2.Connection"]: - """List all connections in the project, without populating connection credentials. - - :keyword connection_type: List connections of this specific type. Known values are: - "AzureOpenAI", "AzureBlob", "AzureStorageAccount", "CognitiveSearch", "CosmosDB", "ApiKey", - "AppConfig", "AppInsights", "CustomKeys", and "RemoteTool_Preview". Default value is None. - :paramtype connection_type: str or ~azure.ai.agents.models.ConnectionType - :keyword default_connection: List connections that are default connections. Default value is - None. - :paramtype default_connection: bool - :return: An iterator like instance of Connection - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.types.Connection] - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AAD": - base_credentials = { - "type": "AAD" - } - - # JSON input template for discriminator value "AgenticIdentityToken_Preview": - base_credentials = { - "type": "AgenticIdentityToken_Preview" - } - - # JSON input template for discriminator value "ApiKey": - base_credentials = { - "type": "ApiKey", - "key": "str" - } - - # JSON input template for discriminator value "CustomKeys": - base_credentials = { - "type": "CustomKeys" - } - - # JSON input template for discriminator value "None": - base_credentials = { - "type": "None" - } - - # response body for status code(s): 200 - response == { - "credentials": base_credentials, - "id": "str", - "isDefault": bool, - "metadata": { - "str": "str" - }, - "name": "str", - "target": "str", - "type": "str" - } - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_types_models2.Connection]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_connections_list_request( - connection_type=connection_type, - default_connection=default_connection, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized.get("value", []) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - -class DatasetsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.agents.aio.AIProjectClient`'s - :attr:`datasets` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_versions(self, name: str, **kwargs: Any) -> AsyncItemPaged["_types_models2.DatasetVersion"]: - """List all versions of the given DatasetVersion. - - :param name: The name of the resource. Required. - :type name: str - :return: An iterator like instance of DatasetVersion - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.types.DatasetVersion] - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "uri_file": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_file", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "uri_folder": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_folder", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # response body for status code(s): 200 - response == dataset_version - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_types_models2.DatasetVersion]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_datasets_list_versions_request( - name=name, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized.get("value", []) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncItemPaged["_types_models2.DatasetVersion"]: - """List the latest version of each DatasetVersion. - - :return: An iterator like instance of DatasetVersion - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.types.DatasetVersion] - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "uri_file": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_file", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "uri_folder": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_folder", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # response body for status code(s): 200 - response == dataset_version - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_types_models2.DatasetVersion]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_datasets_list_request( - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized.get("value", []) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get(self, name: str, version: str, **kwargs: Any) -> _types_models2.DatasetVersion: - """Get the specific version of the DatasetVersion. The service returns 404 Not Found error if the - DatasetVersion does not exist. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the DatasetVersion to retrieve. Required. - :type version: str - :return: DatasetVersion - :rtype: ~azure.ai.agents.types.DatasetVersion - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "uri_file": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_file", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "uri_folder": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_folder", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # response body for status code(s): 200 - response == dataset_version - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_types_models2.DatasetVersion] = kwargs.pop("cls", None) - - _request = build_datasets_get_request( - name=name, - version=version, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete(self, name: str, version: str, **kwargs: Any) -> None: - """Delete the specific version of the DatasetVersion. The service returns 204 No Content if the - DatasetVersion was deleted successfully or if the DatasetVersion does not exist. - - :param name: The name of the resource. Required. - :type name: str - :param version: The version of the DatasetVersion to delete. Required. - :type version: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_datasets_delete_request( - name=name, - version=version, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @overload - async def create_or_update( - self, - name: str, - version: str, - dataset_version: _types_models2.DatasetVersion, - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> _types_models2.DatasetVersion: - """Create a new or update an existing DatasetVersion with the given version id. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the DatasetVersion to create or update. Required. - :type version: str - :param dataset_version: The DatasetVersion to create or update. Required. - :type dataset_version: ~azure.ai.agents.types.DatasetVersion - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/merge-patch+json". - :paramtype content_type: str - :return: DatasetVersion - :rtype: ~azure.ai.agents.types.DatasetVersion - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "type": - - # JSON input template for discriminator value "uri_file": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_file", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "uri_folder": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_folder", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # JSON input template you can fill out and use as your body input. - dataset_version = dataset_version - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "uri_file": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_file", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "uri_folder": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_folder", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "uri_file": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_file", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "uri_folder": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_folder", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # response body for status code(s): 201, 200 - response == dataset_version - """ - - @overload - async def create_or_update( - self, - name: str, - version: str, - dataset_version: IO[bytes], - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> _types_models2.DatasetVersion: - """Create a new or update an existing DatasetVersion with the given version id. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the DatasetVersion to create or update. Required. - :type version: str - :param dataset_version: The DatasetVersion to create or update. Required. - :type dataset_version: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/merge-patch+json". - :paramtype content_type: str - :return: DatasetVersion - :rtype: ~azure.ai.agents.types.DatasetVersion - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "uri_file": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_file", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "uri_folder": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_folder", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "uri_file": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_file", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "uri_folder": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_folder", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # response body for status code(s): 201, 200 - response == dataset_version - """ - - @distributed_trace_async - async def create_or_update( - self, name: str, version: str, dataset_version: Union[_types_models2.DatasetVersion, IO[bytes]], **kwargs: Any - ) -> _types_models2.DatasetVersion: - """Create a new or update an existing DatasetVersion with the given version id. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the DatasetVersion to create or update. Required. - :type version: str - :param dataset_version: The DatasetVersion to create or update. Is either a DatasetVersion type - or a IO[bytes] type. Required. - :type dataset_version: ~azure.ai.agents.types.DatasetVersion or IO[bytes] - :return: DatasetVersion - :rtype: ~azure.ai.agents.types.DatasetVersion - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "type": - - # JSON input template for discriminator value "uri_file": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_file", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "uri_folder": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_folder", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # JSON input template you can fill out and use as your body input. - dataset_version = dataset_version - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "uri_file": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_file", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "uri_folder": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_folder", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "uri_file": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_file", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "uri_folder": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_folder", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # response body for status code(s): 201, 200 - response == dataset_version - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models2.DatasetVersion] = kwargs.pop("cls", None) - - content_type = content_type or "application/merge-patch+json" - _json = None - _content = None - if isinstance(dataset_version, (IOBase, bytes)): - _content = dataset_version - else: - _json = dataset_version - - _request = build_datasets_create_or_update_request( - name=name, - version=version, - content_type=content_type, - api_version=self._config.api_version, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def pending_upload( - self, - name: str, - version: str, - pending_upload_request: _types_models2.PendingUploadRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models2.PendingUploadResponse: - """Start a new or get an existing pending upload of a dataset for a specific version. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the DatasetVersion to operate on. Required. - :type version: str - :param pending_upload_request: The pending upload request parameters. Required. - :type pending_upload_request: ~azure.ai.agents.types.PendingUploadRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: PendingUploadResponse - :rtype: ~azure.ai.agents.types.PendingUploadResponse - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - pending_upload_request = { - "pendingUploadType": "str", - "connectionName": "str", - "pendingUploadId": "str" - } - - # response body for status code(s): 200 - response == { - "blobReference": { - "blobUri": "str", - "credential": { - "sasUri": "str", - "type": "SAS" - }, - "storageAccountArmId": "str" - }, - "pendingUploadId": "str", - "pendingUploadType": "str", - "version": "str" - } - """ - - @overload - async def pending_upload( - self, - name: str, - version: str, - pending_upload_request: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models2.PendingUploadResponse: - """Start a new or get an existing pending upload of a dataset for a specific version. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the DatasetVersion to operate on. Required. - :type version: str - :param pending_upload_request: The pending upload request parameters. Required. - :type pending_upload_request: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: PendingUploadResponse - :rtype: ~azure.ai.agents.types.PendingUploadResponse - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "blobReference": { - "blobUri": "str", - "credential": { - "sasUri": "str", - "type": "SAS" - }, - "storageAccountArmId": "str" - }, - "pendingUploadId": "str", - "pendingUploadType": "str", - "version": "str" - } - """ - - @distributed_trace_async - async def pending_upload( - self, - name: str, - version: str, - pending_upload_request: Union[_types_models2.PendingUploadRequest, IO[bytes]], - **kwargs: Any - ) -> _types_models2.PendingUploadResponse: - """Start a new or get an existing pending upload of a dataset for a specific version. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the DatasetVersion to operate on. Required. - :type version: str - :param pending_upload_request: The pending upload request parameters. Is either a - PendingUploadRequest type or a IO[bytes] type. Required. - :type pending_upload_request: ~azure.ai.agents.types.PendingUploadRequest or IO[bytes] - :return: PendingUploadResponse - :rtype: ~azure.ai.agents.types.PendingUploadResponse - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - pending_upload_request = { - "pendingUploadType": "str", - "connectionName": "str", - "pendingUploadId": "str" - } - - # response body for status code(s): 200 - response == { - "blobReference": { - "blobUri": "str", - "credential": { - "sasUri": "str", - "type": "SAS" - }, - "storageAccountArmId": "str" - }, - "pendingUploadId": "str", - "pendingUploadType": "str", - "version": "str" - } - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models2.PendingUploadResponse] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(pending_upload_request, (IOBase, bytes)): - _content = pending_upload_request - else: - _json = pending_upload_request - - _request = build_datasets_pending_upload_request( - name=name, - version=version, - content_type=content_type, - api_version=self._config.api_version, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get_credentials(self, name: str, version: str, **kwargs: Any) -> _types_models2.DatasetCredential: - """Get the SAS credential to access the storage account associated with a Dataset version. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the DatasetVersion to operate on. Required. - :type version: str - :return: DatasetCredential - :rtype: ~azure.ai.agents.types.DatasetCredential - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "blobReference": { - "blobUri": "str", - "credential": { - "sasUri": "str", - "type": "SAS" - }, - "storageAccountArmId": "str" - } - } - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_types_models2.DatasetCredential] = kwargs.pop("cls", None) - - _request = build_datasets_get_credentials_request( - name=name, - version=version, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class DeploymentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.agents.aio.AIProjectClient`'s - :attr:`deployments` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get(self, name: str, **kwargs: Any) -> _types_models2.Deployment: - """Get a deployed model. - - :param name: Name of the deployment. Required. - :type name: str - :return: Deployment - :rtype: ~azure.ai.agents.types.Deployment - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "ModelDeployment": - deployment = { - "capabilities": { - "str": "str" - }, - "modelName": "str", - "modelPublisher": "str", - "modelVersion": "str", - "name": "str", - "sku": { - "capacity": 0, - "family": "str", - "name": "str", - "size": "str", - "tier": "str" - }, - "type": "ModelDeployment", - "connectionName": "str" - } - - # response body for status code(s): 200 - response == deployment - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_types_models2.Deployment] = kwargs.pop("cls", None) - - _request = build_deployments_get_request( - name=name, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - response_headers = {} - response_headers["x-ms-client-request-id"] = self._deserialize( - "str", response.headers.get("x-ms-client-request-id") - ) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, - *, - model_publisher: Optional[str] = None, - model_name: Optional[str] = None, - deployment_type: Optional[types.DeploymentType] = None, - **kwargs: Any - ) -> AsyncItemPaged["_types_models2.Deployment"]: - """List all deployed models in the project. - - :keyword model_publisher: Model publisher to filter models by. Default value is None. - :paramtype model_publisher: str - :keyword model_name: Model name (the publisher specific name) to filter models by. Default - value is None. - :paramtype model_name: str - :keyword deployment_type: Type of deployment to filter list by. "ModelDeployment" Default value - is None. - :paramtype deployment_type: str or ~azure.ai.agents.models.DeploymentType - :return: An iterator like instance of Deployment - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.types.Deployment] - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "ModelDeployment": - deployment = { - "capabilities": { - "str": "str" - }, - "modelName": "str", - "modelPublisher": "str", - "modelVersion": "str", - "name": "str", - "sku": { - "capacity": 0, - "family": "str", - "name": "str", - "size": "str", - "tier": "str" - }, - "type": "ModelDeployment", - "connectionName": "str" - } - - # response body for status code(s): 200 - response == deployment - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_types_models2.Deployment]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_deployments_list_request( - model_publisher=model_publisher, - model_name=model_name, - deployment_type=deployment_type, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized.get("value", []) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - -class IndexesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.agents.aio.AIProjectClient`'s - :attr:`indexes` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_versions(self, name: str, **kwargs: Any) -> AsyncItemPaged["_types_models2.Index"]: - """List all versions of the given Index. - - :param name: The name of the resource. Required. - :type name: str - :return: An iterator like instance of Index - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.types.Index] - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AzureSearch": - index = { - "connectionName": "str", - "indexName": "str", - "name": "str", - "type": "AzureSearch", - "version": "str", - "description": "str", - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": - index = { - "connectionName": "str", - "containerName": "str", - "databaseName": "str", - "embeddingConfiguration": { - "embeddingField": "str", - "modelDeploymentName": "str" - }, - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "name": "str", - "type": "CosmosDBNoSqlVectorStore", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "ManagedAzureSearch": - index = { - "name": "str", - "type": "ManagedAzureSearch", - "vectorStoreId": "str", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # response body for status code(s): 200 - response == index - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_types_models2.Index]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_indexes_list_versions_request( - name=name, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized.get("value", []) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncItemPaged["_types_models2.Index"]: - """List the latest version of each Index. - - :return: An iterator like instance of Index - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.types.Index] - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AzureSearch": - index = { - "connectionName": "str", - "indexName": "str", - "name": "str", - "type": "AzureSearch", - "version": "str", - "description": "str", - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": - index = { - "connectionName": "str", - "containerName": "str", - "databaseName": "str", - "embeddingConfiguration": { - "embeddingField": "str", - "modelDeploymentName": "str" - }, - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "name": "str", - "type": "CosmosDBNoSqlVectorStore", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "ManagedAzureSearch": - index = { - "name": "str", - "type": "ManagedAzureSearch", - "vectorStoreId": "str", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # response body for status code(s): 200 - response == index - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_types_models2.Index]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_indexes_list_request( - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized.get("value", []) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get(self, name: str, version: str, **kwargs: Any) -> _types_models2.Index: - """Get the specific version of the Index. The service returns 404 Not Found error if the Index - does not exist. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the Index to retrieve. Required. - :type version: str - :return: Index - :rtype: ~azure.ai.agents.types.Index - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AzureSearch": - index = { - "connectionName": "str", - "indexName": "str", - "name": "str", - "type": "AzureSearch", - "version": "str", - "description": "str", - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": - index = { - "connectionName": "str", - "containerName": "str", - "databaseName": "str", - "embeddingConfiguration": { - "embeddingField": "str", - "modelDeploymentName": "str" - }, - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "name": "str", - "type": "CosmosDBNoSqlVectorStore", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "ManagedAzureSearch": - index = { - "name": "str", - "type": "ManagedAzureSearch", - "vectorStoreId": "str", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # response body for status code(s): 200 - response == index - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_types_models2.Index] = kwargs.pop("cls", None) - - _request = build_indexes_get_request( - name=name, - version=version, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete(self, name: str, version: str, **kwargs: Any) -> None: - """Delete the specific version of the Index. The service returns 204 No Content if the Index was - deleted successfully or if the Index does not exist. - - :param name: The name of the resource. Required. - :type name: str - :param version: The version of the Index to delete. Required. - :type version: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_indexes_delete_request( - name=name, - version=version, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @overload - async def create_or_update( - self, - name: str, - version: str, - index: _types_models2.Index, - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> _types_models2.Index: - """Create a new or update an existing Index with the given version id. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the Index to create or update. Required. - :type version: str - :param index: The Index to create or update. Required. - :type index: ~azure.ai.agents.types.Index - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/merge-patch+json". - :paramtype content_type: str - :return: Index - :rtype: ~azure.ai.agents.types.Index - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "type": - - # JSON input template for discriminator value "AzureSearch": - index = { - "connectionName": "str", - "indexName": "str", - "name": "str", - "type": "AzureSearch", - "version": "str", - "description": "str", - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": - index = { - "connectionName": "str", - "containerName": "str", - "databaseName": "str", - "embeddingConfiguration": { - "embeddingField": "str", - "modelDeploymentName": "str" - }, - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "name": "str", - "type": "CosmosDBNoSqlVectorStore", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "ManagedAzureSearch": - index = { - "name": "str", - "type": "ManagedAzureSearch", - "vectorStoreId": "str", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template you can fill out and use as your body input. - index = index - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AzureSearch": - index = { - "connectionName": "str", - "indexName": "str", - "name": "str", - "type": "AzureSearch", - "version": "str", - "description": "str", - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": - index = { - "connectionName": "str", - "containerName": "str", - "databaseName": "str", - "embeddingConfiguration": { - "embeddingField": "str", - "modelDeploymentName": "str" - }, - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "name": "str", - "type": "CosmosDBNoSqlVectorStore", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "ManagedAzureSearch": - index = { - "name": "str", - "type": "ManagedAzureSearch", - "vectorStoreId": "str", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AzureSearch": - index = { - "connectionName": "str", - "indexName": "str", - "name": "str", - "type": "AzureSearch", - "version": "str", - "description": "str", - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": - index = { - "connectionName": "str", - "containerName": "str", - "databaseName": "str", - "embeddingConfiguration": { - "embeddingField": "str", - "modelDeploymentName": "str" - }, - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "name": "str", - "type": "CosmosDBNoSqlVectorStore", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "ManagedAzureSearch": - index = { - "name": "str", - "type": "ManagedAzureSearch", - "vectorStoreId": "str", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # response body for status code(s): 201, 200 - response == index - """ - - @overload - async def create_or_update( - self, - name: str, - version: str, - index: IO[bytes], - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> _types_models2.Index: - """Create a new or update an existing Index with the given version id. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the Index to create or update. Required. - :type version: str - :param index: The Index to create or update. Required. - :type index: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/merge-patch+json". - :paramtype content_type: str - :return: Index - :rtype: ~azure.ai.agents.types.Index - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AzureSearch": - index = { - "connectionName": "str", - "indexName": "str", - "name": "str", - "type": "AzureSearch", - "version": "str", - "description": "str", - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": - index = { - "connectionName": "str", - "containerName": "str", - "databaseName": "str", - "embeddingConfiguration": { - "embeddingField": "str", - "modelDeploymentName": "str" - }, - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "name": "str", - "type": "CosmosDBNoSqlVectorStore", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "ManagedAzureSearch": - index = { - "name": "str", - "type": "ManagedAzureSearch", - "vectorStoreId": "str", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AzureSearch": - index = { - "connectionName": "str", - "indexName": "str", - "name": "str", - "type": "AzureSearch", - "version": "str", - "description": "str", - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": - index = { - "connectionName": "str", - "containerName": "str", - "databaseName": "str", - "embeddingConfiguration": { - "embeddingField": "str", - "modelDeploymentName": "str" - }, - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "name": "str", - "type": "CosmosDBNoSqlVectorStore", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "ManagedAzureSearch": - index = { - "name": "str", - "type": "ManagedAzureSearch", - "vectorStoreId": "str", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # response body for status code(s): 201, 200 - response == index - """ - - @distributed_trace_async - async def create_or_update( - self, name: str, version: str, index: Union[_types_models2.Index, IO[bytes]], **kwargs: Any - ) -> _types_models2.Index: - """Create a new or update an existing Index with the given version id. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the Index to create or update. Required. - :type version: str - :param index: The Index to create or update. Is either a Index type or a IO[bytes] type. - Required. - :type index: ~azure.ai.agents.types.Index or IO[bytes] - :return: Index - :rtype: ~azure.ai.agents.types.Index - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "type": - - # JSON input template for discriminator value "AzureSearch": - index = { - "connectionName": "str", - "indexName": "str", - "name": "str", - "type": "AzureSearch", - "version": "str", - "description": "str", - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": - index = { - "connectionName": "str", - "containerName": "str", - "databaseName": "str", - "embeddingConfiguration": { - "embeddingField": "str", - "modelDeploymentName": "str" - }, - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "name": "str", - "type": "CosmosDBNoSqlVectorStore", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "ManagedAzureSearch": - index = { - "name": "str", - "type": "ManagedAzureSearch", - "vectorStoreId": "str", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template you can fill out and use as your body input. - index = index - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AzureSearch": - index = { - "connectionName": "str", - "indexName": "str", - "name": "str", - "type": "AzureSearch", - "version": "str", - "description": "str", - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": - index = { - "connectionName": "str", - "containerName": "str", - "databaseName": "str", - "embeddingConfiguration": { - "embeddingField": "str", - "modelDeploymentName": "str" - }, - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "name": "str", - "type": "CosmosDBNoSqlVectorStore", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "ManagedAzureSearch": - index = { - "name": "str", - "type": "ManagedAzureSearch", - "vectorStoreId": "str", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AzureSearch": - index = { - "connectionName": "str", - "indexName": "str", - "name": "str", - "type": "AzureSearch", - "version": "str", - "description": "str", - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": - index = { - "connectionName": "str", - "containerName": "str", - "databaseName": "str", - "embeddingConfiguration": { - "embeddingField": "str", - "modelDeploymentName": "str" - }, - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "name": "str", - "type": "CosmosDBNoSqlVectorStore", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "ManagedAzureSearch": - index = { - "name": "str", - "type": "ManagedAzureSearch", - "vectorStoreId": "str", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # response body for status code(s): 201, 200 - response == index - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models2.Index] = kwargs.pop("cls", None) - - content_type = content_type or "application/merge-patch+json" - _json = None - _content = None - if isinstance(index, (IOBase, bytes)): - _content = index - else: - _json = index - - _request = build_indexes_create_or_update_request( - name=name, - version=version, - content_type=content_type, - api_version=self._config.api_version, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class _AIProjectClientOperationsMixin( - ClientMixinABC[AsyncPipelineClient[HttpRequest, AsyncHttpResponse], AIProjectClientConfiguration] -): - - @distributed_trace_async - async def delete_job(self, job_id: str, **kwargs: Any) -> None: - """Delete a job. Returns 204 No Content. - - :param job_id: The ID of the job to delete. Required. - :type job_id: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_ai_project_delete_job_request( - job_id=job_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models2.ApiErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - -class BetaEvaluationTaxonomiesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.agents.aio.AIProjectClient`'s - :attr:`evaluation_taxonomies` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get( - self, name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], **kwargs: Any - ) -> _types_models2.EvaluationTaxonomy: - """Get an evaluation run by name. - - :param name: The name of the resource. Required. - :type name: str - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW - :return: EvaluationTaxonomy - :rtype: ~azure.ai.agents.types.EvaluationTaxonomy - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "agent": - evaluation_taxonomy_input = { - "riskCategories": [ - "str" - ], - "target": target, - "type": "agent" - } - - # JSON input template for discriminator value "azure_ai_agent": - target = { - "name": "str", - "type": "azure_ai_agent", - "tool_descriptions": [ - { - "description": "str", - "name": "str" - } - ], - "version": "str" - } - - # JSON input template for discriminator value "azure_ai_model": - target = { - "type": "azure_ai_model", - "model": "str", - "sampling_params": { - "max_completion_tokens": 0, - "seed": 0, - "temperature": 0.0, - "top_p": 0.0 - } - } - - # response body for status code(s): 200 - response == { - "name": "str", - "taxonomyInput": evaluation_taxonomy_input, - "version": "str", - "description": "str", - "id": "str", - "properties": { - "str": "str" - }, - "tags": { - "str": "str" - }, - "taxonomyCategories": [ - { - "id": "str", - "name": "str", - "riskCategory": "str", - "subCategories": [ - { - "enabled": bool, - "id": "str", - "name": "str", - "description": "str", - "properties": { - "str": "str" - } - } - ], - "description": "str", - "properties": { - "str": "str" - } - } - ] - } - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_types_models2.EvaluationTaxonomy] = kwargs.pop("cls", None) - - _request = build_beta_evaluation_taxonomies_get_request( - name=name, - foundry_features=foundry_features, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], - input_name: Optional[str] = None, - input_type: Optional[str] = None, - **kwargs: Any - ) -> AsyncItemPaged["_types_models2.EvaluationTaxonomy"]: - """List evaluation taxonomies. - - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW - :keyword input_name: Filter by the evaluation input name. Default value is None. - :paramtype input_name: str - :keyword input_type: Filter by taxonomy input type. Default value is None. - :paramtype input_type: str - :return: An iterator like instance of EvaluationTaxonomy - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.types.EvaluationTaxonomy] - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "agent": - evaluation_taxonomy_input = { - "riskCategories": [ - "str" - ], - "target": target, - "type": "agent" - } - - # JSON input template for discriminator value "azure_ai_agent": - target = { - "name": "str", - "type": "azure_ai_agent", - "tool_descriptions": [ - { - "description": "str", - "name": "str" - } - ], - "version": "str" - } - - # JSON input template for discriminator value "azure_ai_model": - target = { - "type": "azure_ai_model", - "model": "str", - "sampling_params": { - "max_completion_tokens": 0, - "seed": 0, - "temperature": 0.0, - "top_p": 0.0 - } - } - - # response body for status code(s): 200 - response == { - "name": "str", - "taxonomyInput": evaluation_taxonomy_input, - "version": "str", - "description": "str", - "id": "str", - "properties": { - "str": "str" - }, - "tags": { - "str": "str" - }, - "taxonomyCategories": [ - { - "id": "str", - "name": "str", - "riskCategory": "str", - "subCategories": [ - { - "enabled": bool, - "id": "str", - "name": "str", - "description": "str", - "properties": { - "str": "str" - } - } - ], - "description": "str", - "properties": { - "str": "str" - } - } - ] - } - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_types_models2.EvaluationTaxonomy]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_beta_evaluation_taxonomies_list_request( - foundry_features=foundry_features, - input_name=input_name, - input_type=input_type, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized.get("value", []) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def delete( - self, name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], **kwargs: Any - ) -> None: - """Delete an evaluation taxonomy by name. - - :param name: The name of the resource. Required. - :type name: str - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_beta_evaluation_taxonomies_delete_request( - name=name, - foundry_features=foundry_features, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore + return deserialized # type: ignore @overload - async def create( + async def submit_tool_outputs( self, - name: str, - body: _types_models2.EvaluationTaxonomy, + thread_id: str, + run_id: str, *, - foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], content_type: str = "application/json", + tool_outputs: Optional[List[_models.StructuredToolOutput]] = None, + tool_approvals: Optional[List[_models.ToolApproval]] = None, + stream_parameter: Optional[bool] = None, **kwargs: Any - ) -> _types_models2.EvaluationTaxonomy: - """Create an evaluation taxonomy. - - :param name: The name of the evaluation taxonomy. Required. - :type name: str - :param body: The evaluation taxonomy. Required. - :type body: ~azure.ai.agents.types.EvaluationTaxonomy - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + ) -> _models.ThreadRun: + """Submits outputs from tools as requested by tool calls in a run. + + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param run_id: Identifier of the run. Required. + :type run_id: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: EvaluationTaxonomy - :rtype: ~azure.ai.agents.types.EvaluationTaxonomy + :keyword tool_outputs: A list of tools for which the outputs are being submitted. Default value + is None. + :paramtype tool_outputs: list[~azure.ai.agents.models.StructuredToolOutput] + :keyword tool_approvals: A list of tool approvals allowing data to be sent to tools. Default + value is None. + :paramtype tool_approvals: list[~azure.ai.agents.models.ToolApproval] + :keyword stream_parameter: If true, returns a stream of events that happen during the Run as + SSE, terminating at ``[DONE]``. Default value is None. + :paramtype stream_parameter: bool + :return: ThreadRun. The ThreadRun is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadRun :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "type": - - # JSON input template for discriminator value "agent": - evaluation_taxonomy_input = { - "riskCategories": [ - "str" - ], - "target": target, - "type": "agent" - } - - # JSON input template for discriminator value "azure_ai_agent": - target = { - "name": "str", - "type": "azure_ai_agent", - "tool_descriptions": [ - { - "description": "str", - "name": "str" - } - ], - "version": "str" - } - - # JSON input template for discriminator value "azure_ai_model": - target = { - "type": "azure_ai_model", - "model": "str", - "sampling_params": { - "max_completion_tokens": 0, - "seed": 0, - "temperature": 0.0, - "top_p": 0.0 - } - } - - # JSON input template you can fill out and use as your body input. - body = { - "name": "str", - "taxonomyInput": evaluation_taxonomy_input, - "version": "str", - "description": "str", - "id": "str", - "properties": { - "str": "str" - }, - "tags": { - "str": "str" - }, - "taxonomyCategories": [ - { - "id": "str", - "name": "str", - "riskCategory": "str", - "subCategories": [ - { - "enabled": bool, - "id": "str", - "name": "str", - "description": "str", - "properties": { - "str": "str" - } - } - ], - "description": "str", - "properties": { - "str": "str" - } - } - ] - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "agent": - evaluation_taxonomy_input = { - "riskCategories": [ - "str" - ], - "target": target, - "type": "agent" - } - - # JSON input template for discriminator value "azure_ai_agent": - target = { - "name": "str", - "type": "azure_ai_agent", - "tool_descriptions": [ - { - "description": "str", - "name": "str" - } - ], - "version": "str" - } - - # JSON input template for discriminator value "azure_ai_model": - target = { - "type": "azure_ai_model", - "model": "str", - "sampling_params": { - "max_completion_tokens": 0, - "seed": 0, - "temperature": 0.0, - "top_p": 0.0 - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "agent": - evaluation_taxonomy_input = { - "riskCategories": [ - "str" - ], - "target": target, - "type": "agent" - } - - # JSON input template for discriminator value "azure_ai_agent": - target = { - "name": "str", - "type": "azure_ai_agent", - "tool_descriptions": [ - { - "description": "str", - "name": "str" - } - ], - "version": "str" - } - - # JSON input template for discriminator value "azure_ai_model": - target = { - "type": "azure_ai_model", - "model": "str", - "sampling_params": { - "max_completion_tokens": 0, - "seed": 0, - "temperature": 0.0, - "top_p": 0.0 - } - } - - # response body for status code(s): 201, 200 - response == { - "name": "str", - "taxonomyInput": evaluation_taxonomy_input, - "version": "str", - "description": "str", - "id": "str", - "properties": { - "str": "str" - }, - "tags": { - "str": "str" - }, - "taxonomyCategories": [ - { - "id": "str", - "name": "str", - "riskCategory": "str", - "subCategories": [ - { - "enabled": bool, - "id": "str", - "name": "str", - "description": "str", - "properties": { - "str": "str" - } - } - ], - "description": "str", - "properties": { - "str": "str" - } - } - ] - } """ @overload - async def create( - self, - name: str, - body: IO[bytes], - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models2.EvaluationTaxonomy: - """Create an evaluation taxonomy. + async def submit_tool_outputs( + self, thread_id: str, run_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ThreadRun: + """Submits outputs from tools as requested by tool calls in a run. + + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param run_id: Identifier of the run. Required. + :type run_id: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ThreadRun. The ThreadRun is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadRun + :raises ~azure.core.exceptions.HttpResponseError: + """ - :param name: The name of the evaluation taxonomy. Required. - :type name: str - :param body: The evaluation taxonomy. Required. + @overload + async def submit_tool_outputs( + self, thread_id: str, run_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ThreadRun: + """Submits outputs from tools as requested by tool calls in a run. + + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param run_id: Identifier of the run. Required. + :type run_id: str + :param body: Required. :type body: IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: EvaluationTaxonomy - :rtype: ~azure.ai.agents.types.EvaluationTaxonomy + :return: ThreadRun. The ThreadRun is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadRun :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "agent": - evaluation_taxonomy_input = { - "riskCategories": [ - "str" - ], - "target": target, - "type": "agent" - } - - # JSON input template for discriminator value "azure_ai_agent": - target = { - "name": "str", - "type": "azure_ai_agent", - "tool_descriptions": [ - { - "description": "str", - "name": "str" - } - ], - "version": "str" - } - - # JSON input template for discriminator value "azure_ai_model": - target = { - "type": "azure_ai_model", - "model": "str", - "sampling_params": { - "max_completion_tokens": 0, - "seed": 0, - "temperature": 0.0, - "top_p": 0.0 - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "agent": - evaluation_taxonomy_input = { - "riskCategories": [ - "str" - ], - "target": target, - "type": "agent" - } - - # JSON input template for discriminator value "azure_ai_agent": - target = { - "name": "str", - "type": "azure_ai_agent", - "tool_descriptions": [ - { - "description": "str", - "name": "str" - } - ], - "version": "str" - } - - # JSON input template for discriminator value "azure_ai_model": - target = { - "type": "azure_ai_model", - "model": "str", - "sampling_params": { - "max_completion_tokens": 0, - "seed": 0, - "temperature": 0.0, - "top_p": 0.0 - } - } - - # response body for status code(s): 201, 200 - response == { - "name": "str", - "taxonomyInput": evaluation_taxonomy_input, - "version": "str", - "description": "str", - "id": "str", - "properties": { - "str": "str" - }, - "tags": { - "str": "str" - }, - "taxonomyCategories": [ - { - "id": "str", - "name": "str", - "riskCategory": "str", - "subCategories": [ - { - "enabled": bool, - "id": "str", - "name": "str", - "description": "str", - "properties": { - "str": "str" - } - } - ], - "description": "str", - "properties": { - "str": "str" - } - } - ] - } """ @distributed_trace_async - async def create( + async def submit_tool_outputs( self, - name: str, - body: Union[_types_models2.EvaluationTaxonomy, IO[bytes]], + thread_id: str, + run_id: str, + body: Union[JSON, IO[bytes]] = _Unset, *, - foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + tool_outputs: Optional[List[_models.StructuredToolOutput]] = None, + tool_approvals: Optional[List[_models.ToolApproval]] = None, + stream_parameter: Optional[bool] = None, **kwargs: Any - ) -> _types_models2.EvaluationTaxonomy: - """Create an evaluation taxonomy. + ) -> _models.ThreadRun: + """Submits outputs from tools as requested by tool calls in a run. - :param name: The name of the evaluation taxonomy. Required. - :type name: str - :param body: The evaluation taxonomy. Is either a EvaluationTaxonomy type or a IO[bytes] type. - Required. - :type body: ~azure.ai.agents.types.EvaluationTaxonomy or IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW - :return: EvaluationTaxonomy - :rtype: ~azure.ai.agents.types.EvaluationTaxonomy + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param run_id: Identifier of the run. Required. + :type run_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword tool_outputs: A list of tools for which the outputs are being submitted. Default value + is None. + :paramtype tool_outputs: list[~azure.ai.agents.models.StructuredToolOutput] + :keyword tool_approvals: A list of tool approvals allowing data to be sent to tools. Default + value is None. + :paramtype tool_approvals: list[~azure.ai.agents.models.ToolApproval] + :keyword stream_parameter: If true, returns a stream of events that happen during the Run as + SSE, terminating at ``[DONE]``. Default value is None. + :paramtype stream_parameter: bool + :return: ThreadRun. The ThreadRun is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadRun :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "type": - - # JSON input template for discriminator value "agent": - evaluation_taxonomy_input = { - "riskCategories": [ - "str" - ], - "target": target, - "type": "agent" - } - - # JSON input template for discriminator value "azure_ai_agent": - target = { - "name": "str", - "type": "azure_ai_agent", - "tool_descriptions": [ - { - "description": "str", - "name": "str" - } - ], - "version": "str" - } - - # JSON input template for discriminator value "azure_ai_model": - target = { - "type": "azure_ai_model", - "model": "str", - "sampling_params": { - "max_completion_tokens": 0, - "seed": 0, - "temperature": 0.0, - "top_p": 0.0 - } - } - - # JSON input template you can fill out and use as your body input. - body = { - "name": "str", - "taxonomyInput": evaluation_taxonomy_input, - "version": "str", - "description": "str", - "id": "str", - "properties": { - "str": "str" - }, - "tags": { - "str": "str" - }, - "taxonomyCategories": [ - { - "id": "str", - "name": "str", - "riskCategory": "str", - "subCategories": [ - { - "enabled": bool, - "id": "str", - "name": "str", - "description": "str", - "properties": { - "str": "str" - } - } - ], - "description": "str", - "properties": { - "str": "str" - } - } - ] - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "agent": - evaluation_taxonomy_input = { - "riskCategories": [ - "str" - ], - "target": target, - "type": "agent" - } - - # JSON input template for discriminator value "azure_ai_agent": - target = { - "name": "str", - "type": "azure_ai_agent", - "tool_descriptions": [ - { - "description": "str", - "name": "str" - } - ], - "version": "str" - } - - # JSON input template for discriminator value "azure_ai_model": - target = { - "type": "azure_ai_model", - "model": "str", - "sampling_params": { - "max_completion_tokens": 0, - "seed": 0, - "temperature": 0.0, - "top_p": 0.0 - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "agent": - evaluation_taxonomy_input = { - "riskCategories": [ - "str" - ], - "target": target, - "type": "agent" - } - - # JSON input template for discriminator value "azure_ai_agent": - target = { - "name": "str", - "type": "azure_ai_agent", - "tool_descriptions": [ - { - "description": "str", - "name": "str" - } - ], - "version": "str" - } - - # JSON input template for discriminator value "azure_ai_model": - target = { - "type": "azure_ai_model", - "model": "str", - "sampling_params": { - "max_completion_tokens": 0, - "seed": 0, - "temperature": 0.0, - "top_p": 0.0 - } - } - - # response body for status code(s): 201, 200 - response == { - "name": "str", - "taxonomyInput": evaluation_taxonomy_input, - "version": "str", - "description": "str", - "id": "str", - "properties": { - "str": "str" - }, - "tags": { - "str": "str" - }, - "taxonomyCategories": [ - { - "id": "str", - "name": "str", - "riskCategory": "str", - "subCategories": [ - { - "enabled": bool, - "id": "str", - "name": "str", - "description": "str", - "properties": { - "str": "str" - } - } - ], - "description": "str", - "properties": { - "str": "str" - } - } - ] - } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -8499,22 +2047,23 @@ async def create( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models2.EvaluationTaxonomy] = kwargs.pop("cls", None) + cls: ClsType[_models.ThreadRun] = kwargs.pop("cls", None) + if body is _Unset: + body = {"stream": stream_parameter, "tool_approvals": tool_approvals, "tool_outputs": tool_outputs} + body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" - _json = None _content = None if isinstance(body, (IOBase, bytes)): _content = body else: - _json = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_beta_evaluation_taxonomies_create_request( - name=name, - foundry_features=foundry_features, + _request = build_runs_submit_tool_outputs_request( + thread_id=thread_id, + run_id=run_id, content_type=content_type, api_version=self._config.api_version, - json=_json, content=_content, headers=_headers, params=_params, @@ -8524,7 +2073,6 @@ async def create( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -8532,483 +2080,37 @@ async def create( response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200]: if _stream: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.ThreadRun, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - async def update( - self, - name: str, - body: _types_models2.EvaluationTaxonomy, - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models2.EvaluationTaxonomy: - """Update an evaluation taxonomy. - - :param name: The name of the evaluation taxonomy. Required. - :type name: str - :param body: The evaluation taxonomy. Required. - :type body: ~azure.ai.agents.types.EvaluationTaxonomy - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: EvaluationTaxonomy - :rtype: ~azure.ai.agents.types.EvaluationTaxonomy - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "type": - - # JSON input template for discriminator value "agent": - evaluation_taxonomy_input = { - "riskCategories": [ - "str" - ], - "target": target, - "type": "agent" - } - - # JSON input template for discriminator value "azure_ai_agent": - target = { - "name": "str", - "type": "azure_ai_agent", - "tool_descriptions": [ - { - "description": "str", - "name": "str" - } - ], - "version": "str" - } - - # JSON input template for discriminator value "azure_ai_model": - target = { - "type": "azure_ai_model", - "model": "str", - "sampling_params": { - "max_completion_tokens": 0, - "seed": 0, - "temperature": 0.0, - "top_p": 0.0 - } - } - - # JSON input template you can fill out and use as your body input. - body = { - "name": "str", - "taxonomyInput": evaluation_taxonomy_input, - "version": "str", - "description": "str", - "id": "str", - "properties": { - "str": "str" - }, - "tags": { - "str": "str" - }, - "taxonomyCategories": [ - { - "id": "str", - "name": "str", - "riskCategory": "str", - "subCategories": [ - { - "enabled": bool, - "id": "str", - "name": "str", - "description": "str", - "properties": { - "str": "str" - } - } - ], - "description": "str", - "properties": { - "str": "str" - } - } - ] - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "agent": - evaluation_taxonomy_input = { - "riskCategories": [ - "str" - ], - "target": target, - "type": "agent" - } - - # JSON input template for discriminator value "azure_ai_agent": - target = { - "name": "str", - "type": "azure_ai_agent", - "tool_descriptions": [ - { - "description": "str", - "name": "str" - } - ], - "version": "str" - } - - # JSON input template for discriminator value "azure_ai_model": - target = { - "type": "azure_ai_model", - "model": "str", - "sampling_params": { - "max_completion_tokens": 0, - "seed": 0, - "temperature": 0.0, - "top_p": 0.0 - } - } - - # response body for status code(s): 200 - response == { - "name": "str", - "taxonomyInput": evaluation_taxonomy_input, - "version": "str", - "description": "str", - "id": "str", - "properties": { - "str": "str" - }, - "tags": { - "str": "str" - }, - "taxonomyCategories": [ - { - "id": "str", - "name": "str", - "riskCategory": "str", - "subCategories": [ - { - "enabled": bool, - "id": "str", - "name": "str", - "description": "str", - "properties": { - "str": "str" - } - } - ], - "description": "str", - "properties": { - "str": "str" - } - } - ] - } - """ - - @overload - async def update( - self, - name: str, - body: IO[bytes], - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models2.EvaluationTaxonomy: - """Update an evaluation taxonomy. - - :param name: The name of the evaluation taxonomy. Required. - :type name: str - :param body: The evaluation taxonomy. Required. - :type body: IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: EvaluationTaxonomy - :rtype: ~azure.ai.agents.types.EvaluationTaxonomy - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "agent": - evaluation_taxonomy_input = { - "riskCategories": [ - "str" - ], - "target": target, - "type": "agent" - } - - # JSON input template for discriminator value "azure_ai_agent": - target = { - "name": "str", - "type": "azure_ai_agent", - "tool_descriptions": [ - { - "description": "str", - "name": "str" - } - ], - "version": "str" - } - - # JSON input template for discriminator value "azure_ai_model": - target = { - "type": "azure_ai_model", - "model": "str", - "sampling_params": { - "max_completion_tokens": 0, - "seed": 0, - "temperature": 0.0, - "top_p": 0.0 - } - } - - # response body for status code(s): 200 - response == { - "name": "str", - "taxonomyInput": evaluation_taxonomy_input, - "version": "str", - "description": "str", - "id": "str", - "properties": { - "str": "str" - }, - "tags": { - "str": "str" - }, - "taxonomyCategories": [ - { - "id": "str", - "name": "str", - "riskCategory": "str", - "subCategories": [ - { - "enabled": bool, - "id": "str", - "name": "str", - "description": "str", - "properties": { - "str": "str" - } - } - ], - "description": "str", - "properties": { - "str": "str" - } - } - ] - } - """ - @distributed_trace_async - async def update( - self, - name: str, - body: Union[_types_models2.EvaluationTaxonomy, IO[bytes]], - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], - **kwargs: Any - ) -> _types_models2.EvaluationTaxonomy: - """Update an evaluation taxonomy. + async def cancel(self, thread_id: str, run_id: str, **kwargs: Any) -> _models.ThreadRun: + """Cancels a run of an in‐progress thread. - :param name: The name of the evaluation taxonomy. Required. - :type name: str - :param body: The evaluation taxonomy. Is either a EvaluationTaxonomy type or a IO[bytes] type. - Required. - :type body: ~azure.ai.agents.types.EvaluationTaxonomy or IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW - :return: EvaluationTaxonomy - :rtype: ~azure.ai.agents.types.EvaluationTaxonomy + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param run_id: Identifier of the run. Required. + :type run_id: str + :return: ThreadRun. The ThreadRun is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadRun :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "type": - - # JSON input template for discriminator value "agent": - evaluation_taxonomy_input = { - "riskCategories": [ - "str" - ], - "target": target, - "type": "agent" - } - - # JSON input template for discriminator value "azure_ai_agent": - target = { - "name": "str", - "type": "azure_ai_agent", - "tool_descriptions": [ - { - "description": "str", - "name": "str" - } - ], - "version": "str" - } - - # JSON input template for discriminator value "azure_ai_model": - target = { - "type": "azure_ai_model", - "model": "str", - "sampling_params": { - "max_completion_tokens": 0, - "seed": 0, - "temperature": 0.0, - "top_p": 0.0 - } - } - - # JSON input template you can fill out and use as your body input. - body = { - "name": "str", - "taxonomyInput": evaluation_taxonomy_input, - "version": "str", - "description": "str", - "id": "str", - "properties": { - "str": "str" - }, - "tags": { - "str": "str" - }, - "taxonomyCategories": [ - { - "id": "str", - "name": "str", - "riskCategory": "str", - "subCategories": [ - { - "enabled": bool, - "id": "str", - "name": "str", - "description": "str", - "properties": { - "str": "str" - } - } - ], - "description": "str", - "properties": { - "str": "str" - } - } - ] - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "agent": - evaluation_taxonomy_input = { - "riskCategories": [ - "str" - ], - "target": target, - "type": "agent" - } - - # JSON input template for discriminator value "azure_ai_agent": - target = { - "name": "str", - "type": "azure_ai_agent", - "tool_descriptions": [ - { - "description": "str", - "name": "str" - } - ], - "version": "str" - } - - # JSON input template for discriminator value "azure_ai_model": - target = { - "type": "azure_ai_model", - "model": "str", - "sampling_params": { - "max_completion_tokens": 0, - "seed": 0, - "temperature": 0.0, - "top_p": 0.0 - } - } - - # response body for status code(s): 200 - response == { - "name": "str", - "taxonomyInput": evaluation_taxonomy_input, - "version": "str", - "description": "str", - "id": "str", - "properties": { - "str": "str" - }, - "tags": { - "str": "str" - }, - "taxonomyCategories": [ - { - "id": "str", - "name": "str", - "riskCategory": "str", - "subCategories": [ - { - "enabled": bool, - "id": "str", - "name": "str", - "description": "str", - "properties": { - "str": "str" - } - } - ], - "description": "str", - "properties": { - "str": "str" - } - } - ] - } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -9018,27 +2120,15 @@ async def update( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models2.EvaluationTaxonomy] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _json = body + cls: ClsType[_models.ThreadRun] = kwargs.pop("cls", None) - _request = build_beta_evaluation_taxonomies_update_request( - name=name, - foundry_features=foundry_features, - content_type=content_type, + _request = build_runs_cancel_request( + thread_id=thread_id, + run_id=run_id, api_version=self._config.api_version, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -9047,7 +2137,6 @@ async def update( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -9062,15 +2151,13 @@ async def update( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.ThreadRun, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -9078,127 +2165,50 @@ async def update( return deserialized # type: ignore -class BetaEvaluatorsOperations: +class RunStepsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.ai.agents.aio.AIProjectClient`'s - :attr:`evaluators` attribute. + :class:`~azure.ai.agents.aio.AgentsClient`'s + :attr:`run_steps` attribute. """ def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._config: AgentsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_versions( + @distributed_trace_async + async def get( self, - name: str, + thread_id: str, + run_id: str, + step_id: str, *, - foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], - type: Optional[Union[Literal["builtin"], Literal["custom"], Literal["all"], str]] = None, - limit: Optional[int] = None, + include: Optional[List[Union[str, _models.RunAdditionalFieldList]]] = None, **kwargs: Any - ) -> AsyncItemPaged["_types_models2.EvaluatorVersion"]: - """List all versions of the given evaluator. - - :param name: The name of the resource. Required. - :type name: str - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW - :keyword type: Filter evaluators by type. Possible values: 'all', 'custom', 'builtin'. Is one - of the following types: Literal["builtin"], Literal["custom"], Literal["all"], str Default - value is None. - :paramtype type: str or str or str or str - :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and - 100, and the default is 20. Default value is None. - :paramtype limit: int - :return: An iterator like instance of EvaluatorVersion - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.types.EvaluatorVersion] - :raises ~azure.core.exceptions.HttpResponseError: + ) -> _models.RunStep: + """Retrieves a single run step from a thread run. - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "code": - evaluator_definition = { - "code_text": "str", - "type": "code", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # JSON input template for discriminator value "prompt": - evaluator_definition = { - "prompt_text": "str", - "type": "prompt", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # response body for status code(s): 200 - response == { - "categories": [ - "str" - ], - "created_at": "2020-02-20 00:00:00", - "created_by": "str", - "definition": evaluator_definition, - "evaluator_type": "str", - "modified_at": "2020-02-20 00:00:00", - "name": "str", - "version": "str", - "description": "str", - "display_name": "str", - "id": "str", - "metadata": { - "str": "str" - }, - "tags": { - "str": "str" - } - } + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param run_id: Identifier of the run. Required. + :type run_id: str + :param step_id: Identifier of the run step. Required. + :type step_id: str + :keyword 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. Default value is None. + :paramtype include: list[str or ~azure.ai.agents.models.RunAdditionalFieldList] + :return: RunStep. The RunStep is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.RunStep + :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_types_models2.EvaluatorVersion]] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -9207,174 +2217,94 @@ def list_versions( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - _request = build_beta_evaluators_list_versions_request( - name=name, - foundry_features=foundry_features, - type=type, - limit=limit, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - return _request + cls: ClsType[_models.RunStep] = kwargs.pop("cls", None) - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized.get("value", []) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + _request = build_run_steps_get_request( + thread_id=thread_id, + run_id=run_id, + step_id=step_id, + include=include, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - async def get_next(next_link=None): - _request = prepare_request(next_link) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + response = pipeline_response.http_response - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) - return pipeline_response + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.RunStep, response.json()) - return AsyncItemPaged(get_next, extract_data) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @distributed_trace def list( self, + thread_id: str, + run_id: str, *, - foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], - type: Optional[Union[Literal["builtin"], Literal["custom"], Literal["all"], str]] = None, + include: Optional[List[Union[str, _models.RunAdditionalFieldList]]] = None, limit: Optional[int] = None, + order: Optional[Union[str, _models.ListSortOrder]] = None, + before: Optional[str] = None, **kwargs: Any - ) -> AsyncItemPaged["_types_models2.EvaluatorVersion"]: - """List the latest version of each evaluator. - - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW - :keyword type: Filter evaluators by type. Possible values: 'all', 'custom', 'builtin'. Is one - of the following types: Literal["builtin"], Literal["custom"], Literal["all"], str Default - value is None. - :paramtype type: str or str or str or str + ) -> AsyncItemPaged["_models.RunStep"]: + """Gets a list of run steps from a thread run. + + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param run_id: Identifier of the run. Required. + :type run_id: str + :keyword 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. Default value is None. + :paramtype include: list[str or ~azure.ai.agents.models.RunAdditionalFieldList] :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. Default value is None. :paramtype limit: int - :return: An iterator like instance of EvaluatorVersion - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.types.EvaluatorVersion] + :keyword order: Sort order by the created_at timestamp of the objects. asc for ascending order + and desc for descending order. Known values are: "asc" and "desc". Default value is None. + :paramtype order: str or ~azure.ai.agents.models.ListSortOrder + :keyword 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. Default value is None. + :paramtype before: str + :return: An iterator like instance of RunStep + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.models.RunStep] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "code": - evaluator_definition = { - "code_text": "str", - "type": "code", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # JSON input template for discriminator value "prompt": - evaluator_definition = { - "prompt_text": "str", - "type": "prompt", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # response body for status code(s): 200 - response == { - "categories": [ - "str" - ], - "created_at": "2020-02-20 00:00:00", - "created_by": "str", - "definition": evaluator_definition, - "evaluator_type": "str", - "modified_at": "2020-02-20 00:00:00", - "name": "str", - "version": "str", - "description": "str", - "display_name": "str", - "id": "str", - "metadata": { - "str": "str" - }, - "tags": { - "str": "str" - } - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_types_models2.EvaluatorVersion]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.RunStep]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -9384,58 +2314,35 @@ def list( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - _request = build_beta_evaluators_list_request( - foundry_features=foundry_features, - type=type, - limit=limit, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + def prepare_request(_continuation_token=None): + _request = build_run_steps_list_request( + thread_id=thread_id, + run_id=run_id, + include=include, + limit=limit, + order=order, + after=_continuation_token, + before=before, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) return _request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized.get("value", []) + list_of_elem = _deserialize(List[_models.RunStep], deserialized.get("data", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + return deserialized.get("last_id") or None, AsyncList(list_of_elem) - async def get_next(next_link=None): - _request = prepare_request(next_link) + async def get_next(_continuation_token=None): + _request = prepare_request(_continuation_token) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access @@ -9445,105 +2352,43 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) return pipeline_response return AsyncItemPaged(get_next, extract_data) + +class FilesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.agents.aio.AgentsClient`'s + :attr:`files` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AgentsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async - async def get_version( - self, - name: str, - version: str, - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], - **kwargs: Any - ) -> _types_models2.EvaluatorVersion: - """Get the specific version of the EvaluatorVersion. The service returns 404 Not Found error if - the EvaluatorVersion does not exist. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the EvaluatorVersion to retrieve. Required. - :type version: str - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW - :return: EvaluatorVersion - :rtype: ~azure.ai.agents.types.EvaluatorVersion + async def list( + self, *, purpose: Optional[Union[str, _models.FilePurpose]] = None, **kwargs: Any + ) -> _models.FileListResponse: + """Gets a list of previously uploaded files. + + :keyword purpose: The purpose of the file. Known values are: "assistants", "assistants_output", + and "vision". Default value is None. + :paramtype purpose: str or ~azure.ai.agents.models.FilePurpose + :return: FileListResponse. The FileListResponse is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.FileListResponse :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "code": - evaluator_definition = { - "code_text": "str", - "type": "code", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # JSON input template for discriminator value "prompt": - evaluator_definition = { - "prompt_text": "str", - "type": "prompt", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # response body for status code(s): 200 - response == { - "categories": [ - "str" - ], - "created_at": "2020-02-20 00:00:00", - "created_by": "str", - "definition": evaluator_definition, - "evaluator_type": "str", - "modified_at": "2020-02-20 00:00:00", - "name": "str", - "version": "str", - "description": "str", - "display_name": "str", - "id": "str", - "metadata": { - "str": "str" - }, - "tags": { - "str": "str" - } - } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -9556,12 +2401,10 @@ async def get_version( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_types_models2.EvaluatorVersion] = kwargs.pop("cls", None) + cls: ClsType[_models.FileListResponse] = kwargs.pop("cls", None) - _request = build_beta_evaluators_get_version_request( - name=name, - version=version, - foundry_features=foundry_features, + _request = build_files_list_request( + purpose=purpose, api_version=self._config.api_version, headers=_headers, params=_params, @@ -9571,7 +2414,6 @@ async def get_version( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -9586,508 +2428,35 @@ async def get_version( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.FileListResponse, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace_async - async def delete_version( - self, - name: str, - version: str, - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], - **kwargs: Any - ) -> None: - """Delete the specific version of the EvaluatorVersion. The service returns 204 No Content if the - EvaluatorVersion was deleted successfully or if the EvaluatorVersion does not exist. - - :param name: The name of the resource. Required. - :type name: str - :param version: The version of the EvaluatorVersion to delete. Required. - :type version: str - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_beta_evaluators_delete_version_request( - name=name, - version=version, - foundry_features=foundry_features, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @overload - async def create_version( - self, - name: str, - evaluator_version: _types_models2.EvaluatorVersion, - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models2.EvaluatorVersion: - """Create a new EvaluatorVersion with auto incremented version id. - - :param name: The name of the resource. Required. - :type name: str - :param evaluator_version: Required. - :type evaluator_version: ~azure.ai.agents.types.EvaluatorVersion - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: EvaluatorVersion - :rtype: ~azure.ai.agents.types.EvaluatorVersion - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "type": - - # JSON input template for discriminator value "code": - evaluator_definition = { - "code_text": "str", - "type": "code", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # JSON input template for discriminator value "prompt": - evaluator_definition = { - "prompt_text": "str", - "type": "prompt", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # JSON input template you can fill out and use as your body input. - evaluator_version = { - "categories": [ - "str" - ], - "created_at": "2020-02-20 00:00:00", - "created_by": "str", - "definition": evaluator_definition, - "evaluator_type": "str", - "modified_at": "2020-02-20 00:00:00", - "name": "str", - "version": "str", - "description": "str", - "display_name": "str", - "id": "str", - "metadata": { - "str": "str" - }, - "tags": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "code": - evaluator_definition = { - "code_text": "str", - "type": "code", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # JSON input template for discriminator value "prompt": - evaluator_definition = { - "prompt_text": "str", - "type": "prompt", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # response body for status code(s): 201 - response == { - "categories": [ - "str" - ], - "created_at": "2020-02-20 00:00:00", - "created_by": "str", - "definition": evaluator_definition, - "evaluator_type": "str", - "modified_at": "2020-02-20 00:00:00", - "name": "str", - "version": "str", - "description": "str", - "display_name": "str", - "id": "str", - "metadata": { - "str": "str" - }, - "tags": { - "str": "str" - } - } - """ - - @overload - async def create_version( - self, - name: str, - evaluator_version: IO[bytes], - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models2.EvaluatorVersion: - """Create a new EvaluatorVersion with auto incremented version id. - - :param name: The name of the resource. Required. - :type name: str - :param evaluator_version: Required. - :type evaluator_version: IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: EvaluatorVersion - :rtype: ~azure.ai.agents.types.EvaluatorVersion - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "code": - evaluator_definition = { - "code_text": "str", - "type": "code", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # JSON input template for discriminator value "prompt": - evaluator_definition = { - "prompt_text": "str", - "type": "prompt", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # response body for status code(s): 201 - response == { - "categories": [ - "str" - ], - "created_at": "2020-02-20 00:00:00", - "created_by": "str", - "definition": evaluator_definition, - "evaluator_type": "str", - "modified_at": "2020-02-20 00:00:00", - "name": "str", - "version": "str", - "description": "str", - "display_name": "str", - "id": "str", - "metadata": { - "str": "str" - }, - "tags": { - "str": "str" - } - } - """ + @overload + async def _upload_file(self, body: _models._models.UploadFileRequest, **kwargs: Any) -> _models.FileInfo: ... + @overload + async def _upload_file(self, body: JSON, **kwargs: Any) -> _models.FileInfo: ... @distributed_trace_async - async def create_version( - self, - name: str, - evaluator_version: Union[_types_models2.EvaluatorVersion, IO[bytes]], - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], - **kwargs: Any - ) -> _types_models2.EvaluatorVersion: - """Create a new EvaluatorVersion with auto incremented version id. - - :param name: The name of the resource. Required. - :type name: str - :param evaluator_version: Is either a EvaluatorVersion type or a IO[bytes] type. Required. - :type evaluator_version: ~azure.ai.agents.types.EvaluatorVersion or IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW - :return: EvaluatorVersion - :rtype: ~azure.ai.agents.types.EvaluatorVersion + async def _upload_file( + self, body: Union[_models._models.UploadFileRequest, JSON], **kwargs: Any + ) -> _models.FileInfo: + """Uploads a file for use by other operations. + + :param body: Multipart body. Is either a UploadFileRequest type or a JSON type. Required. + :type body: ~azure.ai.agents.models._models.UploadFileRequest or JSON + :return: FileInfo. The FileInfo is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.FileInfo :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "type": - - # JSON input template for discriminator value "code": - evaluator_definition = { - "code_text": "str", - "type": "code", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # JSON input template for discriminator value "prompt": - evaluator_definition = { - "prompt_text": "str", - "type": "prompt", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # JSON input template you can fill out and use as your body input. - evaluator_version = { - "categories": [ - "str" - ], - "created_at": "2020-02-20 00:00:00", - "created_by": "str", - "definition": evaluator_definition, - "evaluator_type": "str", - "modified_at": "2020-02-20 00:00:00", - "name": "str", - "version": "str", - "description": "str", - "display_name": "str", - "id": "str", - "metadata": { - "str": "str" - }, - "tags": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "code": - evaluator_definition = { - "code_text": "str", - "type": "code", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # JSON input template for discriminator value "prompt": - evaluator_definition = { - "prompt_text": "str", - "type": "prompt", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # response body for status code(s): 201 - response == { - "categories": [ - "str" - ], - "created_at": "2020-02-20 00:00:00", - "created_by": "str", - "definition": evaluator_definition, - "evaluator_type": "str", - "modified_at": "2020-02-20 00:00:00", - "name": "str", - "version": "str", - "description": "str", - "display_name": "str", - "id": "str", - "metadata": { - "str": "str" - }, - "tags": { - "str": "str" - } - } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -10097,27 +2466,20 @@ async def create_version( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models2.EvaluatorVersion] = kwargs.pop("cls", None) + cls: ClsType[_models.FileInfo] = kwargs.pop("cls", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(evaluator_version, (IOBase, bytes)): - _content = evaluator_version - else: - _json = evaluator_version + _body = body.as_dict() if isinstance(body, _Model) else body + _file_fields: list[str] = ["file"] + _data_fields: list[str] = ["purpose", "filename"] + _files, _data = prepare_multipart_form_data(_body, _file_fields, _data_fields) - _request = build_beta_evaluators_create_version_request( - name=name, - foundry_features=foundry_features, - content_type=content_type, + _request = build_files_upload_file_request( api_version=self._config.api_version, - json=_json, - content=_content, + files=_files, + data=_data, headers=_headers, params=_params, ) @@ -10126,7 +2488,6 @@ async def create_version( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -10134,462 +2495,35 @@ async def create_version( response = pipeline_response.http_response - if response.status_code not in [201]: + if response.status_code not in [200]: if _stream: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.FileInfo, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - async def update_version( - self, - name: str, - version: str, - evaluator_version: _types_models2.EvaluatorVersion, - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models2.EvaluatorVersion: - """Update an existing EvaluatorVersion with the given version id. - - :param name: The name of the resource. Required. - :type name: str - :param version: The version of the EvaluatorVersion to update. Required. - :type version: str - :param evaluator_version: Evaluator resource. Required. - :type evaluator_version: ~azure.ai.agents.types.EvaluatorVersion - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: EvaluatorVersion - :rtype: ~azure.ai.agents.types.EvaluatorVersion - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "type": - - # JSON input template for discriminator value "code": - evaluator_definition = { - "code_text": "str", - "type": "code", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # JSON input template for discriminator value "prompt": - evaluator_definition = { - "prompt_text": "str", - "type": "prompt", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # JSON input template you can fill out and use as your body input. - evaluator_version = { - "categories": [ - "str" - ], - "created_at": "2020-02-20 00:00:00", - "created_by": "str", - "definition": evaluator_definition, - "evaluator_type": "str", - "modified_at": "2020-02-20 00:00:00", - "name": "str", - "version": "str", - "description": "str", - "display_name": "str", - "id": "str", - "metadata": { - "str": "str" - }, - "tags": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "code": - evaluator_definition = { - "code_text": "str", - "type": "code", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # JSON input template for discriminator value "prompt": - evaluator_definition = { - "prompt_text": "str", - "type": "prompt", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # response body for status code(s): 200 - response == { - "categories": [ - "str" - ], - "created_at": "2020-02-20 00:00:00", - "created_by": "str", - "definition": evaluator_definition, - "evaluator_type": "str", - "modified_at": "2020-02-20 00:00:00", - "name": "str", - "version": "str", - "description": "str", - "display_name": "str", - "id": "str", - "metadata": { - "str": "str" - }, - "tags": { - "str": "str" - } - } - """ - - @overload - async def update_version( - self, - name: str, - version: str, - evaluator_version: IO[bytes], - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models2.EvaluatorVersion: - """Update an existing EvaluatorVersion with the given version id. - - :param name: The name of the resource. Required. - :type name: str - :param version: The version of the EvaluatorVersion to update. Required. - :type version: str - :param evaluator_version: Evaluator resource. Required. - :type evaluator_version: IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: EvaluatorVersion - :rtype: ~azure.ai.agents.types.EvaluatorVersion - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "code": - evaluator_definition = { - "code_text": "str", - "type": "code", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # JSON input template for discriminator value "prompt": - evaluator_definition = { - "prompt_text": "str", - "type": "prompt", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # response body for status code(s): 200 - response == { - "categories": [ - "str" - ], - "created_at": "2020-02-20 00:00:00", - "created_by": "str", - "definition": evaluator_definition, - "evaluator_type": "str", - "modified_at": "2020-02-20 00:00:00", - "name": "str", - "version": "str", - "description": "str", - "display_name": "str", - "id": "str", - "metadata": { - "str": "str" - }, - "tags": { - "str": "str" - } - } - """ - @distributed_trace_async - async def update_version( - self, - name: str, - version: str, - evaluator_version: Union[_types_models2.EvaluatorVersion, IO[bytes]], - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], - **kwargs: Any - ) -> _types_models2.EvaluatorVersion: - """Update an existing EvaluatorVersion with the given version id. - - :param name: The name of the resource. Required. - :type name: str - :param version: The version of the EvaluatorVersion to update. Required. - :type version: str - :param evaluator_version: Evaluator resource. Is either a EvaluatorVersion type or a IO[bytes] - type. Required. - :type evaluator_version: ~azure.ai.agents.types.EvaluatorVersion or IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW - :return: EvaluatorVersion - :rtype: ~azure.ai.agents.types.EvaluatorVersion - :raises ~azure.core.exceptions.HttpResponseError: + async def _delete_file(self, file_id: str, **kwargs: Any) -> _models._models.FileDeletionStatus: + """Delete a previously uploaded file. - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "type": - - # JSON input template for discriminator value "code": - evaluator_definition = { - "code_text": "str", - "type": "code", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # JSON input template for discriminator value "prompt": - evaluator_definition = { - "prompt_text": "str", - "type": "prompt", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # JSON input template you can fill out and use as your body input. - evaluator_version = { - "categories": [ - "str" - ], - "created_at": "2020-02-20 00:00:00", - "created_by": "str", - "definition": evaluator_definition, - "evaluator_type": "str", - "modified_at": "2020-02-20 00:00:00", - "name": "str", - "version": "str", - "description": "str", - "display_name": "str", - "id": "str", - "metadata": { - "str": "str" - }, - "tags": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "code": - evaluator_definition = { - "code_text": "str", - "type": "code", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # JSON input template for discriminator value "prompt": - evaluator_definition = { - "prompt_text": "str", - "type": "prompt", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # response body for status code(s): 200 - response == { - "categories": [ - "str" - ], - "created_at": "2020-02-20 00:00:00", - "created_by": "str", - "definition": evaluator_definition, - "evaluator_type": "str", - "modified_at": "2020-02-20 00:00:00", - "name": "str", - "version": "str", - "description": "str", - "display_name": "str", - "id": "str", - "metadata": { - "str": "str" - }, - "tags": { - "str": "str" - } - } + :param file_id: The ID of the file to delete. Required. + :type file_id: str + :return: FileDeletionStatus. The FileDeletionStatus is compatible with MutableMapping + :rtype: ~azure.ai.agents.models._models.FileDeletionStatus + :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -10599,28 +2533,14 @@ async def update_version( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models2.EvaluatorVersion] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(evaluator_version, (IOBase, bytes)): - _content = evaluator_version - else: - _json = evaluator_version + cls: ClsType[_models._models.FileDeletionStatus] = kwargs.pop("cls", None) - _request = build_beta_evaluators_update_version_request( - name=name, - version=version, - foundry_features=foundry_features, - content_type=content_type, + _request = build_files_delete_file_request( + file_id=file_id, api_version=self._config.api_version, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -10629,7 +2549,6 @@ async def update_version( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -10644,722 +2563,30 @@ async def update_version( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize( + _models._models.FileDeletionStatus, response.json() # pylint: disable=protected-access + ) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - -class BetaInsightsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.agents.aio.AIProjectClient`'s - :attr:`insights` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - async def generate( - self, - insight: _types_models2.Insight, - *, - foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW]] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models2.Insight: - """Generate Insights. - - :param insight: Complete evaluation configuration including data source, evaluators, and result - settings. Required. - :type insight: ~azure.ai.agents.types.Insight - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. INSIGHTS_V1_PREVIEW. Default value is None. - :paramtype foundry_features: str or ~azure.ai.agents.models.INSIGHTS_V1_PREVIEW - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Insight - :rtype: ~azure.ai.agents.types.Insight - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "type": - - # JSON input template for discriminator value "AgentClusterInsight": - insight_request = { - "agentName": "str", - "type": "AgentClusterInsight", - "modelConfiguration": { - "modelDeploymentName": "str" - } - } - - # JSON input template for discriminator value "EvaluationComparison": - insight_request = { - "baselineRunId": "str", - "evalId": "str", - "treatmentRunIds": [ - "str" - ], - "type": "EvaluationComparison" - } - - # JSON input template for discriminator value "EvaluationRunClusterInsight": - insight_request = { - "evalId": "str", - "runIds": [ - "str" - ], - "type": "EvaluationRunClusterInsight", - "modelConfiguration": { - "modelDeploymentName": "str" - } - } - - # JSON input template for discriminator value "AgentClusterInsight": - insight_result = { - "clusterInsight": { - "clusters": [ - { - "description": "str", - "id": "str", - "label": "str", - "suggestion": "str", - "suggestionTitle": "str", - "weight": 0, - "samples": [ - insight_sample - ], - "subClusters": [ - ... - ] - } - ], - "summary": { - "method": "str", - "sampleCount": 0, - "uniqueClusterCount": 0, - "uniqueSubclusterCount": 0, - "usage": { - "inputTokenUsage": 0, - "outputTokenUsage": 0, - "totalTokenUsage": 0 - } - }, - "coordinates": { - "str": { - "size": 0, - "x": 0, - "y": 0 - } - } - }, - "type": "AgentClusterInsight" - } - - # JSON input template for discriminator value "EvaluationComparison": - insight_result = { - "comparisons": [ - { - "baselineRunSummary": { - "average": 0.0, - "runId": "str", - "sampleCount": 0, - "standardDeviation": 0.0 - }, - "compareItems": [ - { - "deltaEstimate": 0.0, - "pValue": 0.0, - "treatmentEffect": "str", - "treatmentRunId": "str", - "treatmentRunSummary": { - "average": 0.0, - "runId": "str", - "sampleCount": 0, - "standardDeviation": 0.0 - } - } - ], - "evaluator": "str", - "metric": "str", - "testingCriteria": "str" - } - ], - "method": "str", - "type": "EvaluationComparison" - } - - # JSON input template you can fill out and use as your body input. - insight = { - "displayName": "str", - "id": "str", - "metadata": { - "createdAt": "2020-02-20 00:00:00", - "completedAt": "2020-02-20 00:00:00" - }, - "request": insight_request, - "state": "str", - "result": insight_result - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AgentClusterInsight": - insight_request = { - "agentName": "str", - "type": "AgentClusterInsight", - "modelConfiguration": { - "modelDeploymentName": "str" - } - } - - # JSON input template for discriminator value "EvaluationComparison": - insight_request = { - "baselineRunId": "str", - "evalId": "str", - "treatmentRunIds": [ - "str" - ], - "type": "EvaluationComparison" - } - - # JSON input template for discriminator value "EvaluationRunClusterInsight": - insight_request = { - "evalId": "str", - "runIds": [ - "str" - ], - "type": "EvaluationRunClusterInsight", - "modelConfiguration": { - "modelDeploymentName": "str" - } - } - - # JSON input template for discriminator value "AgentClusterInsight": - insight_result = { - "clusterInsight": { - "clusters": [ - { - "description": "str", - "id": "str", - "label": "str", - "suggestion": "str", - "suggestionTitle": "str", - "weight": 0, - "samples": [ - insight_sample - ], - "subClusters": [ - ... - ] - } - ], - "summary": { - "method": "str", - "sampleCount": 0, - "uniqueClusterCount": 0, - "uniqueSubclusterCount": 0, - "usage": { - "inputTokenUsage": 0, - "outputTokenUsage": 0, - "totalTokenUsage": 0 - } - }, - "coordinates": { - "str": { - "size": 0, - "x": 0, - "y": 0 - } - } - }, - "type": "AgentClusterInsight" - } - - # JSON input template for discriminator value "EvaluationComparison": - insight_result = { - "comparisons": [ - { - "baselineRunSummary": { - "average": 0.0, - "runId": "str", - "sampleCount": 0, - "standardDeviation": 0.0 - }, - "compareItems": [ - { - "deltaEstimate": 0.0, - "pValue": 0.0, - "treatmentEffect": "str", - "treatmentRunId": "str", - "treatmentRunSummary": { - "average": 0.0, - "runId": "str", - "sampleCount": 0, - "standardDeviation": 0.0 - } - } - ], - "evaluator": "str", - "metric": "str", - "testingCriteria": "str" - } - ], - "method": "str", - "type": "EvaluationComparison" - } - - # response body for status code(s): 201 - response == { - "displayName": "str", - "id": "str", - "metadata": { - "createdAt": "2020-02-20 00:00:00", - "completedAt": "2020-02-20 00:00:00" - }, - "request": insight_request, - "state": "str", - "result": insight_result - } - """ - - @overload - async def generate( - self, - insight: IO[bytes], - *, - foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW]] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models2.Insight: - """Generate Insights. - - :param insight: Complete evaluation configuration including data source, evaluators, and result - settings. Required. - :type insight: IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. INSIGHTS_V1_PREVIEW. Default value is None. - :paramtype foundry_features: str or ~azure.ai.agents.models.INSIGHTS_V1_PREVIEW - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: Insight - :rtype: ~azure.ai.agents.types.Insight - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AgentClusterInsight": - insight_request = { - "agentName": "str", - "type": "AgentClusterInsight", - "modelConfiguration": { - "modelDeploymentName": "str" - } - } - - # JSON input template for discriminator value "EvaluationComparison": - insight_request = { - "baselineRunId": "str", - "evalId": "str", - "treatmentRunIds": [ - "str" - ], - "type": "EvaluationComparison" - } - - # JSON input template for discriminator value "EvaluationRunClusterInsight": - insight_request = { - "evalId": "str", - "runIds": [ - "str" - ], - "type": "EvaluationRunClusterInsight", - "modelConfiguration": { - "modelDeploymentName": "str" - } - } - - # JSON input template for discriminator value "AgentClusterInsight": - insight_result = { - "clusterInsight": { - "clusters": [ - { - "description": "str", - "id": "str", - "label": "str", - "suggestion": "str", - "suggestionTitle": "str", - "weight": 0, - "samples": [ - insight_sample - ], - "subClusters": [ - ... - ] - } - ], - "summary": { - "method": "str", - "sampleCount": 0, - "uniqueClusterCount": 0, - "uniqueSubclusterCount": 0, - "usage": { - "inputTokenUsage": 0, - "outputTokenUsage": 0, - "totalTokenUsage": 0 - } - }, - "coordinates": { - "str": { - "size": 0, - "x": 0, - "y": 0 - } - } - }, - "type": "AgentClusterInsight" - } - - # JSON input template for discriminator value "EvaluationComparison": - insight_result = { - "comparisons": [ - { - "baselineRunSummary": { - "average": 0.0, - "runId": "str", - "sampleCount": 0, - "standardDeviation": 0.0 - }, - "compareItems": [ - { - "deltaEstimate": 0.0, - "pValue": 0.0, - "treatmentEffect": "str", - "treatmentRunId": "str", - "treatmentRunSummary": { - "average": 0.0, - "runId": "str", - "sampleCount": 0, - "standardDeviation": 0.0 - } - } - ], - "evaluator": "str", - "metric": "str", - "testingCriteria": "str" - } - ], - "method": "str", - "type": "EvaluationComparison" - } - - # response body for status code(s): 201 - response == { - "displayName": "str", - "id": "str", - "metadata": { - "createdAt": "2020-02-20 00:00:00", - "completedAt": "2020-02-20 00:00:00" - }, - "request": insight_request, - "state": "str", - "result": insight_result - } - """ - @distributed_trace_async - async def generate( - self, - insight: Union[_types_models2.Insight, IO[bytes]], - *, - foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW]] = None, - **kwargs: Any - ) -> _types_models2.Insight: - """Generate Insights. - - :param insight: Complete evaluation configuration including data source, evaluators, and result - settings. Is either a Insight type or a IO[bytes] type. Required. - :type insight: ~azure.ai.agents.types.Insight or IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. INSIGHTS_V1_PREVIEW. Default value is None. - :paramtype foundry_features: str or ~azure.ai.agents.models.INSIGHTS_V1_PREVIEW - :return: Insight - :rtype: ~azure.ai.agents.types.Insight - :raises ~azure.core.exceptions.HttpResponseError: + async def get(self, file_id: str, **kwargs: Any) -> _models.FileInfo: + """Returns information about a specific file. Does not retrieve file content. - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "type": - - # JSON input template for discriminator value "AgentClusterInsight": - insight_request = { - "agentName": "str", - "type": "AgentClusterInsight", - "modelConfiguration": { - "modelDeploymentName": "str" - } - } - - # JSON input template for discriminator value "EvaluationComparison": - insight_request = { - "baselineRunId": "str", - "evalId": "str", - "treatmentRunIds": [ - "str" - ], - "type": "EvaluationComparison" - } - - # JSON input template for discriminator value "EvaluationRunClusterInsight": - insight_request = { - "evalId": "str", - "runIds": [ - "str" - ], - "type": "EvaluationRunClusterInsight", - "modelConfiguration": { - "modelDeploymentName": "str" - } - } - - # JSON input template for discriminator value "AgentClusterInsight": - insight_result = { - "clusterInsight": { - "clusters": [ - { - "description": "str", - "id": "str", - "label": "str", - "suggestion": "str", - "suggestionTitle": "str", - "weight": 0, - "samples": [ - insight_sample - ], - "subClusters": [ - ... - ] - } - ], - "summary": { - "method": "str", - "sampleCount": 0, - "uniqueClusterCount": 0, - "uniqueSubclusterCount": 0, - "usage": { - "inputTokenUsage": 0, - "outputTokenUsage": 0, - "totalTokenUsage": 0 - } - }, - "coordinates": { - "str": { - "size": 0, - "x": 0, - "y": 0 - } - } - }, - "type": "AgentClusterInsight" - } - - # JSON input template for discriminator value "EvaluationComparison": - insight_result = { - "comparisons": [ - { - "baselineRunSummary": { - "average": 0.0, - "runId": "str", - "sampleCount": 0, - "standardDeviation": 0.0 - }, - "compareItems": [ - { - "deltaEstimate": 0.0, - "pValue": 0.0, - "treatmentEffect": "str", - "treatmentRunId": "str", - "treatmentRunSummary": { - "average": 0.0, - "runId": "str", - "sampleCount": 0, - "standardDeviation": 0.0 - } - } - ], - "evaluator": "str", - "metric": "str", - "testingCriteria": "str" - } - ], - "method": "str", - "type": "EvaluationComparison" - } - - # JSON input template you can fill out and use as your body input. - insight = { - "displayName": "str", - "id": "str", - "metadata": { - "createdAt": "2020-02-20 00:00:00", - "completedAt": "2020-02-20 00:00:00" - }, - "request": insight_request, - "state": "str", - "result": insight_result - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AgentClusterInsight": - insight_request = { - "agentName": "str", - "type": "AgentClusterInsight", - "modelConfiguration": { - "modelDeploymentName": "str" - } - } - - # JSON input template for discriminator value "EvaluationComparison": - insight_request = { - "baselineRunId": "str", - "evalId": "str", - "treatmentRunIds": [ - "str" - ], - "type": "EvaluationComparison" - } - - # JSON input template for discriminator value "EvaluationRunClusterInsight": - insight_request = { - "evalId": "str", - "runIds": [ - "str" - ], - "type": "EvaluationRunClusterInsight", - "modelConfiguration": { - "modelDeploymentName": "str" - } - } - - # JSON input template for discriminator value "AgentClusterInsight": - insight_result = { - "clusterInsight": { - "clusters": [ - { - "description": "str", - "id": "str", - "label": "str", - "suggestion": "str", - "suggestionTitle": "str", - "weight": 0, - "samples": [ - insight_sample - ], - "subClusters": [ - ... - ] - } - ], - "summary": { - "method": "str", - "sampleCount": 0, - "uniqueClusterCount": 0, - "uniqueSubclusterCount": 0, - "usage": { - "inputTokenUsage": 0, - "outputTokenUsage": 0, - "totalTokenUsage": 0 - } - }, - "coordinates": { - "str": { - "size": 0, - "x": 0, - "y": 0 - } - } - }, - "type": "AgentClusterInsight" - } - - # JSON input template for discriminator value "EvaluationComparison": - insight_result = { - "comparisons": [ - { - "baselineRunSummary": { - "average": 0.0, - "runId": "str", - "sampleCount": 0, - "standardDeviation": 0.0 - }, - "compareItems": [ - { - "deltaEstimate": 0.0, - "pValue": 0.0, - "treatmentEffect": "str", - "treatmentRunId": "str", - "treatmentRunSummary": { - "average": 0.0, - "runId": "str", - "sampleCount": 0, - "standardDeviation": 0.0 - } - } - ], - "evaluator": "str", - "metric": "str", - "testingCriteria": "str" - } - ], - "method": "str", - "type": "EvaluationComparison" - } - - # response body for status code(s): 201 - response == { - "displayName": "str", - "id": "str", - "metadata": { - "createdAt": "2020-02-20 00:00:00", - "completedAt": "2020-02-20 00:00:00" - }, - "request": insight_request, - "state": "str", - "result": insight_result - } + :param file_id: The ID of the file to retrieve. Required. + :type file_id: str + :return: FileInfo. The FileInfo is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.FileInfo + :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -11369,26 +2596,14 @@ async def generate( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models2.Insight] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(insight, (IOBase, bytes)): - _content = insight - else: - _json = insight + cls: ClsType[_models.FileInfo] = kwargs.pop("cls", None) - _request = build_beta_insights_generate_request( - foundry_features=foundry_features, - content_type=content_type, + _request = build_files_get_request( + file_id=file_id, api_version=self._config.api_version, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -11397,7 +2612,6 @@ async def generate( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -11405,26 +2619,20 @@ async def generate( response = pipeline_response.http_response - if response.status_code not in [201]: + if response.status_code not in [200]: if _stream: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models2.ApiErrorResponse, - pipeline_response, - ) + error = _failsafe_deserialize(_models.AgentV1Error, response) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.FileInfo, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -11432,151 +2640,14 @@ async def generate( return deserialized # type: ignore @distributed_trace_async - async def get( - self, - id: str, - *, - foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW]] = None, - include_coordinates: Optional[bool] = None, - **kwargs: Any - ) -> _types_models2.Insight: - """Get a specific insight by Id. - - :param id: The unique identifier for the insights report. Required. - :type id: str - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. INSIGHTS_V1_PREVIEW. Default value is None. - :paramtype foundry_features: str or ~azure.ai.agents.models.INSIGHTS_V1_PREVIEW - :keyword include_coordinates: Whether to include coordinates for visualization in the response. - Defaults to false. Default value is None. - :paramtype include_coordinates: bool - :return: Insight - :rtype: ~azure.ai.agents.types.Insight - :raises ~azure.core.exceptions.HttpResponseError: + async def _get_file_content(self, file_id: str, **kwargs: Any) -> AsyncIterator[bytes]: + """Retrieves the raw content of a specific file. - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AgentClusterInsight": - insight_request = { - "agentName": "str", - "type": "AgentClusterInsight", - "modelConfiguration": { - "modelDeploymentName": "str" - } - } - - # JSON input template for discriminator value "EvaluationComparison": - insight_request = { - "baselineRunId": "str", - "evalId": "str", - "treatmentRunIds": [ - "str" - ], - "type": "EvaluationComparison" - } - - # JSON input template for discriminator value "EvaluationRunClusterInsight": - insight_request = { - "evalId": "str", - "runIds": [ - "str" - ], - "type": "EvaluationRunClusterInsight", - "modelConfiguration": { - "modelDeploymentName": "str" - } - } - - # JSON input template for discriminator value "AgentClusterInsight": - insight_result = { - "clusterInsight": { - "clusters": [ - { - "description": "str", - "id": "str", - "label": "str", - "suggestion": "str", - "suggestionTitle": "str", - "weight": 0, - "samples": [ - insight_sample - ], - "subClusters": [ - ... - ] - } - ], - "summary": { - "method": "str", - "sampleCount": 0, - "uniqueClusterCount": 0, - "uniqueSubclusterCount": 0, - "usage": { - "inputTokenUsage": 0, - "outputTokenUsage": 0, - "totalTokenUsage": 0 - } - }, - "coordinates": { - "str": { - "size": 0, - "x": 0, - "y": 0 - } - } - }, - "type": "AgentClusterInsight" - } - - # JSON input template for discriminator value "EvaluationComparison": - insight_result = { - "comparisons": [ - { - "baselineRunSummary": { - "average": 0.0, - "runId": "str", - "sampleCount": 0, - "standardDeviation": 0.0 - }, - "compareItems": [ - { - "deltaEstimate": 0.0, - "pValue": 0.0, - "treatmentEffect": "str", - "treatmentRunId": "str", - "treatmentRunSummary": { - "average": 0.0, - "runId": "str", - "sampleCount": 0, - "standardDeviation": 0.0 - } - } - ], - "evaluator": "str", - "metric": "str", - "testingCriteria": "str" - } - ], - "method": "str", - "type": "EvaluationComparison" - } - - # response body for status code(s): 200 - response == { - "displayName": "str", - "id": "str", - "metadata": { - "createdAt": "2020-02-20 00:00:00", - "completedAt": "2020-02-20 00:00:00" - }, - "request": insight_request, - "state": "str", - "result": insight_result - } + :param file_id: The ID of the file to retrieve. Required. + :type file_id: str + :return: AsyncIterator[bytes] + :rtype: AsyncIterator[bytes] + :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -11589,12 +2660,10 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_types_models2.Insight] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_beta_insights_get_request( - id=id, - foundry_features=foundry_features, - include_coordinates=include_coordinates, + _request = build_files_get_file_content_request( + file_id=file_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -11604,8 +2673,7 @@ async def get( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) + _stream = kwargs.pop("stream", True) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -11619,186 +2687,64 @@ async def get( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models2.ApiErrorResponse, - pipeline_response, - ) + error = _failsafe_deserialize(_models.AgentV1Error, response) raise HttpResponseError(response=response, model=error) - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + +class VectorStoresOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.agents.aio.AgentsClient`'s + :attr:`vector_stores` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AgentsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, *, - foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW]] = None, - type: Optional[types.InsightType] = None, - eval_id: Optional[str] = None, - run_id: Optional[str] = None, - agent_name: Optional[str] = None, - include_coordinates: Optional[bool] = None, + limit: Optional[int] = None, + order: Optional[Union[str, _models.ListSortOrder]] = None, + before: Optional[str] = None, **kwargs: Any - ) -> AsyncItemPaged["_types_models2.Insight"]: - """List all insights in reverse chronological order (newest first). - - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. INSIGHTS_V1_PREVIEW. Default value is None. - :paramtype foundry_features: str or ~azure.ai.agents.models.INSIGHTS_V1_PREVIEW - :keyword type: Filter by the type of analysis. Known values are: "EvaluationRunClusterInsight", - "AgentClusterInsight", and "EvaluationComparison". Default value is None. - :paramtype type: str or ~azure.ai.agents.models.InsightType - :keyword eval_id: Filter by the evaluation ID. Default value is None. - :paramtype eval_id: str - :keyword run_id: Filter by the evaluation run ID. Default value is None. - :paramtype run_id: str - :keyword agent_name: Filter by the agent name. Default value is None. - :paramtype agent_name: str - :keyword include_coordinates: Whether to include coordinates for visualization in the response. - Defaults to false. Default value is None. - :paramtype include_coordinates: bool - :return: An iterator like instance of Insight - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.types.Insight] - :raises ~azure.core.exceptions.HttpResponseError: + ) -> AsyncItemPaged["_models.VectorStore"]: + """Returns a list of vector stores. - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AgentClusterInsight": - insight_request = { - "agentName": "str", - "type": "AgentClusterInsight", - "modelConfiguration": { - "modelDeploymentName": "str" - } - } - - # JSON input template for discriminator value "EvaluationComparison": - insight_request = { - "baselineRunId": "str", - "evalId": "str", - "treatmentRunIds": [ - "str" - ], - "type": "EvaluationComparison" - } - - # JSON input template for discriminator value "EvaluationRunClusterInsight": - insight_request = { - "evalId": "str", - "runIds": [ - "str" - ], - "type": "EvaluationRunClusterInsight", - "modelConfiguration": { - "modelDeploymentName": "str" - } - } - - # JSON input template for discriminator value "AgentClusterInsight": - insight_result = { - "clusterInsight": { - "clusters": [ - { - "description": "str", - "id": "str", - "label": "str", - "suggestion": "str", - "suggestionTitle": "str", - "weight": 0, - "samples": [ - insight_sample - ], - "subClusters": [ - ... - ] - } - ], - "summary": { - "method": "str", - "sampleCount": 0, - "uniqueClusterCount": 0, - "uniqueSubclusterCount": 0, - "usage": { - "inputTokenUsage": 0, - "outputTokenUsage": 0, - "totalTokenUsage": 0 - } - }, - "coordinates": { - "str": { - "size": 0, - "x": 0, - "y": 0 - } - } - }, - "type": "AgentClusterInsight" - } - - # JSON input template for discriminator value "EvaluationComparison": - insight_result = { - "comparisons": [ - { - "baselineRunSummary": { - "average": 0.0, - "runId": "str", - "sampleCount": 0, - "standardDeviation": 0.0 - }, - "compareItems": [ - { - "deltaEstimate": 0.0, - "pValue": 0.0, - "treatmentEffect": "str", - "treatmentRunId": "str", - "treatmentRunSummary": { - "average": 0.0, - "runId": "str", - "sampleCount": 0, - "standardDeviation": 0.0 - } - } - ], - "evaluator": "str", - "metric": "str", - "testingCriteria": "str" - } - ], - "method": "str", - "type": "EvaluationComparison" - } - - # response body for status code(s): 200 - response == { - "displayName": "str", - "id": "str", - "metadata": { - "createdAt": "2020-02-20 00:00:00", - "completedAt": "2020-02-20 00:00:00" - }, - "request": insight_request, - "state": "str", - "result": insight_result - } + :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and + 100, and the default is 20. Default value is None. + :paramtype limit: int + :keyword order: Sort order by the created_at timestamp of the objects. asc for ascending order + and desc for descending order. Known values are: "asc" and "desc". Default value is None. + :paramtype order: str or ~azure.ai.agents.models.ListSortOrder + :keyword 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. Default value is None. + :paramtype before: str + :return: An iterator like instance of VectorStore + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.models.VectorStore] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_types_models2.Insight]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.VectorStore]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -11808,61 +2754,32 @@ def list( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - _request = build_beta_insights_list_request( - foundry_features=foundry_features, - type=type, - eval_id=eval_id, - run_id=run_id, - agent_name=agent_name, - include_coordinates=include_coordinates, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + def prepare_request(_continuation_token=None): + _request = build_vector_stores_list_request( + limit=limit, + order=order, + after=_continuation_token, + before=before, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) return _request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized.get("value", []) + list_of_elem = _deserialize(List[_models.VectorStore], deserialized.get("data", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + return deserialized.get("last_id") or None, AsyncList(list_of_elem) - async def get_next(next_link=None): - _request = prepare_request(next_link) + async def get_next(_continuation_token=None): + _request = prepare_request(_continuation_token) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access @@ -11872,325 +2789,122 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models2.ApiErrorResponse, - pipeline_response, - ) + error = _failsafe_deserialize(_models.AgentV1Error, response) raise HttpResponseError(response=response, model=error) return pipeline_response return AsyncItemPaged(get_next, extract_data) - -class BetaMemoryStoresOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.agents.aio.AIProjectClient`'s - :attr:`memory_stores` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @overload async def create( self, - name: str, - definition: _types_models2.MemoryStoreDefinition, - description: Optional[str] = None, - metadata: Optional[dict[str, str]] = None, *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], content_type: str = "application/json", + file_ids: Optional[List[str]] = None, + name: Optional[str] = None, + store_configuration: Optional[_models.VectorStoreConfiguration] = None, + expires_after: Optional[_models.VectorStoreExpirationPolicy] = None, + chunking_strategy: Optional[_models.VectorStoreChunkingStrategyRequest] = None, + metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> _types_models2.MemoryStoreDetails: - """Create a memory store. - - :param name: The name of the memory store. Required. - :type name: str - :param definition: The memory store definition. Required. - :type definition: ~azure.ai.agents.types.MemoryStoreDefinition - :param description: A human-readable description of the memory store. Default value is None. - :type description: str - :param metadata: Arbitrary key-value metadata to associate with the memory store. Default value - is None. - :type metadata: dict[str, str] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW + ) -> _models.VectorStore: + """Creates a vector store. + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: MemoryStoreDetails - :rtype: ~azure.ai.agents.types.MemoryStoreDetails + :keyword file_ids: A list of file IDs that the vector store should use. Useful for tools like + ``file_search`` that can access files. Default value is None. + :paramtype file_ids: list[str] + :keyword name: The name of the vector store. Default value is None. + :paramtype name: str + :keyword store_configuration: The vector store configuration, used when vector store is created + from Azure asset URIs. Default value is None. + :paramtype store_configuration: ~azure.ai.agents.models.VectorStoreConfiguration + :keyword expires_after: Details on when this vector store expires. Default value is None. + :paramtype expires_after: ~azure.ai.agents.models.VectorStoreExpirationPolicy + :keyword chunking_strategy: 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. Default value is None. + :paramtype chunking_strategy: ~azure.ai.agents.models.VectorStoreChunkingStrategyRequest + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: VectorStore. The VectorStore is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.VectorStore :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "default": - memory_store_definition = { - "chat_model": "str", - "embedding_model": "str", - "kind": "default", - "options": { - "chat_summary_enabled": bool, - "user_profile_enabled": bool, - "user_profile_details": "str" - } - } - - # response body for status code(s): 200 - response == { - "created_at": "2020-02-20 00:00:00", - "definition": memory_store_definition, - "id": "str", - "name": "str", - "object": "str", - "updated_at": "2020-02-20 00:00:00", - "description": "str", - "metadata": { - "str": "str" - } - } """ @overload - async def create( - self, - body: JSON, - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models2.MemoryStoreDetails: - """Create a memory store. + async def create(self, body: JSON, *, content_type: str = "application/json", **kwargs: Any) -> _models.VectorStore: + """Creates a vector store. :param body: Required. :type body: JSON - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: MemoryStoreDetails - :rtype: ~azure.ai.agents.types.MemoryStoreDetails + :return: VectorStore. The VectorStore is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.VectorStore :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "kind": - - # JSON input template for discriminator value "default": - memory_store_definition = { - "chat_model": "str", - "embedding_model": "str", - "kind": "default", - "options": { - "chat_summary_enabled": bool, - "user_profile_enabled": bool, - "user_profile_details": "str" - } - } - - # JSON input template you can fill out and use as your body input. - body = { - "definition": memory_store_definition, - "name": "str", - "description": "str", - "metadata": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "default": - memory_store_definition = { - "chat_model": "str", - "embedding_model": "str", - "kind": "default", - "options": { - "chat_summary_enabled": bool, - "user_profile_enabled": bool, - "user_profile_details": "str" - } - } - - # response body for status code(s): 200 - response == { - "created_at": "2020-02-20 00:00:00", - "definition": memory_store_definition, - "id": "str", - "name": "str", - "object": "str", - "updated_at": "2020-02-20 00:00:00", - "description": "str", - "metadata": { - "str": "str" - } - } """ @overload async def create( - self, - body: IO[bytes], - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models2.MemoryStoreDetails: - """Create a memory store. + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.VectorStore: + """Creates a vector store. :param body: Required. :type body: IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: MemoryStoreDetails - :rtype: ~azure.ai.agents.types.MemoryStoreDetails + :return: VectorStore. The VectorStore is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.VectorStore :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "default": - memory_store_definition = { - "chat_model": "str", - "embedding_model": "str", - "kind": "default", - "options": { - "chat_summary_enabled": bool, - "user_profile_enabled": bool, - "user_profile_details": "str" - } - } - - # response body for status code(s): 200 - response == { - "created_at": "2020-02-20 00:00:00", - "definition": memory_store_definition, - "id": "str", - "name": "str", - "object": "str", - "updated_at": "2020-02-20 00:00:00", - "description": "str", - "metadata": { - "str": "str" - } - } """ @distributed_trace_async async def create( self, - name: str = _Unset, - definition: _types_models2.MemoryStoreDefinition = _Unset, body: Union[JSON, IO[bytes]] = _Unset, - description: Optional[str] = None, - metadata: Optional[dict[str, str]] = None, *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + file_ids: Optional[List[str]] = None, + name: Optional[str] = None, + store_configuration: Optional[_models.VectorStoreConfiguration] = None, + expires_after: Optional[_models.VectorStoreExpirationPolicy] = None, + chunking_strategy: Optional[_models.VectorStoreChunkingStrategyRequest] = None, + metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> _types_models2.MemoryStoreDetails: - """Create a memory store. + ) -> _models.VectorStore: + """Creates a vector store. - :param name: The name of the memory store. Required. - :type name: str - :param definition: The memory store definition. Required. - :type definition: ~azure.ai.agents.types.MemoryStoreDefinition :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :param description: A human-readable description of the memory store. Default value is None. - :type description: str - :param metadata: Arbitrary key-value metadata to associate with the memory store. Default value - is None. - :type metadata: dict[str, str] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW - :return: MemoryStoreDetails - :rtype: ~azure.ai.agents.types.MemoryStoreDetails + :keyword file_ids: A list of file IDs that the vector store should use. Useful for tools like + ``file_search`` that can access files. Default value is None. + :paramtype file_ids: list[str] + :keyword name: The name of the vector store. Default value is None. + :paramtype name: str + :keyword store_configuration: The vector store configuration, used when vector store is created + from Azure asset URIs. Default value is None. + :paramtype store_configuration: ~azure.ai.agents.models.VectorStoreConfiguration + :keyword expires_after: Details on when this vector store expires. Default value is None. + :paramtype expires_after: ~azure.ai.agents.models.VectorStoreExpirationPolicy + :keyword chunking_strategy: 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. Default value is None. + :paramtype chunking_strategy: ~azure.ai.agents.models.VectorStoreChunkingStrategyRequest + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: VectorStore. The VectorStore is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.VectorStore :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "kind": - - # JSON input template for discriminator value "default": - memory_store_definition = { - "chat_model": "str", - "embedding_model": "str", - "kind": "default", - "options": { - "chat_summary_enabled": bool, - "user_profile_enabled": bool, - "user_profile_details": "str" - } - } - - # JSON input template you can fill out and use as your body input. - body = { - "definition": memory_store_definition, - "name": "str", - "description": "str", - "metadata": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "default": - memory_store_definition = { - "chat_model": "str", - "embedding_model": "str", - "kind": "default", - "options": { - "chat_summary_enabled": bool, - "user_profile_enabled": bool, - "user_profile_details": "str" - } - } - - # response body for status code(s): 200 - response == { - "created_at": "2020-02-20 00:00:00", - "definition": memory_store_definition, - "id": "str", - "name": "str", - "object": "str", - "updated_at": "2020-02-20 00:00:00", - "description": "str", - "metadata": { - "str": "str" - } - } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -12204,28 +2918,28 @@ async def create( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models2.MemoryStoreDetails] = kwargs.pop("cls", None) + cls: ClsType[_models.VectorStore] = kwargs.pop("cls", None) if body is _Unset: - if name is _Unset: - raise TypeError("missing required argument: name") - if definition is _Unset: - raise TypeError("missing required argument: definition") - body = {"definition": definition, "description": description, "metadata": metadata, "name": name} + body = { + "chunking_strategy": chunking_strategy, + "configuration": store_configuration, + "expires_after": expires_after, + "file_ids": file_ids, + "metadata": metadata, + "name": name, + } body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" - _json = None _content = None if isinstance(body, (IOBase, bytes)): _content = body else: - _json = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_beta_memory_stores_create_request( - foundry_features=foundry_features, + _request = build_vector_stores_create_request( content_type=content_type, api_version=self._config.api_version, - json=_json, content=_content, headers=_headers, params=_params, @@ -12235,7 +2949,6 @@ async def create( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -12250,19 +2963,74 @@ async def create( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models2.ApiErrorResponse, - pipeline_response, - ) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.VectorStore, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get(self, vector_store_id: str, **kwargs: Any) -> _models.VectorStore: + """Returns the vector store object matching the specified ID. + + :param vector_store_id: Identifier of the vector store. Required. + :type vector_store_id: str + :return: VectorStore. The VectorStore is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.VectorStore + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.VectorStore] = kwargs.pop("cls", None) + + _request = build_vector_stores_get_request( + vector_store_id=vector_store_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.AgentV1Error, response) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.VectorStore, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -12270,262 +3038,102 @@ async def create( return deserialized # type: ignore @overload - async def update( + async def modify( self, - name: str, - description: Optional[str] = None, - metadata: Optional[dict[str, str]] = None, + vector_store_id: str, *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], content_type: str = "application/json", + name: Optional[str] = None, + expires_after: Optional[_models.VectorStoreExpirationPolicy] = None, + metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> _types_models2.MemoryStoreDetails: - """Update a memory store. - - :param name: The name of the memory store to update. Required. - :type name: str - :param description: A human-readable description of the memory store. Default value is None. - :type description: str - :param metadata: Arbitrary key-value metadata to associate with the memory store. Default value - is None. - :type metadata: dict[str, str] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW + ) -> _models.VectorStore: + """Modifies an existing vector store. + + :param vector_store_id: Identifier of the vector store. Required. + :type vector_store_id: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: MemoryStoreDetails - :rtype: ~azure.ai.agents.types.MemoryStoreDetails + :keyword name: The name of the vector store. Default value is None. + :paramtype name: str + :keyword expires_after: Details on when this vector store expires. Default value is None. + :paramtype expires_after: ~azure.ai.agents.models.VectorStoreExpirationPolicy + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: VectorStore. The VectorStore is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.VectorStore :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "default": - memory_store_definition = { - "chat_model": "str", - "embedding_model": "str", - "kind": "default", - "options": { - "chat_summary_enabled": bool, - "user_profile_enabled": bool, - "user_profile_details": "str" - } - } - - # response body for status code(s): 200 - response == { - "created_at": "2020-02-20 00:00:00", - "definition": memory_store_definition, - "id": "str", - "name": "str", - "object": "str", - "updated_at": "2020-02-20 00:00:00", - "description": "str", - "metadata": { - "str": "str" - } - } """ @overload - async def update( - self, - name: str, - body: JSON, - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models2.MemoryStoreDetails: - """Update a memory store. + async def modify( + self, vector_store_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.VectorStore: + """Modifies an existing vector store. - :param name: The name of the memory store to update. Required. - :type name: str + :param vector_store_id: Identifier of the vector store. Required. + :type vector_store_id: str :param body: Required. :type body: JSON - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: MemoryStoreDetails - :rtype: ~azure.ai.agents.types.MemoryStoreDetails + :return: VectorStore. The VectorStore is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.VectorStore :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "description": "str", - "metadata": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "default": - memory_store_definition = { - "chat_model": "str", - "embedding_model": "str", - "kind": "default", - "options": { - "chat_summary_enabled": bool, - "user_profile_enabled": bool, - "user_profile_details": "str" - } - } - - # response body for status code(s): 200 - response == { - "created_at": "2020-02-20 00:00:00", - "definition": memory_store_definition, - "id": "str", - "name": "str", - "object": "str", - "updated_at": "2020-02-20 00:00:00", - "description": "str", - "metadata": { - "str": "str" - } - } """ @overload - async def update( - self, - name: str, - body: IO[bytes], - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models2.MemoryStoreDetails: - """Update a memory store. + async def modify( + self, vector_store_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.VectorStore: + """Modifies an existing vector store. - :param name: The name of the memory store to update. Required. - :type name: str + :param vector_store_id: Identifier of the vector store. Required. + :type vector_store_id: str :param body: Required. :type body: IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: MemoryStoreDetails - :rtype: ~azure.ai.agents.types.MemoryStoreDetails + :return: VectorStore. The VectorStore is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.VectorStore :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "default": - memory_store_definition = { - "chat_model": "str", - "embedding_model": "str", - "kind": "default", - "options": { - "chat_summary_enabled": bool, - "user_profile_enabled": bool, - "user_profile_details": "str" - } - } - - # response body for status code(s): 200 - response == { - "created_at": "2020-02-20 00:00:00", - "definition": memory_store_definition, - "id": "str", - "name": "str", - "object": "str", - "updated_at": "2020-02-20 00:00:00", - "description": "str", - "metadata": { - "str": "str" - } - } """ @distributed_trace_async - async def update( + async def modify( self, - name: str, + vector_store_id: str, body: Union[JSON, IO[bytes]] = _Unset, - description: Optional[str] = None, - metadata: Optional[dict[str, str]] = None, *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + name: Optional[str] = None, + expires_after: Optional[_models.VectorStoreExpirationPolicy] = None, + metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> _types_models2.MemoryStoreDetails: - """Update a memory store. + ) -> _models.VectorStore: + """Modifies an existing vector store. - :param name: The name of the memory store to update. Required. - :type name: str + :param vector_store_id: Identifier of the vector store. Required. + :type vector_store_id: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :param description: A human-readable description of the memory store. Default value is None. - :type description: str - :param metadata: Arbitrary key-value metadata to associate with the memory store. Default value - is None. - :type metadata: dict[str, str] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW - :return: MemoryStoreDetails - :rtype: ~azure.ai.agents.types.MemoryStoreDetails + :keyword name: The name of the vector store. Default value is None. + :paramtype name: str + :keyword expires_after: Details on when this vector store expires. Default value is None. + :paramtype expires_after: ~azure.ai.agents.models.VectorStoreExpirationPolicy + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: VectorStore. The VectorStore is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.VectorStore :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "description": "str", - "metadata": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "default": - memory_store_definition = { - "chat_model": "str", - "embedding_model": "str", - "kind": "default", - "options": { - "chat_summary_enabled": bool, - "user_profile_enabled": bool, - "user_profile_details": "str" - } - } - - # response body for status code(s): 200 - response == { - "created_at": "2020-02-20 00:00:00", - "definition": memory_store_definition, - "id": "str", - "name": "str", - "object": "str", - "updated_at": "2020-02-20 00:00:00", - "description": "str", - "metadata": { - "str": "str" - } - } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -12539,25 +3147,22 @@ async def update( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models2.MemoryStoreDetails] = kwargs.pop("cls", None) + cls: ClsType[_models.VectorStore] = kwargs.pop("cls", None) if body is _Unset: - body = {"description": description, "metadata": metadata} + body = {"expires_after": expires_after, "metadata": metadata, "name": name} body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" - _json = None _content = None if isinstance(body, (IOBase, bytes)): _content = body else: - _json = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_beta_memory_stores_update_request( - name=name, - foundry_features=foundry_features, + _request = build_vector_stores_modify_request( + vector_store_id=vector_store_id, content_type=content_type, api_version=self._config.api_version, - json=_json, content=_content, headers=_headers, params=_params, @@ -12567,7 +3172,6 @@ async def update( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -12582,19 +3186,13 @@ async def update( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models2.ApiErrorResponse, - pipeline_response, - ) + error = _failsafe_deserialize(_models.AgentV1Error, response) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.VectorStore, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -12602,51 +3200,17 @@ async def update( return deserialized # type: ignore @distributed_trace_async - async def get( - self, name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], **kwargs: Any - ) -> _types_models2.MemoryStoreDetails: - """Retrieve a memory store. - - :param name: The name of the memory store to retrieve. Required. - :type name: str - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW - :return: MemoryStoreDetails - :rtype: ~azure.ai.agents.types.MemoryStoreDetails + async def _delete_vector_store( + self, vector_store_id: str, **kwargs: Any + ) -> _models._models.VectorStoreDeletionStatus: + """Deletes the vector store object matching the specified ID. + + :param vector_store_id: Identifier of the vector store. Required. + :type vector_store_id: str + :return: VectorStoreDeletionStatus. The VectorStoreDeletionStatus is compatible with + MutableMapping + :rtype: ~azure.ai.agents.models._models.VectorStoreDeletionStatus :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "default": - memory_store_definition = { - "chat_model": "str", - "embedding_model": "str", - "kind": "default", - "options": { - "chat_summary_enabled": bool, - "user_profile_enabled": bool, - "user_profile_details": "str" - } - } - - # response body for status code(s): 200 - response == { - "created_at": "2020-02-20 00:00:00", - "definition": memory_store_definition, - "id": "str", - "name": "str", - "object": "str", - "updated_at": "2020-02-20 00:00:00", - "description": "str", - "metadata": { - "str": "str" - } - } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -12659,11 +3223,10 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_types_models2.MemoryStoreDetails] = kwargs.pop("cls", None) + cls: ClsType[_models._models.VectorStoreDeletionStatus] = kwargs.pop("cls", None) - _request = build_beta_memory_stores_get_request( - name=name, - foundry_features=foundry_features, + _request = build_vector_stores_delete_vector_store_request( + vector_store_id=vector_store_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -12673,7 +3236,6 @@ async def get( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -12688,94 +3250,76 @@ async def get( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models2.ApiErrorResponse, - pipeline_response, - ) + error = _failsafe_deserialize(_models.AgentV1Error, response) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize( + _models._models.VectorStoreDeletionStatus, response.json() # pylint: disable=protected-access + ) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + +class VectorStoreFilesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.agents.aio.AgentsClient`'s + :attr:`vector_store_files` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AgentsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, + vector_store_id: str, *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + filter: Optional[Union[str, _models.VectorStoreFileStatusFilter]] = None, limit: Optional[int] = None, - order: Optional[types.PageOrder] = None, + order: Optional[Union[str, _models.ListSortOrder]] = None, before: Optional[str] = None, **kwargs: Any - ) -> AsyncItemPaged["_types_models2.MemoryStoreDetails"]: - """List all memory stores. - - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW + ) -> AsyncItemPaged["_models.VectorStoreFile"]: + """Returns a list of vector store files. + + :param vector_store_id: Identifier of the vector store. Required. + :type vector_store_id: str + :keyword filter: Filter by file status. Known values are: "in_progress", "completed", "failed", + and "cancelled". Default value is None. + :paramtype filter: str or ~azure.ai.agents.models.VectorStoreFileStatusFilter :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and - 100, and the - default is 20. Default value is None. + 100, and the default is 20. Default value is None. :paramtype limit: int - :keyword order: Sort order by the ``created_at`` timestamp of the objects. ``asc`` for - ascending order and``desc`` - for descending order. Known values are: "asc" and "desc". Default value is None. - :paramtype order: str or ~azure.ai.agents.models.PageOrder - :keyword 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. - Default value is None. + :keyword order: Sort order by the created_at timestamp of the objects. asc for ascending order + and desc for descending order. Known values are: "asc" and "desc". Default value is None. + :paramtype order: str or ~azure.ai.agents.models.ListSortOrder + :keyword 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. Default value is None. :paramtype before: str - :return: An iterator like instance of MemoryStoreDetails - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.types.MemoryStoreDetails] + :return: An iterator like instance of VectorStoreFile + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.models.VectorStoreFile] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "default": - memory_store_definition = { - "chat_model": "str", - "embedding_model": "str", - "kind": "default", - "options": { - "chat_summary_enabled": bool, - "user_profile_enabled": bool, - "user_profile_details": "str" - } - } - - # response body for status code(s): 200 - response == { - "created_at": "2020-02-20 00:00:00", - "definition": memory_store_definition, - "id": "str", - "name": "str", - "object": "str", - "updated_at": "2020-02-20 00:00:00", - "description": "str", - "metadata": { - "str": "str" - } - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_types_models2.MemoryStoreDetails]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.VectorStoreFile]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -12787,8 +3331,9 @@ def list( def prepare_request(_continuation_token=None): - _request = build_beta_memory_stores_list_request( - foundry_features=foundry_features, + _request = build_vector_store_files_list_request( + vector_store_id=vector_store_id, + filter=filter, limit=limit, order=order, after=_continuation_token, @@ -12805,7 +3350,7 @@ def prepare_request(_continuation_token=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized.get("data", []) + list_of_elem = _deserialize(List[_models.VectorStoreFile], deserialized.get("data", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("last_id") or None, AsyncList(list_of_elem) @@ -12821,40 +3366,106 @@ async def get_next(_continuation_token=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models2.ApiErrorResponse, - pipeline_response, - ) + error = _failsafe_deserialize(_models.AgentV1Error, response) raise HttpResponseError(response=response, model=error) return pipeline_response return AsyncItemPaged(get_next, extract_data) - @distributed_trace_async - async def delete( - self, name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], **kwargs: Any - ) -> _types_models2.DeleteMemoryStoreResult: - """Delete a memory store. - - :param name: The name of the memory store to delete. Required. - :type name: str - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW - :return: DeleteMemoryStoreResult - :rtype: ~azure.ai.agents.types.DeleteMemoryStoreResult + @overload + async def create( + self, + vector_store_id: str, + *, + content_type: str = "application/json", + file_id: Optional[str] = None, + data_source: Optional[_models.VectorStoreDataSource] = None, + chunking_strategy: Optional[_models.VectorStoreChunkingStrategyRequest] = None, + **kwargs: Any + ) -> _models.VectorStoreFile: + """Create a vector store file by attaching a file to a vector store. + + :param vector_store_id: Identifier of the vector store. Required. + :type vector_store_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword file_id: Identifier of the file. Default value is None. + :paramtype file_id: str + :keyword data_source: Azure asset ID. Default value is None. + :paramtype data_source: ~azure.ai.agents.models.VectorStoreDataSource + :keyword chunking_strategy: The chunking strategy used to chunk the file. If not set, uses the + auto strategy. Default value is None. + :paramtype chunking_strategy: ~azure.ai.agents.models.VectorStoreChunkingStrategyRequest + :return: VectorStoreFile. The VectorStoreFile is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.VectorStoreFile + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, vector_store_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.VectorStoreFile: + """Create a vector store file by attaching a file to a vector store. + + :param vector_store_id: Identifier of the vector store. Required. + :type vector_store_id: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: VectorStoreFile. The VectorStoreFile is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.VectorStoreFile + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, vector_store_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.VectorStoreFile: + """Create a vector store file by attaching a file to a vector store. + + :param vector_store_id: Identifier of the vector store. Required. + :type vector_store_id: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: VectorStoreFile. The VectorStoreFile is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.VectorStoreFile :raises ~azure.core.exceptions.HttpResponseError: + """ - Example: - .. code-block:: python + @distributed_trace_async + async def create( + self, + vector_store_id: str, + body: Union[JSON, IO[bytes]] = _Unset, + *, + file_id: Optional[str] = None, + data_source: Optional[_models.VectorStoreDataSource] = None, + chunking_strategy: Optional[_models.VectorStoreChunkingStrategyRequest] = None, + **kwargs: Any + ) -> _models.VectorStoreFile: + """Create a vector store file by attaching a file to a vector store. - # response body for status code(s): 200 - response == { - "deleted": bool, - "name": "str", - "object": "str" - } + :param vector_store_id: Identifier of the vector store. Required. + :type vector_store_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword file_id: Identifier of the file. Default value is None. + :paramtype file_id: str + :keyword data_source: Azure asset ID. Default value is None. + :paramtype data_source: ~azure.ai.agents.models.VectorStoreDataSource + :keyword chunking_strategy: The chunking strategy used to chunk the file. If not set, uses the + auto strategy. Default value is None. + :paramtype chunking_strategy: ~azure.ai.agents.models.VectorStoreChunkingStrategyRequest + :return: VectorStoreFile. The VectorStoreFile is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.VectorStoreFile + :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -12864,15 +3475,27 @@ async def delete( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_types_models2.DeleteMemoryStoreResult] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VectorStoreFile] = kwargs.pop("cls", None) + + if body is _Unset: + body = {"chunking_strategy": chunking_strategy, "data_source": data_source, "file_id": file_id} + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_beta_memory_stores_delete_request( - name=name, - foundry_features=foundry_features, + _request = build_vector_store_files_create_request( + vector_store_id=vector_store_id, + content_type=content_type, api_version=self._config.api_version, + content=_content, headers=_headers, params=_params, ) @@ -12881,7 +3504,6 @@ async def delete( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -12896,133 +3518,30 @@ async def delete( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models2.ApiErrorResponse, - pipeline_response, - ) + error = _failsafe_deserialize(_models.AgentV1Error, response) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.VectorStoreFile, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - async def _search_memories( - self, - name: str, - scope: str, - items: Optional[List[dict[str, Any]]] = None, - previous_search_id: Optional[str] = None, - options: Optional[_types_models2.MemorySearchOptions] = None, - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models2.MemoryStoreSearchResult: ... - @overload - async def _search_memories( - self, - name: str, - body: JSON, - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models2.MemoryStoreSearchResult: ... - @overload - async def _search_memories( - self, - name: str, - body: IO[bytes], - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models2.MemoryStoreSearchResult: ... - @distributed_trace_async - async def _search_memories( - self, - name: str, - scope: str = _Unset, - body: Union[JSON, IO[bytes]] = _Unset, - items: Optional[List[dict[str, Any]]] = None, - previous_search_id: Optional[str] = None, - options: Optional[_types_models2.MemorySearchOptions] = None, - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], - **kwargs: Any - ) -> _types_models2.MemoryStoreSearchResult: - """Search for relevant memories from a memory store based on conversation context. - - :param name: The name of the memory store to search. Required. - :type name: str - :param scope: The namespace that logically groups and isolates memories, such as a user ID. - Required. - :type scope: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :param items: Items for which to search for relevant memories. Default value is None. - :type items: list[dict[str, any]] - :param previous_search_id: The unique ID of the previous search request, enabling incremental - memory search from where the last operation left off. Default value is None. - :type previous_search_id: str - :param options: Memory search options. Default value is None. - :type options: ~azure.ai.agents.types.MemorySearchOptions - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW - :return: MemoryStoreSearchResult - :rtype: ~azure.ai.agents.types.MemoryStoreSearchResult + async def get(self, vector_store_id: str, file_id: str, **kwargs: Any) -> _models.VectorStoreFile: + """Retrieves a vector store file. + + :param vector_store_id: Identifier of the vector store. Required. + :type vector_store_id: str + :param file_id: Identifier of the file. Required. + :type file_id: str + :return: VectorStoreFile. The VectorStoreFile is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.VectorStoreFile :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "scope": "str", - "items": [ - { - "str": {} - } - ], - "options": { - "max_memories": 0 - }, - "previous_search_id": "str" - } - - # response body for status code(s): 200 - response == { - "memories": [ - { - "memory_item": memory_item - } - ], - "search_id": "str", - "usage": { - "embedding_tokens": 0, - "input_tokens": 0, - "input_tokens_details": { - "cached_tokens": 0 - }, - "output_tokens": 0, - "output_tokens_details": { - "reasoning_tokens": 0 - }, - "total_tokens": 0 - } - } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -13032,32 +3551,15 @@ async def _search_memories( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models2.MemoryStoreSearchResult] = kwargs.pop("cls", None) - - if body is _Unset: - if scope is _Unset: - raise TypeError("missing required argument: scope") - body = {"items": items, "options": options, "previous_search_id": previous_search_id, "scope": scope} - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _json = body + cls: ClsType[_models.VectorStoreFile] = kwargs.pop("cls", None) - _request = build_beta_memory_stores_search_memories_request( - name=name, - foundry_features=foundry_features, - content_type=content_type, + _request = build_vector_store_files_get_request( + vector_store_id=vector_store_id, + file_id=file_id, api_version=self._config.api_version, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -13066,7 +3568,6 @@ async def _search_memories( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -13081,37 +3582,35 @@ async def _search_memories( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models2.ApiErrorResponse, - pipeline_response, - ) + error = _failsafe_deserialize(_models.AgentV1Error, response) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.VectorStoreFile, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - async def _update_memories_initial( - self, - name: str, - scope: str = _Unset, - body: Union[JSON, IO[bytes]] = _Unset, - items: Optional[List[dict[str, Any]]] = None, - previous_update_id: Optional[str] = None, - update_delay: Optional[int] = None, - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], - **kwargs: Any - ) -> AsyncIterator[bytes]: + @distributed_trace_async + async def _delete_vector_store_file( + self, vector_store_id: str, file_id: str, **kwargs: Any + ) -> _models._models.VectorStoreFileDeletionStatus: + """Deletes a vector store file. This removes the file‐to‐store link (does not delete the file + itself). + + :param vector_store_id: Identifier of the vector store. Required. + :type vector_store_id: str + :param file_id: Identifier of the file. Required. + :type file_id: str + :return: VectorStoreFileDeletionStatus. The VectorStoreFileDeletionStatus is compatible with + MutableMapping + :rtype: ~azure.ai.agents.models._models.VectorStoreFileDeletionStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -13120,37 +3619,15 @@ async def _update_memories_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - if body is _Unset: - if scope is _Unset: - raise TypeError("missing required argument: scope") - body = { - "items": items, - "previous_update_id": previous_update_id, - "scope": scope, - "update_delay": update_delay, - } - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _json = body + cls: ClsType[_models._models.VectorStoreFileDeletionStatus] = kwargs.pop("cls", None) - _request = build_beta_memory_stores_update_memories_request( - name=name, - foundry_features=foundry_features, - content_type=content_type, + _request = build_vector_store_files_delete_vector_store_file_request( + vector_store_id=vector_store_id, + file_id=file_id, api_version=self._config.api_version, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -13159,374 +3636,146 @@ async def _update_memories_initial( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models2.ApiErrorResponse, - pipeline_response, - ) + error = _failsafe_deserialize(_models.AgentV1Error, response) raise HttpResponseError(response=response, model=error) - response_headers = {} - response_headers["Operation-Location"] = self._deserialize("str", response.headers.get("Operation-Location")) - - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize( + _models._models.VectorStoreFileDeletionStatus, response.json() # pylint: disable=protected-access + ) if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - async def _begin_update_memories( - self, - name: str, - scope: str, - items: Optional[List[dict[str, Any]]] = None, - previous_update_id: Optional[str] = None, - update_delay: Optional[int] = None, - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_types_models2.MemoryStoreUpdateCompletedResult]: ... - @overload - async def _begin_update_memories( - self, - name: str, - body: JSON, - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_types_models2.MemoryStoreUpdateCompletedResult]: ... - @overload - async def _begin_update_memories( - self, - name: str, - body: IO[bytes], - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_types_models2.MemoryStoreUpdateCompletedResult]: ... - - @distributed_trace_async - async def _begin_update_memories( - self, - name: str, - scope: str = _Unset, - body: Union[JSON, IO[bytes]] = _Unset, - items: Optional[List[dict[str, Any]]] = None, - previous_update_id: Optional[str] = None, - update_delay: Optional[int] = None, - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], - **kwargs: Any - ) -> AsyncLROPoller[_types_models2.MemoryStoreUpdateCompletedResult]: - """Update memory store with conversation memories. - - :param name: The name of the memory store to update. Required. - :type name: str - :param scope: The namespace that logically groups and isolates memories, such as a user ID. - Required. - :type scope: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :param items: Conversation items to be stored in memory. Default value is None. - :type items: list[dict[str, any]] - :param previous_update_id: The unique ID of the previous update request, enabling incremental - memory updates from where the last operation left off. Default value is None. - :type previous_update_id: str - :param update_delay: Timeout period before processing the memory update in seconds. - If a new update request is received during this period, it will cancel the current request and - reset the timeout. - Set to 0 to immediately trigger the update without delay. - Defaults to 300 (5 minutes). Default value is None. - :type update_delay: int - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW - :return: An instance of AsyncLROPoller that returns MemoryStoreUpdateCompletedResult - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.ai.agents.types.MemoryStoreUpdateCompletedResult] - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "scope": "str", - "items": [ - { - "str": {} - } - ], - "previous_update_id": "str", - "update_delay": 0 - } - - # response body for status code(s): 202 - response == { - "memory_operations": [ - { - "kind": "str", - "memory_item": memory_item - } - ], - "usage": { - "embedding_tokens": 0, - "input_tokens": 0, - "input_tokens_details": { - "cached_tokens": 0 - }, - "output_tokens": 0, - "output_tokens_details": { - "reasoning_tokens": 0 - }, - "total_tokens": 0 - } - } - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models2.MemoryStoreUpdateCompletedResult] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_memories_initial( - name=name, - scope=scope, - body=body, - items=items, - previous_update_id=previous_update_id, - update_delay=update_delay, - foundry_features=foundry_features, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Operation-Location"] = self._deserialize( - "str", response.headers.get("Operation-Location") - ) - if response.content: - deserialized = response.json() - else: - deserialized = None - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized +class VectorStoreFileBatchesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } + Instead, you should access the following operations through + :class:`~azure.ai.agents.aio.AgentsClient`'s + :attr:`vector_store_file_batches` attribute. + """ - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncLROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_types_models.MemoryStoreUpdateCompletedResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_types_models.MemoryStoreUpdateCompletedResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AgentsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @overload - async def delete_scope( + async def create( self, - name: str, - scope: str, + vector_store_id: str, *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], content_type: str = "application/json", + file_ids: Optional[List[str]] = None, + data_sources: Optional[List[_models.VectorStoreDataSource]] = None, + chunking_strategy: Optional[_models.VectorStoreChunkingStrategyRequest] = None, **kwargs: Any - ) -> _types_models2.MemoryStoreDeleteScopeResult: - """Delete all memories associated with a specific scope from a memory store. - - :param name: The name of the memory store. Required. - :type name: str - :param scope: The namespace that logically groups and isolates memories to delete, such as a - user ID. Required. - :type scope: str - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW + ) -> _models.VectorStoreFileBatch: + """Create a vector store file batch. + + :param vector_store_id: Identifier of the vector store. Required. + :type vector_store_id: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: MemoryStoreDeleteScopeResult - :rtype: ~azure.ai.agents.types.MemoryStoreDeleteScopeResult + :keyword file_ids: List of file identifiers. Default value is None. + :paramtype file_ids: list[str] + :keyword data_sources: List of Azure assets. Default value is None. + :paramtype data_sources: list[~azure.ai.agents.models.VectorStoreDataSource] + :keyword chunking_strategy: The chunking strategy used to chunk the file(s). If not set, will + use the auto strategy. Default value is None. + :paramtype chunking_strategy: ~azure.ai.agents.models.VectorStoreChunkingStrategyRequest + :return: VectorStoreFileBatch. The VectorStoreFileBatch is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.VectorStoreFileBatch :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, vector_store_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.VectorStoreFileBatch: + """Create a vector store file batch. - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "deleted": bool, - "name": "str", - "object": "str", - "scope": "str" - } - """ - - @overload - async def delete_scope( - self, - name: str, - body: JSON, - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models2.MemoryStoreDeleteScopeResult: - """Delete all memories associated with a specific scope from a memory store. - - :param name: The name of the memory store. Required. - :type name: str + :param vector_store_id: Identifier of the vector store. Required. + :type vector_store_id: str :param body: Required. :type body: JSON - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: MemoryStoreDeleteScopeResult - :rtype: ~azure.ai.agents.types.MemoryStoreDeleteScopeResult + :return: VectorStoreFileBatch. The VectorStoreFileBatch is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.VectorStoreFileBatch :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "scope": "str" - } - - # response body for status code(s): 200 - response == { - "deleted": bool, - "name": "str", - "object": "str", - "scope": "str" - } """ @overload - async def delete_scope( - self, - name: str, - body: IO[bytes], - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models2.MemoryStoreDeleteScopeResult: - """Delete all memories associated with a specific scope from a memory store. + async def create( + self, vector_store_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.VectorStoreFileBatch: + """Create a vector store file batch. - :param name: The name of the memory store. Required. - :type name: str + :param vector_store_id: Identifier of the vector store. Required. + :type vector_store_id: str :param body: Required. :type body: IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: MemoryStoreDeleteScopeResult - :rtype: ~azure.ai.agents.types.MemoryStoreDeleteScopeResult + :return: VectorStoreFileBatch. The VectorStoreFileBatch is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.VectorStoreFileBatch :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "deleted": bool, - "name": "str", - "object": "str", - "scope": "str" - } """ @distributed_trace_async - async def delete_scope( + async def create( self, - name: str, - scope: str = _Unset, + vector_store_id: str, body: Union[JSON, IO[bytes]] = _Unset, *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + file_ids: Optional[List[str]] = None, + data_sources: Optional[List[_models.VectorStoreDataSource]] = None, + chunking_strategy: Optional[_models.VectorStoreChunkingStrategyRequest] = None, **kwargs: Any - ) -> _types_models2.MemoryStoreDeleteScopeResult: - """Delete all memories associated with a specific scope from a memory store. - - :param name: The name of the memory store. Required. - :type name: str - :param scope: The namespace that logically groups and isolates memories to delete, such as a - user ID. Required. - :type scope: str + ) -> _models.VectorStoreFileBatch: + """Create a vector store file batch. + + :param vector_store_id: Identifier of the vector store. Required. + :type vector_store_id: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW - :return: MemoryStoreDeleteScopeResult - :rtype: ~azure.ai.agents.types.MemoryStoreDeleteScopeResult + :keyword file_ids: List of file identifiers. Default value is None. + :paramtype file_ids: list[str] + :keyword data_sources: List of Azure assets. Default value is None. + :paramtype data_sources: list[~azure.ai.agents.models.VectorStoreDataSource] + :keyword chunking_strategy: The chunking strategy used to chunk the file(s). If not set, will + use the auto strategy. Default value is None. + :paramtype chunking_strategy: ~azure.ai.agents.models.VectorStoreChunkingStrategyRequest + :return: VectorStoreFileBatch. The VectorStoreFileBatch is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.VectorStoreFileBatch :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "scope": "str" - } - - # response body for status code(s): 200 - response == { - "deleted": bool, - "name": "str", - "object": "str", - "scope": "str" - } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -13540,27 +3789,22 @@ async def delete_scope( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models2.MemoryStoreDeleteScopeResult] = kwargs.pop("cls", None) + cls: ClsType[_models.VectorStoreFileBatch] = kwargs.pop("cls", None) if body is _Unset: - if scope is _Unset: - raise TypeError("missing required argument: scope") - body = {"scope": scope} + body = {"chunking_strategy": chunking_strategy, "data_sources": data_sources, "file_ids": file_ids} body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" - _json = None _content = None if isinstance(body, (IOBase, bytes)): _content = body else: - _json = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_beta_memory_stores_delete_scope_request( - name=name, - foundry_features=foundry_features, + _request = build_vector_store_file_batches_create_request( + vector_store_id=vector_store_id, content_type=content_type, api_version=self._config.api_version, - json=_json, content=_content, headers=_headers, params=_params, @@ -13570,7 +3814,6 @@ async def delete_scope( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -13585,92 +3828,30 @@ async def delete_scope( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models2.ApiErrorResponse, - pipeline_response, - ) + error = _failsafe_deserialize(_models.AgentV1Error, response) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.VectorStoreFileBatch, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - -class BetaRedTeamsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.agents.aio.AIProjectClient`'s - :attr:`red_teams` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def get( - self, name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.RED_TEAMS_V1_PREVIEW], **kwargs: Any - ) -> _types_models2.RedTeam: - """Get a redteam by name. - - :param name: Identifier of the red team run. Required. - :type name: str - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. RED_TEAMS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.RED_TEAMS_V1_PREVIEW - :return: RedTeam - :rtype: ~azure.ai.agents.types.RedTeam + async def get(self, vector_store_id: str, batch_id: str, **kwargs: Any) -> _models.VectorStoreFileBatch: + """Retrieve a vector store file batch. + + :param vector_store_id: Identifier of the vector store. Required. + :type vector_store_id: str + :param batch_id: Identifier of the file batch. Required. + :type batch_id: str + :return: VectorStoreFileBatch. The VectorStoreFileBatch is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.VectorStoreFileBatch :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AzureOpenAIModel": - target_config = { - "modelDeploymentName": "str", - "type": "AzureOpenAIModel" - } - - # response body for status code(s): 200 - response == { - "id": "str", - "target": target_config, - "applicationScenario": "str", - "attackStrategies": [ - "str" - ], - "displayName": "str", - "numTurns": 0, - "properties": { - "str": "str" - }, - "riskCategories": [ - "str" - ], - "simulationOnly": bool, - "status": "str", - "tags": { - "str": "str" - } - } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -13683,11 +3864,11 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_types_models2.RedTeam] = kwargs.pop("cls", None) + cls: ClsType[_models.VectorStoreFileBatch] = kwargs.pop("cls", None) - _request = build_beta_red_teams_get_request( - name=name, - foundry_features=foundry_features, + _request = build_vector_store_file_batches_get_request( + vector_store_id=vector_store_id, + batch_id=batch_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -13697,7 +3878,6 @@ async def get( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -13712,382 +3892,31 @@ async def get( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.VectorStoreFileBatch, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def list( - self, *, foundry_features: Literal[FoundryFeaturesOptInKeys.RED_TEAMS_V1_PREVIEW], **kwargs: Any - ) -> AsyncItemPaged["_types_models2.RedTeam"]: - """List a redteam by name. - - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. RED_TEAMS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.RED_TEAMS_V1_PREVIEW - :return: An iterator like instance of RedTeam - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.types.RedTeam] - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AzureOpenAIModel": - target_config = { - "modelDeploymentName": "str", - "type": "AzureOpenAIModel" - } - - # response body for status code(s): 200 - response == { - "id": "str", - "target": target_config, - "applicationScenario": "str", - "attackStrategies": [ - "str" - ], - "displayName": "str", - "numTurns": 0, - "properties": { - "str": "str" - }, - "riskCategories": [ - "str" - ], - "simulationOnly": bool, - "status": "str", - "tags": { - "str": "str" - } - } - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_types_models2.RedTeam]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_beta_red_teams_list_request( - foundry_features=foundry_features, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized.get("value", []) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @overload - async def create( - self, - red_team: _types_models2.RedTeam, - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.RED_TEAMS_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models2.RedTeam: - """Creates a redteam run. - - :param red_team: Redteam to be run. Required. - :type red_team: ~azure.ai.agents.types.RedTeam - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. RED_TEAMS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.RED_TEAMS_V1_PREVIEW - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: RedTeam - :rtype: ~azure.ai.agents.types.RedTeam - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "type": - - # JSON input template for discriminator value "AzureOpenAIModel": - target_config = { - "modelDeploymentName": "str", - "type": "AzureOpenAIModel" - } - - # JSON input template you can fill out and use as your body input. - red_team = { - "id": "str", - "target": target_config, - "applicationScenario": "str", - "attackStrategies": [ - "str" - ], - "displayName": "str", - "numTurns": 0, - "properties": { - "str": "str" - }, - "riskCategories": [ - "str" - ], - "simulationOnly": bool, - "status": "str", - "tags": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AzureOpenAIModel": - target_config = { - "modelDeploymentName": "str", - "type": "AzureOpenAIModel" - } - - # response body for status code(s): 201 - response == { - "id": "str", - "target": target_config, - "applicationScenario": "str", - "attackStrategies": [ - "str" - ], - "displayName": "str", - "numTurns": 0, - "properties": { - "str": "str" - }, - "riskCategories": [ - "str" - ], - "simulationOnly": bool, - "status": "str", - "tags": { - "str": "str" - } - } - """ - - @overload - async def create( - self, - red_team: IO[bytes], - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.RED_TEAMS_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models2.RedTeam: - """Creates a redteam run. - - :param red_team: Redteam to be run. Required. - :type red_team: IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. RED_TEAMS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.RED_TEAMS_V1_PREVIEW - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: RedTeam - :rtype: ~azure.ai.agents.types.RedTeam - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AzureOpenAIModel": - target_config = { - "modelDeploymentName": "str", - "type": "AzureOpenAIModel" - } - - # response body for status code(s): 201 - response == { - "id": "str", - "target": target_config, - "applicationScenario": "str", - "attackStrategies": [ - "str" - ], - "displayName": "str", - "numTurns": 0, - "properties": { - "str": "str" - }, - "riskCategories": [ - "str" - ], - "simulationOnly": bool, - "status": "str", - "tags": { - "str": "str" - } - } - """ - @distributed_trace_async - async def create( - self, - red_team: Union[_types_models2.RedTeam, IO[bytes]], - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.RED_TEAMS_V1_PREVIEW], - **kwargs: Any - ) -> _types_models2.RedTeam: - """Creates a redteam run. - - :param red_team: Redteam to be run. Is either a RedTeam type or a IO[bytes] type. Required. - :type red_team: ~azure.ai.agents.types.RedTeam or IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. RED_TEAMS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.RED_TEAMS_V1_PREVIEW - :return: RedTeam - :rtype: ~azure.ai.agents.types.RedTeam + async def cancel(self, vector_store_id: str, batch_id: str, **kwargs: Any) -> _models.VectorStoreFileBatch: + """Cancel a vector store file batch. This attempts to cancel the processing of files in this batch + as soon as possible. + + :param vector_store_id: Identifier of the vector store. Required. + :type vector_store_id: str + :param batch_id: Identifier of the file batch. Required. + :type batch_id: str + :return: VectorStoreFileBatch. The VectorStoreFileBatch is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.VectorStoreFileBatch :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "type": - - # JSON input template for discriminator value "AzureOpenAIModel": - target_config = { - "modelDeploymentName": "str", - "type": "AzureOpenAIModel" - } - - # JSON input template you can fill out and use as your body input. - red_team = { - "id": "str", - "target": target_config, - "applicationScenario": "str", - "attackStrategies": [ - "str" - ], - "displayName": "str", - "numTurns": 0, - "properties": { - "str": "str" - }, - "riskCategories": [ - "str" - ], - "simulationOnly": bool, - "status": "str", - "tags": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AzureOpenAIModel": - target_config = { - "modelDeploymentName": "str", - "type": "AzureOpenAIModel" - } - - # response body for status code(s): 201 - response == { - "id": "str", - "target": target_config, - "applicationScenario": "str", - "attackStrategies": [ - "str" - ], - "displayName": "str", - "numTurns": 0, - "properties": { - "str": "str" - }, - "riskCategories": [ - "str" - ], - "simulationOnly": bool, - "status": "str", - "tags": { - "str": "str" - } - } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -14097,26 +3926,15 @@ async def create( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models2.RedTeam] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(red_team, (IOBase, bytes)): - _content = red_team - else: - _json = red_team + cls: ClsType[_models.VectorStoreFileBatch] = kwargs.pop("cls", None) - _request = build_beta_red_teams_create_request( - foundry_features=foundry_features, - content_type=content_type, + _request = build_vector_store_file_batches_cancel_request( + vector_store_id=vector_store_id, + batch_id=batch_id, api_version=self._config.api_version, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -14125,7 +3943,6 @@ async def create( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -14133,69 +3950,67 @@ async def create( response = pipeline_response.http_response - if response.status_code not in [201]: + if response.status_code not in [200]: if _stream: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models2.ApiErrorResponse, - pipeline_response, - ) + error = _failsafe_deserialize(_models.AgentV1Error, response) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.VectorStoreFileBatch, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - -class BetaSchedulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.agents.aio.AIProjectClient`'s - :attr:`schedules` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def delete( + @distributed_trace + def list_files( self, - schedule_id: str, + vector_store_id: str, + batch_id: str, *, - foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], + filter: Optional[Union[str, _models.VectorStoreFileStatusFilter]] = None, + limit: Optional[int] = None, + order: Optional[Union[str, _models.ListSortOrder]] = None, + before: Optional[str] = None, **kwargs: Any - ) -> None: - """Delete a schedule. - - :param schedule_id: Identifier of the schedule. Required. - :type schedule_id: str - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. SCHEDULES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.SCHEDULES_V1_PREVIEW - :return: None - :rtype: None + ) -> AsyncItemPaged["_models.VectorStoreFile"]: + """Returns a list of vector store files in a batch. + + :param vector_store_id: Identifier of the vector store. Required. + :type vector_store_id: str + :param batch_id: Identifier of the file batch. Required. + :type batch_id: str + :keyword filter: Filter by file status. Known values are: "in_progress", "completed", "failed", + and "cancelled". Default value is None. + :paramtype filter: str or ~azure.ai.agents.models.VectorStoreFileStatusFilter + :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and + 100, and the default is 20. Default value is None. + :paramtype limit: int + :keyword order: Sort order by the created_at timestamp of the objects. asc for ascending order + and desc for descending order. Known values are: "asc" and "desc". Default value is None. + :paramtype order: str or ~azure.ai.agents.models.ListSortOrder + :keyword 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. Default value is None. + :paramtype before: str + :return: An iterator like instance of VectorStoreFile + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.models.VectorStoreFile] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.VectorStoreFile]] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -14204,120 +4019,211 @@ async def delete( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} + def prepare_request(_continuation_token=None): - cls: ClsType[None] = kwargs.pop("cls", None) + _request = build_vector_store_file_batches_list_files_request( + vector_store_id=vector_store_id, + batch_id=batch_id, + filter=filter, + limit=limit, + order=order, + after=_continuation_token, + before=before, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request - _request = build_beta_schedules_delete_request( - schedule_id=schedule_id, - foundry_features=foundry_features, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.VectorStoreFile], deserialized.get("data", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("last_id") or None, AsyncList(list_of_elem) - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + async def get_next(_continuation_token=None): + _request = prepare_request(_continuation_token) - response = pipeline_response.http_response + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) - if cls: - return cls(pipeline_response, None, {}) # type: ignore + return pipeline_response - @distributed_trace_async - async def get( + return AsyncItemPaged(get_next, extract_data) + + +class _AgentsClientOperationsMixin( + ClientMixinABC[AsyncPipelineClient[HttpRequest, AsyncHttpResponse], AgentsClientConfiguration] +): + + @overload + async def create_agent( self, - schedule_id: str, *, - foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], + model: str, + content_type: str = "application/json", + name: Optional[str] = None, + description: Optional[str] = None, + instructions: Optional[str] = None, + tools: Optional[List[_models.ToolDefinition]] = None, + tool_resources: Optional[_models.ToolResources] = None, + temperature: Optional[float] = None, + top_p: Optional[float] = None, + response_format: Optional["_types.AgentsResponseFormatOption"] = None, + metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> _types_models2.Schedule: - """Get a schedule by id. - - :param schedule_id: Identifier of the schedule. Required. - :type schedule_id: str - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. SCHEDULES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.SCHEDULES_V1_PREVIEW - :return: Schedule - :rtype: ~azure.ai.agents.types.Schedule + ) -> _models.Agent: + """Creates a new agent. + + :keyword model: The ID of the model to use. Required. + :paramtype model: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword name: The name of the new agent. Default value is None. + :paramtype name: str + :keyword description: The description of the new agent. Default value is None. + :paramtype description: str + :keyword instructions: The system instructions for the new agent to use. Default value is None. + :paramtype instructions: str + :keyword tools: The collection of tools to enable for the new agent. Default value is None. + :paramtype tools: list[~azure.ai.agents.models.ToolDefinition] + :keyword tool_resources: 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. Default value is None. + :paramtype tool_resources: ~azure.ai.agents.models.ToolResources + :keyword temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 + will make the output more random, + while lower values like 0.2 will make it more focused and deterministic. Default value is + None. + :paramtype temperature: float + :keyword top_p: An alternative to sampling with temperature, called nucleus sampling, where the + model considers the results of the tokens with top_p probability mass. + So 0.1 means only the tokens comprising the top 10% probability mass are considered. + + We generally recommend altering this or temperature but not both. Default value is None. + :paramtype top_p: float + :keyword response_format: The response format of the tool calls used by this agent. Is one of + the following types: str, Union[str, "_models.AgentsResponseFormatMode"], AgentsResponseFormat, + ResponseFormatJsonSchemaType Default value is None. + :paramtype response_format: str or str or ~azure.ai.agents.models.AgentsResponseFormatMode or + ~azure.ai.agents.models.AgentsResponseFormat or + ~azure.ai.agents.models.ResponseFormatJsonSchemaType + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: Agent. The Agent is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.Agent + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_agent(self, body: JSON, *, content_type: str = "application/json", **kwargs: Any) -> _models.Agent: + """Creates a new agent. + + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Agent. The Agent is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.Agent + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_agent( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.Agent: + """Creates a new agent. + + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: Agent. The Agent is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.Agent :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_agent( + self, + body: Union[JSON, IO[bytes]] = _Unset, + *, + model: str = _Unset, + name: Optional[str] = None, + description: Optional[str] = None, + instructions: Optional[str] = None, + tools: Optional[List[_models.ToolDefinition]] = None, + tool_resources: Optional[_models.ToolResources] = None, + temperature: Optional[float] = None, + top_p: Optional[float] = None, + response_format: Optional["_types.AgentsResponseFormatOption"] = None, + metadata: Optional[dict[str, str]] = None, + **kwargs: Any + ) -> _models.Agent: + """Creates a new agent. - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "Cron": - trigger = { - "expression": "str", - "type": "Cron", - "endTime": "2020-02-20 00:00:00", - "startTime": "2020-02-20 00:00:00", - "timeZone": "str" - } - - # JSON input template for discriminator value "OneTime": - trigger = { - "triggerAt": "2020-02-20 00:00:00", - "type": "OneTime", - "timeZone": "str" - } - - # JSON input template for discriminator value "Recurrence": - trigger = { - "interval": 0, - "schedule": recurrence_schedule, - "type": "Recurrence", - "endTime": "2020-02-20 00:00:00", - "startTime": "2020-02-20 00:00:00", - "timeZone": "str" - } - - # JSON input template for discriminator value "Daily": - recurrence_schedule = { - "hours": [ - 0 - ], - "type": "Daily" - } - - # JSON input template for discriminator value "Hourly": - recurrence_schedule = { - "type": "Hourly" - } - - # response body for status code(s): 200 - response == { - "enabled": bool, - "id": "str", - "systemData": { - "str": "str" - }, - "task": schedule_task, - "trigger": trigger, - "description": "str", - "displayName": "str", - "properties": { - "str": "str" - }, - "provisioningStatus": "str", - "tags": { - "str": "str" - } - } + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword model: The ID of the model to use. Required. + :paramtype model: str + :keyword name: The name of the new agent. Default value is None. + :paramtype name: str + :keyword description: The description of the new agent. Default value is None. + :paramtype description: str + :keyword instructions: The system instructions for the new agent to use. Default value is None. + :paramtype instructions: str + :keyword tools: The collection of tools to enable for the new agent. Default value is None. + :paramtype tools: list[~azure.ai.agents.models.ToolDefinition] + :keyword tool_resources: 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. Default value is None. + :paramtype tool_resources: ~azure.ai.agents.models.ToolResources + :keyword temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 + will make the output more random, + while lower values like 0.2 will make it more focused and deterministic. Default value is + None. + :paramtype temperature: float + :keyword top_p: An alternative to sampling with temperature, called nucleus sampling, where the + model considers the results of the tokens with top_p probability mass. + So 0.1 means only the tokens comprising the top 10% probability mass are considered. + + We generally recommend altering this or temperature but not both. Default value is None. + :paramtype top_p: float + :keyword response_format: The response format of the tool calls used by this agent. Is one of + the following types: str, Union[str, "_models.AgentsResponseFormatMode"], AgentsResponseFormat, + ResponseFormatJsonSchemaType Default value is None. + :paramtype response_format: str or str or ~azure.ai.agents.models.AgentsResponseFormatMode or + ~azure.ai.agents.models.AgentsResponseFormat or + ~azure.ai.agents.models.ResponseFormatJsonSchemaType + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: Agent. The Agent is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.Agent + :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -14327,15 +4233,39 @@ async def get( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_types_models2.Schedule] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Agent] = kwargs.pop("cls", None) + + if body is _Unset: + if model is _Unset: + raise TypeError("missing required argument: model") + body = { + "description": description, + "instructions": instructions, + "metadata": metadata, + "model": model, + "name": name, + "response_format": response_format, + "temperature": temperature, + "tool_resources": tool_resources, + "tools": tools, + "top_p": top_p, + } + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_beta_schedules_get_request( - schedule_id=schedule_id, - foundry_features=foundry_features, + _request = build_agents_create_agent_request( + content_type=content_type, api_version=self._config.api_version, + content=_content, headers=_headers, params=_params, ) @@ -14344,9 +4274,8 @@ async def get( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -14359,15 +4288,13 @@ async def get( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.Agent, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -14375,97 +4302,35 @@ async def get( return deserialized # type: ignore @distributed_trace - def list( + def list_agents( self, *, - foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], - type: Optional[types.ScheduleTaskType] = None, - enabled: Optional[bool] = None, + limit: Optional[int] = None, + order: Optional[Union[str, _models.ListSortOrder]] = None, + before: Optional[str] = None, **kwargs: Any - ) -> AsyncItemPaged["_types_models2.Schedule"]: - """List all schedules. + ) -> AsyncItemPaged["_models.Agent"]: + """Gets a list of agents that were previously created. - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. SCHEDULES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.SCHEDULES_V1_PREVIEW - :keyword type: Filter by the type of schedule. Known values are: "Evaluation" and "Insight". - Default value is None. - :paramtype type: str or ~azure.ai.agents.models.ScheduleTaskType - :keyword enabled: Filter by the enabled status. Default value is None. - :paramtype enabled: bool - :return: An iterator like instance of Schedule - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.types.Schedule] + :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and + 100, and the default is 20. Default value is None. + :paramtype limit: int + :keyword order: Sort order by the created_at timestamp of the objects. asc for ascending order + and desc for descending order. Known values are: "asc" and "desc". Default value is None. + :paramtype order: str or ~azure.ai.agents.models.ListSortOrder + :keyword 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. Default value is None. + :paramtype before: str + :return: An iterator like instance of Agent + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.models.Agent] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "Cron": - trigger = { - "expression": "str", - "type": "Cron", - "endTime": "2020-02-20 00:00:00", - "startTime": "2020-02-20 00:00:00", - "timeZone": "str" - } - - # JSON input template for discriminator value "OneTime": - trigger = { - "triggerAt": "2020-02-20 00:00:00", - "type": "OneTime", - "timeZone": "str" - } - - # JSON input template for discriminator value "Recurrence": - trigger = { - "interval": 0, - "schedule": recurrence_schedule, - "type": "Recurrence", - "endTime": "2020-02-20 00:00:00", - "startTime": "2020-02-20 00:00:00", - "timeZone": "str" - } - - # JSON input template for discriminator value "Daily": - recurrence_schedule = { - "hours": [ - 0 - ], - "type": "Daily" - } - - # JSON input template for discriminator value "Hourly": - recurrence_schedule = { - "type": "Hourly" - } - - # response body for status code(s): 200 - response == { - "enabled": bool, - "id": "str", - "systemData": { - "str": "str" - }, - "task": schedule_task, - "trigger": trigger, - "description": "str", - "displayName": "str", - "properties": { - "str": "str" - }, - "provisioningStatus": "str", - "tags": { - "str": "str" - } - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_types_models2.Schedule]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.Agent]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -14475,594 +4340,280 @@ def list( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - _request = build_beta_schedules_list_request( - foundry_features=foundry_features, - type=type, - enabled=enabled, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + def prepare_request(_continuation_token=None): + _request = build_agents_list_agents_request( + limit=limit, + order=order, + after=_continuation_token, + before=before, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) return _request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized.get("value", []) + list_of_elem = _deserialize(List[_models.Agent], deserialized.get("data", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + return deserialized.get("last_id") or None, AsyncList(list_of_elem) - async def get_next(next_link=None): - _request = prepare_request(next_link) + async def get_next(_continuation_token=None): + _request = prepare_request(_continuation_token) _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) return pipeline_response return AsyncItemPaged(get_next, extract_data) + @distributed_trace_async + async def get_agent(self, agent_id: str, **kwargs: Any) -> _models.Agent: + """Retrieves an existing agent. + + :param agent_id: Identifier of the agent. Required. + :type agent_id: str + :return: Agent. The Agent is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.Agent + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Agent] = kwargs.pop("cls", None) + + _request = build_agents_get_agent_request( + agent_id=agent_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Agent, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + @overload - async def create_or_update( + async def update_agent( self, - schedule_id: str, - schedule: _types_models2.Schedule, + agent_id: str, *, - foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], content_type: str = "application/json", + model: Optional[str] = None, + name: Optional[str] = None, + description: Optional[str] = None, + instructions: Optional[str] = None, + tools: Optional[List[_models.ToolDefinition]] = None, + tool_resources: Optional[_models.ToolResources] = None, + temperature: Optional[float] = None, + top_p: Optional[float] = None, + response_format: Optional["_types.AgentsResponseFormatOption"] = None, + metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> _types_models2.Schedule: - """Create or update operation template. - - :param schedule_id: Identifier of the schedule. Required. - :type schedule_id: str - :param schedule: The resource instance. Required. - :type schedule: ~azure.ai.agents.types.Schedule - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. SCHEDULES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.SCHEDULES_V1_PREVIEW + ) -> _models.Agent: + """Modifies an existing agent. + + :param agent_id: The ID of the agent to modify. Required. + :type agent_id: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: Schedule - :rtype: ~azure.ai.agents.types.Schedule + :keyword model: The ID of the model to use. Default value is None. + :paramtype model: str + :keyword name: The modified name for the agent to use. Default value is None. + :paramtype name: str + :keyword description: The modified description for the agent to use. Default value is None. + :paramtype description: str + :keyword instructions: The modified system instructions for the new agent to use. Default value + is None. + :paramtype instructions: str + :keyword tools: The modified collection of tools to enable for the agent. Default value is + None. + :paramtype tools: list[~azure.ai.agents.models.ToolDefinition] + :keyword tool_resources: 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. Default value is None. + :paramtype tool_resources: ~azure.ai.agents.models.ToolResources + :keyword temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 + will make the output more random, + while lower values like 0.2 will make it more focused and deterministic. Default value is + None. + :paramtype temperature: float + :keyword top_p: An alternative to sampling with temperature, called nucleus sampling, where the + model considers the results of the tokens with top_p probability mass. + So 0.1 means only the tokens comprising the top 10% probability mass are considered. + + We generally recommend altering this or temperature but not both. Default value is None. + :paramtype top_p: float + :keyword response_format: The response format of the tool calls used by this agent. Is one of + the following types: str, Union[str, "_models.AgentsResponseFormatMode"], AgentsResponseFormat, + ResponseFormatJsonSchemaType Default value is None. + :paramtype response_format: str or str or ~azure.ai.agents.models.AgentsResponseFormatMode or + ~azure.ai.agents.models.AgentsResponseFormat or + ~azure.ai.agents.models.ResponseFormatJsonSchemaType + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: Agent. The Agent is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.Agent :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_agent( + self, agent_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.Agent: + """Modifies an existing agent. - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "type": - - # JSON input template for discriminator value "Cron": - trigger = { - "expression": "str", - "type": "Cron", - "endTime": "2020-02-20 00:00:00", - "startTime": "2020-02-20 00:00:00", - "timeZone": "str" - } - - # JSON input template for discriminator value "OneTime": - trigger = { - "triggerAt": "2020-02-20 00:00:00", - "type": "OneTime", - "timeZone": "str" - } - - # JSON input template for discriminator value "Recurrence": - trigger = { - "interval": 0, - "schedule": recurrence_schedule, - "type": "Recurrence", - "endTime": "2020-02-20 00:00:00", - "startTime": "2020-02-20 00:00:00", - "timeZone": "str" - } - - # JSON input template for discriminator value "Daily": - recurrence_schedule = { - "hours": [ - 0 - ], - "type": "Daily" - } - - # JSON input template for discriminator value "Hourly": - recurrence_schedule = { - "type": "Hourly" - } - - # JSON input template you can fill out and use as your body input. - schedule = { - "enabled": bool, - "id": "str", - "systemData": { - "str": "str" - }, - "task": schedule_task, - "trigger": trigger, - "description": "str", - "displayName": "str", - "properties": { - "str": "str" - }, - "provisioningStatus": "str", - "tags": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "Cron": - trigger = { - "expression": "str", - "type": "Cron", - "endTime": "2020-02-20 00:00:00", - "startTime": "2020-02-20 00:00:00", - "timeZone": "str" - } - - # JSON input template for discriminator value "OneTime": - trigger = { - "triggerAt": "2020-02-20 00:00:00", - "type": "OneTime", - "timeZone": "str" - } - - # JSON input template for discriminator value "Recurrence": - trigger = { - "interval": 0, - "schedule": recurrence_schedule, - "type": "Recurrence", - "endTime": "2020-02-20 00:00:00", - "startTime": "2020-02-20 00:00:00", - "timeZone": "str" - } - - # JSON input template for discriminator value "Daily": - recurrence_schedule = { - "hours": [ - 0 - ], - "type": "Daily" - } - - # JSON input template for discriminator value "Hourly": - recurrence_schedule = { - "type": "Hourly" - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "Cron": - trigger = { - "expression": "str", - "type": "Cron", - "endTime": "2020-02-20 00:00:00", - "startTime": "2020-02-20 00:00:00", - "timeZone": "str" - } - - # JSON input template for discriminator value "OneTime": - trigger = { - "triggerAt": "2020-02-20 00:00:00", - "type": "OneTime", - "timeZone": "str" - } - - # JSON input template for discriminator value "Recurrence": - trigger = { - "interval": 0, - "schedule": recurrence_schedule, - "type": "Recurrence", - "endTime": "2020-02-20 00:00:00", - "startTime": "2020-02-20 00:00:00", - "timeZone": "str" - } - - # JSON input template for discriminator value "Daily": - recurrence_schedule = { - "hours": [ - 0 - ], - "type": "Daily" - } - - # JSON input template for discriminator value "Hourly": - recurrence_schedule = { - "type": "Hourly" - } - - # response body for status code(s): 201, 200 - response == { - "enabled": bool, - "id": "str", - "systemData": { - "str": "str" - }, - "task": schedule_task, - "trigger": trigger, - "description": "str", - "displayName": "str", - "properties": { - "str": "str" - }, - "provisioningStatus": "str", - "tags": { - "str": "str" - } - } + :param agent_id: The ID of the agent to modify. Required. + :type agent_id: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Agent. The Agent is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.Agent + :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def create_or_update( - self, - schedule_id: str, - schedule: IO[bytes], - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models2.Schedule: - """Create or update operation template. - - :param schedule_id: Identifier of the schedule. Required. - :type schedule_id: str - :param schedule: The resource instance. Required. - :type schedule: IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. SCHEDULES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.SCHEDULES_V1_PREVIEW + async def update_agent( + self, agent_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.Agent: + """Modifies an existing agent. + + :param agent_id: The ID of the agent to modify. Required. + :type agent_id: str + :param body: Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: Schedule - :rtype: ~azure.ai.agents.types.Schedule + :return: Agent. The Agent is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.Agent :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "Cron": - trigger = { - "expression": "str", - "type": "Cron", - "endTime": "2020-02-20 00:00:00", - "startTime": "2020-02-20 00:00:00", - "timeZone": "str" - } - - # JSON input template for discriminator value "OneTime": - trigger = { - "triggerAt": "2020-02-20 00:00:00", - "type": "OneTime", - "timeZone": "str" - } - - # JSON input template for discriminator value "Recurrence": - trigger = { - "interval": 0, - "schedule": recurrence_schedule, - "type": "Recurrence", - "endTime": "2020-02-20 00:00:00", - "startTime": "2020-02-20 00:00:00", - "timeZone": "str" - } - - # JSON input template for discriminator value "Daily": - recurrence_schedule = { - "hours": [ - 0 - ], - "type": "Daily" - } - - # JSON input template for discriminator value "Hourly": - recurrence_schedule = { - "type": "Hourly" - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "Cron": - trigger = { - "expression": "str", - "type": "Cron", - "endTime": "2020-02-20 00:00:00", - "startTime": "2020-02-20 00:00:00", - "timeZone": "str" - } - - # JSON input template for discriminator value "OneTime": - trigger = { - "triggerAt": "2020-02-20 00:00:00", - "type": "OneTime", - "timeZone": "str" - } - - # JSON input template for discriminator value "Recurrence": - trigger = { - "interval": 0, - "schedule": recurrence_schedule, - "type": "Recurrence", - "endTime": "2020-02-20 00:00:00", - "startTime": "2020-02-20 00:00:00", - "timeZone": "str" - } - - # JSON input template for discriminator value "Daily": - recurrence_schedule = { - "hours": [ - 0 - ], - "type": "Daily" - } - - # JSON input template for discriminator value "Hourly": - recurrence_schedule = { - "type": "Hourly" - } - - # response body for status code(s): 201, 200 - response == { - "enabled": bool, - "id": "str", - "systemData": { - "str": "str" - }, - "task": schedule_task, - "trigger": trigger, - "description": "str", - "displayName": "str", - "properties": { - "str": "str" - }, - "provisioningStatus": "str", - "tags": { - "str": "str" - } - } """ @distributed_trace_async - async def create_or_update( + async def update_agent( self, - schedule_id: str, - schedule: Union[_types_models2.Schedule, IO[bytes]], + agent_id: str, + body: Union[JSON, IO[bytes]] = _Unset, *, - foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], + model: Optional[str] = None, + name: Optional[str] = None, + description: Optional[str] = None, + instructions: Optional[str] = None, + tools: Optional[List[_models.ToolDefinition]] = None, + tool_resources: Optional[_models.ToolResources] = None, + temperature: Optional[float] = None, + top_p: Optional[float] = None, + response_format: Optional["_types.AgentsResponseFormatOption"] = None, + metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> _types_models2.Schedule: - """Create or update operation template. + ) -> _models.Agent: + """Modifies an existing agent. - :param schedule_id: Identifier of the schedule. Required. - :type schedule_id: str - :param schedule: The resource instance. Is either a Schedule type or a IO[bytes] type. - Required. - :type schedule: ~azure.ai.agents.types.Schedule or IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. SCHEDULES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.SCHEDULES_V1_PREVIEW - :return: Schedule - :rtype: ~azure.ai.agents.types.Schedule + :param agent_id: The ID of the agent to modify. Required. + :type agent_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword model: The ID of the model to use. Default value is None. + :paramtype model: str + :keyword name: The modified name for the agent to use. Default value is None. + :paramtype name: str + :keyword description: The modified description for the agent to use. Default value is None. + :paramtype description: str + :keyword instructions: The modified system instructions for the new agent to use. Default value + is None. + :paramtype instructions: str + :keyword tools: The modified collection of tools to enable for the agent. Default value is + None. + :paramtype tools: list[~azure.ai.agents.models.ToolDefinition] + :keyword tool_resources: 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. Default value is None. + :paramtype tool_resources: ~azure.ai.agents.models.ToolResources + :keyword temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 + will make the output more random, + while lower values like 0.2 will make it more focused and deterministic. Default value is + None. + :paramtype temperature: float + :keyword top_p: An alternative to sampling with temperature, called nucleus sampling, where the + model considers the results of the tokens with top_p probability mass. + So 0.1 means only the tokens comprising the top 10% probability mass are considered. + + We generally recommend altering this or temperature but not both. Default value is None. + :paramtype top_p: float + :keyword response_format: The response format of the tool calls used by this agent. Is one of + the following types: str, Union[str, "_models.AgentsResponseFormatMode"], AgentsResponseFormat, + ResponseFormatJsonSchemaType Default value is None. + :paramtype response_format: str or str or ~azure.ai.agents.models.AgentsResponseFormatMode or + ~azure.ai.agents.models.AgentsResponseFormat or + ~azure.ai.agents.models.ResponseFormatJsonSchemaType + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: Agent. The Agent is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.Agent :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "type": - - # JSON input template for discriminator value "Cron": - trigger = { - "expression": "str", - "type": "Cron", - "endTime": "2020-02-20 00:00:00", - "startTime": "2020-02-20 00:00:00", - "timeZone": "str" - } - - # JSON input template for discriminator value "OneTime": - trigger = { - "triggerAt": "2020-02-20 00:00:00", - "type": "OneTime", - "timeZone": "str" - } - - # JSON input template for discriminator value "Recurrence": - trigger = { - "interval": 0, - "schedule": recurrence_schedule, - "type": "Recurrence", - "endTime": "2020-02-20 00:00:00", - "startTime": "2020-02-20 00:00:00", - "timeZone": "str" - } - - # JSON input template for discriminator value "Daily": - recurrence_schedule = { - "hours": [ - 0 - ], - "type": "Daily" - } - - # JSON input template for discriminator value "Hourly": - recurrence_schedule = { - "type": "Hourly" - } - - # JSON input template you can fill out and use as your body input. - schedule = { - "enabled": bool, - "id": "str", - "systemData": { - "str": "str" - }, - "task": schedule_task, - "trigger": trigger, - "description": "str", - "displayName": "str", - "properties": { - "str": "str" - }, - "provisioningStatus": "str", - "tags": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "Cron": - trigger = { - "expression": "str", - "type": "Cron", - "endTime": "2020-02-20 00:00:00", - "startTime": "2020-02-20 00:00:00", - "timeZone": "str" - } - - # JSON input template for discriminator value "OneTime": - trigger = { - "triggerAt": "2020-02-20 00:00:00", - "type": "OneTime", - "timeZone": "str" - } - - # JSON input template for discriminator value "Recurrence": - trigger = { - "interval": 0, - "schedule": recurrence_schedule, - "type": "Recurrence", - "endTime": "2020-02-20 00:00:00", - "startTime": "2020-02-20 00:00:00", - "timeZone": "str" - } - - # JSON input template for discriminator value "Daily": - recurrence_schedule = { - "hours": [ - 0 - ], - "type": "Daily" - } - - # JSON input template for discriminator value "Hourly": - recurrence_schedule = { - "type": "Hourly" - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "Cron": - trigger = { - "expression": "str", - "type": "Cron", - "endTime": "2020-02-20 00:00:00", - "startTime": "2020-02-20 00:00:00", - "timeZone": "str" - } - - # JSON input template for discriminator value "OneTime": - trigger = { - "triggerAt": "2020-02-20 00:00:00", - "type": "OneTime", - "timeZone": "str" - } - - # JSON input template for discriminator value "Recurrence": - trigger = { - "interval": 0, - "schedule": recurrence_schedule, - "type": "Recurrence", - "endTime": "2020-02-20 00:00:00", - "startTime": "2020-02-20 00:00:00", - "timeZone": "str" - } - - # JSON input template for discriminator value "Daily": - recurrence_schedule = { - "hours": [ - 0 - ], - "type": "Daily" - } - - # JSON input template for discriminator value "Hourly": - recurrence_schedule = { - "type": "Hourly" - } - - # response body for status code(s): 201, 200 - response == { - "enabled": bool, - "id": "str", - "systemData": { - "str": "str" - }, - "task": schedule_task, - "trigger": trigger, - "description": "str", - "displayName": "str", - "properties": { - "str": "str" - }, - "provisioningStatus": "str", - "tags": { - "str": "str" - } - } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -15076,22 +4627,33 @@ async def create_or_update( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models2.Schedule] = kwargs.pop("cls", None) + cls: ClsType[_models.Agent] = kwargs.pop("cls", None) + if body is _Unset: + body = { + "description": description, + "instructions": instructions, + "metadata": metadata, + "model": model, + "name": name, + "response_format": response_format, + "temperature": temperature, + "tool_resources": tool_resources, + "tools": tools, + "top_p": top_p, + } + body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" - _json = None _content = None - if isinstance(schedule, (IOBase, bytes)): - _content = schedule + if isinstance(body, (IOBase, bytes)): + _content = body else: - _json = schedule + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_beta_schedules_create_or_update_request( - schedule_id=schedule_id, - foundry_features=foundry_features, + _request = build_agents_update_agent_request( + agent_id=agent_id, content_type=content_type, api_version=self._config.api_version, - json=_json, content=_content, headers=_headers, params=_params, @@ -15101,30 +4663,27 @@ async def create_or_update( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200]: if _stream: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.Agent, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -15132,41 +4691,14 @@ async def create_or_update( return deserialized # type: ignore @distributed_trace_async - async def get_run( - self, - schedule_id: str, - run_id: str, - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], - **kwargs: Any - ) -> _types_models2.ScheduleRun: - """Get a schedule run by id. + async def _delete_agent(self, agent_id: str, **kwargs: Any) -> _models._models.AgentDeletionStatus: + """Deletes an agent. - :param schedule_id: The unique identifier of the schedule. Required. - :type schedule_id: str - :param run_id: The unique identifier of the schedule run. Required. - :type run_id: str - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. SCHEDULES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.SCHEDULES_V1_PREVIEW - :return: ScheduleRun - :rtype: ~azure.ai.agents.types.ScheduleRun + :param agent_id: Identifier of the agent. Required. + :type agent_id: str + :return: AgentDeletionStatus. The AgentDeletionStatus is compatible with MutableMapping + :rtype: ~azure.ai.agents.models._models.AgentDeletionStatus :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "id": "str", - "properties": { - "str": "str" - }, - "scheduleId": "str", - "success": bool, - "error": "str", - "triggerTime": "2020-02-20 00:00:00" - } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -15179,12 +4711,10 @@ async def get_run( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_types_models2.ScheduleRun] = kwargs.pop("cls", None) + cls: ClsType[_models._models.AgentDeletionStatus] = kwargs.pop("cls", None) - _request = build_beta_schedules_get_run_request( - schedule_id=schedule_id, - run_id=run_id, - foundry_features=foundry_features, + _request = build_agents_delete_agent_request( + agent_id=agent_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -15194,9 +4724,8 @@ async def get_run( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -15209,71 +4738,257 @@ async def get_run( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models2.ApiErrorResponse, - pipeline_response, - ) + error = _failsafe_deserialize(_models.AgentV1Error, response) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize( + _models._models.AgentDeletionStatus, response.json() # pylint: disable=protected-access + ) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def list_runs( + @overload + async def create_thread_and_run( self, - schedule_id: str, *, - foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], - type: Optional[types.ScheduleTaskType] = None, - enabled: Optional[bool] = None, + agent_id: str, + content_type: str = "application/json", + thread: Optional[_models.AgentThreadCreationOptions] = None, + model: Optional[str] = None, + instructions: Optional[str] = None, + tools: Optional[List[_models.ToolDefinition]] = None, + tool_resources: Optional[_models.ToolResources] = None, + stream_parameter: Optional[bool] = None, + temperature: Optional[float] = None, + top_p: Optional[float] = None, + max_prompt_tokens: Optional[int] = None, + max_completion_tokens: Optional[int] = None, + truncation_strategy: Optional[_models.TruncationObject] = None, + tool_choice: Optional["_types.AgentsToolChoiceOption"] = None, + response_format: Optional["_types.AgentsResponseFormatOption"] = None, + parallel_tool_calls: Optional[bool] = None, + metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> AsyncItemPaged["_types_models2.ScheduleRun"]: - """List all schedule runs. - - :param schedule_id: Identifier of the schedule. Required. - :type schedule_id: str - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. SCHEDULES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.SCHEDULES_V1_PREVIEW - :keyword type: Filter by the type of schedule. Known values are: "Evaluation" and "Insight". + ) -> _models.ThreadRun: + """Creates a new agent thread and immediately starts a run using that new thread. + + :keyword agent_id: The ID of the agent for which the thread should be created. Required. + :paramtype agent_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword thread: The details used to create the new thread. If no thread is provided, an empty + one will be created. Default value is None. + :paramtype thread: ~azure.ai.agents.models.AgentThreadCreationOptions + :keyword model: The overridden model that the agent should use to run the thread. Default value + is None. + :paramtype model: str + :keyword instructions: The overridden system instructions the agent should use to run the + thread. Default value is None. + :paramtype instructions: str + :keyword tools: The overridden list of enabled tools the agent should use to run the thread. + Default value is None. + :paramtype tools: list[~azure.ai.agents.models.ToolDefinition] + :keyword tool_resources: Override the tools the agent can use for this run. This is useful for + modifying the behavior on a per-run basis. Default value is None. + :paramtype tool_resources: ~azure.ai.agents.models.ToolResources + :keyword stream_parameter: 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. Default + value is None. + :paramtype stream_parameter: bool + :keyword temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 + will make the output + more random, while lower values like 0.2 will make it more focused and deterministic. Default + value is None. + :paramtype temperature: float + :keyword top_p: An alternative to sampling with temperature, called nucleus sampling, where the + model + considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens + comprising the top 10% probability mass are considered. + + We generally recommend altering this or temperature but not both. Default value is None. + :paramtype top_p: float + :keyword max_prompt_tokens: 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. Default + value is None. + :paramtype max_prompt_tokens: int + :keyword max_completion_tokens: 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. Default value is None. + :paramtype max_completion_tokens: int + :keyword truncation_strategy: The strategy to use for dropping messages as the context windows + moves forward. Default value is None. + :paramtype truncation_strategy: ~azure.ai.agents.models.TruncationObject + :keyword tool_choice: Controls whether or not and which tool is called by the model. Is one of + the following types: str, Union[str, "_models.AgentsToolChoiceOptionMode"], + AgentsNamedToolChoice Default value is None. + :paramtype tool_choice: str or str or ~azure.ai.agents.models.AgentsToolChoiceOptionMode or + ~azure.ai.agents.models.AgentsNamedToolChoice + :keyword response_format: Specifies the format that the model must output. Is one of the + following types: str, Union[str, "_models.AgentsResponseFormatMode"], AgentsResponseFormat, + ResponseFormatJsonSchemaType Default value is None. + :paramtype response_format: str or str or ~azure.ai.agents.models.AgentsResponseFormatMode or + ~azure.ai.agents.models.AgentsResponseFormat or + ~azure.ai.agents.models.ResponseFormatJsonSchemaType + :keyword parallel_tool_calls: If ``true`` functions will run in parallel during tool use. Default value is None. - :paramtype type: str or ~azure.ai.agents.models.ScheduleTaskType - :keyword enabled: Filter by the enabled status. Default value is None. - :paramtype enabled: bool - :return: An iterator like instance of ScheduleRun - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.agents.types.ScheduleRun] + :paramtype parallel_tool_calls: bool + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: ThreadRun. The ThreadRun is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadRun + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_thread_and_run( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ThreadRun: + """Creates a new agent thread and immediately starts a run using that new thread. + + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ThreadRun. The ThreadRun is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadRun :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_thread_and_run( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ThreadRun: + """Creates a new agent thread and immediately starts a run using that new thread. - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "id": "str", - "properties": { - "str": "str" - }, - "scheduleId": "str", - "success": bool, - "error": "str", - "triggerTime": "2020-02-20 00:00:00" - } + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ThreadRun. The ThreadRun is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadRun + :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_types_models2.ScheduleRun]] = kwargs.pop("cls", None) + @distributed_trace_async + async def create_thread_and_run( + self, + body: Union[JSON, IO[bytes]] = _Unset, + *, + agent_id: str = _Unset, + thread: Optional[_models.AgentThreadCreationOptions] = None, + model: Optional[str] = None, + instructions: Optional[str] = None, + tools: Optional[List[_models.ToolDefinition]] = None, + tool_resources: Optional[_models.ToolResources] = None, + stream_parameter: Optional[bool] = None, + temperature: Optional[float] = None, + top_p: Optional[float] = None, + max_prompt_tokens: Optional[int] = None, + max_completion_tokens: Optional[int] = None, + truncation_strategy: Optional[_models.TruncationObject] = None, + tool_choice: Optional["_types.AgentsToolChoiceOption"] = None, + response_format: Optional["_types.AgentsResponseFormatOption"] = None, + parallel_tool_calls: Optional[bool] = None, + metadata: Optional[dict[str, str]] = None, + **kwargs: Any + ) -> _models.ThreadRun: + """Creates a new agent thread and immediately starts a run using that new thread. + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword agent_id: The ID of the agent for which the thread should be created. Required. + :paramtype agent_id: str + :keyword thread: The details used to create the new thread. If no thread is provided, an empty + one will be created. Default value is None. + :paramtype thread: ~azure.ai.agents.models.AgentThreadCreationOptions + :keyword model: The overridden model that the agent should use to run the thread. Default value + is None. + :paramtype model: str + :keyword instructions: The overridden system instructions the agent should use to run the + thread. Default value is None. + :paramtype instructions: str + :keyword tools: The overridden list of enabled tools the agent should use to run the thread. + Default value is None. + :paramtype tools: list[~azure.ai.agents.models.ToolDefinition] + :keyword tool_resources: Override the tools the agent can use for this run. This is useful for + modifying the behavior on a per-run basis. Default value is None. + :paramtype tool_resources: ~azure.ai.agents.models.ToolResources + :keyword stream_parameter: 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. Default + value is None. + :paramtype stream_parameter: bool + :keyword temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 + will make the output + more random, while lower values like 0.2 will make it more focused and deterministic. Default + value is None. + :paramtype temperature: float + :keyword top_p: An alternative to sampling with temperature, called nucleus sampling, where the + model + considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens + comprising the top 10% probability mass are considered. + + We generally recommend altering this or temperature but not both. Default value is None. + :paramtype top_p: float + :keyword max_prompt_tokens: 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. Default + value is None. + :paramtype max_prompt_tokens: int + :keyword max_completion_tokens: 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. Default value is None. + :paramtype max_completion_tokens: int + :keyword truncation_strategy: The strategy to use for dropping messages as the context windows + moves forward. Default value is None. + :paramtype truncation_strategy: ~azure.ai.agents.models.TruncationObject + :keyword tool_choice: Controls whether or not and which tool is called by the model. Is one of + the following types: str, Union[str, "_models.AgentsToolChoiceOptionMode"], + AgentsNamedToolChoice Default value is None. + :paramtype tool_choice: str or str or ~azure.ai.agents.models.AgentsToolChoiceOptionMode or + ~azure.ai.agents.models.AgentsNamedToolChoice + :keyword response_format: Specifies the format that the model must output. Is one of the + following types: str, Union[str, "_models.AgentsResponseFormatMode"], AgentsResponseFormat, + ResponseFormatJsonSchemaType Default value is None. + :paramtype response_format: str or str or ~azure.ai.agents.models.AgentsResponseFormatMode or + ~azure.ai.agents.models.AgentsResponseFormat or + ~azure.ai.agents.models.ResponseFormatJsonSchemaType + :keyword parallel_tool_calls: If ``true`` functions will run in parallel during tool use. + Default value is None. + :paramtype parallel_tool_calls: bool + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: ThreadRun. The ThreadRun is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadRun + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -15282,70 +4997,76 @@ def list_runs( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - _request = build_beta_schedules_list_runs_request( - schedule_id=schedule_id, - foundry_features=foundry_features, - type=type, - enabled=enabled, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - return _request + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ThreadRun] = kwargs.pop("cls", None) - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized.get("value", []) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + if body is _Unset: + if agent_id is _Unset: + raise TypeError("missing required argument: agent_id") + body = { + "assistant_id": agent_id, + "instructions": instructions, + "max_completion_tokens": max_completion_tokens, + "max_prompt_tokens": max_prompt_tokens, + "metadata": metadata, + "model": model, + "parallel_tool_calls": parallel_tool_calls, + "response_format": response_format, + "stream": stream_parameter, + "temperature": temperature, + "thread": thread, + "tool_choice": tool_choice, + "tool_resources": tool_resources, + "tools": tools, + "top_p": top_p, + "truncation_strategy": truncation_strategy, + } + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_agents_create_thread_and_run_request( + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - async def get_next(next_link=None): - _request = prepare_request(next_link) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + response = pipeline_response.http_response - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) - return pipeline_response + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.ThreadRun, response.json()) - return AsyncItemPaged(get_next, extract_data) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/ai/azure-ai-agents/azure/ai/agents/models/__init__.py b/sdk/ai/azure-ai-agents/azure/ai/agents/models/__init__.py index e3b4c5295f07..8e589c978dc4 100644 --- a/sdk/ai/azure-ai-agents/azure/ai/agents/models/__init__.py +++ b/sdk/ai/azure-ai-agents/azure/ai/agents/models/__init__.py @@ -12,10 +12,535 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import + +from ._models import ( # type: ignore + AISearchIndexResource, + ActivityFunctionDefinition, + ActivityFunctionParameters, + Agent, + AgentErrorDetail, + AgentThread, + AgentThreadCreationOptions, + AgentV1Error, + AgentsNamedToolChoice, + AgentsResponseFormat, + AzureAISearchToolDefinition, + AzureAISearchToolResource, + AzureFunctionBinding, + AzureFunctionDefinition, + AzureFunctionStorageQueue, + AzureFunctionToolCallDetails, + AzureFunctionToolDefinition, + BingCustomSearchConfiguration, + BingCustomSearchToolDefinition, + BingCustomSearchToolParameters, + BingGroundingSearchConfiguration, + BingGroundingSearchToolParameters, + BingGroundingToolDefinition, + BrowserAutomationToolCallDetails, + BrowserAutomationToolCallStep, + BrowserAutomationToolConnectionParameters, + BrowserAutomationToolDefinition, + BrowserAutomationToolParameters, + ClickAction, + CodeInterpreterToolDefinition, + CodeInterpreterToolResource, + ComputerScreenshot, + ComputerToolOutput, + ComputerUseAction, + ComputerUseToolDefinition, + ComputerUseToolParameters, + ConnectedAgentDetails, + ConnectedAgentToolDefinition, + CoordinatePoint, + DeepResearchBingGroundingConnection, + DeepResearchDetails, + DeepResearchToolDefinition, + DoubleClickAction, + DragAction, + FabricDataAgentToolParameters, + FileInfo, + FileListResponse, + FileSearchRankingOptions, + FileSearchToolCallContent, + FileSearchToolDefinition, + FileSearchToolDefinitionDetails, + FileSearchToolResource, + FunctionArgument, + FunctionDefinition, + FunctionName, + FunctionToolDefinition, + IncompleteRunDetails, + KeyPressAction, + MCPApprovalPerTool, + MCPToolDefinition, + MCPToolList, + MCPToolResource, + MessageAttachment, + MessageContent, + MessageDelta, + MessageDeltaChunk, + MessageDeltaContent, + MessageDeltaImageFileContent, + MessageDeltaImageFileContentObject, + MessageDeltaTextAnnotation, + MessageDeltaTextContent, + MessageDeltaTextContentObject, + MessageDeltaTextFileCitationAnnotation, + MessageDeltaTextFileCitationAnnotationObject, + MessageDeltaTextFilePathAnnotation, + MessageDeltaTextFilePathAnnotationObject, + MessageDeltaTextUrlCitationAnnotation, + MessageDeltaTextUrlCitationDetails, + MessageImageFileContent, + MessageImageFileDetails, + MessageImageFileParam, + MessageImageUrlParam, + MessageIncompleteDetails, + MessageInputContentBlock, + MessageInputImageFileBlock, + MessageInputImageUrlBlock, + MessageInputTextBlock, + MessageTextAnnotation, + MessageTextContent, + MessageTextDetails, + MessageTextFileCitationAnnotation, + MessageTextFileCitationDetails, + MessageTextFilePathAnnotation, + MessageTextFilePathDetails, + MessageTextUrlCitationAnnotation, + MessageTextUrlCitationDetails, + MicrosoftFabricToolDefinition, + MoveAction, + OpenApiAnonymousAuthDetails, + OpenApiAuthDetails, + OpenApiConnectionAuthDetails, + OpenApiConnectionSecurityScheme, + OpenApiFunctionDefinition, + OpenApiManagedAuthDetails, + OpenApiManagedSecurityScheme, + OpenApiToolDefinition, + RequiredAction, + RequiredComputerUseToolCall, + RequiredComputerUseToolCallDetails, + RequiredFunctionToolCall, + RequiredFunctionToolCallDetails, + RequiredMcpToolCall, + RequiredToolCall, + ResponseFormatJsonSchema, + ResponseFormatJsonSchemaType, + RunCompletionUsage, + RunError, + RunStep, + RunStepActivityDetails, + RunStepAzureAISearchToolCall, + RunStepAzureFunctionToolCall, + RunStepBingCustomSearchToolCall, + RunStepBingGroundingToolCall, + RunStepBrowserAutomationToolCall, + RunStepCodeInterpreterImageOutput, + RunStepCodeInterpreterImageReference, + RunStepCodeInterpreterLogOutput, + RunStepCodeInterpreterToolCall, + RunStepCodeInterpreterToolCallDetails, + RunStepCodeInterpreterToolCallOutput, + RunStepCompletionUsage, + RunStepComputerUseToolCall, + RunStepComputerUseToolCallDetails, + RunStepConnectedAgent, + RunStepConnectedAgentToolCall, + RunStepDeepResearchToolCall, + RunStepDeepResearchToolCallDetails, + RunStepDelta, + RunStepDeltaAzureAISearchToolCall, + RunStepDeltaAzureFunctionToolCall, + RunStepDeltaBingGroundingToolCall, + RunStepDeltaChunk, + RunStepDeltaCodeInterpreterDetailItemObject, + RunStepDeltaCodeInterpreterImageOutput, + RunStepDeltaCodeInterpreterImageOutputObject, + RunStepDeltaCodeInterpreterLogOutput, + RunStepDeltaCodeInterpreterOutput, + RunStepDeltaCodeInterpreterToolCall, + RunStepDeltaComputerUseDetails, + RunStepDeltaComputerUseToolCall, + RunStepDeltaConnectedAgentToolCall, + RunStepDeltaCustomBingGroundingToolCall, + RunStepDeltaDeepResearchToolCall, + RunStepDeltaDetail, + RunStepDeltaFileSearchToolCall, + RunStepDeltaFunction, + RunStepDeltaFunctionToolCall, + RunStepDeltaMCPObject, + RunStepDeltaMcpToolCall, + RunStepDeltaMessageCreation, + RunStepDeltaMessageCreationObject, + RunStepDeltaMicrosoftFabricToolCall, + RunStepDeltaOpenAPIObject, + RunStepDeltaOpenAPIToolCall, + RunStepDeltaSharepointToolCall, + RunStepDeltaToolCall, + RunStepDeltaToolCallObject, + RunStepDetails, + RunStepDetailsActivity, + RunStepError, + RunStepFileSearchToolCall, + RunStepFileSearchToolCallResult, + RunStepFileSearchToolCallResults, + RunStepFunctionToolCall, + RunStepFunctionToolCallDetails, + RunStepMcpToolCall, + RunStepMessageCreationDetails, + RunStepMessageCreationReference, + RunStepMicrosoftFabricToolCall, + RunStepOpenAPIToolCall, + RunStepSharepointToolCall, + RunStepToolCall, + RunStepToolCallDetails, + SafetyCheck, + ScreenshotAction, + ScrollAction, + SharepointGroundingToolParameters, + SharepointToolDefinition, + StructuredToolOutput, + SubmitToolApprovalAction, + SubmitToolApprovalDetails, + SubmitToolOutputsAction, + SubmitToolOutputsDetails, + ThreadMessage, + ThreadMessageOptions, + ThreadRun, + ToolApproval, + ToolConnection, + ToolDefinition, + ToolOutput, + ToolResources, + TruncationObject, + TypeAction, + VectorStore, + VectorStoreAutoChunkingStrategyRequest, + VectorStoreAutoChunkingStrategyResponse, + VectorStoreChunkingStrategyRequest, + VectorStoreChunkingStrategyResponse, + VectorStoreConfiguration, + VectorStoreConfigurations, + VectorStoreDataSource, + VectorStoreExpirationPolicy, + VectorStoreFile, + VectorStoreFileBatch, + VectorStoreFileCount, + VectorStoreFileError, + VectorStoreStaticChunkingStrategyOptions, + VectorStoreStaticChunkingStrategyRequest, + VectorStoreStaticChunkingStrategyResponse, + WaitAction, +) + +from ._enums import ( # type: ignore + AgentStreamEvent, + AgentsNamedToolChoiceType, + AgentsResponseFormatMode, + AgentsToolChoiceOptionMode, + AzureAISearchQueryType, + ComputerUseEnvironment, + DoneEvent, + ErrorEvent, + FilePurpose, + FileState, + ImageDetailLevel, + IncompleteDetailsReason, + ListSortOrder, + MessageBlockType, + MessageIncompleteDetailsReason, + MessageRole, + MessageStatus, + MessageStreamEvent, + MouseButton, + OpenApiAuthType, + ResponseFormat, + RunAdditionalFieldList, + RunStatus, + RunStepErrorCode, + RunStepStatus, + RunStepStreamEvent, + RunStepType, + RunStreamEvent, + ThreadStreamEvent, + TruncationStrategy, + VectorStoreChunkingStrategyRequestType, + VectorStoreChunkingStrategyResponseType, + VectorStoreDataSourceAssetType, + VectorStoreExpirationPolicyAnchor, + VectorStoreFileBatchStatus, + VectorStoreFileErrorCode, + VectorStoreFileStatus, + VectorStoreFileStatusFilter, + VectorStoreStatus, +) from ._patch import __all__ as _patch_all from ._patch import * from ._patch import patch_sdk as _patch_sdk -__all__ = [] +__all__ = [ + "AISearchIndexResource", + "ActivityFunctionDefinition", + "ActivityFunctionParameters", + "Agent", + "AgentErrorDetail", + "AgentThread", + "AgentThreadCreationOptions", + "AgentV1Error", + "AgentsNamedToolChoice", + "AgentsResponseFormat", + "AzureAISearchToolDefinition", + "AzureAISearchToolResource", + "AzureFunctionBinding", + "AzureFunctionDefinition", + "AzureFunctionStorageQueue", + "AzureFunctionToolCallDetails", + "AzureFunctionToolDefinition", + "BingCustomSearchConfiguration", + "BingCustomSearchToolDefinition", + "BingCustomSearchToolParameters", + "BingGroundingSearchConfiguration", + "BingGroundingSearchToolParameters", + "BingGroundingToolDefinition", + "BrowserAutomationToolCallDetails", + "BrowserAutomationToolCallStep", + "BrowserAutomationToolConnectionParameters", + "BrowserAutomationToolDefinition", + "BrowserAutomationToolParameters", + "ClickAction", + "CodeInterpreterToolDefinition", + "CodeInterpreterToolResource", + "ComputerScreenshot", + "ComputerToolOutput", + "ComputerUseAction", + "ComputerUseToolDefinition", + "ComputerUseToolParameters", + "ConnectedAgentDetails", + "ConnectedAgentToolDefinition", + "CoordinatePoint", + "DeepResearchBingGroundingConnection", + "DeepResearchDetails", + "DeepResearchToolDefinition", + "DoubleClickAction", + "DragAction", + "FabricDataAgentToolParameters", + "FileInfo", + "FileListResponse", + "FileSearchRankingOptions", + "FileSearchToolCallContent", + "FileSearchToolDefinition", + "FileSearchToolDefinitionDetails", + "FileSearchToolResource", + "FunctionArgument", + "FunctionDefinition", + "FunctionName", + "FunctionToolDefinition", + "IncompleteRunDetails", + "KeyPressAction", + "MCPApprovalPerTool", + "MCPToolDefinition", + "MCPToolList", + "MCPToolResource", + "MessageAttachment", + "MessageContent", + "MessageDelta", + "MessageDeltaChunk", + "MessageDeltaContent", + "MessageDeltaImageFileContent", + "MessageDeltaImageFileContentObject", + "MessageDeltaTextAnnotation", + "MessageDeltaTextContent", + "MessageDeltaTextContentObject", + "MessageDeltaTextFileCitationAnnotation", + "MessageDeltaTextFileCitationAnnotationObject", + "MessageDeltaTextFilePathAnnotation", + "MessageDeltaTextFilePathAnnotationObject", + "MessageDeltaTextUrlCitationAnnotation", + "MessageDeltaTextUrlCitationDetails", + "MessageImageFileContent", + "MessageImageFileDetails", + "MessageImageFileParam", + "MessageImageUrlParam", + "MessageIncompleteDetails", + "MessageInputContentBlock", + "MessageInputImageFileBlock", + "MessageInputImageUrlBlock", + "MessageInputTextBlock", + "MessageTextAnnotation", + "MessageTextContent", + "MessageTextDetails", + "MessageTextFileCitationAnnotation", + "MessageTextFileCitationDetails", + "MessageTextFilePathAnnotation", + "MessageTextFilePathDetails", + "MessageTextUrlCitationAnnotation", + "MessageTextUrlCitationDetails", + "MicrosoftFabricToolDefinition", + "MoveAction", + "OpenApiAnonymousAuthDetails", + "OpenApiAuthDetails", + "OpenApiConnectionAuthDetails", + "OpenApiConnectionSecurityScheme", + "OpenApiFunctionDefinition", + "OpenApiManagedAuthDetails", + "OpenApiManagedSecurityScheme", + "OpenApiToolDefinition", + "RequiredAction", + "RequiredComputerUseToolCall", + "RequiredComputerUseToolCallDetails", + "RequiredFunctionToolCall", + "RequiredFunctionToolCallDetails", + "RequiredMcpToolCall", + "RequiredToolCall", + "ResponseFormatJsonSchema", + "ResponseFormatJsonSchemaType", + "RunCompletionUsage", + "RunError", + "RunStep", + "RunStepActivityDetails", + "RunStepAzureAISearchToolCall", + "RunStepAzureFunctionToolCall", + "RunStepBingCustomSearchToolCall", + "RunStepBingGroundingToolCall", + "RunStepBrowserAutomationToolCall", + "RunStepCodeInterpreterImageOutput", + "RunStepCodeInterpreterImageReference", + "RunStepCodeInterpreterLogOutput", + "RunStepCodeInterpreterToolCall", + "RunStepCodeInterpreterToolCallDetails", + "RunStepCodeInterpreterToolCallOutput", + "RunStepCompletionUsage", + "RunStepComputerUseToolCall", + "RunStepComputerUseToolCallDetails", + "RunStepConnectedAgent", + "RunStepConnectedAgentToolCall", + "RunStepDeepResearchToolCall", + "RunStepDeepResearchToolCallDetails", + "RunStepDelta", + "RunStepDeltaAzureAISearchToolCall", + "RunStepDeltaAzureFunctionToolCall", + "RunStepDeltaBingGroundingToolCall", + "RunStepDeltaChunk", + "RunStepDeltaCodeInterpreterDetailItemObject", + "RunStepDeltaCodeInterpreterImageOutput", + "RunStepDeltaCodeInterpreterImageOutputObject", + "RunStepDeltaCodeInterpreterLogOutput", + "RunStepDeltaCodeInterpreterOutput", + "RunStepDeltaCodeInterpreterToolCall", + "RunStepDeltaComputerUseDetails", + "RunStepDeltaComputerUseToolCall", + "RunStepDeltaConnectedAgentToolCall", + "RunStepDeltaCustomBingGroundingToolCall", + "RunStepDeltaDeepResearchToolCall", + "RunStepDeltaDetail", + "RunStepDeltaFileSearchToolCall", + "RunStepDeltaFunction", + "RunStepDeltaFunctionToolCall", + "RunStepDeltaMCPObject", + "RunStepDeltaMcpToolCall", + "RunStepDeltaMessageCreation", + "RunStepDeltaMessageCreationObject", + "RunStepDeltaMicrosoftFabricToolCall", + "RunStepDeltaOpenAPIObject", + "RunStepDeltaOpenAPIToolCall", + "RunStepDeltaSharepointToolCall", + "RunStepDeltaToolCall", + "RunStepDeltaToolCallObject", + "RunStepDetails", + "RunStepDetailsActivity", + "RunStepError", + "RunStepFileSearchToolCall", + "RunStepFileSearchToolCallResult", + "RunStepFileSearchToolCallResults", + "RunStepFunctionToolCall", + "RunStepFunctionToolCallDetails", + "RunStepMcpToolCall", + "RunStepMessageCreationDetails", + "RunStepMessageCreationReference", + "RunStepMicrosoftFabricToolCall", + "RunStepOpenAPIToolCall", + "RunStepSharepointToolCall", + "RunStepToolCall", + "RunStepToolCallDetails", + "SafetyCheck", + "ScreenshotAction", + "ScrollAction", + "SharepointGroundingToolParameters", + "SharepointToolDefinition", + "StructuredToolOutput", + "SubmitToolApprovalAction", + "SubmitToolApprovalDetails", + "SubmitToolOutputsAction", + "SubmitToolOutputsDetails", + "ThreadMessage", + "ThreadMessageOptions", + "ThreadRun", + "ToolApproval", + "ToolConnection", + "ToolDefinition", + "ToolOutput", + "ToolResources", + "TruncationObject", + "TypeAction", + "VectorStore", + "VectorStoreAutoChunkingStrategyRequest", + "VectorStoreAutoChunkingStrategyResponse", + "VectorStoreChunkingStrategyRequest", + "VectorStoreChunkingStrategyResponse", + "VectorStoreConfiguration", + "VectorStoreConfigurations", + "VectorStoreDataSource", + "VectorStoreExpirationPolicy", + "VectorStoreFile", + "VectorStoreFileBatch", + "VectorStoreFileCount", + "VectorStoreFileError", + "VectorStoreStaticChunkingStrategyOptions", + "VectorStoreStaticChunkingStrategyRequest", + "VectorStoreStaticChunkingStrategyResponse", + "WaitAction", + "AgentStreamEvent", + "AgentsNamedToolChoiceType", + "AgentsResponseFormatMode", + "AgentsToolChoiceOptionMode", + "AzureAISearchQueryType", + "ComputerUseEnvironment", + "DoneEvent", + "ErrorEvent", + "FilePurpose", + "FileState", + "ImageDetailLevel", + "IncompleteDetailsReason", + "ListSortOrder", + "MessageBlockType", + "MessageIncompleteDetailsReason", + "MessageRole", + "MessageStatus", + "MessageStreamEvent", + "MouseButton", + "OpenApiAuthType", + "ResponseFormat", + "RunAdditionalFieldList", + "RunStatus", + "RunStepErrorCode", + "RunStepStatus", + "RunStepStreamEvent", + "RunStepType", + "RunStreamEvent", + "ThreadStreamEvent", + "TruncationStrategy", + "VectorStoreChunkingStrategyRequestType", + "VectorStoreChunkingStrategyResponseType", + "VectorStoreDataSourceAssetType", + "VectorStoreExpirationPolicyAnchor", + "VectorStoreFileBatchStatus", + "VectorStoreFileErrorCode", + "VectorStoreFileStatus", + "VectorStoreFileStatusFilter", + "VectorStoreStatus", +] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/ai/azure-ai-agents/azure/ai/agents/models/_models.py b/sdk/ai/azure-ai-agents/azure/ai/agents/models/_models.py index dc7ec89e633b..09dd194b5a8f 100644 --- a/sdk/ai/azure-ai-agents/azure/ai/agents/models/_models.py +++ b/sdk/ai/azure-ai-agents/azure/ai/agents/models/_models.py @@ -1,4 +1,3 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/ai/azure-ai-agents/azure/ai/agents/operations/__init__.py b/sdk/ai/azure-ai-agents/azure/ai/agents/operations/__init__.py index ac09c02d32cd..a3f2341966aa 100644 --- a/sdk/ai/azure-ai-agents/azure/ai/agents/operations/__init__.py +++ b/sdk/ai/azure-ai-agents/azure/ai/agents/operations/__init__.py @@ -12,27 +12,29 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._operations import BetaOperations # type: ignore -from ._operations import AgentsOperations # type: ignore -from ._operations import EvaluationRulesOperations # type: ignore -from ._operations import ConnectionsOperations # type: ignore -from ._operations import DatasetsOperations # type: ignore -from ._operations import DeploymentsOperations # type: ignore -from ._operations import IndexesOperations # type: ignore -from ._operations import _AIProjectClientOperationsMixin # type: ignore # pylint: disable=unused-import +from ._operations import ThreadsOperations # type: ignore +from ._operations import MessagesOperations # type: ignore +from ._operations import RunsOperations # type: ignore +from ._operations import RunStepsOperations # type: ignore +from ._operations import FilesOperations # type: ignore +from ._operations import VectorStoresOperations # type: ignore +from ._operations import VectorStoreFilesOperations # type: ignore +from ._operations import VectorStoreFileBatchesOperations # type: ignore +from ._operations import _AgentsClientOperationsMixin # type: ignore # pylint: disable=unused-import from ._patch import __all__ as _patch_all from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ - "BetaOperations", - "AgentsOperations", - "EvaluationRulesOperations", - "ConnectionsOperations", - "DatasetsOperations", - "DeploymentsOperations", - "IndexesOperations", + "ThreadsOperations", + "MessagesOperations", + "RunsOperations", + "RunStepsOperations", + "FilesOperations", + "VectorStoresOperations", + "VectorStoreFilesOperations", + "VectorStoreFileBatchesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/ai/azure-ai-agents/azure/ai/agents/operations/_operations.py b/sdk/ai/azure-ai-agents/azure/ai/agents/operations/_operations.py index 53812981e831..eba194bfb068 100644 --- a/sdk/ai/azure-ai-agents/azure/ai/agents/operations/_operations.py +++ b/sdk/ai/azure-ai-agents/azure/ai/agents/operations/_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,11 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from collections.abc import MutableMapping -import datetime from io import IOBase -from typing import Any, Callable, IO, Iterator, Literal, Optional, TypeVar, Union, cast, overload +import json +from typing import Any, Callable, IO, Iterator, Optional, TYPE_CHECKING, TypeVar, Union, overload import urllib.parse -import uuid from azure.core import PipelineClient from azure.core.exceptions import ( @@ -26,20 +24,21 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.polling.base_polling import LROBasePolling from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict -from .. import types, types as _types_models1 -from .._configuration import AIProjectClientConfiguration +from .. import models as _models +from .._configuration import AgentsClientConfiguration +from .._utils.model_base import Model as _Model, SdkJSONEncoder, _deserialize, _failsafe_deserialize from .._utils.serialization import Deserializer, Serializer -from .._utils.utils import ClientMixinABC -from ..models._enums import FoundryFeaturesOptInKeys +from .._utils.utils import ClientMixinABC, prepare_multipart_form_data +from .._validation import api_version_validation -_Unset: Any = object() +if TYPE_CHECKING: + from .. import _types JSON = MutableMapping[str, Any] +_Unset: Any = object() T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] List = list @@ -48,70 +47,73 @@ _SERIALIZER.client_side_validation = False -def build_agents_get_request(agent_name: str, **kwargs: Any) -> HttpRequest: +def build_threads_create_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/agents/{agent_name}" - path_format_arguments = { - "agent_name": _SERIALIZER.url("agent_name", agent_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore + _url = "/threads" # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_agents_create_agent_request( - *, foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, **kwargs: Any +def build_threads_list_request( + *, + limit: Optional[int] = None, + order: Optional[Union[str, _models.ListSortOrder]] = None, + after: Optional[str] = None, + before: Optional[str] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/agents" + _url = "/threads" # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if limit is not None: + _params["limit"] = _SERIALIZER.query("limit", limit, "int") + if order is not None: + _params["order"] = _SERIALIZER.query("order", order, "str") + if after is not None: + _params["after"] = _SERIALIZER.query("after", after, "str") + if before is not None: + _params["before"] = _SERIALIZER.query("before", before, "str") # Construct headers - if foundry_features is not None: - _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_agents_update_agent_request( - agent_name: str, *, foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, **kwargs: Any -) -> HttpRequest: +def build_threads_get_request(thread_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/agents/{agent_name}" + _url = "/threads/{threadId}" path_format_arguments = { - "agent_name": _SERIALIZER.url("agent_name", agent_name, "str"), + "threadId": _SERIALIZER.url("thread_id", thread_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -120,25 +122,26 @@ def build_agents_update_agent_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if foundry_features is not None: - _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_agents_create_agent_from_manifest_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long +def build_threads_update_request(thread_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/agents:import" + _url = "/threads/{threadId}" + path_format_arguments = { + "threadId": _SERIALIZER.url("thread_id", thread_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -151,20 +154,17 @@ def build_agents_create_agent_from_manifest_request(**kwargs: Any) -> HttpReques return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_agents_update_agent_from_manifest_request( # pylint: disable=name-too-long - agent_name: str, **kwargs: Any -) -> HttpRequest: +def build_threads_delete_thread_request(thread_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/agents/{agent_name}/import" + _url = "/threads/{threadId}" path_format_arguments = { - "agent_name": _SERIALIZER.url("agent_name", agent_name, "str"), + "threadId": _SERIALIZER.url("thread_id", thread_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -173,24 +173,23 @@ def build_agents_update_agent_from_manifest_request( # pylint: disable=name-too _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_agents_delete_request(agent_name: str, **kwargs: Any) -> HttpRequest: +def build_messages_create_request(thread_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/agents/{agent_name}" + _url = "/threads/{threadId}/messages" path_format_arguments = { - "agent_name": _SERIALIZER.url("agent_name", agent_name, "str"), + "threadId": _SERIALIZER.url("thread_id", thread_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -199,16 +198,19 @@ def build_agents_delete_request(agent_name: str, **kwargs: Any) -> HttpRequest: _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_agents_list_request( +def build_messages_list_request( + thread_id: str, *, - kind: Optional[types.AgentKind] = None, + run_id: Optional[str] = None, limit: Optional[int] = None, - order: Optional[types.PageOrder] = None, + order: Optional[Union[str, _models.ListSortOrder]] = None, after: Optional[str] = None, before: Optional[str] = None, **kwargs: Any @@ -216,15 +218,21 @@ def build_agents_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/agents" + _url = "/threads/{threadId}/messages" + path_format_arguments = { + "threadId": _SERIALIZER.url("thread_id", thread_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if kind is not None: - _params["kind"] = _SERIALIZER.query("kind", kind, "str") + if run_id is not None: + _params["run_id"] = _SERIALIZER.query("run_id", run_id, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if limit is not None: _params["limit"] = _SERIALIZER.query("limit", limit, "int") if order is not None: @@ -233,7 +241,6 @@ def build_agents_list_request( _params["after"] = _SERIALIZER.query("after", after, "str") if before is not None: _params["before"] = _SERIALIZER.query("before", before, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -241,20 +248,18 @@ def build_agents_list_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_agents_create_version_request( - agent_name: str, *, foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, **kwargs: Any -) -> HttpRequest: +def build_messages_get_request(thread_id: str, message_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/agents/{agent_name}/versions" + _url = "/threads/{threadId}/messages/{messageId}" path_format_arguments = { - "agent_name": _SERIALIZER.url("agent_name", agent_name, "str"), + "threadId": _SERIALIZER.url("thread_id", thread_id, "str"), + "messageId": _SERIALIZER.url("message_id", message_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -263,29 +268,24 @@ def build_agents_create_version_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if foundry_features is not None: - _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_agents_create_version_from_manifest_request( # pylint: disable=name-too-long - agent_name: str, **kwargs: Any -) -> HttpRequest: +def build_messages_update_request(thread_id: str, message_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/agents/{agent_name}/versions:import" + _url = "/threads/{threadId}/messages/{messageId}" path_format_arguments = { - "agent_name": _SERIALIZER.url("agent_name", agent_name, "str"), + "threadId": _SERIALIZER.url("thread_id", thread_id, "str"), + "messageId": _SERIALIZER.url("message_id", message_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -301,18 +301,18 @@ def build_agents_create_version_from_manifest_request( # pylint: disable=name-t return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_agents_get_version_request(agent_name: str, agent_version: str, **kwargs: Any) -> HttpRequest: +def build_messages_delete_request(thread_id: str, message_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/agents/{agent_name}/versions/{agent_version}" + _url = "/threads/{threadId}/messages/{messageId}" path_format_arguments = { - "agent_name": _SERIALIZER.url("agent_name", agent_name, "str"), - "agent_version": _SERIALIZER.url("agent_version", agent_version, "str"), + "threadId": _SERIALIZER.url("thread_id", thread_id, "str"), + "messageId": _SERIALIZER.url("message_id", message_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -323,39 +323,45 @@ def build_agents_get_version_request(agent_name: str, agent_version: str, **kwar # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_agents_delete_version_request(agent_name: str, agent_version: str, **kwargs: Any) -> HttpRequest: +def build_runs_create_request( + thread_id: str, *, include: Optional[List[Union[str, _models.RunAdditionalFieldList]]] = None, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/agents/{agent_name}/versions/{agent_version}" + _url = "/threads/{threadId}/runs" path_format_arguments = { - "agent_name": _SERIALIZER.url("agent_name", agent_name, "str"), - "agent_version": _SERIALIZER.url("agent_version", agent_version, "str"), + "threadId": _SERIALIZER.url("thread_id", thread_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if include is not None: + _params["include[]"] = _SERIALIZER.query("include", include, "[str]", div=",") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_agents_list_versions_request( - agent_name: str, +def build_runs_list_request( + thread_id: str, *, limit: Optional[int] = None, - order: Optional[types.PageOrder] = None, + order: Optional[Union[str, _models.ListSortOrder]] = None, after: Optional[str] = None, before: Optional[str] = None, **kwargs: Any @@ -363,18 +369,19 @@ def build_agents_list_versions_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/agents/{agent_name}/versions" + _url = "/threads/{threadId}/runs" path_format_arguments = { - "agent_name": _SERIALIZER.url("agent_name", agent_name, "str"), + "threadId": _SERIALIZER.url("thread_id", thread_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if limit is not None: _params["limit"] = _SERIALIZER.query("limit", limit, "int") if order is not None: @@ -383,7 +390,6 @@ def build_agents_list_versions_request( _params["after"] = _SERIALIZER.query("after", after, "str") if before is not None: _params["before"] = _SERIALIZER.query("before", before, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -391,17 +397,18 @@ def build_agents_list_versions_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_evaluation_rules_get_request(id: str, **kwargs: Any) -> HttpRequest: +def build_runs_get_request(thread_id: str, run_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/evaluationrules/{id}" + _url = "/threads/{threadId}/runs/{runId}" path_format_arguments = { - "id": _SERIALIZER.url("id", id, "str"), + "threadId": _SERIALIZER.url("thread_id", thread_id, "str"), + "runId": _SERIALIZER.url("run_id", run_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -415,14 +422,19 @@ def build_evaluation_rules_get_request(id: str, **kwargs: Any) -> HttpRequest: return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_evaluation_rules_delete_request(id: str, **kwargs: Any) -> HttpRequest: +def build_runs_update_request(thread_id: str, run_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = "/evaluationrules/{id}" + _url = "/threads/{threadId}/runs/{runId}" path_format_arguments = { - "id": _SERIALIZER.url("id", id, "str"), + "threadId": _SERIALIZER.url("thread_id", thread_id, "str"), + "runId": _SERIALIZER.url("run_id", run_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -430,26 +442,27 @@ def build_evaluation_rules_delete_request(id: str, **kwargs: Any) -> HttpRequest # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_evaluation_rules_create_or_update_request( # pylint: disable=name-too-long - id: str, - *, - foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW]] = None, - **kwargs: Any -) -> HttpRequest: +def build_runs_submit_tool_outputs_request(thread_id: str, run_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/evaluationrules/{id}" + _url = "/threads/{threadId}/runs/{runId}/submit_tool_outputs" path_format_arguments = { - "id": _SERIALIZER.url("id", id, "str"), + "threadId": _SERIALIZER.url("thread_id", thread_id, "str"), + "runId": _SERIALIZER.url("run_id", run_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -458,63 +471,66 @@ def build_evaluation_rules_create_or_update_request( # pylint: disable=name-too _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if foundry_features is not None: - _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_evaluation_rules_list_request( - *, - action_type: Optional[types.EvaluationRuleActionType] = None, - agent_name: Optional[str] = None, - enabled: Optional[bool] = None, - **kwargs: Any -) -> HttpRequest: +def build_runs_cancel_request(thread_id: str, run_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/evaluationrules" + _url = "/threads/{threadId}/runs/{runId}/cancel" + path_format_arguments = { + "threadId": _SERIALIZER.url("thread_id", thread_id, "str"), + "runId": _SERIALIZER.url("run_id", run_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if action_type is not None: - _params["actionType"] = _SERIALIZER.query("action_type", action_type, "str") - if agent_name is not None: - _params["agentName"] = _SERIALIZER.query("agent_name", agent_name, "str") - if enabled is not None: - _params["enabled"] = _SERIALIZER.query("enabled", enabled, "bool") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_connections_get_request(name: str, **kwargs: Any) -> HttpRequest: +def build_run_steps_get_request( + thread_id: str, + run_id: str, + step_id: str, + *, + include: Optional[List[Union[str, _models.RunAdditionalFieldList]]] = None, + **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/connections/{name}" + _url = "/threads/{threadId}/runs/{runId}/steps/{stepId}" path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), + "threadId": _SERIALIZER.url("thread_id", thread_id, "str"), + "runId": _SERIALIZER.url("run_id", run_id, "str"), + "stepId": _SERIALIZER.url("step_id", step_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if include is not None: + _params["include[]"] = _SERIALIZER.query("include", include, "[str]", div=",") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -522,50 +538,67 @@ def build_connections_get_request(name: str, **kwargs: Any) -> HttpRequest: return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_connections_get_with_credentials_request( # pylint: disable=name-too-long - name: str, **kwargs: Any +def build_run_steps_list_request( + thread_id: str, + run_id: str, + *, + include: Optional[List[Union[str, _models.RunAdditionalFieldList]]] = None, + limit: Optional[int] = None, + order: Optional[Union[str, _models.ListSortOrder]] = None, + after: Optional[str] = None, + before: Optional[str] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/connections/{name}/getConnectionWithCredentials" + _url = "/threads/{threadId}/runs/{runId}/steps" path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), + "threadId": _SERIALIZER.url("thread_id", thread_id, "str"), + "runId": _SERIALIZER.url("run_id", run_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters + if include is not None: + _params["include[]"] = _SERIALIZER.query("include", include, "[str]", div=",") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if limit is not None: + _params["limit"] = _SERIALIZER.query("limit", limit, "int") + if order is not None: + _params["order"] = _SERIALIZER.query("order", order, "str") + if after is not None: + _params["after"] = _SERIALIZER.query("after", after, "str") + if before is not None: + _params["before"] = _SERIALIZER.query("before", before, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_connections_list_request( - *, connection_type: Optional[types.ConnectionType] = None, default_connection: Optional[bool] = None, **kwargs: Any +def build_files_list_request( + *, purpose: Optional[Union[str, _models.FilePurpose]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/connections" + _url = "/files" # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if connection_type is not None: - _params["connectionType"] = _SERIALIZER.query("connection_type", connection_type, "str") - if default_connection is not None: - _params["defaultConnection"] = _SERIALIZER.query("default_connection", default_connection, "bool") + if purpose is not None: + _params["purpose"] = _SERIALIZER.query("purpose", purpose, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -573,20 +606,15 @@ def build_connections_list_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_datasets_list_versions_request(name: str, **kwargs: Any) -> HttpRequest: +def build_files_upload_file_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/datasets/{name}/versions" - path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore + _url = "/files" # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -594,18 +622,23 @@ def build_datasets_list_versions_request(name: str, **kwargs: Any) -> HttpReques # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_datasets_list_request(**kwargs: Any) -> HttpRequest: +def build_files_delete_file_request(file_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/datasets" + _url = "/files/{fileId}" + path_format_arguments = { + "fileId": _SERIALIZER.url("file_id", file_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -613,21 +646,20 @@ def build_datasets_list_request(**kwargs: Any) -> HttpRequest: # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_datasets_get_request(name: str, version: str, **kwargs: Any) -> HttpRequest: +def build_files_get_request(file_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/datasets/{name}/versions/{version}" + _url = "/files/{fileId}" path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - "version": _SERIALIZER.url("version", version, "str"), + "fileId": _SERIALIZER.url("file_id", file_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -641,15 +673,17 @@ def build_datasets_get_request(name: str, version: str, **kwargs: Any) -> HttpRe return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_datasets_delete_request(name: str, version: str, **kwargs: Any) -> HttpRequest: +def build_files_get_file_content_request(file_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) + accept = _headers.pop("Accept", "application/octet-stream") + # Construct URL - _url = "/datasets/{name}/versions/{version}" + _url = "/files/{fileId}/content" path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - "version": _SERIALIZER.url("version", version, "str"), + "fileId": _SERIALIZER.url("file_id", file_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -657,53 +691,56 @@ def build_datasets_delete_request(name: str, version: str, **kwargs: Any) -> Htt # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_datasets_create_or_update_request(name: str, version: str, **kwargs: Any) -> HttpRequest: +def build_vector_stores_list_request( + *, + limit: Optional[int] = None, + order: Optional[Union[str, _models.ListSortOrder]] = None, + after: Optional[str] = None, + before: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/datasets/{name}/versions/{version}" - path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - "version": _SERIALIZER.url("version", version, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore + _url = "/vector_stores" # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if limit is not None: + _params["limit"] = _SERIALIZER.query("limit", limit, "int") + if order is not None: + _params["order"] = _SERIALIZER.query("order", order, "str") + if after is not None: + _params["after"] = _SERIALIZER.query("after", after, "str") + if before is not None: + _params["before"] = _SERIALIZER.query("before", before, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_datasets_pending_upload_request(name: str, version: str, **kwargs: Any) -> HttpRequest: +def build_vector_stores_create_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/datasets/{name}/versions/{version}/startPendingUpload" - path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - "version": _SERIALIZER.url("version", version, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore + _url = "/vector_stores" # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -716,18 +753,17 @@ def build_datasets_pending_upload_request(name: str, version: str, **kwargs: Any return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_datasets_get_credentials_request(name: str, version: str, **kwargs: Any) -> HttpRequest: +def build_vector_stores_get_request(vector_store_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/datasets/{name}/versions/{version}/credentials" + _url = "/vector_stores/{vectorStoreId}" path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - "version": _SERIALIZER.url("version", version, "str"), + "vectorStoreId": _SERIALIZER.url("vector_store_id", vector_store_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -738,20 +774,21 @@ def build_datasets_get_credentials_request(name: str, version: str, **kwargs: An # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_get_request(name: str, **kwargs: Any) -> HttpRequest: +def build_vector_stores_modify_request(vector_store_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/deployments/{name}" + _url = "/vector_stores/{vectorStoreId}" path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), + "vectorStoreId": _SERIALIZER.url("vector_store_id", vector_store_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -760,59 +797,75 @@ def build_deployments_get_request(name: str, **kwargs: Any) -> HttpRequest: _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_list_request( - *, - model_publisher: Optional[str] = None, - model_name: Optional[str] = None, - deployment_type: Optional[types.DeploymentType] = None, - **kwargs: Any +def build_vector_stores_delete_vector_store_request( # pylint: disable=name-too-long + vector_store_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/deployments" + _url = "/vector_stores/{vectorStoreId}" + path_format_arguments = { + "vectorStoreId": _SERIALIZER.url("vector_store_id", vector_store_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if model_publisher is not None: - _params["modelPublisher"] = _SERIALIZER.query("model_publisher", model_publisher, "str") - if model_name is not None: - _params["modelName"] = _SERIALIZER.query("model_name", model_name, "str") - if deployment_type is not None: - _params["deploymentType"] = _SERIALIZER.query("deployment_type", deployment_type, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_indexes_list_versions_request(name: str, **kwargs: Any) -> HttpRequest: +def build_vector_store_files_list_request( + vector_store_id: str, + *, + filter: Optional[Union[str, _models.VectorStoreFileStatusFilter]] = None, + limit: Optional[int] = None, + order: Optional[Union[str, _models.ListSortOrder]] = None, + after: Optional[str] = None, + before: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/indexes/{name}/versions" + _url = "/vector_stores/{vectorStoreId}/files" path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), + "vectorStoreId": _SERIALIZER.url("vector_store_id", vector_store_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters + if filter is not None: + _params["filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if limit is not None: + _params["limit"] = _SERIALIZER.query("limit", limit, "int") + if order is not None: + _params["order"] = _SERIALIZER.query("order", order, "str") + if after is not None: + _params["after"] = _SERIALIZER.query("after", after, "str") + if before is not None: + _params["before"] = _SERIALIZER.query("before", before, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -820,37 +873,45 @@ def build_indexes_list_versions_request(name: str, **kwargs: Any) -> HttpRequest return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_indexes_list_request(**kwargs: Any) -> HttpRequest: +def build_vector_store_files_create_request(vector_store_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/indexes" + _url = "/vector_stores/{vectorStoreId}/files" + path_format_arguments = { + "vectorStoreId": _SERIALIZER.url("vector_store_id", vector_store_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_indexes_get_request(name: str, version: str, **kwargs: Any) -> HttpRequest: +def build_vector_store_files_get_request(vector_store_id: str, file_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/indexes/{name}/versions/{version}" + _url = "/vector_stores/{vectorStoreId}/files/{fileId}" path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - "version": _SERIALIZER.url("version", version, "str"), + "vectorStoreId": _SERIALIZER.url("vector_store_id", vector_store_id, "str"), + "fileId": _SERIALIZER.url("file_id", file_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -864,15 +925,20 @@ def build_indexes_get_request(name: str, version: str, **kwargs: Any) -> HttpReq return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_indexes_delete_request(name: str, version: str, **kwargs: Any) -> HttpRequest: +def build_vector_store_files_delete_vector_store_file_request( # pylint: disable=name-too-long + vector_store_id: str, file_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = "/indexes/{name}/versions/{version}" + _url = "/vector_stores/{vectorStoreId}/files/{fileId}" path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - "version": _SERIALIZER.url("version", version, "str"), + "vectorStoreId": _SERIALIZER.url("vector_store_id", vector_store_id, "str"), + "fileId": _SERIALIZER.url("file_id", file_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -880,22 +946,26 @@ def build_indexes_delete_request(name: str, version: str, **kwargs: Any) -> Http # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_indexes_create_or_update_request(name: str, version: str, **kwargs: Any) -> HttpRequest: +def build_vector_store_file_batches_create_request( # pylint: disable=name-too-long + vector_store_id: str, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/indexes/{name}/versions/{version}" + _url = "/vector_stores/{vectorStoreId}/file_batches" path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - "version": _SERIALIZER.url("version", version, "str"), + "vectorStoreId": _SERIALIZER.url("vector_store_id", vector_store_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -908,40 +978,23 @@ def build_indexes_create_or_update_request(name: str, version: str, **kwargs: An _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_ai_project_delete_job_request(job_id: str, **kwargs: Any) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) - # Construct URL - _url = "/{jobId}" - path_format_arguments = { - "jobId": _SERIALIZER.url("job_id", job_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_evaluation_taxonomies_get_request( # pylint: disable=name-too-long - name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], **kwargs: Any +def build_vector_store_file_batches_get_request( # pylint: disable=name-too-long + vector_store_id: str, batch_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/evaluationtaxonomies/{name}" + _url = "/vector_stores/{vectorStoreId}/file_batches/{batchId}" path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), + "vectorStoreId": _SERIALIZER.url("vector_store_id", vector_store_id, "str"), + "batchId": _SERIALIZER.url("batch_id", batch_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -950,210 +1003,150 @@ def build_beta_evaluation_taxonomies_get_request( # pylint: disable=name-too-lo _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_evaluation_taxonomies_list_request( # pylint: disable=name-too-long - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], - input_name: Optional[str] = None, - input_type: Optional[str] = None, - **kwargs: Any +def build_vector_store_file_batches_cancel_request( # pylint: disable=name-too-long + vector_store_id: str, batch_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/evaluationtaxonomies" + _url = "/vector_stores/{vectorStoreId}/file_batches/{batchId}/cancel" + path_format_arguments = { + "vectorStoreId": _SERIALIZER.url("vector_store_id", vector_store_id, "str"), + "batchId": _SERIALIZER.url("batch_id", batch_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if input_name is not None: - _params["inputName"] = _SERIALIZER.query("input_name", input_name, "str") - if input_type is not None: - _params["inputType"] = _SERIALIZER.query("input_type", input_type, "str") # Construct headers - _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_evaluation_taxonomies_delete_request( # pylint: disable=name-too-long - name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], **kwargs: Any +def build_vector_store_file_batches_list_files_request( # pylint: disable=name-too-long + vector_store_id: str, + batch_id: str, + *, + filter: Optional[Union[str, _models.VectorStoreFileStatusFilter]] = None, + limit: Optional[int] = None, + order: Optional[Union[str, _models.ListSortOrder]] = None, + after: Optional[str] = None, + before: Optional[str] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = "/evaluationtaxonomies/{name}" + _url = "/vector_stores/{vectorStoreId}/file_batches/{batchId}/files" path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), + "vectorStoreId": _SERIALIZER.url("vector_store_id", vector_store_id, "str"), + "batchId": _SERIALIZER.url("batch_id", batch_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters + if filter is not None: + _params["filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if limit is not None: + _params["limit"] = _SERIALIZER.query("limit", limit, "int") + if order is not None: + _params["order"] = _SERIALIZER.query("order", order, "str") + if after is not None: + _params["after"] = _SERIALIZER.query("after", after, "str") + if before is not None: + _params["before"] = _SERIALIZER.query("before", before, "str") # Construct headers - _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_evaluation_taxonomies_create_request( # pylint: disable=name-too-long - name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], **kwargs: Any -) -> HttpRequest: +def build_agents_create_agent_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/evaluationtaxonomies/{name}" - path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore + _url = "/assistants" # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_evaluation_taxonomies_update_request( # pylint: disable=name-too-long - name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/evaluationtaxonomies/{name}" - path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_beta_evaluators_list_versions_request( # pylint: disable=name-too-long - name: str, - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], - type: Optional[Union[Literal["builtin"], Literal["custom"], Literal["all"], str]] = None, - limit: Optional[int] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/evaluators/{name}/versions" - path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if type is not None: - _params["type"] = _SERIALIZER.query("type", type, "str") - if limit is not None: - _params["limit"] = _SERIALIZER.query("limit", limit, "int") - - # Construct headers - _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_beta_evaluators_list_request( +def build_agents_list_agents_request( *, - foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], - type: Optional[Union[Literal["builtin"], Literal["custom"], Literal["all"], str]] = None, limit: Optional[int] = None, + order: Optional[Union[str, _models.ListSortOrder]] = None, + after: Optional[str] = None, + before: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/evaluators" + _url = "/assistants" # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if type is not None: - _params["type"] = _SERIALIZER.query("type", type, "str") if limit is not None: _params["limit"] = _SERIALIZER.query("limit", limit, "int") + if order is not None: + _params["order"] = _SERIALIZER.query("order", order, "str") + if after is not None: + _params["after"] = _SERIALIZER.query("after", after, "str") + if before is not None: + _params["before"] = _SERIALIZER.query("before", before, "str") # Construct headers - _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_evaluators_get_version_request( # pylint: disable=name-too-long - name: str, - version: str, - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], - **kwargs: Any -) -> HttpRequest: +def build_agents_get_agent_request(agent_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/evaluators/{name}/versions/{version}" + _url = "/assistants/{assistantId}" path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - "version": _SERIALIZER.url("version", version, "str"), + "assistantId": _SERIALIZER.url("agent_id", agent_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1162,90 +1155,23 @@ def build_beta_evaluators_get_version_request( # pylint: disable=name-too-long _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_evaluators_delete_version_request( # pylint: disable=name-too-long - name: str, - version: str, - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) - # Construct URL - _url = "/evaluators/{name}/versions/{version}" - path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - "version": _SERIALIZER.url("version", version, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_beta_evaluators_create_version_request( # pylint: disable=name-too-long - name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/evaluators/{name}/versions" - path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_beta_evaluators_update_version_request( # pylint: disable=name-too-long - name: str, - version: str, - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], - **kwargs: Any -) -> HttpRequest: +def build_agents_update_agent_request(agent_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/evaluators/{name}/versions/{version}" + _url = "/assistants/{assistantId}" path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - "version": _SERIALIZER.url("version", version, "str"), + "assistantId": _SERIALIZER.url("agent_id", agent_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1254,39 +1180,6 @@ def build_beta_evaluators_update_version_request( # pylint: disable=name-too-lo _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_beta_insights_generate_request( - *, foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW]] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/insights" - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if foundry_features is not None: - _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") - if "Repeatability-Request-ID" not in _headers: - _headers["Repeatability-Request-ID"] = str(uuid.uuid4()) - if "Repeatability-First-Sent" not in _headers: - _headers["Repeatability-First-Sent"] = _SERIALIZER.serialize_data( - datetime.datetime.now(datetime.timezone.utc), "rfc-1123" - ) if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1294,5514 +1187,162 @@ def build_beta_insights_generate_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_insights_get_request( - id: str, - *, - foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW]] = None, - include_coordinates: Optional[bool] = None, - **kwargs: Any -) -> HttpRequest: +def build_agents_delete_agent_request(agent_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/insights/{id}" + _url = "/assistants/{assistantId}" path_format_arguments = { - "id": _SERIALIZER.url("id", id, "str"), + "assistantId": _SERIALIZER.url("agent_id", agent_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore - # Construct parameters - if include_coordinates is not None: - _params["includeCoordinates"] = _SERIALIZER.query("include_coordinates", include_coordinates, "bool") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if foundry_features is not None: - _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_beta_insights_list_request( - *, - foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW]] = None, - type: Optional[types.InsightType] = None, - eval_id: Optional[str] = None, - run_id: Optional[str] = None, - agent_name: Optional[str] = None, - include_coordinates: Optional[bool] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/insights" - - # Construct parameters - if type is not None: - _params["type"] = _SERIALIZER.query("type", type, "str") - if eval_id is not None: - _params["evalId"] = _SERIALIZER.query("eval_id", eval_id, "str") - if run_id is not None: - _params["runId"] = _SERIALIZER.query("run_id", run_id, "str") - if agent_name is not None: - _params["agentName"] = _SERIALIZER.query("agent_name", agent_name, "str") - if include_coordinates is not None: - _params["includeCoordinates"] = _SERIALIZER.query("include_coordinates", include_coordinates, "bool") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if foundry_features is not None: - _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_beta_memory_stores_create_request( - *, foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/memory_stores" - # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_memory_stores_update_request( - name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], **kwargs: Any -) -> HttpRequest: +def build_agents_create_thread_and_run_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/memory_stores/{name}" - path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_beta_memory_stores_get_request( - name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/memory_stores/{name}" - path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_beta_memory_stores_list_request( - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], - limit: Optional[int] = None, - order: Optional[types.PageOrder] = None, - after: Optional[str] = None, - before: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/memory_stores" - - # Construct parameters - if limit is not None: - _params["limit"] = _SERIALIZER.query("limit", limit, "int") - if order is not None: - _params["order"] = _SERIALIZER.query("order", order, "str") - if after is not None: - _params["after"] = _SERIALIZER.query("after", after, "str") - if before is not None: - _params["before"] = _SERIALIZER.query("before", before, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_beta_memory_stores_delete_request( - name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/memory_stores/{name}" - path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore + _url = "/threads/runs" # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_beta_memory_stores_search_memories_request( # pylint: disable=name-too-long - name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/memory_stores/{name}:search_memories" - path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_beta_memory_stores_update_memories_request( # pylint: disable=name-too-long - name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/memory_stores/{name}:update_memories" - path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_beta_memory_stores_delete_scope_request( # pylint: disable=name-too-long - name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/memory_stores/{name}:delete_scope" - path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_beta_red_teams_get_request( - name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.RED_TEAMS_V1_PREVIEW], **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/redTeams/runs/{name}" - path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_beta_red_teams_list_request( - *, foundry_features: Literal[FoundryFeaturesOptInKeys.RED_TEAMS_V1_PREVIEW], **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/redTeams/runs" - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_beta_red_teams_create_request( - *, foundry_features: Literal[FoundryFeaturesOptInKeys.RED_TEAMS_V1_PREVIEW], **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/redTeams/runs:run" - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_beta_schedules_delete_request( - schedule_id: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) - # Construct URL - _url = "/schedules/{id}" - path_format_arguments = { - "id": _SERIALIZER.url("schedule_id", schedule_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_beta_schedules_get_request( - schedule_id: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/schedules/{id}" - path_format_arguments = { - "id": _SERIALIZER.url("schedule_id", schedule_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_beta_schedules_list_request( - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], - type: Optional[types.ScheduleTaskType] = None, - enabled: Optional[bool] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/schedules" - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if type is not None: - _params["type"] = _SERIALIZER.query("type", type, "str") - if enabled is not None: - _params["enabled"] = _SERIALIZER.query("enabled", enabled, "bool") - - # Construct headers - _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_beta_schedules_create_or_update_request( # pylint: disable=name-too-long - schedule_id: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/schedules/{id}" - path_format_arguments = { - "id": _SERIALIZER.url("schedule_id", schedule_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_beta_schedules_get_run_request( - schedule_id: str, - run_id: str, - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/schedules/{schedule_id}/runs/{run_id}" - path_format_arguments = { - "schedule_id": _SERIALIZER.url("schedule_id", schedule_id, "str"), - "run_id": _SERIALIZER.url("run_id", run_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_beta_schedules_list_runs_request( - schedule_id: str, - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], - type: Optional[types.ScheduleTaskType] = None, - enabled: Optional[bool] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/schedules/{id}/runs" - path_format_arguments = { - "id": _SERIALIZER.url("schedule_id", schedule_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if type is not None: - _params["type"] = _SERIALIZER.query("type", type, "str") - if enabled is not None: - _params["enabled"] = _SERIALIZER.query("enabled", enabled, "bool") - - # Construct headers - _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class BetaOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.agents.AIProjectClient`'s - :attr:`beta` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - self.evaluation_taxonomies = BetaEvaluationTaxonomiesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.evaluators = BetaEvaluatorsOperations(self._client, self._config, self._serialize, self._deserialize) - self.insights = BetaInsightsOperations(self._client, self._config, self._serialize, self._deserialize) - self.memory_stores = BetaMemoryStoresOperations(self._client, self._config, self._serialize, self._deserialize) - self.red_teams = BetaRedTeamsOperations(self._client, self._config, self._serialize, self._deserialize) - self.schedules = BetaSchedulesOperations(self._client, self._config, self._serialize, self._deserialize) - - -class AgentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.agents.AIProjectClient`'s - :attr:`agents` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get(self, agent_name: str, **kwargs: Any) -> _types_models1.AgentDetails: - """Retrieves the agent. - - :param agent_name: The name of the agent to retrieve. Required. - :type agent_name: str - :return: AgentDetails - :rtype: ~azure.ai.agents.types.AgentDetails - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "hosted": - agent_definition = { - "container_protocol_versions": [ - { - "protocol": "str", - "version": "str" - } - ], - "cpu": "str", - "kind": "hosted", - "memory": "str", - "environment_variables": { - "str": "str" - }, - "image": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "tools": [ - tool - ] - } - - # JSON input template for discriminator value "prompt": - agent_definition = { - "kind": "prompt", - "model": "str", - "instructions": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "reasoning": { - "effort": "none", - "generate_summary": "auto", - "summary": "auto" - }, - "structured_inputs": { - "str": { - "default_value": {}, - "description": "str", - "required": bool, - "schema": { - "str": {} - } - } - }, - "temperature": 0.0, - "text": { - "format": text_response_format - }, - "tool_choice": "str", - "tools": [ - tool - ], - "top_p": 0.0 - } - - # JSON input template for discriminator value "json_object": - text_response_format = { - "type": "json_object" - } - - # JSON input template for discriminator value "json_schema": - text_response_format = { - "name": "str", - "schema": { - "str": {} - }, - "type": "json_schema", - "description": "str", - "strict": bool - } - - # JSON input template for discriminator value "text": - text_response_format = { - "type": "text" - } - - # response body for status code(s): 200 - response == { - "id": "str", - "name": "str", - "object": "str", - "versions": { - "latest": { - "created_at": "2020-02-20 00:00:00", - "definition": agent_definition, - "id": "str", - "metadata": { - "str": "str" - }, - "name": "str", - "object": "str", - "version": "str", - "description": "str" - } - } - } - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_types_models1.AgentDetails] = kwargs.pop("cls", None) - - _request = build_agents_get_request( - agent_name=agent_name, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models1.ApiErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def _create_agent( - self, - name: str, - definition: _types_models1.AgentDefinition, - metadata: Optional[dict[str, str]] = None, - description: Optional[str] = None, - *, - foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models1.AgentDetails: ... - @overload - def _create_agent( - self, - body: JSON, - *, - foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models1.AgentDetails: ... - @overload - def _create_agent( - self, - body: IO[bytes], - *, - foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models1.AgentDetails: ... - - @distributed_trace - def _create_agent( - self, - name: str = _Unset, - definition: _types_models1.AgentDefinition = _Unset, - body: Union[JSON, IO[bytes]] = _Unset, - metadata: Optional[dict[str, str]] = None, - description: Optional[str] = None, - *, - foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, - **kwargs: Any - ) -> _types_models1.AgentDetails: - """Creates the agent. - - :param name: The unique name that identifies the agent. Name can be used to - retrieve/update/delete the agent. - - * Must start and end with alphanumeric characters, - * Can contain hyphens in the middle - * Must not exceed 63 characters. Required. - :type name: str - :param definition: The agent definition. This can be a workflow, hosted agent, or a simple - agent definition. Required. - :type definition: ~azure.ai.agents.types.AgentDefinition - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :param metadata: Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. Default value is None. - :type metadata: dict[str, str] - :param description: A human-readable description of the agent. Default value is None. - :type description: str - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. Known values are: "HostedAgents=V1Preview" and - "WorkflowAgents=V1Preview". Default value is None. - :paramtype foundry_features: str or ~azure.ai.agents.models.AgentDefinitionOptInKeys - :return: AgentDetails - :rtype: ~azure.ai.agents.types.AgentDetails - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "kind": - - # JSON input template for discriminator value "hosted": - agent_definition = { - "container_protocol_versions": [ - { - "protocol": "str", - "version": "str" - } - ], - "cpu": "str", - "kind": "hosted", - "memory": "str", - "environment_variables": { - "str": "str" - }, - "image": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "tools": [ - tool - ] - } - - # JSON input template for discriminator value "prompt": - agent_definition = { - "kind": "prompt", - "model": "str", - "instructions": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "reasoning": { - "effort": "none", - "generate_summary": "auto", - "summary": "auto" - }, - "structured_inputs": { - "str": { - "default_value": {}, - "description": "str", - "required": bool, - "schema": { - "str": {} - } - } - }, - "temperature": 0.0, - "text": { - "format": text_response_format - }, - "tool_choice": "str", - "tools": [ - tool - ], - "top_p": 0.0 - } - - # JSON input template for discriminator value "json_object": - text_response_format = { - "type": "json_object" - } - - # JSON input template for discriminator value "json_schema": - text_response_format = { - "name": "str", - "schema": { - "str": {} - }, - "type": "json_schema", - "description": "str", - "strict": bool - } - - # JSON input template for discriminator value "text": - text_response_format = { - "type": "text" - } - - # JSON input template you can fill out and use as your body input. - body = { - "definition": agent_definition, - "name": "str", - "description": "str", - "metadata": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "hosted": - agent_definition = { - "container_protocol_versions": [ - { - "protocol": "str", - "version": "str" - } - ], - "cpu": "str", - "kind": "hosted", - "memory": "str", - "environment_variables": { - "str": "str" - }, - "image": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "tools": [ - tool - ] - } - - # JSON input template for discriminator value "prompt": - agent_definition = { - "kind": "prompt", - "model": "str", - "instructions": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "reasoning": { - "effort": "none", - "generate_summary": "auto", - "summary": "auto" - }, - "structured_inputs": { - "str": { - "default_value": {}, - "description": "str", - "required": bool, - "schema": { - "str": {} - } - } - }, - "temperature": 0.0, - "text": { - "format": text_response_format - }, - "tool_choice": "str", - "tools": [ - tool - ], - "top_p": 0.0 - } - - # JSON input template for discriminator value "json_object": - text_response_format = { - "type": "json_object" - } - - # JSON input template for discriminator value "json_schema": - text_response_format = { - "name": "str", - "schema": { - "str": {} - }, - "type": "json_schema", - "description": "str", - "strict": bool - } - - # JSON input template for discriminator value "text": - text_response_format = { - "type": "text" - } - - # response body for status code(s): 200 - response == { - "id": "str", - "name": "str", - "object": "str", - "versions": { - "latest": { - "created_at": "2020-02-20 00:00:00", - "definition": agent_definition, - "id": "str", - "metadata": { - "str": "str" - }, - "name": "str", - "object": "str", - "version": "str", - "description": "str" - } - } - } - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models1.AgentDetails] = kwargs.pop("cls", None) - - if body is _Unset: - if name is _Unset: - raise TypeError("missing required argument: name") - if definition is _Unset: - raise TypeError("missing required argument: definition") - body = {"definition": definition, "description": description, "metadata": metadata, "name": name} - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _json = body - - _request = build_agents_create_agent_request( - foundry_features=foundry_features, - content_type=content_type, - api_version=self._config.api_version, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models1.ApiErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def _update_agent( - self, - agent_name: str, - definition: _types_models1.AgentDefinition, - metadata: Optional[dict[str, str]] = None, - description: Optional[str] = None, - *, - foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models1.AgentDetails: ... - @overload - def _update_agent( - self, - agent_name: str, - body: JSON, - *, - foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models1.AgentDetails: ... - @overload - def _update_agent( - self, - agent_name: str, - body: IO[bytes], - *, - foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models1.AgentDetails: ... - - @distributed_trace - def _update_agent( - self, - agent_name: str, - definition: _types_models1.AgentDefinition = _Unset, - body: Union[JSON, IO[bytes]] = _Unset, - metadata: Optional[dict[str, str]] = None, - description: Optional[str] = None, - *, - foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, - **kwargs: Any - ) -> _types_models1.AgentDetails: - """Updates the agent by adding a new version if there are any changes to the agent definition. If - no changes, returns the existing agent version. - - :param agent_name: The name of the agent to retrieve. Required. - :type agent_name: str - :param definition: The agent definition. This can be a workflow, hosted agent, or a simple - agent definition. Required. - :type definition: ~azure.ai.agents.types.AgentDefinition - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :param metadata: Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. Default value is None. - :type metadata: dict[str, str] - :param description: A human-readable description of the agent. Default value is None. - :type description: str - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. Known values are: "HostedAgents=V1Preview" and - "WorkflowAgents=V1Preview". Default value is None. - :paramtype foundry_features: str or ~azure.ai.agents.models.AgentDefinitionOptInKeys - :return: AgentDetails - :rtype: ~azure.ai.agents.types.AgentDetails - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "kind": - - # JSON input template for discriminator value "hosted": - agent_definition = { - "container_protocol_versions": [ - { - "protocol": "str", - "version": "str" - } - ], - "cpu": "str", - "kind": "hosted", - "memory": "str", - "environment_variables": { - "str": "str" - }, - "image": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "tools": [ - tool - ] - } - - # JSON input template for discriminator value "prompt": - agent_definition = { - "kind": "prompt", - "model": "str", - "instructions": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "reasoning": { - "effort": "none", - "generate_summary": "auto", - "summary": "auto" - }, - "structured_inputs": { - "str": { - "default_value": {}, - "description": "str", - "required": bool, - "schema": { - "str": {} - } - } - }, - "temperature": 0.0, - "text": { - "format": text_response_format - }, - "tool_choice": "str", - "tools": [ - tool - ], - "top_p": 0.0 - } - - # JSON input template for discriminator value "json_object": - text_response_format = { - "type": "json_object" - } - - # JSON input template for discriminator value "json_schema": - text_response_format = { - "name": "str", - "schema": { - "str": {} - }, - "type": "json_schema", - "description": "str", - "strict": bool - } - - # JSON input template for discriminator value "text": - text_response_format = { - "type": "text" - } - - # JSON input template you can fill out and use as your body input. - body = { - "definition": agent_definition, - "description": "str", - "metadata": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "hosted": - agent_definition = { - "container_protocol_versions": [ - { - "protocol": "str", - "version": "str" - } - ], - "cpu": "str", - "kind": "hosted", - "memory": "str", - "environment_variables": { - "str": "str" - }, - "image": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "tools": [ - tool - ] - } - - # JSON input template for discriminator value "prompt": - agent_definition = { - "kind": "prompt", - "model": "str", - "instructions": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "reasoning": { - "effort": "none", - "generate_summary": "auto", - "summary": "auto" - }, - "structured_inputs": { - "str": { - "default_value": {}, - "description": "str", - "required": bool, - "schema": { - "str": {} - } - } - }, - "temperature": 0.0, - "text": { - "format": text_response_format - }, - "tool_choice": "str", - "tools": [ - tool - ], - "top_p": 0.0 - } - - # JSON input template for discriminator value "json_object": - text_response_format = { - "type": "json_object" - } - - # JSON input template for discriminator value "json_schema": - text_response_format = { - "name": "str", - "schema": { - "str": {} - }, - "type": "json_schema", - "description": "str", - "strict": bool - } - - # JSON input template for discriminator value "text": - text_response_format = { - "type": "text" - } - - # response body for status code(s): 200 - response == { - "id": "str", - "name": "str", - "object": "str", - "versions": { - "latest": { - "created_at": "2020-02-20 00:00:00", - "definition": agent_definition, - "id": "str", - "metadata": { - "str": "str" - }, - "name": "str", - "object": "str", - "version": "str", - "description": "str" - } - } - } - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models1.AgentDetails] = kwargs.pop("cls", None) - - if body is _Unset: - if definition is _Unset: - raise TypeError("missing required argument: definition") - body = {"definition": definition, "description": description, "metadata": metadata} - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _json = body - - _request = build_agents_update_agent_request( - agent_name=agent_name, - foundry_features=foundry_features, - content_type=content_type, - api_version=self._config.api_version, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models1.ApiErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def _create_agent_from_manifest( - self, - name: str, - manifest_id: str, - parameter_values: dict[str, Any], - metadata: Optional[dict[str, str]] = None, - description: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models1.AgentDetails: ... - @overload - def _create_agent_from_manifest( - self, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _types_models1.AgentDetails: ... - @overload - def _create_agent_from_manifest( - self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _types_models1.AgentDetails: ... - - @distributed_trace - def _create_agent_from_manifest( - self, - name: str = _Unset, - manifest_id: str = _Unset, - parameter_values: dict[str, Any] = _Unset, - body: Union[JSON, IO[bytes]] = _Unset, - metadata: Optional[dict[str, str]] = None, - description: Optional[str] = None, - **kwargs: Any - ) -> _types_models1.AgentDetails: - """Creates an agent from a manifest. - - :param name: The unique name that identifies the agent. Name can be used to - retrieve/update/delete the agent. - - * Must start and end with alphanumeric characters, - * Can contain hyphens in the middle - * Must not exceed 63 characters. Required. - :type name: str - :param manifest_id: The manifest ID to import the agent version from. Required. - :type manifest_id: str - :param parameter_values: The inputs to the manifest that will result in a fully materialized - Agent. Required. - :type parameter_values: dict[str, any] - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :param metadata: Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. Default value is None. - :type metadata: dict[str, str] - :param description: A human-readable description of the agent. Default value is None. - :type description: str - :return: AgentDetails - :rtype: ~azure.ai.agents.types.AgentDetails - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "manifest_id": "str", - "name": "str", - "parameter_values": { - "str": {} - }, - "description": "str", - "metadata": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "hosted": - agent_definition = { - "container_protocol_versions": [ - { - "protocol": "str", - "version": "str" - } - ], - "cpu": "str", - "kind": "hosted", - "memory": "str", - "environment_variables": { - "str": "str" - }, - "image": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "tools": [ - tool - ] - } - - # JSON input template for discriminator value "prompt": - agent_definition = { - "kind": "prompt", - "model": "str", - "instructions": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "reasoning": { - "effort": "none", - "generate_summary": "auto", - "summary": "auto" - }, - "structured_inputs": { - "str": { - "default_value": {}, - "description": "str", - "required": bool, - "schema": { - "str": {} - } - } - }, - "temperature": 0.0, - "text": { - "format": text_response_format - }, - "tool_choice": "str", - "tools": [ - tool - ], - "top_p": 0.0 - } - - # JSON input template for discriminator value "json_object": - text_response_format = { - "type": "json_object" - } - - # JSON input template for discriminator value "json_schema": - text_response_format = { - "name": "str", - "schema": { - "str": {} - }, - "type": "json_schema", - "description": "str", - "strict": bool - } - - # JSON input template for discriminator value "text": - text_response_format = { - "type": "text" - } - - # response body for status code(s): 200 - response == { - "id": "str", - "name": "str", - "object": "str", - "versions": { - "latest": { - "created_at": "2020-02-20 00:00:00", - "definition": agent_definition, - "id": "str", - "metadata": { - "str": "str" - }, - "name": "str", - "object": "str", - "version": "str", - "description": "str" - } - } - } - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models1.AgentDetails] = kwargs.pop("cls", None) - - if body is _Unset: - if name is _Unset: - raise TypeError("missing required argument: name") - if manifest_id is _Unset: - raise TypeError("missing required argument: manifest_id") - if parameter_values is _Unset: - raise TypeError("missing required argument: parameter_values") - body = { - "description": description, - "manifest_id": manifest_id, - "metadata": metadata, - "name": name, - "parameter_values": parameter_values, - } - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _json = body - - _request = build_agents_create_agent_from_manifest_request( - content_type=content_type, - api_version=self._config.api_version, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models1.ApiErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def _update_agent_from_manifest( - self, - agent_name: str, - manifest_id: str, - parameter_values: dict[str, Any], - metadata: Optional[dict[str, str]] = None, - description: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models1.AgentDetails: ... - @overload - def _update_agent_from_manifest( - self, agent_name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _types_models1.AgentDetails: ... - @overload - def _update_agent_from_manifest( - self, agent_name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _types_models1.AgentDetails: ... - - @distributed_trace - def _update_agent_from_manifest( - self, - agent_name: str, - manifest_id: str = _Unset, - parameter_values: dict[str, Any] = _Unset, - body: Union[JSON, IO[bytes]] = _Unset, - metadata: Optional[dict[str, str]] = None, - description: Optional[str] = None, - **kwargs: Any - ) -> _types_models1.AgentDetails: - """Updates the agent from a manifest by adding a new version if there are any changes to the agent - definition. If no changes, returns the existing agent version. - - :param agent_name: The name of the agent to update. Required. - :type agent_name: str - :param manifest_id: The manifest ID to import the agent version from. Required. - :type manifest_id: str - :param parameter_values: The inputs to the manifest that will result in a fully materialized - Agent. Required. - :type parameter_values: dict[str, any] - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :param metadata: Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. Default value is None. - :type metadata: dict[str, str] - :param description: A human-readable description of the agent. Default value is None. - :type description: str - :return: AgentDetails - :rtype: ~azure.ai.agents.types.AgentDetails - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "manifest_id": "str", - "parameter_values": { - "str": {} - }, - "description": "str", - "metadata": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "hosted": - agent_definition = { - "container_protocol_versions": [ - { - "protocol": "str", - "version": "str" - } - ], - "cpu": "str", - "kind": "hosted", - "memory": "str", - "environment_variables": { - "str": "str" - }, - "image": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "tools": [ - tool - ] - } - - # JSON input template for discriminator value "prompt": - agent_definition = { - "kind": "prompt", - "model": "str", - "instructions": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "reasoning": { - "effort": "none", - "generate_summary": "auto", - "summary": "auto" - }, - "structured_inputs": { - "str": { - "default_value": {}, - "description": "str", - "required": bool, - "schema": { - "str": {} - } - } - }, - "temperature": 0.0, - "text": { - "format": text_response_format - }, - "tool_choice": "str", - "tools": [ - tool - ], - "top_p": 0.0 - } - - # JSON input template for discriminator value "json_object": - text_response_format = { - "type": "json_object" - } - - # JSON input template for discriminator value "json_schema": - text_response_format = { - "name": "str", - "schema": { - "str": {} - }, - "type": "json_schema", - "description": "str", - "strict": bool - } - - # JSON input template for discriminator value "text": - text_response_format = { - "type": "text" - } - - # response body for status code(s): 200 - response == { - "id": "str", - "name": "str", - "object": "str", - "versions": { - "latest": { - "created_at": "2020-02-20 00:00:00", - "definition": agent_definition, - "id": "str", - "metadata": { - "str": "str" - }, - "name": "str", - "object": "str", - "version": "str", - "description": "str" - } - } - } - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models1.AgentDetails] = kwargs.pop("cls", None) - - if body is _Unset: - if manifest_id is _Unset: - raise TypeError("missing required argument: manifest_id") - if parameter_values is _Unset: - raise TypeError("missing required argument: parameter_values") - body = { - "description": description, - "manifest_id": manifest_id, - "metadata": metadata, - "parameter_values": parameter_values, - } - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _json = body - - _request = build_agents_update_agent_from_manifest_request( - agent_name=agent_name, - content_type=content_type, - api_version=self._config.api_version, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models1.ApiErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete(self, agent_name: str, **kwargs: Any) -> _types_models1.DeleteAgentResponse: - """Deletes an agent. - - :param agent_name: The name of the agent to delete. Required. - :type agent_name: str - :return: DeleteAgentResponse - :rtype: ~azure.ai.agents.types.DeleteAgentResponse - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "deleted": bool, - "name": "str", - "object": "str" - } - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_types_models1.DeleteAgentResponse] = kwargs.pop("cls", None) - - _request = build_agents_delete_request( - agent_name=agent_name, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models1.ApiErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, - *, - kind: Optional[types.AgentKind] = None, - limit: Optional[int] = None, - order: Optional[types.PageOrder] = None, - before: Optional[str] = None, - **kwargs: Any - ) -> ItemPaged["_types_models1.AgentDetails"]: - """Returns the list of all agents. - - :keyword kind: Filter agents by kind. If not provided, all agents are returned. Known values - are: "prompt", "hosted", and "workflow". Default value is None. - :paramtype kind: str or ~azure.ai.agents.models.AgentKind - :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and - 100, and the - default is 20. Default value is None. - :paramtype limit: int - :keyword order: Sort order by the ``created_at`` timestamp of the objects. ``asc`` for - ascending order and``desc`` - for descending order. Known values are: "asc" and "desc". Default value is None. - :paramtype order: str or ~azure.ai.agents.models.PageOrder - :keyword 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. - Default value is None. - :paramtype before: str - :return: An iterator like instance of AgentDetails - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.types.AgentDetails] - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "hosted": - agent_definition = { - "container_protocol_versions": [ - { - "protocol": "str", - "version": "str" - } - ], - "cpu": "str", - "kind": "hosted", - "memory": "str", - "environment_variables": { - "str": "str" - }, - "image": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "tools": [ - tool - ] - } - - # JSON input template for discriminator value "prompt": - agent_definition = { - "kind": "prompt", - "model": "str", - "instructions": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "reasoning": { - "effort": "none", - "generate_summary": "auto", - "summary": "auto" - }, - "structured_inputs": { - "str": { - "default_value": {}, - "description": "str", - "required": bool, - "schema": { - "str": {} - } - } - }, - "temperature": 0.0, - "text": { - "format": text_response_format - }, - "tool_choice": "str", - "tools": [ - tool - ], - "top_p": 0.0 - } - - # JSON input template for discriminator value "json_object": - text_response_format = { - "type": "json_object" - } - - # JSON input template for discriminator value "json_schema": - text_response_format = { - "name": "str", - "schema": { - "str": {} - }, - "type": "json_schema", - "description": "str", - "strict": bool - } - - # JSON input template for discriminator value "text": - text_response_format = { - "type": "text" - } - - # response body for status code(s): 200 - response == { - "id": "str", - "name": "str", - "object": "str", - "versions": { - "latest": { - "created_at": "2020-02-20 00:00:00", - "definition": agent_definition, - "id": "str", - "metadata": { - "str": "str" - }, - "name": "str", - "object": "str", - "version": "str", - "description": "str" - } - } - } - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_types_models1.AgentDetails]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(_continuation_token=None): - - _request = build_agents_list_request( - kind=kind, - limit=limit, - order=order, - after=_continuation_token, - before=before, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - return _request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized.get("data", []) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("last_id") or None, iter(list_of_elem) - - def get_next(_continuation_token=None): - _request = prepare_request(_continuation_token) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models1.ApiErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @overload - def create_version( - self, - agent_name: str, - definition: _types_models1.AgentDefinition, - metadata: Optional[dict[str, str]] = None, - description: Optional[str] = None, - *, - foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models1.AgentVersionDetails: - """Create a new agent version. - - :param agent_name: The unique name that identifies the agent. Name can be used to - retrieve/update/delete the agent. - - * Must start and end with alphanumeric characters, - * Can contain hyphens in the middle - * Must not exceed 63 characters. Required. - :type agent_name: str - :param definition: The agent definition. This can be a workflow, hosted agent, or a simple - agent definition. Required. - :type definition: ~azure.ai.agents.types.AgentDefinition - :param metadata: Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. Default value is None. - :type metadata: dict[str, str] - :param description: A human-readable description of the agent. Default value is None. - :type description: str - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. Known values are: "HostedAgents=V1Preview" and - "WorkflowAgents=V1Preview". Default value is None. - :paramtype foundry_features: str or ~azure.ai.agents.models.AgentDefinitionOptInKeys - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AgentVersionDetails - :rtype: ~azure.ai.agents.types.AgentVersionDetails - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "hosted": - agent_definition = { - "container_protocol_versions": [ - { - "protocol": "str", - "version": "str" - } - ], - "cpu": "str", - "kind": "hosted", - "memory": "str", - "environment_variables": { - "str": "str" - }, - "image": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "tools": [ - tool - ] - } - - # JSON input template for discriminator value "prompt": - agent_definition = { - "kind": "prompt", - "model": "str", - "instructions": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "reasoning": { - "effort": "none", - "generate_summary": "auto", - "summary": "auto" - }, - "structured_inputs": { - "str": { - "default_value": {}, - "description": "str", - "required": bool, - "schema": { - "str": {} - } - } - }, - "temperature": 0.0, - "text": { - "format": text_response_format - }, - "tool_choice": "str", - "tools": [ - tool - ], - "top_p": 0.0 - } - - # JSON input template for discriminator value "json_object": - text_response_format = { - "type": "json_object" - } - - # JSON input template for discriminator value "json_schema": - text_response_format = { - "name": "str", - "schema": { - "str": {} - }, - "type": "json_schema", - "description": "str", - "strict": bool - } - - # JSON input template for discriminator value "text": - text_response_format = { - "type": "text" - } - - # response body for status code(s): 200 - response == { - "created_at": "2020-02-20 00:00:00", - "definition": agent_definition, - "id": "str", - "metadata": { - "str": "str" - }, - "name": "str", - "object": "str", - "version": "str", - "description": "str" - } - """ - - @overload - def create_version( - self, - agent_name: str, - body: JSON, - *, - foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models1.AgentVersionDetails: - """Create a new agent version. - - :param agent_name: The unique name that identifies the agent. Name can be used to - retrieve/update/delete the agent. - - * Must start and end with alphanumeric characters, - * Can contain hyphens in the middle - * Must not exceed 63 characters. Required. - :type agent_name: str - :param body: Required. - :type body: JSON - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. Known values are: "HostedAgents=V1Preview" and - "WorkflowAgents=V1Preview". Default value is None. - :paramtype foundry_features: str or ~azure.ai.agents.models.AgentDefinitionOptInKeys - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AgentVersionDetails - :rtype: ~azure.ai.agents.types.AgentVersionDetails - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "kind": - - # JSON input template for discriminator value "hosted": - agent_definition = { - "container_protocol_versions": [ - { - "protocol": "str", - "version": "str" - } - ], - "cpu": "str", - "kind": "hosted", - "memory": "str", - "environment_variables": { - "str": "str" - }, - "image": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "tools": [ - tool - ] - } - - # JSON input template for discriminator value "prompt": - agent_definition = { - "kind": "prompt", - "model": "str", - "instructions": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "reasoning": { - "effort": "none", - "generate_summary": "auto", - "summary": "auto" - }, - "structured_inputs": { - "str": { - "default_value": {}, - "description": "str", - "required": bool, - "schema": { - "str": {} - } - } - }, - "temperature": 0.0, - "text": { - "format": text_response_format - }, - "tool_choice": "str", - "tools": [ - tool - ], - "top_p": 0.0 - } - - # JSON input template for discriminator value "json_object": - text_response_format = { - "type": "json_object" - } - - # JSON input template for discriminator value "json_schema": - text_response_format = { - "name": "str", - "schema": { - "str": {} - }, - "type": "json_schema", - "description": "str", - "strict": bool - } - - # JSON input template for discriminator value "text": - text_response_format = { - "type": "text" - } - - # JSON input template you can fill out and use as your body input. - body = { - "definition": agent_definition, - "description": "str", - "metadata": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "hosted": - agent_definition = { - "container_protocol_versions": [ - { - "protocol": "str", - "version": "str" - } - ], - "cpu": "str", - "kind": "hosted", - "memory": "str", - "environment_variables": { - "str": "str" - }, - "image": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "tools": [ - tool - ] - } - - # JSON input template for discriminator value "prompt": - agent_definition = { - "kind": "prompt", - "model": "str", - "instructions": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "reasoning": { - "effort": "none", - "generate_summary": "auto", - "summary": "auto" - }, - "structured_inputs": { - "str": { - "default_value": {}, - "description": "str", - "required": bool, - "schema": { - "str": {} - } - } - }, - "temperature": 0.0, - "text": { - "format": text_response_format - }, - "tool_choice": "str", - "tools": [ - tool - ], - "top_p": 0.0 - } - - # JSON input template for discriminator value "json_object": - text_response_format = { - "type": "json_object" - } - - # JSON input template for discriminator value "json_schema": - text_response_format = { - "name": "str", - "schema": { - "str": {} - }, - "type": "json_schema", - "description": "str", - "strict": bool - } - - # JSON input template for discriminator value "text": - text_response_format = { - "type": "text" - } - - # response body for status code(s): 200 - response == { - "created_at": "2020-02-20 00:00:00", - "definition": agent_definition, - "id": "str", - "metadata": { - "str": "str" - }, - "name": "str", - "object": "str", - "version": "str", - "description": "str" - } - """ - - @overload - def create_version( - self, - agent_name: str, - body: IO[bytes], - *, - foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models1.AgentVersionDetails: - """Create a new agent version. - - :param agent_name: The unique name that identifies the agent. Name can be used to - retrieve/update/delete the agent. - - * Must start and end with alphanumeric characters, - * Can contain hyphens in the middle - * Must not exceed 63 characters. Required. - :type agent_name: str - :param body: Required. - :type body: IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. Known values are: "HostedAgents=V1Preview" and - "WorkflowAgents=V1Preview". Default value is None. - :paramtype foundry_features: str or ~azure.ai.agents.models.AgentDefinitionOptInKeys - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: AgentVersionDetails - :rtype: ~azure.ai.agents.types.AgentVersionDetails - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "hosted": - agent_definition = { - "container_protocol_versions": [ - { - "protocol": "str", - "version": "str" - } - ], - "cpu": "str", - "kind": "hosted", - "memory": "str", - "environment_variables": { - "str": "str" - }, - "image": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "tools": [ - tool - ] - } - - # JSON input template for discriminator value "prompt": - agent_definition = { - "kind": "prompt", - "model": "str", - "instructions": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "reasoning": { - "effort": "none", - "generate_summary": "auto", - "summary": "auto" - }, - "structured_inputs": { - "str": { - "default_value": {}, - "description": "str", - "required": bool, - "schema": { - "str": {} - } - } - }, - "temperature": 0.0, - "text": { - "format": text_response_format - }, - "tool_choice": "str", - "tools": [ - tool - ], - "top_p": 0.0 - } - - # JSON input template for discriminator value "json_object": - text_response_format = { - "type": "json_object" - } - - # JSON input template for discriminator value "json_schema": - text_response_format = { - "name": "str", - "schema": { - "str": {} - }, - "type": "json_schema", - "description": "str", - "strict": bool - } - - # JSON input template for discriminator value "text": - text_response_format = { - "type": "text" - } - - # response body for status code(s): 200 - response == { - "created_at": "2020-02-20 00:00:00", - "definition": agent_definition, - "id": "str", - "metadata": { - "str": "str" - }, - "name": "str", - "object": "str", - "version": "str", - "description": "str" - } - """ - - @distributed_trace - def create_version( - self, - agent_name: str, - definition: _types_models1.AgentDefinition = _Unset, - body: Union[JSON, IO[bytes]] = _Unset, - metadata: Optional[dict[str, str]] = None, - description: Optional[str] = None, - *, - foundry_features: Optional[types.AgentDefinitionOptInKeys] = None, - **kwargs: Any - ) -> _types_models1.AgentVersionDetails: - """Create a new agent version. - - :param agent_name: The unique name that identifies the agent. Name can be used to - retrieve/update/delete the agent. - - * Must start and end with alphanumeric characters, - * Can contain hyphens in the middle - * Must not exceed 63 characters. Required. - :type agent_name: str - :param definition: The agent definition. This can be a workflow, hosted agent, or a simple - agent definition. Required. - :type definition: ~azure.ai.agents.types.AgentDefinition - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :param metadata: Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. Default value is None. - :type metadata: dict[str, str] - :param description: A human-readable description of the agent. Default value is None. - :type description: str - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. Known values are: "HostedAgents=V1Preview" and - "WorkflowAgents=V1Preview". Default value is None. - :paramtype foundry_features: str or ~azure.ai.agents.models.AgentDefinitionOptInKeys - :return: AgentVersionDetails - :rtype: ~azure.ai.agents.types.AgentVersionDetails - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "kind": - - # JSON input template for discriminator value "hosted": - agent_definition = { - "container_protocol_versions": [ - { - "protocol": "str", - "version": "str" - } - ], - "cpu": "str", - "kind": "hosted", - "memory": "str", - "environment_variables": { - "str": "str" - }, - "image": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "tools": [ - tool - ] - } - - # JSON input template for discriminator value "prompt": - agent_definition = { - "kind": "prompt", - "model": "str", - "instructions": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "reasoning": { - "effort": "none", - "generate_summary": "auto", - "summary": "auto" - }, - "structured_inputs": { - "str": { - "default_value": {}, - "description": "str", - "required": bool, - "schema": { - "str": {} - } - } - }, - "temperature": 0.0, - "text": { - "format": text_response_format - }, - "tool_choice": "str", - "tools": [ - tool - ], - "top_p": 0.0 - } - - # JSON input template for discriminator value "json_object": - text_response_format = { - "type": "json_object" - } - - # JSON input template for discriminator value "json_schema": - text_response_format = { - "name": "str", - "schema": { - "str": {} - }, - "type": "json_schema", - "description": "str", - "strict": bool - } - - # JSON input template for discriminator value "text": - text_response_format = { - "type": "text" - } - - # JSON input template you can fill out and use as your body input. - body = { - "definition": agent_definition, - "description": "str", - "metadata": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "hosted": - agent_definition = { - "container_protocol_versions": [ - { - "protocol": "str", - "version": "str" - } - ], - "cpu": "str", - "kind": "hosted", - "memory": "str", - "environment_variables": { - "str": "str" - }, - "image": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "tools": [ - tool - ] - } - - # JSON input template for discriminator value "prompt": - agent_definition = { - "kind": "prompt", - "model": "str", - "instructions": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "reasoning": { - "effort": "none", - "generate_summary": "auto", - "summary": "auto" - }, - "structured_inputs": { - "str": { - "default_value": {}, - "description": "str", - "required": bool, - "schema": { - "str": {} - } - } - }, - "temperature": 0.0, - "text": { - "format": text_response_format - }, - "tool_choice": "str", - "tools": [ - tool - ], - "top_p": 0.0 - } - - # JSON input template for discriminator value "json_object": - text_response_format = { - "type": "json_object" - } - - # JSON input template for discriminator value "json_schema": - text_response_format = { - "name": "str", - "schema": { - "str": {} - }, - "type": "json_schema", - "description": "str", - "strict": bool - } - - # JSON input template for discriminator value "text": - text_response_format = { - "type": "text" - } - - # response body for status code(s): 200 - response == { - "created_at": "2020-02-20 00:00:00", - "definition": agent_definition, - "id": "str", - "metadata": { - "str": "str" - }, - "name": "str", - "object": "str", - "version": "str", - "description": "str" - } - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models1.AgentVersionDetails] = kwargs.pop("cls", None) - - if body is _Unset: - if definition is _Unset: - raise TypeError("missing required argument: definition") - body = {"definition": definition, "description": description, "metadata": metadata} - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _json = body - - _request = build_agents_create_version_request( - agent_name=agent_name, - foundry_features=foundry_features, - content_type=content_type, - api_version=self._config.api_version, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models1.ApiErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_version_from_manifest( - self, - agent_name: str, - manifest_id: str, - parameter_values: dict[str, Any], - metadata: Optional[dict[str, str]] = None, - description: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models1.AgentVersionDetails: - """Create a new agent version from a manifest. - - :param agent_name: The unique name that identifies the agent. Name can be used to - retrieve/update/delete the agent. - - * Must start and end with alphanumeric characters, - * Can contain hyphens in the middle - * Must not exceed 63 characters. Required. - :type agent_name: str - :param manifest_id: The manifest ID to import the agent version from. Required. - :type manifest_id: str - :param parameter_values: The inputs to the manifest that will result in a fully materialized - Agent. Required. - :type parameter_values: dict[str, any] - :param metadata: Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. Default value is None. - :type metadata: dict[str, str] - :param description: A human-readable description of the agent. Default value is None. - :type description: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AgentVersionDetails - :rtype: ~azure.ai.agents.types.AgentVersionDetails - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "hosted": - agent_definition = { - "container_protocol_versions": [ - { - "protocol": "str", - "version": "str" - } - ], - "cpu": "str", - "kind": "hosted", - "memory": "str", - "environment_variables": { - "str": "str" - }, - "image": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "tools": [ - tool - ] - } - - # JSON input template for discriminator value "prompt": - agent_definition = { - "kind": "prompt", - "model": "str", - "instructions": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "reasoning": { - "effort": "none", - "generate_summary": "auto", - "summary": "auto" - }, - "structured_inputs": { - "str": { - "default_value": {}, - "description": "str", - "required": bool, - "schema": { - "str": {} - } - } - }, - "temperature": 0.0, - "text": { - "format": text_response_format - }, - "tool_choice": "str", - "tools": [ - tool - ], - "top_p": 0.0 - } - - # JSON input template for discriminator value "json_object": - text_response_format = { - "type": "json_object" - } - - # JSON input template for discriminator value "json_schema": - text_response_format = { - "name": "str", - "schema": { - "str": {} - }, - "type": "json_schema", - "description": "str", - "strict": bool - } - - # JSON input template for discriminator value "text": - text_response_format = { - "type": "text" - } - - # response body for status code(s): 200 - response == { - "created_at": "2020-02-20 00:00:00", - "definition": agent_definition, - "id": "str", - "metadata": { - "str": "str" - }, - "name": "str", - "object": "str", - "version": "str", - "description": "str" - } - """ - - @overload - def create_version_from_manifest( - self, agent_name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _types_models1.AgentVersionDetails: - """Create a new agent version from a manifest. - - :param agent_name: The unique name that identifies the agent. Name can be used to - retrieve/update/delete the agent. - - * Must start and end with alphanumeric characters, - * Can contain hyphens in the middle - * Must not exceed 63 characters. Required. - :type agent_name: str - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AgentVersionDetails - :rtype: ~azure.ai.agents.types.AgentVersionDetails - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "manifest_id": "str", - "parameter_values": { - "str": {} - }, - "description": "str", - "metadata": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "hosted": - agent_definition = { - "container_protocol_versions": [ - { - "protocol": "str", - "version": "str" - } - ], - "cpu": "str", - "kind": "hosted", - "memory": "str", - "environment_variables": { - "str": "str" - }, - "image": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "tools": [ - tool - ] - } - - # JSON input template for discriminator value "prompt": - agent_definition = { - "kind": "prompt", - "model": "str", - "instructions": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "reasoning": { - "effort": "none", - "generate_summary": "auto", - "summary": "auto" - }, - "structured_inputs": { - "str": { - "default_value": {}, - "description": "str", - "required": bool, - "schema": { - "str": {} - } - } - }, - "temperature": 0.0, - "text": { - "format": text_response_format - }, - "tool_choice": "str", - "tools": [ - tool - ], - "top_p": 0.0 - } - - # JSON input template for discriminator value "json_object": - text_response_format = { - "type": "json_object" - } - - # JSON input template for discriminator value "json_schema": - text_response_format = { - "name": "str", - "schema": { - "str": {} - }, - "type": "json_schema", - "description": "str", - "strict": bool - } - - # JSON input template for discriminator value "text": - text_response_format = { - "type": "text" - } - - # response body for status code(s): 200 - response == { - "created_at": "2020-02-20 00:00:00", - "definition": agent_definition, - "id": "str", - "metadata": { - "str": "str" - }, - "name": "str", - "object": "str", - "version": "str", - "description": "str" - } - """ - - @overload - def create_version_from_manifest( - self, agent_name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _types_models1.AgentVersionDetails: - """Create a new agent version from a manifest. - - :param agent_name: The unique name that identifies the agent. Name can be used to - retrieve/update/delete the agent. - - * Must start and end with alphanumeric characters, - * Can contain hyphens in the middle - * Must not exceed 63 characters. Required. - :type agent_name: str - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: AgentVersionDetails - :rtype: ~azure.ai.agents.types.AgentVersionDetails - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "hosted": - agent_definition = { - "container_protocol_versions": [ - { - "protocol": "str", - "version": "str" - } - ], - "cpu": "str", - "kind": "hosted", - "memory": "str", - "environment_variables": { - "str": "str" - }, - "image": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "tools": [ - tool - ] - } - - # JSON input template for discriminator value "prompt": - agent_definition = { - "kind": "prompt", - "model": "str", - "instructions": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "reasoning": { - "effort": "none", - "generate_summary": "auto", - "summary": "auto" - }, - "structured_inputs": { - "str": { - "default_value": {}, - "description": "str", - "required": bool, - "schema": { - "str": {} - } - } - }, - "temperature": 0.0, - "text": { - "format": text_response_format - }, - "tool_choice": "str", - "tools": [ - tool - ], - "top_p": 0.0 - } - - # JSON input template for discriminator value "json_object": - text_response_format = { - "type": "json_object" - } - - # JSON input template for discriminator value "json_schema": - text_response_format = { - "name": "str", - "schema": { - "str": {} - }, - "type": "json_schema", - "description": "str", - "strict": bool - } - - # JSON input template for discriminator value "text": - text_response_format = { - "type": "text" - } - - # response body for status code(s): 200 - response == { - "created_at": "2020-02-20 00:00:00", - "definition": agent_definition, - "id": "str", - "metadata": { - "str": "str" - }, - "name": "str", - "object": "str", - "version": "str", - "description": "str" - } - """ - - @distributed_trace - def create_version_from_manifest( - self, - agent_name: str, - manifest_id: str = _Unset, - parameter_values: dict[str, Any] = _Unset, - body: Union[JSON, IO[bytes]] = _Unset, - metadata: Optional[dict[str, str]] = None, - description: Optional[str] = None, - **kwargs: Any - ) -> _types_models1.AgentVersionDetails: - """Create a new agent version from a manifest. - - :param agent_name: The unique name that identifies the agent. Name can be used to - retrieve/update/delete the agent. - - * Must start and end with alphanumeric characters, - * Can contain hyphens in the middle - * Must not exceed 63 characters. Required. - :type agent_name: str - :param manifest_id: The manifest ID to import the agent version from. Required. - :type manifest_id: str - :param parameter_values: The inputs to the manifest that will result in a fully materialized - Agent. Required. - :type parameter_values: dict[str, any] - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :param metadata: Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. Default value is None. - :type metadata: dict[str, str] - :param description: A human-readable description of the agent. Default value is None. - :type description: str - :return: AgentVersionDetails - :rtype: ~azure.ai.agents.types.AgentVersionDetails - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "manifest_id": "str", - "parameter_values": { - "str": {} - }, - "description": "str", - "metadata": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "hosted": - agent_definition = { - "container_protocol_versions": [ - { - "protocol": "str", - "version": "str" - } - ], - "cpu": "str", - "kind": "hosted", - "memory": "str", - "environment_variables": { - "str": "str" - }, - "image": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "tools": [ - tool - ] - } - - # JSON input template for discriminator value "prompt": - agent_definition = { - "kind": "prompt", - "model": "str", - "instructions": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "reasoning": { - "effort": "none", - "generate_summary": "auto", - "summary": "auto" - }, - "structured_inputs": { - "str": { - "default_value": {}, - "description": "str", - "required": bool, - "schema": { - "str": {} - } - } - }, - "temperature": 0.0, - "text": { - "format": text_response_format - }, - "tool_choice": "str", - "tools": [ - tool - ], - "top_p": 0.0 - } - - # JSON input template for discriminator value "json_object": - text_response_format = { - "type": "json_object" - } - - # JSON input template for discriminator value "json_schema": - text_response_format = { - "name": "str", - "schema": { - "str": {} - }, - "type": "json_schema", - "description": "str", - "strict": bool - } - - # JSON input template for discriminator value "text": - text_response_format = { - "type": "text" - } - - # response body for status code(s): 200 - response == { - "created_at": "2020-02-20 00:00:00", - "definition": agent_definition, - "id": "str", - "metadata": { - "str": "str" - }, - "name": "str", - "object": "str", - "version": "str", - "description": "str" - } - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models1.AgentVersionDetails] = kwargs.pop("cls", None) - - if body is _Unset: - if manifest_id is _Unset: - raise TypeError("missing required argument: manifest_id") - if parameter_values is _Unset: - raise TypeError("missing required argument: parameter_values") - body = { - "description": description, - "manifest_id": manifest_id, - "metadata": metadata, - "parameter_values": parameter_values, - } - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _json = body - - _request = build_agents_create_version_from_manifest_request( - agent_name=agent_name, - content_type=content_type, - api_version=self._config.api_version, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models1.ApiErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get_version(self, agent_name: str, agent_version: str, **kwargs: Any) -> _types_models1.AgentVersionDetails: - """Retrieves a specific version of an agent. - - :param agent_name: The name of the agent to retrieve. Required. - :type agent_name: str - :param agent_version: The version of the agent to retrieve. Required. - :type agent_version: str - :return: AgentVersionDetails - :rtype: ~azure.ai.agents.types.AgentVersionDetails - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "hosted": - agent_definition = { - "container_protocol_versions": [ - { - "protocol": "str", - "version": "str" - } - ], - "cpu": "str", - "kind": "hosted", - "memory": "str", - "environment_variables": { - "str": "str" - }, - "image": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "tools": [ - tool - ] - } - - # JSON input template for discriminator value "prompt": - agent_definition = { - "kind": "prompt", - "model": "str", - "instructions": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "reasoning": { - "effort": "none", - "generate_summary": "auto", - "summary": "auto" - }, - "structured_inputs": { - "str": { - "default_value": {}, - "description": "str", - "required": bool, - "schema": { - "str": {} - } - } - }, - "temperature": 0.0, - "text": { - "format": text_response_format - }, - "tool_choice": "str", - "tools": [ - tool - ], - "top_p": 0.0 - } - - # JSON input template for discriminator value "json_object": - text_response_format = { - "type": "json_object" - } - - # JSON input template for discriminator value "json_schema": - text_response_format = { - "name": "str", - "schema": { - "str": {} - }, - "type": "json_schema", - "description": "str", - "strict": bool - } - - # JSON input template for discriminator value "text": - text_response_format = { - "type": "text" - } - - # response body for status code(s): 200 - response == { - "created_at": "2020-02-20 00:00:00", - "definition": agent_definition, - "id": "str", - "metadata": { - "str": "str" - }, - "name": "str", - "object": "str", - "version": "str", - "description": "str" - } - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_types_models1.AgentVersionDetails] = kwargs.pop("cls", None) - - _request = build_agents_get_version_request( - agent_name=agent_name, - agent_version=agent_version, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models1.ApiErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete_version( - self, agent_name: str, agent_version: str, **kwargs: Any - ) -> _types_models1.DeleteAgentVersionResponse: - """Deletes a specific version of an agent. - - :param agent_name: The name of the agent to delete. Required. - :type agent_name: str - :param agent_version: The version of the agent to delete. Required. - :type agent_version: str - :return: DeleteAgentVersionResponse - :rtype: ~azure.ai.agents.types.DeleteAgentVersionResponse - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "deleted": bool, - "name": "str", - "object": "str", - "version": "str" - } - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_types_models1.DeleteAgentVersionResponse] = kwargs.pop("cls", None) - - _request = build_agents_delete_version_request( - agent_name=agent_name, - agent_version=agent_version, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models1.ApiErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_versions( - self, - agent_name: str, - *, - limit: Optional[int] = None, - order: Optional[types.PageOrder] = None, - before: Optional[str] = None, - **kwargs: Any - ) -> ItemPaged["_types_models1.AgentVersionDetails"]: - """Returns the list of versions of an agent. - - :param agent_name: The name of the agent to retrieve versions for. Required. - :type agent_name: str - :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and - 100, and the - default is 20. Default value is None. - :paramtype limit: int - :keyword order: Sort order by the ``created_at`` timestamp of the objects. ``asc`` for - ascending order and``desc`` - for descending order. Known values are: "asc" and "desc". Default value is None. - :paramtype order: str or ~azure.ai.agents.models.PageOrder - :keyword 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. - Default value is None. - :paramtype before: str - :return: An iterator like instance of AgentVersionDetails - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.types.AgentVersionDetails] - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "hosted": - agent_definition = { - "container_protocol_versions": [ - { - "protocol": "str", - "version": "str" - } - ], - "cpu": "str", - "kind": "hosted", - "memory": "str", - "environment_variables": { - "str": "str" - }, - "image": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "tools": [ - tool - ] - } - - # JSON input template for discriminator value "prompt": - agent_definition = { - "kind": "prompt", - "model": "str", - "instructions": "str", - "rai_config": { - "rai_policy_name": "str" - }, - "reasoning": { - "effort": "none", - "generate_summary": "auto", - "summary": "auto" - }, - "structured_inputs": { - "str": { - "default_value": {}, - "description": "str", - "required": bool, - "schema": { - "str": {} - } - } - }, - "temperature": 0.0, - "text": { - "format": text_response_format - }, - "tool_choice": "str", - "tools": [ - tool - ], - "top_p": 0.0 - } - - # JSON input template for discriminator value "json_object": - text_response_format = { - "type": "json_object" - } - - # JSON input template for discriminator value "json_schema": - text_response_format = { - "name": "str", - "schema": { - "str": {} - }, - "type": "json_schema", - "description": "str", - "strict": bool - } - - # JSON input template for discriminator value "text": - text_response_format = { - "type": "text" - } - - # response body for status code(s): 200 - response == { - "created_at": "2020-02-20 00:00:00", - "definition": agent_definition, - "id": "str", - "metadata": { - "str": "str" - }, - "name": "str", - "object": "str", - "version": "str", - "description": "str" - } - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_types_models1.AgentVersionDetails]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(_continuation_token=None): - - _request = build_agents_list_versions_request( - agent_name=agent_name, - limit=limit, - order=order, - after=_continuation_token, - before=before, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - return _request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized.get("data", []) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("last_id") or None, iter(list_of_elem) - - def get_next(_continuation_token=None): - _request = prepare_request(_continuation_token) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models1.ApiErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - -class EvaluationRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.agents.AIProjectClient`'s - :attr:`evaluation_rules` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get(self, id: str, **kwargs: Any) -> _types_models1.EvaluationRule: - """Get an evaluation rule. - - :param id: Unique identifier for the evaluation rule. Required. - :type id: str - :return: EvaluationRule - :rtype: ~azure.ai.agents.types.EvaluationRule - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "continuousEvaluation": - evaluation_rule_action = { - "evalId": "str", - "type": "continuousEvaluation", - "maxHourlyRuns": 0 - } - - # JSON input template for discriminator value "humanEvaluationPreview": - evaluation_rule_action = { - "templateId": "str", - "type": "humanEvaluationPreview" - } - - # response body for status code(s): 200 - response == { - "action": evaluation_rule_action, - "enabled": bool, - "eventType": "str", - "id": "str", - "systemData": { - "str": "str" - }, - "description": "str", - "displayName": "str", - "filter": { - "agentName": "str" - } - } - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_types_models1.EvaluationRule] = kwargs.pop("cls", None) - - _request = build_evaluation_rules_get_request( - id=id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete(self, id: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements - """Delete an evaluation rule. - - :param id: Unique identifier for the evaluation rule. Required. - :type id: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_evaluation_rules_delete_request( - id=id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @overload - def create_or_update( - self, - id: str, - evaluation_rule: _types_models1.EvaluationRule, - *, - foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW]] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models1.EvaluationRule: - """Create or update an evaluation rule. - - :param id: Unique identifier for the evaluation rule. Required. - :type id: str - :param evaluation_rule: Evaluation rule resource. Required. - :type evaluation_rule: ~azure.ai.agents.types.EvaluationRule - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Default value is None. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: EvaluationRule - :rtype: ~azure.ai.agents.types.EvaluationRule - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "type": - - # JSON input template for discriminator value "continuousEvaluation": - evaluation_rule_action = { - "evalId": "str", - "type": "continuousEvaluation", - "maxHourlyRuns": 0 - } - - # JSON input template for discriminator value "humanEvaluationPreview": - evaluation_rule_action = { - "templateId": "str", - "type": "humanEvaluationPreview" - } - - # JSON input template you can fill out and use as your body input. - evaluation_rule = { - "action": evaluation_rule_action, - "enabled": bool, - "eventType": "str", - "id": "str", - "systemData": { - "str": "str" - }, - "description": "str", - "displayName": "str", - "filter": { - "agentName": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "continuousEvaluation": - evaluation_rule_action = { - "evalId": "str", - "type": "continuousEvaluation", - "maxHourlyRuns": 0 - } - - # JSON input template for discriminator value "humanEvaluationPreview": - evaluation_rule_action = { - "templateId": "str", - "type": "humanEvaluationPreview" - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "continuousEvaluation": - evaluation_rule_action = { - "evalId": "str", - "type": "continuousEvaluation", - "maxHourlyRuns": 0 - } - - # JSON input template for discriminator value "humanEvaluationPreview": - evaluation_rule_action = { - "templateId": "str", - "type": "humanEvaluationPreview" - } - - # response body for status code(s): 201, 200 - response == { - "action": evaluation_rule_action, - "enabled": bool, - "eventType": "str", - "id": "str", - "systemData": { - "str": "str" - }, - "description": "str", - "displayName": "str", - "filter": { - "agentName": "str" - } - } - """ - - @overload - def create_or_update( - self, - id: str, - evaluation_rule: IO[bytes], - *, - foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW]] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models1.EvaluationRule: - """Create or update an evaluation rule. - - :param id: Unique identifier for the evaluation rule. Required. - :type id: str - :param evaluation_rule: Evaluation rule resource. Required. - :type evaluation_rule: IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Default value is None. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: EvaluationRule - :rtype: ~azure.ai.agents.types.EvaluationRule - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "continuousEvaluation": - evaluation_rule_action = { - "evalId": "str", - "type": "continuousEvaluation", - "maxHourlyRuns": 0 - } - - # JSON input template for discriminator value "humanEvaluationPreview": - evaluation_rule_action = { - "templateId": "str", - "type": "humanEvaluationPreview" - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "continuousEvaluation": - evaluation_rule_action = { - "evalId": "str", - "type": "continuousEvaluation", - "maxHourlyRuns": 0 - } - - # JSON input template for discriminator value "humanEvaluationPreview": - evaluation_rule_action = { - "templateId": "str", - "type": "humanEvaluationPreview" - } - - # response body for status code(s): 201, 200 - response == { - "action": evaluation_rule_action, - "enabled": bool, - "eventType": "str", - "id": "str", - "systemData": { - "str": "str" - }, - "description": "str", - "displayName": "str", - "filter": { - "agentName": "str" - } - } - """ - - @distributed_trace - def create_or_update( - self, - id: str, - evaluation_rule: Union[_types_models1.EvaluationRule, IO[bytes]], - *, - foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW]] = None, - **kwargs: Any - ) -> _types_models1.EvaluationRule: - """Create or update an evaluation rule. - - :param id: Unique identifier for the evaluation rule. Required. - :type id: str - :param evaluation_rule: Evaluation rule resource. Is either a EvaluationRule type or a - IO[bytes] type. Required. - :type evaluation_rule: ~azure.ai.agents.types.EvaluationRule or IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Default value is None. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW - :return: EvaluationRule - :rtype: ~azure.ai.agents.types.EvaluationRule - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "type": - - # JSON input template for discriminator value "continuousEvaluation": - evaluation_rule_action = { - "evalId": "str", - "type": "continuousEvaluation", - "maxHourlyRuns": 0 - } - - # JSON input template for discriminator value "humanEvaluationPreview": - evaluation_rule_action = { - "templateId": "str", - "type": "humanEvaluationPreview" - } - - # JSON input template you can fill out and use as your body input. - evaluation_rule = { - "action": evaluation_rule_action, - "enabled": bool, - "eventType": "str", - "id": "str", - "systemData": { - "str": "str" - }, - "description": "str", - "displayName": "str", - "filter": { - "agentName": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "continuousEvaluation": - evaluation_rule_action = { - "evalId": "str", - "type": "continuousEvaluation", - "maxHourlyRuns": 0 - } - - # JSON input template for discriminator value "humanEvaluationPreview": - evaluation_rule_action = { - "templateId": "str", - "type": "humanEvaluationPreview" - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "continuousEvaluation": - evaluation_rule_action = { - "evalId": "str", - "type": "continuousEvaluation", - "maxHourlyRuns": 0 - } - - # JSON input template for discriminator value "humanEvaluationPreview": - evaluation_rule_action = { - "templateId": "str", - "type": "humanEvaluationPreview" - } - - # response body for status code(s): 201, 200 - response == { - "action": evaluation_rule_action, - "enabled": bool, - "eventType": "str", - "id": "str", - "systemData": { - "str": "str" - }, - "description": "str", - "displayName": "str", - "filter": { - "agentName": "str" - } - } - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models1.EvaluationRule] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(evaluation_rule, (IOBase, bytes)): - _content = evaluation_rule - else: - _json = evaluation_rule - - _request = build_evaluation_rules_create_or_update_request( - id=id, - foundry_features=foundry_features, - content_type=content_type, - api_version=self._config.api_version, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, - *, - action_type: Optional[types.EvaluationRuleActionType] = None, - agent_name: Optional[str] = None, - enabled: Optional[bool] = None, - **kwargs: Any - ) -> ItemPaged["_types_models1.EvaluationRule"]: - """List all evaluation rules. - - :keyword action_type: Filter by the type of evaluation rule. Known values are: - "continuousEvaluation" and "humanEvaluationPreview". Default value is None. - :paramtype action_type: str or ~azure.ai.agents.models.EvaluationRuleActionType - :keyword agent_name: Filter by the agent name. Default value is None. - :paramtype agent_name: str - :keyword enabled: Filter by the enabled status. Default value is None. - :paramtype enabled: bool - :return: An iterator like instance of EvaluationRule - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.types.EvaluationRule] - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "continuousEvaluation": - evaluation_rule_action = { - "evalId": "str", - "type": "continuousEvaluation", - "maxHourlyRuns": 0 - } - - # JSON input template for discriminator value "humanEvaluationPreview": - evaluation_rule_action = { - "templateId": "str", - "type": "humanEvaluationPreview" - } - - # response body for status code(s): 200 - response == { - "action": evaluation_rule_action, - "enabled": bool, - "eventType": "str", - "id": "str", - "systemData": { - "str": "str" - }, - "description": "str", - "displayName": "str", - "filter": { - "agentName": "str" - } - } - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_types_models1.EvaluationRule]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_evaluation_rules_list_request( - action_type=action_type, - agent_name=agent_name, - enabled=enabled, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized.get("value", []) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - -class ConnectionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.agents.AIProjectClient`'s - :attr:`connections` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def _get(self, name: str, **kwargs: Any) -> _types_models1.Connection: - """Get a connection by name, without populating connection credentials. - - :param name: The friendly name of the connection, provided by the user. Required. - :type name: str - :return: Connection - :rtype: ~azure.ai.agents.types.Connection - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AAD": - base_credentials = { - "type": "AAD" - } - - # JSON input template for discriminator value "AgenticIdentityToken_Preview": - base_credentials = { - "type": "AgenticIdentityToken_Preview" - } - - # JSON input template for discriminator value "ApiKey": - base_credentials = { - "type": "ApiKey", - "key": "str" - } - - # JSON input template for discriminator value "CustomKeys": - base_credentials = { - "type": "CustomKeys" - } - - # JSON input template for discriminator value "None": - base_credentials = { - "type": "None" - } - - # response body for status code(s): 200 - response == { - "credentials": base_credentials, - "id": "str", - "isDefault": bool, - "metadata": { - "str": "str" - }, - "name": "str", - "target": "str", - "type": "str" - } - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_types_models1.Connection] = kwargs.pop("cls", None) - - _request = build_connections_get_request( - name=name, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - response_headers = {} - response_headers["x-ms-client-request-id"] = self._deserialize( - "str", response.headers.get("x-ms-client-request-id") - ) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def _get_with_credentials(self, name: str, **kwargs: Any) -> _types_models1.Connection: - """Get a connection by name, with its connection credentials. - - :param name: The friendly name of the connection, provided by the user. Required. - :type name: str - :return: Connection - :rtype: ~azure.ai.agents.types.Connection - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AAD": - base_credentials = { - "type": "AAD" - } - - # JSON input template for discriminator value "AgenticIdentityToken_Preview": - base_credentials = { - "type": "AgenticIdentityToken_Preview" - } - - # JSON input template for discriminator value "ApiKey": - base_credentials = { - "type": "ApiKey", - "key": "str" - } - - # JSON input template for discriminator value "CustomKeys": - base_credentials = { - "type": "CustomKeys" - } - - # JSON input template for discriminator value "None": - base_credentials = { - "type": "None" - } - - # response body for status code(s): 200 - response == { - "credentials": base_credentials, - "id": "str", - "isDefault": bool, - "metadata": { - "str": "str" - }, - "name": "str", - "target": "str", - "type": "str" - } - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_types_models1.Connection] = kwargs.pop("cls", None) - - _request = build_connections_get_with_credentials_request( - name=name, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - response_headers = {} - response_headers["x-ms-client-request-id"] = self._deserialize( - "str", response.headers.get("x-ms-client-request-id") - ) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, - *, - connection_type: Optional[types.ConnectionType] = None, - default_connection: Optional[bool] = None, - **kwargs: Any - ) -> ItemPaged["_types_models1.Connection"]: - """List all connections in the project, without populating connection credentials. - - :keyword connection_type: List connections of this specific type. Known values are: - "AzureOpenAI", "AzureBlob", "AzureStorageAccount", "CognitiveSearch", "CosmosDB", "ApiKey", - "AppConfig", "AppInsights", "CustomKeys", and "RemoteTool_Preview". Default value is None. - :paramtype connection_type: str or ~azure.ai.agents.models.ConnectionType - :keyword default_connection: List connections that are default connections. Default value is - None. - :paramtype default_connection: bool - :return: An iterator like instance of Connection - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.types.Connection] - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AAD": - base_credentials = { - "type": "AAD" - } - - # JSON input template for discriminator value "AgenticIdentityToken_Preview": - base_credentials = { - "type": "AgenticIdentityToken_Preview" - } - - # JSON input template for discriminator value "ApiKey": - base_credentials = { - "type": "ApiKey", - "key": "str" - } - - # JSON input template for discriminator value "CustomKeys": - base_credentials = { - "type": "CustomKeys" - } - - # JSON input template for discriminator value "None": - base_credentials = { - "type": "None" - } - - # response body for status code(s): 200 - response == { - "credentials": base_credentials, - "id": "str", - "isDefault": bool, - "metadata": { - "str": "str" - }, - "name": "str", - "target": "str", - "type": "str" - } - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_types_models1.Connection]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_connections_list_request( - connection_type=connection_type, - default_connection=default_connection, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized.get("value", []) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - -class DatasetsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.agents.AIProjectClient`'s - :attr:`datasets` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_versions(self, name: str, **kwargs: Any) -> ItemPaged["_types_models1.DatasetVersion"]: - """List all versions of the given DatasetVersion. - - :param name: The name of the resource. Required. - :type name: str - :return: An iterator like instance of DatasetVersion - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.types.DatasetVersion] - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "uri_file": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_file", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "uri_folder": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_folder", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # response body for status code(s): 200 - response == dataset_version - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_types_models1.DatasetVersion]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_datasets_list_versions_request( - name=name, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized.get("value", []) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> ItemPaged["_types_models1.DatasetVersion"]: - """List the latest version of each DatasetVersion. - - :return: An iterator like instance of DatasetVersion - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.types.DatasetVersion] - :raises ~azure.core.exceptions.HttpResponseError: + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "uri_file": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_file", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "uri_folder": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_folder", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # response body for status code(s): 200 - response == dataset_version - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - cls: ClsType[List[_types_models1.DatasetVersion]] = kwargs.pop("cls", None) - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) +class ThreadsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - def prepare_request(next_link=None): - if not next_link: - - _request = build_datasets_list_request( - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + Instead, you should access the following operations through + :class:`~azure.ai.agents.AgentsClient`'s + :attr:`threads` attribute. + """ - return _request + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AgentsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized.get("value", []) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) + @overload + def create( + self, + *, + content_type: str = "application/json", + messages: Optional[List[_models.ThreadMessageOptions]] = None, + tool_resources: Optional[_models.ToolResources] = None, + metadata: Optional[dict[str, str]] = None, + **kwargs: Any + ) -> _models.AgentThread: + """Creates a new thread. Threads contain messages and can be run by agents. - def get_next(next_link=None): - _request = prepare_request(next_link) + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword messages: The initial messages to associate with the new thread. Default value is + None. + :paramtype messages: list[~azure.ai.agents.models.ThreadMessageOptions] + :keyword tool_resources: 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. Default value is None. + :paramtype tool_resources: ~azure.ai.agents.models.ToolResources + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: AgentThread. The AgentThread is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.AgentThread + :raises ~azure.core.exceptions.HttpResponseError: + """ - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + @overload + def create(self, body: JSON, *, content_type: str = "application/json", **kwargs: Any) -> _models.AgentThread: + """Creates a new thread. Threads contain messages and can be run by agents. - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AgentThread. The AgentThread is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.AgentThread + :raises ~azure.core.exceptions.HttpResponseError: + """ - return pipeline_response + @overload + def create(self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any) -> _models.AgentThread: + """Creates a new thread. Threads contain messages and can be run by agents. - return ItemPaged(get_next, extract_data) + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: AgentThread. The AgentThread is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.AgentThread + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace - def get(self, name: str, version: str, **kwargs: Any) -> _types_models1.DatasetVersion: - """Get the specific version of the DatasetVersion. The service returns 404 Not Found error if the - DatasetVersion does not exist. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the DatasetVersion to retrieve. Required. - :type version: str - :return: DatasetVersion - :rtype: ~azure.ai.agents.types.DatasetVersion - :raises ~azure.core.exceptions.HttpResponseError: + def create( + self, + body: Union[JSON, IO[bytes]] = _Unset, + *, + messages: Optional[List[_models.ThreadMessageOptions]] = None, + tool_resources: Optional[_models.ToolResources] = None, + metadata: Optional[dict[str, str]] = None, + **kwargs: Any + ) -> _models.AgentThread: + """Creates a new thread. Threads contain messages and can be run by agents. - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "uri_file": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_file", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "uri_folder": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_folder", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # response body for status code(s): 200 - response == dataset_version + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword messages: The initial messages to associate with the new thread. Default value is + None. + :paramtype messages: list[~azure.ai.agents.models.ThreadMessageOptions] + :keyword tool_resources: 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. Default value is None. + :paramtype tool_resources: ~azure.ai.agents.models.ToolResources + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: AgentThread. The AgentThread is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.AgentThread + :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -6811,15 +1352,26 @@ def get(self, name: str, version: str, **kwargs: Any) -> _types_models1.DatasetV } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_types_models1.DatasetVersion] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AgentThread] = kwargs.pop("cls", None) + + if body is _Unset: + body = {"messages": messages, "metadata": metadata, "tool_resources": tool_resources} + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_datasets_get_request( - name=name, - version=version, + _request = build_threads_create_request( + content_type=content_type, api_version=self._config.api_version, + content=_content, headers=_headers, params=_params, ) @@ -6828,7 +1380,6 @@ def get(self, name: str, version: str, **kwargs: Any) -> _types_models1.DatasetV } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -6843,15 +1394,13 @@ def get(self, name: str, version: str, **kwargs: Any) -> _types_models1.DatasetV except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.AgentThread, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -6859,18 +1408,36 @@ def get(self, name: str, version: str, **kwargs: Any) -> _types_models1.DatasetV return deserialized # type: ignore @distributed_trace - def delete(self, name: str, version: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements - """Delete the specific version of the DatasetVersion. The service returns 204 No Content if the - DatasetVersion was deleted successfully or if the DatasetVersion does not exist. - - :param name: The name of the resource. Required. - :type name: str - :param version: The version of the DatasetVersion to delete. Required. - :type version: str - :return: None - :rtype: None + def list( + self, + *, + limit: Optional[int] = None, + order: Optional[Union[str, _models.ListSortOrder]] = None, + before: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.AgentThread"]: + """Gets a list of threads that were previously created. + + :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and + 100, and the default is 20. Default value is None. + :paramtype limit: int + :keyword order: Sort order by the created_at timestamp of the objects. asc for ascending order + and desc for descending order. Known values are: "asc" and "desc". Default value is None. + :paramtype order: str or ~azure.ai.agents.models.ListSortOrder + :keyword 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. Default value is None. + :paramtype before: str + :return: An iterator like instance of AgentThread + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.models.AgentThread] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AgentThread]] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -6879,393 +1446,57 @@ def delete(self, name: str, version: str, **kwargs: Any) -> None: # pylint: dis } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_datasets_delete_request( - name=name, - version=version, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + def prepare_request(_continuation_token=None): - response = pipeline_response.http_response + _request = build_threads_list_request( + limit=limit, + order=order, + after=_continuation_token, + before=before, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.AgentThread], deserialized.get("data", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("last_id") or None, iter(list_of_elem) - if cls: - return cls(pipeline_response, None, {}) # type: ignore + def get_next(_continuation_token=None): + _request = prepare_request(_continuation_token) - @overload - def create_or_update( - self, - name: str, - version: str, - dataset_version: _types_models1.DatasetVersion, - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> _types_models1.DatasetVersion: - """Create a new or update an existing DatasetVersion with the given version id. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the DatasetVersion to create or update. Required. - :type version: str - :param dataset_version: The DatasetVersion to create or update. Required. - :type dataset_version: ~azure.ai.agents.types.DatasetVersion - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/merge-patch+json". - :paramtype content_type: str - :return: DatasetVersion - :rtype: ~azure.ai.agents.types.DatasetVersion - :raises ~azure.core.exceptions.HttpResponseError: + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "type": - - # JSON input template for discriminator value "uri_file": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_file", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "uri_folder": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_folder", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # JSON input template you can fill out and use as your body input. - dataset_version = dataset_version - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "uri_file": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_file", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "uri_folder": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_folder", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "uri_file": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_file", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "uri_folder": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_folder", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # response body for status code(s): 201, 200 - response == dataset_version - """ + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) - @overload - def create_or_update( - self, - name: str, - version: str, - dataset_version: IO[bytes], - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> _types_models1.DatasetVersion: - """Create a new or update an existing DatasetVersion with the given version id. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the DatasetVersion to create or update. Required. - :type version: str - :param dataset_version: The DatasetVersion to create or update. Required. - :type dataset_version: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/merge-patch+json". - :paramtype content_type: str - :return: DatasetVersion - :rtype: ~azure.ai.agents.types.DatasetVersion - :raises ~azure.core.exceptions.HttpResponseError: + return pipeline_response - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "uri_file": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_file", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "uri_folder": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_folder", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "uri_file": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_file", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "uri_folder": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_folder", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # response body for status code(s): 201, 200 - response == dataset_version - """ + return ItemPaged(get_next, extract_data) @distributed_trace - def create_or_update( - self, name: str, version: str, dataset_version: Union[_types_models1.DatasetVersion, IO[bytes]], **kwargs: Any - ) -> _types_models1.DatasetVersion: - """Create a new or update an existing DatasetVersion with the given version id. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the DatasetVersion to create or update. Required. - :type version: str - :param dataset_version: The DatasetVersion to create or update. Is either a DatasetVersion type - or a IO[bytes] type. Required. - :type dataset_version: ~azure.ai.agents.types.DatasetVersion or IO[bytes] - :return: DatasetVersion - :rtype: ~azure.ai.agents.types.DatasetVersion - :raises ~azure.core.exceptions.HttpResponseError: + def get(self, thread_id: str, **kwargs: Any) -> _models.AgentThread: + """Gets information about an existing thread. - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "type": - - # JSON input template for discriminator value "uri_file": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_file", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "uri_folder": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_folder", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # JSON input template you can fill out and use as your body input. - dataset_version = dataset_version - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "uri_file": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_file", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "uri_folder": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_folder", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "uri_file": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_file", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "uri_folder": - dataset_version = { - "dataUri": "str", - "name": "str", - "type": "uri_folder", - "version": "str", - "connectionName": "str", - "description": "str", - "id": "str", - "isReference": bool, - "tags": { - "str": "str" - } - } - - # response body for status code(s): 201, 200 - response == dataset_version + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :return: AgentThread. The AgentThread is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.AgentThread + :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -7275,27 +1506,14 @@ def create_or_update( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models1.DatasetVersion] = kwargs.pop("cls", None) - - content_type = content_type or "application/merge-patch+json" - _json = None - _content = None - if isinstance(dataset_version, (IOBase, bytes)): - _content = dataset_version - else: - _json = dataset_version + cls: ClsType[_models.AgentThread] = kwargs.pop("cls", None) - _request = build_datasets_create_or_update_request( - name=name, - version=version, - content_type=content_type, + _request = build_threads_get_request( + thread_id=thread_id, api_version=self._config.api_version, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -7304,7 +1522,6 @@ def create_or_update( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -7312,22 +1529,20 @@ def create_or_update( response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200]: if _stream: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.AgentThread, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -7335,145 +1550,104 @@ def create_or_update( return deserialized # type: ignore @overload - def pending_upload( + def update( self, - name: str, - version: str, - pending_upload_request: _types_models1.PendingUploadRequest, + thread_id: str, *, content_type: str = "application/json", + tool_resources: Optional[_models.ToolResources] = None, + metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> _types_models1.PendingUploadResponse: - """Start a new or get an existing pending upload of a dataset for a specific version. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the DatasetVersion to operate on. Required. - :type version: str - :param pending_upload_request: The pending upload request parameters. Required. - :type pending_upload_request: ~azure.ai.agents.types.PendingUploadRequest + ) -> _models.AgentThread: + """Modifies an existing thread. + + :param thread_id: The ID of the thread to modify. Required. + :type thread_id: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: PendingUploadResponse - :rtype: ~azure.ai.agents.types.PendingUploadResponse + :keyword tool_resources: 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. Default value is None. + :paramtype tool_resources: ~azure.ai.agents.models.ToolResources + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: AgentThread. The AgentThread is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.AgentThread :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, thread_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.AgentThread: + """Modifies an existing thread. - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - pending_upload_request = { - "pendingUploadType": "str", - "connectionName": "str", - "pendingUploadId": "str" - } - - # response body for status code(s): 200 - response == { - "blobReference": { - "blobUri": "str", - "credential": { - "sasUri": "str", - "type": "SAS" - }, - "storageAccountArmId": "str" - }, - "pendingUploadId": "str", - "pendingUploadType": "str", - "version": "str" - } + :param thread_id: The ID of the thread to modify. Required. + :type thread_id: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AgentThread. The AgentThread is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.AgentThread + :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def pending_upload( - self, - name: str, - version: str, - pending_upload_request: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models1.PendingUploadResponse: - """Start a new or get an existing pending upload of a dataset for a specific version. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the DatasetVersion to operate on. Required. - :type version: str - :param pending_upload_request: The pending upload request parameters. Required. - :type pending_upload_request: IO[bytes] + def update( + self, thread_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.AgentThread: + """Modifies an existing thread. + + :param thread_id: The ID of the thread to modify. Required. + :type thread_id: str + :param body: Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: PendingUploadResponse - :rtype: ~azure.ai.agents.types.PendingUploadResponse + :return: AgentThread. The AgentThread is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.AgentThread :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "blobReference": { - "blobUri": "str", - "credential": { - "sasUri": "str", - "type": "SAS" - }, - "storageAccountArmId": "str" - }, - "pendingUploadId": "str", - "pendingUploadType": "str", - "version": "str" - } """ @distributed_trace - def pending_upload( + def update( self, - name: str, - version: str, - pending_upload_request: Union[_types_models1.PendingUploadRequest, IO[bytes]], + thread_id: str, + body: Union[JSON, IO[bytes]] = _Unset, + *, + tool_resources: Optional[_models.ToolResources] = None, + metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> _types_models1.PendingUploadResponse: - """Start a new or get an existing pending upload of a dataset for a specific version. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the DatasetVersion to operate on. Required. - :type version: str - :param pending_upload_request: The pending upload request parameters. Is either a - PendingUploadRequest type or a IO[bytes] type. Required. - :type pending_upload_request: ~azure.ai.agents.types.PendingUploadRequest or IO[bytes] - :return: PendingUploadResponse - :rtype: ~azure.ai.agents.types.PendingUploadResponse - :raises ~azure.core.exceptions.HttpResponseError: + ) -> _models.AgentThread: + """Modifies an existing thread. - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - pending_upload_request = { - "pendingUploadType": "str", - "connectionName": "str", - "pendingUploadId": "str" - } - - # response body for status code(s): 200 - response == { - "blobReference": { - "blobUri": "str", - "credential": { - "sasUri": "str", - "type": "SAS" - }, - "storageAccountArmId": "str" - }, - "pendingUploadId": "str", - "pendingUploadType": "str", - "version": "str" - } + :param thread_id: The ID of the thread to modify. Required. + :type thread_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword tool_resources: 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. Default value is None. + :paramtype tool_resources: ~azure.ai.agents.models.ToolResources + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: AgentThread. The AgentThread is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.AgentThread + :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -7487,22 +1661,22 @@ def pending_upload( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models1.PendingUploadResponse] = kwargs.pop("cls", None) + cls: ClsType[_models.AgentThread] = kwargs.pop("cls", None) + if body is _Unset: + body = {"metadata": metadata, "tool_resources": tool_resources} + body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" - _json = None _content = None - if isinstance(pending_upload_request, (IOBase, bytes)): - _content = pending_upload_request + if isinstance(body, (IOBase, bytes)): + _content = body else: - _json = pending_upload_request + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_datasets_pending_upload_request( - name=name, - version=version, + _request = build_threads_update_request( + thread_id=thread_id, content_type=content_type, api_version=self._config.api_version, - json=_json, content=_content, headers=_headers, params=_params, @@ -7512,7 +1686,6 @@ def pending_upload( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -7527,15 +1700,13 @@ def pending_upload( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.AgentThread, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -7543,31 +1714,14 @@ def pending_upload( return deserialized # type: ignore @distributed_trace - def get_credentials(self, name: str, version: str, **kwargs: Any) -> _types_models1.DatasetCredential: - """Get the SAS credential to access the storage account associated with a Dataset version. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the DatasetVersion to operate on. Required. - :type version: str - :return: DatasetCredential - :rtype: ~azure.ai.agents.types.DatasetCredential - :raises ~azure.core.exceptions.HttpResponseError: + def _delete_thread(self, thread_id: str, **kwargs: Any) -> _models._models.ThreadDeletionStatus: + """Deletes an existing thread. - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "blobReference": { - "blobUri": "str", - "credential": { - "sasUri": "str", - "type": "SAS" - }, - "storageAccountArmId": "str" - } - } + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :return: ThreadDeletionStatus. The ThreadDeletionStatus is compatible with MutableMapping + :rtype: ~azure.ai.agents.models._models.ThreadDeletionStatus + :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -7580,11 +1734,10 @@ def get_credentials(self, name: str, version: str, **kwargs: Any) -> _types_mode _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_types_models1.DatasetCredential] = kwargs.pop("cls", None) + cls: ClsType[_models._models.ThreadDeletionStatus] = kwargs.pop("cls", None) - _request = build_datasets_get_credentials_request( - name=name, - version=version, + _request = build_threads_delete_thread_request( + thread_id=thread_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -7594,7 +1747,6 @@ def get_credentials(self, name: str, version: str, **kwargs: Any) -> _types_mode } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -7609,15 +1761,15 @@ def get_credentials(self, name: str, version: str, **kwargs: Any) -> _types_mode except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize( + _models._models.ThreadDeletionStatus, response.json() # pylint: disable=protected-access + ) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -7625,61 +1777,142 @@ def get_credentials(self, name: str, version: str, **kwargs: Any) -> _types_mode return deserialized # type: ignore -class DeploymentsOperations: +class MessagesOperations: """ .. warning:: **DO NOT** instantiate this class directly. - Instead, you should access the following operations through - :class:`~azure.ai.agents.AIProjectClient`'s - :attr:`deployments` attribute. - """ + Instead, you should access the following operations through + :class:`~azure.ai.agents.AgentsClient`'s + :attr:`messages` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AgentsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + def create( + self, + thread_id: str, + *, + role: Union[str, _models.MessageRole], + content: "_types.MessageInputContent", + content_type: str = "application/json", + attachments: Optional[List[_models.MessageAttachment]] = None, + metadata: Optional[dict[str, str]] = None, + **kwargs: Any + ) -> _models.ThreadMessage: + """Creates a new message on a specified thread. + + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :keyword 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). Known values are: "user" and "assistant". + Required. + :paramtype role: str or ~azure.ai.agents.models.MessageRole + :keyword 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). Is either a str type or a [MessageInputContentBlock] type. Required. + :paramtype content: str or list[~azure.ai.agents.models.MessageInputContentBlock] + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword attachments: A list of files attached to the message, and the tools they should be + added to. Default value is None. + :paramtype attachments: list[~azure.ai.agents.models.MessageAttachment] + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: ThreadMessage. The ThreadMessage is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadMessage + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, thread_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ThreadMessage: + """Creates a new message on a specified thread. + + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ThreadMessage. The ThreadMessage is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadMessage + :raises ~azure.core.exceptions.HttpResponseError: + """ - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @overload + def create( + self, thread_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ThreadMessage: + """Creates a new message on a specified thread. + + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ThreadMessage. The ThreadMessage is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadMessage + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace - def get(self, name: str, **kwargs: Any) -> _types_models1.Deployment: - """Get a deployed model. + def create( + self, + thread_id: str, + body: Union[JSON, IO[bytes]] = _Unset, + *, + role: Union[str, _models.MessageRole] = _Unset, + content: "_types.MessageInputContent" = _Unset, + attachments: Optional[List[_models.MessageAttachment]] = None, + metadata: Optional[dict[str, str]] = None, + **kwargs: Any + ) -> _models.ThreadMessage: + """Creates a new message on a specified thread. - :param name: Name of the deployment. Required. - :type name: str - :return: Deployment - :rtype: ~azure.ai.agents.types.Deployment + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword 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). Known values are: "user" and "assistant". + Required. + :paramtype role: str or ~azure.ai.agents.models.MessageRole + :keyword 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). Is either a str type or a [MessageInputContentBlock] type. Required. + :paramtype content: str or list[~azure.ai.agents.models.MessageInputContentBlock] + :keyword attachments: A list of files attached to the message, and the tools they should be + added to. Default value is None. + :paramtype attachments: list[~azure.ai.agents.models.MessageAttachment] + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: ThreadMessage. The ThreadMessage is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadMessage :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "ModelDeployment": - deployment = { - "capabilities": { - "str": "str" - }, - "modelName": "str", - "modelPublisher": "str", - "modelVersion": "str", - "name": "str", - "sku": { - "capacity": 0, - "family": "str", - "name": "str", - "size": "str", - "tier": "str" - }, - "type": "ModelDeployment", - "connectionName": "str" - } - - # response body for status code(s): 200 - response == deployment """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -7689,14 +1922,31 @@ def get(self, name: str, **kwargs: Any) -> _types_models1.Deployment: } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_types_models1.Deployment] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ThreadMessage] = kwargs.pop("cls", None) + + if body is _Unset: + if role is _Unset: + raise TypeError("missing required argument: role") + if content is _Unset: + raise TypeError("missing required argument: content") + body = {"attachments": attachments, "content": content, "metadata": metadata, "role": role} + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_deployments_get_request( - name=name, + _request = build_messages_create_request( + thread_id=thread_id, + content_type=content_type, api_version=self._config.api_version, + content=_content, headers=_headers, params=_params, ) @@ -7705,7 +1955,6 @@ def get(self, name: str, **kwargs: Any) -> _types_models1.Deployment: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -7720,82 +1969,55 @@ def get(self, name: str, **kwargs: Any) -> _types_models1.Deployment: except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - response_headers = {} - response_headers["x-ms-client-request-id"] = self._deserialize( - "str", response.headers.get("x-ms-client-request-id") - ) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.ThreadMessage, response.json()) if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @distributed_trace def list( self, + thread_id: str, *, - model_publisher: Optional[str] = None, - model_name: Optional[str] = None, - deployment_type: Optional[types.DeploymentType] = None, + run_id: Optional[str] = None, + limit: Optional[int] = None, + order: Optional[Union[str, _models.ListSortOrder]] = None, + before: Optional[str] = None, **kwargs: Any - ) -> ItemPaged["_types_models1.Deployment"]: - """List all deployed models in the project. + ) -> ItemPaged["_models.ThreadMessage"]: + """Gets a list of messages that exist on a thread. - :keyword model_publisher: Model publisher to filter models by. Default value is None. - :paramtype model_publisher: str - :keyword model_name: Model name (the publisher specific name) to filter models by. Default - value is None. - :paramtype model_name: str - :keyword deployment_type: Type of deployment to filter list by. "ModelDeployment" Default value - is None. - :paramtype deployment_type: str or ~azure.ai.agents.models.DeploymentType - :return: An iterator like instance of Deployment - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.types.Deployment] + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :keyword run_id: Filter messages by the run ID that generated them. Default value is None. + :paramtype run_id: str + :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and + 100, and the default is 20. Default value is None. + :paramtype limit: int + :keyword order: Sort order by the created_at timestamp of the objects. asc for ascending order + and desc for descending order. Known values are: "asc" and "desc". Default value is None. + :paramtype order: str or ~azure.ai.agents.models.ListSortOrder + :keyword 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. Default value is None. + :paramtype before: str + :return: An iterator like instance of ThreadMessage + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.models.ThreadMessage] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "ModelDeployment": - deployment = { - "capabilities": { - "str": "str" - }, - "modelName": "str", - "modelPublisher": "str", - "modelVersion": "str", - "name": "str", - "sku": { - "capacity": 0, - "family": "str", - "name": "str", - "size": "str", - "tier": "str" - }, - "type": "ModelDeployment", - "connectionName": "str" - } - - # response body for status code(s): 200 - response == deployment """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_types_models1.Deployment]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.ThreadMessage]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -7805,58 +2027,34 @@ def list( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - _request = build_deployments_list_request( - model_publisher=model_publisher, - model_name=model_name, - deployment_type=deployment_type, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + def prepare_request(_continuation_token=None): + _request = build_messages_list_request( + thread_id=thread_id, + run_id=run_id, + limit=limit, + order=order, + after=_continuation_token, + before=before, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) return _request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized.get("value", []) + list_of_elem = _deserialize(List[_models.ThreadMessage], deserialized.get("data", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) + return deserialized.get("last_id") or None, iter(list_of_elem) - def get_next(next_link=None): - _request = prepare_request(next_link) + def get_next(_continuation_token=None): + _request = prepare_request(_continuation_token) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access @@ -7872,122 +2070,18 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - -class IndexesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.agents.AIProjectClient`'s - :attr:`indexes` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_versions(self, name: str, **kwargs: Any) -> ItemPaged["_types_models1.Index"]: - """List all versions of the given Index. - - :param name: The name of the resource. Required. - :type name: str - :return: An iterator like instance of Index - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.types.Index] + def get(self, thread_id: str, message_id: str, **kwargs: Any) -> _models.ThreadMessage: + """Retrieves an existing message. + + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param message_id: Identifier of the message. Required. + :type message_id: str + :return: ThreadMessage. The ThreadMessage is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadMessage :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AzureSearch": - index = { - "connectionName": "str", - "indexName": "str", - "name": "str", - "type": "AzureSearch", - "version": "str", - "description": "str", - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": - index = { - "connectionName": "str", - "containerName": "str", - "databaseName": "str", - "embeddingConfiguration": { - "embeddingField": "str", - "modelDeploymentName": "str" - }, - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "name": "str", - "type": "CosmosDBNoSqlVectorStore", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "ManagedAzureSearch": - index = { - "name": "str", - "type": "ManagedAzureSearch", - "vectorStoreId": "str", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # response body for status code(s): 200 - response == index """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_types_models1.Index]] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -7996,334 +2090,145 @@ def list_versions(self, name: str, **kwargs: Any) -> ItemPaged["_types_models1.I } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - _request = build_indexes_list_versions_request( - name=name, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized.get("value", []) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> ItemPaged["_types_models1.Index"]: - """List the latest version of each Index. - - :return: An iterator like instance of Index - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.types.Index] - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AzureSearch": - index = { - "connectionName": "str", - "indexName": "str", - "name": "str", - "type": "AzureSearch", - "version": "str", - "description": "str", - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": - index = { - "connectionName": "str", - "containerName": "str", - "databaseName": "str", - "embeddingConfiguration": { - "embeddingField": "str", - "modelDeploymentName": "str" - }, - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "name": "str", - "type": "CosmosDBNoSqlVectorStore", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "ManagedAzureSearch": - index = { - "name": "str", - "type": "ManagedAzureSearch", - "vectorStoreId": "str", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # response body for status code(s): 200 - response == index - """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_types_models1.Index]] = kwargs.pop("cls", None) + cls: ClsType[_models.ThreadMessage] = kwargs.pop("cls", None) - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, + _request = build_messages_get_request( + thread_id=thread_id, + message_id=message_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - error_map.update(kwargs.pop("error_map", {}) or {}) + _request.url = self._client.format_url(_request.url, **path_format_arguments) - def prepare_request(next_link=None): - if not next_link: - - _request = build_indexes_list_request( - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - return _request + response = pipeline_response.http_response - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized.get("value", []) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) - def get_next(next_link=None): - _request = prepare_request(next_link) + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.ThreadMessage, response.json()) - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + return deserialized # type: ignore - return pipeline_response + @overload + def update( + self, + thread_id: str, + message_id: str, + *, + content_type: str = "application/json", + metadata: Optional[dict[str, str]] = None, + **kwargs: Any + ) -> _models.ThreadMessage: + """Modifies an existing message on an existing thread. - return ItemPaged(get_next, extract_data) + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param message_id: Identifier of the message. Required. + :type message_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: ThreadMessage. The ThreadMessage is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadMessage + :raises ~azure.core.exceptions.HttpResponseError: + """ - @distributed_trace - def get(self, name: str, version: str, **kwargs: Any) -> _types_models1.Index: - """Get the specific version of the Index. The service returns 404 Not Found error if the Index - does not exist. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the Index to retrieve. Required. - :type version: str - :return: Index - :rtype: ~azure.ai.agents.types.Index + @overload + def update( + self, thread_id: str, message_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ThreadMessage: + """Modifies an existing message on an existing thread. + + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param message_id: Identifier of the message. Required. + :type message_id: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ThreadMessage. The ThreadMessage is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadMessage + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, thread_id: str, message_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ThreadMessage: + """Modifies an existing message on an existing thread. + + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param message_id: Identifier of the message. Required. + :type message_id: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ThreadMessage. The ThreadMessage is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadMessage :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + thread_id: str, + message_id: str, + body: Union[JSON, IO[bytes]] = _Unset, + *, + metadata: Optional[dict[str, str]] = None, + **kwargs: Any + ) -> _models.ThreadMessage: + """Modifies an existing message on an existing thread. - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AzureSearch": - index = { - "connectionName": "str", - "indexName": "str", - "name": "str", - "type": "AzureSearch", - "version": "str", - "description": "str", - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": - index = { - "connectionName": "str", - "containerName": "str", - "databaseName": "str", - "embeddingConfiguration": { - "embeddingField": "str", - "modelDeploymentName": "str" - }, - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "name": "str", - "type": "CosmosDBNoSqlVectorStore", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "ManagedAzureSearch": - index = { - "name": "str", - "type": "ManagedAzureSearch", - "vectorStoreId": "str", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # response body for status code(s): 200 - response == index + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param message_id: Identifier of the message. Required. + :type message_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: ThreadMessage. The ThreadMessage is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadMessage + :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -8333,15 +2238,28 @@ def get(self, name: str, version: str, **kwargs: Any) -> _types_models1.Index: } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_types_models1.Index] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ThreadMessage] = kwargs.pop("cls", None) + + if body is _Unset: + body = {"metadata": metadata} + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_indexes_get_request( - name=name, - version=version, + _request = build_messages_update_request( + thread_id=thread_id, + message_id=message_id, + content_type=content_type, api_version=self._config.api_version, + content=_content, headers=_headers, params=_params, ) @@ -8350,7 +2268,6 @@ def get(self, name: str, version: str, **kwargs: Any) -> _types_models1.Index: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -8365,15 +2282,13 @@ def get(self, name: str, version: str, **kwargs: Any) -> _types_models1.Index: except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.ThreadMessage, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -8381,16 +2296,20 @@ def get(self, name: str, version: str, **kwargs: Any) -> _types_models1.Index: return deserialized # type: ignore @distributed_trace - def delete(self, name: str, version: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements - """Delete the specific version of the Index. The service returns 204 No Content if the Index was - deleted successfully or if the Index does not exist. - - :param name: The name of the resource. Required. - :type name: str - :param version: The version of the Index to delete. Required. - :type version: str - :return: None - :rtype: None + @api_version_validation( + method_added_on="v1", + params_added_on={"v1": ["api_version", "thread_id", "message_id", "accept"]}, + api_versions_list=["v1", "2025-05-15-preview"], + ) + def _delete(self, thread_id: str, message_id: str, **kwargs: Any) -> _models._models.MessageDeletionStatus: + """Deletes an existing message on an existing thread. + + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param message_id: Identifier of the message. Required. + :type message_id: str + :return: MessageDeletionStatus. The MessageDeletionStatus is compatible with MutableMapping + :rtype: ~azure.ai.agents.models._models.MessageDeletionStatus :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -8404,11 +2323,11 @@ def delete(self, name: str, version: str, **kwargs: Any) -> None: # pylint: dis _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[_models._models.MessageDeletionStatus] = kwargs.pop("cls", None) - _request = build_indexes_delete_request( - name=name, - version=version, + _request = build_messages_delete_request( + thread_id=thread_id, + message_id=message_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -8418,728 +2337,342 @@ def delete(self, name: str, version: str, **kwargs: Any) -> None: # pylint: dis } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [204]: + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize( + _models._models.MessageDeletionStatus, response.json() # pylint: disable=protected-access + ) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class RunsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.agents.AgentsClient`'s + :attr:`runs` attribute. + """ - if cls: - return cls(pipeline_response, None, {}) # type: ignore + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AgentsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @overload - def create_or_update( + def create( self, - name: str, - version: str, - index: _types_models1.Index, + thread_id: str, *, - content_type: str = "application/merge-patch+json", + agent_id: str, + include: Optional[List[Union[str, _models.RunAdditionalFieldList]]] = None, + content_type: str = "application/json", + model: Optional[str] = None, + instructions: Optional[str] = None, + additional_instructions: Optional[str] = None, + additional_messages: Optional[List[_models.ThreadMessageOptions]] = None, + tools: Optional[List[_models.ToolDefinition]] = None, + tool_resources: Optional[_models.ToolResources] = None, + stream_parameter: Optional[bool] = None, + temperature: Optional[float] = None, + top_p: Optional[float] = None, + max_prompt_tokens: Optional[int] = None, + max_completion_tokens: Optional[int] = None, + truncation_strategy: Optional[_models.TruncationObject] = None, + tool_choice: Optional["_types.AgentsToolChoiceOption"] = None, + response_format: Optional["_types.AgentsResponseFormatOption"] = None, + parallel_tool_calls: Optional[bool] = None, + metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> _types_models1.Index: - """Create a new or update an existing Index with the given version id. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the Index to create or update. Required. - :type version: str - :param index: The Index to create or update. Required. - :type index: ~azure.ai.agents.types.Index + ) -> _models.ThreadRun: + """Creates a new run for an agent thread. + + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :keyword agent_id: The ID of the agent that should run the thread. Required. + :paramtype agent_id: str + :keyword 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. Default value is None. + :paramtype include: list[str or ~azure.ai.agents.models.RunAdditionalFieldList] :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/merge-patch+json". + Default value is "application/json". :paramtype content_type: str - :return: Index - :rtype: ~azure.ai.agents.types.Index + :keyword model: The overridden model name that the agent should use to run the thread. Default + value is None. + :paramtype model: str + :keyword instructions: The overridden system instructions that the agent should use to run the + thread. Default value is None. + :paramtype instructions: str + :keyword additional_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. Default value is None. + :paramtype additional_instructions: str + :keyword additional_messages: Adds additional messages to the thread before creating the run. + Default value is None. + :paramtype additional_messages: list[~azure.ai.agents.models.ThreadMessageOptions] + :keyword tools: The overridden list of enabled tools that the agent should use to run the + thread. Default value is None. + :paramtype tools: list[~azure.ai.agents.models.ToolDefinition] + :keyword tool_resources: The overridden enabled tool resources that the agent should use to run + the thread. Default value is None. + :paramtype tool_resources: ~azure.ai.agents.models.ToolResources + :keyword stream_parameter: 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. Default + value is None. + :paramtype stream_parameter: bool + :keyword temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 + will make the output + more random, while lower values like 0.2 will make it more focused and deterministic. Default + value is None. + :paramtype temperature: float + :keyword top_p: An alternative to sampling with temperature, called nucleus sampling, where the + model + considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens + comprising the top 10% probability mass are considered. + + We generally recommend altering this or temperature but not both. Default value is None. + :paramtype top_p: float + :keyword max_prompt_tokens: 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. Default + value is None. + :paramtype max_prompt_tokens: int + :keyword max_completion_tokens: 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. Default value is None. + :paramtype max_completion_tokens: int + :keyword truncation_strategy: The strategy to use for dropping messages as the context windows + moves forward. Default value is None. + :paramtype truncation_strategy: ~azure.ai.agents.models.TruncationObject + :keyword tool_choice: Controls whether or not and which tool is called by the model. Is one of + the following types: str, Union[str, "_models.AgentsToolChoiceOptionMode"], + AgentsNamedToolChoice Default value is None. + :paramtype tool_choice: str or str or ~azure.ai.agents.models.AgentsToolChoiceOptionMode or + ~azure.ai.agents.models.AgentsNamedToolChoice + :keyword response_format: Specifies the format that the model must output. Is one of the + following types: str, Union[str, "_models.AgentsResponseFormatMode"], AgentsResponseFormat, + ResponseFormatJsonSchemaType Default value is None. + :paramtype response_format: str or str or ~azure.ai.agents.models.AgentsResponseFormatMode or + ~azure.ai.agents.models.AgentsResponseFormat or + ~azure.ai.agents.models.ResponseFormatJsonSchemaType + :keyword parallel_tool_calls: If ``true`` functions will run in parallel during tool use. + Default value is None. + :paramtype parallel_tool_calls: bool + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: ThreadRun. The ThreadRun is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadRun :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + thread_id: str, + body: JSON, + *, + include: Optional[List[Union[str, _models.RunAdditionalFieldList]]] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ThreadRun: + """Creates a new run for an agent thread. - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "type": - - # JSON input template for discriminator value "AzureSearch": - index = { - "connectionName": "str", - "indexName": "str", - "name": "str", - "type": "AzureSearch", - "version": "str", - "description": "str", - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": - index = { - "connectionName": "str", - "containerName": "str", - "databaseName": "str", - "embeddingConfiguration": { - "embeddingField": "str", - "modelDeploymentName": "str" - }, - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "name": "str", - "type": "CosmosDBNoSqlVectorStore", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "ManagedAzureSearch": - index = { - "name": "str", - "type": "ManagedAzureSearch", - "vectorStoreId": "str", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template you can fill out and use as your body input. - index = index - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AzureSearch": - index = { - "connectionName": "str", - "indexName": "str", - "name": "str", - "type": "AzureSearch", - "version": "str", - "description": "str", - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": - index = { - "connectionName": "str", - "containerName": "str", - "databaseName": "str", - "embeddingConfiguration": { - "embeddingField": "str", - "modelDeploymentName": "str" - }, - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "name": "str", - "type": "CosmosDBNoSqlVectorStore", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "ManagedAzureSearch": - index = { - "name": "str", - "type": "ManagedAzureSearch", - "vectorStoreId": "str", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AzureSearch": - index = { - "connectionName": "str", - "indexName": "str", - "name": "str", - "type": "AzureSearch", - "version": "str", - "description": "str", - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": - index = { - "connectionName": "str", - "containerName": "str", - "databaseName": "str", - "embeddingConfiguration": { - "embeddingField": "str", - "modelDeploymentName": "str" - }, - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "name": "str", - "type": "CosmosDBNoSqlVectorStore", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "ManagedAzureSearch": - index = { - "name": "str", - "type": "ManagedAzureSearch", - "vectorStoreId": "str", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # response body for status code(s): 201, 200 - response == index + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param body: Required. + :type body: JSON + :keyword 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. Default value is None. + :paramtype include: list[str or ~azure.ai.agents.models.RunAdditionalFieldList] + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ThreadRun. The ThreadRun is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadRun + :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def create_or_update( + def create( self, - name: str, - version: str, - index: IO[bytes], + thread_id: str, + body: IO[bytes], *, - content_type: str = "application/merge-patch+json", + include: Optional[List[Union[str, _models.RunAdditionalFieldList]]] = None, + content_type: str = "application/json", **kwargs: Any - ) -> _types_models1.Index: - """Create a new or update an existing Index with the given version id. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the Index to create or update. Required. - :type version: str - :param index: The Index to create or update. Required. - :type index: IO[bytes] + ) -> _models.ThreadRun: + """Creates a new run for an agent thread. + + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param body: Required. + :type body: IO[bytes] + :keyword 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. Default value is None. + :paramtype include: list[str or ~azure.ai.agents.models.RunAdditionalFieldList] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/merge-patch+json". + Default value is "application/json". :paramtype content_type: str - :return: Index - :rtype: ~azure.ai.agents.types.Index + :return: ThreadRun. The ThreadRun is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadRun :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AzureSearch": - index = { - "connectionName": "str", - "indexName": "str", - "name": "str", - "type": "AzureSearch", - "version": "str", - "description": "str", - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": - index = { - "connectionName": "str", - "containerName": "str", - "databaseName": "str", - "embeddingConfiguration": { - "embeddingField": "str", - "modelDeploymentName": "str" - }, - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "name": "str", - "type": "CosmosDBNoSqlVectorStore", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "ManagedAzureSearch": - index = { - "name": "str", - "type": "ManagedAzureSearch", - "vectorStoreId": "str", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AzureSearch": - index = { - "connectionName": "str", - "indexName": "str", - "name": "str", - "type": "AzureSearch", - "version": "str", - "description": "str", - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": - index = { - "connectionName": "str", - "containerName": "str", - "databaseName": "str", - "embeddingConfiguration": { - "embeddingField": "str", - "modelDeploymentName": "str" - }, - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "name": "str", - "type": "CosmosDBNoSqlVectorStore", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "ManagedAzureSearch": - index = { - "name": "str", - "type": "ManagedAzureSearch", - "vectorStoreId": "str", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # response body for status code(s): 201, 200 - response == index """ @distributed_trace - def create_or_update( - self, name: str, version: str, index: Union[_types_models1.Index, IO[bytes]], **kwargs: Any - ) -> _types_models1.Index: - """Create a new or update an existing Index with the given version id. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the Index to create or update. Required. - :type version: str - :param index: The Index to create or update. Is either a Index type or a IO[bytes] type. - Required. - :type index: ~azure.ai.agents.types.Index or IO[bytes] - :return: Index - :rtype: ~azure.ai.agents.types.Index - :raises ~azure.core.exceptions.HttpResponseError: + def create( + self, + thread_id: str, + body: Union[JSON, IO[bytes]] = _Unset, + *, + agent_id: str = _Unset, + include: Optional[List[Union[str, _models.RunAdditionalFieldList]]] = None, + model: Optional[str] = None, + instructions: Optional[str] = None, + additional_instructions: Optional[str] = None, + additional_messages: Optional[List[_models.ThreadMessageOptions]] = None, + tools: Optional[List[_models.ToolDefinition]] = None, + tool_resources: Optional[_models.ToolResources] = None, + stream_parameter: Optional[bool] = None, + temperature: Optional[float] = None, + top_p: Optional[float] = None, + max_prompt_tokens: Optional[int] = None, + max_completion_tokens: Optional[int] = None, + truncation_strategy: Optional[_models.TruncationObject] = None, + tool_choice: Optional["_types.AgentsToolChoiceOption"] = None, + response_format: Optional["_types.AgentsResponseFormatOption"] = None, + parallel_tool_calls: Optional[bool] = None, + metadata: Optional[dict[str, str]] = None, + **kwargs: Any + ) -> _models.ThreadRun: + """Creates a new run for an agent thread. - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "type": - - # JSON input template for discriminator value "AzureSearch": - index = { - "connectionName": "str", - "indexName": "str", - "name": "str", - "type": "AzureSearch", - "version": "str", - "description": "str", - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": - index = { - "connectionName": "str", - "containerName": "str", - "databaseName": "str", - "embeddingConfiguration": { - "embeddingField": "str", - "modelDeploymentName": "str" - }, - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "name": "str", - "type": "CosmosDBNoSqlVectorStore", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "ManagedAzureSearch": - index = { - "name": "str", - "type": "ManagedAzureSearch", - "vectorStoreId": "str", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template you can fill out and use as your body input. - index = index - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AzureSearch": - index = { - "connectionName": "str", - "indexName": "str", - "name": "str", - "type": "AzureSearch", - "version": "str", - "description": "str", - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": - index = { - "connectionName": "str", - "containerName": "str", - "databaseName": "str", - "embeddingConfiguration": { - "embeddingField": "str", - "modelDeploymentName": "str" - }, - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "name": "str", - "type": "CosmosDBNoSqlVectorStore", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "ManagedAzureSearch": - index = { - "name": "str", - "type": "ManagedAzureSearch", - "vectorStoreId": "str", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AzureSearch": - index = { - "connectionName": "str", - "indexName": "str", - "name": "str", - "type": "AzureSearch", - "version": "str", - "description": "str", - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "CosmosDBNoSqlVectorStore": - index = { - "connectionName": "str", - "containerName": "str", - "databaseName": "str", - "embeddingConfiguration": { - "embeddingField": "str", - "modelDeploymentName": "str" - }, - "fieldMapping": { - "contentFields": [ - "str" - ], - "filepathField": "str", - "metadataFields": [ - "str" - ], - "titleField": "str", - "urlField": "str", - "vectorFields": [ - "str" - ] - }, - "name": "str", - "type": "CosmosDBNoSqlVectorStore", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # JSON input template for discriminator value "ManagedAzureSearch": - index = { - "name": "str", - "type": "ManagedAzureSearch", - "vectorStoreId": "str", - "version": "str", - "description": "str", - "id": "str", - "tags": { - "str": "str" - } - } - - # response body for status code(s): 201, 200 - response == index + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword agent_id: The ID of the agent that should run the thread. Required. + :paramtype agent_id: str + :keyword 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. Default value is None. + :paramtype include: list[str or ~azure.ai.agents.models.RunAdditionalFieldList] + :keyword model: The overridden model name that the agent should use to run the thread. Default + value is None. + :paramtype model: str + :keyword instructions: The overridden system instructions that the agent should use to run the + thread. Default value is None. + :paramtype instructions: str + :keyword additional_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. Default value is None. + :paramtype additional_instructions: str + :keyword additional_messages: Adds additional messages to the thread before creating the run. + Default value is None. + :paramtype additional_messages: list[~azure.ai.agents.models.ThreadMessageOptions] + :keyword tools: The overridden list of enabled tools that the agent should use to run the + thread. Default value is None. + :paramtype tools: list[~azure.ai.agents.models.ToolDefinition] + :keyword tool_resources: The overridden enabled tool resources that the agent should use to run + the thread. Default value is None. + :paramtype tool_resources: ~azure.ai.agents.models.ToolResources + :keyword stream_parameter: 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. Default + value is None. + :paramtype stream_parameter: bool + :keyword temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 + will make the output + more random, while lower values like 0.2 will make it more focused and deterministic. Default + value is None. + :paramtype temperature: float + :keyword top_p: An alternative to sampling with temperature, called nucleus sampling, where the + model + considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens + comprising the top 10% probability mass are considered. + + We generally recommend altering this or temperature but not both. Default value is None. + :paramtype top_p: float + :keyword max_prompt_tokens: 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. Default + value is None. + :paramtype max_prompt_tokens: int + :keyword max_completion_tokens: 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. Default value is None. + :paramtype max_completion_tokens: int + :keyword truncation_strategy: The strategy to use for dropping messages as the context windows + moves forward. Default value is None. + :paramtype truncation_strategy: ~azure.ai.agents.models.TruncationObject + :keyword tool_choice: Controls whether or not and which tool is called by the model. Is one of + the following types: str, Union[str, "_models.AgentsToolChoiceOptionMode"], + AgentsNamedToolChoice Default value is None. + :paramtype tool_choice: str or str or ~azure.ai.agents.models.AgentsToolChoiceOptionMode or + ~azure.ai.agents.models.AgentsNamedToolChoice + :keyword response_format: Specifies the format that the model must output. Is one of the + following types: str, Union[str, "_models.AgentsResponseFormatMode"], AgentsResponseFormat, + ResponseFormatJsonSchemaType Default value is None. + :paramtype response_format: str or str or ~azure.ai.agents.models.AgentsResponseFormatMode or + ~azure.ai.agents.models.AgentsResponseFormat or + ~azure.ai.agents.models.ResponseFormatJsonSchemaType + :keyword parallel_tool_calls: If ``true`` functions will run in parallel during tool use. + Default value is None. + :paramtype parallel_tool_calls: bool + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: ThreadRun. The ThreadRun is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadRun + :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -9153,22 +2686,43 @@ def create_or_update( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models1.Index] = kwargs.pop("cls", None) + cls: ClsType[_models.ThreadRun] = kwargs.pop("cls", None) - content_type = content_type or "application/merge-patch+json" - _json = None + if body is _Unset: + if agent_id is _Unset: + raise TypeError("missing required argument: agent_id") + body = { + "additional_instructions": additional_instructions, + "additional_messages": additional_messages, + "assistant_id": agent_id, + "instructions": instructions, + "max_completion_tokens": max_completion_tokens, + "max_prompt_tokens": max_prompt_tokens, + "metadata": metadata, + "model": model, + "parallel_tool_calls": parallel_tool_calls, + "response_format": response_format, + "stream": stream_parameter, + "temperature": temperature, + "tool_choice": tool_choice, + "tool_resources": tool_resources, + "tools": tools, + "top_p": top_p, + "truncation_strategy": truncation_strategy, + } + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" _content = None - if isinstance(index, (IOBase, bytes)): - _content = index + if isinstance(body, (IOBase, bytes)): + _content = body else: - _json = index + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_indexes_create_or_update_request( - name=name, - version=version, + _request = build_runs_create_request( + thread_id=thread_id, + include=include, content_type=content_type, api_version=self._config.api_version, - json=_json, content=_content, headers=_headers, params=_params, @@ -9178,7 +2732,6 @@ def create_or_update( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -9186,43 +2739,60 @@ def create_or_update( response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200]: if _stream: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.ThreadRun, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - -class _AIProjectClientOperationsMixin( - ClientMixinABC[PipelineClient[HttpRequest, HttpResponse], AIProjectClientConfiguration] -): - @distributed_trace - def delete_job(self, job_id: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements - """Delete a job. Returns 204 No Content. + def list( + self, + thread_id: str, + *, + limit: Optional[int] = None, + order: Optional[Union[str, _models.ListSortOrder]] = None, + before: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.ThreadRun"]: + """Gets a list of runs for a specified thread. - :param job_id: The ID of the job to delete. Required. - :type job_id: str - :return: None - :rtype: None + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and + 100, and the default is 20. Default value is None. + :paramtype limit: int + :keyword order: Sort order by the created_at timestamp of the objects. asc for ascending order + and desc for descending order. Known values are: "asc" and "desc". Default value is None. + :paramtype order: str or ~azure.ai.agents.models.ListSortOrder + :keyword 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. Default value is None. + :paramtype before: str + :return: An iterator like instance of ThreadRun + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.models.ThreadRun] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ThreadRun]] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -9231,149 +2801,60 @@ def delete_job(self, job_id: str, **kwargs: Any) -> None: # pylint: disable=inc } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) + def prepare_request(_continuation_token=None): - _request = build_ai_project_delete_job_request( - job_id=job_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + _request = build_runs_list_request( + thread_id=thread_id, + limit=limit, + order=order, + after=_continuation_token, + before=before, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.ThreadRun], deserialized.get("data", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("last_id") or None, iter(list_of_elem) - response = pipeline_response.http_response + def get_next(_continuation_token=None): + _request = prepare_request(_continuation_token) - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models1.ApiErrorResponse, - pipeline_response, + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - + response = pipeline_response.http_response -class BetaEvaluationTaxonomiesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) - Instead, you should access the following operations through - :class:`~azure.ai.agents.AIProjectClient`'s - :attr:`evaluation_taxonomies` attribute. - """ + return pipeline_response - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + return ItemPaged(get_next, extract_data) @distributed_trace - def get( - self, name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], **kwargs: Any - ) -> _types_models1.EvaluationTaxonomy: - """Get an evaluation run by name. - - :param name: The name of the resource. Required. - :type name: str - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW - :return: EvaluationTaxonomy - :rtype: ~azure.ai.agents.types.EvaluationTaxonomy - :raises ~azure.core.exceptions.HttpResponseError: + def get(self, thread_id: str, run_id: str, **kwargs: Any) -> _models.ThreadRun: + """Gets an existing run from an existing thread. - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "agent": - evaluation_taxonomy_input = { - "riskCategories": [ - "str" - ], - "target": target, - "type": "agent" - } - - # JSON input template for discriminator value "azure_ai_agent": - target = { - "name": "str", - "type": "azure_ai_agent", - "tool_descriptions": [ - { - "description": "str", - "name": "str" - } - ], - "version": "str" - } - - # JSON input template for discriminator value "azure_ai_model": - target = { - "type": "azure_ai_model", - "model": "str", - "sampling_params": { - "max_completion_tokens": 0, - "seed": 0, - "temperature": 0.0, - "top_p": 0.0 - } - } - - # response body for status code(s): 200 - response == { - "name": "str", - "taxonomyInput": evaluation_taxonomy_input, - "version": "str", - "description": "str", - "id": "str", - "properties": { - "str": "str" - }, - "tags": { - "str": "str" - }, - "taxonomyCategories": [ - { - "id": "str", - "name": "str", - "riskCategory": "str", - "subCategories": [ - { - "enabled": bool, - "id": "str", - "name": "str", - "description": "str", - "properties": { - "str": "str" - } - } - ], - "description": "str", - "properties": { - "str": "str" - } - } - ] - } + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param run_id: Identifier of the run. Required. + :type run_id: str + :return: ThreadRun. The ThreadRun is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadRun + :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -9386,11 +2867,11 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_types_models1.EvaluationTaxonomy] = kwargs.pop("cls", None) + cls: ClsType[_models.ThreadRun] = kwargs.pop("cls", None) - _request = build_beta_evaluation_taxonomies_get_request( - name=name, - foundry_features=foundry_features, + _request = build_runs_get_request( + thread_id=thread_id, + run_id=run_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -9400,7 +2881,6 @@ def get( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -9415,213 +2895,113 @@ def get( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.ThreadRun, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def list( + @overload + def update( self, + thread_id: str, + run_id: str, *, - foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], - input_name: Optional[str] = None, - input_type: Optional[str] = None, + content_type: str = "application/json", + metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> ItemPaged["_types_models1.EvaluationTaxonomy"]: - """List evaluation taxonomies. - - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW - :keyword input_name: Filter by the evaluation input name. Default value is None. - :paramtype input_name: str - :keyword input_type: Filter by taxonomy input type. Default value is None. - :paramtype input_type: str - :return: An iterator like instance of EvaluationTaxonomy - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.types.EvaluationTaxonomy] - :raises ~azure.core.exceptions.HttpResponseError: + ) -> _models.ThreadRun: + """Modifies an existing thread run. - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "agent": - evaluation_taxonomy_input = { - "riskCategories": [ - "str" - ], - "target": target, - "type": "agent" - } - - # JSON input template for discriminator value "azure_ai_agent": - target = { - "name": "str", - "type": "azure_ai_agent", - "tool_descriptions": [ - { - "description": "str", - "name": "str" - } - ], - "version": "str" - } - - # JSON input template for discriminator value "azure_ai_model": - target = { - "type": "azure_ai_model", - "model": "str", - "sampling_params": { - "max_completion_tokens": 0, - "seed": 0, - "temperature": 0.0, - "top_p": 0.0 - } - } - - # response body for status code(s): 200 - response == { - "name": "str", - "taxonomyInput": evaluation_taxonomy_input, - "version": "str", - "description": "str", - "id": "str", - "properties": { - "str": "str" - }, - "tags": { - "str": "str" - }, - "taxonomyCategories": [ - { - "id": "str", - "name": "str", - "riskCategory": "str", - "subCategories": [ - { - "enabled": bool, - "id": "str", - "name": "str", - "description": "str", - "properties": { - "str": "str" - } - } - ], - "description": "str", - "properties": { - "str": "str" - } - } - ] - } + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param run_id: Identifier of the run. Required. + :type run_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: ThreadRun. The ThreadRun is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadRun + :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_types_models1.EvaluationTaxonomy]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_beta_evaluation_taxonomies_list_request( - foundry_features=foundry_features, - input_name=input_name, - input_type=input_type, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized.get("value", []) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + @overload + def update( + self, thread_id: str, run_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ThreadRun: + """Modifies an existing thread run. - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param run_id: Identifier of the run. Required. + :type run_id: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ThreadRun. The ThreadRun is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadRun + :raises ~azure.core.exceptions.HttpResponseError: + """ - return pipeline_response + @overload + def update( + self, thread_id: str, run_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ThreadRun: + """Modifies an existing thread run. - return ItemPaged(get_next, extract_data) + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param run_id: Identifier of the run. Required. + :type run_id: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ThreadRun. The ThreadRun is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadRun + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], **kwargs: Any - ) -> None: - """Delete an evaluation taxonomy by name. - - :param name: The name of the resource. Required. - :type name: str - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW - :return: None - :rtype: None + def update( + self, + thread_id: str, + run_id: str, + body: Union[JSON, IO[bytes]] = _Unset, + *, + metadata: Optional[dict[str, str]] = None, + **kwargs: Any + ) -> _models.ThreadRun: + """Modifies an existing thread run. + + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param run_id: Identifier of the run. Required. + :type run_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: ThreadRun. The ThreadRun is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadRun :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -9632,15 +3012,28 @@ def delete( # pylint: disable=inconsistent-return-statements } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[None] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ThreadRun] = kwargs.pop("cls", None) + + if body is _Unset: + body = {"metadata": metadata} + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_beta_evaluation_taxonomies_delete_request( - name=name, - foundry_features=foundry_features, + _request = build_runs_update_request( + thread_id=thread_id, + run_id=run_id, + content_type=content_type, api_version=self._config.api_version, + content=_content, headers=_headers, params=_params, ) @@ -9649,586 +3042,140 @@ def delete( # pylint: disable=inconsistent-return-statements } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [204]: + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.ThreadRun, response.json()) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @overload - def create( + def submit_tool_outputs( self, - name: str, - body: _types_models1.EvaluationTaxonomy, + thread_id: str, + run_id: str, *, - foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], content_type: str = "application/json", + tool_outputs: Optional[List[_models.StructuredToolOutput]] = None, + tool_approvals: Optional[List[_models.ToolApproval]] = None, + stream_parameter: Optional[bool] = None, **kwargs: Any - ) -> _types_models1.EvaluationTaxonomy: - """Create an evaluation taxonomy. - - :param name: The name of the evaluation taxonomy. Required. - :type name: str - :param body: The evaluation taxonomy. Required. - :type body: ~azure.ai.agents.types.EvaluationTaxonomy - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW + ) -> _models.ThreadRun: + """Submits outputs from tools as requested by tool calls in a run. + + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param run_id: Identifier of the run. Required. + :type run_id: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: EvaluationTaxonomy - :rtype: ~azure.ai.agents.types.EvaluationTaxonomy + :keyword tool_outputs: A list of tools for which the outputs are being submitted. Default value + is None. + :paramtype tool_outputs: list[~azure.ai.agents.models.StructuredToolOutput] + :keyword tool_approvals: A list of tool approvals allowing data to be sent to tools. Default + value is None. + :paramtype tool_approvals: list[~azure.ai.agents.models.ToolApproval] + :keyword stream_parameter: If true, returns a stream of events that happen during the Run as + SSE, terminating at ``[DONE]``. Default value is None. + :paramtype stream_parameter: bool + :return: ThreadRun. The ThreadRun is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadRun :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "type": - - # JSON input template for discriminator value "agent": - evaluation_taxonomy_input = { - "riskCategories": [ - "str" - ], - "target": target, - "type": "agent" - } - - # JSON input template for discriminator value "azure_ai_agent": - target = { - "name": "str", - "type": "azure_ai_agent", - "tool_descriptions": [ - { - "description": "str", - "name": "str" - } - ], - "version": "str" - } - - # JSON input template for discriminator value "azure_ai_model": - target = { - "type": "azure_ai_model", - "model": "str", - "sampling_params": { - "max_completion_tokens": 0, - "seed": 0, - "temperature": 0.0, - "top_p": 0.0 - } - } - - # JSON input template you can fill out and use as your body input. - body = { - "name": "str", - "taxonomyInput": evaluation_taxonomy_input, - "version": "str", - "description": "str", - "id": "str", - "properties": { - "str": "str" - }, - "tags": { - "str": "str" - }, - "taxonomyCategories": [ - { - "id": "str", - "name": "str", - "riskCategory": "str", - "subCategories": [ - { - "enabled": bool, - "id": "str", - "name": "str", - "description": "str", - "properties": { - "str": "str" - } - } - ], - "description": "str", - "properties": { - "str": "str" - } - } - ] - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "agent": - evaluation_taxonomy_input = { - "riskCategories": [ - "str" - ], - "target": target, - "type": "agent" - } - - # JSON input template for discriminator value "azure_ai_agent": - target = { - "name": "str", - "type": "azure_ai_agent", - "tool_descriptions": [ - { - "description": "str", - "name": "str" - } - ], - "version": "str" - } - - # JSON input template for discriminator value "azure_ai_model": - target = { - "type": "azure_ai_model", - "model": "str", - "sampling_params": { - "max_completion_tokens": 0, - "seed": 0, - "temperature": 0.0, - "top_p": 0.0 - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "agent": - evaluation_taxonomy_input = { - "riskCategories": [ - "str" - ], - "target": target, - "type": "agent" - } - - # JSON input template for discriminator value "azure_ai_agent": - target = { - "name": "str", - "type": "azure_ai_agent", - "tool_descriptions": [ - { - "description": "str", - "name": "str" - } - ], - "version": "str" - } - - # JSON input template for discriminator value "azure_ai_model": - target = { - "type": "azure_ai_model", - "model": "str", - "sampling_params": { - "max_completion_tokens": 0, - "seed": 0, - "temperature": 0.0, - "top_p": 0.0 - } - } - - # response body for status code(s): 201, 200 - response == { - "name": "str", - "taxonomyInput": evaluation_taxonomy_input, - "version": "str", - "description": "str", - "id": "str", - "properties": { - "str": "str" - }, - "tags": { - "str": "str" - }, - "taxonomyCategories": [ - { - "id": "str", - "name": "str", - "riskCategory": "str", - "subCategories": [ - { - "enabled": bool, - "id": "str", - "name": "str", - "description": "str", - "properties": { - "str": "str" - } - } - ], - "description": "str", - "properties": { - "str": "str" - } - } - ] - } """ @overload - def create( - self, - name: str, - body: IO[bytes], - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models1.EvaluationTaxonomy: - """Create an evaluation taxonomy. + def submit_tool_outputs( + self, thread_id: str, run_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ThreadRun: + """Submits outputs from tools as requested by tool calls in a run. + + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param run_id: Identifier of the run. Required. + :type run_id: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ThreadRun. The ThreadRun is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadRun + :raises ~azure.core.exceptions.HttpResponseError: + """ - :param name: The name of the evaluation taxonomy. Required. - :type name: str - :param body: The evaluation taxonomy. Required. + @overload + def submit_tool_outputs( + self, thread_id: str, run_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ThreadRun: + """Submits outputs from tools as requested by tool calls in a run. + + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param run_id: Identifier of the run. Required. + :type run_id: str + :param body: Required. :type body: IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: EvaluationTaxonomy - :rtype: ~azure.ai.agents.types.EvaluationTaxonomy + :return: ThreadRun. The ThreadRun is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadRun :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "agent": - evaluation_taxonomy_input = { - "riskCategories": [ - "str" - ], - "target": target, - "type": "agent" - } - - # JSON input template for discriminator value "azure_ai_agent": - target = { - "name": "str", - "type": "azure_ai_agent", - "tool_descriptions": [ - { - "description": "str", - "name": "str" - } - ], - "version": "str" - } - - # JSON input template for discriminator value "azure_ai_model": - target = { - "type": "azure_ai_model", - "model": "str", - "sampling_params": { - "max_completion_tokens": 0, - "seed": 0, - "temperature": 0.0, - "top_p": 0.0 - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "agent": - evaluation_taxonomy_input = { - "riskCategories": [ - "str" - ], - "target": target, - "type": "agent" - } - - # JSON input template for discriminator value "azure_ai_agent": - target = { - "name": "str", - "type": "azure_ai_agent", - "tool_descriptions": [ - { - "description": "str", - "name": "str" - } - ], - "version": "str" - } - - # JSON input template for discriminator value "azure_ai_model": - target = { - "type": "azure_ai_model", - "model": "str", - "sampling_params": { - "max_completion_tokens": 0, - "seed": 0, - "temperature": 0.0, - "top_p": 0.0 - } - } - - # response body for status code(s): 201, 200 - response == { - "name": "str", - "taxonomyInput": evaluation_taxonomy_input, - "version": "str", - "description": "str", - "id": "str", - "properties": { - "str": "str" - }, - "tags": { - "str": "str" - }, - "taxonomyCategories": [ - { - "id": "str", - "name": "str", - "riskCategory": "str", - "subCategories": [ - { - "enabled": bool, - "id": "str", - "name": "str", - "description": "str", - "properties": { - "str": "str" - } - } - ], - "description": "str", - "properties": { - "str": "str" - } - } - ] - } """ @distributed_trace - def create( + def submit_tool_outputs( self, - name: str, - body: Union[_types_models1.EvaluationTaxonomy, IO[bytes]], + thread_id: str, + run_id: str, + body: Union[JSON, IO[bytes]] = _Unset, *, - foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + tool_outputs: Optional[List[_models.StructuredToolOutput]] = None, + tool_approvals: Optional[List[_models.ToolApproval]] = None, + stream_parameter: Optional[bool] = None, **kwargs: Any - ) -> _types_models1.EvaluationTaxonomy: - """Create an evaluation taxonomy. + ) -> _models.ThreadRun: + """Submits outputs from tools as requested by tool calls in a run. - :param name: The name of the evaluation taxonomy. Required. - :type name: str - :param body: The evaluation taxonomy. Is either a EvaluationTaxonomy type or a IO[bytes] type. - Required. - :type body: ~azure.ai.agents.types.EvaluationTaxonomy or IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW - :return: EvaluationTaxonomy - :rtype: ~azure.ai.agents.types.EvaluationTaxonomy + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param run_id: Identifier of the run. Required. + :type run_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword tool_outputs: A list of tools for which the outputs are being submitted. Default value + is None. + :paramtype tool_outputs: list[~azure.ai.agents.models.StructuredToolOutput] + :keyword tool_approvals: A list of tool approvals allowing data to be sent to tools. Default + value is None. + :paramtype tool_approvals: list[~azure.ai.agents.models.ToolApproval] + :keyword stream_parameter: If true, returns a stream of events that happen during the Run as + SSE, terminating at ``[DONE]``. Default value is None. + :paramtype stream_parameter: bool + :return: ThreadRun. The ThreadRun is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadRun :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "type": - - # JSON input template for discriminator value "agent": - evaluation_taxonomy_input = { - "riskCategories": [ - "str" - ], - "target": target, - "type": "agent" - } - - # JSON input template for discriminator value "azure_ai_agent": - target = { - "name": "str", - "type": "azure_ai_agent", - "tool_descriptions": [ - { - "description": "str", - "name": "str" - } - ], - "version": "str" - } - - # JSON input template for discriminator value "azure_ai_model": - target = { - "type": "azure_ai_model", - "model": "str", - "sampling_params": { - "max_completion_tokens": 0, - "seed": 0, - "temperature": 0.0, - "top_p": 0.0 - } - } - - # JSON input template you can fill out and use as your body input. - body = { - "name": "str", - "taxonomyInput": evaluation_taxonomy_input, - "version": "str", - "description": "str", - "id": "str", - "properties": { - "str": "str" - }, - "tags": { - "str": "str" - }, - "taxonomyCategories": [ - { - "id": "str", - "name": "str", - "riskCategory": "str", - "subCategories": [ - { - "enabled": bool, - "id": "str", - "name": "str", - "description": "str", - "properties": { - "str": "str" - } - } - ], - "description": "str", - "properties": { - "str": "str" - } - } - ] - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "agent": - evaluation_taxonomy_input = { - "riskCategories": [ - "str" - ], - "target": target, - "type": "agent" - } - - # JSON input template for discriminator value "azure_ai_agent": - target = { - "name": "str", - "type": "azure_ai_agent", - "tool_descriptions": [ - { - "description": "str", - "name": "str" - } - ], - "version": "str" - } - - # JSON input template for discriminator value "azure_ai_model": - target = { - "type": "azure_ai_model", - "model": "str", - "sampling_params": { - "max_completion_tokens": 0, - "seed": 0, - "temperature": 0.0, - "top_p": 0.0 - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "agent": - evaluation_taxonomy_input = { - "riskCategories": [ - "str" - ], - "target": target, - "type": "agent" - } - - # JSON input template for discriminator value "azure_ai_agent": - target = { - "name": "str", - "type": "azure_ai_agent", - "tool_descriptions": [ - { - "description": "str", - "name": "str" - } - ], - "version": "str" - } - - # JSON input template for discriminator value "azure_ai_model": - target = { - "type": "azure_ai_model", - "model": "str", - "sampling_params": { - "max_completion_tokens": 0, - "seed": 0, - "temperature": 0.0, - "top_p": 0.0 - } - } - - # response body for status code(s): 201, 200 - response == { - "name": "str", - "taxonomyInput": evaluation_taxonomy_input, - "version": "str", - "description": "str", - "id": "str", - "properties": { - "str": "str" - }, - "tags": { - "str": "str" - }, - "taxonomyCategories": [ - { - "id": "str", - "name": "str", - "riskCategory": "str", - "subCategories": [ - { - "enabled": bool, - "id": "str", - "name": "str", - "description": "str", - "properties": { - "str": "str" - } - } - ], - "description": "str", - "properties": { - "str": "str" - } - } - ] - } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -10242,22 +3189,23 @@ def create( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models1.EvaluationTaxonomy] = kwargs.pop("cls", None) + cls: ClsType[_models.ThreadRun] = kwargs.pop("cls", None) + if body is _Unset: + body = {"stream": stream_parameter, "tool_approvals": tool_approvals, "tool_outputs": tool_outputs} + body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" - _json = None _content = None if isinstance(body, (IOBase, bytes)): _content = body else: - _json = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_beta_evaluation_taxonomies_create_request( - name=name, - foundry_features=foundry_features, + _request = build_runs_submit_tool_outputs_request( + thread_id=thread_id, + run_id=run_id, content_type=content_type, api_version=self._config.api_version, - json=_json, content=_content, headers=_headers, params=_params, @@ -10267,7 +3215,6 @@ def create( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -10275,483 +3222,37 @@ def create( response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200]: if _stream: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.ThreadRun, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - def update( - self, - name: str, - body: _types_models1.EvaluationTaxonomy, - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models1.EvaluationTaxonomy: - """Update an evaluation taxonomy. - - :param name: The name of the evaluation taxonomy. Required. - :type name: str - :param body: The evaluation taxonomy. Required. - :type body: ~azure.ai.agents.types.EvaluationTaxonomy - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: EvaluationTaxonomy - :rtype: ~azure.ai.agents.types.EvaluationTaxonomy - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "type": - - # JSON input template for discriminator value "agent": - evaluation_taxonomy_input = { - "riskCategories": [ - "str" - ], - "target": target, - "type": "agent" - } - - # JSON input template for discriminator value "azure_ai_agent": - target = { - "name": "str", - "type": "azure_ai_agent", - "tool_descriptions": [ - { - "description": "str", - "name": "str" - } - ], - "version": "str" - } - - # JSON input template for discriminator value "azure_ai_model": - target = { - "type": "azure_ai_model", - "model": "str", - "sampling_params": { - "max_completion_tokens": 0, - "seed": 0, - "temperature": 0.0, - "top_p": 0.0 - } - } - - # JSON input template you can fill out and use as your body input. - body = { - "name": "str", - "taxonomyInput": evaluation_taxonomy_input, - "version": "str", - "description": "str", - "id": "str", - "properties": { - "str": "str" - }, - "tags": { - "str": "str" - }, - "taxonomyCategories": [ - { - "id": "str", - "name": "str", - "riskCategory": "str", - "subCategories": [ - { - "enabled": bool, - "id": "str", - "name": "str", - "description": "str", - "properties": { - "str": "str" - } - } - ], - "description": "str", - "properties": { - "str": "str" - } - } - ] - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "agent": - evaluation_taxonomy_input = { - "riskCategories": [ - "str" - ], - "target": target, - "type": "agent" - } - - # JSON input template for discriminator value "azure_ai_agent": - target = { - "name": "str", - "type": "azure_ai_agent", - "tool_descriptions": [ - { - "description": "str", - "name": "str" - } - ], - "version": "str" - } - - # JSON input template for discriminator value "azure_ai_model": - target = { - "type": "azure_ai_model", - "model": "str", - "sampling_params": { - "max_completion_tokens": 0, - "seed": 0, - "temperature": 0.0, - "top_p": 0.0 - } - } - - # response body for status code(s): 200 - response == { - "name": "str", - "taxonomyInput": evaluation_taxonomy_input, - "version": "str", - "description": "str", - "id": "str", - "properties": { - "str": "str" - }, - "tags": { - "str": "str" - }, - "taxonomyCategories": [ - { - "id": "str", - "name": "str", - "riskCategory": "str", - "subCategories": [ - { - "enabled": bool, - "id": "str", - "name": "str", - "description": "str", - "properties": { - "str": "str" - } - } - ], - "description": "str", - "properties": { - "str": "str" - } - } - ] - } - """ - - @overload - def update( - self, - name: str, - body: IO[bytes], - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models1.EvaluationTaxonomy: - """Update an evaluation taxonomy. - - :param name: The name of the evaluation taxonomy. Required. - :type name: str - :param body: The evaluation taxonomy. Required. - :type body: IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: EvaluationTaxonomy - :rtype: ~azure.ai.agents.types.EvaluationTaxonomy - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "agent": - evaluation_taxonomy_input = { - "riskCategories": [ - "str" - ], - "target": target, - "type": "agent" - } - - # JSON input template for discriminator value "azure_ai_agent": - target = { - "name": "str", - "type": "azure_ai_agent", - "tool_descriptions": [ - { - "description": "str", - "name": "str" - } - ], - "version": "str" - } - - # JSON input template for discriminator value "azure_ai_model": - target = { - "type": "azure_ai_model", - "model": "str", - "sampling_params": { - "max_completion_tokens": 0, - "seed": 0, - "temperature": 0.0, - "top_p": 0.0 - } - } - - # response body for status code(s): 200 - response == { - "name": "str", - "taxonomyInput": evaluation_taxonomy_input, - "version": "str", - "description": "str", - "id": "str", - "properties": { - "str": "str" - }, - "tags": { - "str": "str" - }, - "taxonomyCategories": [ - { - "id": "str", - "name": "str", - "riskCategory": "str", - "subCategories": [ - { - "enabled": bool, - "id": "str", - "name": "str", - "description": "str", - "properties": { - "str": "str" - } - } - ], - "description": "str", - "properties": { - "str": "str" - } - } - ] - } - """ - @distributed_trace - def update( - self, - name: str, - body: Union[_types_models1.EvaluationTaxonomy, IO[bytes]], - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], - **kwargs: Any - ) -> _types_models1.EvaluationTaxonomy: - """Update an evaluation taxonomy. + def cancel(self, thread_id: str, run_id: str, **kwargs: Any) -> _models.ThreadRun: + """Cancels a run of an in‐progress thread. - :param name: The name of the evaluation taxonomy. Required. - :type name: str - :param body: The evaluation taxonomy. Is either a EvaluationTaxonomy type or a IO[bytes] type. - Required. - :type body: ~azure.ai.agents.types.EvaluationTaxonomy or IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW - :return: EvaluationTaxonomy - :rtype: ~azure.ai.agents.types.EvaluationTaxonomy + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param run_id: Identifier of the run. Required. + :type run_id: str + :return: ThreadRun. The ThreadRun is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadRun :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "type": - - # JSON input template for discriminator value "agent": - evaluation_taxonomy_input = { - "riskCategories": [ - "str" - ], - "target": target, - "type": "agent" - } - - # JSON input template for discriminator value "azure_ai_agent": - target = { - "name": "str", - "type": "azure_ai_agent", - "tool_descriptions": [ - { - "description": "str", - "name": "str" - } - ], - "version": "str" - } - - # JSON input template for discriminator value "azure_ai_model": - target = { - "type": "azure_ai_model", - "model": "str", - "sampling_params": { - "max_completion_tokens": 0, - "seed": 0, - "temperature": 0.0, - "top_p": 0.0 - } - } - - # JSON input template you can fill out and use as your body input. - body = { - "name": "str", - "taxonomyInput": evaluation_taxonomy_input, - "version": "str", - "description": "str", - "id": "str", - "properties": { - "str": "str" - }, - "tags": { - "str": "str" - }, - "taxonomyCategories": [ - { - "id": "str", - "name": "str", - "riskCategory": "str", - "subCategories": [ - { - "enabled": bool, - "id": "str", - "name": "str", - "description": "str", - "properties": { - "str": "str" - } - } - ], - "description": "str", - "properties": { - "str": "str" - } - } - ] - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "agent": - evaluation_taxonomy_input = { - "riskCategories": [ - "str" - ], - "target": target, - "type": "agent" - } - - # JSON input template for discriminator value "azure_ai_agent": - target = { - "name": "str", - "type": "azure_ai_agent", - "tool_descriptions": [ - { - "description": "str", - "name": "str" - } - ], - "version": "str" - } - - # JSON input template for discriminator value "azure_ai_model": - target = { - "type": "azure_ai_model", - "model": "str", - "sampling_params": { - "max_completion_tokens": 0, - "seed": 0, - "temperature": 0.0, - "top_p": 0.0 - } - } - - # response body for status code(s): 200 - response == { - "name": "str", - "taxonomyInput": evaluation_taxonomy_input, - "version": "str", - "description": "str", - "id": "str", - "properties": { - "str": "str" - }, - "tags": { - "str": "str" - }, - "taxonomyCategories": [ - { - "id": "str", - "name": "str", - "riskCategory": "str", - "subCategories": [ - { - "enabled": bool, - "id": "str", - "name": "str", - "description": "str", - "properties": { - "str": "str" - } - } - ], - "description": "str", - "properties": { - "str": "str" - } - } - ] - } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -10761,27 +3262,15 @@ def update( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models1.EvaluationTaxonomy] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _json = body + cls: ClsType[_models.ThreadRun] = kwargs.pop("cls", None) - _request = build_beta_evaluation_taxonomies_update_request( - name=name, - foundry_features=foundry_features, - content_type=content_type, + _request = build_runs_cancel_request( + thread_id=thread_id, + run_id=run_id, api_version=self._config.api_version, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -10790,7 +3279,6 @@ def update( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -10805,15 +3293,13 @@ def update( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.ThreadRun, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -10821,127 +3307,50 @@ def update( return deserialized # type: ignore -class BetaEvaluatorsOperations: +class RunStepsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.ai.agents.AIProjectClient`'s - :attr:`evaluators` attribute. + :class:`~azure.ai.agents.AgentsClient`'s + :attr:`run_steps` attribute. """ def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._config: AgentsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_versions( + def get( self, - name: str, + thread_id: str, + run_id: str, + step_id: str, *, - foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], - type: Optional[Union[Literal["builtin"], Literal["custom"], Literal["all"], str]] = None, - limit: Optional[int] = None, + include: Optional[List[Union[str, _models.RunAdditionalFieldList]]] = None, **kwargs: Any - ) -> ItemPaged["_types_models1.EvaluatorVersion"]: - """List all versions of the given evaluator. - - :param name: The name of the resource. Required. - :type name: str - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW - :keyword type: Filter evaluators by type. Possible values: 'all', 'custom', 'builtin'. Is one - of the following types: Literal["builtin"], Literal["custom"], Literal["all"], str Default - value is None. - :paramtype type: str or str or str or str - :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and - 100, and the default is 20. Default value is None. - :paramtype limit: int - :return: An iterator like instance of EvaluatorVersion - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.types.EvaluatorVersion] - :raises ~azure.core.exceptions.HttpResponseError: + ) -> _models.RunStep: + """Retrieves a single run step from a thread run. - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "code": - evaluator_definition = { - "code_text": "str", - "type": "code", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # JSON input template for discriminator value "prompt": - evaluator_definition = { - "prompt_text": "str", - "type": "prompt", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # response body for status code(s): 200 - response == { - "categories": [ - "str" - ], - "created_at": "2020-02-20 00:00:00", - "created_by": "str", - "definition": evaluator_definition, - "evaluator_type": "str", - "modified_at": "2020-02-20 00:00:00", - "name": "str", - "version": "str", - "description": "str", - "display_name": "str", - "id": "str", - "metadata": { - "str": "str" - }, - "tags": { - "str": "str" - } - } + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param run_id: Identifier of the run. Required. + :type run_id: str + :param step_id: Identifier of the run step. Required. + :type step_id: str + :keyword 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. Default value is None. + :paramtype include: list[str or ~azure.ai.agents.models.RunAdditionalFieldList] + :return: RunStep. The RunStep is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.RunStep + :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_types_models1.EvaluatorVersion]] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -10950,174 +3359,94 @@ def list_versions( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - _request = build_beta_evaluators_list_versions_request( - name=name, - foundry_features=foundry_features, - type=type, - limit=limit, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - return _request + cls: ClsType[_models.RunStep] = kwargs.pop("cls", None) - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized.get("value", []) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) + _request = build_run_steps_get_request( + thread_id=thread_id, + run_id=run_id, + step_id=step_id, + include=include, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - def get_next(next_link=None): - _request = prepare_request(next_link) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + response = pipeline_response.http_response - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) - return pipeline_response + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.RunStep, response.json()) - return ItemPaged(get_next, extract_data) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @distributed_trace def list( self, + thread_id: str, + run_id: str, *, - foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], - type: Optional[Union[Literal["builtin"], Literal["custom"], Literal["all"], str]] = None, + include: Optional[List[Union[str, _models.RunAdditionalFieldList]]] = None, limit: Optional[int] = None, + order: Optional[Union[str, _models.ListSortOrder]] = None, + before: Optional[str] = None, **kwargs: Any - ) -> ItemPaged["_types_models1.EvaluatorVersion"]: - """List the latest version of each evaluator. - - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW - :keyword type: Filter evaluators by type. Possible values: 'all', 'custom', 'builtin'. Is one - of the following types: Literal["builtin"], Literal["custom"], Literal["all"], str Default - value is None. - :paramtype type: str or str or str or str + ) -> ItemPaged["_models.RunStep"]: + """Gets a list of run steps from a thread run. + + :param thread_id: Identifier of the thread. Required. + :type thread_id: str + :param run_id: Identifier of the run. Required. + :type run_id: str + :keyword 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. Default value is None. + :paramtype include: list[str or ~azure.ai.agents.models.RunAdditionalFieldList] :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. Default value is None. :paramtype limit: int - :return: An iterator like instance of EvaluatorVersion - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.types.EvaluatorVersion] + :keyword order: Sort order by the created_at timestamp of the objects. asc for ascending order + and desc for descending order. Known values are: "asc" and "desc". Default value is None. + :paramtype order: str or ~azure.ai.agents.models.ListSortOrder + :keyword 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. Default value is None. + :paramtype before: str + :return: An iterator like instance of RunStep + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.models.RunStep] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "code": - evaluator_definition = { - "code_text": "str", - "type": "code", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # JSON input template for discriminator value "prompt": - evaluator_definition = { - "prompt_text": "str", - "type": "prompt", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # response body for status code(s): 200 - response == { - "categories": [ - "str" - ], - "created_at": "2020-02-20 00:00:00", - "created_by": "str", - "definition": evaluator_definition, - "evaluator_type": "str", - "modified_at": "2020-02-20 00:00:00", - "name": "str", - "version": "str", - "description": "str", - "display_name": "str", - "id": "str", - "metadata": { - "str": "str" - }, - "tags": { - "str": "str" - } - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_types_models1.EvaluatorVersion]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.RunStep]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -11127,58 +3456,35 @@ def list( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - _request = build_beta_evaluators_list_request( - foundry_features=foundry_features, - type=type, - limit=limit, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + def prepare_request(_continuation_token=None): + _request = build_run_steps_list_request( + thread_id=thread_id, + run_id=run_id, + include=include, + limit=limit, + order=order, + after=_continuation_token, + before=before, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) return _request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized.get("value", []) + list_of_elem = _deserialize(List[_models.RunStep], deserialized.get("data", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) + return deserialized.get("last_id") or None, iter(list_of_elem) - def get_next(next_link=None): - _request = prepare_request(next_link) + def get_next(_continuation_token=None): + _request = prepare_request(_continuation_token) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access @@ -11188,105 +3494,43 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) return pipeline_response return ItemPaged(get_next, extract_data) + +class FilesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.agents.AgentsClient`'s + :attr:`files` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AgentsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace - def get_version( - self, - name: str, - version: str, - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], - **kwargs: Any - ) -> _types_models1.EvaluatorVersion: - """Get the specific version of the EvaluatorVersion. The service returns 404 Not Found error if - the EvaluatorVersion does not exist. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the EvaluatorVersion to retrieve. Required. - :type version: str - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW - :return: EvaluatorVersion - :rtype: ~azure.ai.agents.types.EvaluatorVersion + def list( + self, *, purpose: Optional[Union[str, _models.FilePurpose]] = None, **kwargs: Any + ) -> _models.FileListResponse: + """Gets a list of previously uploaded files. + + :keyword purpose: The purpose of the file. Known values are: "assistants", "assistants_output", + and "vision". Default value is None. + :paramtype purpose: str or ~azure.ai.agents.models.FilePurpose + :return: FileListResponse. The FileListResponse is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.FileListResponse :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "code": - evaluator_definition = { - "code_text": "str", - "type": "code", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # JSON input template for discriminator value "prompt": - evaluator_definition = { - "prompt_text": "str", - "type": "prompt", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # response body for status code(s): 200 - response == { - "categories": [ - "str" - ], - "created_at": "2020-02-20 00:00:00", - "created_by": "str", - "definition": evaluator_definition, - "evaluator_type": "str", - "modified_at": "2020-02-20 00:00:00", - "name": "str", - "version": "str", - "description": "str", - "display_name": "str", - "id": "str", - "metadata": { - "str": "str" - }, - "tags": { - "str": "str" - } - } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -11299,12 +3543,10 @@ def get_version( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_types_models1.EvaluatorVersion] = kwargs.pop("cls", None) + cls: ClsType[_models.FileListResponse] = kwargs.pop("cls", None) - _request = build_beta_evaluators_get_version_request( - name=name, - version=version, - foundry_features=foundry_features, + _request = build_files_list_request( + purpose=purpose, api_version=self._config.api_version, headers=_headers, params=_params, @@ -11314,7 +3556,6 @@ def get_version( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -11329,508 +3570,33 @@ def get_version( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.FileListResponse, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def delete_version( # pylint: disable=inconsistent-return-statements - self, - name: str, - version: str, - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], - **kwargs: Any - ) -> None: - """Delete the specific version of the EvaluatorVersion. The service returns 204 No Content if the - EvaluatorVersion was deleted successfully or if the EvaluatorVersion does not exist. - - :param name: The name of the resource. Required. - :type name: str - :param version: The version of the EvaluatorVersion to delete. Required. - :type version: str - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_beta_evaluators_delete_version_request( - name=name, - version=version, - foundry_features=foundry_features, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - @overload - def create_version( - self, - name: str, - evaluator_version: _types_models1.EvaluatorVersion, - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models1.EvaluatorVersion: - """Create a new EvaluatorVersion with auto incremented version id. - - :param name: The name of the resource. Required. - :type name: str - :param evaluator_version: Required. - :type evaluator_version: ~azure.ai.agents.types.EvaluatorVersion - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: EvaluatorVersion - :rtype: ~azure.ai.agents.types.EvaluatorVersion - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "type": - - # JSON input template for discriminator value "code": - evaluator_definition = { - "code_text": "str", - "type": "code", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # JSON input template for discriminator value "prompt": - evaluator_definition = { - "prompt_text": "str", - "type": "prompt", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # JSON input template you can fill out and use as your body input. - evaluator_version = { - "categories": [ - "str" - ], - "created_at": "2020-02-20 00:00:00", - "created_by": "str", - "definition": evaluator_definition, - "evaluator_type": "str", - "modified_at": "2020-02-20 00:00:00", - "name": "str", - "version": "str", - "description": "str", - "display_name": "str", - "id": "str", - "metadata": { - "str": "str" - }, - "tags": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "code": - evaluator_definition = { - "code_text": "str", - "type": "code", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # JSON input template for discriminator value "prompt": - evaluator_definition = { - "prompt_text": "str", - "type": "prompt", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # response body for status code(s): 201 - response == { - "categories": [ - "str" - ], - "created_at": "2020-02-20 00:00:00", - "created_by": "str", - "definition": evaluator_definition, - "evaluator_type": "str", - "modified_at": "2020-02-20 00:00:00", - "name": "str", - "version": "str", - "description": "str", - "display_name": "str", - "id": "str", - "metadata": { - "str": "str" - }, - "tags": { - "str": "str" - } - } - """ - + def _upload_file(self, body: _models._models.UploadFileRequest, **kwargs: Any) -> _models.FileInfo: ... @overload - def create_version( - self, - name: str, - evaluator_version: IO[bytes], - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models1.EvaluatorVersion: - """Create a new EvaluatorVersion with auto incremented version id. - - :param name: The name of the resource. Required. - :type name: str - :param evaluator_version: Required. - :type evaluator_version: IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: EvaluatorVersion - :rtype: ~azure.ai.agents.types.EvaluatorVersion - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "code": - evaluator_definition = { - "code_text": "str", - "type": "code", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # JSON input template for discriminator value "prompt": - evaluator_definition = { - "prompt_text": "str", - "type": "prompt", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # response body for status code(s): 201 - response == { - "categories": [ - "str" - ], - "created_at": "2020-02-20 00:00:00", - "created_by": "str", - "definition": evaluator_definition, - "evaluator_type": "str", - "modified_at": "2020-02-20 00:00:00", - "name": "str", - "version": "str", - "description": "str", - "display_name": "str", - "id": "str", - "metadata": { - "str": "str" - }, - "tags": { - "str": "str" - } - } - """ + def _upload_file(self, body: JSON, **kwargs: Any) -> _models.FileInfo: ... @distributed_trace - def create_version( - self, - name: str, - evaluator_version: Union[_types_models1.EvaluatorVersion, IO[bytes]], - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], - **kwargs: Any - ) -> _types_models1.EvaluatorVersion: - """Create a new EvaluatorVersion with auto incremented version id. - - :param name: The name of the resource. Required. - :type name: str - :param evaluator_version: Is either a EvaluatorVersion type or a IO[bytes] type. Required. - :type evaluator_version: ~azure.ai.agents.types.EvaluatorVersion or IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW - :return: EvaluatorVersion - :rtype: ~azure.ai.agents.types.EvaluatorVersion - :raises ~azure.core.exceptions.HttpResponseError: + def _upload_file(self, body: Union[_models._models.UploadFileRequest, JSON], **kwargs: Any) -> _models.FileInfo: + """Uploads a file for use by other operations. - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "type": - - # JSON input template for discriminator value "code": - evaluator_definition = { - "code_text": "str", - "type": "code", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # JSON input template for discriminator value "prompt": - evaluator_definition = { - "prompt_text": "str", - "type": "prompt", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # JSON input template you can fill out and use as your body input. - evaluator_version = { - "categories": [ - "str" - ], - "created_at": "2020-02-20 00:00:00", - "created_by": "str", - "definition": evaluator_definition, - "evaluator_type": "str", - "modified_at": "2020-02-20 00:00:00", - "name": "str", - "version": "str", - "description": "str", - "display_name": "str", - "id": "str", - "metadata": { - "str": "str" - }, - "tags": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "code": - evaluator_definition = { - "code_text": "str", - "type": "code", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # JSON input template for discriminator value "prompt": - evaluator_definition = { - "prompt_text": "str", - "type": "prompt", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # response body for status code(s): 201 - response == { - "categories": [ - "str" - ], - "created_at": "2020-02-20 00:00:00", - "created_by": "str", - "definition": evaluator_definition, - "evaluator_type": "str", - "modified_at": "2020-02-20 00:00:00", - "name": "str", - "version": "str", - "description": "str", - "display_name": "str", - "id": "str", - "metadata": { - "str": "str" - }, - "tags": { - "str": "str" - } - } + :param body: Multipart body. Is either a UploadFileRequest type or a JSON type. Required. + :type body: ~azure.ai.agents.models._models.UploadFileRequest or JSON + :return: FileInfo. The FileInfo is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.FileInfo + :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -11840,27 +3606,20 @@ def create_version( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models1.EvaluatorVersion] = kwargs.pop("cls", None) + cls: ClsType[_models.FileInfo] = kwargs.pop("cls", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(evaluator_version, (IOBase, bytes)): - _content = evaluator_version - else: - _json = evaluator_version + _body = body.as_dict() if isinstance(body, _Model) else body + _file_fields: list[str] = ["file"] + _data_fields: list[str] = ["purpose", "filename"] + _files, _data = prepare_multipart_form_data(_body, _file_fields, _data_fields) - _request = build_beta_evaluators_create_version_request( - name=name, - foundry_features=foundry_features, - content_type=content_type, + _request = build_files_upload_file_request( api_version=self._config.api_version, - json=_json, - content=_content, + files=_files, + data=_data, headers=_headers, params=_params, ) @@ -11869,7 +3628,6 @@ def create_version( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -11877,462 +3635,35 @@ def create_version( response = pipeline_response.http_response - if response.status_code not in [201]: + if response.status_code not in [200]: if _stream: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.FileInfo, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - def update_version( - self, - name: str, - version: str, - evaluator_version: _types_models1.EvaluatorVersion, - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models1.EvaluatorVersion: - """Update an existing EvaluatorVersion with the given version id. - - :param name: The name of the resource. Required. - :type name: str - :param version: The version of the EvaluatorVersion to update. Required. - :type version: str - :param evaluator_version: Evaluator resource. Required. - :type evaluator_version: ~azure.ai.agents.types.EvaluatorVersion - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: EvaluatorVersion - :rtype: ~azure.ai.agents.types.EvaluatorVersion - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "type": - - # JSON input template for discriminator value "code": - evaluator_definition = { - "code_text": "str", - "type": "code", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # JSON input template for discriminator value "prompt": - evaluator_definition = { - "prompt_text": "str", - "type": "prompt", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # JSON input template you can fill out and use as your body input. - evaluator_version = { - "categories": [ - "str" - ], - "created_at": "2020-02-20 00:00:00", - "created_by": "str", - "definition": evaluator_definition, - "evaluator_type": "str", - "modified_at": "2020-02-20 00:00:00", - "name": "str", - "version": "str", - "description": "str", - "display_name": "str", - "id": "str", - "metadata": { - "str": "str" - }, - "tags": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "code": - evaluator_definition = { - "code_text": "str", - "type": "code", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # JSON input template for discriminator value "prompt": - evaluator_definition = { - "prompt_text": "str", - "type": "prompt", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # response body for status code(s): 200 - response == { - "categories": [ - "str" - ], - "created_at": "2020-02-20 00:00:00", - "created_by": "str", - "definition": evaluator_definition, - "evaluator_type": "str", - "modified_at": "2020-02-20 00:00:00", - "name": "str", - "version": "str", - "description": "str", - "display_name": "str", - "id": "str", - "metadata": { - "str": "str" - }, - "tags": { - "str": "str" - } - } - """ - - @overload - def update_version( - self, - name: str, - version: str, - evaluator_version: IO[bytes], - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models1.EvaluatorVersion: - """Update an existing EvaluatorVersion with the given version id. - - :param name: The name of the resource. Required. - :type name: str - :param version: The version of the EvaluatorVersion to update. Required. - :type version: str - :param evaluator_version: Evaluator resource. Required. - :type evaluator_version: IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: EvaluatorVersion - :rtype: ~azure.ai.agents.types.EvaluatorVersion - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "code": - evaluator_definition = { - "code_text": "str", - "type": "code", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # JSON input template for discriminator value "prompt": - evaluator_definition = { - "prompt_text": "str", - "type": "prompt", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # response body for status code(s): 200 - response == { - "categories": [ - "str" - ], - "created_at": "2020-02-20 00:00:00", - "created_by": "str", - "definition": evaluator_definition, - "evaluator_type": "str", - "modified_at": "2020-02-20 00:00:00", - "name": "str", - "version": "str", - "description": "str", - "display_name": "str", - "id": "str", - "metadata": { - "str": "str" - }, - "tags": { - "str": "str" - } - } - """ - @distributed_trace - def update_version( - self, - name: str, - version: str, - evaluator_version: Union[_types_models1.EvaluatorVersion, IO[bytes]], - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], - **kwargs: Any - ) -> _types_models1.EvaluatorVersion: - """Update an existing EvaluatorVersion with the given version id. - - :param name: The name of the resource. Required. - :type name: str - :param version: The version of the EvaluatorVersion to update. Required. - :type version: str - :param evaluator_version: Evaluator resource. Is either a EvaluatorVersion type or a IO[bytes] - type. Required. - :type evaluator_version: ~azure.ai.agents.types.EvaluatorVersion or IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.EVALUATIONS_V1_PREVIEW - :return: EvaluatorVersion - :rtype: ~azure.ai.agents.types.EvaluatorVersion - :raises ~azure.core.exceptions.HttpResponseError: + def _delete_file(self, file_id: str, **kwargs: Any) -> _models._models.FileDeletionStatus: + """Delete a previously uploaded file. - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "type": - - # JSON input template for discriminator value "code": - evaluator_definition = { - "code_text": "str", - "type": "code", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # JSON input template for discriminator value "prompt": - evaluator_definition = { - "prompt_text": "str", - "type": "prompt", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # JSON input template you can fill out and use as your body input. - evaluator_version = { - "categories": [ - "str" - ], - "created_at": "2020-02-20 00:00:00", - "created_by": "str", - "definition": evaluator_definition, - "evaluator_type": "str", - "modified_at": "2020-02-20 00:00:00", - "name": "str", - "version": "str", - "description": "str", - "display_name": "str", - "id": "str", - "metadata": { - "str": "str" - }, - "tags": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "code": - evaluator_definition = { - "code_text": "str", - "type": "code", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # JSON input template for discriminator value "prompt": - evaluator_definition = { - "prompt_text": "str", - "type": "prompt", - "data_schema": { - "str": {} - }, - "init_parameters": { - "str": {} - }, - "metrics": { - "str": { - "desirable_direction": "str", - "is_primary": bool, - "max_value": 0.0, - "min_value": 0.0, - "type": "str" - } - } - } - - # response body for status code(s): 200 - response == { - "categories": [ - "str" - ], - "created_at": "2020-02-20 00:00:00", - "created_by": "str", - "definition": evaluator_definition, - "evaluator_type": "str", - "modified_at": "2020-02-20 00:00:00", - "name": "str", - "version": "str", - "description": "str", - "display_name": "str", - "id": "str", - "metadata": { - "str": "str" - }, - "tags": { - "str": "str" - } - } + :param file_id: The ID of the file to delete. Required. + :type file_id: str + :return: FileDeletionStatus. The FileDeletionStatus is compatible with MutableMapping + :rtype: ~azure.ai.agents.models._models.FileDeletionStatus + :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -12342,28 +3673,14 @@ def update_version( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models1.EvaluatorVersion] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(evaluator_version, (IOBase, bytes)): - _content = evaluator_version - else: - _json = evaluator_version + cls: ClsType[_models._models.FileDeletionStatus] = kwargs.pop("cls", None) - _request = build_beta_evaluators_update_version_request( - name=name, - version=version, - foundry_features=foundry_features, - content_type=content_type, + _request = build_files_delete_file_request( + file_id=file_id, api_version=self._config.api_version, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -12372,7 +3689,6 @@ def update_version( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -12387,722 +3703,30 @@ def update_version( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize( + _models._models.FileDeletionStatus, response.json() # pylint: disable=protected-access + ) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - -class BetaInsightsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.agents.AIProjectClient`'s - :attr:`insights` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - def generate( - self, - insight: _types_models1.Insight, - *, - foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW]] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models1.Insight: - """Generate Insights. - - :param insight: Complete evaluation configuration including data source, evaluators, and result - settings. Required. - :type insight: ~azure.ai.agents.types.Insight - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. INSIGHTS_V1_PREVIEW. Default value is None. - :paramtype foundry_features: str or ~azure.ai.agents.models.INSIGHTS_V1_PREVIEW - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Insight - :rtype: ~azure.ai.agents.types.Insight - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "type": - - # JSON input template for discriminator value "AgentClusterInsight": - insight_request = { - "agentName": "str", - "type": "AgentClusterInsight", - "modelConfiguration": { - "modelDeploymentName": "str" - } - } - - # JSON input template for discriminator value "EvaluationComparison": - insight_request = { - "baselineRunId": "str", - "evalId": "str", - "treatmentRunIds": [ - "str" - ], - "type": "EvaluationComparison" - } - - # JSON input template for discriminator value "EvaluationRunClusterInsight": - insight_request = { - "evalId": "str", - "runIds": [ - "str" - ], - "type": "EvaluationRunClusterInsight", - "modelConfiguration": { - "modelDeploymentName": "str" - } - } - - # JSON input template for discriminator value "AgentClusterInsight": - insight_result = { - "clusterInsight": { - "clusters": [ - { - "description": "str", - "id": "str", - "label": "str", - "suggestion": "str", - "suggestionTitle": "str", - "weight": 0, - "samples": [ - insight_sample - ], - "subClusters": [ - ... - ] - } - ], - "summary": { - "method": "str", - "sampleCount": 0, - "uniqueClusterCount": 0, - "uniqueSubclusterCount": 0, - "usage": { - "inputTokenUsage": 0, - "outputTokenUsage": 0, - "totalTokenUsage": 0 - } - }, - "coordinates": { - "str": { - "size": 0, - "x": 0, - "y": 0 - } - } - }, - "type": "AgentClusterInsight" - } - - # JSON input template for discriminator value "EvaluationComparison": - insight_result = { - "comparisons": [ - { - "baselineRunSummary": { - "average": 0.0, - "runId": "str", - "sampleCount": 0, - "standardDeviation": 0.0 - }, - "compareItems": [ - { - "deltaEstimate": 0.0, - "pValue": 0.0, - "treatmentEffect": "str", - "treatmentRunId": "str", - "treatmentRunSummary": { - "average": 0.0, - "runId": "str", - "sampleCount": 0, - "standardDeviation": 0.0 - } - } - ], - "evaluator": "str", - "metric": "str", - "testingCriteria": "str" - } - ], - "method": "str", - "type": "EvaluationComparison" - } - - # JSON input template you can fill out and use as your body input. - insight = { - "displayName": "str", - "id": "str", - "metadata": { - "createdAt": "2020-02-20 00:00:00", - "completedAt": "2020-02-20 00:00:00" - }, - "request": insight_request, - "state": "str", - "result": insight_result - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AgentClusterInsight": - insight_request = { - "agentName": "str", - "type": "AgentClusterInsight", - "modelConfiguration": { - "modelDeploymentName": "str" - } - } - - # JSON input template for discriminator value "EvaluationComparison": - insight_request = { - "baselineRunId": "str", - "evalId": "str", - "treatmentRunIds": [ - "str" - ], - "type": "EvaluationComparison" - } - - # JSON input template for discriminator value "EvaluationRunClusterInsight": - insight_request = { - "evalId": "str", - "runIds": [ - "str" - ], - "type": "EvaluationRunClusterInsight", - "modelConfiguration": { - "modelDeploymentName": "str" - } - } - - # JSON input template for discriminator value "AgentClusterInsight": - insight_result = { - "clusterInsight": { - "clusters": [ - { - "description": "str", - "id": "str", - "label": "str", - "suggestion": "str", - "suggestionTitle": "str", - "weight": 0, - "samples": [ - insight_sample - ], - "subClusters": [ - ... - ] - } - ], - "summary": { - "method": "str", - "sampleCount": 0, - "uniqueClusterCount": 0, - "uniqueSubclusterCount": 0, - "usage": { - "inputTokenUsage": 0, - "outputTokenUsage": 0, - "totalTokenUsage": 0 - } - }, - "coordinates": { - "str": { - "size": 0, - "x": 0, - "y": 0 - } - } - }, - "type": "AgentClusterInsight" - } - - # JSON input template for discriminator value "EvaluationComparison": - insight_result = { - "comparisons": [ - { - "baselineRunSummary": { - "average": 0.0, - "runId": "str", - "sampleCount": 0, - "standardDeviation": 0.0 - }, - "compareItems": [ - { - "deltaEstimate": 0.0, - "pValue": 0.0, - "treatmentEffect": "str", - "treatmentRunId": "str", - "treatmentRunSummary": { - "average": 0.0, - "runId": "str", - "sampleCount": 0, - "standardDeviation": 0.0 - } - } - ], - "evaluator": "str", - "metric": "str", - "testingCriteria": "str" - } - ], - "method": "str", - "type": "EvaluationComparison" - } - - # response body for status code(s): 201 - response == { - "displayName": "str", - "id": "str", - "metadata": { - "createdAt": "2020-02-20 00:00:00", - "completedAt": "2020-02-20 00:00:00" - }, - "request": insight_request, - "state": "str", - "result": insight_result - } - """ - - @overload - def generate( - self, - insight: IO[bytes], - *, - foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW]] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models1.Insight: - """Generate Insights. - - :param insight: Complete evaluation configuration including data source, evaluators, and result - settings. Required. - :type insight: IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. INSIGHTS_V1_PREVIEW. Default value is None. - :paramtype foundry_features: str or ~azure.ai.agents.models.INSIGHTS_V1_PREVIEW - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: Insight - :rtype: ~azure.ai.agents.types.Insight - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AgentClusterInsight": - insight_request = { - "agentName": "str", - "type": "AgentClusterInsight", - "modelConfiguration": { - "modelDeploymentName": "str" - } - } - - # JSON input template for discriminator value "EvaluationComparison": - insight_request = { - "baselineRunId": "str", - "evalId": "str", - "treatmentRunIds": [ - "str" - ], - "type": "EvaluationComparison" - } - - # JSON input template for discriminator value "EvaluationRunClusterInsight": - insight_request = { - "evalId": "str", - "runIds": [ - "str" - ], - "type": "EvaluationRunClusterInsight", - "modelConfiguration": { - "modelDeploymentName": "str" - } - } - - # JSON input template for discriminator value "AgentClusterInsight": - insight_result = { - "clusterInsight": { - "clusters": [ - { - "description": "str", - "id": "str", - "label": "str", - "suggestion": "str", - "suggestionTitle": "str", - "weight": 0, - "samples": [ - insight_sample - ], - "subClusters": [ - ... - ] - } - ], - "summary": { - "method": "str", - "sampleCount": 0, - "uniqueClusterCount": 0, - "uniqueSubclusterCount": 0, - "usage": { - "inputTokenUsage": 0, - "outputTokenUsage": 0, - "totalTokenUsage": 0 - } - }, - "coordinates": { - "str": { - "size": 0, - "x": 0, - "y": 0 - } - } - }, - "type": "AgentClusterInsight" - } - - # JSON input template for discriminator value "EvaluationComparison": - insight_result = { - "comparisons": [ - { - "baselineRunSummary": { - "average": 0.0, - "runId": "str", - "sampleCount": 0, - "standardDeviation": 0.0 - }, - "compareItems": [ - { - "deltaEstimate": 0.0, - "pValue": 0.0, - "treatmentEffect": "str", - "treatmentRunId": "str", - "treatmentRunSummary": { - "average": 0.0, - "runId": "str", - "sampleCount": 0, - "standardDeviation": 0.0 - } - } - ], - "evaluator": "str", - "metric": "str", - "testingCriteria": "str" - } - ], - "method": "str", - "type": "EvaluationComparison" - } - - # response body for status code(s): 201 - response == { - "displayName": "str", - "id": "str", - "metadata": { - "createdAt": "2020-02-20 00:00:00", - "completedAt": "2020-02-20 00:00:00" - }, - "request": insight_request, - "state": "str", - "result": insight_result - } - """ - @distributed_trace - def generate( - self, - insight: Union[_types_models1.Insight, IO[bytes]], - *, - foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW]] = None, - **kwargs: Any - ) -> _types_models1.Insight: - """Generate Insights. - - :param insight: Complete evaluation configuration including data source, evaluators, and result - settings. Is either a Insight type or a IO[bytes] type. Required. - :type insight: ~azure.ai.agents.types.Insight or IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. INSIGHTS_V1_PREVIEW. Default value is None. - :paramtype foundry_features: str or ~azure.ai.agents.models.INSIGHTS_V1_PREVIEW - :return: Insight - :rtype: ~azure.ai.agents.types.Insight - :raises ~azure.core.exceptions.HttpResponseError: + def get(self, file_id: str, **kwargs: Any) -> _models.FileInfo: + """Returns information about a specific file. Does not retrieve file content. - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "type": - - # JSON input template for discriminator value "AgentClusterInsight": - insight_request = { - "agentName": "str", - "type": "AgentClusterInsight", - "modelConfiguration": { - "modelDeploymentName": "str" - } - } - - # JSON input template for discriminator value "EvaluationComparison": - insight_request = { - "baselineRunId": "str", - "evalId": "str", - "treatmentRunIds": [ - "str" - ], - "type": "EvaluationComparison" - } - - # JSON input template for discriminator value "EvaluationRunClusterInsight": - insight_request = { - "evalId": "str", - "runIds": [ - "str" - ], - "type": "EvaluationRunClusterInsight", - "modelConfiguration": { - "modelDeploymentName": "str" - } - } - - # JSON input template for discriminator value "AgentClusterInsight": - insight_result = { - "clusterInsight": { - "clusters": [ - { - "description": "str", - "id": "str", - "label": "str", - "suggestion": "str", - "suggestionTitle": "str", - "weight": 0, - "samples": [ - insight_sample - ], - "subClusters": [ - ... - ] - } - ], - "summary": { - "method": "str", - "sampleCount": 0, - "uniqueClusterCount": 0, - "uniqueSubclusterCount": 0, - "usage": { - "inputTokenUsage": 0, - "outputTokenUsage": 0, - "totalTokenUsage": 0 - } - }, - "coordinates": { - "str": { - "size": 0, - "x": 0, - "y": 0 - } - } - }, - "type": "AgentClusterInsight" - } - - # JSON input template for discriminator value "EvaluationComparison": - insight_result = { - "comparisons": [ - { - "baselineRunSummary": { - "average": 0.0, - "runId": "str", - "sampleCount": 0, - "standardDeviation": 0.0 - }, - "compareItems": [ - { - "deltaEstimate": 0.0, - "pValue": 0.0, - "treatmentEffect": "str", - "treatmentRunId": "str", - "treatmentRunSummary": { - "average": 0.0, - "runId": "str", - "sampleCount": 0, - "standardDeviation": 0.0 - } - } - ], - "evaluator": "str", - "metric": "str", - "testingCriteria": "str" - } - ], - "method": "str", - "type": "EvaluationComparison" - } - - # JSON input template you can fill out and use as your body input. - insight = { - "displayName": "str", - "id": "str", - "metadata": { - "createdAt": "2020-02-20 00:00:00", - "completedAt": "2020-02-20 00:00:00" - }, - "request": insight_request, - "state": "str", - "result": insight_result - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AgentClusterInsight": - insight_request = { - "agentName": "str", - "type": "AgentClusterInsight", - "modelConfiguration": { - "modelDeploymentName": "str" - } - } - - # JSON input template for discriminator value "EvaluationComparison": - insight_request = { - "baselineRunId": "str", - "evalId": "str", - "treatmentRunIds": [ - "str" - ], - "type": "EvaluationComparison" - } - - # JSON input template for discriminator value "EvaluationRunClusterInsight": - insight_request = { - "evalId": "str", - "runIds": [ - "str" - ], - "type": "EvaluationRunClusterInsight", - "modelConfiguration": { - "modelDeploymentName": "str" - } - } - - # JSON input template for discriminator value "AgentClusterInsight": - insight_result = { - "clusterInsight": { - "clusters": [ - { - "description": "str", - "id": "str", - "label": "str", - "suggestion": "str", - "suggestionTitle": "str", - "weight": 0, - "samples": [ - insight_sample - ], - "subClusters": [ - ... - ] - } - ], - "summary": { - "method": "str", - "sampleCount": 0, - "uniqueClusterCount": 0, - "uniqueSubclusterCount": 0, - "usage": { - "inputTokenUsage": 0, - "outputTokenUsage": 0, - "totalTokenUsage": 0 - } - }, - "coordinates": { - "str": { - "size": 0, - "x": 0, - "y": 0 - } - } - }, - "type": "AgentClusterInsight" - } - - # JSON input template for discriminator value "EvaluationComparison": - insight_result = { - "comparisons": [ - { - "baselineRunSummary": { - "average": 0.0, - "runId": "str", - "sampleCount": 0, - "standardDeviation": 0.0 - }, - "compareItems": [ - { - "deltaEstimate": 0.0, - "pValue": 0.0, - "treatmentEffect": "str", - "treatmentRunId": "str", - "treatmentRunSummary": { - "average": 0.0, - "runId": "str", - "sampleCount": 0, - "standardDeviation": 0.0 - } - } - ], - "evaluator": "str", - "metric": "str", - "testingCriteria": "str" - } - ], - "method": "str", - "type": "EvaluationComparison" - } - - # response body for status code(s): 201 - response == { - "displayName": "str", - "id": "str", - "metadata": { - "createdAt": "2020-02-20 00:00:00", - "completedAt": "2020-02-20 00:00:00" - }, - "request": insight_request, - "state": "str", - "result": insight_result - } + :param file_id: The ID of the file to retrieve. Required. + :type file_id: str + :return: FileInfo. The FileInfo is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.FileInfo + :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -13112,26 +3736,14 @@ def generate( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models1.Insight] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(insight, (IOBase, bytes)): - _content = insight - else: - _json = insight + cls: ClsType[_models.FileInfo] = kwargs.pop("cls", None) - _request = build_beta_insights_generate_request( - foundry_features=foundry_features, - content_type=content_type, + _request = build_files_get_request( + file_id=file_id, api_version=self._config.api_version, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -13140,7 +3752,6 @@ def generate( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -13148,26 +3759,20 @@ def generate( response = pipeline_response.http_response - if response.status_code not in [201]: + if response.status_code not in [200]: if _stream: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models1.ApiErrorResponse, - pipeline_response, - ) + error = _failsafe_deserialize(_models.AgentV1Error, response) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.FileInfo, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -13175,151 +3780,14 @@ def generate( return deserialized # type: ignore @distributed_trace - def get( - self, - id: str, - *, - foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW]] = None, - include_coordinates: Optional[bool] = None, - **kwargs: Any - ) -> _types_models1.Insight: - """Get a specific insight by Id. - - :param id: The unique identifier for the insights report. Required. - :type id: str - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. INSIGHTS_V1_PREVIEW. Default value is None. - :paramtype foundry_features: str or ~azure.ai.agents.models.INSIGHTS_V1_PREVIEW - :keyword include_coordinates: Whether to include coordinates for visualization in the response. - Defaults to false. Default value is None. - :paramtype include_coordinates: bool - :return: Insight - :rtype: ~azure.ai.agents.types.Insight - :raises ~azure.core.exceptions.HttpResponseError: + def _get_file_content(self, file_id: str, **kwargs: Any) -> Iterator[bytes]: + """Retrieves the raw content of a specific file. - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AgentClusterInsight": - insight_request = { - "agentName": "str", - "type": "AgentClusterInsight", - "modelConfiguration": { - "modelDeploymentName": "str" - } - } - - # JSON input template for discriminator value "EvaluationComparison": - insight_request = { - "baselineRunId": "str", - "evalId": "str", - "treatmentRunIds": [ - "str" - ], - "type": "EvaluationComparison" - } - - # JSON input template for discriminator value "EvaluationRunClusterInsight": - insight_request = { - "evalId": "str", - "runIds": [ - "str" - ], - "type": "EvaluationRunClusterInsight", - "modelConfiguration": { - "modelDeploymentName": "str" - } - } - - # JSON input template for discriminator value "AgentClusterInsight": - insight_result = { - "clusterInsight": { - "clusters": [ - { - "description": "str", - "id": "str", - "label": "str", - "suggestion": "str", - "suggestionTitle": "str", - "weight": 0, - "samples": [ - insight_sample - ], - "subClusters": [ - ... - ] - } - ], - "summary": { - "method": "str", - "sampleCount": 0, - "uniqueClusterCount": 0, - "uniqueSubclusterCount": 0, - "usage": { - "inputTokenUsage": 0, - "outputTokenUsage": 0, - "totalTokenUsage": 0 - } - }, - "coordinates": { - "str": { - "size": 0, - "x": 0, - "y": 0 - } - } - }, - "type": "AgentClusterInsight" - } - - # JSON input template for discriminator value "EvaluationComparison": - insight_result = { - "comparisons": [ - { - "baselineRunSummary": { - "average": 0.0, - "runId": "str", - "sampleCount": 0, - "standardDeviation": 0.0 - }, - "compareItems": [ - { - "deltaEstimate": 0.0, - "pValue": 0.0, - "treatmentEffect": "str", - "treatmentRunId": "str", - "treatmentRunSummary": { - "average": 0.0, - "runId": "str", - "sampleCount": 0, - "standardDeviation": 0.0 - } - } - ], - "evaluator": "str", - "metric": "str", - "testingCriteria": "str" - } - ], - "method": "str", - "type": "EvaluationComparison" - } - - # response body for status code(s): 200 - response == { - "displayName": "str", - "id": "str", - "metadata": { - "createdAt": "2020-02-20 00:00:00", - "completedAt": "2020-02-20 00:00:00" - }, - "request": insight_request, - "state": "str", - "result": insight_result - } + :param file_id: The ID of the file to retrieve. Required. + :type file_id: str + :return: Iterator[bytes] + :rtype: Iterator[bytes] + :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -13332,12 +3800,10 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_types_models1.Insight] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_beta_insights_get_request( - id=id, - foundry_features=foundry_features, - include_coordinates=include_coordinates, + _request = build_files_get_file_content_request( + file_id=file_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -13347,8 +3813,7 @@ def get( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) + _stream = kwargs.pop("stream", True) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -13362,186 +3827,64 @@ def get( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models1.ApiErrorResponse, - pipeline_response, - ) + error = _failsafe_deserialize(_models.AgentV1Error, response) raise HttpResponseError(response=response, model=error) - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + +class VectorStoresOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.agents.AgentsClient`'s + :attr:`vector_stores` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AgentsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, *, - foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW]] = None, - type: Optional[types.InsightType] = None, - eval_id: Optional[str] = None, - run_id: Optional[str] = None, - agent_name: Optional[str] = None, - include_coordinates: Optional[bool] = None, + limit: Optional[int] = None, + order: Optional[Union[str, _models.ListSortOrder]] = None, + before: Optional[str] = None, **kwargs: Any - ) -> ItemPaged["_types_models1.Insight"]: - """List all insights in reverse chronological order (newest first). - - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. INSIGHTS_V1_PREVIEW. Default value is None. - :paramtype foundry_features: str or ~azure.ai.agents.models.INSIGHTS_V1_PREVIEW - :keyword type: Filter by the type of analysis. Known values are: "EvaluationRunClusterInsight", - "AgentClusterInsight", and "EvaluationComparison". Default value is None. - :paramtype type: str or ~azure.ai.agents.models.InsightType - :keyword eval_id: Filter by the evaluation ID. Default value is None. - :paramtype eval_id: str - :keyword run_id: Filter by the evaluation run ID. Default value is None. - :paramtype run_id: str - :keyword agent_name: Filter by the agent name. Default value is None. - :paramtype agent_name: str - :keyword include_coordinates: Whether to include coordinates for visualization in the response. - Defaults to false. Default value is None. - :paramtype include_coordinates: bool - :return: An iterator like instance of Insight - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.types.Insight] - :raises ~azure.core.exceptions.HttpResponseError: + ) -> ItemPaged["_models.VectorStore"]: + """Returns a list of vector stores. - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AgentClusterInsight": - insight_request = { - "agentName": "str", - "type": "AgentClusterInsight", - "modelConfiguration": { - "modelDeploymentName": "str" - } - } - - # JSON input template for discriminator value "EvaluationComparison": - insight_request = { - "baselineRunId": "str", - "evalId": "str", - "treatmentRunIds": [ - "str" - ], - "type": "EvaluationComparison" - } - - # JSON input template for discriminator value "EvaluationRunClusterInsight": - insight_request = { - "evalId": "str", - "runIds": [ - "str" - ], - "type": "EvaluationRunClusterInsight", - "modelConfiguration": { - "modelDeploymentName": "str" - } - } - - # JSON input template for discriminator value "AgentClusterInsight": - insight_result = { - "clusterInsight": { - "clusters": [ - { - "description": "str", - "id": "str", - "label": "str", - "suggestion": "str", - "suggestionTitle": "str", - "weight": 0, - "samples": [ - insight_sample - ], - "subClusters": [ - ... - ] - } - ], - "summary": { - "method": "str", - "sampleCount": 0, - "uniqueClusterCount": 0, - "uniqueSubclusterCount": 0, - "usage": { - "inputTokenUsage": 0, - "outputTokenUsage": 0, - "totalTokenUsage": 0 - } - }, - "coordinates": { - "str": { - "size": 0, - "x": 0, - "y": 0 - } - } - }, - "type": "AgentClusterInsight" - } - - # JSON input template for discriminator value "EvaluationComparison": - insight_result = { - "comparisons": [ - { - "baselineRunSummary": { - "average": 0.0, - "runId": "str", - "sampleCount": 0, - "standardDeviation": 0.0 - }, - "compareItems": [ - { - "deltaEstimate": 0.0, - "pValue": 0.0, - "treatmentEffect": "str", - "treatmentRunId": "str", - "treatmentRunSummary": { - "average": 0.0, - "runId": "str", - "sampleCount": 0, - "standardDeviation": 0.0 - } - } - ], - "evaluator": "str", - "metric": "str", - "testingCriteria": "str" - } - ], - "method": "str", - "type": "EvaluationComparison" - } - - # response body for status code(s): 200 - response == { - "displayName": "str", - "id": "str", - "metadata": { - "createdAt": "2020-02-20 00:00:00", - "completedAt": "2020-02-20 00:00:00" - }, - "request": insight_request, - "state": "str", - "result": insight_result - } + :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and + 100, and the default is 20. Default value is None. + :paramtype limit: int + :keyword order: Sort order by the created_at timestamp of the objects. asc for ascending order + and desc for descending order. Known values are: "asc" and "desc". Default value is None. + :paramtype order: str or ~azure.ai.agents.models.ListSortOrder + :keyword 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. Default value is None. + :paramtype before: str + :return: An iterator like instance of VectorStore + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.models.VectorStore] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_types_models1.Insight]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.VectorStore]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -13551,61 +3894,32 @@ def list( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - _request = build_beta_insights_list_request( - foundry_features=foundry_features, - type=type, - eval_id=eval_id, - run_id=run_id, - agent_name=agent_name, - include_coordinates=include_coordinates, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + def prepare_request(_continuation_token=None): + _request = build_vector_stores_list_request( + limit=limit, + order=order, + after=_continuation_token, + before=before, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) return _request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized.get("value", []) + list_of_elem = _deserialize(List[_models.VectorStore], deserialized.get("data", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) + return deserialized.get("last_id") or None, iter(list_of_elem) - def get_next(next_link=None): - _request = prepare_request(next_link) + def get_next(_continuation_token=None): + _request = prepare_request(_continuation_token) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access @@ -13615,325 +3929,200 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models1.ApiErrorResponse, - pipeline_response, - ) + error = _failsafe_deserialize(_models.AgentV1Error, response) raise HttpResponseError(response=response, model=error) return pipeline_response return ItemPaged(get_next, extract_data) - -class BetaMemoryStoresOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.agents.AIProjectClient`'s - :attr:`memory_stores` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @overload def create( self, - name: str, - definition: _types_models1.MemoryStoreDefinition, - description: Optional[str] = None, - metadata: Optional[dict[str, str]] = None, *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], content_type: str = "application/json", + file_ids: Optional[List[str]] = None, + name: Optional[str] = None, + store_configuration: Optional[_models.VectorStoreConfiguration] = None, + expires_after: Optional[_models.VectorStoreExpirationPolicy] = None, + chunking_strategy: Optional[_models.VectorStoreChunkingStrategyRequest] = None, + metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> _types_models1.MemoryStoreDetails: - """Create a memory store. - - :param name: The name of the memory store. Required. - :type name: str - :param definition: The memory store definition. Required. - :type definition: ~azure.ai.agents.types.MemoryStoreDefinition - :param description: A human-readable description of the memory store. Default value is None. - :type description: str - :param metadata: Arbitrary key-value metadata to associate with the memory store. Default value - is None. - :type metadata: dict[str, str] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW + ) -> _models.VectorStore: + """Creates a vector store. + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: MemoryStoreDetails - :rtype: ~azure.ai.agents.types.MemoryStoreDetails + :keyword file_ids: A list of file IDs that the vector store should use. Useful for tools like + ``file_search`` that can access files. Default value is None. + :paramtype file_ids: list[str] + :keyword name: The name of the vector store. Default value is None. + :paramtype name: str + :keyword store_configuration: The vector store configuration, used when vector store is created + from Azure asset URIs. Default value is None. + :paramtype store_configuration: ~azure.ai.agents.models.VectorStoreConfiguration + :keyword expires_after: Details on when this vector store expires. Default value is None. + :paramtype expires_after: ~azure.ai.agents.models.VectorStoreExpirationPolicy + :keyword chunking_strategy: 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. Default value is None. + :paramtype chunking_strategy: ~azure.ai.agents.models.VectorStoreChunkingStrategyRequest + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: VectorStore. The VectorStore is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.VectorStore :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "default": - memory_store_definition = { - "chat_model": "str", - "embedding_model": "str", - "kind": "default", - "options": { - "chat_summary_enabled": bool, - "user_profile_enabled": bool, - "user_profile_details": "str" - } - } - - # response body for status code(s): 200 - response == { - "created_at": "2020-02-20 00:00:00", - "definition": memory_store_definition, - "id": "str", - "name": "str", - "object": "str", - "updated_at": "2020-02-20 00:00:00", - "description": "str", - "metadata": { - "str": "str" - } - } """ @overload - def create( - self, - body: JSON, - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models1.MemoryStoreDetails: - """Create a memory store. + def create(self, body: JSON, *, content_type: str = "application/json", **kwargs: Any) -> _models.VectorStore: + """Creates a vector store. :param body: Required. :type body: JSON - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: MemoryStoreDetails - :rtype: ~azure.ai.agents.types.MemoryStoreDetails + :return: VectorStore. The VectorStore is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.VectorStore :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "kind": - - # JSON input template for discriminator value "default": - memory_store_definition = { - "chat_model": "str", - "embedding_model": "str", - "kind": "default", - "options": { - "chat_summary_enabled": bool, - "user_profile_enabled": bool, - "user_profile_details": "str" - } - } - - # JSON input template you can fill out and use as your body input. - body = { - "definition": memory_store_definition, - "name": "str", - "description": "str", - "metadata": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "default": - memory_store_definition = { - "chat_model": "str", - "embedding_model": "str", - "kind": "default", - "options": { - "chat_summary_enabled": bool, - "user_profile_enabled": bool, - "user_profile_details": "str" - } - } - - # response body for status code(s): 200 - response == { - "created_at": "2020-02-20 00:00:00", - "definition": memory_store_definition, - "id": "str", - "name": "str", - "object": "str", - "updated_at": "2020-02-20 00:00:00", - "description": "str", - "metadata": { - "str": "str" - } - } """ @overload - def create( - self, - body: IO[bytes], - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models1.MemoryStoreDetails: - """Create a memory store. + def create(self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any) -> _models.VectorStore: + """Creates a vector store. :param body: Required. :type body: IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: MemoryStoreDetails - :rtype: ~azure.ai.agents.types.MemoryStoreDetails + :return: VectorStore. The VectorStore is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.VectorStore :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "default": - memory_store_definition = { - "chat_model": "str", - "embedding_model": "str", - "kind": "default", - "options": { - "chat_summary_enabled": bool, - "user_profile_enabled": bool, - "user_profile_details": "str" - } - } - - # response body for status code(s): 200 - response == { - "created_at": "2020-02-20 00:00:00", - "definition": memory_store_definition, - "id": "str", - "name": "str", - "object": "str", - "updated_at": "2020-02-20 00:00:00", - "description": "str", - "metadata": { - "str": "str" - } - } """ @distributed_trace def create( self, - name: str = _Unset, - definition: _types_models1.MemoryStoreDefinition = _Unset, body: Union[JSON, IO[bytes]] = _Unset, - description: Optional[str] = None, - metadata: Optional[dict[str, str]] = None, *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + file_ids: Optional[List[str]] = None, + name: Optional[str] = None, + store_configuration: Optional[_models.VectorStoreConfiguration] = None, + expires_after: Optional[_models.VectorStoreExpirationPolicy] = None, + chunking_strategy: Optional[_models.VectorStoreChunkingStrategyRequest] = None, + metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> _types_models1.MemoryStoreDetails: - """Create a memory store. + ) -> _models.VectorStore: + """Creates a vector store. - :param name: The name of the memory store. Required. - :type name: str - :param definition: The memory store definition. Required. - :type definition: ~azure.ai.agents.types.MemoryStoreDefinition :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :param description: A human-readable description of the memory store. Default value is None. - :type description: str - :param metadata: Arbitrary key-value metadata to associate with the memory store. Default value - is None. - :type metadata: dict[str, str] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW - :return: MemoryStoreDetails - :rtype: ~azure.ai.agents.types.MemoryStoreDetails + :keyword file_ids: A list of file IDs that the vector store should use. Useful for tools like + ``file_search`` that can access files. Default value is None. + :paramtype file_ids: list[str] + :keyword name: The name of the vector store. Default value is None. + :paramtype name: str + :keyword store_configuration: The vector store configuration, used when vector store is created + from Azure asset URIs. Default value is None. + :paramtype store_configuration: ~azure.ai.agents.models.VectorStoreConfiguration + :keyword expires_after: Details on when this vector store expires. Default value is None. + :paramtype expires_after: ~azure.ai.agents.models.VectorStoreExpirationPolicy + :keyword chunking_strategy: 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. Default value is None. + :paramtype chunking_strategy: ~azure.ai.agents.models.VectorStoreChunkingStrategyRequest + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: VectorStore. The VectorStore is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.VectorStore :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VectorStore] = kwargs.pop("cls", None) + + if body is _Unset: + body = { + "chunking_strategy": chunking_strategy, + "configuration": store_configuration, + "expires_after": expires_after, + "file_ids": file_ids, + "metadata": metadata, + "name": name, + } + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_vector_stores_create_request( + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.VectorStore, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get(self, vector_store_id: str, **kwargs: Any) -> _models.VectorStore: + """Returns the vector store object matching the specified ID. - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "kind": - - # JSON input template for discriminator value "default": - memory_store_definition = { - "chat_model": "str", - "embedding_model": "str", - "kind": "default", - "options": { - "chat_summary_enabled": bool, - "user_profile_enabled": bool, - "user_profile_details": "str" - } - } - - # JSON input template you can fill out and use as your body input. - body = { - "definition": memory_store_definition, - "name": "str", - "description": "str", - "metadata": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "default": - memory_store_definition = { - "chat_model": "str", - "embedding_model": "str", - "kind": "default", - "options": { - "chat_summary_enabled": bool, - "user_profile_enabled": bool, - "user_profile_details": "str" - } - } - - # response body for status code(s): 200 - response == { - "created_at": "2020-02-20 00:00:00", - "definition": memory_store_definition, - "id": "str", - "name": "str", - "object": "str", - "updated_at": "2020-02-20 00:00:00", - "description": "str", - "metadata": { - "str": "str" - } - } + :param vector_store_id: Identifier of the vector store. Required. + :type vector_store_id: str + :return: VectorStore. The VectorStore is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.VectorStore + :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -13943,33 +4132,14 @@ def create( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models1.MemoryStoreDetails] = kwargs.pop("cls", None) - - if body is _Unset: - if name is _Unset: - raise TypeError("missing required argument: name") - if definition is _Unset: - raise TypeError("missing required argument: definition") - body = {"definition": definition, "description": description, "metadata": metadata, "name": name} - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _json = body + cls: ClsType[_models.VectorStore] = kwargs.pop("cls", None) - _request = build_beta_memory_stores_create_request( - foundry_features=foundry_features, - content_type=content_type, + _request = build_vector_stores_get_request( + vector_store_id=vector_store_id, api_version=self._config.api_version, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -13978,7 +4148,6 @@ def create( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -13993,19 +4162,13 @@ def create( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models1.ApiErrorResponse, - pipeline_response, - ) + error = _failsafe_deserialize(_models.AgentV1Error, response) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.VectorStore, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -14013,262 +4176,102 @@ def create( return deserialized # type: ignore @overload - def update( + def modify( self, - name: str, - description: Optional[str] = None, - metadata: Optional[dict[str, str]] = None, + vector_store_id: str, *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], content_type: str = "application/json", + name: Optional[str] = None, + expires_after: Optional[_models.VectorStoreExpirationPolicy] = None, + metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> _types_models1.MemoryStoreDetails: - """Update a memory store. - - :param name: The name of the memory store to update. Required. - :type name: str - :param description: A human-readable description of the memory store. Default value is None. - :type description: str - :param metadata: Arbitrary key-value metadata to associate with the memory store. Default value - is None. - :type metadata: dict[str, str] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW + ) -> _models.VectorStore: + """Modifies an existing vector store. + + :param vector_store_id: Identifier of the vector store. Required. + :type vector_store_id: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: MemoryStoreDetails - :rtype: ~azure.ai.agents.types.MemoryStoreDetails + :keyword name: The name of the vector store. Default value is None. + :paramtype name: str + :keyword expires_after: Details on when this vector store expires. Default value is None. + :paramtype expires_after: ~azure.ai.agents.models.VectorStoreExpirationPolicy + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: VectorStore. The VectorStore is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.VectorStore :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "default": - memory_store_definition = { - "chat_model": "str", - "embedding_model": "str", - "kind": "default", - "options": { - "chat_summary_enabled": bool, - "user_profile_enabled": bool, - "user_profile_details": "str" - } - } - - # response body for status code(s): 200 - response == { - "created_at": "2020-02-20 00:00:00", - "definition": memory_store_definition, - "id": "str", - "name": "str", - "object": "str", - "updated_at": "2020-02-20 00:00:00", - "description": "str", - "metadata": { - "str": "str" - } - } """ @overload - def update( - self, - name: str, - body: JSON, - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models1.MemoryStoreDetails: - """Update a memory store. + def modify( + self, vector_store_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.VectorStore: + """Modifies an existing vector store. - :param name: The name of the memory store to update. Required. - :type name: str + :param vector_store_id: Identifier of the vector store. Required. + :type vector_store_id: str :param body: Required. :type body: JSON - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: MemoryStoreDetails - :rtype: ~azure.ai.agents.types.MemoryStoreDetails + :return: VectorStore. The VectorStore is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.VectorStore :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "description": "str", - "metadata": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "default": - memory_store_definition = { - "chat_model": "str", - "embedding_model": "str", - "kind": "default", - "options": { - "chat_summary_enabled": bool, - "user_profile_enabled": bool, - "user_profile_details": "str" - } - } - - # response body for status code(s): 200 - response == { - "created_at": "2020-02-20 00:00:00", - "definition": memory_store_definition, - "id": "str", - "name": "str", - "object": "str", - "updated_at": "2020-02-20 00:00:00", - "description": "str", - "metadata": { - "str": "str" - } - } """ @overload - def update( - self, - name: str, - body: IO[bytes], - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models1.MemoryStoreDetails: - """Update a memory store. + def modify( + self, vector_store_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.VectorStore: + """Modifies an existing vector store. - :param name: The name of the memory store to update. Required. - :type name: str + :param vector_store_id: Identifier of the vector store. Required. + :type vector_store_id: str :param body: Required. :type body: IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: MemoryStoreDetails - :rtype: ~azure.ai.agents.types.MemoryStoreDetails + :return: VectorStore. The VectorStore is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.VectorStore :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "default": - memory_store_definition = { - "chat_model": "str", - "embedding_model": "str", - "kind": "default", - "options": { - "chat_summary_enabled": bool, - "user_profile_enabled": bool, - "user_profile_details": "str" - } - } - - # response body for status code(s): 200 - response == { - "created_at": "2020-02-20 00:00:00", - "definition": memory_store_definition, - "id": "str", - "name": "str", - "object": "str", - "updated_at": "2020-02-20 00:00:00", - "description": "str", - "metadata": { - "str": "str" - } - } """ @distributed_trace - def update( + def modify( self, - name: str, + vector_store_id: str, body: Union[JSON, IO[bytes]] = _Unset, - description: Optional[str] = None, - metadata: Optional[dict[str, str]] = None, *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + name: Optional[str] = None, + expires_after: Optional[_models.VectorStoreExpirationPolicy] = None, + metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> _types_models1.MemoryStoreDetails: - """Update a memory store. + ) -> _models.VectorStore: + """Modifies an existing vector store. - :param name: The name of the memory store to update. Required. - :type name: str + :param vector_store_id: Identifier of the vector store. Required. + :type vector_store_id: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :param description: A human-readable description of the memory store. Default value is None. - :type description: str - :param metadata: Arbitrary key-value metadata to associate with the memory store. Default value - is None. - :type metadata: dict[str, str] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW - :return: MemoryStoreDetails - :rtype: ~azure.ai.agents.types.MemoryStoreDetails + :keyword name: The name of the vector store. Default value is None. + :paramtype name: str + :keyword expires_after: Details on when this vector store expires. Default value is None. + :paramtype expires_after: ~azure.ai.agents.models.VectorStoreExpirationPolicy + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: VectorStore. The VectorStore is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.VectorStore :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "description": "str", - "metadata": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "default": - memory_store_definition = { - "chat_model": "str", - "embedding_model": "str", - "kind": "default", - "options": { - "chat_summary_enabled": bool, - "user_profile_enabled": bool, - "user_profile_details": "str" - } - } - - # response body for status code(s): 200 - response == { - "created_at": "2020-02-20 00:00:00", - "definition": memory_store_definition, - "id": "str", - "name": "str", - "object": "str", - "updated_at": "2020-02-20 00:00:00", - "description": "str", - "metadata": { - "str": "str" - } - } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -14282,25 +4285,22 @@ def update( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models1.MemoryStoreDetails] = kwargs.pop("cls", None) + cls: ClsType[_models.VectorStore] = kwargs.pop("cls", None) if body is _Unset: - body = {"description": description, "metadata": metadata} + body = {"expires_after": expires_after, "metadata": metadata, "name": name} body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" - _json = None _content = None if isinstance(body, (IOBase, bytes)): _content = body else: - _json = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_beta_memory_stores_update_request( - name=name, - foundry_features=foundry_features, + _request = build_vector_stores_modify_request( + vector_store_id=vector_store_id, content_type=content_type, api_version=self._config.api_version, - json=_json, content=_content, headers=_headers, params=_params, @@ -14310,7 +4310,6 @@ def update( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -14325,19 +4324,13 @@ def update( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models1.ApiErrorResponse, - pipeline_response, - ) + error = _failsafe_deserialize(_models.AgentV1Error, response) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.VectorStore, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -14345,51 +4338,15 @@ def update( return deserialized # type: ignore @distributed_trace - def get( - self, name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], **kwargs: Any - ) -> _types_models1.MemoryStoreDetails: - """Retrieve a memory store. - - :param name: The name of the memory store to retrieve. Required. - :type name: str - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW - :return: MemoryStoreDetails - :rtype: ~azure.ai.agents.types.MemoryStoreDetails + def _delete_vector_store(self, vector_store_id: str, **kwargs: Any) -> _models._models.VectorStoreDeletionStatus: + """Deletes the vector store object matching the specified ID. + + :param vector_store_id: Identifier of the vector store. Required. + :type vector_store_id: str + :return: VectorStoreDeletionStatus. The VectorStoreDeletionStatus is compatible with + MutableMapping + :rtype: ~azure.ai.agents.models._models.VectorStoreDeletionStatus :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "default": - memory_store_definition = { - "chat_model": "str", - "embedding_model": "str", - "kind": "default", - "options": { - "chat_summary_enabled": bool, - "user_profile_enabled": bool, - "user_profile_details": "str" - } - } - - # response body for status code(s): 200 - response == { - "created_at": "2020-02-20 00:00:00", - "definition": memory_store_definition, - "id": "str", - "name": "str", - "object": "str", - "updated_at": "2020-02-20 00:00:00", - "description": "str", - "metadata": { - "str": "str" - } - } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -14402,11 +4359,10 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_types_models1.MemoryStoreDetails] = kwargs.pop("cls", None) + cls: ClsType[_models._models.VectorStoreDeletionStatus] = kwargs.pop("cls", None) - _request = build_beta_memory_stores_get_request( - name=name, - foundry_features=foundry_features, + _request = build_vector_stores_delete_vector_store_request( + vector_store_id=vector_store_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -14416,7 +4372,6 @@ def get( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -14431,94 +4386,76 @@ def get( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models1.ApiErrorResponse, - pipeline_response, - ) + error = _failsafe_deserialize(_models.AgentV1Error, response) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize( + _models._models.VectorStoreDeletionStatus, response.json() # pylint: disable=protected-access + ) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + +class VectorStoreFilesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.agents.AgentsClient`'s + :attr:`vector_store_files` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AgentsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, + vector_store_id: str, *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + filter: Optional[Union[str, _models.VectorStoreFileStatusFilter]] = None, limit: Optional[int] = None, - order: Optional[types.PageOrder] = None, + order: Optional[Union[str, _models.ListSortOrder]] = None, before: Optional[str] = None, **kwargs: Any - ) -> ItemPaged["_types_models1.MemoryStoreDetails"]: - """List all memory stores. - - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW + ) -> ItemPaged["_models.VectorStoreFile"]: + """Returns a list of vector store files. + + :param vector_store_id: Identifier of the vector store. Required. + :type vector_store_id: str + :keyword filter: Filter by file status. Known values are: "in_progress", "completed", "failed", + and "cancelled". Default value is None. + :paramtype filter: str or ~azure.ai.agents.models.VectorStoreFileStatusFilter :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and - 100, and the - default is 20. Default value is None. + 100, and the default is 20. Default value is None. :paramtype limit: int - :keyword order: Sort order by the ``created_at`` timestamp of the objects. ``asc`` for - ascending order and``desc`` - for descending order. Known values are: "asc" and "desc". Default value is None. - :paramtype order: str or ~azure.ai.agents.models.PageOrder - :keyword 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. - Default value is None. + :keyword order: Sort order by the created_at timestamp of the objects. asc for ascending order + and desc for descending order. Known values are: "asc" and "desc". Default value is None. + :paramtype order: str or ~azure.ai.agents.models.ListSortOrder + :keyword 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. Default value is None. :paramtype before: str - :return: An iterator like instance of MemoryStoreDetails - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.types.MemoryStoreDetails] + :return: An iterator like instance of VectorStoreFile + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.models.VectorStoreFile] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "default": - memory_store_definition = { - "chat_model": "str", - "embedding_model": "str", - "kind": "default", - "options": { - "chat_summary_enabled": bool, - "user_profile_enabled": bool, - "user_profile_details": "str" - } - } - - # response body for status code(s): 200 - response == { - "created_at": "2020-02-20 00:00:00", - "definition": memory_store_definition, - "id": "str", - "name": "str", - "object": "str", - "updated_at": "2020-02-20 00:00:00", - "description": "str", - "metadata": { - "str": "str" - } - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_types_models1.MemoryStoreDetails]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.VectorStoreFile]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -14530,8 +4467,9 @@ def list( def prepare_request(_continuation_token=None): - _request = build_beta_memory_stores_list_request( - foundry_features=foundry_features, + _request = build_vector_store_files_list_request( + vector_store_id=vector_store_id, + filter=filter, limit=limit, order=order, after=_continuation_token, @@ -14548,7 +4486,7 @@ def prepare_request(_continuation_token=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized.get("data", []) + list_of_elem = _deserialize(List[_models.VectorStoreFile], deserialized.get("data", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("last_id") or None, iter(list_of_elem) @@ -14564,40 +4502,106 @@ def get_next(_continuation_token=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models1.ApiErrorResponse, - pipeline_response, - ) + error = _failsafe_deserialize(_models.AgentV1Error, response) raise HttpResponseError(response=response, model=error) return pipeline_response return ItemPaged(get_next, extract_data) - @distributed_trace - def delete( - self, name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], **kwargs: Any - ) -> _types_models1.DeleteMemoryStoreResult: - """Delete a memory store. - - :param name: The name of the memory store to delete. Required. - :type name: str - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW - :return: DeleteMemoryStoreResult - :rtype: ~azure.ai.agents.types.DeleteMemoryStoreResult + @overload + def create( + self, + vector_store_id: str, + *, + content_type: str = "application/json", + file_id: Optional[str] = None, + data_source: Optional[_models.VectorStoreDataSource] = None, + chunking_strategy: Optional[_models.VectorStoreChunkingStrategyRequest] = None, + **kwargs: Any + ) -> _models.VectorStoreFile: + """Create a vector store file by attaching a file to a vector store. + + :param vector_store_id: Identifier of the vector store. Required. + :type vector_store_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword file_id: Identifier of the file. Default value is None. + :paramtype file_id: str + :keyword data_source: Azure asset ID. Default value is None. + :paramtype data_source: ~azure.ai.agents.models.VectorStoreDataSource + :keyword chunking_strategy: The chunking strategy used to chunk the file. If not set, uses the + auto strategy. Default value is None. + :paramtype chunking_strategy: ~azure.ai.agents.models.VectorStoreChunkingStrategyRequest + :return: VectorStoreFile. The VectorStoreFile is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.VectorStoreFile + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, vector_store_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.VectorStoreFile: + """Create a vector store file by attaching a file to a vector store. + + :param vector_store_id: Identifier of the vector store. Required. + :type vector_store_id: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: VectorStoreFile. The VectorStoreFile is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.VectorStoreFile + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, vector_store_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.VectorStoreFile: + """Create a vector store file by attaching a file to a vector store. + + :param vector_store_id: Identifier of the vector store. Required. + :type vector_store_id: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: VectorStoreFile. The VectorStoreFile is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.VectorStoreFile :raises ~azure.core.exceptions.HttpResponseError: + """ - Example: - .. code-block:: python + @distributed_trace + def create( + self, + vector_store_id: str, + body: Union[JSON, IO[bytes]] = _Unset, + *, + file_id: Optional[str] = None, + data_source: Optional[_models.VectorStoreDataSource] = None, + chunking_strategy: Optional[_models.VectorStoreChunkingStrategyRequest] = None, + **kwargs: Any + ) -> _models.VectorStoreFile: + """Create a vector store file by attaching a file to a vector store. - # response body for status code(s): 200 - response == { - "deleted": bool, - "name": "str", - "object": "str" - } + :param vector_store_id: Identifier of the vector store. Required. + :type vector_store_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword file_id: Identifier of the file. Default value is None. + :paramtype file_id: str + :keyword data_source: Azure asset ID. Default value is None. + :paramtype data_source: ~azure.ai.agents.models.VectorStoreDataSource + :keyword chunking_strategy: The chunking strategy used to chunk the file. If not set, uses the + auto strategy. Default value is None. + :paramtype chunking_strategy: ~azure.ai.agents.models.VectorStoreChunkingStrategyRequest + :return: VectorStoreFile. The VectorStoreFile is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.VectorStoreFile + :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -14607,15 +4611,27 @@ def delete( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_types_models1.DeleteMemoryStoreResult] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VectorStoreFile] = kwargs.pop("cls", None) + + if body is _Unset: + body = {"chunking_strategy": chunking_strategy, "data_source": data_source, "file_id": file_id} + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_beta_memory_stores_delete_request( - name=name, - foundry_features=foundry_features, + _request = build_vector_store_files_create_request( + vector_store_id=vector_store_id, + content_type=content_type, api_version=self._config.api_version, + content=_content, headers=_headers, params=_params, ) @@ -14624,7 +4640,6 @@ def delete( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -14639,133 +4654,30 @@ def delete( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models1.ApiErrorResponse, - pipeline_response, - ) + error = _failsafe_deserialize(_models.AgentV1Error, response) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.VectorStoreFile, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - def _search_memories( - self, - name: str, - scope: str, - items: Optional[List[dict[str, Any]]] = None, - previous_search_id: Optional[str] = None, - options: Optional[_types_models1.MemorySearchOptions] = None, - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models1.MemoryStoreSearchResult: ... - @overload - def _search_memories( - self, - name: str, - body: JSON, - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models1.MemoryStoreSearchResult: ... - @overload - def _search_memories( - self, - name: str, - body: IO[bytes], - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models1.MemoryStoreSearchResult: ... - @distributed_trace - def _search_memories( - self, - name: str, - scope: str = _Unset, - body: Union[JSON, IO[bytes]] = _Unset, - items: Optional[List[dict[str, Any]]] = None, - previous_search_id: Optional[str] = None, - options: Optional[_types_models1.MemorySearchOptions] = None, - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], - **kwargs: Any - ) -> _types_models1.MemoryStoreSearchResult: - """Search for relevant memories from a memory store based on conversation context. - - :param name: The name of the memory store to search. Required. - :type name: str - :param scope: The namespace that logically groups and isolates memories, such as a user ID. - Required. - :type scope: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :param items: Items for which to search for relevant memories. Default value is None. - :type items: list[dict[str, any]] - :param previous_search_id: The unique ID of the previous search request, enabling incremental - memory search from where the last operation left off. Default value is None. - :type previous_search_id: str - :param options: Memory search options. Default value is None. - :type options: ~azure.ai.agents.types.MemorySearchOptions - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW - :return: MemoryStoreSearchResult - :rtype: ~azure.ai.agents.types.MemoryStoreSearchResult + def get(self, vector_store_id: str, file_id: str, **kwargs: Any) -> _models.VectorStoreFile: + """Retrieves a vector store file. + + :param vector_store_id: Identifier of the vector store. Required. + :type vector_store_id: str + :param file_id: Identifier of the file. Required. + :type file_id: str + :return: VectorStoreFile. The VectorStoreFile is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.VectorStoreFile :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "scope": "str", - "items": [ - { - "str": {} - } - ], - "options": { - "max_memories": 0 - }, - "previous_search_id": "str" - } - - # response body for status code(s): 200 - response == { - "memories": [ - { - "memory_item": memory_item - } - ], - "search_id": "str", - "usage": { - "embedding_tokens": 0, - "input_tokens": 0, - "input_tokens_details": { - "cached_tokens": 0 - }, - "output_tokens": 0, - "output_tokens_details": { - "reasoning_tokens": 0 - }, - "total_tokens": 0 - } - } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -14775,32 +4687,15 @@ def _search_memories( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models1.MemoryStoreSearchResult] = kwargs.pop("cls", None) - - if body is _Unset: - if scope is _Unset: - raise TypeError("missing required argument: scope") - body = {"items": items, "options": options, "previous_search_id": previous_search_id, "scope": scope} - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _json = body + cls: ClsType[_models.VectorStoreFile] = kwargs.pop("cls", None) - _request = build_beta_memory_stores_search_memories_request( - name=name, - foundry_features=foundry_features, - content_type=content_type, + _request = build_vector_store_files_get_request( + vector_store_id=vector_store_id, + file_id=file_id, api_version=self._config.api_version, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -14809,7 +4704,6 @@ def _search_memories( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -14824,37 +4718,35 @@ def _search_memories( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models1.ApiErrorResponse, - pipeline_response, - ) + error = _failsafe_deserialize(_models.AgentV1Error, response) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.VectorStoreFile, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - def _update_memories_initial( - self, - name: str, - scope: str = _Unset, - body: Union[JSON, IO[bytes]] = _Unset, - items: Optional[List[dict[str, Any]]] = None, - previous_update_id: Optional[str] = None, - update_delay: Optional[int] = None, - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], - **kwargs: Any - ) -> Iterator[bytes]: + @distributed_trace + def _delete_vector_store_file( + self, vector_store_id: str, file_id: str, **kwargs: Any + ) -> _models._models.VectorStoreFileDeletionStatus: + """Deletes a vector store file. This removes the file‐to‐store link (does not delete the file + itself). + + :param vector_store_id: Identifier of the vector store. Required. + :type vector_store_id: str + :param file_id: Identifier of the file. Required. + :type file_id: str + :return: VectorStoreFileDeletionStatus. The VectorStoreFileDeletionStatus is compatible with + MutableMapping + :rtype: ~azure.ai.agents.models._models.VectorStoreFileDeletionStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -14863,37 +4755,15 @@ def _update_memories_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - if body is _Unset: - if scope is _Unset: - raise TypeError("missing required argument: scope") - body = { - "items": items, - "previous_update_id": previous_update_id, - "scope": scope, - "update_delay": update_delay, - } - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _json = body + cls: ClsType[_models._models.VectorStoreFileDeletionStatus] = kwargs.pop("cls", None) - _request = build_beta_memory_stores_update_memories_request( - name=name, - foundry_features=foundry_features, - content_type=content_type, + _request = build_vector_store_files_delete_vector_store_file_request( + vector_store_id=vector_store_id, + file_id=file_id, api_version=self._config.api_version, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -14902,372 +4772,146 @@ def _update_memories_initial( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models1.ApiErrorResponse, - pipeline_response, - ) + error = _failsafe_deserialize(_models.AgentV1Error, response) raise HttpResponseError(response=response, model=error) - response_headers = {} - response_headers["Operation-Location"] = self._deserialize("str", response.headers.get("Operation-Location")) - - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize( + _models._models.VectorStoreFileDeletionStatus, response.json() # pylint: disable=protected-access + ) if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - def _begin_update_memories( - self, - name: str, - scope: str, - items: Optional[List[dict[str, Any]]] = None, - previous_update_id: Optional[str] = None, - update_delay: Optional[int] = None, - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_types_models1.MemoryStoreUpdateCompletedResult]: ... - @overload - def _begin_update_memories( - self, - name: str, - body: JSON, - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_types_models1.MemoryStoreUpdateCompletedResult]: ... - @overload - def _begin_update_memories( - self, - name: str, - body: IO[bytes], - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_types_models1.MemoryStoreUpdateCompletedResult]: ... - - @distributed_trace - def _begin_update_memories( - self, - name: str, - scope: str = _Unset, - body: Union[JSON, IO[bytes]] = _Unset, - items: Optional[List[dict[str, Any]]] = None, - previous_update_id: Optional[str] = None, - update_delay: Optional[int] = None, - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], - **kwargs: Any - ) -> LROPoller[_types_models1.MemoryStoreUpdateCompletedResult]: - """Update memory store with conversation memories. - - :param name: The name of the memory store to update. Required. - :type name: str - :param scope: The namespace that logically groups and isolates memories, such as a user ID. - Required. - :type scope: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :param items: Conversation items to be stored in memory. Default value is None. - :type items: list[dict[str, any]] - :param previous_update_id: The unique ID of the previous update request, enabling incremental - memory updates from where the last operation left off. Default value is None. - :type previous_update_id: str - :param update_delay: Timeout period before processing the memory update in seconds. - If a new update request is received during this period, it will cancel the current request and - reset the timeout. - Set to 0 to immediately trigger the update without delay. - Defaults to 300 (5 minutes). Default value is None. - :type update_delay: int - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW - :return: An instance of LROPoller that returns MemoryStoreUpdateCompletedResult - :rtype: ~azure.core.polling.LROPoller[~azure.ai.agents.types.MemoryStoreUpdateCompletedResult] - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "scope": "str", - "items": [ - { - "str": {} - } - ], - "previous_update_id": "str", - "update_delay": 0 - } - - # response body for status code(s): 202 - response == { - "memory_operations": [ - { - "kind": "str", - "memory_item": memory_item - } - ], - "usage": { - "embedding_tokens": 0, - "input_tokens": 0, - "input_tokens_details": { - "cached_tokens": 0 - }, - "output_tokens": 0, - "output_tokens_details": { - "reasoning_tokens": 0 - }, - "total_tokens": 0 - } - } - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models1.MemoryStoreUpdateCompletedResult] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_memories_initial( - name=name, - scope=scope, - body=body, - items=items, - previous_update_id=previous_update_id, - update_delay=update_delay, - foundry_features=foundry_features, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Operation-Location"] = self._deserialize( - "str", response.headers.get("Operation-Location") - ) - if response.content: - deserialized = response.json() - else: - deserialized = None - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized +class VectorStoreFileBatchesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } + Instead, you should access the following operations through + :class:`~azure.ai.agents.AgentsClient`'s + :attr:`vector_store_file_batches` attribute. + """ - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, LROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_types_models.MemoryStoreUpdateCompletedResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_types_models.MemoryStoreUpdateCompletedResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AgentsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @overload - def delete_scope( + def create( self, - name: str, - scope: str, + vector_store_id: str, *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], content_type: str = "application/json", + file_ids: Optional[List[str]] = None, + data_sources: Optional[List[_models.VectorStoreDataSource]] = None, + chunking_strategy: Optional[_models.VectorStoreChunkingStrategyRequest] = None, **kwargs: Any - ) -> _types_models1.MemoryStoreDeleteScopeResult: - """Delete all memories associated with a specific scope from a memory store. - - :param name: The name of the memory store. Required. - :type name: str - :param scope: The namespace that logically groups and isolates memories to delete, such as a - user ID. Required. - :type scope: str - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW + ) -> _models.VectorStoreFileBatch: + """Create a vector store file batch. + + :param vector_store_id: Identifier of the vector store. Required. + :type vector_store_id: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: MemoryStoreDeleteScopeResult - :rtype: ~azure.ai.agents.types.MemoryStoreDeleteScopeResult + :keyword file_ids: List of file identifiers. Default value is None. + :paramtype file_ids: list[str] + :keyword data_sources: List of Azure assets. Default value is None. + :paramtype data_sources: list[~azure.ai.agents.models.VectorStoreDataSource] + :keyword chunking_strategy: The chunking strategy used to chunk the file(s). If not set, will + use the auto strategy. Default value is None. + :paramtype chunking_strategy: ~azure.ai.agents.models.VectorStoreChunkingStrategyRequest + :return: VectorStoreFileBatch. The VectorStoreFileBatch is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.VectorStoreFileBatch :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "deleted": bool, - "name": "str", - "object": "str", - "scope": "str" - } """ @overload - def delete_scope( - self, - name: str, - body: JSON, - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models1.MemoryStoreDeleteScopeResult: - """Delete all memories associated with a specific scope from a memory store. + def create( + self, vector_store_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.VectorStoreFileBatch: + """Create a vector store file batch. - :param name: The name of the memory store. Required. - :type name: str + :param vector_store_id: Identifier of the vector store. Required. + :type vector_store_id: str :param body: Required. :type body: JSON - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: MemoryStoreDeleteScopeResult - :rtype: ~azure.ai.agents.types.MemoryStoreDeleteScopeResult + :return: VectorStoreFileBatch. The VectorStoreFileBatch is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.VectorStoreFileBatch :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "scope": "str" - } - - # response body for status code(s): 200 - response == { - "deleted": bool, - "name": "str", - "object": "str", - "scope": "str" - } """ @overload - def delete_scope( - self, - name: str, - body: IO[bytes], - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models1.MemoryStoreDeleteScopeResult: - """Delete all memories associated with a specific scope from a memory store. + def create( + self, vector_store_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.VectorStoreFileBatch: + """Create a vector store file batch. - :param name: The name of the memory store. Required. - :type name: str + :param vector_store_id: Identifier of the vector store. Required. + :type vector_store_id: str :param body: Required. :type body: IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: MemoryStoreDeleteScopeResult - :rtype: ~azure.ai.agents.types.MemoryStoreDeleteScopeResult + :return: VectorStoreFileBatch. The VectorStoreFileBatch is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.VectorStoreFileBatch :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "deleted": bool, - "name": "str", - "object": "str", - "scope": "str" - } """ @distributed_trace - def delete_scope( + def create( self, - name: str, - scope: str = _Unset, + vector_store_id: str, body: Union[JSON, IO[bytes]] = _Unset, *, - foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + file_ids: Optional[List[str]] = None, + data_sources: Optional[List[_models.VectorStoreDataSource]] = None, + chunking_strategy: Optional[_models.VectorStoreChunkingStrategyRequest] = None, **kwargs: Any - ) -> _types_models1.MemoryStoreDeleteScopeResult: - """Delete all memories associated with a specific scope from a memory store. - - :param name: The name of the memory store. Required. - :type name: str - :param scope: The namespace that logically groups and isolates memories to delete, such as a - user ID. Required. - :type scope: str + ) -> _models.VectorStoreFileBatch: + """Create a vector store file batch. + + :param vector_store_id: Identifier of the vector store. Required. + :type vector_store_id: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. MEMORY_STORES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.MEMORY_STORES_V1_PREVIEW - :return: MemoryStoreDeleteScopeResult - :rtype: ~azure.ai.agents.types.MemoryStoreDeleteScopeResult + :keyword file_ids: List of file identifiers. Default value is None. + :paramtype file_ids: list[str] + :keyword data_sources: List of Azure assets. Default value is None. + :paramtype data_sources: list[~azure.ai.agents.models.VectorStoreDataSource] + :keyword chunking_strategy: The chunking strategy used to chunk the file(s). If not set, will + use the auto strategy. Default value is None. + :paramtype chunking_strategy: ~azure.ai.agents.models.VectorStoreChunkingStrategyRequest + :return: VectorStoreFileBatch. The VectorStoreFileBatch is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.VectorStoreFileBatch :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "scope": "str" - } - - # response body for status code(s): 200 - response == { - "deleted": bool, - "name": "str", - "object": "str", - "scope": "str" - } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -15281,27 +4925,22 @@ def delete_scope( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models1.MemoryStoreDeleteScopeResult] = kwargs.pop("cls", None) + cls: ClsType[_models.VectorStoreFileBatch] = kwargs.pop("cls", None) if body is _Unset: - if scope is _Unset: - raise TypeError("missing required argument: scope") - body = {"scope": scope} + body = {"chunking_strategy": chunking_strategy, "data_sources": data_sources, "file_ids": file_ids} body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" - _json = None _content = None if isinstance(body, (IOBase, bytes)): _content = body else: - _json = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_beta_memory_stores_delete_scope_request( - name=name, - foundry_features=foundry_features, + _request = build_vector_store_file_batches_create_request( + vector_store_id=vector_store_id, content_type=content_type, api_version=self._config.api_version, - json=_json, content=_content, headers=_headers, params=_params, @@ -15311,7 +4950,6 @@ def delete_scope( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -15326,92 +4964,30 @@ def delete_scope( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models1.ApiErrorResponse, - pipeline_response, - ) + error = _failsafe_deserialize(_models.AgentV1Error, response) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.VectorStoreFileBatch, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - -class BetaRedTeamsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.agents.AIProjectClient`'s - :attr:`red_teams` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def get( - self, name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.RED_TEAMS_V1_PREVIEW], **kwargs: Any - ) -> _types_models1.RedTeam: - """Get a redteam by name. - - :param name: Identifier of the red team run. Required. - :type name: str - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. RED_TEAMS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.RED_TEAMS_V1_PREVIEW - :return: RedTeam - :rtype: ~azure.ai.agents.types.RedTeam + def get(self, vector_store_id: str, batch_id: str, **kwargs: Any) -> _models.VectorStoreFileBatch: + """Retrieve a vector store file batch. + + :param vector_store_id: Identifier of the vector store. Required. + :type vector_store_id: str + :param batch_id: Identifier of the file batch. Required. + :type batch_id: str + :return: VectorStoreFileBatch. The VectorStoreFileBatch is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.VectorStoreFileBatch :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AzureOpenAIModel": - target_config = { - "modelDeploymentName": "str", - "type": "AzureOpenAIModel" - } - - # response body for status code(s): 200 - response == { - "id": "str", - "target": target_config, - "applicationScenario": "str", - "attackStrategies": [ - "str" - ], - "displayName": "str", - "numTurns": 0, - "properties": { - "str": "str" - }, - "riskCategories": [ - "str" - ], - "simulationOnly": bool, - "status": "str", - "tags": { - "str": "str" - } - } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -15424,11 +5000,11 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_types_models1.RedTeam] = kwargs.pop("cls", None) + cls: ClsType[_models.VectorStoreFileBatch] = kwargs.pop("cls", None) - _request = build_beta_red_teams_get_request( - name=name, - foundry_features=foundry_features, + _request = build_vector_store_file_batches_get_request( + vector_store_id=vector_store_id, + batch_id=batch_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -15438,7 +5014,6 @@ def get( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -15453,15 +5028,13 @@ def get( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.VectorStoreFileBatch, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -15469,366 +5042,17 @@ def get( return deserialized # type: ignore @distributed_trace - def list( - self, *, foundry_features: Literal[FoundryFeaturesOptInKeys.RED_TEAMS_V1_PREVIEW], **kwargs: Any - ) -> ItemPaged["_types_models1.RedTeam"]: - """List a redteam by name. - - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. RED_TEAMS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.RED_TEAMS_V1_PREVIEW - :return: An iterator like instance of RedTeam - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.types.RedTeam] - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AzureOpenAIModel": - target_config = { - "modelDeploymentName": "str", - "type": "AzureOpenAIModel" - } - - # response body for status code(s): 200 - response == { - "id": "str", - "target": target_config, - "applicationScenario": "str", - "attackStrategies": [ - "str" - ], - "displayName": "str", - "numTurns": 0, - "properties": { - "str": "str" - }, - "riskCategories": [ - "str" - ], - "simulationOnly": bool, - "status": "str", - "tags": { - "str": "str" - } - } - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_types_models1.RedTeam]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_beta_red_teams_list_request( - foundry_features=foundry_features, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized.get("value", []) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @overload - def create( - self, - red_team: _types_models1.RedTeam, - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.RED_TEAMS_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models1.RedTeam: - """Creates a redteam run. - - :param red_team: Redteam to be run. Required. - :type red_team: ~azure.ai.agents.types.RedTeam - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. RED_TEAMS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.RED_TEAMS_V1_PREVIEW - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: RedTeam - :rtype: ~azure.ai.agents.types.RedTeam - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "type": - - # JSON input template for discriminator value "AzureOpenAIModel": - target_config = { - "modelDeploymentName": "str", - "type": "AzureOpenAIModel" - } - - # JSON input template you can fill out and use as your body input. - red_team = { - "id": "str", - "target": target_config, - "applicationScenario": "str", - "attackStrategies": [ - "str" - ], - "displayName": "str", - "numTurns": 0, - "properties": { - "str": "str" - }, - "riskCategories": [ - "str" - ], - "simulationOnly": bool, - "status": "str", - "tags": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AzureOpenAIModel": - target_config = { - "modelDeploymentName": "str", - "type": "AzureOpenAIModel" - } - - # response body for status code(s): 201 - response == { - "id": "str", - "target": target_config, - "applicationScenario": "str", - "attackStrategies": [ - "str" - ], - "displayName": "str", - "numTurns": 0, - "properties": { - "str": "str" - }, - "riskCategories": [ - "str" - ], - "simulationOnly": bool, - "status": "str", - "tags": { - "str": "str" - } - } - """ - - @overload - def create( - self, - red_team: IO[bytes], - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.RED_TEAMS_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models1.RedTeam: - """Creates a redteam run. - - :param red_team: Redteam to be run. Required. - :type red_team: IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. RED_TEAMS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.RED_TEAMS_V1_PREVIEW - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: RedTeam - :rtype: ~azure.ai.agents.types.RedTeam - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AzureOpenAIModel": - target_config = { - "modelDeploymentName": "str", - "type": "AzureOpenAIModel" - } - - # response body for status code(s): 201 - response == { - "id": "str", - "target": target_config, - "applicationScenario": "str", - "attackStrategies": [ - "str" - ], - "displayName": "str", - "numTurns": 0, - "properties": { - "str": "str" - }, - "riskCategories": [ - "str" - ], - "simulationOnly": bool, - "status": "str", - "tags": { - "str": "str" - } - } - """ - - @distributed_trace - def create( - self, - red_team: Union[_types_models1.RedTeam, IO[bytes]], - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.RED_TEAMS_V1_PREVIEW], - **kwargs: Any - ) -> _types_models1.RedTeam: - """Creates a redteam run. - - :param red_team: Redteam to be run. Is either a RedTeam type or a IO[bytes] type. Required. - :type red_team: ~azure.ai.agents.types.RedTeam or IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. RED_TEAMS_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.RED_TEAMS_V1_PREVIEW - :return: RedTeam - :rtype: ~azure.ai.agents.types.RedTeam + def cancel(self, vector_store_id: str, batch_id: str, **kwargs: Any) -> _models.VectorStoreFileBatch: + """Cancel a vector store file batch. This attempts to cancel the processing of files in this batch + as soon as possible. + + :param vector_store_id: Identifier of the vector store. Required. + :type vector_store_id: str + :param batch_id: Identifier of the file batch. Required. + :type batch_id: str + :return: VectorStoreFileBatch. The VectorStoreFileBatch is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.VectorStoreFileBatch :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "type": - - # JSON input template for discriminator value "AzureOpenAIModel": - target_config = { - "modelDeploymentName": "str", - "type": "AzureOpenAIModel" - } - - # JSON input template you can fill out and use as your body input. - red_team = { - "id": "str", - "target": target_config, - "applicationScenario": "str", - "attackStrategies": [ - "str" - ], - "displayName": "str", - "numTurns": 0, - "properties": { - "str": "str" - }, - "riskCategories": [ - "str" - ], - "simulationOnly": bool, - "status": "str", - "tags": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "AzureOpenAIModel": - target_config = { - "modelDeploymentName": "str", - "type": "AzureOpenAIModel" - } - - # response body for status code(s): 201 - response == { - "id": "str", - "target": target_config, - "applicationScenario": "str", - "attackStrategies": [ - "str" - ], - "displayName": "str", - "numTurns": 0, - "properties": { - "str": "str" - }, - "riskCategories": [ - "str" - ], - "simulationOnly": bool, - "status": "str", - "tags": { - "str": "str" - } - } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -15838,26 +5062,15 @@ def create( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models1.RedTeam] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(red_team, (IOBase, bytes)): - _content = red_team - else: - _json = red_team + cls: ClsType[_models.VectorStoreFileBatch] = kwargs.pop("cls", None) - _request = build_beta_red_teams_create_request( - foundry_features=foundry_features, - content_type=content_type, + _request = build_vector_store_file_batches_cancel_request( + vector_store_id=vector_store_id, + batch_id=batch_id, api_version=self._config.api_version, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -15866,7 +5079,6 @@ def create( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -15874,69 +5086,67 @@ def create( response = pipeline_response.http_response - if response.status_code not in [201]: + if response.status_code not in [200]: if _stream: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models1.ApiErrorResponse, - pipeline_response, - ) + error = _failsafe_deserialize(_models.AgentV1Error, response) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.VectorStoreFileBatch, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - -class BetaSchedulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.agents.AIProjectClient`'s - :attr:`schedules` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements + def list_files( self, - schedule_id: str, + vector_store_id: str, + batch_id: str, *, - foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], + filter: Optional[Union[str, _models.VectorStoreFileStatusFilter]] = None, + limit: Optional[int] = None, + order: Optional[Union[str, _models.ListSortOrder]] = None, + before: Optional[str] = None, **kwargs: Any - ) -> None: - """Delete a schedule. - - :param schedule_id: Identifier of the schedule. Required. - :type schedule_id: str - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. SCHEDULES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.SCHEDULES_V1_PREVIEW - :return: None - :rtype: None + ) -> ItemPaged["_models.VectorStoreFile"]: + """Returns a list of vector store files in a batch. + + :param vector_store_id: Identifier of the vector store. Required. + :type vector_store_id: str + :param batch_id: Identifier of the file batch. Required. + :type batch_id: str + :keyword filter: Filter by file status. Known values are: "in_progress", "completed", "failed", + and "cancelled". Default value is None. + :paramtype filter: str or ~azure.ai.agents.models.VectorStoreFileStatusFilter + :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and + 100, and the default is 20. Default value is None. + :paramtype limit: int + :keyword order: Sort order by the created_at timestamp of the objects. asc for ascending order + and desc for descending order. Known values are: "asc" and "desc". Default value is None. + :paramtype order: str or ~azure.ai.agents.models.ListSortOrder + :keyword 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. Default value is None. + :paramtype before: str + :return: An iterator like instance of VectorStoreFile + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.models.VectorStoreFile] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.VectorStoreFile]] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -15945,120 +5155,209 @@ def delete( # pylint: disable=inconsistent-return-statements } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} + def prepare_request(_continuation_token=None): - cls: ClsType[None] = kwargs.pop("cls", None) + _request = build_vector_store_file_batches_list_files_request( + vector_store_id=vector_store_id, + batch_id=batch_id, + filter=filter, + limit=limit, + order=order, + after=_continuation_token, + before=before, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request - _request = build_beta_schedules_delete_request( - schedule_id=schedule_id, - foundry_features=foundry_features, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.VectorStoreFile], deserialized.get("data", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("last_id") or None, iter(list_of_elem) - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + def get_next(_continuation_token=None): + _request = prepare_request(_continuation_token) - response = pipeline_response.http_response + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) - if cls: - return cls(pipeline_response, None, {}) # type: ignore + return pipeline_response - @distributed_trace - def get( + return ItemPaged(get_next, extract_data) + + +class _AgentsClientOperationsMixin( + ClientMixinABC[PipelineClient[HttpRequest, HttpResponse], AgentsClientConfiguration] +): + + @overload + def create_agent( self, - schedule_id: str, *, - foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], + model: str, + content_type: str = "application/json", + name: Optional[str] = None, + description: Optional[str] = None, + instructions: Optional[str] = None, + tools: Optional[List[_models.ToolDefinition]] = None, + tool_resources: Optional[_models.ToolResources] = None, + temperature: Optional[float] = None, + top_p: Optional[float] = None, + response_format: Optional["_types.AgentsResponseFormatOption"] = None, + metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> _types_models1.Schedule: - """Get a schedule by id. - - :param schedule_id: Identifier of the schedule. Required. - :type schedule_id: str - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. SCHEDULES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.SCHEDULES_V1_PREVIEW - :return: Schedule - :rtype: ~azure.ai.agents.types.Schedule + ) -> _models.Agent: + """Creates a new agent. + + :keyword model: The ID of the model to use. Required. + :paramtype model: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword name: The name of the new agent. Default value is None. + :paramtype name: str + :keyword description: The description of the new agent. Default value is None. + :paramtype description: str + :keyword instructions: The system instructions for the new agent to use. Default value is None. + :paramtype instructions: str + :keyword tools: The collection of tools to enable for the new agent. Default value is None. + :paramtype tools: list[~azure.ai.agents.models.ToolDefinition] + :keyword tool_resources: 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. Default value is None. + :paramtype tool_resources: ~azure.ai.agents.models.ToolResources + :keyword temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 + will make the output more random, + while lower values like 0.2 will make it more focused and deterministic. Default value is + None. + :paramtype temperature: float + :keyword top_p: An alternative to sampling with temperature, called nucleus sampling, where the + model considers the results of the tokens with top_p probability mass. + So 0.1 means only the tokens comprising the top 10% probability mass are considered. + + We generally recommend altering this or temperature but not both. Default value is None. + :paramtype top_p: float + :keyword response_format: The response format of the tool calls used by this agent. Is one of + the following types: str, Union[str, "_models.AgentsResponseFormatMode"], AgentsResponseFormat, + ResponseFormatJsonSchemaType Default value is None. + :paramtype response_format: str or str or ~azure.ai.agents.models.AgentsResponseFormatMode or + ~azure.ai.agents.models.AgentsResponseFormat or + ~azure.ai.agents.models.ResponseFormatJsonSchemaType + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: Agent. The Agent is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.Agent + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_agent(self, body: JSON, *, content_type: str = "application/json", **kwargs: Any) -> _models.Agent: + """Creates a new agent. + + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Agent. The Agent is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.Agent + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_agent(self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any) -> _models.Agent: + """Creates a new agent. + + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: Agent. The Agent is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.Agent :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_agent( + self, + body: Union[JSON, IO[bytes]] = _Unset, + *, + model: str = _Unset, + name: Optional[str] = None, + description: Optional[str] = None, + instructions: Optional[str] = None, + tools: Optional[List[_models.ToolDefinition]] = None, + tool_resources: Optional[_models.ToolResources] = None, + temperature: Optional[float] = None, + top_p: Optional[float] = None, + response_format: Optional["_types.AgentsResponseFormatOption"] = None, + metadata: Optional[dict[str, str]] = None, + **kwargs: Any + ) -> _models.Agent: + """Creates a new agent. - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "Cron": - trigger = { - "expression": "str", - "type": "Cron", - "endTime": "2020-02-20 00:00:00", - "startTime": "2020-02-20 00:00:00", - "timeZone": "str" - } - - # JSON input template for discriminator value "OneTime": - trigger = { - "triggerAt": "2020-02-20 00:00:00", - "type": "OneTime", - "timeZone": "str" - } - - # JSON input template for discriminator value "Recurrence": - trigger = { - "interval": 0, - "schedule": recurrence_schedule, - "type": "Recurrence", - "endTime": "2020-02-20 00:00:00", - "startTime": "2020-02-20 00:00:00", - "timeZone": "str" - } - - # JSON input template for discriminator value "Daily": - recurrence_schedule = { - "hours": [ - 0 - ], - "type": "Daily" - } - - # JSON input template for discriminator value "Hourly": - recurrence_schedule = { - "type": "Hourly" - } - - # response body for status code(s): 200 - response == { - "enabled": bool, - "id": "str", - "systemData": { - "str": "str" - }, - "task": schedule_task, - "trigger": trigger, - "description": "str", - "displayName": "str", - "properties": { - "str": "str" - }, - "provisioningStatus": "str", - "tags": { - "str": "str" - } - } + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword model: The ID of the model to use. Required. + :paramtype model: str + :keyword name: The name of the new agent. Default value is None. + :paramtype name: str + :keyword description: The description of the new agent. Default value is None. + :paramtype description: str + :keyword instructions: The system instructions for the new agent to use. Default value is None. + :paramtype instructions: str + :keyword tools: The collection of tools to enable for the new agent. Default value is None. + :paramtype tools: list[~azure.ai.agents.models.ToolDefinition] + :keyword tool_resources: 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. Default value is None. + :paramtype tool_resources: ~azure.ai.agents.models.ToolResources + :keyword temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 + will make the output more random, + while lower values like 0.2 will make it more focused and deterministic. Default value is + None. + :paramtype temperature: float + :keyword top_p: An alternative to sampling with temperature, called nucleus sampling, where the + model considers the results of the tokens with top_p probability mass. + So 0.1 means only the tokens comprising the top 10% probability mass are considered. + + We generally recommend altering this or temperature but not both. Default value is None. + :paramtype top_p: float + :keyword response_format: The response format of the tool calls used by this agent. Is one of + the following types: str, Union[str, "_models.AgentsResponseFormatMode"], AgentsResponseFormat, + ResponseFormatJsonSchemaType Default value is None. + :paramtype response_format: str or str or ~azure.ai.agents.models.AgentsResponseFormatMode or + ~azure.ai.agents.models.AgentsResponseFormat or + ~azure.ai.agents.models.ResponseFormatJsonSchemaType + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: Agent. The Agent is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.Agent + :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -16068,15 +5367,39 @@ def get( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_types_models1.Schedule] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Agent] = kwargs.pop("cls", None) + + if body is _Unset: + if model is _Unset: + raise TypeError("missing required argument: model") + body = { + "description": description, + "instructions": instructions, + "metadata": metadata, + "model": model, + "name": name, + "response_format": response_format, + "temperature": temperature, + "tool_resources": tool_resources, + "tools": tools, + "top_p": top_p, + } + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_beta_schedules_get_request( - schedule_id=schedule_id, - foundry_features=foundry_features, + _request = build_agents_create_agent_request( + content_type=content_type, api_version=self._config.api_version, + content=_content, headers=_headers, params=_params, ) @@ -16085,7 +5408,6 @@ def get( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -16100,15 +5422,13 @@ def get( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.Agent, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -16116,97 +5436,35 @@ def get( return deserialized # type: ignore @distributed_trace - def list( + def list_agents( self, *, - foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], - type: Optional[types.ScheduleTaskType] = None, - enabled: Optional[bool] = None, + limit: Optional[int] = None, + order: Optional[Union[str, _models.ListSortOrder]] = None, + before: Optional[str] = None, **kwargs: Any - ) -> ItemPaged["_types_models1.Schedule"]: - """List all schedules. + ) -> ItemPaged["_models.Agent"]: + """Gets a list of agents that were previously created. - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. SCHEDULES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.SCHEDULES_V1_PREVIEW - :keyword type: Filter by the type of schedule. Known values are: "Evaluation" and "Insight". - Default value is None. - :paramtype type: str or ~azure.ai.agents.models.ScheduleTaskType - :keyword enabled: Filter by the enabled status. Default value is None. - :paramtype enabled: bool - :return: An iterator like instance of Schedule - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.types.Schedule] + :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and + 100, and the default is 20. Default value is None. + :paramtype limit: int + :keyword order: Sort order by the created_at timestamp of the objects. asc for ascending order + and desc for descending order. Known values are: "asc" and "desc". Default value is None. + :paramtype order: str or ~azure.ai.agents.models.ListSortOrder + :keyword 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. Default value is None. + :paramtype before: str + :return: An iterator like instance of Agent + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.models.Agent] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "Cron": - trigger = { - "expression": "str", - "type": "Cron", - "endTime": "2020-02-20 00:00:00", - "startTime": "2020-02-20 00:00:00", - "timeZone": "str" - } - - # JSON input template for discriminator value "OneTime": - trigger = { - "triggerAt": "2020-02-20 00:00:00", - "type": "OneTime", - "timeZone": "str" - } - - # JSON input template for discriminator value "Recurrence": - trigger = { - "interval": 0, - "schedule": recurrence_schedule, - "type": "Recurrence", - "endTime": "2020-02-20 00:00:00", - "startTime": "2020-02-20 00:00:00", - "timeZone": "str" - } - - # JSON input template for discriminator value "Daily": - recurrence_schedule = { - "hours": [ - 0 - ], - "type": "Daily" - } - - # JSON input template for discriminator value "Hourly": - recurrence_schedule = { - "type": "Hourly" - } - - # response body for status code(s): 200 - response == { - "enabled": bool, - "id": "str", - "systemData": { - "str": "str" - }, - "task": schedule_task, - "trigger": trigger, - "description": "str", - "displayName": "str", - "properties": { - "str": "str" - }, - "provisioningStatus": "str", - "tags": { - "str": "str" - } - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_types_models1.Schedule]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.Agent]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -16216,58 +5474,32 @@ def list( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - _request = build_beta_schedules_list_request( - foundry_features=foundry_features, - type=type, - enabled=enabled, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + def prepare_request(_continuation_token=None): + _request = build_agents_list_agents_request( + limit=limit, + order=order, + after=_continuation_token, + before=before, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) return _request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized.get("value", []) + list_of_elem = _deserialize(List[_models.Agent], deserialized.get("data", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) + return deserialized.get("last_id") or None, iter(list_of_elem) - def get_next(next_link=None): - _request = prepare_request(next_link) + def get_next(_continuation_token=None): + _request = prepare_request(_continuation_token) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access @@ -16277,533 +5509,245 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) return pipeline_response return ItemPaged(get_next, extract_data) + @distributed_trace + def get_agent(self, agent_id: str, **kwargs: Any) -> _models.Agent: + """Retrieves an existing agent. + + :param agent_id: Identifier of the agent. Required. + :type agent_id: str + :return: Agent. The Agent is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.Agent + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Agent] = kwargs.pop("cls", None) + + _request = build_agents_get_agent_request( + agent_id=agent_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Agent, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + @overload - def create_or_update( + def update_agent( self, - schedule_id: str, - schedule: _types_models1.Schedule, + agent_id: str, *, - foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], content_type: str = "application/json", + model: Optional[str] = None, + name: Optional[str] = None, + description: Optional[str] = None, + instructions: Optional[str] = None, + tools: Optional[List[_models.ToolDefinition]] = None, + tool_resources: Optional[_models.ToolResources] = None, + temperature: Optional[float] = None, + top_p: Optional[float] = None, + response_format: Optional["_types.AgentsResponseFormatOption"] = None, + metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> _types_models1.Schedule: - """Create or update operation template. - - :param schedule_id: Identifier of the schedule. Required. - :type schedule_id: str - :param schedule: The resource instance. Required. - :type schedule: ~azure.ai.agents.types.Schedule - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. SCHEDULES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.SCHEDULES_V1_PREVIEW + ) -> _models.Agent: + """Modifies an existing agent. + + :param agent_id: The ID of the agent to modify. Required. + :type agent_id: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: Schedule - :rtype: ~azure.ai.agents.types.Schedule + :keyword model: The ID of the model to use. Default value is None. + :paramtype model: str + :keyword name: The modified name for the agent to use. Default value is None. + :paramtype name: str + :keyword description: The modified description for the agent to use. Default value is None. + :paramtype description: str + :keyword instructions: The modified system instructions for the new agent to use. Default value + is None. + :paramtype instructions: str + :keyword tools: The modified collection of tools to enable for the agent. Default value is + None. + :paramtype tools: list[~azure.ai.agents.models.ToolDefinition] + :keyword tool_resources: 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. Default value is None. + :paramtype tool_resources: ~azure.ai.agents.models.ToolResources + :keyword temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 + will make the output more random, + while lower values like 0.2 will make it more focused and deterministic. Default value is + None. + :paramtype temperature: float + :keyword top_p: An alternative to sampling with temperature, called nucleus sampling, where the + model considers the results of the tokens with top_p probability mass. + So 0.1 means only the tokens comprising the top 10% probability mass are considered. + + We generally recommend altering this or temperature but not both. Default value is None. + :paramtype top_p: float + :keyword response_format: The response format of the tool calls used by this agent. Is one of + the following types: str, Union[str, "_models.AgentsResponseFormatMode"], AgentsResponseFormat, + ResponseFormatJsonSchemaType Default value is None. + :paramtype response_format: str or str or ~azure.ai.agents.models.AgentsResponseFormatMode or + ~azure.ai.agents.models.AgentsResponseFormat or + ~azure.ai.agents.models.ResponseFormatJsonSchemaType + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: Agent. The Agent is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.Agent :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_agent( + self, agent_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.Agent: + """Modifies an existing agent. - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "type": - - # JSON input template for discriminator value "Cron": - trigger = { - "expression": "str", - "type": "Cron", - "endTime": "2020-02-20 00:00:00", - "startTime": "2020-02-20 00:00:00", - "timeZone": "str" - } - - # JSON input template for discriminator value "OneTime": - trigger = { - "triggerAt": "2020-02-20 00:00:00", - "type": "OneTime", - "timeZone": "str" - } - - # JSON input template for discriminator value "Recurrence": - trigger = { - "interval": 0, - "schedule": recurrence_schedule, - "type": "Recurrence", - "endTime": "2020-02-20 00:00:00", - "startTime": "2020-02-20 00:00:00", - "timeZone": "str" - } - - # JSON input template for discriminator value "Daily": - recurrence_schedule = { - "hours": [ - 0 - ], - "type": "Daily" - } - - # JSON input template for discriminator value "Hourly": - recurrence_schedule = { - "type": "Hourly" - } - - # JSON input template you can fill out and use as your body input. - schedule = { - "enabled": bool, - "id": "str", - "systemData": { - "str": "str" - }, - "task": schedule_task, - "trigger": trigger, - "description": "str", - "displayName": "str", - "properties": { - "str": "str" - }, - "provisioningStatus": "str", - "tags": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "Cron": - trigger = { - "expression": "str", - "type": "Cron", - "endTime": "2020-02-20 00:00:00", - "startTime": "2020-02-20 00:00:00", - "timeZone": "str" - } - - # JSON input template for discriminator value "OneTime": - trigger = { - "triggerAt": "2020-02-20 00:00:00", - "type": "OneTime", - "timeZone": "str" - } - - # JSON input template for discriminator value "Recurrence": - trigger = { - "interval": 0, - "schedule": recurrence_schedule, - "type": "Recurrence", - "endTime": "2020-02-20 00:00:00", - "startTime": "2020-02-20 00:00:00", - "timeZone": "str" - } - - # JSON input template for discriminator value "Daily": - recurrence_schedule = { - "hours": [ - 0 - ], - "type": "Daily" - } - - # JSON input template for discriminator value "Hourly": - recurrence_schedule = { - "type": "Hourly" - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "Cron": - trigger = { - "expression": "str", - "type": "Cron", - "endTime": "2020-02-20 00:00:00", - "startTime": "2020-02-20 00:00:00", - "timeZone": "str" - } - - # JSON input template for discriminator value "OneTime": - trigger = { - "triggerAt": "2020-02-20 00:00:00", - "type": "OneTime", - "timeZone": "str" - } - - # JSON input template for discriminator value "Recurrence": - trigger = { - "interval": 0, - "schedule": recurrence_schedule, - "type": "Recurrence", - "endTime": "2020-02-20 00:00:00", - "startTime": "2020-02-20 00:00:00", - "timeZone": "str" - } - - # JSON input template for discriminator value "Daily": - recurrence_schedule = { - "hours": [ - 0 - ], - "type": "Daily" - } - - # JSON input template for discriminator value "Hourly": - recurrence_schedule = { - "type": "Hourly" - } - - # response body for status code(s): 201, 200 - response == { - "enabled": bool, - "id": "str", - "systemData": { - "str": "str" - }, - "task": schedule_task, - "trigger": trigger, - "description": "str", - "displayName": "str", - "properties": { - "str": "str" - }, - "provisioningStatus": "str", - "tags": { - "str": "str" - } - } + :param agent_id: The ID of the agent to modify. Required. + :type agent_id: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Agent. The Agent is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.Agent + :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def create_or_update( - self, - schedule_id: str, - schedule: IO[bytes], - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], - content_type: str = "application/json", - **kwargs: Any - ) -> _types_models1.Schedule: - """Create or update operation template. - - :param schedule_id: Identifier of the schedule. Required. - :type schedule_id: str - :param schedule: The resource instance. Required. - :type schedule: IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. SCHEDULES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.SCHEDULES_V1_PREVIEW + def update_agent( + self, agent_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.Agent: + """Modifies an existing agent. + + :param agent_id: The ID of the agent to modify. Required. + :type agent_id: str + :param body: Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: Schedule - :rtype: ~azure.ai.agents.types.Schedule + :return: Agent. The Agent is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.Agent :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "Cron": - trigger = { - "expression": "str", - "type": "Cron", - "endTime": "2020-02-20 00:00:00", - "startTime": "2020-02-20 00:00:00", - "timeZone": "str" - } - - # JSON input template for discriminator value "OneTime": - trigger = { - "triggerAt": "2020-02-20 00:00:00", - "type": "OneTime", - "timeZone": "str" - } - - # JSON input template for discriminator value "Recurrence": - trigger = { - "interval": 0, - "schedule": recurrence_schedule, - "type": "Recurrence", - "endTime": "2020-02-20 00:00:00", - "startTime": "2020-02-20 00:00:00", - "timeZone": "str" - } - - # JSON input template for discriminator value "Daily": - recurrence_schedule = { - "hours": [ - 0 - ], - "type": "Daily" - } - - # JSON input template for discriminator value "Hourly": - recurrence_schedule = { - "type": "Hourly" - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "Cron": - trigger = { - "expression": "str", - "type": "Cron", - "endTime": "2020-02-20 00:00:00", - "startTime": "2020-02-20 00:00:00", - "timeZone": "str" - } - - # JSON input template for discriminator value "OneTime": - trigger = { - "triggerAt": "2020-02-20 00:00:00", - "type": "OneTime", - "timeZone": "str" - } - - # JSON input template for discriminator value "Recurrence": - trigger = { - "interval": 0, - "schedule": recurrence_schedule, - "type": "Recurrence", - "endTime": "2020-02-20 00:00:00", - "startTime": "2020-02-20 00:00:00", - "timeZone": "str" - } - - # JSON input template for discriminator value "Daily": - recurrence_schedule = { - "hours": [ - 0 - ], - "type": "Daily" - } - - # JSON input template for discriminator value "Hourly": - recurrence_schedule = { - "type": "Hourly" - } - - # response body for status code(s): 201, 200 - response == { - "enabled": bool, - "id": "str", - "systemData": { - "str": "str" - }, - "task": schedule_task, - "trigger": trigger, - "description": "str", - "displayName": "str", - "properties": { - "str": "str" - }, - "provisioningStatus": "str", - "tags": { - "str": "str" - } - } """ @distributed_trace - def create_or_update( + def update_agent( self, - schedule_id: str, - schedule: Union[_types_models1.Schedule, IO[bytes]], + agent_id: str, + body: Union[JSON, IO[bytes]] = _Unset, *, - foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], + model: Optional[str] = None, + name: Optional[str] = None, + description: Optional[str] = None, + instructions: Optional[str] = None, + tools: Optional[List[_models.ToolDefinition]] = None, + tool_resources: Optional[_models.ToolResources] = None, + temperature: Optional[float] = None, + top_p: Optional[float] = None, + response_format: Optional["_types.AgentsResponseFormatOption"] = None, + metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> _types_models1.Schedule: - """Create or update operation template. + ) -> _models.Agent: + """Modifies an existing agent. - :param schedule_id: Identifier of the schedule. Required. - :type schedule_id: str - :param schedule: The resource instance. Is either a Schedule type or a IO[bytes] type. - Required. - :type schedule: ~azure.ai.agents.types.Schedule or IO[bytes] - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. SCHEDULES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.SCHEDULES_V1_PREVIEW - :return: Schedule - :rtype: ~azure.ai.agents.types.Schedule + :param agent_id: The ID of the agent to modify. Required. + :type agent_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword model: The ID of the model to use. Default value is None. + :paramtype model: str + :keyword name: The modified name for the agent to use. Default value is None. + :paramtype name: str + :keyword description: The modified description for the agent to use. Default value is None. + :paramtype description: str + :keyword instructions: The modified system instructions for the new agent to use. Default value + is None. + :paramtype instructions: str + :keyword tools: The modified collection of tools to enable for the agent. Default value is + None. + :paramtype tools: list[~azure.ai.agents.models.ToolDefinition] + :keyword tool_resources: 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. Default value is None. + :paramtype tool_resources: ~azure.ai.agents.models.ToolResources + :keyword temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 + will make the output more random, + while lower values like 0.2 will make it more focused and deterministic. Default value is + None. + :paramtype temperature: float + :keyword top_p: An alternative to sampling with temperature, called nucleus sampling, where the + model considers the results of the tokens with top_p probability mass. + So 0.1 means only the tokens comprising the top 10% probability mass are considered. + + We generally recommend altering this or temperature but not both. Default value is None. + :paramtype top_p: float + :keyword response_format: The response format of the tool calls used by this agent. Is one of + the following types: str, Union[str, "_models.AgentsResponseFormatMode"], AgentsResponseFormat, + ResponseFormatJsonSchemaType Default value is None. + :paramtype response_format: str or str or ~azure.ai.agents.models.AgentsResponseFormatMode or + ~azure.ai.agents.models.AgentsResponseFormat or + ~azure.ai.agents.models.ResponseFormatJsonSchemaType + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: Agent. The Agent is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.Agent :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # The input is polymorphic. The following are possible polymorphic inputs based off - discriminator "type": - - # JSON input template for discriminator value "Cron": - trigger = { - "expression": "str", - "type": "Cron", - "endTime": "2020-02-20 00:00:00", - "startTime": "2020-02-20 00:00:00", - "timeZone": "str" - } - - # JSON input template for discriminator value "OneTime": - trigger = { - "triggerAt": "2020-02-20 00:00:00", - "type": "OneTime", - "timeZone": "str" - } - - # JSON input template for discriminator value "Recurrence": - trigger = { - "interval": 0, - "schedule": recurrence_schedule, - "type": "Recurrence", - "endTime": "2020-02-20 00:00:00", - "startTime": "2020-02-20 00:00:00", - "timeZone": "str" - } - - # JSON input template for discriminator value "Daily": - recurrence_schedule = { - "hours": [ - 0 - ], - "type": "Daily" - } - - # JSON input template for discriminator value "Hourly": - recurrence_schedule = { - "type": "Hourly" - } - - # JSON input template you can fill out and use as your body input. - schedule = { - "enabled": bool, - "id": "str", - "systemData": { - "str": "str" - }, - "task": schedule_task, - "trigger": trigger, - "description": "str", - "displayName": "str", - "properties": { - "str": "str" - }, - "provisioningStatus": "str", - "tags": { - "str": "str" - } - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "Cron": - trigger = { - "expression": "str", - "type": "Cron", - "endTime": "2020-02-20 00:00:00", - "startTime": "2020-02-20 00:00:00", - "timeZone": "str" - } - - # JSON input template for discriminator value "OneTime": - trigger = { - "triggerAt": "2020-02-20 00:00:00", - "type": "OneTime", - "timeZone": "str" - } - - # JSON input template for discriminator value "Recurrence": - trigger = { - "interval": 0, - "schedule": recurrence_schedule, - "type": "Recurrence", - "endTime": "2020-02-20 00:00:00", - "startTime": "2020-02-20 00:00:00", - "timeZone": "str" - } - - # JSON input template for discriminator value "Daily": - recurrence_schedule = { - "hours": [ - 0 - ], - "type": "Daily" - } - - # JSON input template for discriminator value "Hourly": - recurrence_schedule = { - "type": "Hourly" - } - - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "type": - - # JSON input template for discriminator value "Cron": - trigger = { - "expression": "str", - "type": "Cron", - "endTime": "2020-02-20 00:00:00", - "startTime": "2020-02-20 00:00:00", - "timeZone": "str" - } - - # JSON input template for discriminator value "OneTime": - trigger = { - "triggerAt": "2020-02-20 00:00:00", - "type": "OneTime", - "timeZone": "str" - } - - # JSON input template for discriminator value "Recurrence": - trigger = { - "interval": 0, - "schedule": recurrence_schedule, - "type": "Recurrence", - "endTime": "2020-02-20 00:00:00", - "startTime": "2020-02-20 00:00:00", - "timeZone": "str" - } - - # JSON input template for discriminator value "Daily": - recurrence_schedule = { - "hours": [ - 0 - ], - "type": "Daily" - } - - # JSON input template for discriminator value "Hourly": - recurrence_schedule = { - "type": "Hourly" - } - - # response body for status code(s): 201, 200 - response == { - "enabled": bool, - "id": "str", - "systemData": { - "str": "str" - }, - "task": schedule_task, - "trigger": trigger, - "description": "str", - "displayName": "str", - "properties": { - "str": "str" - }, - "provisioningStatus": "str", - "tags": { - "str": "str" - } - } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -16817,22 +5761,33 @@ def create_or_update( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_types_models1.Schedule] = kwargs.pop("cls", None) + cls: ClsType[_models.Agent] = kwargs.pop("cls", None) + if body is _Unset: + body = { + "description": description, + "instructions": instructions, + "metadata": metadata, + "model": model, + "name": name, + "response_format": response_format, + "temperature": temperature, + "tool_resources": tool_resources, + "tools": tools, + "top_p": top_p, + } + body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" - _json = None _content = None - if isinstance(schedule, (IOBase, bytes)): - _content = schedule + if isinstance(body, (IOBase, bytes)): + _content = body else: - _json = schedule + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_beta_schedules_create_or_update_request( - schedule_id=schedule_id, - foundry_features=foundry_features, + _request = build_agents_update_agent_request( + agent_id=agent_id, content_type=content_type, api_version=self._config.api_version, - json=_json, content=_content, headers=_headers, params=_params, @@ -16842,7 +5797,6 @@ def create_or_update( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -16850,22 +5804,20 @@ def create_or_update( response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200]: if _stream: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize(_models.Agent, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -16873,41 +5825,14 @@ def create_or_update( return deserialized # type: ignore @distributed_trace - def get_run( - self, - schedule_id: str, - run_id: str, - *, - foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], - **kwargs: Any - ) -> _types_models1.ScheduleRun: - """Get a schedule run by id. + def _delete_agent(self, agent_id: str, **kwargs: Any) -> _models._models.AgentDeletionStatus: + """Deletes an agent. - :param schedule_id: The unique identifier of the schedule. Required. - :type schedule_id: str - :param run_id: The unique identifier of the schedule run. Required. - :type run_id: str - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. SCHEDULES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.SCHEDULES_V1_PREVIEW - :return: ScheduleRun - :rtype: ~azure.ai.agents.types.ScheduleRun + :param agent_id: Identifier of the agent. Required. + :type agent_id: str + :return: AgentDeletionStatus. The AgentDeletionStatus is compatible with MutableMapping + :rtype: ~azure.ai.agents.models._models.AgentDeletionStatus :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "id": "str", - "properties": { - "str": "str" - }, - "scheduleId": "str", - "success": bool, - "error": "str", - "triggerTime": "2020-02-20 00:00:00" - } """ error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -16920,12 +5845,10 @@ def get_run( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_types_models1.ScheduleRun] = kwargs.pop("cls", None) + cls: ClsType[_models._models.AgentDeletionStatus] = kwargs.pop("cls", None) - _request = build_beta_schedules_get_run_request( - schedule_id=schedule_id, - run_id=run_id, - foundry_features=foundry_features, + _request = build_agents_delete_agent_request( + agent_id=agent_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -16935,7 +5858,6 @@ def get_run( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -16950,71 +5872,257 @@ def get_run( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _types_models1.ApiErrorResponse, - pipeline_response, - ) + error = _failsafe_deserialize(_models.AgentV1Error, response) raise HttpResponseError(response=response, model=error) if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = response.iter_bytes() else: - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = _deserialize( + _models._models.AgentDeletionStatus, response.json() # pylint: disable=protected-access + ) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def list_runs( + @overload + def create_thread_and_run( self, - schedule_id: str, *, - foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], - type: Optional[types.ScheduleTaskType] = None, - enabled: Optional[bool] = None, + agent_id: str, + content_type: str = "application/json", + thread: Optional[_models.AgentThreadCreationOptions] = None, + model: Optional[str] = None, + instructions: Optional[str] = None, + tools: Optional[List[_models.ToolDefinition]] = None, + tool_resources: Optional[_models.ToolResources] = None, + stream_parameter: Optional[bool] = None, + temperature: Optional[float] = None, + top_p: Optional[float] = None, + max_prompt_tokens: Optional[int] = None, + max_completion_tokens: Optional[int] = None, + truncation_strategy: Optional[_models.TruncationObject] = None, + tool_choice: Optional["_types.AgentsToolChoiceOption"] = None, + response_format: Optional["_types.AgentsResponseFormatOption"] = None, + parallel_tool_calls: Optional[bool] = None, + metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> ItemPaged["_types_models1.ScheduleRun"]: - """List all schedule runs. - - :param schedule_id: Identifier of the schedule. Required. - :type schedule_id: str - :keyword foundry_features: A feature flag opt-in required when using preview operations or - modifying persisted preview resources. SCHEDULES_V1_PREVIEW. Required. - :paramtype foundry_features: str or ~azure.ai.agents.models.SCHEDULES_V1_PREVIEW - :keyword type: Filter by the type of schedule. Known values are: "Evaluation" and "Insight". + ) -> _models.ThreadRun: + """Creates a new agent thread and immediately starts a run using that new thread. + + :keyword agent_id: The ID of the agent for which the thread should be created. Required. + :paramtype agent_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword thread: The details used to create the new thread. If no thread is provided, an empty + one will be created. Default value is None. + :paramtype thread: ~azure.ai.agents.models.AgentThreadCreationOptions + :keyword model: The overridden model that the agent should use to run the thread. Default value + is None. + :paramtype model: str + :keyword instructions: The overridden system instructions the agent should use to run the + thread. Default value is None. + :paramtype instructions: str + :keyword tools: The overridden list of enabled tools the agent should use to run the thread. + Default value is None. + :paramtype tools: list[~azure.ai.agents.models.ToolDefinition] + :keyword tool_resources: Override the tools the agent can use for this run. This is useful for + modifying the behavior on a per-run basis. Default value is None. + :paramtype tool_resources: ~azure.ai.agents.models.ToolResources + :keyword stream_parameter: 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. Default + value is None. + :paramtype stream_parameter: bool + :keyword temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 + will make the output + more random, while lower values like 0.2 will make it more focused and deterministic. Default + value is None. + :paramtype temperature: float + :keyword top_p: An alternative to sampling with temperature, called nucleus sampling, where the + model + considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens + comprising the top 10% probability mass are considered. + + We generally recommend altering this or temperature but not both. Default value is None. + :paramtype top_p: float + :keyword max_prompt_tokens: 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. Default + value is None. + :paramtype max_prompt_tokens: int + :keyword max_completion_tokens: 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. Default value is None. + :paramtype max_completion_tokens: int + :keyword truncation_strategy: The strategy to use for dropping messages as the context windows + moves forward. Default value is None. + :paramtype truncation_strategy: ~azure.ai.agents.models.TruncationObject + :keyword tool_choice: Controls whether or not and which tool is called by the model. Is one of + the following types: str, Union[str, "_models.AgentsToolChoiceOptionMode"], + AgentsNamedToolChoice Default value is None. + :paramtype tool_choice: str or str or ~azure.ai.agents.models.AgentsToolChoiceOptionMode or + ~azure.ai.agents.models.AgentsNamedToolChoice + :keyword response_format: Specifies the format that the model must output. Is one of the + following types: str, Union[str, "_models.AgentsResponseFormatMode"], AgentsResponseFormat, + ResponseFormatJsonSchemaType Default value is None. + :paramtype response_format: str or str or ~azure.ai.agents.models.AgentsResponseFormatMode or + ~azure.ai.agents.models.AgentsResponseFormat or + ~azure.ai.agents.models.ResponseFormatJsonSchemaType + :keyword parallel_tool_calls: If ``true`` functions will run in parallel during tool use. Default value is None. - :paramtype type: str or ~azure.ai.agents.models.ScheduleTaskType - :keyword enabled: Filter by the enabled status. Default value is None. - :paramtype enabled: bool - :return: An iterator like instance of ScheduleRun - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.agents.types.ScheduleRun] + :paramtype parallel_tool_calls: bool + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: ThreadRun. The ThreadRun is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadRun + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_thread_and_run( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ThreadRun: + """Creates a new agent thread and immediately starts a run using that new thread. + + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ThreadRun. The ThreadRun is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadRun :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_thread_and_run( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ThreadRun: + """Creates a new agent thread and immediately starts a run using that new thread. - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "id": "str", - "properties": { - "str": "str" - }, - "scheduleId": "str", - "success": bool, - "error": "str", - "triggerTime": "2020-02-20 00:00:00" - } + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ThreadRun. The ThreadRun is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadRun + :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_types_models1.ScheduleRun]] = kwargs.pop("cls", None) + @distributed_trace + def create_thread_and_run( + self, + body: Union[JSON, IO[bytes]] = _Unset, + *, + agent_id: str = _Unset, + thread: Optional[_models.AgentThreadCreationOptions] = None, + model: Optional[str] = None, + instructions: Optional[str] = None, + tools: Optional[List[_models.ToolDefinition]] = None, + tool_resources: Optional[_models.ToolResources] = None, + stream_parameter: Optional[bool] = None, + temperature: Optional[float] = None, + top_p: Optional[float] = None, + max_prompt_tokens: Optional[int] = None, + max_completion_tokens: Optional[int] = None, + truncation_strategy: Optional[_models.TruncationObject] = None, + tool_choice: Optional["_types.AgentsToolChoiceOption"] = None, + response_format: Optional["_types.AgentsResponseFormatOption"] = None, + parallel_tool_calls: Optional[bool] = None, + metadata: Optional[dict[str, str]] = None, + **kwargs: Any + ) -> _models.ThreadRun: + """Creates a new agent thread and immediately starts a run using that new thread. + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword agent_id: The ID of the agent for which the thread should be created. Required. + :paramtype agent_id: str + :keyword thread: The details used to create the new thread. If no thread is provided, an empty + one will be created. Default value is None. + :paramtype thread: ~azure.ai.agents.models.AgentThreadCreationOptions + :keyword model: The overridden model that the agent should use to run the thread. Default value + is None. + :paramtype model: str + :keyword instructions: The overridden system instructions the agent should use to run the + thread. Default value is None. + :paramtype instructions: str + :keyword tools: The overridden list of enabled tools the agent should use to run the thread. + Default value is None. + :paramtype tools: list[~azure.ai.agents.models.ToolDefinition] + :keyword tool_resources: Override the tools the agent can use for this run. This is useful for + modifying the behavior on a per-run basis. Default value is None. + :paramtype tool_resources: ~azure.ai.agents.models.ToolResources + :keyword stream_parameter: 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. Default + value is None. + :paramtype stream_parameter: bool + :keyword temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 + will make the output + more random, while lower values like 0.2 will make it more focused and deterministic. Default + value is None. + :paramtype temperature: float + :keyword top_p: An alternative to sampling with temperature, called nucleus sampling, where the + model + considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens + comprising the top 10% probability mass are considered. + + We generally recommend altering this or temperature but not both. Default value is None. + :paramtype top_p: float + :keyword max_prompt_tokens: 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. Default + value is None. + :paramtype max_prompt_tokens: int + :keyword max_completion_tokens: 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. Default value is None. + :paramtype max_completion_tokens: int + :keyword truncation_strategy: The strategy to use for dropping messages as the context windows + moves forward. Default value is None. + :paramtype truncation_strategy: ~azure.ai.agents.models.TruncationObject + :keyword tool_choice: Controls whether or not and which tool is called by the model. Is one of + the following types: str, Union[str, "_models.AgentsToolChoiceOptionMode"], + AgentsNamedToolChoice Default value is None. + :paramtype tool_choice: str or str or ~azure.ai.agents.models.AgentsToolChoiceOptionMode or + ~azure.ai.agents.models.AgentsNamedToolChoice + :keyword response_format: Specifies the format that the model must output. Is one of the + following types: str, Union[str, "_models.AgentsResponseFormatMode"], AgentsResponseFormat, + ResponseFormatJsonSchemaType Default value is None. + :paramtype response_format: str or str or ~azure.ai.agents.models.AgentsResponseFormatMode or + ~azure.ai.agents.models.AgentsResponseFormat or + ~azure.ai.agents.models.ResponseFormatJsonSchemaType + :keyword parallel_tool_calls: If ``true`` functions will run in parallel during tool use. + Default value is None. + :paramtype parallel_tool_calls: bool + :keyword 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. Default value is + None. + :paramtype metadata: dict[str, str] + :return: ThreadRun. The ThreadRun is compatible with MutableMapping + :rtype: ~azure.ai.agents.models.ThreadRun + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -17023,70 +6131,76 @@ def list_runs( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - _request = build_beta_schedules_list_runs_request( - schedule_id=schedule_id, - foundry_features=foundry_features, - type=type, - enabled=enabled, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - return _request + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ThreadRun] = kwargs.pop("cls", None) - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized.get("value", []) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) + if body is _Unset: + if agent_id is _Unset: + raise TypeError("missing required argument: agent_id") + body = { + "assistant_id": agent_id, + "instructions": instructions, + "max_completion_tokens": max_completion_tokens, + "max_prompt_tokens": max_prompt_tokens, + "metadata": metadata, + "model": model, + "parallel_tool_calls": parallel_tool_calls, + "response_format": response_format, + "stream": stream_parameter, + "temperature": temperature, + "thread": thread, + "tool_choice": tool_choice, + "tool_resources": tool_resources, + "tools": tools, + "top_p": top_p, + "truncation_strategy": truncation_strategy, + } + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_agents_create_thread_and_run_request( + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - def get_next(next_link=None): - _request = prepare_request(next_link) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + response = pipeline_response.http_response - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.AgentV1Error, response) + raise HttpResponseError(response=response, model=error) - return pipeline_response + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.ThreadRun, response.json()) - return ItemPaged(get_next, extract_data) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/ai/azure-ai-agents/pyproject.toml b/sdk/ai/azure-ai-agents/pyproject.toml index 25f2d68057a4..062a6418ec7b 100644 --- a/sdk/ai/azure-ai-agents/pyproject.toml +++ b/sdk/ai/azure-ai-agents/pyproject.toml @@ -1,67 +1,26 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -[build-system] -requires = ["setuptools>=77.0.3", "wheel"] -build-backend = "setuptools.build_meta" - -[project] -name = "azure-ai-agents" -authors = [ - { name = "Microsoft Corporation", email = "azpysdkhelp@microsoft.com" }, -] -description = "Microsoft Corporation Azure Ai Agents Client Library for Python" -license = "MIT" -classifiers = [ - "Development Status :: 4 - Beta", - "Programming Language :: Python", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: 3.13", - "Programming Language :: Python :: 3.14", -] -requires-python = ">=3.10" -keywords = ["azure", "azure sdk"] - -dependencies = [ - "isodate>=0.6.1", - "azure-core>=1.37.0", - "typing-extensions>=4.6.0", -] -dynamic = [ -"version", "readme" -] - -[project.urls] -repository = "https://github.com/Azure/azure-sdk-for-python" - -[tool.setuptools.dynamic] -version = {attr = "azure.ai.agents._version.VERSION"} -readme = {file = ["README.md", "CHANGELOG.md"], content-type = "text/markdown"} - -[tool.setuptools.packages.find] +[tool.mypy] +python_version = "3.10" exclude = [ - "tests*", - "generated_tests*", - "samples*", - "generated_samples*", - "doc*", - "azure", - "azure.ai", ] - -[tool.setuptools.package-data] -pytyped = ["py.typed"] +warn_unused_configs = true +ignore_missing_imports = true +follow_imports_for_stubs = false + +[tool.isort] +profile = "black" +line_length = 120 +known_first_party = ["azure"] +filter_files=true +extend_skip_glob = [ + "*/_vendor/*", + "*/_generated/*", + "*/_restclient/*", + "*/doc/*", + "*/.tox/*", +] [tool.azure-sdk-build] -whl_no_aio = false +whl_no_aio= false [tool.azure-sdk-conda] in_bundle = false diff --git a/sdk/ai/azure-ai-agents/samples/agents_async/sample_agents_basics_with_console_tracing_async.py b/sdk/ai/azure-ai-agents/samples/agents_async/sample_agents_basics_with_console_tracing_async.py index 67c32b24c200..bacec1c100b0 100644 --- a/sdk/ai/azure-ai-agents/samples/agents_async/sample_agents_basics_with_console_tracing_async.py +++ b/sdk/ai/azure-ai-agents/samples/agents_async/sample_agents_basics_with_console_tracing_async.py @@ -1,4 +1,3 @@ -# pylint: disable=line-too-long,useless-suppression # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -38,7 +37,6 @@ from azure.identity.aio import DefaultAzureCredential from azure.core.settings import settings - settings.tracing_implementation = "opentelemetry" # Install opentelemetry with command "pip install azure-ai-projects opentelemetry-sdk". @@ -55,7 +53,6 @@ tracer = trace.get_tracer(__name__) from azure.ai.agents.telemetry import AIAgentsInstrumentor - AIAgentsInstrumentor().instrument() @@ -83,9 +80,7 @@ async def main() -> None: thread = await project_client.agents.threads.create() print(f"Created thread, thread ID: {thread.id}") - message = await project_client.agents.messages.create( - thread_id=thread.id, role="user", content="Hello, tell me a joke" - ) + message = await project_client.agents.messages.create(thread_id=thread.id, role="user", content="Hello, tell me a joke") print(f"Created message, message ID: {message.id}") run = await project_client.agents.runs.create_and_process(thread_id=thread.id, agent_id=agent.id) diff --git a/sdk/ai/azure-ai-agents/setup.py b/sdk/ai/azure-ai-agents/setup.py new file mode 100644 index 000000000000..372a1c431d12 --- /dev/null +++ b/sdk/ai/azure-ai-agents/setup.py @@ -0,0 +1,80 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + + +import os +import re +from setuptools import setup, find_packages + + +PACKAGE_NAME = "azure-ai-agents" +PACKAGE_PPRINT_NAME = "Azure AI Agents" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace("-", "/") + +# Version extraction inspired from 'requests' +with open(os.path.join(package_folder_path, "_version.py"), "r") as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError("Cannot find version information") + + +setup( + name=PACKAGE_NAME, + version=version, + description="Microsoft Corporation {} Client Library for Python".format(PACKAGE_PPRINT_NAME), + long_description=open("README.md", "r").read(), + long_description_content_type="text/markdown", + license="MIT License", + author="Microsoft Corporation", + author_email="azpysdkhelp@microsoft.com", + url="https://github.com/Azure/azure-sdk-for-python/tree/main/sdk", + keywords="azure, azure sdk", + classifiers=[ + "Development Status :: 4 - Beta", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "License :: OSI Approved :: MIT License", + ], + zip_safe=False, + packages=find_packages( + exclude=[ + "samples", + "samples.utils", + "samples.agents_tools", + "samples.agents_async", + "samples.agents_multiagent", + "samples.agents_streaming", + "samples.agents_telemetry", + "samples.agents_tools", + "samples.assets", + "samples.agents_async.utils", + "tests", + # Exclude packages that will be covered by PEP420 or nspkg + "azure", + "azure.ai", + ] + ), + include_package_data=True, + package_data={ + "azure.ai.agents": ["py.typed"], + }, + install_requires=[ + "isodate>=0.6.1", + "azure-core>=1.30.0", + "typing-extensions>=4.6.0", + ], + python_requires=">=3.9", +) From d5c2f423232c295dbfa57df8d9414902796e7389 Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Wed, 17 Jun 2026 15:20:55 -0400 Subject: [PATCH 5/5] remove extra regenerated files under other ai folders --- .../azure/ai/agents/_unions.py | 13 - .../azure-ai-agents/azure/ai/agents/types.py | 3342 ------------ .../azure/ai/projects/__init__.py | 1 - .../azure/ai/projects/models/__init__.py | 21 - .../azure/ai/projects/models/_patch.py | 21 - .../azure/ai/projects/types.py | 1317 ----- .../azure/ai/projects/_unions.py | 13 - .../azure/ai/projects/types.py | 4640 ----------------- 8 files changed, 9368 deletions(-) delete mode 100644 sdk/ai/azure-ai-agents/azure/ai/agents/_unions.py delete mode 100644 sdk/ai/azure-ai-agents/azure/ai/agents/types.py delete mode 100644 sdk/ai/azure-ai-agents/azure/ai/projects/__init__.py delete mode 100644 sdk/ai/azure-ai-agents/azure/ai/projects/models/__init__.py delete mode 100644 sdk/ai/azure-ai-agents/azure/ai/projects/models/_patch.py delete mode 100644 sdk/ai/azure-ai-agents/azure/ai/projects/types.py delete mode 100644 sdk/ai/azure-ai-projects/azure/ai/projects/_unions.py delete mode 100644 sdk/ai/azure-ai-projects/azure/ai/projects/types.py diff --git a/sdk/ai/azure-ai-agents/azure/ai/agents/_unions.py b/sdk/ai/azure-ai-agents/azure/ai/agents/_unions.py deleted file mode 100644 index c43e76df7511..000000000000 --- a/sdk/ai/azure-ai-agents/azure/ai/agents/_unions.py +++ /dev/null @@ -1,13 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import TYPE_CHECKING, Union - -if TYPE_CHECKING: - from ..projects import types as _types_projects_models2 -Filters = Union["_types_projects_models2.ComparisonFilter", "_types_projects_models2.CompoundFilter"] diff --git a/sdk/ai/azure-ai-agents/azure/ai/agents/types.py b/sdk/ai/azure-ai-agents/azure/ai/agents/types.py deleted file mode 100644 index 935b8ec4fc4d..000000000000 --- a/sdk/ai/azure-ai-agents/azure/ai/agents/types.py +++ /dev/null @@ -1,3342 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, Literal, Optional, TYPE_CHECKING, Union -from typing_extensions import Required, TypedDict - -from ..projects.models._enums import ToolType -from .models._enums import ( - AgentKind, - AgentObjectType, - CredentialType, - DatasetType, - DeploymentType, - EvaluationRuleActionType, - EvaluationTaxonomyInputType, - EvaluatorDefinitionType, - IndexType, - InsightType, - MemoryItemKind, - MemoryStoreKind, - MemoryStoreObjectType, - OpenApiAuthType, - PendingUploadType, - RecurrenceType, - SampleType, - ScheduleTaskType, - TriggerType, -) - -if TYPE_CHECKING: - from ..projects import types as _types_projects_models2 - -AgentDefinitionOptInKeys = Literal["HostedAgents=V1Preview", "WorkflowAgents=V1Preview"] -"""Feature opt-in keys for agent definition operations supporting hosted or workflow agents.""" - -AgentKind = Literal["prompt", "hosted", "workflow"] -"""Type of AgentKind.""" - -AgentObjectType = Literal["agent", "agent.version", "agent.deleted", "agent.version.deleted", "agent.container"] -"""Type of AgentObjectType.""" - -AgentProtocol = Literal["activity_protocol", "responses"] -"""Type of AgentProtocol.""" - -AttackStrategy = Literal[ - "easy", - "moderate", - "difficult", - "ascii_art", - "ascii_smuggler", - "atbash", - "base64", - "binary", - "caesar", - "character_space", - "jailbreak", - "ansi_attack", - "character_swap", - "suffix_append", - "string_join", - "unicode_confusable", - "unicode_substitution", - "diacritic", - "flip", - "leetspeak", - "rot13", - "morse", - "url", - "baseline", - "indirect_jailbreak", - "tense", - "multi_turn", - "crescendo", -] -"""Strategies for attacks.""" - -AzureAISearchQueryType = Literal["simple", "semantic", "vector", "vector_simple_hybrid", "vector_semantic_hybrid"] -"""Available query types for Azure AI Search tool.""" - -ConnectionType = Literal[ - "AzureOpenAI", - "AzureBlob", - "AzureStorageAccount", - "CognitiveSearch", - "CosmosDB", - "ApiKey", - "AppConfig", - "AppInsights", - "CustomKeys", - "RemoteTool_Preview", -] -"""The Type (or category) of the connection.""" - -CredentialType = Literal["ApiKey", "AAD", "SAS", "CustomKeys", "None", "AgenticIdentityToken_Preview"] -"""The credential type used by the connection.""" - -DatasetType = Literal["uri_file", "uri_folder"] -"""Enum to determine the type of data.""" - -DayOfWeek = Literal["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] -"""Days of the week for recurrence schedule.""" - -DeploymentType = Literal["ModelDeployment"] -"""Type of DeploymentType.""" - -EvaluationRuleActionType = Literal["continuousEvaluation", "humanEvaluationPreview"] -"""Type of the evaluation action.""" - -EvaluationRuleEventType = Literal["responseCompleted", "manual"] -"""Type of the evaluation rule event.""" - -EvaluationTaxonomyInputType = Literal["agent", "policy"] -"""Type of the evaluation taxonomy input.""" - -EvaluatorCategory = Literal["quality", "safety", "agents"] -"""The category of the evaluator.""" - -EvaluatorDefinitionType = Literal["prompt", "code", "prompt_and_code", "service", "openai_graders"] -"""The type of evaluator definition.""" - -EvaluatorMetricDirection = Literal["increase", "decrease", "neutral"] -"""The direction of the metric indicating whether a higher value is better, a lower value is -better, or neutral.""" - -EvaluatorMetricType = Literal["ordinal", "continuous", "boolean"] -"""The type of the evaluator.""" - -EvaluatorType = Literal["builtin", "custom"] -"""The type of the evaluator.""" - -FoundryFeaturesOptInKeys = Literal[ - "Evaluations=V1Preview", "Schedules=V1Preview", "RedTeams=V1Preview", "Insights=V1Preview", "MemoryStores=V1Preview" -] -"""Type of FoundryFeaturesOptInKeys.""" - -IndexType = Literal["AzureSearch", "CosmosDBNoSqlVectorStore", "ManagedAzureSearch"] -"""Type of IndexType.""" - -InsightType = Literal["EvaluationRunClusterInsight", "AgentClusterInsight", "EvaluationComparison"] -"""The request of the insights.""" - -MemoryItemKind = Literal["user_profile", "chat_summary"] -"""Memory item kind.""" - -MemoryOperationKind = Literal["create", "update", "delete"] -"""Memory operation kind.""" - -MemoryStoreKind = Literal["default"] -"""The type of memory store implementation to use.""" - -MemoryStoreObjectType = Literal["memory_store", "memory_store.deleted", "memory_store.scope.deleted"] -"""Type of MemoryStoreObjectType.""" - -MemoryStoreUpdateStatus = Literal["queued", "in_progress", "completed", "failed", "superseded"] -"""Status of a memory store update operation.""" - -OpenApiAuthType = Literal["anonymous", "project_connection", "managed_identity"] -"""Authentication type for OpenApi endpoint. Allowed types are: - -* Anonymous (no authentication required) -* Project Connection (requires project_connection_id to endpoint, as setup in AI Foundry) -* Managed_Identity (requires audience for identity based auth).""" - -OperationState = Literal["NotStarted", "Running", "Succeeded", "Failed", "Canceled"] -"""Enum describing allowed operation states.""" - -PageOrder = Literal["asc", "desc"] -"""Type of PageOrder.""" - -PendingUploadType = Literal["None", "BlobReference"] -"""The type of pending upload.""" - -RecurrenceType = Literal["Hourly", "Daily", "Weekly", "Monthly"] -"""Recurrence type.""" - -RiskCategory = Literal[ - "HateUnfairness", - "Violence", - "Sexual", - "SelfHarm", - "ProtectedMaterial", - "CodeVulnerability", - "UngroundedAttributes", - "ProhibitedActions", - "SensitiveDataLeakage", - "TaskAdherence", -] -"""Risk category for the attack objective.""" - -SampleType = Literal["EvaluationResultSample"] -"""The type of sample used in the analysis.""" - -ScheduleProvisioningStatus = Literal["Creating", "Updating", "Deleting", "Succeeded", "Failed"] -"""Schedule provisioning status.""" - -ScheduleTaskType = Literal["Evaluation", "Insight"] -"""Type of the task.""" - -TreatmentEffectType = Literal["TooFewSamples", "Inconclusive", "Changed", "Improved", "Degraded"] -"""Treatment Effect Type.""" - -TriggerType = Literal["Cron", "Recurrence", "OneTime"] -"""Type of the trigger.""" - - -class A2APreviewTool(TypedDict, total=False): - """An agent implementing the A2A protocol. - - :ivar type: The type of the tool. Always ``"a2a_preview``. Required. A2_A_PREVIEW. - :vartype type: str or ~azure.ai.projects.models.A2_A_PREVIEW - :ivar base_url: Base URL of the agent. - :vartype base_url: str - :ivar agent_card_path: The path to the agent card relative to the ``base_url``. If not - provided, defaults to ``/.well-known/agent-card.json``. - :vartype agent_card_path: str - :ivar project_connection_id: The connection ID in the project for the A2A server. The - connection stores authentication and other connection details needed to connect to the A2A - server. - :vartype project_connection_id: str - """ - - type: Required[Literal[ToolType.A2_A_PREVIEW]] - """The type of the tool. Always ``\"a2a_preview``. Required. A2_A_PREVIEW.""" - base_url: str - """Base URL of the agent.""" - agent_card_path: str - """The path to the agent card relative to the ``base_url``. If not provided, defaults to - ``/.well-known/agent-card.json``.""" - project_connection_id: str - """The connection ID in the project for the A2A server. The connection stores authentication and - other connection details needed to connect to the A2A server.""" - - -class AgentClusterInsightRequest(TypedDict, total=False): - """Insights on set of Agent Evaluation Results. - - :ivar type: The type of request. Required. Cluster Insight on an Agent. - :vartype type: str or ~azure.ai.agents.models.AGENT_CLUSTER_INSIGHT - :ivar agent_name: Identifier for the agent. Required. - :vartype agent_name: str - :ivar model_configuration: Configuration of the model used in the insight generation. - :vartype model_configuration: ~azure.ai.agents.types.InsightModelConfiguration - """ - - type: Required[Literal[InsightType.AGENT_CLUSTER_INSIGHT]] - """The type of request. Required. Cluster Insight on an Agent.""" - agentName: Required[str] - """Identifier for the agent. Required.""" - modelConfiguration: "InsightModelConfiguration" - """Configuration of the model used in the insight generation.""" - - -class AgentClusterInsightResult(TypedDict, total=False): - """Insights from the agent cluster analysis. - - :ivar type: The type of insights result. Required. Cluster Insight on an Agent. - :vartype type: str or ~azure.ai.agents.models.AGENT_CLUSTER_INSIGHT - :ivar cluster_insight: Required. - :vartype cluster_insight: ~azure.ai.agents.types.ClusterInsightResult - """ - - type: Required[Literal[InsightType.AGENT_CLUSTER_INSIGHT]] - """The type of insights result. Required. Cluster Insight on an Agent.""" - clusterInsight: Required["ClusterInsightResult"] - """Required.""" - - -class AgentDetails(TypedDict, total=False): - """AgentDetails. - - :ivar object: The object type, which is always 'agent'. Required. AGENT. - :vartype object: str or ~azure.ai.agents.models.AGENT - :ivar id: The unique identifier of the agent. Required. - :vartype id: str - :ivar name: The name of the agent. Required. - :vartype name: str - :ivar versions: The latest version of the agent. Required. - :vartype versions: ~azure.ai.agents.types.AgentObjectVersions - """ - - object: Required[Literal[AgentObjectType.AGENT]] - """The object type, which is always 'agent'. Required. AGENT.""" - id: Required[str] - """The unique identifier of the agent. Required.""" - name: Required[str] - """The name of the agent. Required.""" - versions: Required["AgentObjectVersions"] - """The latest version of the agent. Required.""" - - -class AgenticIdentityPreviewCredentials(TypedDict, total=False): - """Agentic identity credential definition. - - :ivar type: The credential type. Required. Agentic identity credential. - :vartype type: str or ~azure.ai.agents.models.AGENTIC_IDENTITY_PREVIEW - """ - - type: Required[Literal[CredentialType.AGENTIC_IDENTITY_PREVIEW]] - """The credential type. Required. Agentic identity credential.""" - - -class AgentObjectVersions(TypedDict, total=False): - """AgentObjectVersions. - - :ivar latest: Required. - :vartype latest: ~azure.ai.agents.types.AgentVersionDetails - """ - - latest: Required["AgentVersionDetails"] - """Required.""" - - -class AgentTaxonomyInput(TypedDict, total=False): - """Input configuration for the evaluation taxonomy when the input type is agent. - - :ivar type: Input type of the evaluation taxonomy. Required. Agent. - :vartype type: str or ~azure.ai.agents.models.AGENT - :ivar target: Target configuration for the agent. Required. - :vartype target: ~azure.ai.agents.types.Target - :ivar risk_categories: List of risk categories to evaluate against. Required. - :vartype risk_categories: list[str or ~azure.ai.agents.models.RiskCategory] - """ - - type: Required[Literal[EvaluationTaxonomyInputType.AGENT]] - """Input type of the evaluation taxonomy. Required. Agent.""" - target: Required["Target"] - """Target configuration for the agent. Required.""" - riskCategories: Required[list[RiskCategory]] - """List of risk categories to evaluate against. Required.""" - - -class AgentVersionDetails(TypedDict, total=False): - """AgentVersionDetails. - - :ivar metadata: Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. Required. - :vartype metadata: dict[str, str] - :ivar object: The object type, which is always 'agent.version'. Required. AGENT_VERSION. - :vartype object: str or ~azure.ai.agents.models.AGENT_VERSION - :ivar id: The unique identifier of the agent version. Required. - :vartype id: str - :ivar name: The name of the agent. Name can be used to retrieve/update/delete the agent. - Required. - :vartype name: str - :ivar version: The version identifier of the agent. Agents are immutable and every update - creates a new version while keeping the name same. Required. - :vartype version: str - :ivar description: A human-readable description of the agent. - :vartype description: str - :ivar created_at: The Unix timestamp (seconds) when the agent was created. Required. - :vartype created_at: ~datetime.datetime - :ivar definition: Required. - :vartype definition: ~azure.ai.agents.types.AgentDefinition - """ - - metadata: Required[Optional[dict[str, str]]] - """Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. Required.""" - object: Required[Literal[AgentObjectType.AGENT_VERSION]] - """The object type, which is always 'agent.version'. Required. AGENT_VERSION.""" - id: Required[str] - """The unique identifier of the agent version. Required.""" - name: Required[str] - """The name of the agent. Name can be used to retrieve/update/delete the agent. Required.""" - version: Required[str] - """The version identifier of the agent. Agents are immutable and every update creates a new - version while keeping the name same. Required.""" - description: str - """A human-readable description of the agent.""" - created_at: Required[int] - """The Unix timestamp (seconds) when the agent was created. Required.""" - definition: Required["AgentDefinition"] - """Required.""" - - -class AISearchIndexResource(TypedDict, total=False): - """A AI Search Index resource. - - :ivar project_connection_id: An index connection ID in an IndexResource attached to this agent. - :vartype project_connection_id: str - :ivar index_name: The name of an index in an IndexResource attached to this agent. - :vartype index_name: str - :ivar query_type: Type of query in an AIIndexResource attached to this agent. Known values are: - "simple", "semantic", "vector", "vector_simple_hybrid", and "vector_semantic_hybrid". - :vartype query_type: str or ~azure.ai.agents.models.AzureAISearchQueryType - :ivar top_k: Number of documents to retrieve from search and present to the model. - :vartype top_k: int - :ivar filter: filter string for search resource. `Learn more here - `_. - :vartype filter: str - :ivar index_asset_id: Index asset id for search resource. - :vartype index_asset_id: str - """ - - project_connection_id: str - """An index connection ID in an IndexResource attached to this agent.""" - index_name: str - """The name of an index in an IndexResource attached to this agent.""" - query_type: AzureAISearchQueryType - """Type of query in an AIIndexResource attached to this agent. Known values are: \"simple\", - \"semantic\", \"vector\", \"vector_simple_hybrid\", and \"vector_semantic_hybrid\".""" - top_k: int - """Number of documents to retrieve from search and present to the model.""" - filter: str - """filter string for search resource. `Learn more here - `_.""" - index_asset_id: str - """Index asset id for search resource.""" - - -class ApiErrorResponse(TypedDict, total=False): - """Error response for API failures. - - :ivar error: Required. - :vartype error: ~azure.ai.projects.types.ApiError - """ - - error: Required["ApiError"] - """Required.""" - - -class ApiKeyCredentials(TypedDict, total=False): - """API Key Credential definition. - - :ivar type: The credential type. Required. API Key credential. - :vartype type: str or ~azure.ai.agents.models.API_KEY - :ivar api_key: API Key. - :vartype api_key: str - """ - - type: Required[Literal[CredentialType.API_KEY]] - """The credential type. Required. API Key credential.""" - key: str - """API Key.""" - - -class AzureAIAgentTarget(TypedDict, total=False): - """Represents a target specifying an Azure AI agent. - - :ivar type: The type of target, always ``azure_ai_agent``. Required. Default value is - "azure_ai_agent". - :vartype type: str - :ivar name: The unique identifier of the Azure AI agent. Required. - :vartype name: str - :ivar version: The version of the Azure AI agent. - :vartype version: str - :ivar tool_descriptions: The parameters used to control the sampling behavior of the agent - during text generation. - :vartype tool_descriptions: list[~azure.ai.agents.types.ToolDescription] - """ - - type: Required[Literal["azure_ai_agent"]] - """The type of target, always ``azure_ai_agent``. Required. Default value is \"azure_ai_agent\".""" - name: Required[str] - """The unique identifier of the Azure AI agent. Required.""" - version: str - """The version of the Azure AI agent.""" - tool_descriptions: list["ToolDescription"] - """The parameters used to control the sampling behavior of the agent during text generation.""" - - -class AzureAIModelTarget(TypedDict, total=False): - """Represents a target specifying an Azure AI model for operations requiring model selection. - - :ivar type: The type of target, always ``azure_ai_model``. Required. Default value is - "azure_ai_model". - :vartype type: str - :ivar model: The unique identifier of the Azure AI model. - :vartype model: str - :ivar sampling_params: The parameters used to control the sampling behavior of the model during - text generation. - :vartype sampling_params: ~azure.ai.agents.types.ModelSamplingParams - """ - - type: Required[Literal["azure_ai_model"]] - """The type of target, always ``azure_ai_model``. Required. Default value is \"azure_ai_model\".""" - model: str - """The unique identifier of the Azure AI model.""" - sampling_params: "ModelSamplingParams" - """The parameters used to control the sampling behavior of the model during text generation.""" - - -class AzureAISearchIndex(TypedDict, total=False): - """Azure AI Search Index Definition. - - :ivar id: Asset ID, a unique identifier for the asset. - :vartype id: str - :ivar name: The name of the resource. Required. - :vartype name: str - :ivar version: The version of the resource. Required. - :vartype version: str - :ivar description: The asset description text. - :vartype description: str - :ivar tags: Tag dictionary. Tags can be added, removed, and updated. - :vartype tags: dict[str, str] - :ivar type: Type of index. Required. Azure search. - :vartype type: str or ~azure.ai.agents.models.AZURE_SEARCH - :ivar connection_name: Name of connection to Azure AI Search. Required. - :vartype connection_name: str - :ivar index_name: Name of index in Azure AI Search resource to attach. Required. - :vartype index_name: str - :ivar field_mapping: Field mapping configuration. - :vartype field_mapping: ~azure.ai.agents.types.FieldMapping - """ - - id: str - """Asset ID, a unique identifier for the asset.""" - name: Required[str] - """The name of the resource. Required.""" - version: Required[str] - """The version of the resource. Required.""" - description: str - """The asset description text.""" - tags: dict[str, str] - """Tag dictionary. Tags can be added, removed, and updated.""" - type: Required[Literal[IndexType.AZURE_SEARCH]] - """Type of index. Required. Azure search.""" - connectionName: Required[str] - """Name of connection to Azure AI Search. Required.""" - indexName: Required[str] - """Name of index in Azure AI Search resource to attach. Required.""" - fieldMapping: "FieldMapping" - """Field mapping configuration.""" - - -class AzureAISearchTool(TypedDict, total=False): - """The input definition information for an Azure AI search tool as used to configure an agent. - - :ivar type: The object type, which is always 'azure_ai_search'. Required. AZURE_AI_SEARCH. - :vartype type: str or ~azure.ai.projects.models.AZURE_AI_SEARCH - :ivar azure_ai_search: The azure ai search index resource. Required. - :vartype azure_ai_search: ~azure.ai.agents.types.AzureAISearchToolResource - """ - - type: Required[Literal[ToolType.AZURE_AI_SEARCH]] - """The object type, which is always 'azure_ai_search'. Required. AZURE_AI_SEARCH.""" - azure_ai_search: Required["AzureAISearchToolResource"] - """The azure ai search index resource. Required.""" - - -class AzureAISearchToolResource(TypedDict, total=False): - """A set of index resources used by the ``azure_ai_search`` tool. - - :ivar indexes: The indices attached to this agent. There can be a maximum of 1 index resource - attached to the agent. Required. - :vartype indexes: list[~azure.ai.agents.types.AISearchIndexResource] - """ - - indexes: Required[list["AISearchIndexResource"]] - """The indices attached to this agent. There can be a maximum of 1 index resource attached to the - agent. Required.""" - - -class AzureFunctionBinding(TypedDict, total=False): - """The structure for keeping storage queue name and URI. - - :ivar type: The type of binding, which is always 'storage_queue'. Required. Default value is - "storage_queue". - :vartype type: str - :ivar storage_queue: Storage queue. Required. - :vartype storage_queue: ~azure.ai.agents.types.AzureFunctionStorageQueue - """ - - type: Required[Literal["storage_queue"]] - """The type of binding, which is always 'storage_queue'. Required. Default value is - \"storage_queue\".""" - storage_queue: Required["AzureFunctionStorageQueue"] - """Storage queue. Required.""" - - -class AzureFunctionDefinition(TypedDict, total=False): - """The definition of Azure function. - - :ivar function: The definition of azure function and its parameters. Required. - :vartype function: ~azure.ai.agents.types.AzureFunctionDefinitionFunction - :ivar input_binding: Input storage queue. The queue storage trigger runs a function as messages - are added to it. Required. - :vartype input_binding: ~azure.ai.agents.types.AzureFunctionBinding - :ivar output_binding: Output storage queue. The function writes output to this queue when the - input items are processed. Required. - :vartype output_binding: ~azure.ai.agents.types.AzureFunctionBinding - """ - - function: Required["AzureFunctionDefinitionFunction"] - """The definition of azure function and its parameters. Required.""" - input_binding: Required["AzureFunctionBinding"] - """Input storage queue. The queue storage trigger runs a function as messages are added to it. - Required.""" - output_binding: Required["AzureFunctionBinding"] - """Output storage queue. The function writes output to this queue when the input items are - processed. Required.""" - - -class AzureFunctionDefinitionFunction(TypedDict, total=False): - """AzureFunctionDefinitionFunction. - - :ivar name: The name of the function to be called. Required. - :vartype name: str - :ivar description: A description of what the function does, used by the model to choose when - and how to call the function. - :vartype description: str - :ivar parameters: The parameters the functions accepts, described as a JSON Schema object. - Required. - :vartype parameters: dict[str, any] - """ - - name: Required[str] - """The name of the function to be called. Required.""" - description: str - """A description of what the function does, used by the model to choose when and how to call the - function.""" - parameters: Required[dict[str, Any]] - """The parameters the functions accepts, described as a JSON Schema object. Required.""" - - -class AzureFunctionStorageQueue(TypedDict, total=False): - """The structure for keeping storage queue name and URI. - - :ivar queue_service_endpoint: URI to the Azure Storage Queue service allowing you to manipulate - a queue. Required. - :vartype queue_service_endpoint: str - :ivar queue_name: The name of an Azure function storage queue. Required. - :vartype queue_name: str - """ - - queue_service_endpoint: Required[str] - """URI to the Azure Storage Queue service allowing you to manipulate a queue. Required.""" - queue_name: Required[str] - """The name of an Azure function storage queue. Required.""" - - -class AzureFunctionTool(TypedDict, total=False): - """The input definition information for an Azure Function Tool, as used to configure an Agent. - - :ivar type: The object type, which is always 'browser_automation'. Required. AZURE_FUNCTION. - :vartype type: str or ~azure.ai.projects.models.AZURE_FUNCTION - :ivar azure_function: The Azure Function Tool definition. Required. - :vartype azure_function: ~azure.ai.agents.types.AzureFunctionDefinition - """ - - type: Required[Literal[ToolType.AZURE_FUNCTION]] - """The object type, which is always 'browser_automation'. Required. AZURE_FUNCTION.""" - azure_function: Required["AzureFunctionDefinition"] - """The Azure Function Tool definition. Required.""" - - -class AzureOpenAIModelConfiguration(TypedDict, total=False): - """Azure OpenAI model configuration. The API version would be selected by the service for querying - the model. - - :ivar type: Required. Default value is "AzureOpenAIModel". - :vartype type: str - :ivar model_deployment_name: Deployment name for AOAI model. Example: gpt-4o if in AIServices - or connection based ``connection_name/deployment_name`` (e.g. ``my-aoai-connection/gpt-4o``). - Required. - :vartype model_deployment_name: str - """ - - type: Required[Literal["AzureOpenAIModel"]] - """Required. Default value is \"AzureOpenAIModel\".""" - modelDeploymentName: Required[str] - """Deployment name for AOAI model. Example: gpt-4o if in AIServices or connection based - ``connection_name/deployment_name`` (e.g. ``my-aoai-connection/gpt-4o``). Required.""" - - -class BingCustomSearchConfiguration(TypedDict, total=False): - """A bing custom search configuration. - - :ivar project_connection_id: Project connection id for grounding with bing search. Required. - :vartype project_connection_id: str - :ivar instance_name: Name of the custom configuration instance given to config. Required. - :vartype instance_name: str - :ivar market: The market where the results come from. - :vartype market: str - :ivar set_lang: The language to use for user interface strings when calling Bing API. - :vartype set_lang: str - :ivar count: The number of search results to return in the bing api response. - :vartype count: int - :ivar freshness: Filter search results by a specific time range. See `accepted values here - `_. - :vartype freshness: str - """ - - project_connection_id: Required[str] - """Project connection id for grounding with bing search. Required.""" - instance_name: Required[str] - """Name of the custom configuration instance given to config. Required.""" - market: str - """The market where the results come from.""" - set_lang: str - """The language to use for user interface strings when calling Bing API.""" - count: int - """The number of search results to return in the bing api response.""" - freshness: str - """Filter search results by a specific time range. See `accepted values here - `_.""" - - -class BingCustomSearchPreviewTool(TypedDict, total=False): - """The input definition information for a Bing custom search tool as used to configure an agent. - - :ivar type: The object type, which is always 'bing_custom_search_preview'. Required. - BING_CUSTOM_SEARCH_PREVIEW. - :vartype type: str or ~azure.ai.projects.models.BING_CUSTOM_SEARCH_PREVIEW - :ivar bing_custom_search_preview: The bing custom search tool parameters. Required. - :vartype bing_custom_search_preview: ~azure.ai.agents.types.BingCustomSearchToolParameters - """ - - type: Required[Literal[ToolType.BING_CUSTOM_SEARCH_PREVIEW]] - """The object type, which is always 'bing_custom_search_preview'. Required. - BING_CUSTOM_SEARCH_PREVIEW.""" - bing_custom_search_preview: Required["BingCustomSearchToolParameters"] - """The bing custom search tool parameters. Required.""" - - -class BingCustomSearchToolParameters(TypedDict, total=False): - """The bing custom search tool parameters. - - :ivar search_configurations: The project connections attached to this tool. There can be a - maximum of 1 connection resource attached to the tool. Required. - :vartype search_configurations: list[~azure.ai.agents.types.BingCustomSearchConfiguration] - """ - - search_configurations: Required[list["BingCustomSearchConfiguration"]] - """The project connections attached to this tool. There can be a maximum of 1 connection resource - attached to the tool. Required.""" - - -class BingGroundingSearchConfiguration(TypedDict, total=False): - """Search configuration for Bing Grounding. - - :ivar project_connection_id: Project connection id for grounding with bing search. Required. - :vartype project_connection_id: str - :ivar market: The market where the results come from. - :vartype market: str - :ivar set_lang: The language to use for user interface strings when calling Bing API. - :vartype set_lang: str - :ivar count: The number of search results to return in the bing api response. - :vartype count: int - :ivar freshness: Filter search results by a specific time range. See `accepted values here - `_. - :vartype freshness: str - """ - - project_connection_id: Required[str] - """Project connection id for grounding with bing search. Required.""" - market: str - """The market where the results come from.""" - set_lang: str - """The language to use for user interface strings when calling Bing API.""" - count: int - """The number of search results to return in the bing api response.""" - freshness: str - """Filter search results by a specific time range. See `accepted values here - `_.""" - - -class BingGroundingSearchToolParameters(TypedDict, total=False): - """The bing grounding search tool parameters. - - :ivar search_configurations: The search configurations attached to this tool. There can be a - maximum of 1 search configuration resource attached to the tool. Required. - :vartype search_configurations: list[~azure.ai.agents.types.BingGroundingSearchConfiguration] - """ - - search_configurations: Required[list["BingGroundingSearchConfiguration"]] - """The search configurations attached to this tool. There can be a maximum of 1 search - configuration resource attached to the tool. Required.""" - - -class BingGroundingTool(TypedDict, total=False): - """The input definition information for a bing grounding search tool as used to configure an - agent. - - :ivar type: The object type, which is always 'bing_grounding'. Required. BING_GROUNDING. - :vartype type: str or ~azure.ai.projects.models.BING_GROUNDING - :ivar bing_grounding: The bing grounding search tool parameters. Required. - :vartype bing_grounding: ~azure.ai.agents.types.BingGroundingSearchToolParameters - """ - - type: Required[Literal[ToolType.BING_GROUNDING]] - """The object type, which is always 'bing_grounding'. Required. BING_GROUNDING.""" - bing_grounding: Required["BingGroundingSearchToolParameters"] - """The bing grounding search tool parameters. Required.""" - - -class BlobReference(TypedDict, total=False): - """Blob reference details. - - :ivar blob_uri: Blob URI path for client to upload data. Example: - ``https://blob.windows.core.net/Container/Path``. Required. - :vartype blob_uri: str - :ivar storage_account_arm_id: ARM ID of the storage account to use. Required. - :vartype storage_account_arm_id: str - :ivar credential: Credential info to access the storage account. Required. - :vartype credential: ~azure.ai.agents.types.BlobReferenceSasCredential - """ - - blobUri: Required[str] - """Blob URI path for client to upload data. Example: - ``https://blob.windows.core.net/Container/Path``. Required.""" - storageAccountArmId: Required[str] - """ARM ID of the storage account to use. Required.""" - credential: Required["BlobReferenceSasCredential"] - """Credential info to access the storage account. Required.""" - - -class BlobReferenceSasCredential(TypedDict, total=False): - """SAS Credential definition. - - :ivar sas_uri: SAS uri. Required. - :vartype sas_uri: str - :ivar type: Type of credential. Required. Default value is "SAS". - :vartype type: str - """ - - sasUri: Required[str] - """SAS uri. Required.""" - type: Required[Literal["SAS"]] - """Type of credential. Required. Default value is \"SAS\".""" - - -class BrowserAutomationPreviewTool(TypedDict, total=False): - """The input definition information for a Browser Automation Tool, as used to configure an Agent. - - :ivar type: The object type, which is always 'browser_automation_preview'. Required. - BROWSER_AUTOMATION_PREVIEW. - :vartype type: str or ~azure.ai.projects.models.BROWSER_AUTOMATION_PREVIEW - :ivar browser_automation_preview: The Browser Automation Tool parameters. Required. - :vartype browser_automation_preview: ~azure.ai.agents.types.BrowserAutomationToolParameters - """ - - type: Required[Literal[ToolType.BROWSER_AUTOMATION_PREVIEW]] - """The object type, which is always 'browser_automation_preview'. Required. - BROWSER_AUTOMATION_PREVIEW.""" - browser_automation_preview: Required["BrowserAutomationToolParameters"] - """The Browser Automation Tool parameters. Required.""" - - -class BrowserAutomationToolConnectionParameters(TypedDict, total=False): # pylint: disable=name-too-long - """Definition of input parameters for the connection used by the Browser Automation Tool. - - :ivar project_connection_id: The ID of the project connection to your Azure Playwright - resource. Required. - :vartype project_connection_id: str - """ - - project_connection_id: Required[str] - """The ID of the project connection to your Azure Playwright resource. Required.""" - - -class BrowserAutomationToolParameters(TypedDict, total=False): - """Definition of input parameters for the Browser Automation Tool. - - :ivar connection: The project connection parameters associated with the Browser Automation - Tool. Required. - :vartype connection: ~azure.ai.agents.types.BrowserAutomationToolConnectionParameters - """ - - connection: Required["BrowserAutomationToolConnectionParameters"] - """The project connection parameters associated with the Browser Automation Tool. Required.""" - - -class CaptureStructuredOutputsTool(TypedDict, total=False): - """A tool for capturing structured outputs. - - :ivar type: The type of the tool. Always ``capture_structured_outputs``. Required. - CAPTURE_STRUCTURED_OUTPUTS. - :vartype type: str or ~azure.ai.projects.models.CAPTURE_STRUCTURED_OUTPUTS - :ivar outputs: The structured outputs to capture from the model. Required. - :vartype outputs: ~azure.ai.agents.types.StructuredOutputDefinition - """ - - type: Required[Literal[ToolType.CAPTURE_STRUCTURED_OUTPUTS]] - """The type of the tool. Always ``capture_structured_outputs``. Required. - CAPTURE_STRUCTURED_OUTPUTS.""" - outputs: Required["StructuredOutputDefinition"] - """The structured outputs to capture from the model. Required.""" - - -class ChartCoordinate(TypedDict, total=False): - """Coordinates for the analysis chart. - - :ivar x: X-axis coordinate. Required. - :vartype x: int - :ivar y: Y-axis coordinate. Required. - :vartype y: int - :ivar size: Size of the chart element. Required. - :vartype size: int - """ - - x: Required[int] - """X-axis coordinate. Required.""" - y: Required[int] - """Y-axis coordinate. Required.""" - size: Required[int] - """Size of the chart element. Required.""" - - -class ChatSummaryMemoryItem(TypedDict, total=False): - """A memory item containing a summary extracted from conversations. - - :ivar memory_id: The unique ID of the memory item. Required. - :vartype memory_id: str - :ivar updated_at: The last update time of the memory item. Required. - :vartype updated_at: ~datetime.datetime - :ivar scope: The namespace that logically groups and isolates memories, such as a user ID. - Required. - :vartype scope: str - :ivar content: The content of the memory. Required. - :vartype content: str - :ivar kind: The kind of the memory item. Required. Summary of chat conversations. - :vartype kind: str or ~azure.ai.agents.models.CHAT_SUMMARY - """ - - memory_id: Required[str] - """The unique ID of the memory item. Required.""" - updated_at: Required[int] - """The last update time of the memory item. Required.""" - scope: Required[str] - """The namespace that logically groups and isolates memories, such as a user ID. Required.""" - content: Required[str] - """The content of the memory. Required.""" - kind: Required[Literal[MemoryItemKind.CHAT_SUMMARY]] - """The kind of the memory item. Required. Summary of chat conversations.""" - - -class ClusterInsightResult(TypedDict, total=False): - """Insights from the cluster analysis. - - :ivar summary: Summary of the insights report. Required. - :vartype summary: ~azure.ai.agents.types.InsightSummary - :ivar clusters: List of clusters identified in the insights. Required. - :vartype clusters: list[~azure.ai.agents.types.InsightCluster] - :ivar coordinates: Optional mapping of IDs to 2D coordinates used by the UX for - visualization. - - The map keys are string identifiers (for example, a cluster id or a sample id) - and the values are the coordinates and visual size for rendering on a 2D chart. - - This property is omitted unless the client requests coordinates (for example, - by passing ``includeCoordinates=true`` as a query parameter). - - Example: - - .. code-block:: - - { - "cluster-1": { "x": 12, "y": 34, "size": 8 }, - "sample-123": { "x": 18, "y": 22, "size": 4 } - } - - Coordinates are intended only for client-side visualization and do not - modify the canonical insights results. - :vartype coordinates: dict[str, ~azure.ai.agents.types.ChartCoordinate] - """ - - summary: Required["InsightSummary"] - """Summary of the insights report. Required.""" - clusters: Required[list["InsightCluster"]] - """List of clusters identified in the insights. Required.""" - coordinates: dict[str, "ChartCoordinate"] - """ Optional mapping of IDs to 2D coordinates used by the UX for visualization. - - The map keys are string identifiers (for example, a cluster id or a sample id) - and the values are the coordinates and visual size for rendering on a 2D chart. - - This property is omitted unless the client requests coordinates (for example, - by passing ``includeCoordinates=true`` as a query parameter). - - Example: - - .. code-block:: - - { - \"cluster-1\": { \"x\": 12, \"y\": 34, \"size\": 8 }, - \"sample-123\": { \"x\": 18, \"y\": 22, \"size\": 4 } - } - - Coordinates are intended only for client-side visualization and do not - modify the canonical insights results.""" - - -class ClusterTokenUsage(TypedDict, total=False): - """Token usage for cluster analysis. - - :ivar input_token_usage: input token usage. Required. - :vartype input_token_usage: int - :ivar output_token_usage: output token usage. Required. - :vartype output_token_usage: int - :ivar total_token_usage: total token usage. Required. - :vartype total_token_usage: int - """ - - inputTokenUsage: Required[int] - """input token usage. Required.""" - outputTokenUsage: Required[int] - """output token usage. Required.""" - totalTokenUsage: Required[int] - """total token usage. Required.""" - - -class CodeBasedEvaluatorDefinition(TypedDict, total=False): - """Code-based evaluator definition using python code. - - :ivar init_parameters: The JSON schema (Draft 2020-12) for the evaluator's input parameters. - This includes parameters like type, properties, required. - :vartype init_parameters: dict[str, any] - :ivar data_schema: The JSON schema (Draft 2020-12) for the evaluator's input data. This - includes parameters like type, properties, required. - :vartype data_schema: dict[str, any] - :ivar metrics: List of output metrics produced by this evaluator. - :vartype metrics: dict[str, ~azure.ai.agents.types.EvaluatorMetric] - :ivar type: Required. Code-based definition. - :vartype type: str or ~azure.ai.agents.models.CODE - :ivar code_text: Inline code text for the evaluator. Required. - :vartype code_text: str - """ - - init_parameters: dict[str, Any] - """The JSON schema (Draft 2020-12) for the evaluator's input parameters. This includes parameters - like type, properties, required.""" - data_schema: dict[str, Any] - """The JSON schema (Draft 2020-12) for the evaluator's input data. This includes parameters like - type, properties, required.""" - metrics: dict[str, "EvaluatorMetric"] - """List of output metrics produced by this evaluator.""" - type: Required[Literal[EvaluatorDefinitionType.CODE]] - """Required. Code-based definition.""" - code_text: Required[str] - """Inline code text for the evaluator. Required.""" - - -class Connection(TypedDict, total=False): - """Response from the list and get connections operations. - - :ivar name: The friendly name of the connection, provided by the user. Required. - :vartype name: str - :ivar id: A unique identifier for the connection, generated by the service. Required. - :vartype id: str - :ivar type: Category of the connection. Required. Known values are: "AzureOpenAI", "AzureBlob", - "AzureStorageAccount", "CognitiveSearch", "CosmosDB", "ApiKey", "AppConfig", "AppInsights", - "CustomKeys", and "RemoteTool_Preview". - :vartype type: str or ~azure.ai.agents.models.ConnectionType - :ivar target: The connection URL to be used for this service. Required. - :vartype target: str - :ivar is_default: Whether the connection is tagged as the default connection of its type. - Required. - :vartype is_default: bool - :ivar credentials: The credentials used by the connection. Required. - :vartype credentials: ~azure.ai.agents.types.BaseCredentials - :ivar metadata: Metadata of the connection. Required. - :vartype metadata: dict[str, str] - """ - - name: Required[str] - """The friendly name of the connection, provided by the user. Required.""" - id: Required[str] - """A unique identifier for the connection, generated by the service. Required.""" - type: Required[ConnectionType] - """Category of the connection. Required. Known values are: \"AzureOpenAI\", \"AzureBlob\", - \"AzureStorageAccount\", \"CognitiveSearch\", \"CosmosDB\", \"ApiKey\", \"AppConfig\", - \"AppInsights\", \"CustomKeys\", and \"RemoteTool_Preview\".""" - target: Required[str] - """The connection URL to be used for this service. Required.""" - isDefault: Required[bool] - """Whether the connection is tagged as the default connection of its type. Required.""" - credentials: Required["BaseCredentials"] - """The credentials used by the connection. Required.""" - metadata: Required[dict[str, str]] - """Metadata of the connection. Required.""" - - -class ContinuousEvaluationRuleAction(TypedDict, total=False): - """Evaluation rule action for continuous evaluation. - - :ivar type: Required. Continuous evaluation. - :vartype type: str or ~azure.ai.agents.models.CONTINUOUS_EVALUATION - :ivar eval_id: Eval Id to add continuous evaluation runs to. Required. - :vartype eval_id: str - :ivar max_hourly_runs: Maximum number of evaluation runs allowed per hour. - :vartype max_hourly_runs: int - """ - - type: Required[Literal[EvaluationRuleActionType.CONTINUOUS_EVALUATION]] - """Required. Continuous evaluation.""" - evalId: Required[str] - """Eval Id to add continuous evaluation runs to. Required.""" - maxHourlyRuns: int - """Maximum number of evaluation runs allowed per hour.""" - - -class CosmosDBIndex(TypedDict, total=False): - """CosmosDB Vector Store Index Definition. - - :ivar id: Asset ID, a unique identifier for the asset. - :vartype id: str - :ivar name: The name of the resource. Required. - :vartype name: str - :ivar version: The version of the resource. Required. - :vartype version: str - :ivar description: The asset description text. - :vartype description: str - :ivar tags: Tag dictionary. Tags can be added, removed, and updated. - :vartype tags: dict[str, str] - :ivar type: Type of index. Required. CosmosDB. - :vartype type: str or ~azure.ai.agents.models.COSMOS_DB - :ivar connection_name: Name of connection to CosmosDB. Required. - :vartype connection_name: str - :ivar database_name: Name of the CosmosDB Database. Required. - :vartype database_name: str - :ivar container_name: Name of CosmosDB Container. Required. - :vartype container_name: str - :ivar embedding_configuration: Embedding model configuration. Required. - :vartype embedding_configuration: ~azure.ai.agents.types.EmbeddingConfiguration - :ivar field_mapping: Field mapping configuration. Required. - :vartype field_mapping: ~azure.ai.agents.types.FieldMapping - """ - - id: str - """Asset ID, a unique identifier for the asset.""" - name: Required[str] - """The name of the resource. Required.""" - version: Required[str] - """The version of the resource. Required.""" - description: str - """The asset description text.""" - tags: dict[str, str] - """Tag dictionary. Tags can be added, removed, and updated.""" - type: Required[Literal[IndexType.COSMOS_DB]] - """Type of index. Required. CosmosDB.""" - connectionName: Required[str] - """Name of connection to CosmosDB. Required.""" - databaseName: Required[str] - """Name of the CosmosDB Database. Required.""" - containerName: Required[str] - """Name of CosmosDB Container. Required.""" - embeddingConfiguration: Required["EmbeddingConfiguration"] - """Embedding model configuration. Required.""" - fieldMapping: Required["FieldMapping"] - """Field mapping configuration. Required.""" - - -class CronTrigger(TypedDict, total=False): - """Cron based trigger. - - :ivar type: Required. Cron based trigger. - :vartype type: str or ~azure.ai.agents.models.CRON - :ivar expression: Cron expression that defines the schedule frequency. Required. - :vartype expression: str - :ivar time_zone: Time zone for the cron schedule. - :vartype time_zone: str - :ivar start_time: Start time for the cron schedule in ISO 8601 format. - :vartype start_time: ~datetime.datetime - :ivar end_time: End time for the cron schedule in ISO 8601 format. - :vartype end_time: ~datetime.datetime - """ - - type: Required[Literal[TriggerType.CRON]] - """Required. Cron based trigger.""" - expression: Required[str] - """Cron expression that defines the schedule frequency. Required.""" - timeZone: str - """Time zone for the cron schedule.""" - startTime: str - """Start time for the cron schedule in ISO 8601 format.""" - endTime: str - """End time for the cron schedule in ISO 8601 format.""" - - -class CustomCredential(TypedDict, total=False): - """Custom credential definition. - - :ivar type: The credential type. Required. Custom credential. - :vartype type: str or ~azure.ai.agents.models.CUSTOM - """ - - type: Required[Literal[CredentialType.CUSTOM]] - """The credential type. Required. Custom credential.""" - - -class DailyRecurrenceSchedule(TypedDict, total=False): - """Daily recurrence schedule. - - :ivar type: Daily recurrence type. Required. Daily recurrence pattern. - :vartype type: str or ~azure.ai.agents.models.DAILY - :ivar hours: Hours for the recurrence schedule. Required. - :vartype hours: list[int] - """ - - type: Required[Literal[RecurrenceType.DAILY]] - """Daily recurrence type. Required. Daily recurrence pattern.""" - hours: Required[list[int]] - """Hours for the recurrence schedule. Required.""" - - -class DatasetCredential(TypedDict, total=False): - """Represents a reference to a blob for consumption. - - :ivar blob_reference: Credential info to access the storage account. Required. - :vartype blob_reference: ~azure.ai.agents.types.BlobReference - """ - - blobReference: Required["BlobReference"] - """Credential info to access the storage account. Required.""" - - -class DeleteAgentResponse(TypedDict, total=False): - """A deleted agent Object. - - :ivar object: The object type. Always 'agent.deleted'. Required. AGENT_DELETED. - :vartype object: str or ~azure.ai.agents.models.AGENT_DELETED - :ivar name: The name of the agent. Required. - :vartype name: str - :ivar deleted: Whether the agent was successfully deleted. Required. - :vartype deleted: bool - """ - - object: Required[Literal[AgentObjectType.AGENT_DELETED]] - """The object type. Always 'agent.deleted'. Required. AGENT_DELETED.""" - name: Required[str] - """The name of the agent. Required.""" - deleted: Required[bool] - """Whether the agent was successfully deleted. Required.""" - - -class DeleteAgentVersionResponse(TypedDict, total=False): - """A deleted agent version Object. - - :ivar object: The object type. Always 'agent.version.deleted'. Required. AGENT_VERSION_DELETED. - :vartype object: str or ~azure.ai.agents.models.AGENT_VERSION_DELETED - :ivar name: The name of the agent. Required. - :vartype name: str - :ivar version: The version identifier of the agent. Required. - :vartype version: str - :ivar deleted: Whether the agent was successfully deleted. Required. - :vartype deleted: bool - """ - - object: Required[Literal[AgentObjectType.AGENT_VERSION_DELETED]] - """The object type. Always 'agent.version.deleted'. Required. AGENT_VERSION_DELETED.""" - name: Required[str] - """The name of the agent. Required.""" - version: Required[str] - """The version identifier of the agent. Required.""" - deleted: Required[bool] - """Whether the agent was successfully deleted. Required.""" - - -class DeleteMemoryStoreResult(TypedDict, total=False): - """DeleteMemoryStoreResult. - - :ivar object: The object type. Always 'memory_store.deleted'. Required. MEMORY_STORE_DELETED. - :vartype object: str or ~azure.ai.agents.models.MEMORY_STORE_DELETED - :ivar name: The name of the memory store. Required. - :vartype name: str - :ivar deleted: Whether the memory store was successfully deleted. Required. - :vartype deleted: bool - """ - - object: Required[Literal[MemoryStoreObjectType.MEMORY_STORE_DELETED]] - """The object type. Always 'memory_store.deleted'. Required. MEMORY_STORE_DELETED.""" - name: Required[str] - """The name of the memory store. Required.""" - deleted: Required[bool] - """Whether the memory store was successfully deleted. Required.""" - - -class EmbeddingConfiguration(TypedDict, total=False): - """Embedding configuration class. - - :ivar model_deployment_name: Deployment name of embedding model. It can point to a model - deployment either in the parent AIServices or a connection. Required. - :vartype model_deployment_name: str - :ivar embedding_field: Embedding field. Required. - :vartype embedding_field: str - """ - - modelDeploymentName: Required[str] - """Deployment name of embedding model. It can point to a model deployment either in the parent - AIServices or a connection. Required.""" - embeddingField: Required[str] - """Embedding field. Required.""" - - -class EntraIDCredentials(TypedDict, total=False): - """Entra ID credential definition. - - :ivar type: The credential type. Required. Entra ID credential (formerly known as AAD). - :vartype type: str or ~azure.ai.agents.models.ENTRA_ID - """ - - type: Required[Literal[CredentialType.ENTRA_ID]] - """The credential type. Required. Entra ID credential (formerly known as AAD).""" - - -class EvalResult(TypedDict, total=False): - """Result of the evaluation. - - :ivar name: name of the check. Required. - :vartype name: str - :ivar type: type of the check. Required. - :vartype type: str - :ivar score: score. Required. - :vartype score: float - :ivar passed: indicates if the check passed or failed. Required. - :vartype passed: bool - """ - - name: Required[str] - """name of the check. Required.""" - type: Required[str] - """type of the check. Required.""" - score: Required[float] - """score. Required.""" - passed: Required[bool] - """indicates if the check passed or failed. Required.""" - - -class EvalRunResultCompareItem(TypedDict, total=False): - """Metric comparison for a treatment against the baseline. - - :ivar treatment_run_id: The treatment run ID. Required. - :vartype treatment_run_id: str - :ivar treatment_run_summary: Summary statistics of the treatment run. Required. - :vartype treatment_run_summary: ~azure.ai.agents.types.EvalRunResultSummary - :ivar delta_estimate: Estimated difference between treatment and baseline. Required. - :vartype delta_estimate: float - :ivar p_value: P-value for the treatment effect. Required. - :vartype p_value: float - :ivar treatment_effect: Type of treatment effect. Required. Known values are: "TooFewSamples", - "Inconclusive", "Changed", "Improved", and "Degraded". - :vartype treatment_effect: str or ~azure.ai.agents.models.TreatmentEffectType - """ - - treatmentRunId: Required[str] - """The treatment run ID. Required.""" - treatmentRunSummary: Required["EvalRunResultSummary"] - """Summary statistics of the treatment run. Required.""" - deltaEstimate: Required[float] - """Estimated difference between treatment and baseline. Required.""" - pValue: Required[float] - """P-value for the treatment effect. Required.""" - treatmentEffect: Required[TreatmentEffectType] - """Type of treatment effect. Required. Known values are: \"TooFewSamples\", \"Inconclusive\", - \"Changed\", \"Improved\", and \"Degraded\".""" - - -class EvalRunResultComparison(TypedDict, total=False): - """Comparison results for treatment runs against the baseline. - - :ivar testing_criteria: Name of the testing criteria. Required. - :vartype testing_criteria: str - :ivar metric: Metric being evaluated. Required. - :vartype metric: str - :ivar evaluator: Name of the evaluator for this testing criteria. Required. - :vartype evaluator: str - :ivar baseline_run_summary: Summary statistics of the baseline run. Required. - :vartype baseline_run_summary: ~azure.ai.agents.types.EvalRunResultSummary - :ivar compare_items: List of comparison results for each treatment run. Required. - :vartype compare_items: list[~azure.ai.agents.types.EvalRunResultCompareItem] - """ - - testingCriteria: Required[str] - """Name of the testing criteria. Required.""" - metric: Required[str] - """Metric being evaluated. Required.""" - evaluator: Required[str] - """Name of the evaluator for this testing criteria. Required.""" - baselineRunSummary: Required["EvalRunResultSummary"] - """Summary statistics of the baseline run. Required.""" - compareItems: Required[list["EvalRunResultCompareItem"]] - """List of comparison results for each treatment run. Required.""" - - -class EvalRunResultSummary(TypedDict, total=False): - """Summary statistics of a metric in an evaluation run. - - :ivar run_id: The evaluation run ID. Required. - :vartype run_id: str - :ivar sample_count: Number of samples in the evaluation run. Required. - :vartype sample_count: int - :ivar average: Average value of the metric in the evaluation run. Required. - :vartype average: float - :ivar standard_deviation: Standard deviation of the metric in the evaluation run. Required. - :vartype standard_deviation: float - """ - - runId: Required[str] - """The evaluation run ID. Required.""" - sampleCount: Required[int] - """Number of samples in the evaluation run. Required.""" - average: Required[float] - """Average value of the metric in the evaluation run. Required.""" - standardDeviation: Required[float] - """Standard deviation of the metric in the evaluation run. Required.""" - - -class EvaluationComparisonInsightRequest(TypedDict, total=False): - """Evaluation Comparison Request. - - :ivar type: The type of request. Required. Evaluation Comparison. - :vartype type: str or ~azure.ai.agents.models.EVALUATION_COMPARISON - :ivar eval_id: Identifier for the evaluation. Required. - :vartype eval_id: str - :ivar baseline_run_id: The baseline run ID for comparison. Required. - :vartype baseline_run_id: str - :ivar treatment_run_ids: List of treatment run IDs for comparison. Required. - :vartype treatment_run_ids: list[str] - """ - - type: Required[Literal[InsightType.EVALUATION_COMPARISON]] - """The type of request. Required. Evaluation Comparison.""" - evalId: Required[str] - """Identifier for the evaluation. Required.""" - baselineRunId: Required[str] - """The baseline run ID for comparison. Required.""" - treatmentRunIds: Required[list[str]] - """List of treatment run IDs for comparison. Required.""" - - -class EvaluationComparisonInsightResult(TypedDict, total=False): - """Insights from the evaluation comparison. - - :ivar type: The type of insights result. Required. Evaluation Comparison. - :vartype type: str or ~azure.ai.agents.models.EVALUATION_COMPARISON - :ivar comparisons: Comparison results for each treatment run against the baseline. Required. - :vartype comparisons: list[~azure.ai.agents.types.EvalRunResultComparison] - :ivar method: The statistical method used for comparison. Required. - :vartype method: str - """ - - type: Required[Literal[InsightType.EVALUATION_COMPARISON]] - """The type of insights result. Required. Evaluation Comparison.""" - comparisons: Required[list["EvalRunResultComparison"]] - """Comparison results for each treatment run against the baseline. Required.""" - method: Required[str] - """The statistical method used for comparison. Required.""" - - -class EvaluationResultSample(TypedDict, total=False): - """A sample from the evaluation result. - - :ivar id: The unique identifier for the analysis sample. Required. - :vartype id: str - :ivar features: Features to help with additional filtering of data in UX. Required. - :vartype features: dict[str, any] - :ivar correlation_info: Info about the correlation for the analysis sample. Required. - :vartype correlation_info: dict[str, any] - :ivar type: Evaluation Result Sample Type. Required. A sample from the evaluation result. - :vartype type: str or ~azure.ai.agents.models.EVALUATION_RESULT_SAMPLE - :ivar evaluation_result: Evaluation result for the analysis sample. Required. - :vartype evaluation_result: ~azure.ai.agents.types.EvalResult - """ - - id: Required[str] - """The unique identifier for the analysis sample. Required.""" - features: Required[dict[str, Any]] - """Features to help with additional filtering of data in UX. Required.""" - correlationInfo: Required[dict[str, Any]] - """Info about the correlation for the analysis sample. Required.""" - type: Required[Literal[SampleType.EVALUATION_RESULT_SAMPLE]] - """Evaluation Result Sample Type. Required. A sample from the evaluation result.""" - evaluationResult: Required["EvalResult"] - """Evaluation result for the analysis sample. Required.""" - - -class EvaluationRule(TypedDict, total=False): - """Evaluation rule model. - - :ivar id: Unique identifier for the evaluation rule. Required. - :vartype id: str - :ivar display_name: Display Name for the evaluation rule. - :vartype display_name: str - :ivar description: Description for the evaluation rule. - :vartype description: str - :ivar action: Definition of the evaluation rule action. Required. - :vartype action: ~azure.ai.agents.types.EvaluationRuleAction - :ivar filter: Filter condition of the evaluation rule. - :vartype filter: ~azure.ai.agents.types.EvaluationRuleFilter - :ivar event_type: Event type that the evaluation rule applies to. Required. Known values are: - "responseCompleted" and "manual". - :vartype event_type: str or ~azure.ai.agents.models.EvaluationRuleEventType - :ivar enabled: Indicates whether the evaluation rule is enabled. Default is true. Required. - :vartype enabled: bool - :ivar system_data: System metadata for the evaluation rule. Required. - :vartype system_data: dict[str, str] - """ - - id: Required[str] - """Unique identifier for the evaluation rule. Required.""" - displayName: str - """Display Name for the evaluation rule.""" - description: str - """Description for the evaluation rule.""" - action: Required["EvaluationRuleAction"] - """Definition of the evaluation rule action. Required.""" - filter: "EvaluationRuleFilter" - """Filter condition of the evaluation rule.""" - eventType: Required[EvaluationRuleEventType] - """Event type that the evaluation rule applies to. Required. Known values are: - \"responseCompleted\" and \"manual\".""" - enabled: Required[bool] - """Indicates whether the evaluation rule is enabled. Default is true. Required.""" - systemData: Required[dict[str, str]] - """System metadata for the evaluation rule. Required.""" - - -class EvaluationRuleFilter(TypedDict, total=False): - """Evaluation filter model. - - :ivar agent_name: Filter by agent name. Required. - :vartype agent_name: str - """ - - agentName: Required[str] - """Filter by agent name. Required.""" - - -class EvaluationRunClusterInsightRequest(TypedDict, total=False): - """Insights on set of Evaluation Results. - - :ivar type: The type of insights request. Required. Insights on an Evaluation run result. - :vartype type: str or ~azure.ai.agents.models.EVALUATION_RUN_CLUSTER_INSIGHT - :ivar eval_id: Evaluation Id for the insights. Required. - :vartype eval_id: str - :ivar run_ids: List of evaluation run IDs for the insights. Required. - :vartype run_ids: list[str] - :ivar model_configuration: Configuration of the model used in the insight generation. - :vartype model_configuration: ~azure.ai.agents.types.InsightModelConfiguration - """ - - type: Required[Literal[InsightType.EVALUATION_RUN_CLUSTER_INSIGHT]] - """The type of insights request. Required. Insights on an Evaluation run result.""" - evalId: Required[str] - """Evaluation Id for the insights. Required.""" - runIds: Required[list[str]] - """List of evaluation run IDs for the insights. Required.""" - modelConfiguration: "InsightModelConfiguration" - """Configuration of the model used in the insight generation.""" - - -class EvaluationRunClusterInsightResult(TypedDict, total=False): - """Insights from the evaluation run cluster analysis. - - :ivar type: The type of insights result. Required. Insights on an Evaluation run result. - :vartype type: str or ~azure.ai.agents.models.EVALUATION_RUN_CLUSTER_INSIGHT - :ivar cluster_insight: Required. - :vartype cluster_insight: ~azure.ai.agents.types.ClusterInsightResult - """ - - type: Required[Literal[InsightType.EVALUATION_RUN_CLUSTER_INSIGHT]] - """The type of insights result. Required. Insights on an Evaluation run result.""" - clusterInsight: Required["ClusterInsightResult"] - """Required.""" - - -class EvaluationScheduleTask(TypedDict, total=False): - """Evaluation task for the schedule. - - :ivar configuration: Configuration for the task. - :vartype configuration: dict[str, str] - :ivar type: Required. Evaluation task. - :vartype type: str or ~azure.ai.agents.models.EVALUATION - :ivar eval_id: Identifier of the evaluation group. Required. - :vartype eval_id: str - :ivar eval_run: The evaluation run payload. Required. - :vartype eval_run: any - """ - - configuration: dict[str, str] - """Configuration for the task.""" - type: Required[Literal[ScheduleTaskType.EVALUATION]] - """Required. Evaluation task.""" - evalId: Required[str] - """Identifier of the evaluation group. Required.""" - evalRun: Required[Any] - """The evaluation run payload. Required.""" - - -class EvaluationTaxonomy(TypedDict, total=False): - """Evaluation Taxonomy Definition. - - :ivar id: Asset ID, a unique identifier for the asset. - :vartype id: str - :ivar name: The name of the resource. Required. - :vartype name: str - :ivar version: The version of the resource. Required. - :vartype version: str - :ivar description: The asset description text. - :vartype description: str - :ivar tags: Tag dictionary. Tags can be added, removed, and updated. - :vartype tags: dict[str, str] - :ivar taxonomy_input: Input configuration for the evaluation taxonomy. Required. - :vartype taxonomy_input: ~azure.ai.agents.types.EvaluationTaxonomyInput - :ivar taxonomy_categories: List of taxonomy categories. - :vartype taxonomy_categories: list[~azure.ai.agents.types.TaxonomyCategory] - :ivar properties: Additional properties for the evaluation taxonomy. - :vartype properties: dict[str, str] - """ - - id: str - """Asset ID, a unique identifier for the asset.""" - name: Required[str] - """The name of the resource. Required.""" - version: Required[str] - """The version of the resource. Required.""" - description: str - """The asset description text.""" - tags: dict[str, str] - """Tag dictionary. Tags can be added, removed, and updated.""" - taxonomyInput: Required["EvaluationTaxonomyInput"] - """Input configuration for the evaluation taxonomy. Required.""" - taxonomyCategories: list["TaxonomyCategory"] - """List of taxonomy categories.""" - properties: dict[str, str] - """Additional properties for the evaluation taxonomy.""" - - -class EvaluatorMetric(TypedDict, total=False): - """Evaluator Metric. - - :ivar type: Type of the metric. Known values are: "ordinal", "continuous", and "boolean". - :vartype type: str or ~azure.ai.agents.models.EvaluatorMetricType - :ivar desirable_direction: It indicates whether a higher value is better or a lower value is - better for this metric. Known values are: "increase", "decrease", and "neutral". - :vartype desirable_direction: str or ~azure.ai.agents.models.EvaluatorMetricDirection - :ivar min_value: Minimum value for the metric. - :vartype min_value: float - :ivar max_value: Maximum value for the metric. If not specified, it is assumed to be unbounded. - :vartype max_value: float - :ivar is_primary: Indicates if this metric is primary when there are multiple metrics. - :vartype is_primary: bool - """ - - type: EvaluatorMetricType - """Type of the metric. Known values are: \"ordinal\", \"continuous\", and \"boolean\".""" - desirable_direction: EvaluatorMetricDirection - """It indicates whether a higher value is better or a lower value is better for this metric. Known - values are: \"increase\", \"decrease\", and \"neutral\".""" - min_value: float - """Minimum value for the metric.""" - max_value: float - """Maximum value for the metric. If not specified, it is assumed to be unbounded.""" - is_primary: bool - """Indicates if this metric is primary when there are multiple metrics.""" - - -class EvaluatorVersion(TypedDict, total=False): - """Evaluator Definition. - - :ivar display_name: Display Name for evaluator. It helps to find the evaluator easily in AI - Foundry. It does not need to be unique. - :vartype display_name: str - :ivar metadata: Metadata about the evaluator. - :vartype metadata: dict[str, str] - :ivar evaluator_type: The type of the evaluator. Required. Known values are: "builtin" and - "custom". - :vartype evaluator_type: str or ~azure.ai.agents.models.EvaluatorType - :ivar categories: The categories of the evaluator. Required. - :vartype categories: list[str or ~azure.ai.agents.models.EvaluatorCategory] - :ivar definition: Definition of the evaluator. Required. - :vartype definition: ~azure.ai.agents.types.EvaluatorDefinition - :ivar created_by: Creator of the evaluator. Required. - :vartype created_by: str - :ivar created_at: Creation date/time of the evaluator. Required. - :vartype created_at: ~datetime.datetime - :ivar modified_at: Last modified date/time of the evaluator. Required. - :vartype modified_at: ~datetime.datetime - :ivar id: Asset ID, a unique identifier for the asset. - :vartype id: str - :ivar name: The name of the resource. Required. - :vartype name: str - :ivar version: The version of the resource. Required. - :vartype version: str - :ivar description: The asset description text. - :vartype description: str - :ivar tags: Tag dictionary. Tags can be added, removed, and updated. - :vartype tags: dict[str, str] - """ - - display_name: str - """Display Name for evaluator. It helps to find the evaluator easily in AI Foundry. It does not - need to be unique.""" - metadata: dict[str, str] - """Metadata about the evaluator.""" - evaluator_type: Required[EvaluatorType] - """The type of the evaluator. Required. Known values are: \"builtin\" and \"custom\".""" - categories: Required[list[EvaluatorCategory]] - """The categories of the evaluator. Required.""" - definition: Required["EvaluatorDefinition"] - """Definition of the evaluator. Required.""" - created_by: Required[str] - """Creator of the evaluator. Required.""" - created_at: Required[str] - """Creation date/time of the evaluator. Required.""" - modified_at: Required[str] - """Last modified date/time of the evaluator. Required.""" - id: str - """Asset ID, a unique identifier for the asset.""" - name: Required[str] - """The name of the resource. Required.""" - version: Required[str] - """The version of the resource. Required.""" - description: str - """The asset description text.""" - tags: dict[str, str] - """Tag dictionary. Tags can be added, removed, and updated.""" - - -class FabricDataAgentToolParameters(TypedDict, total=False): - """The fabric data agent tool parameters. - - :ivar project_connections: The project connections attached to this tool. There can be a - maximum of 1 connection resource attached to the tool. - :vartype project_connections: list[~azure.ai.agents.types.ToolProjectConnection] - """ - - project_connections: list["ToolProjectConnection"] - """The project connections attached to this tool. There can be a maximum of 1 connection resource - attached to the tool.""" - - -class FieldMapping(TypedDict, total=False): - """Field mapping configuration class. - - :ivar content_fields: List of fields with text content. Required. - :vartype content_fields: list[str] - :ivar filepath_field: Path of file to be used as a source of text content. - :vartype filepath_field: str - :ivar title_field: Field containing the title of the document. - :vartype title_field: str - :ivar url_field: Field containing the url of the document. - :vartype url_field: str - :ivar vector_fields: List of fields with vector content. - :vartype vector_fields: list[str] - :ivar metadata_fields: List of fields with metadata content. - :vartype metadata_fields: list[str] - """ - - contentFields: Required[list[str]] - """List of fields with text content. Required.""" - filepathField: str - """Path of file to be used as a source of text content.""" - titleField: str - """Field containing the title of the document.""" - urlField: str - """Field containing the url of the document.""" - vectorFields: list[str] - """List of fields with vector content.""" - metadataFields: list[str] - """List of fields with metadata content.""" - - -class FileDatasetVersion(TypedDict, total=False): - """FileDatasetVersion Definition. - - :ivar data_uri: URI of the data (`example `_). - Required. - :vartype data_uri: str - :ivar is_reference: Indicates if the dataset holds a reference to the storage, or the dataset - manages storage itself. If true, the underlying data will not be deleted when the dataset - version is deleted. - :vartype is_reference: bool - :ivar connection_name: The Azure Storage Account connection name. Required if - startPendingUploadVersion was not called before creating the Dataset. - :vartype connection_name: str - :ivar id: Asset ID, a unique identifier for the asset. - :vartype id: str - :ivar name: The name of the resource. Required. - :vartype name: str - :ivar version: The version of the resource. Required. - :vartype version: str - :ivar description: The asset description text. - :vartype description: str - :ivar tags: Tag dictionary. Tags can be added, removed, and updated. - :vartype tags: dict[str, str] - :ivar type: Dataset type. Required. URI file. - :vartype type: str or ~azure.ai.agents.models.URI_FILE - """ - - dataUri: Required[str] - """URI of the data (`example `_). Required.""" - isReference: bool - """Indicates if the dataset holds a reference to the storage, or the dataset manages storage - itself. If true, the underlying data will not be deleted when the dataset version is deleted.""" - connectionName: str - """The Azure Storage Account connection name. Required if startPendingUploadVersion was not called - before creating the Dataset.""" - id: str - """Asset ID, a unique identifier for the asset.""" - name: Required[str] - """The name of the resource. Required.""" - version: Required[str] - """The version of the resource. Required.""" - description: str - """The asset description text.""" - tags: dict[str, str] - """Tag dictionary. Tags can be added, removed, and updated.""" - type: Required[Literal[DatasetType.URI_FILE]] - """Dataset type. Required. URI file.""" - - -class FolderDatasetVersion(TypedDict, total=False): - """FileDatasetVersion Definition. - - :ivar data_uri: URI of the data (`example `_). - Required. - :vartype data_uri: str - :ivar is_reference: Indicates if the dataset holds a reference to the storage, or the dataset - manages storage itself. If true, the underlying data will not be deleted when the dataset - version is deleted. - :vartype is_reference: bool - :ivar connection_name: The Azure Storage Account connection name. Required if - startPendingUploadVersion was not called before creating the Dataset. - :vartype connection_name: str - :ivar id: Asset ID, a unique identifier for the asset. - :vartype id: str - :ivar name: The name of the resource. Required. - :vartype name: str - :ivar version: The version of the resource. Required. - :vartype version: str - :ivar description: The asset description text. - :vartype description: str - :ivar tags: Tag dictionary. Tags can be added, removed, and updated. - :vartype tags: dict[str, str] - :ivar type: Dataset type. Required. URI folder. - :vartype type: str or ~azure.ai.agents.models.URI_FOLDER - """ - - dataUri: Required[str] - """URI of the data (`example `_). Required.""" - isReference: bool - """Indicates if the dataset holds a reference to the storage, or the dataset manages storage - itself. If true, the underlying data will not be deleted when the dataset version is deleted.""" - connectionName: str - """The Azure Storage Account connection name. Required if startPendingUploadVersion was not called - before creating the Dataset.""" - id: str - """Asset ID, a unique identifier for the asset.""" - name: Required[str] - """The name of the resource. Required.""" - version: Required[str] - """The version of the resource. Required.""" - description: str - """The asset description text.""" - tags: dict[str, str] - """Tag dictionary. Tags can be added, removed, and updated.""" - type: Required[Literal[DatasetType.URI_FOLDER]] - """Dataset type. Required. URI folder.""" - - -class HostedAgentDefinition(TypedDict, total=False): - """The hosted agent definition. - - :ivar rai_config: Configuration for Responsible AI (RAI) content filtering and safety features. - :vartype rai_config: ~azure.ai.agents.types.RaiConfig - :ivar kind: Required. HOSTED. - :vartype kind: str or ~azure.ai.agents.models.HOSTED - :ivar tools: An array of tools the hosted agent's model may call while generating a response. - You can specify which tool to use by setting the ``tool_choice`` parameter. - :vartype tools: list[~azure.ai.projects.types.Tool] - :ivar container_protocol_versions: The protocols that the agent supports for ingress - communication of the containers. Required. - :vartype container_protocol_versions: list[~azure.ai.agents.types.ProtocolVersionRecord] - :ivar cpu: The CPU configuration for the hosted agent. Required. - :vartype cpu: str - :ivar memory: The memory configuration for the hosted agent. Required. - :vartype memory: str - :ivar environment_variables: Environment variables to set in the hosted agent container. - :vartype environment_variables: dict[str, str] - :ivar image: The image ID for the agent, applicable to image-based hosted agents. - :vartype image: str - """ - - rai_config: "RaiConfig" - """Configuration for Responsible AI (RAI) content filtering and safety features.""" - kind: Required[Literal[AgentKind.HOSTED]] - """Required. HOSTED.""" - tools: list["Tool"] - """An array of tools the hosted agent's model may call while generating a response. You can - specify which tool to use by setting the ``tool_choice`` parameter.""" - container_protocol_versions: Required[list["ProtocolVersionRecord"]] - """The protocols that the agent supports for ingress communication of the containers. Required.""" - cpu: Required[str] - """The CPU configuration for the hosted agent. Required.""" - memory: Required[str] - """The memory configuration for the hosted agent. Required.""" - environment_variables: dict[str, str] - """Environment variables to set in the hosted agent container.""" - image: str - """The image ID for the agent, applicable to image-based hosted agents.""" - - -class HourlyRecurrenceSchedule(TypedDict, total=False): - """Hourly recurrence schedule. - - :ivar type: Required. Hourly recurrence pattern. - :vartype type: str or ~azure.ai.agents.models.HOURLY - """ - - type: Required[Literal[RecurrenceType.HOURLY]] - """Required. Hourly recurrence pattern.""" - - -class HumanEvaluationPreviewRuleAction(TypedDict, total=False): - """Evaluation rule action for human evaluation. - - :ivar type: Required. Human evaluation preview. - :vartype type: str or ~azure.ai.agents.models.HUMAN_EVALUATION_PREVIEW - :ivar template_id: Human evaluation template Id. Required. - :vartype template_id: str - """ - - type: Required[Literal[EvaluationRuleActionType.HUMAN_EVALUATION_PREVIEW]] - """Required. Human evaluation preview.""" - templateId: Required[str] - """Human evaluation template Id. Required.""" - - -class Insight(TypedDict, total=False): - """The response body for cluster insights. - - :ivar insight_id: The unique identifier for the insights report. Required. - :vartype insight_id: str - :ivar metadata: Metadata about the insights report. Required. - :vartype metadata: ~azure.ai.agents.types.InsightsMetadata - :ivar state: The current state of the insights. Required. Known values are: "NotStarted", - "Running", "Succeeded", "Failed", and "Canceled". - :vartype state: str or ~azure.ai.agents.models.OperationState - :ivar display_name: User friendly display name for the insight. Required. - :vartype display_name: str - :ivar request: Request for the insights analysis. Required. - :vartype request: ~azure.ai.agents.types.InsightRequest - :ivar result: The result of the insights report. - :vartype result: ~azure.ai.agents.types.InsightResult - """ - - id: Required[str] - """The unique identifier for the insights report. Required.""" - metadata: Required["InsightsMetadata"] - """Metadata about the insights report. Required.""" - state: Required[OperationState] - """The current state of the insights. Required. Known values are: \"NotStarted\", \"Running\", - \"Succeeded\", \"Failed\", and \"Canceled\".""" - displayName: Required[str] - """User friendly display name for the insight. Required.""" - request: Required["InsightRequest"] - """Request for the insights analysis. Required.""" - result: "InsightResult" - """The result of the insights report.""" - - -class InsightCluster(TypedDict, total=False): - """A cluster of analysis samples. - - :ivar id: The id of the analysis cluster. Required. - :vartype id: str - :ivar label: Label for the cluster. Required. - :vartype label: str - :ivar suggestion: Suggestion for the cluster. Required. - :vartype suggestion: str - :ivar suggestion_title: The title of the suggestion for the cluster. Required. - :vartype suggestion_title: str - :ivar description: Description of the analysis cluster. Required. - :vartype description: str - :ivar weight: The weight of the analysis cluster. This indicate number of samples in the - cluster. Required. - :vartype weight: int - :ivar sub_clusters: List of subclusters within this cluster. Empty if no subclusters exist. - :vartype sub_clusters: list[~azure.ai.agents.types.InsightCluster] - :ivar samples: List of samples that belong to this cluster. Empty if samples are part of - subclusters. - :vartype samples: list[~azure.ai.agents.types.InsightSample] - """ - - id: Required[str] - """The id of the analysis cluster. Required.""" - label: Required[str] - """Label for the cluster. Required.""" - suggestion: Required[str] - """Suggestion for the cluster. Required.""" - suggestionTitle: Required[str] - """The title of the suggestion for the cluster. Required.""" - description: Required[str] - """Description of the analysis cluster. Required.""" - weight: Required[int] - """The weight of the analysis cluster. This indicate number of samples in the cluster. Required.""" - subClusters: list["InsightCluster"] - """List of subclusters within this cluster. Empty if no subclusters exist.""" - samples: list["InsightSample"] - """List of samples that belong to this cluster. Empty if samples are part of subclusters.""" - - -class InsightModelConfiguration(TypedDict, total=False): - """Configuration of the model used in the insight generation. - - :ivar model_deployment_name: The model deployment to be evaluated. Accepts either the - deployment name alone or with the connection name as '{connectionName}/'. - Required. - :vartype model_deployment_name: str - """ - - modelDeploymentName: Required[str] - """The model deployment to be evaluated. Accepts either the deployment name alone or with the - connection name as '{connectionName}/'. Required.""" - - -class InsightScheduleTask(TypedDict, total=False): - """Insight task for the schedule. - - :ivar configuration: Configuration for the task. - :vartype configuration: dict[str, str] - :ivar type: Required. Insight task. - :vartype type: str or ~azure.ai.agents.models.INSIGHT - :ivar insight: The insight payload. Required. - :vartype insight: ~azure.ai.agents.types.Insight - """ - - configuration: dict[str, str] - """Configuration for the task.""" - type: Required[Literal[ScheduleTaskType.INSIGHT]] - """Required. Insight task.""" - insight: Required["Insight"] - """The insight payload. Required.""" - - -class InsightsMetadata(TypedDict, total=False): - """Metadata about the insights. - - :ivar created_at: The timestamp when the insights were created. Required. - :vartype created_at: ~datetime.datetime - :ivar completed_at: The timestamp when the insights were completed. - :vartype completed_at: ~datetime.datetime - """ - - createdAt: Required[str] - """The timestamp when the insights were created. Required.""" - completedAt: str - """The timestamp when the insights were completed.""" - - -class InsightSummary(TypedDict, total=False): - """Summary of the error cluster analysis. - - :ivar sample_count: Total number of samples analyzed. Required. - :vartype sample_count: int - :ivar unique_subcluster_count: Total number of unique subcluster labels. Required. - :vartype unique_subcluster_count: int - :ivar unique_cluster_count: Total number of unique clusters. Required. - :vartype unique_cluster_count: int - :ivar method: Method used for clustering. Required. - :vartype method: str - :ivar usage: Token usage while performing clustering analysis. Required. - :vartype usage: ~azure.ai.agents.types.ClusterTokenUsage - """ - - sampleCount: Required[int] - """Total number of samples analyzed. Required.""" - uniqueSubclusterCount: Required[int] - """Total number of unique subcluster labels. Required.""" - uniqueClusterCount: Required[int] - """Total number of unique clusters. Required.""" - method: Required[str] - """Method used for clustering. Required.""" - usage: Required["ClusterTokenUsage"] - """Token usage while performing clustering analysis. Required.""" - - -class ManagedAzureAISearchIndex(TypedDict, total=False): - """Managed Azure AI Search Index Definition. - - :ivar id: Asset ID, a unique identifier for the asset. - :vartype id: str - :ivar name: The name of the resource. Required. - :vartype name: str - :ivar version: The version of the resource. Required. - :vartype version: str - :ivar description: The asset description text. - :vartype description: str - :ivar tags: Tag dictionary. Tags can be added, removed, and updated. - :vartype tags: dict[str, str] - :ivar type: Type of index. Required. Managed Azure Search. - :vartype type: str or ~azure.ai.agents.models.MANAGED_AZURE_SEARCH - :ivar vector_store_id: Vector store id of managed index. Required. - :vartype vector_store_id: str - """ - - id: str - """Asset ID, a unique identifier for the asset.""" - name: Required[str] - """The name of the resource. Required.""" - version: Required[str] - """The version of the resource. Required.""" - description: str - """The asset description text.""" - tags: dict[str, str] - """Tag dictionary. Tags can be added, removed, and updated.""" - type: Required[Literal[IndexType.MANAGED_AZURE_SEARCH]] - """Type of index. Required. Managed Azure Search.""" - vectorStoreId: Required[str] - """Vector store id of managed index. Required.""" - - -class MemoryOperation(TypedDict, total=False): - """Represents a single memory operation (create, update, or delete) performed on a memory item. - - :ivar kind: The type of memory operation being performed. Required. Known values are: "create", - "update", and "delete". - :vartype kind: str or ~azure.ai.agents.models.MemoryOperationKind - :ivar memory_item: The memory item to create, update, or delete. Required. - :vartype memory_item: ~azure.ai.agents.types.MemoryItem - """ - - kind: Required[MemoryOperationKind] - """The type of memory operation being performed. Required. Known values are: \"create\", - \"update\", and \"delete\".""" - memory_item: Required["MemoryItem"] - """The memory item to create, update, or delete. Required.""" - - -class MemorySearchItem(TypedDict, total=False): - """A retrieved memory item from memory search. - - :ivar memory_item: Retrieved memory item. Required. - :vartype memory_item: ~azure.ai.agents.types.MemoryItem - """ - - memory_item: Required["MemoryItem"] - """Retrieved memory item. Required.""" - - -class MemorySearchOptions(TypedDict, total=False): - """Memory search options. - - :ivar max_memories: Maximum number of memory items to return. - :vartype max_memories: int - """ - - max_memories: int - """Maximum number of memory items to return.""" - - -class MemorySearchPreviewTool(TypedDict, total=False): - """A tool for integrating memories into the agent. - - :ivar type: The type of the tool. Always ``memory_search_preview``. Required. - MEMORY_SEARCH_PREVIEW. - :vartype type: str or ~azure.ai.projects.models.MEMORY_SEARCH_PREVIEW - :ivar memory_store_name: The name of the memory store to use. Required. - :vartype memory_store_name: str - :ivar scope: The namespace used to group and isolate memories, such as a user ID. Limits which - memories can be retrieved or updated. Use special variable ``{{$userId}}`` to scope memories to - the current signed-in user. Required. - :vartype scope: str - :ivar search_options: Options for searching the memory store. - :vartype search_options: ~azure.ai.agents.types.MemorySearchOptions - :ivar update_delay: Time to wait before updating memories after inactivity (seconds). Default - 300. - :vartype update_delay: int - """ - - type: Required[Literal[ToolType.MEMORY_SEARCH_PREVIEW]] - """The type of the tool. Always ``memory_search_preview``. Required. MEMORY_SEARCH_PREVIEW.""" - memory_store_name: Required[str] - """The name of the memory store to use. Required.""" - scope: Required[str] - """The namespace used to group and isolate memories, such as a user ID. Limits which memories can - be retrieved or updated. Use special variable ``{{$userId}}`` to scope memories to the current - signed-in user. Required.""" - search_options: "MemorySearchOptions" - """Options for searching the memory store.""" - update_delay: int - """Time to wait before updating memories after inactivity (seconds). Default 300.""" - - -class MemoryStoreDefaultDefinition(TypedDict, total=False): - """Default memory store implementation. - - :ivar kind: The kind of the memory store. Required. The default memory store implementation. - :vartype kind: str or ~azure.ai.agents.models.DEFAULT - :ivar chat_model: The name or identifier of the chat completion model deployment used for - memory processing. Required. - :vartype chat_model: str - :ivar embedding_model: The name or identifier of the embedding model deployment used for memory - processing. Required. - :vartype embedding_model: str - :ivar options: Default memory store options. - :vartype options: ~azure.ai.agents.types.MemoryStoreDefaultOptions - """ - - kind: Required[Literal[MemoryStoreKind.DEFAULT]] - """The kind of the memory store. Required. The default memory store implementation.""" - chat_model: Required[str] - """The name or identifier of the chat completion model deployment used for memory processing. - Required.""" - embedding_model: Required[str] - """The name or identifier of the embedding model deployment used for memory processing. Required.""" - options: "MemoryStoreDefaultOptions" - """Default memory store options.""" - - -class MemoryStoreDefaultOptions(TypedDict, total=False): - """Default memory store configurations. - - :ivar user_profile_enabled: Whether to enable user profile extraction and storage. Default is - true. Required. - :vartype user_profile_enabled: bool - :ivar user_profile_details: Specific categories or types of user profile information to extract - and store. - :vartype user_profile_details: str - :ivar chat_summary_enabled: Whether to enable chat summary extraction and storage. Default is - true. Required. - :vartype chat_summary_enabled: bool - """ - - user_profile_enabled: Required[bool] - """Whether to enable user profile extraction and storage. Default is true. Required.""" - user_profile_details: str - """Specific categories or types of user profile information to extract and store.""" - chat_summary_enabled: Required[bool] - """Whether to enable chat summary extraction and storage. Default is true. Required.""" - - -class MemoryStoreDeleteScopeResult(TypedDict, total=False): - """Response for deleting memories from a scope. - - :ivar object: The object type. Always 'memory_store.scope.deleted'. Required. - MEMORY_STORE_SCOPE_DELETED. - :vartype object: str or ~azure.ai.agents.models.MEMORY_STORE_SCOPE_DELETED - :ivar name: The name of the memory store. Required. - :vartype name: str - :ivar scope: The scope from which memories were deleted. Required. - :vartype scope: str - :ivar deleted: Whether the deletion operation was successful. Required. - :vartype deleted: bool - """ - - object: Required[Literal[MemoryStoreObjectType.MEMORY_STORE_SCOPE_DELETED]] - """The object type. Always 'memory_store.scope.deleted'. Required. MEMORY_STORE_SCOPE_DELETED.""" - name: Required[str] - """The name of the memory store. Required.""" - scope: Required[str] - """The scope from which memories were deleted. Required.""" - deleted: Required[bool] - """Whether the deletion operation was successful. Required.""" - - -class MemoryStoreDetails(TypedDict, total=False): - """A memory store that can store and retrieve user memories. - - :ivar object: The object type, which is always 'memory_store'. Required. MEMORY_STORE. - :vartype object: str or ~azure.ai.agents.models.MEMORY_STORE - :ivar id: The unique identifier of the memory store. Required. - :vartype id: str - :ivar created_at: The Unix timestamp (seconds) when the memory store was created. Required. - :vartype created_at: ~datetime.datetime - :ivar updated_at: The Unix timestamp (seconds) when the memory store was last updated. - Required. - :vartype updated_at: ~datetime.datetime - :ivar name: The name of the memory store. Required. - :vartype name: str - :ivar description: A human-readable description of the memory store. - :vartype description: str - :ivar metadata: Arbitrary key-value metadata to associate with the memory store. - :vartype metadata: dict[str, str] - :ivar definition: The definition of the memory store. Required. - :vartype definition: ~azure.ai.agents.types.MemoryStoreDefinition - """ - - object: Required[Literal[MemoryStoreObjectType.MEMORY_STORE]] - """The object type, which is always 'memory_store'. Required. MEMORY_STORE.""" - id: Required[str] - """The unique identifier of the memory store. Required.""" - created_at: Required[int] - """The Unix timestamp (seconds) when the memory store was created. Required.""" - updated_at: Required[int] - """The Unix timestamp (seconds) when the memory store was last updated. Required.""" - name: Required[str] - """The name of the memory store. Required.""" - description: str - """A human-readable description of the memory store.""" - metadata: dict[str, str] - """Arbitrary key-value metadata to associate with the memory store.""" - definition: Required["MemoryStoreDefinition"] - """The definition of the memory store. Required.""" - - -class MemoryStoreOperationUsage(TypedDict, total=False): - """Usage statistics of a memory store operation. - - :ivar embedding_tokens: The number of embedding tokens. Required. - :vartype embedding_tokens: int - :ivar input_tokens: The number of input tokens. Required. - :vartype input_tokens: int - :ivar input_tokens_details: A detailed breakdown of the input tokens. Required. - :vartype input_tokens_details: ~azure.ai.projects.types.ResponseUsageInputTokensDetails - :ivar output_tokens: The number of output tokens. Required. - :vartype output_tokens: int - :ivar output_tokens_details: A detailed breakdown of the output tokens. Required. - :vartype output_tokens_details: ~azure.ai.projects.types.ResponseUsageOutputTokensDetails - :ivar total_tokens: The total number of tokens used. Required. - :vartype total_tokens: int - """ - - embedding_tokens: Required[int] - """The number of embedding tokens. Required.""" - input_tokens: Required[int] - """The number of input tokens. Required.""" - input_tokens_details: Required["ResponseUsageInputTokensDetails"] - """A detailed breakdown of the input tokens. Required.""" - output_tokens: Required[int] - """The number of output tokens. Required.""" - output_tokens_details: Required["ResponseUsageOutputTokensDetails"] - """A detailed breakdown of the output tokens. Required.""" - total_tokens: Required[int] - """The total number of tokens used. Required.""" - - -class MemoryStoreSearchResult(TypedDict, total=False): - """Memory search response. - - :ivar search_id: The unique ID of this search request. Use this value as previous_search_id in - subsequent requests to perform incremental searches. Required. - :vartype search_id: str - :ivar memories: Related memory items found during the search operation. Required. - :vartype memories: list[~azure.ai.agents.types.MemorySearchItem] - :ivar usage: Usage statistics associated with the memory search operation. Required. - :vartype usage: ~azure.ai.agents.types.MemoryStoreOperationUsage - """ - - search_id: Required[str] - """The unique ID of this search request. Use this value as previous_search_id in subsequent - requests to perform incremental searches. Required.""" - memories: Required[list["MemorySearchItem"]] - """Related memory items found during the search operation. Required.""" - usage: Required["MemoryStoreOperationUsage"] - """Usage statistics associated with the memory search operation. Required.""" - - -class MemoryStoreUpdateCompletedResult(TypedDict, total=False): - """Memory update result. - - :ivar memory_operations: A list of individual memory operations that were performed during the - update. Required. - :vartype memory_operations: list[~azure.ai.agents.types.MemoryOperation] - :ivar usage: Usage statistics associated with the memory update operation. Required. - :vartype usage: ~azure.ai.agents.types.MemoryStoreOperationUsage - """ - - memory_operations: Required[list["MemoryOperation"]] - """A list of individual memory operations that were performed during the update. Required.""" - usage: Required["MemoryStoreOperationUsage"] - """Usage statistics associated with the memory update operation. Required.""" - - -class MemoryStoreUpdateResult(TypedDict, total=False): - """Provides the status of a memory store update operation. - - :ivar update_id: The unique ID of this update request. Use this value as previous_update_id in - subsequent requests to perform incremental updates. Required. - :vartype update_id: str - :ivar status: The status of the memory update operation. One of "queued", "in_progress", - "completed", "failed", or "superseded". Required. Known values are: "queued", "in_progress", - "completed", "failed", and "superseded". - :vartype status: str or ~azure.ai.agents.models.MemoryStoreUpdateStatus - :ivar superseded_by: The update_id the operation was superseded by when status is "superseded". - :vartype superseded_by: str - :ivar result: The result of memory store update operation when status is "completed". - :vartype result: ~azure.ai.agents.types.MemoryStoreUpdateCompletedResult - :ivar error: Error object that describes the error when status is "failed". - :vartype error: ~azure.ai.projects.types.ApiError - """ - - update_id: Required[str] - """The unique ID of this update request. Use this value as previous_update_id in subsequent - requests to perform incremental updates. Required.""" - status: Required[MemoryStoreUpdateStatus] - """The status of the memory update operation. One of \"queued\", \"in_progress\", \"completed\", - \"failed\", or \"superseded\". Required. Known values are: \"queued\", \"in_progress\", - \"completed\", \"failed\", and \"superseded\".""" - superseded_by: str - """The update_id the operation was superseded by when status is \"superseded\".""" - result: "MemoryStoreUpdateCompletedResult" - """The result of memory store update operation when status is \"completed\".""" - error: "ApiError" - """Error object that describes the error when status is \"failed\".""" - - -class MicrosoftFabricPreviewTool(TypedDict, total=False): - """The input definition information for a Microsoft Fabric tool as used to configure an agent. - - :ivar type: The object type, which is always 'fabric_dataagent_preview'. Required. - FABRIC_DATAAGENT_PREVIEW. - :vartype type: str or ~azure.ai.projects.models.FABRIC_DATAAGENT_PREVIEW - :ivar fabric_dataagent_preview: The fabric data agent tool parameters. Required. - :vartype fabric_dataagent_preview: ~azure.ai.agents.types.FabricDataAgentToolParameters - """ - - type: Required[Literal[ToolType.FABRIC_DATAAGENT_PREVIEW]] - """The object type, which is always 'fabric_dataagent_preview'. Required. - FABRIC_DATAAGENT_PREVIEW.""" - fabric_dataagent_preview: Required["FabricDataAgentToolParameters"] - """The fabric data agent tool parameters. Required.""" - - -class ModelDeployment(TypedDict, total=False): - """Model Deployment Definition. - - :ivar name: Name of the deployment. Required. - :vartype name: str - :ivar type: The type of the deployment. Required. Model deployment. - :vartype type: str or ~azure.ai.agents.models.MODEL_DEPLOYMENT - :ivar model_name: Publisher-specific name of the deployed model. Required. - :vartype model_name: str - :ivar model_version: Publisher-specific version of the deployed model. Required. - :vartype model_version: str - :ivar model_publisher: Name of the deployed model's publisher. Required. - :vartype model_publisher: str - :ivar capabilities: Capabilities of deployed model. Required. - :vartype capabilities: dict[str, str] - :ivar sku: Sku of the model deployment. Required. - :vartype sku: ~azure.ai.agents.types.ModelDeploymentSku - :ivar connection_name: Name of the connection the deployment comes from. - :vartype connection_name: str - """ - - name: Required[str] - """Name of the deployment. Required.""" - type: Required[Literal[DeploymentType.MODEL_DEPLOYMENT]] - """The type of the deployment. Required. Model deployment.""" - modelName: Required[str] - """Publisher-specific name of the deployed model. Required.""" - modelVersion: Required[str] - """Publisher-specific version of the deployed model. Required.""" - modelPublisher: Required[str] - """Name of the deployed model's publisher. Required.""" - capabilities: Required[dict[str, str]] - """Capabilities of deployed model. Required.""" - sku: Required["ModelDeploymentSku"] - """Sku of the model deployment. Required.""" - connectionName: str - """Name of the connection the deployment comes from.""" - - -class ModelDeploymentSku(TypedDict, total=False): - """Sku information. - - :ivar capacity: Sku capacity. Required. - :vartype capacity: int - :ivar family: Sku family. Required. - :vartype family: str - :ivar name: Sku name. Required. - :vartype name: str - :ivar size: Sku size. Required. - :vartype size: str - :ivar tier: Sku tier. Required. - :vartype tier: str - """ - - capacity: Required[int] - """Sku capacity. Required.""" - family: Required[str] - """Sku family. Required.""" - name: Required[str] - """Sku name. Required.""" - size: Required[str] - """Sku size. Required.""" - tier: Required[str] - """Sku tier. Required.""" - - -class ModelSamplingParams(TypedDict, total=False): - """Represents a set of parameters used to control the sampling behavior of a language model during - text generation. - - :ivar temperature: The temperature parameter for sampling. Required. - :vartype temperature: float - :ivar top_p: The top-p parameter for nucleus sampling. Required. - :vartype top_p: float - :ivar seed: The random seed for reproducibility. Required. - :vartype seed: int - :ivar max_completion_tokens: The maximum number of tokens allowed in the completion. Required. - :vartype max_completion_tokens: int - """ - - temperature: Required[float] - """The temperature parameter for sampling. Required.""" - top_p: Required[float] - """The top-p parameter for nucleus sampling. Required.""" - seed: Required[int] - """The random seed for reproducibility. Required.""" - max_completion_tokens: Required[int] - """The maximum number of tokens allowed in the completion. Required.""" - - -class MonthlyRecurrenceSchedule(TypedDict, total=False): - """Monthly recurrence schedule. - - :ivar type: Monthly recurrence type. Required. Monthly recurrence pattern. - :vartype type: str or ~azure.ai.agents.models.MONTHLY - :ivar days_of_month: Days of the month for the recurrence schedule. Required. - :vartype days_of_month: list[int] - """ - - type: Required[Literal[RecurrenceType.MONTHLY]] - """Monthly recurrence type. Required. Monthly recurrence pattern.""" - daysOfMonth: Required[list[int]] - """Days of the month for the recurrence schedule. Required.""" - - -class NoAuthenticationCredentials(TypedDict, total=False): - """Credentials that do not require authentication. - - :ivar type: The credential type. Required. No credential. - :vartype type: str or ~azure.ai.agents.models.NONE - """ - - type: Required[Literal[CredentialType.NONE]] - """The credential type. Required. No credential.""" - - -class OneTimeTrigger(TypedDict, total=False): - """One-time trigger. - - :ivar type: Required. One-time trigger. - :vartype type: str or ~azure.ai.agents.models.ONE_TIME - :ivar trigger_at: Date and time for the one-time trigger in ISO 8601 format. Required. - :vartype trigger_at: ~datetime.datetime - :ivar time_zone: Time zone for the one-time trigger. - :vartype time_zone: str - """ - - type: Required[Literal[TriggerType.ONE_TIME]] - """Required. One-time trigger.""" - triggerAt: Required[str] - """Date and time for the one-time trigger in ISO 8601 format. Required.""" - timeZone: str - """Time zone for the one-time trigger.""" - - -class OpenApiAnonymousAuthDetails(TypedDict, total=False): - """Security details for OpenApi anonymous authentication. - - :ivar type: The object type, which is always 'anonymous'. Required. ANONYMOUS. - :vartype type: str or ~azure.ai.agents.models.ANONYMOUS - """ - - type: Required[Literal[OpenApiAuthType.ANONYMOUS]] - """The object type, which is always 'anonymous'. Required. ANONYMOUS.""" - - -class OpenApiFunctionDefinition(TypedDict, total=False): - """The input definition information for an openapi function. - - :ivar name: The name of the function to be called. Required. - :vartype name: str - :ivar description: A description of what the function does, used by the model to choose when - and how to call the function. - :vartype description: str - :ivar spec: The openapi function shape, described as a JSON Schema object. Required. - :vartype spec: dict[str, any] - :ivar auth: Open API authentication details. Required. - :vartype auth: ~azure.ai.agents.types.OpenApiAuthDetails - :ivar default_params: List of OpenAPI spec parameters that will use user-provided defaults. - :vartype default_params: list[str] - :ivar functions: List of function definitions used by OpenApi tool. - :vartype functions: list[~azure.ai.agents.types.OpenApiFunctionDefinitionFunction] - """ - - name: Required[str] - """The name of the function to be called. Required.""" - description: str - """A description of what the function does, used by the model to choose when and how to call the - function.""" - spec: Required[dict[str, Any]] - """The openapi function shape, described as a JSON Schema object. Required.""" - auth: Required["OpenApiAuthDetails"] - """Open API authentication details. Required.""" - default_params: list[str] - """List of OpenAPI spec parameters that will use user-provided defaults.""" - functions: list["OpenApiFunctionDefinitionFunction"] - """List of function definitions used by OpenApi tool.""" - - -class OpenApiFunctionDefinitionFunction(TypedDict, total=False): - """OpenApiFunctionDefinitionFunction. - - :ivar name: The name of the function to be called. Required. - :vartype name: str - :ivar description: A description of what the function does, used by the model to choose when - and how to call the function. - :vartype description: str - :ivar parameters: The parameters the functions accepts, described as a JSON Schema object. - Required. - :vartype parameters: dict[str, any] - """ - - name: Required[str] - """The name of the function to be called. Required.""" - description: str - """A description of what the function does, used by the model to choose when and how to call the - function.""" - parameters: Required[dict[str, Any]] - """The parameters the functions accepts, described as a JSON Schema object. Required.""" - - -class OpenApiManagedAuthDetails(TypedDict, total=False): - """Security details for OpenApi managed_identity authentication. - - :ivar type: The object type, which is always 'managed_identity'. Required. MANAGED_IDENTITY. - :vartype type: str or ~azure.ai.agents.models.MANAGED_IDENTITY - :ivar security_scheme: Connection auth security details. Required. - :vartype security_scheme: ~azure.ai.agents.types.OpenApiManagedSecurityScheme - """ - - type: Required[Literal[OpenApiAuthType.MANAGED_IDENTITY]] - """The object type, which is always 'managed_identity'. Required. MANAGED_IDENTITY.""" - security_scheme: Required["OpenApiManagedSecurityScheme"] - """Connection auth security details. Required.""" - - -class OpenApiManagedSecurityScheme(TypedDict, total=False): - """Security scheme for OpenApi managed_identity authentication. - - :ivar audience: Authentication scope for managed_identity auth type. Required. - :vartype audience: str - """ - - audience: Required[str] - """Authentication scope for managed_identity auth type. Required.""" - - -class OpenApiProjectConnectionAuthDetails(TypedDict, total=False): - """Security details for OpenApi project connection authentication. - - :ivar type: The object type, which is always 'project_connection'. Required. - PROJECT_CONNECTION. - :vartype type: str or ~azure.ai.agents.models.PROJECT_CONNECTION - :ivar security_scheme: Project connection auth security details. Required. - :vartype security_scheme: ~azure.ai.agents.types.OpenApiProjectConnectionSecurityScheme - """ - - type: Required[Literal[OpenApiAuthType.PROJECT_CONNECTION]] - """The object type, which is always 'project_connection'. Required. PROJECT_CONNECTION.""" - security_scheme: Required["OpenApiProjectConnectionSecurityScheme"] - """Project connection auth security details. Required.""" - - -class OpenApiProjectConnectionSecurityScheme(TypedDict, total=False): - """Security scheme for OpenApi managed_identity authentication. - - :ivar project_connection_id: Project connection id for Project Connection auth type. Required. - :vartype project_connection_id: str - """ - - project_connection_id: Required[str] - """Project connection id for Project Connection auth type. Required.""" - - -class OpenApiTool(TypedDict, total=False): - """The input definition information for an OpenAPI tool as used to configure an agent. - - :ivar type: The object type, which is always 'openapi'. Required. OPENAPI. - :vartype type: str or ~azure.ai.projects.models.OPENAPI - :ivar openapi: The openapi function definition. Required. - :vartype openapi: ~azure.ai.agents.types.OpenApiFunctionDefinition - """ - - type: Required[Literal[ToolType.OPENAPI]] - """The object type, which is always 'openapi'. Required. OPENAPI.""" - openapi: Required["OpenApiFunctionDefinition"] - """The openapi function definition. Required.""" - - -class PendingUploadRequest(TypedDict, total=False): - """Represents a request for a pending upload. - - :ivar pending_upload_id: If PendingUploadId is not provided, a random GUID will be used. - :vartype pending_upload_id: str - :ivar connection_name: Azure Storage Account connection name to use for generating temporary - SAS token. - :vartype connection_name: str - :ivar pending_upload_type: BlobReference is the only supported type. Required. Blob Reference - is the only supported type. - :vartype pending_upload_type: str or ~azure.ai.agents.models.BLOB_REFERENCE - """ - - pendingUploadId: str - """If PendingUploadId is not provided, a random GUID will be used.""" - connectionName: str - """Azure Storage Account connection name to use for generating temporary SAS token.""" - pendingUploadType: Required[Literal[PendingUploadType.BLOB_REFERENCE]] - """BlobReference is the only supported type. Required. Blob Reference is the only supported type.""" - - -class PendingUploadResponse(TypedDict, total=False): - """Represents the response for a pending upload request. - - :ivar blob_reference: Container-level read, write, list SAS. Required. - :vartype blob_reference: ~azure.ai.agents.types.BlobReference - :ivar pending_upload_id: ID for this upload request. Required. - :vartype pending_upload_id: str - :ivar version: Version of asset to be created if user did not specify version when initially - creating upload. - :vartype version: str - :ivar pending_upload_type: BlobReference is the only supported type. Required. Blob Reference - is the only supported type. - :vartype pending_upload_type: str or ~azure.ai.agents.models.BLOB_REFERENCE - """ - - blobReference: Required["BlobReference"] - """Container-level read, write, list SAS. Required.""" - pendingUploadId: Required[str] - """ID for this upload request. Required.""" - version: str - """Version of asset to be created if user did not specify version when initially creating upload.""" - pendingUploadType: Required[Literal[PendingUploadType.BLOB_REFERENCE]] - """BlobReference is the only supported type. Required. Blob Reference is the only supported type.""" - - -class PromptAgentDefinition(TypedDict, total=False): - """The prompt agent definition. - - :ivar rai_config: Configuration for Responsible AI (RAI) content filtering and safety features. - :vartype rai_config: ~azure.ai.agents.types.RaiConfig - :ivar kind: Required. PROMPT. - :vartype kind: str or ~azure.ai.agents.models.PROMPT - :ivar model: The model deployment to use for this agent. Required. - :vartype model: str - :ivar instructions: A system (or developer) message inserted into the model's context. - :vartype instructions: str - :ivar temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 - will make the output more random, while lower values like 0.2 will make it more focused and - deterministic. We generally recommend altering this or ``top_p`` but not both. - :vartype temperature: float - :ivar top_p: 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. - :vartype top_p: float - :ivar reasoning: - :vartype reasoning: ~azure.ai.projects.types.Reasoning - :ivar tools: An array of tools the model may call while generating a response. You can specify - which tool to use by setting the ``tool_choice`` parameter. - :vartype tools: list[~azure.ai.projects.types.Tool] - :ivar tool_choice: How the model should select which tool (or tools) to use when generating a - response. See the ``tools`` parameter to see how to specify which tools the model can call. Is - either a str type or a ToolChoiceParam type. - :vartype tool_choice: str or ~azure.ai.projects.types.ToolChoiceParam - :ivar text: Configuration options for a text response from the model. Can be plain text or - structured JSON data. - :vartype text: ~azure.ai.agents.types.PromptAgentDefinitionTextOptions - :ivar structured_inputs: Set of structured inputs that can participate in prompt template - substitution or tool argument bindings. - :vartype structured_inputs: dict[str, ~azure.ai.agents.types.StructuredInputDefinition] - """ - - rai_config: "RaiConfig" - """Configuration for Responsible AI (RAI) content filtering and safety features.""" - kind: Required[Literal[AgentKind.PROMPT]] - """Required. PROMPT.""" - model: Required[str] - """The model deployment to use for this agent. Required.""" - instructions: Optional[str] - """A system (or developer) message inserted into the model's context.""" - temperature: Optional[float] - """What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output - more random, while lower values like 0.2 will make it more focused and deterministic. We - generally recommend altering this or ``top_p`` but not both.""" - top_p: Optional[float] - """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.""" - reasoning: Optional["Reasoning"] - tools: list["Tool"] - """An array of tools the model may call while generating a response. You can specify which tool to - use by setting the ``tool_choice`` parameter.""" - tool_choice: Union[str, "ToolChoiceParam"] - """How the model should select which tool (or tools) to use when generating a response. See the - ``tools`` parameter to see how to specify which tools the model can call. Is either a str type - or a ToolChoiceParam type.""" - text: "PromptAgentDefinitionTextOptions" - """Configuration options for a text response from the model. Can be plain text or structured JSON - data.""" - structured_inputs: dict[str, "StructuredInputDefinition"] - """Set of structured inputs that can participate in prompt template substitution or tool argument - bindings.""" - - -class PromptAgentDefinitionTextOptions(TypedDict, total=False): - """Configuration options for a text response from the model. Can be plain text or structured JSON - data. - - :ivar format: - :vartype format: ~azure.ai.projects.types.TextResponseFormat - """ - - format: "TextResponseFormat" - - -class PromptBasedEvaluatorDefinition(TypedDict, total=False): - """Prompt-based evaluator. - - :ivar init_parameters: The JSON schema (Draft 2020-12) for the evaluator's input parameters. - This includes parameters like type, properties, required. - :vartype init_parameters: dict[str, any] - :ivar data_schema: The JSON schema (Draft 2020-12) for the evaluator's input data. This - includes parameters like type, properties, required. - :vartype data_schema: dict[str, any] - :ivar metrics: List of output metrics produced by this evaluator. - :vartype metrics: dict[str, ~azure.ai.agents.types.EvaluatorMetric] - :ivar type: Required. Prompt-based definition. - :vartype type: str or ~azure.ai.agents.models.PROMPT - :ivar prompt_text: The prompt text used for evaluation. Required. - :vartype prompt_text: str - """ - - init_parameters: dict[str, Any] - """The JSON schema (Draft 2020-12) for the evaluator's input parameters. This includes parameters - like type, properties, required.""" - data_schema: dict[str, Any] - """The JSON schema (Draft 2020-12) for the evaluator's input data. This includes parameters like - type, properties, required.""" - metrics: dict[str, "EvaluatorMetric"] - """List of output metrics produced by this evaluator.""" - type: Required[Literal[EvaluatorDefinitionType.PROMPT]] - """Required. Prompt-based definition.""" - prompt_text: Required[str] - """The prompt text used for evaluation. Required.""" - - -class ProtocolVersionRecord(TypedDict, total=False): - """A record mapping for a single protocol and its version. - - :ivar protocol: The protocol type. Required. Known values are: "activity_protocol" and - "responses". - :vartype protocol: str or ~azure.ai.agents.models.AgentProtocol - :ivar version: The version string for the protocol, e.g. 'v0.1.1'. Required. - :vartype version: str - """ - - protocol: Required[AgentProtocol] - """The protocol type. Required. Known values are: \"activity_protocol\" and \"responses\".""" - version: Required[str] - """The version string for the protocol, e.g. 'v0.1.1'. Required.""" - - -class RaiConfig(TypedDict, total=False): - """Configuration for Responsible AI (RAI) content filtering and safety features. - - :ivar rai_policy_name: The name of the RAI policy to apply. Required. - :vartype rai_policy_name: str - """ - - rai_policy_name: Required[str] - """The name of the RAI policy to apply. Required.""" - - -class RecurrenceTrigger(TypedDict, total=False): - """Recurrence based trigger. - - :ivar type: Type of the trigger. Required. Recurrence based trigger. - :vartype type: str or ~azure.ai.agents.models.RECURRENCE - :ivar start_time: Start time for the recurrence schedule in ISO 8601 format. - :vartype start_time: ~datetime.datetime - :ivar end_time: End time for the recurrence schedule in ISO 8601 format. - :vartype end_time: ~datetime.datetime - :ivar time_zone: Time zone for the recurrence schedule. - :vartype time_zone: str - :ivar interval: Interval for the recurrence schedule. Required. - :vartype interval: int - :ivar schedule: Recurrence schedule for the recurrence trigger. Required. - :vartype schedule: ~azure.ai.agents.types.RecurrenceSchedule - """ - - type: Required[Literal[TriggerType.RECURRENCE]] - """Type of the trigger. Required. Recurrence based trigger.""" - startTime: str - """Start time for the recurrence schedule in ISO 8601 format.""" - endTime: str - """End time for the recurrence schedule in ISO 8601 format.""" - timeZone: str - """Time zone for the recurrence schedule.""" - interval: Required[int] - """Interval for the recurrence schedule. Required.""" - schedule: Required["RecurrenceSchedule"] - """Recurrence schedule for the recurrence trigger. Required.""" - - -class RedTeam(TypedDict, total=False): - """Red team details. - - :ivar name: Identifier of the red team run. Required. - :vartype name: str - :ivar display_name: Name of the red-team run. - :vartype display_name: str - :ivar num_turns: Number of simulation rounds. - :vartype num_turns: int - :ivar attack_strategies: List of attack strategies or nested lists of attack strategies. - :vartype attack_strategies: list[str or ~azure.ai.agents.models.AttackStrategy] - :ivar simulation_only: Simulation-only or Simulation + Evaluation. Default false, if true the - scan outputs conversation not evaluation result. - :vartype simulation_only: bool - :ivar risk_categories: List of risk categories to generate attack objectives for. - :vartype risk_categories: list[str or ~azure.ai.agents.models.RiskCategory] - :ivar application_scenario: Application scenario for the red team operation, to generate - scenario specific attacks. - :vartype application_scenario: str - :ivar tags: Red team's tags. Unlike properties, tags are fully mutable. - :vartype tags: dict[str, str] - :ivar properties: Red team's properties. Unlike tags, properties are add-only. Once added, a - property cannot be removed. - :vartype properties: dict[str, str] - :ivar status: Status of the red-team. It is set by service and is read-only. - :vartype status: str - :ivar target: Target configuration for the red-team run. Required. - :vartype target: ~azure.ai.agents.types.TargetConfig - """ - - id: Required[str] - """Identifier of the red team run. Required.""" - displayName: str - """Name of the red-team run.""" - numTurns: int - """Number of simulation rounds.""" - attackStrategies: list[AttackStrategy] - """List of attack strategies or nested lists of attack strategies.""" - simulationOnly: bool - """Simulation-only or Simulation + Evaluation. Default false, if true the scan outputs - conversation not evaluation result.""" - riskCategories: list[RiskCategory] - """List of risk categories to generate attack objectives for.""" - applicationScenario: str - """Application scenario for the red team operation, to generate scenario specific attacks.""" - tags: dict[str, str] - """Red team's tags. Unlike properties, tags are fully mutable.""" - properties: dict[str, str] - """Red team's properties. Unlike tags, properties are add-only. Once added, a property cannot be - removed.""" - status: str - """Status of the red-team. It is set by service and is read-only.""" - target: Required["TargetConfig"] - """Target configuration for the red-team run. Required.""" - - -class SASCredentials(TypedDict, total=False): - """Shared Access Signature (SAS) credential definition. - - :ivar type: The credential type. Required. Shared Access Signature (SAS) credential. - :vartype type: str or ~azure.ai.agents.models.SAS - :ivar sas_token: SAS token. - :vartype sas_token: str - """ - - type: Required[Literal[CredentialType.SAS]] - """The credential type. Required. Shared Access Signature (SAS) credential.""" - SAS: str - """SAS token.""" - - -class Schedule(TypedDict, total=False): - """Schedule model. - - :ivar schedule_id: Identifier of the schedule. Required. - :vartype schedule_id: str - :ivar display_name: Name of the schedule. - :vartype display_name: str - :ivar description: Description of the schedule. - :vartype description: str - :ivar enabled: Enabled status of the schedule. Required. - :vartype enabled: bool - :ivar provisioning_status: Provisioning status of the schedule. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", and "Failed". - :vartype provisioning_status: str or ~azure.ai.agents.models.ScheduleProvisioningStatus - :ivar trigger: Trigger for the schedule. Required. - :vartype trigger: ~azure.ai.agents.types.Trigger - :ivar task: Task for the schedule. Required. - :vartype task: ~azure.ai.agents.types.ScheduleTask - :ivar tags: Schedule's tags. Unlike properties, tags are fully mutable. - :vartype tags: dict[str, str] - :ivar properties: Schedule's properties. Unlike tags, properties are add-only. Once added, a - property cannot be removed. - :vartype properties: dict[str, str] - :ivar system_data: System metadata for the resource. Required. - :vartype system_data: dict[str, str] - """ - - id: Required[str] - """Identifier of the schedule. Required.""" - displayName: str - """Name of the schedule.""" - description: str - """Description of the schedule.""" - enabled: Required[bool] - """Enabled status of the schedule. Required.""" - provisioningStatus: ScheduleProvisioningStatus - """Provisioning status of the schedule. Known values are: \"Creating\", \"Updating\", - \"Deleting\", \"Succeeded\", and \"Failed\".""" - trigger: Required["Trigger"] - """Trigger for the schedule. Required.""" - task: Required["ScheduleTask"] - """Task for the schedule. Required.""" - tags: dict[str, str] - """Schedule's tags. Unlike properties, tags are fully mutable.""" - properties: dict[str, str] - """Schedule's properties. Unlike tags, properties are add-only. Once added, a property cannot be - removed.""" - systemData: Required[dict[str, str]] - """System metadata for the resource. Required.""" - - -class ScheduleRun(TypedDict, total=False): - """Schedule run model. - - :ivar run_id: Identifier of the schedule run. Required. - :vartype run_id: str - :ivar schedule_id: Identifier of the schedule. Required. - :vartype schedule_id: str - :ivar success: Trigger success status of the schedule run. Required. - :vartype success: bool - :ivar trigger_time: Trigger time of the schedule run. - :vartype trigger_time: ~datetime.datetime - :ivar error: Error information for the schedule run. - :vartype error: str - :ivar properties: Properties of the schedule run. Required. - :vartype properties: dict[str, str] - """ - - id: Required[str] - """Identifier of the schedule run. Required.""" - scheduleId: Required[str] - """Identifier of the schedule. Required.""" - success: Required[bool] - """Trigger success status of the schedule run. Required.""" - triggerTime: str - """Trigger time of the schedule run.""" - error: str - """Error information for the schedule run.""" - properties: Required[dict[str, str]] - """Properties of the schedule run. Required.""" - - -class SharepointGroundingToolParameters(TypedDict, total=False): - """The sharepoint grounding tool parameters. - - :ivar project_connections: The project connections attached to this tool. There can be a - maximum of 1 connection resource attached to the tool. - :vartype project_connections: list[~azure.ai.agents.types.ToolProjectConnection] - """ - - project_connections: list["ToolProjectConnection"] - """The project connections attached to this tool. There can be a maximum of 1 connection resource - attached to the tool.""" - - -class SharepointPreviewTool(TypedDict, total=False): - """The input definition information for a sharepoint tool as used to configure an agent. - - :ivar type: The object type, which is always 'sharepoint_grounding_preview'. Required. - SHAREPOINT_GROUNDING_PREVIEW. - :vartype type: str or ~azure.ai.projects.models.SHAREPOINT_GROUNDING_PREVIEW - :ivar sharepoint_grounding_preview: The sharepoint grounding tool parameters. Required. - :vartype sharepoint_grounding_preview: ~azure.ai.agents.types.SharepointGroundingToolParameters - """ - - type: Required[Literal[ToolType.SHAREPOINT_GROUNDING_PREVIEW]] - """The object type, which is always 'sharepoint_grounding_preview'. Required. - SHAREPOINT_GROUNDING_PREVIEW.""" - sharepoint_grounding_preview: Required["SharepointGroundingToolParameters"] - """The sharepoint grounding tool parameters. Required.""" - - -class StructuredInputDefinition(TypedDict, total=False): - """An structured input that can participate in prompt template substitutions and tool argument - binding. - - :ivar description: A human-readable description of the input. - :vartype description: str - :ivar default_value: The default value for the input if no run-time value is provided. - :vartype default_value: any - :ivar schema: The JSON schema for the structured input (optional). - :vartype schema: dict[str, any] - :ivar required: Whether the input property is required when the agent is invoked. - :vartype required: bool - """ - - description: str - """A human-readable description of the input.""" - default_value: Any - """The default value for the input if no run-time value is provided.""" - schema: dict[str, Any] - """The JSON schema for the structured input (optional).""" - required: bool - """Whether the input property is required when the agent is invoked.""" - - -class StructuredOutputDefinition(TypedDict, total=False): - """A structured output that can be produced by the agent. - - :ivar name: The name of the structured output. Required. - :vartype name: str - :ivar description: A description of the output to emit. Used by the model to determine when to - emit the output. Required. - :vartype description: str - :ivar schema: The JSON schema for the structured output. Required. - :vartype schema: dict[str, any] - :ivar strict: Whether to enforce strict validation. Default ``true``. Required. - :vartype strict: bool - """ - - name: Required[str] - """The name of the structured output. Required.""" - description: Required[str] - """A description of the output to emit. Used by the model to determine when to emit the output. - Required.""" - schema: Required[dict[str, Any]] - """The JSON schema for the structured output. Required.""" - strict: Required[Optional[bool]] - """Whether to enforce strict validation. Default ``true``. Required.""" - - -class TaxonomyCategory(TypedDict, total=False): - """Taxonomy category definition. - - :ivar id: Unique identifier of the taxonomy category. Required. - :vartype id: str - :ivar name: Name of the taxonomy category. Required. - :vartype name: str - :ivar description: Description of the taxonomy category. - :vartype description: str - :ivar risk_category: Risk category associated with this taxonomy category. Required. Known - values are: "HateUnfairness", "Violence", "Sexual", "SelfHarm", "ProtectedMaterial", - "CodeVulnerability", "UngroundedAttributes", "ProhibitedActions", "SensitiveDataLeakage", and - "TaskAdherence". - :vartype risk_category: str or ~azure.ai.agents.models.RiskCategory - :ivar sub_categories: List of taxonomy sub categories. Required. - :vartype sub_categories: list[~azure.ai.agents.types.TaxonomySubCategory] - :ivar properties: Additional properties for the taxonomy category. - :vartype properties: dict[str, str] - """ - - id: Required[str] - """Unique identifier of the taxonomy category. Required.""" - name: Required[str] - """Name of the taxonomy category. Required.""" - description: str - """Description of the taxonomy category.""" - riskCategory: Required[RiskCategory] - """Risk category associated with this taxonomy category. Required. Known values are: - \"HateUnfairness\", \"Violence\", \"Sexual\", \"SelfHarm\", \"ProtectedMaterial\", - \"CodeVulnerability\", \"UngroundedAttributes\", \"ProhibitedActions\", - \"SensitiveDataLeakage\", and \"TaskAdherence\".""" - subCategories: Required[list["TaxonomySubCategory"]] - """List of taxonomy sub categories. Required.""" - properties: dict[str, str] - """Additional properties for the taxonomy category.""" - - -class TaxonomySubCategory(TypedDict, total=False): - """Taxonomy sub-category definition. - - :ivar id: Unique identifier of the taxonomy sub-category. Required. - :vartype id: str - :ivar name: Name of the taxonomy sub-category. Required. - :vartype name: str - :ivar description: Description of the taxonomy sub-category. - :vartype description: str - :ivar enabled: List of taxonomy items under this sub-category. Required. - :vartype enabled: bool - :ivar properties: Additional properties for the taxonomy sub-category. - :vartype properties: dict[str, str] - """ - - id: Required[str] - """Unique identifier of the taxonomy sub-category. Required.""" - name: Required[str] - """Name of the taxonomy sub-category. Required.""" - description: str - """Description of the taxonomy sub-category.""" - enabled: Required[bool] - """List of taxonomy items under this sub-category. Required.""" - properties: dict[str, str] - """Additional properties for the taxonomy sub-category.""" - - -class ToolDescription(TypedDict, total=False): - """Description of a tool that can be used by an agent. - - :ivar name: The name of the tool. - :vartype name: str - :ivar description: A brief description of the tool's purpose. - :vartype description: str - """ - - name: str - """The name of the tool.""" - description: str - """A brief description of the tool's purpose.""" - - -class ToolProjectConnection(TypedDict, total=False): - """A project connection resource. - - :ivar project_connection_id: A project connection in a ToolProjectConnectionList attached to - this tool. Required. - :vartype project_connection_id: str - """ - - project_connection_id: Required[str] - """A project connection in a ToolProjectConnectionList attached to this tool. Required.""" - - -class UserProfileMemoryItem(TypedDict, total=False): - """A memory item specifically containing user profile information extracted from conversations, - such as preferences, interests, and personal details. - - :ivar memory_id: The unique ID of the memory item. Required. - :vartype memory_id: str - :ivar updated_at: The last update time of the memory item. Required. - :vartype updated_at: ~datetime.datetime - :ivar scope: The namespace that logically groups and isolates memories, such as a user ID. - Required. - :vartype scope: str - :ivar content: The content of the memory. Required. - :vartype content: str - :ivar kind: The kind of the memory item. Required. User profile information extracted from - conversations. - :vartype kind: str or ~azure.ai.agents.models.USER_PROFILE - """ - - memory_id: Required[str] - """The unique ID of the memory item. Required.""" - updated_at: Required[int] - """The last update time of the memory item. Required.""" - scope: Required[str] - """The namespace that logically groups and isolates memories, such as a user ID. Required.""" - content: Required[str] - """The content of the memory. Required.""" - kind: Required[Literal[MemoryItemKind.USER_PROFILE]] - """The kind of the memory item. Required. User profile information extracted from conversations.""" - - -class WebSearchConfiguration(TypedDict, total=False): - """A web search configuration for bing custom search. - - :ivar project_connection_id: Project connection id for grounding with bing custom search. - Required. - :vartype project_connection_id: str - :ivar instance_name: Name of the custom configuration instance given to config. Required. - :vartype instance_name: str - """ - - project_connection_id: Required[str] - """Project connection id for grounding with bing custom search. Required.""" - instance_name: Required[str] - """Name of the custom configuration instance given to config. Required.""" - - -class WeeklyRecurrenceSchedule(TypedDict, total=False): - """Weekly recurrence schedule. - - :ivar type: Weekly recurrence type. Required. Weekly recurrence pattern. - :vartype type: str or ~azure.ai.agents.models.WEEKLY - :ivar days_of_week: Days of the week for the recurrence schedule. Required. - :vartype days_of_week: list[str or ~azure.ai.agents.models.DayOfWeek] - """ - - type: Required[Literal[RecurrenceType.WEEKLY]] - """Weekly recurrence type. Required. Weekly recurrence pattern.""" - daysOfWeek: Required[list[DayOfWeek]] - """Days of the week for the recurrence schedule. Required.""" - - -class WorkflowAgentDefinition(TypedDict, total=False): - """The workflow agent definition. - - :ivar rai_config: Configuration for Responsible AI (RAI) content filtering and safety features. - :vartype rai_config: ~azure.ai.agents.types.RaiConfig - :ivar kind: Required. WORKFLOW. - :vartype kind: str or ~azure.ai.agents.models.WORKFLOW - :ivar workflow: The CSDL YAML definition of the workflow. - :vartype workflow: str - """ - - rai_config: "RaiConfig" - """Configuration for Responsible AI (RAI) content filtering and safety features.""" - kind: Required[Literal[AgentKind.WORKFLOW]] - """Required. WORKFLOW.""" - workflow: str - """The CSDL YAML definition of the workflow.""" - - -InsightRequest = Union[ - AgentClusterInsightRequest, EvaluationComparisonInsightRequest, EvaluationRunClusterInsightRequest -] -InsightResult = Union[AgentClusterInsightResult, EvaluationComparisonInsightResult, EvaluationRunClusterInsightResult] -AgentDefinition = Union[HostedAgentDefinition, PromptAgentDefinition, WorkflowAgentDefinition] -BaseCredentials = Union[ - EntraIDCredentials, - AgenticIdentityPreviewCredentials, - ApiKeyCredentials, - CustomCredential, - NoAuthenticationCredentials, - SASCredentials, -] -EvaluationTaxonomyInput = Union[AgentTaxonomyInput] -Target = Union[AzureAIAgentTarget, AzureAIModelTarget] -Index = Union[AzureAISearchIndex, CosmosDBIndex, ManagedAzureAISearchIndex] -TargetConfig = Union[AzureOpenAIModelConfiguration] -MemoryItem = Union[ChatSummaryMemoryItem, UserProfileMemoryItem] -EvaluatorDefinition = Union[CodeBasedEvaluatorDefinition, PromptBasedEvaluatorDefinition] -EvaluationRuleAction = Union[ContinuousEvaluationRuleAction, HumanEvaluationPreviewRuleAction] -Trigger = Union[CronTrigger, OneTimeTrigger, RecurrenceTrigger] -RecurrenceSchedule = Union[ - DailyRecurrenceSchedule, HourlyRecurrenceSchedule, MonthlyRecurrenceSchedule, WeeklyRecurrenceSchedule -] -DatasetVersion = Union[FileDatasetVersion, FolderDatasetVersion] -Deployment = Union[ModelDeployment] -InsightSample = Union[EvaluationResultSample] -ScheduleTask = Union[EvaluationScheduleTask, InsightScheduleTask] -MemoryStoreDefinition = Union[MemoryStoreDefaultDefinition] -OpenApiAuthDetails = Union[OpenApiAnonymousAuthDetails, OpenApiManagedAuthDetails, OpenApiProjectConnectionAuthDetails] diff --git a/sdk/ai/azure-ai-agents/azure/ai/projects/__init__.py b/sdk/ai/azure-ai-agents/azure/ai/projects/__init__.py deleted file mode 100644 index d55ccad1f573..000000000000 --- a/sdk/ai/azure-ai-agents/azure/ai/projects/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/sdk/ai/azure-ai-agents/azure/ai/projects/models/__init__.py b/sdk/ai/azure-ai-agents/azure/ai/projects/models/__init__.py deleted file mode 100644 index e3b4c5295f07..000000000000 --- a/sdk/ai/azure-ai-agents/azure/ai/projects/models/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_patch_sdk() diff --git a/sdk/ai/azure-ai-agents/azure/ai/projects/models/_patch.py b/sdk/ai/azure-ai-agents/azure/ai/projects/models/_patch.py deleted file mode 100644 index 87676c65a8f0..000000000000 --- a/sdk/ai/azure-ai-agents/azure/ai/projects/models/_patch.py +++ /dev/null @@ -1,21 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------- -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" - - -__all__: list[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/ai/azure-ai-agents/azure/ai/projects/types.py b/sdk/ai/azure-ai-agents/azure/ai/projects/types.py deleted file mode 100644 index 27c4083bea09..000000000000 --- a/sdk/ai/azure-ai-agents/azure/ai/projects/types.py +++ /dev/null @@ -1,1317 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, Literal, Optional, TYPE_CHECKING, Union -from typing_extensions import Required, TypedDict - -from .models._enums import ( - ContainerNetworkPolicyParamType, - ContainerSkillType, - CustomToolParamFormatType, - FunctionShellToolParamEnvironmentType, - TextResponseFormatConfigurationType, - ToolChoiceParamType, - ToolType, -) - -if TYPE_CHECKING: - from ..agents import _unions, types as _types_agents_models2 - -ComputerEnvironment = Literal["windows", "mac", "linux", "ubuntu", "browser"] -"""Type of ComputerEnvironment.""" - -ContainerMemoryLimit = Literal["1g", "4g", "16g", "64g"] -"""Type of ContainerMemoryLimit.""" - -ContainerNetworkPolicyParamType = Literal["disabled", "allowlist"] -"""Type of ContainerNetworkPolicyParamType.""" - -ContainerSkillType = Literal["skill_reference", "inline"] -"""Type of ContainerSkillType.""" - -CustomToolParamFormatType = Literal["text", "grammar"] -"""Type of CustomToolParamFormatType.""" - -FunctionShellToolParamEnvironmentType = Literal["container_auto", "local", "container_reference"] -"""Type of FunctionShellToolParamEnvironmentType.""" - -GrammarSyntax1 = Literal["lark", "regex"] -"""Type of GrammarSyntax1.""" - -ImageGenAction = Literal["generate", "edit", "auto"] -"""Type of ImageGenAction.""" - -InputFidelity = Literal["high", "low"] -"""Control how much effort the model will exert to match the style and features, especially facial -features, of input images. This parameter is only supported for ``gpt-image-1`` and -``gpt-image-1.5`` and later models, unsupported for ``gpt-image-1-mini``. Supports ``high`` and -``low``. Defaults to ``low``.""" - -RankerVersionType = Literal["auto", "default-2024-11-15"] -"""Type of RankerVersionType.""" - -SearchContextSize = Literal["low", "medium", "high"] -"""Type of SearchContextSize.""" - -TextResponseFormatConfigurationType = Literal["text", "json_schema", "json_object"] -"""Type of TextResponseFormatConfigurationType.""" - -ToolChoiceParamType = Literal[ - "allowed_tools", - "function", - "mcp", - "custom", - "apply_patch", - "shell", - "file_search", - "web_search_preview", - "computer_use_preview", - "web_search_preview_2025_03_11", - "image_generation", - "code_interpreter", -] -"""Type of ToolChoiceParamType.""" - -ToolType = Literal[ - "function", - "file_search", - "computer_use_preview", - "web_search", - "mcp", - "code_interpreter", - "image_generation", - "local_shell", - "shell", - "custom", - "web_search_preview", - "apply_patch", - "a2a_preview", - "bing_custom_search_preview", - "browser_automation_preview", - "fabric_dataagent_preview", - "sharepoint_grounding_preview", - "memory_search_preview", - "azure_ai_search", - "azure_function", - "bing_grounding", - "capture_structured_outputs", - "openapi", -] -"""Type of ToolType.""" - - -class ApiError(TypedDict, total=False): - """ApiError. - - :ivar code: Required. - :vartype code: str - :ivar message: Required. - :vartype message: str - :ivar param: - :vartype param: str - :ivar type: - :vartype type: str - :ivar details: - :vartype details: list[~azure.ai.projects.types.ApiError] - :ivar additional_info: - :vartype additional_info: dict[str, any] - :ivar debug_info: - :vartype debug_info: dict[str, any] - """ - - code: Required[Optional[str]] - """Required.""" - message: Required[str] - """Required.""" - param: Optional[str] - type: str - details: list["ApiError"] - additionalInfo: dict[str, Any] - debugInfo: dict[str, Any] - - -class ApplyPatchToolParam(TypedDict, total=False): - """Apply patch tool. - - :ivar type: The type of the tool. Always ``apply_patch``. Required. APPLY_PATCH. - :vartype type: str or ~azure.ai.projects.models.APPLY_PATCH - """ - - type: Required[Literal[ToolType.APPLY_PATCH]] - """The type of the tool. Always ``apply_patch``. Required. APPLY_PATCH.""" - - -class ApproximateLocation(TypedDict, total=False): - """ApproximateLocation. - - :ivar type: The type of location approximation. Always ``approximate``. Required. Default value - is "approximate". - :vartype type: str - :ivar country: - :vartype country: str - :ivar region: - :vartype region: str - :ivar city: - :vartype city: str - :ivar timezone: - :vartype timezone: str - """ - - type: Required[Literal["approximate"]] - """The type of location approximation. Always ``approximate``. Required. Default value is - \"approximate\".""" - country: Optional[str] - region: Optional[str] - city: Optional[str] - timezone: Optional[str] - - -class AutoCodeInterpreterToolParam(TypedDict, total=False): - """Automatic Code Interpreter Tool Parameters. - - :ivar type: Always ``auto``. Required. Default value is "auto". - :vartype type: str - :ivar file_ids: An optional list of uploaded files to make available to your code. - :vartype file_ids: list[str] - :ivar memory_limit: Known values are: "1g", "4g", "16g", and "64g". - :vartype memory_limit: str or ~azure.ai.projects.models.ContainerMemoryLimit - :ivar network_policy: - :vartype network_policy: ~azure.ai.projects.types.ContainerNetworkPolicyParam - """ - - type: Required[Literal["auto"]] - """Always ``auto``. Required. Default value is \"auto\".""" - file_ids: list[str] - """An optional list of uploaded files to make available to your code.""" - memory_limit: Optional[ContainerMemoryLimit] - """Known values are: \"1g\", \"4g\", \"16g\", and \"64g\".""" - network_policy: "ContainerNetworkPolicyParam" - - -class CodeInterpreterTool(TypedDict, total=False): - """Code interpreter. - - :ivar type: The type of the code interpreter tool. Always ``code_interpreter``. Required. - CODE_INTERPRETER. - :vartype type: str or ~azure.ai.projects.models.CODE_INTERPRETER - :ivar container: The code interpreter container. Can be a container ID or an object that - specifies uploaded file IDs to make available to your code, along with an optional - ``memory_limit`` setting. If not provided, the service assumes auto. Is either a str type or a - AutoCodeInterpreterToolParam type. - :vartype container: str or ~azure.ai.projects.types.AutoCodeInterpreterToolParam - """ - - type: Required[Literal[ToolType.CODE_INTERPRETER]] - """The type of the code interpreter tool. Always ``code_interpreter``. Required. CODE_INTERPRETER.""" - container: Union[str, "AutoCodeInterpreterToolParam"] - """The code interpreter container. Can be a container ID or an object that specifies uploaded file - IDs to make available to your code, along with an optional ``memory_limit`` setting. If not - provided, the service assumes auto. Is either a str type or a AutoCodeInterpreterToolParam - type.""" - - -class ComparisonFilter(TypedDict, total=False): - """Comparison Filter. - - :ivar type: Specifies the comparison operator: ``eq``, ``ne``, ``gt``, ``gte``, ``lt``, - ``lte``, ``in``, ``nin``. - - * `eq`: equals - * `ne`: not equal - * `gt`: greater than - * `gte`: greater than or equal - * `lt`: less than - * `lte`: less than or equal - * `in`: in - * `nin`: not in. Required. Is one of the following types: Literal["eq"], Literal["ne"], - Literal["gt"], Literal["gte"], Literal["lt"], Literal["lte"] - :vartype type: str or str or str or str or str or str - :ivar key: The key to compare against the value. Required. - :vartype key: str - :ivar value: The value to compare against the attribute key; supports string, number, or - boolean types. Required. Is one of the following types: str, float, bool, [Union[str, float]] - :vartype value: str or float or bool or list[str or float] - """ - - type: Required[Literal["eq", "ne", "gt", "gte", "lt", "lte"]] - """Specifies the comparison operator: ``eq``, ``ne``, ``gt``, ``gte``, ``lt``, ``lte``, ``in``, - ``nin``. - - * `eq`: equals - * `ne`: not equal - * `gt`: greater than - * `gte`: greater than or equal - * `lt`: less than - * `lte`: less than or equal - * `in`: in - * `nin`: not in. Required. Is one of the following types: Literal[\"eq\"], - Literal[\"ne\"], Literal[\"gt\"], Literal[\"gte\"], Literal[\"lt\"], Literal[\"lte\"]""" - key: Required[str] - """The key to compare against the value. Required.""" - value: Required[Union[str, float, bool, list[Union[str, float]]]] - """The value to compare against the attribute key; supports string, number, or boolean types. - Required. Is one of the following types: str, float, bool, [Union[str, float]]""" - - -class CompoundFilter(TypedDict, total=False): - """Compound Filter. - - :ivar type: Type of operation: ``and`` or ``or``. Required. Is either a Literal["and"] type or - a Literal["or"] type. - :vartype type: str or str - :ivar filters: Array of filters to combine. Items can be ``ComparisonFilter`` or - ``CompoundFilter``. Required. - :vartype filters: list[~azure.ai.projects.types.ComparisonFilter or any] - """ - - type: Required[Literal["and", "or"]] - """Type of operation: ``and`` or ``or``. Required. Is either a Literal[\"and\"] type or a - Literal[\"or\"] type.""" - filters: Required[list[Union["ComparisonFilter", Any]]] - """Array of filters to combine. Items can be ``ComparisonFilter`` or ``CompoundFilter``. Required.""" - - -class ComputerUsePreviewTool(TypedDict, total=False): - """Computer use preview. - - :ivar type: The type of the computer use tool. Always ``computer_use_preview``. Required. - COMPUTER_USE_PREVIEW. - :vartype type: str or ~azure.ai.projects.models.COMPUTER_USE_PREVIEW - :ivar environment: The type of computer environment to control. Required. Known values are: - "windows", "mac", "linux", "ubuntu", and "browser". - :vartype environment: str or ~azure.ai.projects.models.ComputerEnvironment - :ivar display_width: The width of the computer display. Required. - :vartype display_width: int - :ivar display_height: The height of the computer display. Required. - :vartype display_height: int - """ - - type: Required[Literal[ToolType.COMPUTER_USE_PREVIEW]] - """The type of the computer use tool. Always ``computer_use_preview``. Required. - COMPUTER_USE_PREVIEW.""" - environment: Required[ComputerEnvironment] - """The type of computer environment to control. Required. Known values are: \"windows\", \"mac\", - \"linux\", \"ubuntu\", and \"browser\".""" - display_width: Required[int] - """The width of the computer display. Required.""" - display_height: Required[int] - """The height of the computer display. Required.""" - - -class ContainerAutoParam(TypedDict, total=False): - """ContainerAutoParam. - - :ivar type: Automatically creates a container for this request. Required. CONTAINER_AUTO. - :vartype type: str or ~azure.ai.projects.models.CONTAINER_AUTO - :ivar file_ids: An optional list of uploaded files to make available to your code. - :vartype file_ids: list[str] - :ivar memory_limit: Known values are: "1g", "4g", "16g", and "64g". - :vartype memory_limit: str or ~azure.ai.projects.models.ContainerMemoryLimit - :ivar skills: An optional list of skills referenced by id or inline data. - :vartype skills: list[~azure.ai.projects.types.ContainerSkill] - :ivar network_policy: - :vartype network_policy: ~azure.ai.projects.types.ContainerNetworkPolicyParam - """ - - type: Required[Literal[FunctionShellToolParamEnvironmentType.CONTAINER_AUTO]] - """Automatically creates a container for this request. Required. CONTAINER_AUTO.""" - file_ids: list[str] - """An optional list of uploaded files to make available to your code.""" - memory_limit: Optional[ContainerMemoryLimit] - """Known values are: \"1g\", \"4g\", \"16g\", and \"64g\".""" - skills: list["ContainerSkill"] - """An optional list of skills referenced by id or inline data.""" - network_policy: "ContainerNetworkPolicyParam" - - -class ContainerNetworkPolicyAllowlistParam(TypedDict, total=False): - """ContainerNetworkPolicyAllowlistParam. - - :ivar type: Allow outbound network access only to specified domains. Always ``allowlist``. - Required. ALLOWLIST. - :vartype type: str or ~azure.ai.projects.models.ALLOWLIST - :ivar allowed_domains: A list of allowed domains when type is ``allowlist``. Required. - :vartype allowed_domains: list[str] - :ivar domain_secrets: Optional domain-scoped secrets for allowlisted domains. - :vartype domain_secrets: list[~azure.ai.projects.types.ContainerNetworkPolicyDomainSecretParam] - """ - - type: Required[Literal[ContainerNetworkPolicyParamType.ALLOWLIST]] - """Allow outbound network access only to specified domains. Always ``allowlist``. Required. - ALLOWLIST.""" - allowed_domains: Required[list[str]] - """A list of allowed domains when type is ``allowlist``. Required.""" - domain_secrets: list["ContainerNetworkPolicyDomainSecretParam"] - """Optional domain-scoped secrets for allowlisted domains.""" - - -class ContainerNetworkPolicyDisabledParam(TypedDict, total=False): - """ContainerNetworkPolicyDisabledParam. - - :ivar type: Disable outbound network access. Always ``disabled``. Required. DISABLED. - :vartype type: str or ~azure.ai.projects.models.DISABLED - """ - - type: Required[Literal[ContainerNetworkPolicyParamType.DISABLED]] - """Disable outbound network access. Always ``disabled``. Required. DISABLED.""" - - -class ContainerNetworkPolicyDomainSecretParam(TypedDict, total=False): - """ContainerNetworkPolicyDomainSecretParam. - - :ivar domain: The domain associated with the secret. Required. - :vartype domain: str - :ivar name: The name of the secret to inject for the domain. Required. - :vartype name: str - :ivar value: The secret value to inject for the domain. Required. - :vartype value: str - """ - - domain: Required[str] - """The domain associated with the secret. Required.""" - name: Required[str] - """The name of the secret to inject for the domain. Required.""" - value: Required[str] - """The secret value to inject for the domain. Required.""" - - -class CustomGrammarFormatParam(TypedDict, total=False): - """Grammar format. - - :ivar type: Grammar format. Always ``grammar``. Required. GRAMMAR. - :vartype type: str or ~azure.ai.projects.models.GRAMMAR - :ivar syntax: The syntax of the grammar definition. One of ``lark`` or ``regex``. Required. - Known values are: "lark" and "regex". - :vartype syntax: str or ~azure.ai.projects.models.GrammarSyntax1 - :ivar definition: The grammar definition. Required. - :vartype definition: str - """ - - type: Required[Literal[CustomToolParamFormatType.GRAMMAR]] - """Grammar format. Always ``grammar``. Required. GRAMMAR.""" - syntax: Required[GrammarSyntax1] - """The syntax of the grammar definition. One of ``lark`` or ``regex``. Required. Known values are: - \"lark\" and \"regex\".""" - definition: Required[str] - """The grammar definition. Required.""" - - -class CustomTextFormatParam(TypedDict, total=False): - """Text format. - - :ivar type: Unconstrained text format. Always ``text``. Required. TEXT. - :vartype type: str or ~azure.ai.projects.models.TEXT - """ - - type: Required[Literal[CustomToolParamFormatType.TEXT]] - """Unconstrained text format. Always ``text``. Required. TEXT.""" - - -class CustomToolParam(TypedDict, total=False): - """Custom tool. - - :ivar type: The type of the custom tool. Always ``custom``. Required. CUSTOM. - :vartype type: str or ~azure.ai.projects.models.CUSTOM - :ivar name: The name of the custom tool, used to identify it in tool calls. Required. - :vartype name: str - :ivar description: Optional description of the custom tool, used to provide more context. - :vartype description: str - :ivar format: The input format for the custom tool. Default is unconstrained text. - :vartype format: ~azure.ai.projects.types.CustomToolParamFormat - """ - - type: Required[Literal[ToolType.CUSTOM]] - """The type of the custom tool. Always ``custom``. Required. CUSTOM.""" - name: Required[str] - """The name of the custom tool, used to identify it in tool calls. Required.""" - description: str - """Optional description of the custom tool, used to provide more context.""" - format: "CustomToolParamFormat" - """The input format for the custom tool. Default is unconstrained text.""" - - -class FileSearchTool(TypedDict, total=False): - """File search. - - :ivar type: The type of the file search tool. Always ``file_search``. Required. FILE_SEARCH. - :vartype type: str or ~azure.ai.projects.models.FILE_SEARCH - :ivar vector_store_ids: The IDs of the vector stores to search. Required. - :vartype vector_store_ids: list[str] - :ivar max_num_results: The maximum number of results to return. This number should be between 1 - and 50 inclusive. - :vartype max_num_results: int - :ivar ranking_options: Ranking options for search. - :vartype ranking_options: ~azure.ai.projects.types.RankingOptions - :ivar filters: Is either a ComparisonFilter type or a CompoundFilter type. - :vartype filters: ~azure.ai.projects.types.ComparisonFilter or - ~azure.ai.projects.types.CompoundFilter - """ - - type: Required[Literal[ToolType.FILE_SEARCH]] - """The type of the file search tool. Always ``file_search``. Required. FILE_SEARCH.""" - vector_store_ids: Required[list[str]] - """The IDs of the vector stores to search. Required.""" - max_num_results: int - """The maximum number of results to return. This number should be between 1 and 50 inclusive.""" - ranking_options: "RankingOptions" - """Ranking options for search.""" - filters: Optional["_unions.Filters"] - """Is either a ComparisonFilter type or a CompoundFilter type.""" - - -class FunctionShellToolParam(TypedDict, total=False): - """Shell tool. - - :ivar type: The type of the shell tool. Always ``shell``. Required. SHELL. - :vartype type: str or ~azure.ai.projects.models.SHELL - :ivar environment: - :vartype environment: ~azure.ai.projects.types.FunctionShellToolParamEnvironment - """ - - type: Required[Literal[ToolType.SHELL]] - """The type of the shell tool. Always ``shell``. Required. SHELL.""" - environment: Optional["FunctionShellToolParamEnvironment"] - - -class FunctionShellToolParamEnvironmentContainerReferenceParam(TypedDict, total=False): # pylint: disable=name-too-long - """FunctionShellToolParamEnvironmentContainerReferenceParam. - - :ivar type: References a container created with the /v1/containers endpoint. Required. - CONTAINER_REFERENCE. - :vartype type: str or ~azure.ai.projects.models.CONTAINER_REFERENCE - :ivar container_id: The ID of the referenced container. Required. - :vartype container_id: str - """ - - type: Required[Literal[FunctionShellToolParamEnvironmentType.CONTAINER_REFERENCE]] - """References a container created with the /v1/containers endpoint. Required. CONTAINER_REFERENCE.""" - container_id: Required[str] - """The ID of the referenced container. Required.""" - - -class FunctionShellToolParamEnvironmentLocalEnvironmentParam(TypedDict, total=False): # pylint: disable=name-too-long - """FunctionShellToolParamEnvironmentLocalEnvironmentParam. - - :ivar type: Use a local computer environment. Required. LOCAL. - :vartype type: str or ~azure.ai.projects.models.LOCAL - :ivar skills: An optional list of skills. - :vartype skills: list[~azure.ai.projects.types.LocalSkillParam] - """ - - type: Required[Literal[FunctionShellToolParamEnvironmentType.LOCAL]] - """Use a local computer environment. Required. LOCAL.""" - skills: list["LocalSkillParam"] - """An optional list of skills.""" - - -class FunctionTool(TypedDict, total=False): - """Function. - - :ivar type: The type of the function tool. Always ``function``. Required. FUNCTION. - :vartype type: str or ~azure.ai.projects.models.FUNCTION - :ivar name: The name of the function to call. Required. - :vartype name: str - :ivar description: - :vartype description: str - :ivar parameters: Required. - :vartype parameters: dict[str, any] - :ivar strict: Required. - :vartype strict: bool - """ - - type: Required[Literal[ToolType.FUNCTION]] - """The type of the function tool. Always ``function``. Required. FUNCTION.""" - name: Required[str] - """The name of the function to call. Required.""" - description: Optional[str] - parameters: Required[Optional[dict[str, Any]]] - """Required.""" - strict: Required[Optional[bool]] - """Required.""" - - -class HybridSearchOptions(TypedDict, total=False): - """HybridSearchOptions. - - :ivar embedding_weight: The weight of the embedding in the reciprocal ranking fusion. Required. - :vartype embedding_weight: float - :ivar text_weight: The weight of the text in the reciprocal ranking fusion. Required. - :vartype text_weight: float - """ - - embedding_weight: Required[float] - """The weight of the embedding in the reciprocal ranking fusion. Required.""" - text_weight: Required[float] - """The weight of the text in the reciprocal ranking fusion. Required.""" - - -class ImageGenTool(TypedDict, total=False): - """Image generation tool. - - :ivar type: The type of the image generation tool. Always ``image_generation``. Required. - IMAGE_GENERATION. - :vartype type: str or ~azure.ai.projects.models.IMAGE_GENERATION - :ivar model: Is one of the following types: Literal["gpt-image-1"], - Literal["gpt-image-1-mini"], Literal["gpt-image-1.5"], str - :vartype model: str or str or str or str - :ivar quality: The quality of the generated image. One of ``low``, ``medium``, ``high``, or - ``auto``. Default: ``auto``. Is one of the following types: Literal["low"], Literal["medium"], - Literal["high"], Literal["auto"] - :vartype quality: str or str or str or str - :ivar size: The size of the generated image. One of ``1024x1024``, ``1024x1536``, - ``1536x1024``, or ``auto``. Default: ``auto``. Is one of the following types: - Literal["1024x1024"], Literal["1024x1536"], Literal["1536x1024"], Literal["auto"] - :vartype size: str or str or str or str - :ivar output_format: The output format of the generated image. One of ``png``, ``webp``, or - ``jpeg``. Default: ``png``. Is one of the following types: Literal["png"], Literal["webp"], - Literal["jpeg"] - :vartype output_format: str or str or str - :ivar output_compression: Compression level for the output image. Default: 100. - :vartype output_compression: int - :ivar moderation: Moderation level for the generated image. Default: ``auto``. Is either a - Literal["auto"] type or a Literal["low"] type. - :vartype moderation: str or str - :ivar background: Background type for the generated image. One of ``transparent``, ``opaque``, - or ``auto``. Default: ``auto``. Is one of the following types: Literal["transparent"], - Literal["opaque"], Literal["auto"] - :vartype background: str or str or str - :ivar input_fidelity: Known values are: "high" and "low". - :vartype input_fidelity: str or ~azure.ai.projects.models.InputFidelity - :ivar input_image_mask: Optional mask for inpainting. Contains ``image_url`` (string, optional) - and ``file_id`` (string, optional). - :vartype input_image_mask: ~azure.ai.projects.types.ImageGenToolInputImageMask - :ivar partial_images: Number of partial images to generate in streaming mode, from 0 (default - value) to 3. - :vartype partial_images: int - :ivar action: Whether to generate a new image or edit an existing image. Default: ``auto``. - Known values are: "generate", "edit", and "auto". - :vartype action: str or ~azure.ai.projects.models.ImageGenAction - """ - - type: Required[Literal[ToolType.IMAGE_GENERATION]] - """The type of the image generation tool. Always ``image_generation``. Required. IMAGE_GENERATION.""" - model: Union[Literal["gpt-image-1"], Literal["gpt-image-1-mini"], Literal["gpt-image-1.5"], str] - """Is one of the following types: Literal[\"gpt-image-1\"], Literal[\"gpt-image-1-mini\"], - Literal[\"gpt-image-1.5\"], str""" - quality: Literal["low", "medium", "high", "auto"] - """The quality of the generated image. One of ``low``, ``medium``, ``high``, or ``auto``. Default: - ``auto``. Is one of the following types: Literal[\"low\"], Literal[\"medium\"], - Literal[\"high\"], Literal[\"auto\"]""" - size: Literal["1024x1024", "1024x1536", "1536x1024", "auto"] - """The size of the generated image. One of ``1024x1024``, ``1024x1536``, ``1536x1024``, or - ``auto``. Default: ``auto``. Is one of the following types: Literal[\"1024x1024\"], - Literal[\"1024x1536\"], Literal[\"1536x1024\"], Literal[\"auto\"]""" - output_format: Literal["png", "webp", "jpeg"] - """The output format of the generated image. One of ``png``, ``webp``, or ``jpeg``. Default: - ``png``. Is one of the following types: Literal[\"png\"], Literal[\"webp\"], Literal[\"jpeg\"]""" - output_compression: int - """Compression level for the output image. Default: 100.""" - moderation: Literal["auto", "low"] - """Moderation level for the generated image. Default: ``auto``. Is either a Literal[\"auto\"] type - or a Literal[\"low\"] type.""" - background: Literal["transparent", "opaque", "auto"] - """Background type for the generated image. One of ``transparent``, ``opaque``, or ``auto``. - Default: ``auto``. Is one of the following types: Literal[\"transparent\"], - Literal[\"opaque\"], Literal[\"auto\"]""" - input_fidelity: Optional[InputFidelity] - """Known values are: \"high\" and \"low\".""" - input_image_mask: "ImageGenToolInputImageMask" - """Optional mask for inpainting. Contains ``image_url`` (string, optional) and ``file_id`` - (string, optional).""" - partial_images: int - """Number of partial images to generate in streaming mode, from 0 (default value) to 3.""" - action: ImageGenAction - """Whether to generate a new image or edit an existing image. Default: ``auto``. Known values are: - \"generate\", \"edit\", and \"auto\".""" - - -class ImageGenToolInputImageMask(TypedDict, total=False): - """ImageGenToolInputImageMask. - - :ivar image_url: - :vartype image_url: str - :ivar file_id: - :vartype file_id: str - """ - - image_url: str - file_id: str - - -class InlineSkillParam(TypedDict, total=False): - """InlineSkillParam. - - :ivar type: Defines an inline skill for this request. Required. INLINE. - :vartype type: str or ~azure.ai.projects.models.INLINE - :ivar name: The name of the skill. Required. - :vartype name: str - :ivar description: The description of the skill. Required. - :vartype description: str - :ivar source: Inline skill payload. Required. - :vartype source: ~azure.ai.projects.types.InlineSkillSourceParam - """ - - type: Required[Literal[ContainerSkillType.INLINE]] - """Defines an inline skill for this request. Required. INLINE.""" - name: Required[str] - """The name of the skill. Required.""" - description: Required[str] - """The description of the skill. Required.""" - source: Required["InlineSkillSourceParam"] - """Inline skill payload. Required.""" - - -class InlineSkillSourceParam(TypedDict, total=False): - """Inline skill payload. - - :ivar type: The type of the inline skill source. Must be ``base64``. Required. Default value is - "base64". - :vartype type: str - :ivar media_type: The media type of the inline skill payload. Must be ``application/zip``. - Required. Default value is "application/zip". - :vartype media_type: str - :ivar data: Base64-encoded skill zip bundle. Required. - :vartype data: str - """ - - type: Required[Literal["base64"]] - """The type of the inline skill source. Must be ``base64``. Required. Default value is \"base64\".""" - media_type: Required[Literal["application/zip"]] - """The media type of the inline skill payload. Must be ``application/zip``. Required. Default - value is \"application/zip\".""" - data: Required[str] - """Base64-encoded skill zip bundle. Required.""" - - -class LocalShellToolParam(TypedDict, total=False): - """Local shell tool. - - :ivar type: The type of the local shell tool. Always ``local_shell``. Required. LOCAL_SHELL. - :vartype type: str or ~azure.ai.projects.models.LOCAL_SHELL - """ - - type: Required[Literal[ToolType.LOCAL_SHELL]] - """The type of the local shell tool. Always ``local_shell``. Required. LOCAL_SHELL.""" - - -class LocalSkillParam(TypedDict, total=False): - """LocalSkillParam. - - :ivar name: The name of the skill. Required. - :vartype name: str - :ivar description: The description of the skill. Required. - :vartype description: str - :ivar path: The path to the directory containing the skill. Required. - :vartype path: str - """ - - name: Required[str] - """The name of the skill. Required.""" - description: Required[str] - """The description of the skill. Required.""" - path: Required[str] - """The path to the directory containing the skill. Required.""" - - -class MCPTool(TypedDict, total=False): - """MCP tool. - - :ivar type: The type of the MCP tool. Always ``mcp``. Required. MCP. - :vartype type: str or ~azure.ai.projects.models.MCP - :ivar server_label: A label for this MCP server, used to identify it in tool calls. Required. - :vartype server_label: str - :ivar server_url: The URL for the MCP server. One of ``server_url`` or ``connector_id`` must be - provided. - :vartype server_url: str - :ivar connector_id: Identifier for service connectors, like those available in ChatGPT. One of - ``server_url`` or ``connector_id`` must be provided. Learn more about service connectors `here - `_. Currently supported ``connector_id`` values are: - - * Dropbox: `connector_dropbox` - * Gmail: `connector_gmail` - * Google Calendar: `connector_googlecalendar` - * Google Drive: `connector_googledrive` - * Microsoft Teams: `connector_microsoftteams` - * Outlook Calendar: `connector_outlookcalendar` - * Outlook Email: `connector_outlookemail` - * SharePoint: `connector_sharepoint`. Is one of the following types: - Literal["connector_dropbox"], Literal["connector_gmail"], Literal["connector_googlecalendar"], - Literal["connector_googledrive"], Literal["connector_microsoftteams"], - Literal["connector_outlookcalendar"], Literal["connector_outlookemail"], - Literal["connector_sharepoint"] - :vartype connector_id: str or str or str or str or str or str or str or str - :ivar authorization: An OAuth access token that can be used with a remote MCP server, either - with a custom MCP server URL or a service connector. Your application must handle the OAuth - authorization flow and provide the token here. - :vartype authorization: str - :ivar server_description: Optional description of the MCP server, used to provide more context. - :vartype server_description: str - :ivar headers: - :vartype headers: dict[str, str] - :ivar allowed_tools: Is either a [str] type or a MCPToolFilter type. - :vartype allowed_tools: list[str] or ~azure.ai.projects.types.MCPToolFilter - :ivar require_approval: Is one of the following types: MCPToolRequireApproval, - Literal["always"], Literal["never"] - :vartype require_approval: ~azure.ai.projects.types.MCPToolRequireApproval or str or str - :ivar project_connection_id: The connection ID in the project for the MCP server. The - connection stores authentication and other connection details needed to connect to the MCP - server. - :vartype project_connection_id: str - """ - - type: Required[Literal[ToolType.MCP]] - """The type of the MCP tool. Always ``mcp``. Required. MCP.""" - server_label: Required[str] - """A label for this MCP server, used to identify it in tool calls. Required.""" - server_url: str - """The URL for the MCP server. One of ``server_url`` or ``connector_id`` must be provided.""" - connector_id: Literal[ - "connector_dropbox", - "connector_gmail", - "connector_googlecalendar", - "connector_googledrive", - "connector_microsoftteams", - "connector_outlookcalendar", - "connector_outlookemail", - "connector_sharepoint", - ] - """Identifier for service connectors, like those available in ChatGPT. One of ``server_url`` or - ``connector_id`` must be provided. Learn more about service connectors `here - `_. Currently supported ``connector_id`` values are: - - * Dropbox: `connector_dropbox` - * Gmail: `connector_gmail` - * Google Calendar: `connector_googlecalendar` - * Google Drive: `connector_googledrive` - * Microsoft Teams: `connector_microsoftteams` - * Outlook Calendar: `connector_outlookcalendar` - * Outlook Email: `connector_outlookemail` - * SharePoint: `connector_sharepoint`. Is one of the following types: - Literal[\"connector_dropbox\"], Literal[\"connector_gmail\"], - Literal[\"connector_googlecalendar\"], Literal[\"connector_googledrive\"], - Literal[\"connector_microsoftteams\"], Literal[\"connector_outlookcalendar\"], - Literal[\"connector_outlookemail\"], Literal[\"connector_sharepoint\"]""" - authorization: str - """An OAuth access token that can be used with a remote MCP server, either with a custom MCP - server URL or a service connector. Your application must handle the OAuth authorization flow - and provide the token here.""" - server_description: str - """Optional description of the MCP server, used to provide more context.""" - headers: Optional[dict[str, str]] - allowed_tools: Optional[Union[list[str], "MCPToolFilter"]] - """Is either a [str] type or a MCPToolFilter type.""" - require_approval: Optional[Union["MCPToolRequireApproval", Literal["always"], Literal["never"]]] - """Is one of the following types: MCPToolRequireApproval, Literal[\"always\"], Literal[\"never\"]""" - project_connection_id: str - """The connection ID in the project for the MCP server. The connection stores authentication and - other connection details needed to connect to the MCP server.""" - - -class MCPToolFilter(TypedDict, total=False): - """MCP tool filter. - - :ivar tool_names: MCP allowed tools. - :vartype tool_names: list[str] - :ivar read_only: Indicates whether or not a tool modifies data or is read-only. If an MCP - server is `annotated with `readOnlyHint` - `_, - it will match this filter. - :vartype read_only: bool - """ - - tool_names: list[str] - """MCP allowed tools.""" - read_only: bool - """Indicates whether or not a tool modifies data or is read-only. If an MCP server is `annotated - with `readOnlyHint` - `_, - it will match this filter.""" - - -class MCPToolRequireApproval(TypedDict, total=False): - """MCPToolRequireApproval. - - :ivar always: - :vartype always: ~azure.ai.projects.types.MCPToolFilter - :ivar never: - :vartype never: ~azure.ai.projects.types.MCPToolFilter - """ - - always: "MCPToolFilter" - never: "MCPToolFilter" - - -class RankingOptions(TypedDict, total=False): - """RankingOptions. - - :ivar ranker: The ranker to use for the file search. Known values are: "auto" and - "default-2024-11-15". - :vartype ranker: str or ~azure.ai.projects.models.RankerVersionType - :ivar score_threshold: The score threshold for the file search, a number between 0 and 1. - Numbers closer to 1 will attempt to return only the most relevant results, but may return fewer - results. - :vartype score_threshold: float - :ivar hybrid_search: Weights that control how reciprocal rank fusion balances semantic - embedding matches versus sparse keyword matches when hybrid search is enabled. - :vartype hybrid_search: ~azure.ai.projects.types.HybridSearchOptions - """ - - ranker: RankerVersionType - """The ranker to use for the file search. Known values are: \"auto\" and \"default-2024-11-15\".""" - score_threshold: float - """The score threshold for the file search, a number between 0 and 1. Numbers closer to 1 will - attempt to return only the most relevant results, but may return fewer results.""" - hybrid_search: "HybridSearchOptions" - """Weights that control how reciprocal rank fusion balances semantic embedding matches versus - sparse keyword matches when hybrid search is enabled.""" - - -class Reasoning(TypedDict, total=False): - """Reasoning. - - :ivar effort: Is one of the following types: Literal["none"], Literal["minimal"], - Literal["low"], Literal["medium"], Literal["high"], Literal["xhigh"] - :vartype effort: str or str or str or str or str or str - :ivar summary: Is one of the following types: Literal["auto"], Literal["concise"], - Literal["detailed"] - :vartype summary: str or str or str - :ivar generate_summary: Is one of the following types: Literal["auto"], Literal["concise"], - Literal["detailed"] - :vartype generate_summary: str or str or str - """ - - effort: Optional[Literal["none", "minimal", "low", "medium", "high", "xhigh"]] - """Is one of the following types: Literal[\"none\"], Literal[\"minimal\"], Literal[\"low\"], - Literal[\"medium\"], Literal[\"high\"], Literal[\"xhigh\"]""" - summary: Optional[Literal["auto", "concise", "detailed"]] - """Is one of the following types: Literal[\"auto\"], Literal[\"concise\"], Literal[\"detailed\"]""" - generate_summary: Optional[Literal["auto", "concise", "detailed"]] - """Is one of the following types: Literal[\"auto\"], Literal[\"concise\"], Literal[\"detailed\"]""" - - -class ResponseUsageInputTokensDetails(TypedDict, total=False): - """ResponseUsageInputTokensDetails. - - :ivar cached_tokens: Required. - :vartype cached_tokens: int - """ - - cached_tokens: Required[int] - """Required.""" - - -class ResponseUsageOutputTokensDetails(TypedDict, total=False): - """ResponseUsageOutputTokensDetails. - - :ivar reasoning_tokens: Required. - :vartype reasoning_tokens: int - """ - - reasoning_tokens: Required[int] - """Required.""" - - -class SkillReferenceParam(TypedDict, total=False): - """SkillReferenceParam. - - :ivar type: References a skill created with the /v1/skills endpoint. Required. SKILL_REFERENCE. - :vartype type: str or ~azure.ai.projects.models.SKILL_REFERENCE - :ivar skill_id: The ID of the referenced skill. Required. - :vartype skill_id: str - :ivar version: Optional skill version. Use a positive integer or 'latest'. Omit for default. - :vartype version: str - """ - - type: Required[Literal[ContainerSkillType.SKILL_REFERENCE]] - """References a skill created with the /v1/skills endpoint. Required. SKILL_REFERENCE.""" - skill_id: Required[str] - """The ID of the referenced skill. Required.""" - version: str - """Optional skill version. Use a positive integer or 'latest'. Omit for default.""" - - -class SpecificApplyPatchParam(TypedDict, total=False): - """Specific apply patch tool choice. - - :ivar type: The tool to call. Always ``apply_patch``. Required. APPLY_PATCH. - :vartype type: str or ~azure.ai.projects.models.APPLY_PATCH - """ - - type: Required[Literal[ToolChoiceParamType.APPLY_PATCH]] - """The tool to call. Always ``apply_patch``. Required. APPLY_PATCH.""" - - -class SpecificFunctionShellParam(TypedDict, total=False): - """Specific shell tool choice. - - :ivar type: The tool to call. Always ``shell``. Required. SHELL. - :vartype type: str or ~azure.ai.projects.models.SHELL - """ - - type: Required[Literal[ToolChoiceParamType.SHELL]] - """The tool to call. Always ``shell``. Required. SHELL.""" - - -class TextResponseFormatJsonObject(TypedDict, total=False): - """JSON object. - - :ivar type: The type of response format being defined. Always ``json_object``. Required. - JSON_OBJECT. - :vartype type: str or ~azure.ai.projects.models.JSON_OBJECT - """ - - type: Required[Literal[TextResponseFormatConfigurationType.JSON_OBJECT]] - """The type of response format being defined. Always ``json_object``. Required. JSON_OBJECT.""" - - -class TextResponseFormatJsonSchema(TypedDict, total=False): - """JSON schema. - - :ivar type: The type of response format being defined. Always ``json_schema``. Required. - JSON_SCHEMA. - :vartype type: str or ~azure.ai.projects.models.JSON_SCHEMA - :ivar description: A description of what the response format is for, used by the model to - determine how to respond in the format. - :vartype description: str - :ivar name: The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and - dashes, with a maximum length of 64. Required. - :vartype name: str - :ivar schema: Required. - :vartype schema: dict[str, any] - :ivar strict: - :vartype strict: bool - """ - - type: Required[Literal[TextResponseFormatConfigurationType.JSON_SCHEMA]] - """The type of response format being defined. Always ``json_schema``. Required. JSON_SCHEMA.""" - description: str - """A description of what the response format is for, used by the model to determine how to respond - in the format.""" - name: Required[str] - """The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with - a maximum length of 64. Required.""" - schema: Required[dict[str, Any]] - """Required.""" - strict: Optional[bool] - - -class TextResponseFormatText(TypedDict, total=False): - """Text. - - :ivar type: The type of response format being defined. Always ``text``. Required. TEXT. - :vartype type: str or ~azure.ai.projects.models.TEXT - """ - - type: Required[Literal[TextResponseFormatConfigurationType.TEXT]] - """The type of response format being defined. Always ``text``. Required. TEXT.""" - - -class ToolChoiceAllowed(TypedDict, total=False): - """Allowed tools. - - :ivar type: Allowed tool configuration type. Always ``allowed_tools``. Required. ALLOWED_TOOLS. - :vartype type: str or ~azure.ai.projects.models.ALLOWED_TOOLS - :ivar mode: Constrains the tools available to the model to a pre-defined set. ``auto`` allows - the model to pick from among the allowed tools and generate a message. ``required`` requires - the model to call one or more of the allowed tools. Required. Is either a Literal["auto"] type - or a Literal["required"] type. - :vartype mode: str or str - :ivar tools: A list of tool definitions that the model should be allowed to call. For the - Responses API, the list of tool definitions might look like: - - .. code-block:: json - - [ - { "type": "function", "name": "get_weather" }, - { "type": "mcp", "server_label": "deepwiki" }, - { "type": "image_generation" } - ]. Required. - :vartype tools: list[dict[str, any]] - """ - - type: Required[Literal[ToolChoiceParamType.ALLOWED_TOOLS]] - """Allowed tool configuration type. Always ``allowed_tools``. Required. ALLOWED_TOOLS.""" - mode: Required[Literal["auto", "required"]] - """Constrains the tools available to the model to a pre-defined set. ``auto`` allows the model to - pick from among the allowed tools and generate a message. ``required`` requires the model to - call one or more of the allowed tools. Required. Is either a Literal[\"auto\"] type or a - Literal[\"required\"] type.""" - tools: Required[list[dict[str, Any]]] - """A list of tool definitions that the model should be allowed to call. For the Responses API, the - list of tool definitions might look like: - - .. code-block:: json - - [ - { \"type\": \"function\", \"name\": \"get_weather\" }, - { \"type\": \"mcp\", \"server_label\": \"deepwiki\" }, - { \"type\": \"image_generation\" } - ]. Required.""" - - -class ToolChoiceCodeInterpreter(TypedDict, total=False): - """Indicates that the model should use a built-in tool to generate a response. `Learn more about - built-in tools `_. - - :ivar type: Required. CODE_INTERPRETER. - :vartype type: str or ~azure.ai.projects.models.CODE_INTERPRETER - """ - - type: Required[Literal[ToolChoiceParamType.CODE_INTERPRETER]] - """Required. CODE_INTERPRETER.""" - - -class ToolChoiceComputerUsePreview(TypedDict, total=False): - """Indicates that the model should use a built-in tool to generate a response. `Learn more about - built-in tools `_. - - :ivar type: Required. COMPUTER_USE_PREVIEW. - :vartype type: str or ~azure.ai.projects.models.COMPUTER_USE_PREVIEW - """ - - type: Required[Literal[ToolChoiceParamType.COMPUTER_USE_PREVIEW]] - """Required. COMPUTER_USE_PREVIEW.""" - - -class ToolChoiceCustom(TypedDict, total=False): - """Custom tool. - - :ivar type: For custom tool calling, the type is always ``custom``. Required. CUSTOM. - :vartype type: str or ~azure.ai.projects.models.CUSTOM - :ivar name: The name of the custom tool to call. Required. - :vartype name: str - """ - - type: Required[Literal[ToolChoiceParamType.CUSTOM]] - """For custom tool calling, the type is always ``custom``. Required. CUSTOM.""" - name: Required[str] - """The name of the custom tool to call. Required.""" - - -class ToolChoiceFileSearch(TypedDict, total=False): - """Indicates that the model should use a built-in tool to generate a response. `Learn more about - built-in tools `_. - - :ivar type: Required. FILE_SEARCH. - :vartype type: str or ~azure.ai.projects.models.FILE_SEARCH - """ - - type: Required[Literal[ToolChoiceParamType.FILE_SEARCH]] - """Required. FILE_SEARCH.""" - - -class ToolChoiceFunction(TypedDict, total=False): - """Function tool. - - :ivar type: For function calling, the type is always ``function``. Required. FUNCTION. - :vartype type: str or ~azure.ai.projects.models.FUNCTION - :ivar name: The name of the function to call. Required. - :vartype name: str - """ - - type: Required[Literal[ToolChoiceParamType.FUNCTION]] - """For function calling, the type is always ``function``. Required. FUNCTION.""" - name: Required[str] - """The name of the function to call. Required.""" - - -class ToolChoiceImageGeneration(TypedDict, total=False): - """Indicates that the model should use a built-in tool to generate a response. `Learn more about - built-in tools `_. - - :ivar type: Required. IMAGE_GENERATION. - :vartype type: str or ~azure.ai.projects.models.IMAGE_GENERATION - """ - - type: Required[Literal[ToolChoiceParamType.IMAGE_GENERATION]] - """Required. IMAGE_GENERATION.""" - - -class ToolChoiceMCP(TypedDict, total=False): - """MCP tool. - - :ivar type: For MCP tools, the type is always ``mcp``. Required. MCP. - :vartype type: str or ~azure.ai.projects.models.MCP - :ivar server_label: The label of the MCP server to use. Required. - :vartype server_label: str - :ivar name: - :vartype name: str - """ - - type: Required[Literal[ToolChoiceParamType.MCP]] - """For MCP tools, the type is always ``mcp``. Required. MCP.""" - server_label: Required[str] - """The label of the MCP server to use. Required.""" - name: Optional[str] - - -class ToolChoiceWebSearchPreview(TypedDict, total=False): - """Indicates that the model should use a built-in tool to generate a response. `Learn more about - built-in tools `_. - - :ivar type: Required. WEB_SEARCH_PREVIEW. - :vartype type: str or ~azure.ai.projects.models.WEB_SEARCH_PREVIEW - """ - - type: Required[Literal[ToolChoiceParamType.WEB_SEARCH_PREVIEW]] - """Required. WEB_SEARCH_PREVIEW.""" - - -class ToolChoiceWebSearchPreview20250311(TypedDict, total=False): - """Indicates that the model should use a built-in tool to generate a response. `Learn more about - built-in tools `_. - - :ivar type: Required. WEB_SEARCH_PREVIEW2025_03_11. - :vartype type: str or ~azure.ai.projects.models.WEB_SEARCH_PREVIEW2025_03_11 - """ - - type: Required[Literal[ToolChoiceParamType.WEB_SEARCH_PREVIEW2025_03_11]] - """Required. WEB_SEARCH_PREVIEW2025_03_11.""" - - -class WebSearchApproximateLocation(TypedDict, total=False): - """Web search approximate location. - - :ivar type: The type of location approximation. Always ``approximate``. Required. Default value - is "approximate". - :vartype type: str - :ivar country: - :vartype country: str - :ivar region: - :vartype region: str - :ivar city: - :vartype city: str - :ivar timezone: - :vartype timezone: str - """ - - type: Required[Literal["approximate"]] - """The type of location approximation. Always ``approximate``. Required. Default value is - \"approximate\".""" - country: Optional[str] - region: Optional[str] - city: Optional[str] - timezone: Optional[str] - - -class WebSearchPreviewTool(TypedDict, total=False): - """Web search preview. - - :ivar type: The type of the web search tool. One of ``web_search_preview`` or - ``web_search_preview_2025_03_11``. Required. WEB_SEARCH_PREVIEW. - :vartype type: str or ~azure.ai.projects.models.WEB_SEARCH_PREVIEW - :ivar user_location: - :vartype user_location: ~azure.ai.projects.types.ApproximateLocation - :ivar search_context_size: High level guidance for the amount of context window space to use - for the search. One of ``low``, ``medium``, or ``high``. ``medium`` is the default. Known - values are: "low", "medium", and "high". - :vartype search_context_size: str or ~azure.ai.projects.models.SearchContextSize - """ - - type: Required[Literal[ToolType.WEB_SEARCH_PREVIEW]] - """The type of the web search tool. One of ``web_search_preview`` or - ``web_search_preview_2025_03_11``. Required. WEB_SEARCH_PREVIEW.""" - user_location: Optional["ApproximateLocation"] - search_context_size: SearchContextSize - """High level guidance for the amount of context window space to use for the search. One of - ``low``, ``medium``, or ``high``. ``medium`` is the default. Known values are: \"low\", - \"medium\", and \"high\".""" - - -class WebSearchTool(TypedDict, total=False): - """Web search. - - :ivar type: The type of the web search tool. One of ``web_search`` or - ``web_search_2025_08_26``. Required. WEB_SEARCH. - :vartype type: str or ~azure.ai.projects.models.WEB_SEARCH - :ivar filters: - :vartype filters: ~azure.ai.projects.types.WebSearchToolFilters - :ivar user_location: - :vartype user_location: ~azure.ai.projects.types.WebSearchApproximateLocation - :ivar search_context_size: High level guidance for the amount of context window space to use - for the search. One of ``low``, ``medium``, or ``high``. ``medium`` is the default. Is one of - the following types: Literal["low"], Literal["medium"], Literal["high"] - :vartype search_context_size: str or str or str - :ivar custom_search_configuration: The project connections attached to this tool. There can be - a maximum of 1 connection resource attached to the tool. - :vartype custom_search_configuration: ~azure.ai.agents.types.WebSearchConfiguration - """ - - type: Required[Literal[ToolType.WEB_SEARCH]] - """The type of the web search tool. One of ``web_search`` or ``web_search_2025_08_26``. Required. - WEB_SEARCH.""" - filters: Optional["WebSearchToolFilters"] - user_location: Optional["WebSearchApproximateLocation"] - search_context_size: Literal["low", "medium", "high"] - """High level guidance for the amount of context window space to use for the search. One of - ``low``, ``medium``, or ``high``. ``medium`` is the default. Is one of the following types: - Literal[\"low\"], Literal[\"medium\"], Literal[\"high\"]""" - custom_search_configuration: "WebSearchConfiguration" - """The project connections attached to this tool. There can be a maximum of 1 connection resource - attached to the tool.""" - - -class WebSearchToolFilters(TypedDict, total=False): - """WebSearchToolFilters. - - :ivar allowed_domains: - :vartype allowed_domains: list[str] - """ - - allowed_domains: Optional[list[str]] - - -Tool = Union[ - A2APreviewTool, - ApplyPatchToolParam, - AzureAISearchTool, - AzureFunctionTool, - BingCustomSearchPreviewTool, - BingGroundingTool, - BrowserAutomationPreviewTool, - CaptureStructuredOutputsTool, - CodeInterpreterTool, - ComputerUsePreviewTool, - CustomToolParam, - MicrosoftFabricPreviewTool, - FileSearchTool, - FunctionTool, - ImageGenTool, - LocalShellToolParam, - MCPTool, - MemorySearchPreviewTool, - OpenApiTool, - SharepointPreviewTool, - FunctionShellToolParam, - WebSearchTool, - WebSearchPreviewTool, -] -FunctionShellToolParamEnvironment = Union[ - ContainerAutoParam, - FunctionShellToolParamEnvironmentContainerReferenceParam, - FunctionShellToolParamEnvironmentLocalEnvironmentParam, -] -ContainerNetworkPolicyParam = Union[ContainerNetworkPolicyAllowlistParam, ContainerNetworkPolicyDisabledParam] -ContainerSkill = Union[InlineSkillParam, SkillReferenceParam] -CustomToolParamFormat = Union[CustomGrammarFormatParam, CustomTextFormatParam] -ToolChoiceParam = Union[ - ToolChoiceAllowed, - SpecificApplyPatchParam, - ToolChoiceCodeInterpreter, - ToolChoiceComputerUsePreview, - ToolChoiceCustom, - ToolChoiceFileSearch, - ToolChoiceFunction, - ToolChoiceImageGeneration, - ToolChoiceMCP, - SpecificFunctionShellParam, - ToolChoiceWebSearchPreview, - ToolChoiceWebSearchPreview20250311, -] -TextResponseFormat = Union[TextResponseFormatJsonObject, TextResponseFormatJsonSchema, TextResponseFormatText] diff --git a/sdk/ai/azure-ai-projects/azure/ai/projects/_unions.py b/sdk/ai/azure-ai-projects/azure/ai/projects/_unions.py deleted file mode 100644 index b03d9e548284..000000000000 --- a/sdk/ai/azure-ai-projects/azure/ai/projects/_unions.py +++ /dev/null @@ -1,13 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import TYPE_CHECKING, Union - -if TYPE_CHECKING: - from . import types as _types -Filters = Union["_types.ComparisonFilter", "_types.CompoundFilter"] diff --git a/sdk/ai/azure-ai-projects/azure/ai/projects/types.py b/sdk/ai/azure-ai-projects/azure/ai/projects/types.py deleted file mode 100644 index 5a5d1fefd0e3..000000000000 --- a/sdk/ai/azure-ai-projects/azure/ai/projects/types.py +++ /dev/null @@ -1,4640 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, Literal, Optional, TYPE_CHECKING, Union -from typing_extensions import Required, TypedDict - -from .models._enums import ( - AgentKind, - AgentObjectType, - ContainerNetworkPolicyParamType, - ContainerSkillType, - CredentialType, - CustomToolParamFormatType, - DatasetType, - DeploymentType, - EvaluationRuleActionType, - EvaluationTaxonomyInputType, - EvaluatorDefinitionType, - FunctionShellToolParamEnvironmentType, - IndexType, - InsightType, - MemoryItemKind, - MemoryStoreKind, - MemoryStoreObjectType, - OpenApiAuthType, - PendingUploadType, - RecurrenceType, - SampleType, - ScheduleTaskType, - TextResponseFormatConfigurationType, - ToolChoiceParamType, - ToolType, - TriggerType, -) - -if TYPE_CHECKING: - from . import _unions - -AgentDefinitionOptInKeys = Literal["HostedAgents=V1Preview", "WorkflowAgents=V1Preview"] -"""Feature opt-in keys for agent definition operations supporting hosted or workflow agents.""" - -AgentKind = Literal["prompt", "hosted", "workflow"] -"""Type of AgentKind.""" - -AgentObjectType = Literal["agent", "agent.version", "agent.deleted", "agent.version.deleted", "agent.container"] -"""Type of AgentObjectType.""" - -AgentProtocol = Literal["activity_protocol", "responses"] -"""Type of AgentProtocol.""" - -AttackStrategy = Literal[ - "easy", - "moderate", - "difficult", - "ascii_art", - "ascii_smuggler", - "atbash", - "base64", - "binary", - "caesar", - "character_space", - "jailbreak", - "ansi_attack", - "character_swap", - "suffix_append", - "string_join", - "unicode_confusable", - "unicode_substitution", - "diacritic", - "flip", - "leetspeak", - "rot13", - "morse", - "url", - "baseline", - "indirect_jailbreak", - "tense", - "multi_turn", - "crescendo", -] -"""Strategies for attacks.""" - -AzureAISearchQueryType = Literal["simple", "semantic", "vector", "vector_simple_hybrid", "vector_semantic_hybrid"] -"""Available query types for Azure AI Search tool.""" - -ComputerEnvironment = Literal["windows", "mac", "linux", "ubuntu", "browser"] -"""Type of ComputerEnvironment.""" - -ConnectionType = Literal[ - "AzureOpenAI", - "AzureBlob", - "AzureStorageAccount", - "CognitiveSearch", - "CosmosDB", - "ApiKey", - "AppConfig", - "AppInsights", - "CustomKeys", - "RemoteTool_Preview", -] -"""The Type (or category) of the connection.""" - -ContainerMemoryLimit = Literal["1g", "4g", "16g", "64g"] -"""Type of ContainerMemoryLimit.""" - -ContainerNetworkPolicyParamType = Literal["disabled", "allowlist"] -"""Type of ContainerNetworkPolicyParamType.""" - -ContainerSkillType = Literal["skill_reference", "inline"] -"""Type of ContainerSkillType.""" - -CredentialType = Literal["ApiKey", "AAD", "SAS", "CustomKeys", "None", "AgenticIdentityToken_Preview"] -"""The credential type used by the connection.""" - -CustomToolParamFormatType = Literal["text", "grammar"] -"""Type of CustomToolParamFormatType.""" - -DatasetType = Literal["uri_file", "uri_folder"] -"""Enum to determine the type of data.""" - -DayOfWeek = Literal["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] -"""Days of the week for recurrence schedule.""" - -DeploymentType = Literal["ModelDeployment"] -"""Type of DeploymentType.""" - -EvaluationRuleActionType = Literal["continuousEvaluation", "humanEvaluationPreview"] -"""Type of the evaluation action.""" - -EvaluationRuleEventType = Literal["responseCompleted", "manual"] -"""Type of the evaluation rule event.""" - -EvaluationTaxonomyInputType = Literal["agent", "policy"] -"""Type of the evaluation taxonomy input.""" - -EvaluatorCategory = Literal["quality", "safety", "agents"] -"""The category of the evaluator.""" - -EvaluatorDefinitionType = Literal["prompt", "code", "prompt_and_code", "service", "openai_graders"] -"""The type of evaluator definition.""" - -EvaluatorMetricDirection = Literal["increase", "decrease", "neutral"] -"""The direction of the metric indicating whether a higher value is better, a lower value is -better, or neutral.""" - -EvaluatorMetricType = Literal["ordinal", "continuous", "boolean"] -"""The type of the evaluator.""" - -EvaluatorType = Literal["builtin", "custom"] -"""The type of the evaluator.""" - -FoundryFeaturesOptInKeys = Literal[ - "Evaluations=V1Preview", "Schedules=V1Preview", "RedTeams=V1Preview", "Insights=V1Preview", "MemoryStores=V1Preview" -] -"""Type of FoundryFeaturesOptInKeys.""" - -FunctionShellToolParamEnvironmentType = Literal["container_auto", "local", "container_reference"] -"""Type of FunctionShellToolParamEnvironmentType.""" - -GrammarSyntax1 = Literal["lark", "regex"] -"""Type of GrammarSyntax1.""" - -ImageGenAction = Literal["generate", "edit", "auto"] -"""Type of ImageGenAction.""" - -IndexType = Literal["AzureSearch", "CosmosDBNoSqlVectorStore", "ManagedAzureSearch"] -"""Type of IndexType.""" - -InputFidelity = Literal["high", "low"] -"""Control how much effort the model will exert to match the style and features, especially facial -features, of input images. This parameter is only supported for ``gpt-image-1`` and -``gpt-image-1.5`` and later models, unsupported for ``gpt-image-1-mini``. Supports ``high`` and -``low``. Defaults to ``low``.""" - -InsightType = Literal["EvaluationRunClusterInsight", "AgentClusterInsight", "EvaluationComparison"] -"""The request of the insights.""" - -MemoryItemKind = Literal["user_profile", "chat_summary"] -"""Memory item kind.""" - -MemoryOperationKind = Literal["create", "update", "delete"] -"""Memory operation kind.""" - -MemoryStoreKind = Literal["default"] -"""The type of memory store implementation to use.""" - -MemoryStoreObjectType = Literal["memory_store", "memory_store.deleted", "memory_store.scope.deleted"] -"""Type of MemoryStoreObjectType.""" - -MemoryStoreUpdateStatus = Literal["queued", "in_progress", "completed", "failed", "superseded"] -"""Status of a memory store update operation.""" - -OpenApiAuthType = Literal["anonymous", "project_connection", "managed_identity"] -"""Authentication type for OpenApi endpoint. Allowed types are: - -* Anonymous (no authentication required) -* Project Connection (requires project_connection_id to endpoint, as setup in AI Foundry) -* Managed_Identity (requires audience for identity based auth).""" - -OperationState = Literal["NotStarted", "Running", "Succeeded", "Failed", "Canceled"] -"""Enum describing allowed operation states.""" - -PageOrder = Literal["asc", "desc"] -"""Type of PageOrder.""" - -PendingUploadType = Literal["None", "BlobReference"] -"""The type of pending upload.""" - -RankerVersionType = Literal["auto", "default-2024-11-15"] -"""Type of RankerVersionType.""" - -RecurrenceType = Literal["Hourly", "Daily", "Weekly", "Monthly"] -"""Recurrence type.""" - -RiskCategory = Literal[ - "HateUnfairness", - "Violence", - "Sexual", - "SelfHarm", - "ProtectedMaterial", - "CodeVulnerability", - "UngroundedAttributes", - "ProhibitedActions", - "SensitiveDataLeakage", - "TaskAdherence", -] -"""Risk category for the attack objective.""" - -SampleType = Literal["EvaluationResultSample"] -"""The type of sample used in the analysis.""" - -ScheduleProvisioningStatus = Literal["Creating", "Updating", "Deleting", "Succeeded", "Failed"] -"""Schedule provisioning status.""" - -ScheduleTaskType = Literal["Evaluation", "Insight"] -"""Type of the task.""" - -SearchContextSize = Literal["low", "medium", "high"] -"""Type of SearchContextSize.""" - -TextResponseFormatConfigurationType = Literal["text", "json_schema", "json_object"] -"""Type of TextResponseFormatConfigurationType.""" - -ToolChoiceParamType = Literal[ - "allowed_tools", - "function", - "mcp", - "custom", - "apply_patch", - "shell", - "file_search", - "web_search_preview", - "computer_use_preview", - "web_search_preview_2025_03_11", - "image_generation", - "code_interpreter", -] -"""Type of ToolChoiceParamType.""" - -ToolType = Literal[ - "function", - "file_search", - "computer_use_preview", - "web_search", - "mcp", - "code_interpreter", - "image_generation", - "local_shell", - "shell", - "custom", - "web_search_preview", - "apply_patch", - "a2a_preview", - "bing_custom_search_preview", - "browser_automation_preview", - "fabric_dataagent_preview", - "sharepoint_grounding_preview", - "memory_search_preview", - "azure_ai_search", - "azure_function", - "bing_grounding", - "capture_structured_outputs", - "openapi", -] -"""Type of ToolType.""" - -TreatmentEffectType = Literal["TooFewSamples", "Inconclusive", "Changed", "Improved", "Degraded"] -"""Treatment Effect Type.""" - -TriggerType = Literal["Cron", "Recurrence", "OneTime"] -"""Type of the trigger.""" - - -class A2APreviewTool(TypedDict, total=False): - """An agent implementing the A2A protocol. - - :ivar type: The type of the tool. Always ``"a2a_preview``. Required. A2_A_PREVIEW. - :vartype type: str or ~azure.ai.projects.models.A2_A_PREVIEW - :ivar base_url: Base URL of the agent. - :vartype base_url: str - :ivar agent_card_path: The path to the agent card relative to the ``base_url``. If not - provided, defaults to ``/.well-known/agent-card.json``. - :vartype agent_card_path: str - :ivar project_connection_id: The connection ID in the project for the A2A server. The - connection stores authentication and other connection details needed to connect to the A2A - server. - :vartype project_connection_id: str - """ - - type: Required[Literal[ToolType.A2_A_PREVIEW]] - """The type of the tool. Always ``\"a2a_preview``. Required. A2_A_PREVIEW.""" - base_url: str - """Base URL of the agent.""" - agent_card_path: str - """The path to the agent card relative to the ``base_url``. If not provided, defaults to - ``/.well-known/agent-card.json``.""" - project_connection_id: str - """The connection ID in the project for the A2A server. The connection stores authentication and - other connection details needed to connect to the A2A server.""" - - -class AgentClusterInsightRequest(TypedDict, total=False): - """Insights on set of Agent Evaluation Results. - - :ivar type: The type of request. Required. Cluster Insight on an Agent. - :vartype type: str or ~azure.ai.projects.models.AGENT_CLUSTER_INSIGHT - :ivar agent_name: Identifier for the agent. Required. - :vartype agent_name: str - :ivar model_configuration: Configuration of the model used in the insight generation. - :vartype model_configuration: ~azure.ai.projects.types.InsightModelConfiguration - """ - - type: Required[Literal[InsightType.AGENT_CLUSTER_INSIGHT]] - """The type of request. Required. Cluster Insight on an Agent.""" - agentName: Required[str] - """Identifier for the agent. Required.""" - modelConfiguration: "InsightModelConfiguration" - """Configuration of the model used in the insight generation.""" - - -class AgentClusterInsightResult(TypedDict, total=False): - """Insights from the agent cluster analysis. - - :ivar type: The type of insights result. Required. Cluster Insight on an Agent. - :vartype type: str or ~azure.ai.projects.models.AGENT_CLUSTER_INSIGHT - :ivar cluster_insight: Required. - :vartype cluster_insight: ~azure.ai.projects.types.ClusterInsightResult - """ - - type: Required[Literal[InsightType.AGENT_CLUSTER_INSIGHT]] - """The type of insights result. Required. Cluster Insight on an Agent.""" - clusterInsight: Required["ClusterInsightResult"] - """Required.""" - - -class AgentDetails(TypedDict, total=False): - """AgentDetails. - - :ivar object: The object type, which is always 'agent'. Required. AGENT. - :vartype object: str or ~azure.ai.projects.models.AGENT - :ivar id: The unique identifier of the agent. Required. - :vartype id: str - :ivar name: The name of the agent. Required. - :vartype name: str - :ivar versions: The latest version of the agent. Required. - :vartype versions: ~azure.ai.projects.types.AgentObjectVersions - """ - - object: Required[Literal[AgentObjectType.AGENT]] - """The object type, which is always 'agent'. Required. AGENT.""" - id: Required[str] - """The unique identifier of the agent. Required.""" - name: Required[str] - """The name of the agent. Required.""" - versions: Required["AgentObjectVersions"] - """The latest version of the agent. Required.""" - - -class AgenticIdentityPreviewCredentials(TypedDict, total=False): - """Agentic identity credential definition. - - :ivar type: The credential type. Required. Agentic identity credential. - :vartype type: str or ~azure.ai.projects.models.AGENTIC_IDENTITY_PREVIEW - """ - - type: Required[Literal[CredentialType.AGENTIC_IDENTITY_PREVIEW]] - """The credential type. Required. Agentic identity credential.""" - - -class AgentObjectVersions(TypedDict, total=False): - """AgentObjectVersions. - - :ivar latest: Required. - :vartype latest: ~azure.ai.projects.types.AgentVersionDetails - """ - - latest: Required["AgentVersionDetails"] - """Required.""" - - -class AgentTaxonomyInput(TypedDict, total=False): - """Input configuration for the evaluation taxonomy when the input type is agent. - - :ivar type: Input type of the evaluation taxonomy. Required. Agent. - :vartype type: str or ~azure.ai.projects.models.AGENT - :ivar target: Target configuration for the agent. Required. - :vartype target: ~azure.ai.projects.types.Target - :ivar risk_categories: List of risk categories to evaluate against. Required. - :vartype risk_categories: list[str or ~azure.ai.projects.models.RiskCategory] - """ - - type: Required[Literal[EvaluationTaxonomyInputType.AGENT]] - """Input type of the evaluation taxonomy. Required. Agent.""" - target: Required["Target"] - """Target configuration for the agent. Required.""" - riskCategories: Required[list[RiskCategory]] - """List of risk categories to evaluate against. Required.""" - - -class AgentVersionDetails(TypedDict, total=False): - """AgentVersionDetails. - - :ivar metadata: Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. Required. - :vartype metadata: dict[str, str] - :ivar object: The object type, which is always 'agent.version'. Required. AGENT_VERSION. - :vartype object: str or ~azure.ai.projects.models.AGENT_VERSION - :ivar id: The unique identifier of the agent version. Required. - :vartype id: str - :ivar name: The name of the agent. Name can be used to retrieve/update/delete the agent. - Required. - :vartype name: str - :ivar version: The version identifier of the agent. Agents are immutable and every update - creates a new version while keeping the name same. Required. - :vartype version: str - :ivar description: A human-readable description of the agent. - :vartype description: str - :ivar created_at: The Unix timestamp (seconds) when the agent was created. Required. - :vartype created_at: ~datetime.datetime - :ivar definition: Required. - :vartype definition: ~azure.ai.projects.types.AgentDefinition - """ - - metadata: Required[Optional[dict[str, str]]] - """Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. Required.""" - object: Required[Literal[AgentObjectType.AGENT_VERSION]] - """The object type, which is always 'agent.version'. Required. AGENT_VERSION.""" - id: Required[str] - """The unique identifier of the agent version. Required.""" - name: Required[str] - """The name of the agent. Name can be used to retrieve/update/delete the agent. Required.""" - version: Required[str] - """The version identifier of the agent. Agents are immutable and every update creates a new - version while keeping the name same. Required.""" - description: str - """A human-readable description of the agent.""" - created_at: Required[int] - """The Unix timestamp (seconds) when the agent was created. Required.""" - definition: Required["AgentDefinition"] - """Required.""" - - -class AISearchIndexResource(TypedDict, total=False): - """A AI Search Index resource. - - :ivar project_connection_id: An index connection ID in an IndexResource attached to this agent. - :vartype project_connection_id: str - :ivar index_name: The name of an index in an IndexResource attached to this agent. - :vartype index_name: str - :ivar query_type: Type of query in an AIIndexResource attached to this agent. Known values are: - "simple", "semantic", "vector", "vector_simple_hybrid", and "vector_semantic_hybrid". - :vartype query_type: str or ~azure.ai.projects.models.AzureAISearchQueryType - :ivar top_k: Number of documents to retrieve from search and present to the model. - :vartype top_k: int - :ivar filter: filter string for search resource. `Learn more here - `_. - :vartype filter: str - :ivar index_asset_id: Index asset id for search resource. - :vartype index_asset_id: str - """ - - project_connection_id: str - """An index connection ID in an IndexResource attached to this agent.""" - index_name: str - """The name of an index in an IndexResource attached to this agent.""" - query_type: AzureAISearchQueryType - """Type of query in an AIIndexResource attached to this agent. Known values are: \"simple\", - \"semantic\", \"vector\", \"vector_simple_hybrid\", and \"vector_semantic_hybrid\".""" - top_k: int - """Number of documents to retrieve from search and present to the model.""" - filter: str - """filter string for search resource. `Learn more here - `_.""" - index_asset_id: str - """Index asset id for search resource.""" - - -class ApiError(TypedDict, total=False): - """ApiError. - - :ivar code: Required. - :vartype code: str - :ivar message: Required. - :vartype message: str - :ivar param: - :vartype param: str - :ivar type: - :vartype type: str - :ivar details: - :vartype details: list[~azure.ai.projects.types.ApiError] - :ivar additional_info: - :vartype additional_info: dict[str, any] - :ivar debug_info: - :vartype debug_info: dict[str, any] - """ - - code: Required[Optional[str]] - """Required.""" - message: Required[str] - """Required.""" - param: Optional[str] - type: str - details: list["ApiError"] - additionalInfo: dict[str, Any] - debugInfo: dict[str, Any] - - -class ApiErrorResponse(TypedDict, total=False): - """Error response for API failures. - - :ivar error: Required. - :vartype error: ~azure.ai.projects.types.ApiError - """ - - error: Required["ApiError"] - """Required.""" - - -class ApiKeyCredentials(TypedDict, total=False): - """API Key Credential definition. - - :ivar type: The credential type. Required. API Key credential. - :vartype type: str or ~azure.ai.projects.models.API_KEY - :ivar api_key: API Key. - :vartype api_key: str - """ - - type: Required[Literal[CredentialType.API_KEY]] - """The credential type. Required. API Key credential.""" - key: str - """API Key.""" - - -class ApplyPatchToolParam(TypedDict, total=False): - """Apply patch tool. - - :ivar type: The type of the tool. Always ``apply_patch``. Required. APPLY_PATCH. - :vartype type: str or ~azure.ai.projects.models.APPLY_PATCH - """ - - type: Required[Literal[ToolType.APPLY_PATCH]] - """The type of the tool. Always ``apply_patch``. Required. APPLY_PATCH.""" - - -class ApproximateLocation(TypedDict, total=False): - """ApproximateLocation. - - :ivar type: The type of location approximation. Always ``approximate``. Required. Default value - is "approximate". - :vartype type: str - :ivar country: - :vartype country: str - :ivar region: - :vartype region: str - :ivar city: - :vartype city: str - :ivar timezone: - :vartype timezone: str - """ - - type: Required[Literal["approximate"]] - """The type of location approximation. Always ``approximate``. Required. Default value is - \"approximate\".""" - country: Optional[str] - region: Optional[str] - city: Optional[str] - timezone: Optional[str] - - -class AutoCodeInterpreterToolParam(TypedDict, total=False): - """Automatic Code Interpreter Tool Parameters. - - :ivar type: Always ``auto``. Required. Default value is "auto". - :vartype type: str - :ivar file_ids: An optional list of uploaded files to make available to your code. - :vartype file_ids: list[str] - :ivar memory_limit: Known values are: "1g", "4g", "16g", and "64g". - :vartype memory_limit: str or ~azure.ai.projects.models.ContainerMemoryLimit - :ivar network_policy: - :vartype network_policy: ~azure.ai.projects.types.ContainerNetworkPolicyParam - """ - - type: Required[Literal["auto"]] - """Always ``auto``. Required. Default value is \"auto\".""" - file_ids: list[str] - """An optional list of uploaded files to make available to your code.""" - memory_limit: Optional[ContainerMemoryLimit] - """Known values are: \"1g\", \"4g\", \"16g\", and \"64g\".""" - network_policy: "ContainerNetworkPolicyParam" - - -class AzureAIAgentTarget(TypedDict, total=False): - """Represents a target specifying an Azure AI agent. - - :ivar type: The type of target, always ``azure_ai_agent``. Required. Default value is - "azure_ai_agent". - :vartype type: str - :ivar name: The unique identifier of the Azure AI agent. Required. - :vartype name: str - :ivar version: The version of the Azure AI agent. - :vartype version: str - :ivar tool_descriptions: The parameters used to control the sampling behavior of the agent - during text generation. - :vartype tool_descriptions: list[~azure.ai.projects.types.ToolDescription] - """ - - type: Required[Literal["azure_ai_agent"]] - """The type of target, always ``azure_ai_agent``. Required. Default value is \"azure_ai_agent\".""" - name: Required[str] - """The unique identifier of the Azure AI agent. Required.""" - version: str - """The version of the Azure AI agent.""" - tool_descriptions: list["ToolDescription"] - """The parameters used to control the sampling behavior of the agent during text generation.""" - - -class AzureAIModelTarget(TypedDict, total=False): - """Represents a target specifying an Azure AI model for operations requiring model selection. - - :ivar type: The type of target, always ``azure_ai_model``. Required. Default value is - "azure_ai_model". - :vartype type: str - :ivar model: The unique identifier of the Azure AI model. - :vartype model: str - :ivar sampling_params: The parameters used to control the sampling behavior of the model during - text generation. - :vartype sampling_params: ~azure.ai.projects.types.ModelSamplingParams - """ - - type: Required[Literal["azure_ai_model"]] - """The type of target, always ``azure_ai_model``. Required. Default value is \"azure_ai_model\".""" - model: str - """The unique identifier of the Azure AI model.""" - sampling_params: "ModelSamplingParams" - """The parameters used to control the sampling behavior of the model during text generation.""" - - -class AzureAISearchIndex(TypedDict, total=False): - """Azure AI Search Index Definition. - - :ivar id: Asset ID, a unique identifier for the asset. - :vartype id: str - :ivar name: The name of the resource. Required. - :vartype name: str - :ivar version: The version of the resource. Required. - :vartype version: str - :ivar description: The asset description text. - :vartype description: str - :ivar tags: Tag dictionary. Tags can be added, removed, and updated. - :vartype tags: dict[str, str] - :ivar type: Type of index. Required. Azure search. - :vartype type: str or ~azure.ai.projects.models.AZURE_SEARCH - :ivar connection_name: Name of connection to Azure AI Search. Required. - :vartype connection_name: str - :ivar index_name: Name of index in Azure AI Search resource to attach. Required. - :vartype index_name: str - :ivar field_mapping: Field mapping configuration. - :vartype field_mapping: ~azure.ai.projects.types.FieldMapping - """ - - id: str - """Asset ID, a unique identifier for the asset.""" - name: Required[str] - """The name of the resource. Required.""" - version: Required[str] - """The version of the resource. Required.""" - description: str - """The asset description text.""" - tags: dict[str, str] - """Tag dictionary. Tags can be added, removed, and updated.""" - type: Required[Literal[IndexType.AZURE_SEARCH]] - """Type of index. Required. Azure search.""" - connectionName: Required[str] - """Name of connection to Azure AI Search. Required.""" - indexName: Required[str] - """Name of index in Azure AI Search resource to attach. Required.""" - fieldMapping: "FieldMapping" - """Field mapping configuration.""" - - -class AzureAISearchTool(TypedDict, total=False): - """The input definition information for an Azure AI search tool as used to configure an agent. - - :ivar type: The object type, which is always 'azure_ai_search'. Required. AZURE_AI_SEARCH. - :vartype type: str or ~azure.ai.projects.models.AZURE_AI_SEARCH - :ivar azure_ai_search: The azure ai search index resource. Required. - :vartype azure_ai_search: ~azure.ai.projects.types.AzureAISearchToolResource - """ - - type: Required[Literal[ToolType.AZURE_AI_SEARCH]] - """The object type, which is always 'azure_ai_search'. Required. AZURE_AI_SEARCH.""" - azure_ai_search: Required["AzureAISearchToolResource"] - """The azure ai search index resource. Required.""" - - -class AzureAISearchToolResource(TypedDict, total=False): - """A set of index resources used by the ``azure_ai_search`` tool. - - :ivar indexes: The indices attached to this agent. There can be a maximum of 1 index resource - attached to the agent. Required. - :vartype indexes: list[~azure.ai.projects.types.AISearchIndexResource] - """ - - indexes: Required[list["AISearchIndexResource"]] - """The indices attached to this agent. There can be a maximum of 1 index resource attached to the - agent. Required.""" - - -class AzureFunctionBinding(TypedDict, total=False): - """The structure for keeping storage queue name and URI. - - :ivar type: The type of binding, which is always 'storage_queue'. Required. Default value is - "storage_queue". - :vartype type: str - :ivar storage_queue: Storage queue. Required. - :vartype storage_queue: ~azure.ai.projects.types.AzureFunctionStorageQueue - """ - - type: Required[Literal["storage_queue"]] - """The type of binding, which is always 'storage_queue'. Required. Default value is - \"storage_queue\".""" - storage_queue: Required["AzureFunctionStorageQueue"] - """Storage queue. Required.""" - - -class AzureFunctionDefinition(TypedDict, total=False): - """The definition of Azure function. - - :ivar function: The definition of azure function and its parameters. Required. - :vartype function: ~azure.ai.projects.types.AzureFunctionDefinitionFunction - :ivar input_binding: Input storage queue. The queue storage trigger runs a function as messages - are added to it. Required. - :vartype input_binding: ~azure.ai.projects.types.AzureFunctionBinding - :ivar output_binding: Output storage queue. The function writes output to this queue when the - input items are processed. Required. - :vartype output_binding: ~azure.ai.projects.types.AzureFunctionBinding - """ - - function: Required["AzureFunctionDefinitionFunction"] - """The definition of azure function and its parameters. Required.""" - input_binding: Required["AzureFunctionBinding"] - """Input storage queue. The queue storage trigger runs a function as messages are added to it. - Required.""" - output_binding: Required["AzureFunctionBinding"] - """Output storage queue. The function writes output to this queue when the input items are - processed. Required.""" - - -class AzureFunctionDefinitionFunction(TypedDict, total=False): - """AzureFunctionDefinitionFunction. - - :ivar name: The name of the function to be called. Required. - :vartype name: str - :ivar description: A description of what the function does, used by the model to choose when - and how to call the function. - :vartype description: str - :ivar parameters: The parameters the functions accepts, described as a JSON Schema object. - Required. - :vartype parameters: dict[str, any] - """ - - name: Required[str] - """The name of the function to be called. Required.""" - description: str - """A description of what the function does, used by the model to choose when and how to call the - function.""" - parameters: Required[dict[str, Any]] - """The parameters the functions accepts, described as a JSON Schema object. Required.""" - - -class AzureFunctionStorageQueue(TypedDict, total=False): - """The structure for keeping storage queue name and URI. - - :ivar queue_service_endpoint: URI to the Azure Storage Queue service allowing you to manipulate - a queue. Required. - :vartype queue_service_endpoint: str - :ivar queue_name: The name of an Azure function storage queue. Required. - :vartype queue_name: str - """ - - queue_service_endpoint: Required[str] - """URI to the Azure Storage Queue service allowing you to manipulate a queue. Required.""" - queue_name: Required[str] - """The name of an Azure function storage queue. Required.""" - - -class AzureFunctionTool(TypedDict, total=False): - """The input definition information for an Azure Function Tool, as used to configure an Agent. - - :ivar type: The object type, which is always 'browser_automation'. Required. AZURE_FUNCTION. - :vartype type: str or ~azure.ai.projects.models.AZURE_FUNCTION - :ivar azure_function: The Azure Function Tool definition. Required. - :vartype azure_function: ~azure.ai.projects.types.AzureFunctionDefinition - """ - - type: Required[Literal[ToolType.AZURE_FUNCTION]] - """The object type, which is always 'browser_automation'. Required. AZURE_FUNCTION.""" - azure_function: Required["AzureFunctionDefinition"] - """The Azure Function Tool definition. Required.""" - - -class AzureOpenAIModelConfiguration(TypedDict, total=False): - """Azure OpenAI model configuration. The API version would be selected by the service for querying - the model. - - :ivar type: Required. Default value is "AzureOpenAIModel". - :vartype type: str - :ivar model_deployment_name: Deployment name for AOAI model. Example: gpt-4o if in AIServices - or connection based ``connection_name/deployment_name`` (e.g. ``my-aoai-connection/gpt-4o``). - Required. - :vartype model_deployment_name: str - """ - - type: Required[Literal["AzureOpenAIModel"]] - """Required. Default value is \"AzureOpenAIModel\".""" - modelDeploymentName: Required[str] - """Deployment name for AOAI model. Example: gpt-4o if in AIServices or connection based - ``connection_name/deployment_name`` (e.g. ``my-aoai-connection/gpt-4o``). Required.""" - - -class BingCustomSearchConfiguration(TypedDict, total=False): - """A bing custom search configuration. - - :ivar project_connection_id: Project connection id for grounding with bing search. Required. - :vartype project_connection_id: str - :ivar instance_name: Name of the custom configuration instance given to config. Required. - :vartype instance_name: str - :ivar market: The market where the results come from. - :vartype market: str - :ivar set_lang: The language to use for user interface strings when calling Bing API. - :vartype set_lang: str - :ivar count: The number of search results to return in the bing api response. - :vartype count: int - :ivar freshness: Filter search results by a specific time range. See `accepted values here - `_. - :vartype freshness: str - """ - - project_connection_id: Required[str] - """Project connection id for grounding with bing search. Required.""" - instance_name: Required[str] - """Name of the custom configuration instance given to config. Required.""" - market: str - """The market where the results come from.""" - set_lang: str - """The language to use for user interface strings when calling Bing API.""" - count: int - """The number of search results to return in the bing api response.""" - freshness: str - """Filter search results by a specific time range. See `accepted values here - `_.""" - - -class BingCustomSearchPreviewTool(TypedDict, total=False): - """The input definition information for a Bing custom search tool as used to configure an agent. - - :ivar type: The object type, which is always 'bing_custom_search_preview'. Required. - BING_CUSTOM_SEARCH_PREVIEW. - :vartype type: str or ~azure.ai.projects.models.BING_CUSTOM_SEARCH_PREVIEW - :ivar bing_custom_search_preview: The bing custom search tool parameters. Required. - :vartype bing_custom_search_preview: ~azure.ai.projects.types.BingCustomSearchToolParameters - """ - - type: Required[Literal[ToolType.BING_CUSTOM_SEARCH_PREVIEW]] - """The object type, which is always 'bing_custom_search_preview'. Required. - BING_CUSTOM_SEARCH_PREVIEW.""" - bing_custom_search_preview: Required["BingCustomSearchToolParameters"] - """The bing custom search tool parameters. Required.""" - - -class BingCustomSearchToolParameters(TypedDict, total=False): - """The bing custom search tool parameters. - - :ivar search_configurations: The project connections attached to this tool. There can be a - maximum of 1 connection resource attached to the tool. Required. - :vartype search_configurations: list[~azure.ai.projects.types.BingCustomSearchConfiguration] - """ - - search_configurations: Required[list["BingCustomSearchConfiguration"]] - """The project connections attached to this tool. There can be a maximum of 1 connection resource - attached to the tool. Required.""" - - -class BingGroundingSearchConfiguration(TypedDict, total=False): - """Search configuration for Bing Grounding. - - :ivar project_connection_id: Project connection id for grounding with bing search. Required. - :vartype project_connection_id: str - :ivar market: The market where the results come from. - :vartype market: str - :ivar set_lang: The language to use for user interface strings when calling Bing API. - :vartype set_lang: str - :ivar count: The number of search results to return in the bing api response. - :vartype count: int - :ivar freshness: Filter search results by a specific time range. See `accepted values here - `_. - :vartype freshness: str - """ - - project_connection_id: Required[str] - """Project connection id for grounding with bing search. Required.""" - market: str - """The market where the results come from.""" - set_lang: str - """The language to use for user interface strings when calling Bing API.""" - count: int - """The number of search results to return in the bing api response.""" - freshness: str - """Filter search results by a specific time range. See `accepted values here - `_.""" - - -class BingGroundingSearchToolParameters(TypedDict, total=False): - """The bing grounding search tool parameters. - - :ivar search_configurations: The search configurations attached to this tool. There can be a - maximum of 1 search configuration resource attached to the tool. Required. - :vartype search_configurations: list[~azure.ai.projects.types.BingGroundingSearchConfiguration] - """ - - search_configurations: Required[list["BingGroundingSearchConfiguration"]] - """The search configurations attached to this tool. There can be a maximum of 1 search - configuration resource attached to the tool. Required.""" - - -class BingGroundingTool(TypedDict, total=False): - """The input definition information for a bing grounding search tool as used to configure an - agent. - - :ivar type: The object type, which is always 'bing_grounding'. Required. BING_GROUNDING. - :vartype type: str or ~azure.ai.projects.models.BING_GROUNDING - :ivar bing_grounding: The bing grounding search tool parameters. Required. - :vartype bing_grounding: ~azure.ai.projects.types.BingGroundingSearchToolParameters - """ - - type: Required[Literal[ToolType.BING_GROUNDING]] - """The object type, which is always 'bing_grounding'. Required. BING_GROUNDING.""" - bing_grounding: Required["BingGroundingSearchToolParameters"] - """The bing grounding search tool parameters. Required.""" - - -class BlobReference(TypedDict, total=False): - """Blob reference details. - - :ivar blob_uri: Blob URI path for client to upload data. Example: - ``https://blob.windows.core.net/Container/Path``. Required. - :vartype blob_uri: str - :ivar storage_account_arm_id: ARM ID of the storage account to use. Required. - :vartype storage_account_arm_id: str - :ivar credential: Credential info to access the storage account. Required. - :vartype credential: ~azure.ai.projects.types.BlobReferenceSasCredential - """ - - blobUri: Required[str] - """Blob URI path for client to upload data. Example: - ``https://blob.windows.core.net/Container/Path``. Required.""" - storageAccountArmId: Required[str] - """ARM ID of the storage account to use. Required.""" - credential: Required["BlobReferenceSasCredential"] - """Credential info to access the storage account. Required.""" - - -class BlobReferenceSasCredential(TypedDict, total=False): - """SAS Credential definition. - - :ivar sas_uri: SAS uri. Required. - :vartype sas_uri: str - :ivar type: Type of credential. Required. Default value is "SAS". - :vartype type: str - """ - - sasUri: Required[str] - """SAS uri. Required.""" - type: Required[Literal["SAS"]] - """Type of credential. Required. Default value is \"SAS\".""" - - -class BrowserAutomationPreviewTool(TypedDict, total=False): - """The input definition information for a Browser Automation Tool, as used to configure an Agent. - - :ivar type: The object type, which is always 'browser_automation_preview'. Required. - BROWSER_AUTOMATION_PREVIEW. - :vartype type: str or ~azure.ai.projects.models.BROWSER_AUTOMATION_PREVIEW - :ivar browser_automation_preview: The Browser Automation Tool parameters. Required. - :vartype browser_automation_preview: ~azure.ai.projects.types.BrowserAutomationToolParameters - """ - - type: Required[Literal[ToolType.BROWSER_AUTOMATION_PREVIEW]] - """The object type, which is always 'browser_automation_preview'. Required. - BROWSER_AUTOMATION_PREVIEW.""" - browser_automation_preview: Required["BrowserAutomationToolParameters"] - """The Browser Automation Tool parameters. Required.""" - - -class BrowserAutomationToolConnectionParameters(TypedDict, total=False): # pylint: disable=name-too-long - """Definition of input parameters for the connection used by the Browser Automation Tool. - - :ivar project_connection_id: The ID of the project connection to your Azure Playwright - resource. Required. - :vartype project_connection_id: str - """ - - project_connection_id: Required[str] - """The ID of the project connection to your Azure Playwright resource. Required.""" - - -class BrowserAutomationToolParameters(TypedDict, total=False): - """Definition of input parameters for the Browser Automation Tool. - - :ivar connection: The project connection parameters associated with the Browser Automation - Tool. Required. - :vartype connection: ~azure.ai.projects.types.BrowserAutomationToolConnectionParameters - """ - - connection: Required["BrowserAutomationToolConnectionParameters"] - """The project connection parameters associated with the Browser Automation Tool. Required.""" - - -class CaptureStructuredOutputsTool(TypedDict, total=False): - """A tool for capturing structured outputs. - - :ivar type: The type of the tool. Always ``capture_structured_outputs``. Required. - CAPTURE_STRUCTURED_OUTPUTS. - :vartype type: str or ~azure.ai.projects.models.CAPTURE_STRUCTURED_OUTPUTS - :ivar outputs: The structured outputs to capture from the model. Required. - :vartype outputs: ~azure.ai.projects.types.StructuredOutputDefinition - """ - - type: Required[Literal[ToolType.CAPTURE_STRUCTURED_OUTPUTS]] - """The type of the tool. Always ``capture_structured_outputs``. Required. - CAPTURE_STRUCTURED_OUTPUTS.""" - outputs: Required["StructuredOutputDefinition"] - """The structured outputs to capture from the model. Required.""" - - -class ChartCoordinate(TypedDict, total=False): - """Coordinates for the analysis chart. - - :ivar x: X-axis coordinate. Required. - :vartype x: int - :ivar y: Y-axis coordinate. Required. - :vartype y: int - :ivar size: Size of the chart element. Required. - :vartype size: int - """ - - x: Required[int] - """X-axis coordinate. Required.""" - y: Required[int] - """Y-axis coordinate. Required.""" - size: Required[int] - """Size of the chart element. Required.""" - - -class ChatSummaryMemoryItem(TypedDict, total=False): - """A memory item containing a summary extracted from conversations. - - :ivar memory_id: The unique ID of the memory item. Required. - :vartype memory_id: str - :ivar updated_at: The last update time of the memory item. Required. - :vartype updated_at: ~datetime.datetime - :ivar scope: The namespace that logically groups and isolates memories, such as a user ID. - Required. - :vartype scope: str - :ivar content: The content of the memory. Required. - :vartype content: str - :ivar kind: The kind of the memory item. Required. Summary of chat conversations. - :vartype kind: str or ~azure.ai.projects.models.CHAT_SUMMARY - """ - - memory_id: Required[str] - """The unique ID of the memory item. Required.""" - updated_at: Required[int] - """The last update time of the memory item. Required.""" - scope: Required[str] - """The namespace that logically groups and isolates memories, such as a user ID. Required.""" - content: Required[str] - """The content of the memory. Required.""" - kind: Required[Literal[MemoryItemKind.CHAT_SUMMARY]] - """The kind of the memory item. Required. Summary of chat conversations.""" - - -class ClusterInsightResult(TypedDict, total=False): - """Insights from the cluster analysis. - - :ivar summary: Summary of the insights report. Required. - :vartype summary: ~azure.ai.projects.types.InsightSummary - :ivar clusters: List of clusters identified in the insights. Required. - :vartype clusters: list[~azure.ai.projects.types.InsightCluster] - :ivar coordinates: Optional mapping of IDs to 2D coordinates used by the UX for - visualization. - - The map keys are string identifiers (for example, a cluster id or a sample id) - and the values are the coordinates and visual size for rendering on a 2D chart. - - This property is omitted unless the client requests coordinates (for example, - by passing ``includeCoordinates=true`` as a query parameter). - - Example: - - .. code-block:: - - { - "cluster-1": { "x": 12, "y": 34, "size": 8 }, - "sample-123": { "x": 18, "y": 22, "size": 4 } - } - - Coordinates are intended only for client-side visualization and do not - modify the canonical insights results. - :vartype coordinates: dict[str, ~azure.ai.projects.types.ChartCoordinate] - """ - - summary: Required["InsightSummary"] - """Summary of the insights report. Required.""" - clusters: Required[list["InsightCluster"]] - """List of clusters identified in the insights. Required.""" - coordinates: dict[str, "ChartCoordinate"] - """ Optional mapping of IDs to 2D coordinates used by the UX for visualization. - - The map keys are string identifiers (for example, a cluster id or a sample id) - and the values are the coordinates and visual size for rendering on a 2D chart. - - This property is omitted unless the client requests coordinates (for example, - by passing ``includeCoordinates=true`` as a query parameter). - - Example: - - .. code-block:: - - { - \"cluster-1\": { \"x\": 12, \"y\": 34, \"size\": 8 }, - \"sample-123\": { \"x\": 18, \"y\": 22, \"size\": 4 } - } - - Coordinates are intended only for client-side visualization and do not - modify the canonical insights results.""" - - -class ClusterTokenUsage(TypedDict, total=False): - """Token usage for cluster analysis. - - :ivar input_token_usage: input token usage. Required. - :vartype input_token_usage: int - :ivar output_token_usage: output token usage. Required. - :vartype output_token_usage: int - :ivar total_token_usage: total token usage. Required. - :vartype total_token_usage: int - """ - - inputTokenUsage: Required[int] - """input token usage. Required.""" - outputTokenUsage: Required[int] - """output token usage. Required.""" - totalTokenUsage: Required[int] - """total token usage. Required.""" - - -class CodeBasedEvaluatorDefinition(TypedDict, total=False): - """Code-based evaluator definition using python code. - - :ivar init_parameters: The JSON schema (Draft 2020-12) for the evaluator's input parameters. - This includes parameters like type, properties, required. - :vartype init_parameters: dict[str, any] - :ivar data_schema: The JSON schema (Draft 2020-12) for the evaluator's input data. This - includes parameters like type, properties, required. - :vartype data_schema: dict[str, any] - :ivar metrics: List of output metrics produced by this evaluator. - :vartype metrics: dict[str, ~azure.ai.projects.types.EvaluatorMetric] - :ivar type: Required. Code-based definition. - :vartype type: str or ~azure.ai.projects.models.CODE - :ivar code_text: Inline code text for the evaluator. Required. - :vartype code_text: str - """ - - init_parameters: dict[str, Any] - """The JSON schema (Draft 2020-12) for the evaluator's input parameters. This includes parameters - like type, properties, required.""" - data_schema: dict[str, Any] - """The JSON schema (Draft 2020-12) for the evaluator's input data. This includes parameters like - type, properties, required.""" - metrics: dict[str, "EvaluatorMetric"] - """List of output metrics produced by this evaluator.""" - type: Required[Literal[EvaluatorDefinitionType.CODE]] - """Required. Code-based definition.""" - code_text: Required[str] - """Inline code text for the evaluator. Required.""" - - -class CodeInterpreterTool(TypedDict, total=False): - """Code interpreter. - - :ivar type: The type of the code interpreter tool. Always ``code_interpreter``. Required. - CODE_INTERPRETER. - :vartype type: str or ~azure.ai.projects.models.CODE_INTERPRETER - :ivar container: The code interpreter container. Can be a container ID or an object that - specifies uploaded file IDs to make available to your code, along with an optional - ``memory_limit`` setting. If not provided, the service assumes auto. Is either a str type or a - AutoCodeInterpreterToolParam type. - :vartype container: str or ~azure.ai.projects.types.AutoCodeInterpreterToolParam - """ - - type: Required[Literal[ToolType.CODE_INTERPRETER]] - """The type of the code interpreter tool. Always ``code_interpreter``. Required. CODE_INTERPRETER.""" - container: Union[str, "AutoCodeInterpreterToolParam"] - """The code interpreter container. Can be a container ID or an object that specifies uploaded file - IDs to make available to your code, along with an optional ``memory_limit`` setting. If not - provided, the service assumes auto. Is either a str type or a AutoCodeInterpreterToolParam - type.""" - - -class ComparisonFilter(TypedDict, total=False): - """Comparison Filter. - - :ivar type: Specifies the comparison operator: ``eq``, ``ne``, ``gt``, ``gte``, ``lt``, - ``lte``, ``in``, ``nin``. - - * `eq`: equals - * `ne`: not equal - * `gt`: greater than - * `gte`: greater than or equal - * `lt`: less than - * `lte`: less than or equal - * `in`: in - * `nin`: not in. Required. Is one of the following types: Literal["eq"], Literal["ne"], - Literal["gt"], Literal["gte"], Literal["lt"], Literal["lte"] - :vartype type: str or str or str or str or str or str - :ivar key: The key to compare against the value. Required. - :vartype key: str - :ivar value: The value to compare against the attribute key; supports string, number, or - boolean types. Required. Is one of the following types: str, float, bool, [Union[str, float]] - :vartype value: str or float or bool or list[str or float] - """ - - type: Required[Literal["eq", "ne", "gt", "gte", "lt", "lte"]] - """Specifies the comparison operator: ``eq``, ``ne``, ``gt``, ``gte``, ``lt``, ``lte``, ``in``, - ``nin``. - - * `eq`: equals - * `ne`: not equal - * `gt`: greater than - * `gte`: greater than or equal - * `lt`: less than - * `lte`: less than or equal - * `in`: in - * `nin`: not in. Required. Is one of the following types: Literal[\"eq\"], - Literal[\"ne\"], Literal[\"gt\"], Literal[\"gte\"], Literal[\"lt\"], Literal[\"lte\"]""" - key: Required[str] - """The key to compare against the value. Required.""" - value: Required[Union[str, float, bool, list[Union[str, float]]]] - """The value to compare against the attribute key; supports string, number, or boolean types. - Required. Is one of the following types: str, float, bool, [Union[str, float]]""" - - -class CompoundFilter(TypedDict, total=False): - """Compound Filter. - - :ivar type: Type of operation: ``and`` or ``or``. Required. Is either a Literal["and"] type or - a Literal["or"] type. - :vartype type: str or str - :ivar filters: Array of filters to combine. Items can be ``ComparisonFilter`` or - ``CompoundFilter``. Required. - :vartype filters: list[~azure.ai.projects.types.ComparisonFilter or any] - """ - - type: Required[Literal["and", "or"]] - """Type of operation: ``and`` or ``or``. Required. Is either a Literal[\"and\"] type or a - Literal[\"or\"] type.""" - filters: Required[list[Union["ComparisonFilter", Any]]] - """Array of filters to combine. Items can be ``ComparisonFilter`` or ``CompoundFilter``. Required.""" - - -class ComputerUsePreviewTool(TypedDict, total=False): - """Computer use preview. - - :ivar type: The type of the computer use tool. Always ``computer_use_preview``. Required. - COMPUTER_USE_PREVIEW. - :vartype type: str or ~azure.ai.projects.models.COMPUTER_USE_PREVIEW - :ivar environment: The type of computer environment to control. Required. Known values are: - "windows", "mac", "linux", "ubuntu", and "browser". - :vartype environment: str or ~azure.ai.projects.models.ComputerEnvironment - :ivar display_width: The width of the computer display. Required. - :vartype display_width: int - :ivar display_height: The height of the computer display. Required. - :vartype display_height: int - """ - - type: Required[Literal[ToolType.COMPUTER_USE_PREVIEW]] - """The type of the computer use tool. Always ``computer_use_preview``. Required. - COMPUTER_USE_PREVIEW.""" - environment: Required[ComputerEnvironment] - """The type of computer environment to control. Required. Known values are: \"windows\", \"mac\", - \"linux\", \"ubuntu\", and \"browser\".""" - display_width: Required[int] - """The width of the computer display. Required.""" - display_height: Required[int] - """The height of the computer display. Required.""" - - -class Connection(TypedDict, total=False): - """Response from the list and get connections operations. - - :ivar name: The friendly name of the connection, provided by the user. Required. - :vartype name: str - :ivar id: A unique identifier for the connection, generated by the service. Required. - :vartype id: str - :ivar type: Category of the connection. Required. Known values are: "AzureOpenAI", "AzureBlob", - "AzureStorageAccount", "CognitiveSearch", "CosmosDB", "ApiKey", "AppConfig", "AppInsights", - "CustomKeys", and "RemoteTool_Preview". - :vartype type: str or ~azure.ai.projects.models.ConnectionType - :ivar target: The connection URL to be used for this service. Required. - :vartype target: str - :ivar is_default: Whether the connection is tagged as the default connection of its type. - Required. - :vartype is_default: bool - :ivar credentials: The credentials used by the connection. Required. - :vartype credentials: ~azure.ai.projects.types.BaseCredentials - :ivar metadata: Metadata of the connection. Required. - :vartype metadata: dict[str, str] - """ - - name: Required[str] - """The friendly name of the connection, provided by the user. Required.""" - id: Required[str] - """A unique identifier for the connection, generated by the service. Required.""" - type: Required[ConnectionType] - """Category of the connection. Required. Known values are: \"AzureOpenAI\", \"AzureBlob\", - \"AzureStorageAccount\", \"CognitiveSearch\", \"CosmosDB\", \"ApiKey\", \"AppConfig\", - \"AppInsights\", \"CustomKeys\", and \"RemoteTool_Preview\".""" - target: Required[str] - """The connection URL to be used for this service. Required.""" - isDefault: Required[bool] - """Whether the connection is tagged as the default connection of its type. Required.""" - credentials: Required["BaseCredentials"] - """The credentials used by the connection. Required.""" - metadata: Required[dict[str, str]] - """Metadata of the connection. Required.""" - - -class ContainerAutoParam(TypedDict, total=False): - """ContainerAutoParam. - - :ivar type: Automatically creates a container for this request. Required. CONTAINER_AUTO. - :vartype type: str or ~azure.ai.projects.models.CONTAINER_AUTO - :ivar file_ids: An optional list of uploaded files to make available to your code. - :vartype file_ids: list[str] - :ivar memory_limit: Known values are: "1g", "4g", "16g", and "64g". - :vartype memory_limit: str or ~azure.ai.projects.models.ContainerMemoryLimit - :ivar skills: An optional list of skills referenced by id or inline data. - :vartype skills: list[~azure.ai.projects.types.ContainerSkill] - :ivar network_policy: - :vartype network_policy: ~azure.ai.projects.types.ContainerNetworkPolicyParam - """ - - type: Required[Literal[FunctionShellToolParamEnvironmentType.CONTAINER_AUTO]] - """Automatically creates a container for this request. Required. CONTAINER_AUTO.""" - file_ids: list[str] - """An optional list of uploaded files to make available to your code.""" - memory_limit: Optional[ContainerMemoryLimit] - """Known values are: \"1g\", \"4g\", \"16g\", and \"64g\".""" - skills: list["ContainerSkill"] - """An optional list of skills referenced by id or inline data.""" - network_policy: "ContainerNetworkPolicyParam" - - -class ContainerNetworkPolicyAllowlistParam(TypedDict, total=False): - """ContainerNetworkPolicyAllowlistParam. - - :ivar type: Allow outbound network access only to specified domains. Always ``allowlist``. - Required. ALLOWLIST. - :vartype type: str or ~azure.ai.projects.models.ALLOWLIST - :ivar allowed_domains: A list of allowed domains when type is ``allowlist``. Required. - :vartype allowed_domains: list[str] - :ivar domain_secrets: Optional domain-scoped secrets for allowlisted domains. - :vartype domain_secrets: list[~azure.ai.projects.types.ContainerNetworkPolicyDomainSecretParam] - """ - - type: Required[Literal[ContainerNetworkPolicyParamType.ALLOWLIST]] - """Allow outbound network access only to specified domains. Always ``allowlist``. Required. - ALLOWLIST.""" - allowed_domains: Required[list[str]] - """A list of allowed domains when type is ``allowlist``. Required.""" - domain_secrets: list["ContainerNetworkPolicyDomainSecretParam"] - """Optional domain-scoped secrets for allowlisted domains.""" - - -class ContainerNetworkPolicyDisabledParam(TypedDict, total=False): - """ContainerNetworkPolicyDisabledParam. - - :ivar type: Disable outbound network access. Always ``disabled``. Required. DISABLED. - :vartype type: str or ~azure.ai.projects.models.DISABLED - """ - - type: Required[Literal[ContainerNetworkPolicyParamType.DISABLED]] - """Disable outbound network access. Always ``disabled``. Required. DISABLED.""" - - -class ContainerNetworkPolicyDomainSecretParam(TypedDict, total=False): - """ContainerNetworkPolicyDomainSecretParam. - - :ivar domain: The domain associated with the secret. Required. - :vartype domain: str - :ivar name: The name of the secret to inject for the domain. Required. - :vartype name: str - :ivar value: The secret value to inject for the domain. Required. - :vartype value: str - """ - - domain: Required[str] - """The domain associated with the secret. Required.""" - name: Required[str] - """The name of the secret to inject for the domain. Required.""" - value: Required[str] - """The secret value to inject for the domain. Required.""" - - -class ContinuousEvaluationRuleAction(TypedDict, total=False): - """Evaluation rule action for continuous evaluation. - - :ivar type: Required. Continuous evaluation. - :vartype type: str or ~azure.ai.projects.models.CONTINUOUS_EVALUATION - :ivar eval_id: Eval Id to add continuous evaluation runs to. Required. - :vartype eval_id: str - :ivar max_hourly_runs: Maximum number of evaluation runs allowed per hour. - :vartype max_hourly_runs: int - """ - - type: Required[Literal[EvaluationRuleActionType.CONTINUOUS_EVALUATION]] - """Required. Continuous evaluation.""" - evalId: Required[str] - """Eval Id to add continuous evaluation runs to. Required.""" - maxHourlyRuns: int - """Maximum number of evaluation runs allowed per hour.""" - - -class CosmosDBIndex(TypedDict, total=False): - """CosmosDB Vector Store Index Definition. - - :ivar id: Asset ID, a unique identifier for the asset. - :vartype id: str - :ivar name: The name of the resource. Required. - :vartype name: str - :ivar version: The version of the resource. Required. - :vartype version: str - :ivar description: The asset description text. - :vartype description: str - :ivar tags: Tag dictionary. Tags can be added, removed, and updated. - :vartype tags: dict[str, str] - :ivar type: Type of index. Required. CosmosDB. - :vartype type: str or ~azure.ai.projects.models.COSMOS_DB - :ivar connection_name: Name of connection to CosmosDB. Required. - :vartype connection_name: str - :ivar database_name: Name of the CosmosDB Database. Required. - :vartype database_name: str - :ivar container_name: Name of CosmosDB Container. Required. - :vartype container_name: str - :ivar embedding_configuration: Embedding model configuration. Required. - :vartype embedding_configuration: ~azure.ai.projects.types.EmbeddingConfiguration - :ivar field_mapping: Field mapping configuration. Required. - :vartype field_mapping: ~azure.ai.projects.types.FieldMapping - """ - - id: str - """Asset ID, a unique identifier for the asset.""" - name: Required[str] - """The name of the resource. Required.""" - version: Required[str] - """The version of the resource. Required.""" - description: str - """The asset description text.""" - tags: dict[str, str] - """Tag dictionary. Tags can be added, removed, and updated.""" - type: Required[Literal[IndexType.COSMOS_DB]] - """Type of index. Required. CosmosDB.""" - connectionName: Required[str] - """Name of connection to CosmosDB. Required.""" - databaseName: Required[str] - """Name of the CosmosDB Database. Required.""" - containerName: Required[str] - """Name of CosmosDB Container. Required.""" - embeddingConfiguration: Required["EmbeddingConfiguration"] - """Embedding model configuration. Required.""" - fieldMapping: Required["FieldMapping"] - """Field mapping configuration. Required.""" - - -class CronTrigger(TypedDict, total=False): - """Cron based trigger. - - :ivar type: Required. Cron based trigger. - :vartype type: str or ~azure.ai.projects.models.CRON - :ivar expression: Cron expression that defines the schedule frequency. Required. - :vartype expression: str - :ivar time_zone: Time zone for the cron schedule. - :vartype time_zone: str - :ivar start_time: Start time for the cron schedule in ISO 8601 format. - :vartype start_time: ~datetime.datetime - :ivar end_time: End time for the cron schedule in ISO 8601 format. - :vartype end_time: ~datetime.datetime - """ - - type: Required[Literal[TriggerType.CRON]] - """Required. Cron based trigger.""" - expression: Required[str] - """Cron expression that defines the schedule frequency. Required.""" - timeZone: str - """Time zone for the cron schedule.""" - startTime: str - """Start time for the cron schedule in ISO 8601 format.""" - endTime: str - """End time for the cron schedule in ISO 8601 format.""" - - -class CustomCredential(TypedDict, total=False): - """Custom credential definition. - - :ivar type: The credential type. Required. Custom credential. - :vartype type: str or ~azure.ai.projects.models.CUSTOM - """ - - type: Required[Literal[CredentialType.CUSTOM]] - """The credential type. Required. Custom credential.""" - - -class CustomGrammarFormatParam(TypedDict, total=False): - """Grammar format. - - :ivar type: Grammar format. Always ``grammar``. Required. GRAMMAR. - :vartype type: str or ~azure.ai.projects.models.GRAMMAR - :ivar syntax: The syntax of the grammar definition. One of ``lark`` or ``regex``. Required. - Known values are: "lark" and "regex". - :vartype syntax: str or ~azure.ai.projects.models.GrammarSyntax1 - :ivar definition: The grammar definition. Required. - :vartype definition: str - """ - - type: Required[Literal[CustomToolParamFormatType.GRAMMAR]] - """Grammar format. Always ``grammar``. Required. GRAMMAR.""" - syntax: Required[GrammarSyntax1] - """The syntax of the grammar definition. One of ``lark`` or ``regex``. Required. Known values are: - \"lark\" and \"regex\".""" - definition: Required[str] - """The grammar definition. Required.""" - - -class CustomTextFormatParam(TypedDict, total=False): - """Text format. - - :ivar type: Unconstrained text format. Always ``text``. Required. TEXT. - :vartype type: str or ~azure.ai.projects.models.TEXT - """ - - type: Required[Literal[CustomToolParamFormatType.TEXT]] - """Unconstrained text format. Always ``text``. Required. TEXT.""" - - -class CustomToolParam(TypedDict, total=False): - """Custom tool. - - :ivar type: The type of the custom tool. Always ``custom``. Required. CUSTOM. - :vartype type: str or ~azure.ai.projects.models.CUSTOM - :ivar name: The name of the custom tool, used to identify it in tool calls. Required. - :vartype name: str - :ivar description: Optional description of the custom tool, used to provide more context. - :vartype description: str - :ivar format: The input format for the custom tool. Default is unconstrained text. - :vartype format: ~azure.ai.projects.types.CustomToolParamFormat - """ - - type: Required[Literal[ToolType.CUSTOM]] - """The type of the custom tool. Always ``custom``. Required. CUSTOM.""" - name: Required[str] - """The name of the custom tool, used to identify it in tool calls. Required.""" - description: str - """Optional description of the custom tool, used to provide more context.""" - format: "CustomToolParamFormat" - """The input format for the custom tool. Default is unconstrained text.""" - - -class DailyRecurrenceSchedule(TypedDict, total=False): - """Daily recurrence schedule. - - :ivar type: Daily recurrence type. Required. Daily recurrence pattern. - :vartype type: str or ~azure.ai.projects.models.DAILY - :ivar hours: Hours for the recurrence schedule. Required. - :vartype hours: list[int] - """ - - type: Required[Literal[RecurrenceType.DAILY]] - """Daily recurrence type. Required. Daily recurrence pattern.""" - hours: Required[list[int]] - """Hours for the recurrence schedule. Required.""" - - -class DatasetCredential(TypedDict, total=False): - """Represents a reference to a blob for consumption. - - :ivar blob_reference: Credential info to access the storage account. Required. - :vartype blob_reference: ~azure.ai.projects.types.BlobReference - """ - - blobReference: Required["BlobReference"] - """Credential info to access the storage account. Required.""" - - -class DeleteAgentResponse(TypedDict, total=False): - """A deleted agent Object. - - :ivar object: The object type. Always 'agent.deleted'. Required. AGENT_DELETED. - :vartype object: str or ~azure.ai.projects.models.AGENT_DELETED - :ivar name: The name of the agent. Required. - :vartype name: str - :ivar deleted: Whether the agent was successfully deleted. Required. - :vartype deleted: bool - """ - - object: Required[Literal[AgentObjectType.AGENT_DELETED]] - """The object type. Always 'agent.deleted'. Required. AGENT_DELETED.""" - name: Required[str] - """The name of the agent. Required.""" - deleted: Required[bool] - """Whether the agent was successfully deleted. Required.""" - - -class DeleteAgentVersionResponse(TypedDict, total=False): - """A deleted agent version Object. - - :ivar object: The object type. Always 'agent.version.deleted'. Required. AGENT_VERSION_DELETED. - :vartype object: str or ~azure.ai.projects.models.AGENT_VERSION_DELETED - :ivar name: The name of the agent. Required. - :vartype name: str - :ivar version: The version identifier of the agent. Required. - :vartype version: str - :ivar deleted: Whether the agent was successfully deleted. Required. - :vartype deleted: bool - """ - - object: Required[Literal[AgentObjectType.AGENT_VERSION_DELETED]] - """The object type. Always 'agent.version.deleted'. Required. AGENT_VERSION_DELETED.""" - name: Required[str] - """The name of the agent. Required.""" - version: Required[str] - """The version identifier of the agent. Required.""" - deleted: Required[bool] - """Whether the agent was successfully deleted. Required.""" - - -class DeleteMemoryStoreResult(TypedDict, total=False): - """DeleteMemoryStoreResult. - - :ivar object: The object type. Always 'memory_store.deleted'. Required. MEMORY_STORE_DELETED. - :vartype object: str or ~azure.ai.projects.models.MEMORY_STORE_DELETED - :ivar name: The name of the memory store. Required. - :vartype name: str - :ivar deleted: Whether the memory store was successfully deleted. Required. - :vartype deleted: bool - """ - - object: Required[Literal[MemoryStoreObjectType.MEMORY_STORE_DELETED]] - """The object type. Always 'memory_store.deleted'. Required. MEMORY_STORE_DELETED.""" - name: Required[str] - """The name of the memory store. Required.""" - deleted: Required[bool] - """Whether the memory store was successfully deleted. Required.""" - - -class EmbeddingConfiguration(TypedDict, total=False): - """Embedding configuration class. - - :ivar model_deployment_name: Deployment name of embedding model. It can point to a model - deployment either in the parent AIServices or a connection. Required. - :vartype model_deployment_name: str - :ivar embedding_field: Embedding field. Required. - :vartype embedding_field: str - """ - - modelDeploymentName: Required[str] - """Deployment name of embedding model. It can point to a model deployment either in the parent - AIServices or a connection. Required.""" - embeddingField: Required[str] - """Embedding field. Required.""" - - -class EntraIDCredentials(TypedDict, total=False): - """Entra ID credential definition. - - :ivar type: The credential type. Required. Entra ID credential (formerly known as AAD). - :vartype type: str or ~azure.ai.projects.models.ENTRA_ID - """ - - type: Required[Literal[CredentialType.ENTRA_ID]] - """The credential type. Required. Entra ID credential (formerly known as AAD).""" - - -class EvalResult(TypedDict, total=False): - """Result of the evaluation. - - :ivar name: name of the check. Required. - :vartype name: str - :ivar type: type of the check. Required. - :vartype type: str - :ivar score: score. Required. - :vartype score: float - :ivar passed: indicates if the check passed or failed. Required. - :vartype passed: bool - """ - - name: Required[str] - """name of the check. Required.""" - type: Required[str] - """type of the check. Required.""" - score: Required[float] - """score. Required.""" - passed: Required[bool] - """indicates if the check passed or failed. Required.""" - - -class EvalRunResultCompareItem(TypedDict, total=False): - """Metric comparison for a treatment against the baseline. - - :ivar treatment_run_id: The treatment run ID. Required. - :vartype treatment_run_id: str - :ivar treatment_run_summary: Summary statistics of the treatment run. Required. - :vartype treatment_run_summary: ~azure.ai.projects.types.EvalRunResultSummary - :ivar delta_estimate: Estimated difference between treatment and baseline. Required. - :vartype delta_estimate: float - :ivar p_value: P-value for the treatment effect. Required. - :vartype p_value: float - :ivar treatment_effect: Type of treatment effect. Required. Known values are: "TooFewSamples", - "Inconclusive", "Changed", "Improved", and "Degraded". - :vartype treatment_effect: str or ~azure.ai.projects.models.TreatmentEffectType - """ - - treatmentRunId: Required[str] - """The treatment run ID. Required.""" - treatmentRunSummary: Required["EvalRunResultSummary"] - """Summary statistics of the treatment run. Required.""" - deltaEstimate: Required[float] - """Estimated difference between treatment and baseline. Required.""" - pValue: Required[float] - """P-value for the treatment effect. Required.""" - treatmentEffect: Required[TreatmentEffectType] - """Type of treatment effect. Required. Known values are: \"TooFewSamples\", \"Inconclusive\", - \"Changed\", \"Improved\", and \"Degraded\".""" - - -class EvalRunResultComparison(TypedDict, total=False): - """Comparison results for treatment runs against the baseline. - - :ivar testing_criteria: Name of the testing criteria. Required. - :vartype testing_criteria: str - :ivar metric: Metric being evaluated. Required. - :vartype metric: str - :ivar evaluator: Name of the evaluator for this testing criteria. Required. - :vartype evaluator: str - :ivar baseline_run_summary: Summary statistics of the baseline run. Required. - :vartype baseline_run_summary: ~azure.ai.projects.types.EvalRunResultSummary - :ivar compare_items: List of comparison results for each treatment run. Required. - :vartype compare_items: list[~azure.ai.projects.types.EvalRunResultCompareItem] - """ - - testingCriteria: Required[str] - """Name of the testing criteria. Required.""" - metric: Required[str] - """Metric being evaluated. Required.""" - evaluator: Required[str] - """Name of the evaluator for this testing criteria. Required.""" - baselineRunSummary: Required["EvalRunResultSummary"] - """Summary statistics of the baseline run. Required.""" - compareItems: Required[list["EvalRunResultCompareItem"]] - """List of comparison results for each treatment run. Required.""" - - -class EvalRunResultSummary(TypedDict, total=False): - """Summary statistics of a metric in an evaluation run. - - :ivar run_id: The evaluation run ID. Required. - :vartype run_id: str - :ivar sample_count: Number of samples in the evaluation run. Required. - :vartype sample_count: int - :ivar average: Average value of the metric in the evaluation run. Required. - :vartype average: float - :ivar standard_deviation: Standard deviation of the metric in the evaluation run. Required. - :vartype standard_deviation: float - """ - - runId: Required[str] - """The evaluation run ID. Required.""" - sampleCount: Required[int] - """Number of samples in the evaluation run. Required.""" - average: Required[float] - """Average value of the metric in the evaluation run. Required.""" - standardDeviation: Required[float] - """Standard deviation of the metric in the evaluation run. Required.""" - - -class EvaluationComparisonInsightRequest(TypedDict, total=False): - """Evaluation Comparison Request. - - :ivar type: The type of request. Required. Evaluation Comparison. - :vartype type: str or ~azure.ai.projects.models.EVALUATION_COMPARISON - :ivar eval_id: Identifier for the evaluation. Required. - :vartype eval_id: str - :ivar baseline_run_id: The baseline run ID for comparison. Required. - :vartype baseline_run_id: str - :ivar treatment_run_ids: List of treatment run IDs for comparison. Required. - :vartype treatment_run_ids: list[str] - """ - - type: Required[Literal[InsightType.EVALUATION_COMPARISON]] - """The type of request. Required. Evaluation Comparison.""" - evalId: Required[str] - """Identifier for the evaluation. Required.""" - baselineRunId: Required[str] - """The baseline run ID for comparison. Required.""" - treatmentRunIds: Required[list[str]] - """List of treatment run IDs for comparison. Required.""" - - -class EvaluationComparisonInsightResult(TypedDict, total=False): - """Insights from the evaluation comparison. - - :ivar type: The type of insights result. Required. Evaluation Comparison. - :vartype type: str or ~azure.ai.projects.models.EVALUATION_COMPARISON - :ivar comparisons: Comparison results for each treatment run against the baseline. Required. - :vartype comparisons: list[~azure.ai.projects.types.EvalRunResultComparison] - :ivar method: The statistical method used for comparison. Required. - :vartype method: str - """ - - type: Required[Literal[InsightType.EVALUATION_COMPARISON]] - """The type of insights result. Required. Evaluation Comparison.""" - comparisons: Required[list["EvalRunResultComparison"]] - """Comparison results for each treatment run against the baseline. Required.""" - method: Required[str] - """The statistical method used for comparison. Required.""" - - -class EvaluationResultSample(TypedDict, total=False): - """A sample from the evaluation result. - - :ivar id: The unique identifier for the analysis sample. Required. - :vartype id: str - :ivar features: Features to help with additional filtering of data in UX. Required. - :vartype features: dict[str, any] - :ivar correlation_info: Info about the correlation for the analysis sample. Required. - :vartype correlation_info: dict[str, any] - :ivar type: Evaluation Result Sample Type. Required. A sample from the evaluation result. - :vartype type: str or ~azure.ai.projects.models.EVALUATION_RESULT_SAMPLE - :ivar evaluation_result: Evaluation result for the analysis sample. Required. - :vartype evaluation_result: ~azure.ai.projects.types.EvalResult - """ - - id: Required[str] - """The unique identifier for the analysis sample. Required.""" - features: Required[dict[str, Any]] - """Features to help with additional filtering of data in UX. Required.""" - correlationInfo: Required[dict[str, Any]] - """Info about the correlation for the analysis sample. Required.""" - type: Required[Literal[SampleType.EVALUATION_RESULT_SAMPLE]] - """Evaluation Result Sample Type. Required. A sample from the evaluation result.""" - evaluationResult: Required["EvalResult"] - """Evaluation result for the analysis sample. Required.""" - - -class EvaluationRule(TypedDict, total=False): - """Evaluation rule model. - - :ivar id: Unique identifier for the evaluation rule. Required. - :vartype id: str - :ivar display_name: Display Name for the evaluation rule. - :vartype display_name: str - :ivar description: Description for the evaluation rule. - :vartype description: str - :ivar action: Definition of the evaluation rule action. Required. - :vartype action: ~azure.ai.projects.types.EvaluationRuleAction - :ivar filter: Filter condition of the evaluation rule. - :vartype filter: ~azure.ai.projects.types.EvaluationRuleFilter - :ivar event_type: Event type that the evaluation rule applies to. Required. Known values are: - "responseCompleted" and "manual". - :vartype event_type: str or ~azure.ai.projects.models.EvaluationRuleEventType - :ivar enabled: Indicates whether the evaluation rule is enabled. Default is true. Required. - :vartype enabled: bool - :ivar system_data: System metadata for the evaluation rule. Required. - :vartype system_data: dict[str, str] - """ - - id: Required[str] - """Unique identifier for the evaluation rule. Required.""" - displayName: str - """Display Name for the evaluation rule.""" - description: str - """Description for the evaluation rule.""" - action: Required["EvaluationRuleAction"] - """Definition of the evaluation rule action. Required.""" - filter: "EvaluationRuleFilter" - """Filter condition of the evaluation rule.""" - eventType: Required[EvaluationRuleEventType] - """Event type that the evaluation rule applies to. Required. Known values are: - \"responseCompleted\" and \"manual\".""" - enabled: Required[bool] - """Indicates whether the evaluation rule is enabled. Default is true. Required.""" - systemData: Required[dict[str, str]] - """System metadata for the evaluation rule. Required.""" - - -class EvaluationRuleFilter(TypedDict, total=False): - """Evaluation filter model. - - :ivar agent_name: Filter by agent name. Required. - :vartype agent_name: str - """ - - agentName: Required[str] - """Filter by agent name. Required.""" - - -class EvaluationRunClusterInsightRequest(TypedDict, total=False): - """Insights on set of Evaluation Results. - - :ivar type: The type of insights request. Required. Insights on an Evaluation run result. - :vartype type: str or ~azure.ai.projects.models.EVALUATION_RUN_CLUSTER_INSIGHT - :ivar eval_id: Evaluation Id for the insights. Required. - :vartype eval_id: str - :ivar run_ids: List of evaluation run IDs for the insights. Required. - :vartype run_ids: list[str] - :ivar model_configuration: Configuration of the model used in the insight generation. - :vartype model_configuration: ~azure.ai.projects.types.InsightModelConfiguration - """ - - type: Required[Literal[InsightType.EVALUATION_RUN_CLUSTER_INSIGHT]] - """The type of insights request. Required. Insights on an Evaluation run result.""" - evalId: Required[str] - """Evaluation Id for the insights. Required.""" - runIds: Required[list[str]] - """List of evaluation run IDs for the insights. Required.""" - modelConfiguration: "InsightModelConfiguration" - """Configuration of the model used in the insight generation.""" - - -class EvaluationRunClusterInsightResult(TypedDict, total=False): - """Insights from the evaluation run cluster analysis. - - :ivar type: The type of insights result. Required. Insights on an Evaluation run result. - :vartype type: str or ~azure.ai.projects.models.EVALUATION_RUN_CLUSTER_INSIGHT - :ivar cluster_insight: Required. - :vartype cluster_insight: ~azure.ai.projects.types.ClusterInsightResult - """ - - type: Required[Literal[InsightType.EVALUATION_RUN_CLUSTER_INSIGHT]] - """The type of insights result. Required. Insights on an Evaluation run result.""" - clusterInsight: Required["ClusterInsightResult"] - """Required.""" - - -class EvaluationScheduleTask(TypedDict, total=False): - """Evaluation task for the schedule. - - :ivar configuration: Configuration for the task. - :vartype configuration: dict[str, str] - :ivar type: Required. Evaluation task. - :vartype type: str or ~azure.ai.projects.models.EVALUATION - :ivar eval_id: Identifier of the evaluation group. Required. - :vartype eval_id: str - :ivar eval_run: The evaluation run payload. Required. - :vartype eval_run: any - """ - - configuration: dict[str, str] - """Configuration for the task.""" - type: Required[Literal[ScheduleTaskType.EVALUATION]] - """Required. Evaluation task.""" - evalId: Required[str] - """Identifier of the evaluation group. Required.""" - evalRun: Required[Any] - """The evaluation run payload. Required.""" - - -class EvaluationTaxonomy(TypedDict, total=False): - """Evaluation Taxonomy Definition. - - :ivar id: Asset ID, a unique identifier for the asset. - :vartype id: str - :ivar name: The name of the resource. Required. - :vartype name: str - :ivar version: The version of the resource. Required. - :vartype version: str - :ivar description: The asset description text. - :vartype description: str - :ivar tags: Tag dictionary. Tags can be added, removed, and updated. - :vartype tags: dict[str, str] - :ivar taxonomy_input: Input configuration for the evaluation taxonomy. Required. - :vartype taxonomy_input: ~azure.ai.projects.types.EvaluationTaxonomyInput - :ivar taxonomy_categories: List of taxonomy categories. - :vartype taxonomy_categories: list[~azure.ai.projects.types.TaxonomyCategory] - :ivar properties: Additional properties for the evaluation taxonomy. - :vartype properties: dict[str, str] - """ - - id: str - """Asset ID, a unique identifier for the asset.""" - name: Required[str] - """The name of the resource. Required.""" - version: Required[str] - """The version of the resource. Required.""" - description: str - """The asset description text.""" - tags: dict[str, str] - """Tag dictionary. Tags can be added, removed, and updated.""" - taxonomyInput: Required["EvaluationTaxonomyInput"] - """Input configuration for the evaluation taxonomy. Required.""" - taxonomyCategories: list["TaxonomyCategory"] - """List of taxonomy categories.""" - properties: dict[str, str] - """Additional properties for the evaluation taxonomy.""" - - -class EvaluatorMetric(TypedDict, total=False): - """Evaluator Metric. - - :ivar type: Type of the metric. Known values are: "ordinal", "continuous", and "boolean". - :vartype type: str or ~azure.ai.projects.models.EvaluatorMetricType - :ivar desirable_direction: It indicates whether a higher value is better or a lower value is - better for this metric. Known values are: "increase", "decrease", and "neutral". - :vartype desirable_direction: str or ~azure.ai.projects.models.EvaluatorMetricDirection - :ivar min_value: Minimum value for the metric. - :vartype min_value: float - :ivar max_value: Maximum value for the metric. If not specified, it is assumed to be unbounded. - :vartype max_value: float - :ivar is_primary: Indicates if this metric is primary when there are multiple metrics. - :vartype is_primary: bool - """ - - type: EvaluatorMetricType - """Type of the metric. Known values are: \"ordinal\", \"continuous\", and \"boolean\".""" - desirable_direction: EvaluatorMetricDirection - """It indicates whether a higher value is better or a lower value is better for this metric. Known - values are: \"increase\", \"decrease\", and \"neutral\".""" - min_value: float - """Minimum value for the metric.""" - max_value: float - """Maximum value for the metric. If not specified, it is assumed to be unbounded.""" - is_primary: bool - """Indicates if this metric is primary when there are multiple metrics.""" - - -class EvaluatorVersion(TypedDict, total=False): - """Evaluator Definition. - - :ivar display_name: Display Name for evaluator. It helps to find the evaluator easily in AI - Foundry. It does not need to be unique. - :vartype display_name: str - :ivar metadata: Metadata about the evaluator. - :vartype metadata: dict[str, str] - :ivar evaluator_type: The type of the evaluator. Required. Known values are: "builtin" and - "custom". - :vartype evaluator_type: str or ~azure.ai.projects.models.EvaluatorType - :ivar categories: The categories of the evaluator. Required. - :vartype categories: list[str or ~azure.ai.projects.models.EvaluatorCategory] - :ivar definition: Definition of the evaluator. Required. - :vartype definition: ~azure.ai.projects.types.EvaluatorDefinition - :ivar created_by: Creator of the evaluator. Required. - :vartype created_by: str - :ivar created_at: Creation date/time of the evaluator. Required. - :vartype created_at: ~datetime.datetime - :ivar modified_at: Last modified date/time of the evaluator. Required. - :vartype modified_at: ~datetime.datetime - :ivar id: Asset ID, a unique identifier for the asset. - :vartype id: str - :ivar name: The name of the resource. Required. - :vartype name: str - :ivar version: The version of the resource. Required. - :vartype version: str - :ivar description: The asset description text. - :vartype description: str - :ivar tags: Tag dictionary. Tags can be added, removed, and updated. - :vartype tags: dict[str, str] - """ - - display_name: str - """Display Name for evaluator. It helps to find the evaluator easily in AI Foundry. It does not - need to be unique.""" - metadata: dict[str, str] - """Metadata about the evaluator.""" - evaluator_type: Required[EvaluatorType] - """The type of the evaluator. Required. Known values are: \"builtin\" and \"custom\".""" - categories: Required[list[EvaluatorCategory]] - """The categories of the evaluator. Required.""" - definition: Required["EvaluatorDefinition"] - """Definition of the evaluator. Required.""" - created_by: Required[str] - """Creator of the evaluator. Required.""" - created_at: Required[str] - """Creation date/time of the evaluator. Required.""" - modified_at: Required[str] - """Last modified date/time of the evaluator. Required.""" - id: str - """Asset ID, a unique identifier for the asset.""" - name: Required[str] - """The name of the resource. Required.""" - version: Required[str] - """The version of the resource. Required.""" - description: str - """The asset description text.""" - tags: dict[str, str] - """Tag dictionary. Tags can be added, removed, and updated.""" - - -class FabricDataAgentToolParameters(TypedDict, total=False): - """The fabric data agent tool parameters. - - :ivar project_connections: The project connections attached to this tool. There can be a - maximum of 1 connection resource attached to the tool. - :vartype project_connections: list[~azure.ai.projects.types.ToolProjectConnection] - """ - - project_connections: list["ToolProjectConnection"] - """The project connections attached to this tool. There can be a maximum of 1 connection resource - attached to the tool.""" - - -class FieldMapping(TypedDict, total=False): - """Field mapping configuration class. - - :ivar content_fields: List of fields with text content. Required. - :vartype content_fields: list[str] - :ivar filepath_field: Path of file to be used as a source of text content. - :vartype filepath_field: str - :ivar title_field: Field containing the title of the document. - :vartype title_field: str - :ivar url_field: Field containing the url of the document. - :vartype url_field: str - :ivar vector_fields: List of fields with vector content. - :vartype vector_fields: list[str] - :ivar metadata_fields: List of fields with metadata content. - :vartype metadata_fields: list[str] - """ - - contentFields: Required[list[str]] - """List of fields with text content. Required.""" - filepathField: str - """Path of file to be used as a source of text content.""" - titleField: str - """Field containing the title of the document.""" - urlField: str - """Field containing the url of the document.""" - vectorFields: list[str] - """List of fields with vector content.""" - metadataFields: list[str] - """List of fields with metadata content.""" - - -class FileDatasetVersion(TypedDict, total=False): - """FileDatasetVersion Definition. - - :ivar data_uri: URI of the data (`example `_). - Required. - :vartype data_uri: str - :ivar is_reference: Indicates if the dataset holds a reference to the storage, or the dataset - manages storage itself. If true, the underlying data will not be deleted when the dataset - version is deleted. - :vartype is_reference: bool - :ivar connection_name: The Azure Storage Account connection name. Required if - startPendingUploadVersion was not called before creating the Dataset. - :vartype connection_name: str - :ivar id: Asset ID, a unique identifier for the asset. - :vartype id: str - :ivar name: The name of the resource. Required. - :vartype name: str - :ivar version: The version of the resource. Required. - :vartype version: str - :ivar description: The asset description text. - :vartype description: str - :ivar tags: Tag dictionary. Tags can be added, removed, and updated. - :vartype tags: dict[str, str] - :ivar type: Dataset type. Required. URI file. - :vartype type: str or ~azure.ai.projects.models.URI_FILE - """ - - dataUri: Required[str] - """URI of the data (`example `_). Required.""" - isReference: bool - """Indicates if the dataset holds a reference to the storage, or the dataset manages storage - itself. If true, the underlying data will not be deleted when the dataset version is deleted.""" - connectionName: str - """The Azure Storage Account connection name. Required if startPendingUploadVersion was not called - before creating the Dataset.""" - id: str - """Asset ID, a unique identifier for the asset.""" - name: Required[str] - """The name of the resource. Required.""" - version: Required[str] - """The version of the resource. Required.""" - description: str - """The asset description text.""" - tags: dict[str, str] - """Tag dictionary. Tags can be added, removed, and updated.""" - type: Required[Literal[DatasetType.URI_FILE]] - """Dataset type. Required. URI file.""" - - -class FileSearchTool(TypedDict, total=False): - """File search. - - :ivar type: The type of the file search tool. Always ``file_search``. Required. FILE_SEARCH. - :vartype type: str or ~azure.ai.projects.models.FILE_SEARCH - :ivar vector_store_ids: The IDs of the vector stores to search. Required. - :vartype vector_store_ids: list[str] - :ivar max_num_results: The maximum number of results to return. This number should be between 1 - and 50 inclusive. - :vartype max_num_results: int - :ivar ranking_options: Ranking options for search. - :vartype ranking_options: ~azure.ai.projects.types.RankingOptions - :ivar filters: Is either a ComparisonFilter type or a CompoundFilter type. - :vartype filters: ~azure.ai.projects.types.ComparisonFilter or - ~azure.ai.projects.types.CompoundFilter - """ - - type: Required[Literal[ToolType.FILE_SEARCH]] - """The type of the file search tool. Always ``file_search``. Required. FILE_SEARCH.""" - vector_store_ids: Required[list[str]] - """The IDs of the vector stores to search. Required.""" - max_num_results: int - """The maximum number of results to return. This number should be between 1 and 50 inclusive.""" - ranking_options: "RankingOptions" - """Ranking options for search.""" - filters: Optional["_unions.Filters"] - """Is either a ComparisonFilter type or a CompoundFilter type.""" - - -class FolderDatasetVersion(TypedDict, total=False): - """FileDatasetVersion Definition. - - :ivar data_uri: URI of the data (`example `_). - Required. - :vartype data_uri: str - :ivar is_reference: Indicates if the dataset holds a reference to the storage, or the dataset - manages storage itself. If true, the underlying data will not be deleted when the dataset - version is deleted. - :vartype is_reference: bool - :ivar connection_name: The Azure Storage Account connection name. Required if - startPendingUploadVersion was not called before creating the Dataset. - :vartype connection_name: str - :ivar id: Asset ID, a unique identifier for the asset. - :vartype id: str - :ivar name: The name of the resource. Required. - :vartype name: str - :ivar version: The version of the resource. Required. - :vartype version: str - :ivar description: The asset description text. - :vartype description: str - :ivar tags: Tag dictionary. Tags can be added, removed, and updated. - :vartype tags: dict[str, str] - :ivar type: Dataset type. Required. URI folder. - :vartype type: str or ~azure.ai.projects.models.URI_FOLDER - """ - - dataUri: Required[str] - """URI of the data (`example `_). Required.""" - isReference: bool - """Indicates if the dataset holds a reference to the storage, or the dataset manages storage - itself. If true, the underlying data will not be deleted when the dataset version is deleted.""" - connectionName: str - """The Azure Storage Account connection name. Required if startPendingUploadVersion was not called - before creating the Dataset.""" - id: str - """Asset ID, a unique identifier for the asset.""" - name: Required[str] - """The name of the resource. Required.""" - version: Required[str] - """The version of the resource. Required.""" - description: str - """The asset description text.""" - tags: dict[str, str] - """Tag dictionary. Tags can be added, removed, and updated.""" - type: Required[Literal[DatasetType.URI_FOLDER]] - """Dataset type. Required. URI folder.""" - - -class FunctionShellToolParam(TypedDict, total=False): - """Shell tool. - - :ivar type: The type of the shell tool. Always ``shell``. Required. SHELL. - :vartype type: str or ~azure.ai.projects.models.SHELL - :ivar environment: - :vartype environment: ~azure.ai.projects.types.FunctionShellToolParamEnvironment - """ - - type: Required[Literal[ToolType.SHELL]] - """The type of the shell tool. Always ``shell``. Required. SHELL.""" - environment: Optional["FunctionShellToolParamEnvironment"] - - -class FunctionShellToolParamEnvironmentContainerReferenceParam(TypedDict, total=False): # pylint: disable=name-too-long - """FunctionShellToolParamEnvironmentContainerReferenceParam. - - :ivar type: References a container created with the /v1/containers endpoint. Required. - CONTAINER_REFERENCE. - :vartype type: str or ~azure.ai.projects.models.CONTAINER_REFERENCE - :ivar container_id: The ID of the referenced container. Required. - :vartype container_id: str - """ - - type: Required[Literal[FunctionShellToolParamEnvironmentType.CONTAINER_REFERENCE]] - """References a container created with the /v1/containers endpoint. Required. CONTAINER_REFERENCE.""" - container_id: Required[str] - """The ID of the referenced container. Required.""" - - -class FunctionShellToolParamEnvironmentLocalEnvironmentParam(TypedDict, total=False): # pylint: disable=name-too-long - """FunctionShellToolParamEnvironmentLocalEnvironmentParam. - - :ivar type: Use a local computer environment. Required. LOCAL. - :vartype type: str or ~azure.ai.projects.models.LOCAL - :ivar skills: An optional list of skills. - :vartype skills: list[~azure.ai.projects.types.LocalSkillParam] - """ - - type: Required[Literal[FunctionShellToolParamEnvironmentType.LOCAL]] - """Use a local computer environment. Required. LOCAL.""" - skills: list["LocalSkillParam"] - """An optional list of skills.""" - - -class FunctionTool(TypedDict, total=False): - """Function. - - :ivar type: The type of the function tool. Always ``function``. Required. FUNCTION. - :vartype type: str or ~azure.ai.projects.models.FUNCTION - :ivar name: The name of the function to call. Required. - :vartype name: str - :ivar description: - :vartype description: str - :ivar parameters: Required. - :vartype parameters: dict[str, any] - :ivar strict: Required. - :vartype strict: bool - """ - - type: Required[Literal[ToolType.FUNCTION]] - """The type of the function tool. Always ``function``. Required. FUNCTION.""" - name: Required[str] - """The name of the function to call. Required.""" - description: Optional[str] - parameters: Required[Optional[dict[str, Any]]] - """Required.""" - strict: Required[Optional[bool]] - """Required.""" - - -class HostedAgentDefinition(TypedDict, total=False): - """The hosted agent definition. - - :ivar rai_config: Configuration for Responsible AI (RAI) content filtering and safety features. - :vartype rai_config: ~azure.ai.projects.types.RaiConfig - :ivar kind: Required. HOSTED. - :vartype kind: str or ~azure.ai.projects.models.HOSTED - :ivar tools: An array of tools the hosted agent's model may call while generating a response. - You can specify which tool to use by setting the ``tool_choice`` parameter. - :vartype tools: list[~azure.ai.projects.types.Tool] - :ivar container_protocol_versions: The protocols that the agent supports for ingress - communication of the containers. Required. - :vartype container_protocol_versions: list[~azure.ai.projects.types.ProtocolVersionRecord] - :ivar cpu: The CPU configuration for the hosted agent. Required. - :vartype cpu: str - :ivar memory: The memory configuration for the hosted agent. Required. - :vartype memory: str - :ivar environment_variables: Environment variables to set in the hosted agent container. - :vartype environment_variables: dict[str, str] - :ivar image: The image ID for the agent, applicable to image-based hosted agents. - :vartype image: str - """ - - rai_config: "RaiConfig" - """Configuration for Responsible AI (RAI) content filtering and safety features.""" - kind: Required[Literal[AgentKind.HOSTED]] - """Required. HOSTED.""" - tools: list["Tool"] - """An array of tools the hosted agent's model may call while generating a response. You can - specify which tool to use by setting the ``tool_choice`` parameter.""" - container_protocol_versions: Required[list["ProtocolVersionRecord"]] - """The protocols that the agent supports for ingress communication of the containers. Required.""" - cpu: Required[str] - """The CPU configuration for the hosted agent. Required.""" - memory: Required[str] - """The memory configuration for the hosted agent. Required.""" - environment_variables: dict[str, str] - """Environment variables to set in the hosted agent container.""" - image: str - """The image ID for the agent, applicable to image-based hosted agents.""" - - -class HourlyRecurrenceSchedule(TypedDict, total=False): - """Hourly recurrence schedule. - - :ivar type: Required. Hourly recurrence pattern. - :vartype type: str or ~azure.ai.projects.models.HOURLY - """ - - type: Required[Literal[RecurrenceType.HOURLY]] - """Required. Hourly recurrence pattern.""" - - -class HumanEvaluationPreviewRuleAction(TypedDict, total=False): - """Evaluation rule action for human evaluation. - - :ivar type: Required. Human evaluation preview. - :vartype type: str or ~azure.ai.projects.models.HUMAN_EVALUATION_PREVIEW - :ivar template_id: Human evaluation template Id. Required. - :vartype template_id: str - """ - - type: Required[Literal[EvaluationRuleActionType.HUMAN_EVALUATION_PREVIEW]] - """Required. Human evaluation preview.""" - templateId: Required[str] - """Human evaluation template Id. Required.""" - - -class HybridSearchOptions(TypedDict, total=False): - """HybridSearchOptions. - - :ivar embedding_weight: The weight of the embedding in the reciprocal ranking fusion. Required. - :vartype embedding_weight: float - :ivar text_weight: The weight of the text in the reciprocal ranking fusion. Required. - :vartype text_weight: float - """ - - embedding_weight: Required[float] - """The weight of the embedding in the reciprocal ranking fusion. Required.""" - text_weight: Required[float] - """The weight of the text in the reciprocal ranking fusion. Required.""" - - -class ImageGenTool(TypedDict, total=False): - """Image generation tool. - - :ivar type: The type of the image generation tool. Always ``image_generation``. Required. - IMAGE_GENERATION. - :vartype type: str or ~azure.ai.projects.models.IMAGE_GENERATION - :ivar model: Is one of the following types: Literal["gpt-image-1"], - Literal["gpt-image-1-mini"], Literal["gpt-image-1.5"], str - :vartype model: str or str or str or str - :ivar quality: The quality of the generated image. One of ``low``, ``medium``, ``high``, or - ``auto``. Default: ``auto``. Is one of the following types: Literal["low"], Literal["medium"], - Literal["high"], Literal["auto"] - :vartype quality: str or str or str or str - :ivar size: The size of the generated image. One of ``1024x1024``, ``1024x1536``, - ``1536x1024``, or ``auto``. Default: ``auto``. Is one of the following types: - Literal["1024x1024"], Literal["1024x1536"], Literal["1536x1024"], Literal["auto"] - :vartype size: str or str or str or str - :ivar output_format: The output format of the generated image. One of ``png``, ``webp``, or - ``jpeg``. Default: ``png``. Is one of the following types: Literal["png"], Literal["webp"], - Literal["jpeg"] - :vartype output_format: str or str or str - :ivar output_compression: Compression level for the output image. Default: 100. - :vartype output_compression: int - :ivar moderation: Moderation level for the generated image. Default: ``auto``. Is either a - Literal["auto"] type or a Literal["low"] type. - :vartype moderation: str or str - :ivar background: Background type for the generated image. One of ``transparent``, ``opaque``, - or ``auto``. Default: ``auto``. Is one of the following types: Literal["transparent"], - Literal["opaque"], Literal["auto"] - :vartype background: str or str or str - :ivar input_fidelity: Known values are: "high" and "low". - :vartype input_fidelity: str or ~azure.ai.projects.models.InputFidelity - :ivar input_image_mask: Optional mask for inpainting. Contains ``image_url`` (string, optional) - and ``file_id`` (string, optional). - :vartype input_image_mask: ~azure.ai.projects.types.ImageGenToolInputImageMask - :ivar partial_images: Number of partial images to generate in streaming mode, from 0 (default - value) to 3. - :vartype partial_images: int - :ivar action: Whether to generate a new image or edit an existing image. Default: ``auto``. - Known values are: "generate", "edit", and "auto". - :vartype action: str or ~azure.ai.projects.models.ImageGenAction - """ - - type: Required[Literal[ToolType.IMAGE_GENERATION]] - """The type of the image generation tool. Always ``image_generation``. Required. IMAGE_GENERATION.""" - model: Union[Literal["gpt-image-1"], Literal["gpt-image-1-mini"], Literal["gpt-image-1.5"], str] - """Is one of the following types: Literal[\"gpt-image-1\"], Literal[\"gpt-image-1-mini\"], - Literal[\"gpt-image-1.5\"], str""" - quality: Literal["low", "medium", "high", "auto"] - """The quality of the generated image. One of ``low``, ``medium``, ``high``, or ``auto``. Default: - ``auto``. Is one of the following types: Literal[\"low\"], Literal[\"medium\"], - Literal[\"high\"], Literal[\"auto\"]""" - size: Literal["1024x1024", "1024x1536", "1536x1024", "auto"] - """The size of the generated image. One of ``1024x1024``, ``1024x1536``, ``1536x1024``, or - ``auto``. Default: ``auto``. Is one of the following types: Literal[\"1024x1024\"], - Literal[\"1024x1536\"], Literal[\"1536x1024\"], Literal[\"auto\"]""" - output_format: Literal["png", "webp", "jpeg"] - """The output format of the generated image. One of ``png``, ``webp``, or ``jpeg``. Default: - ``png``. Is one of the following types: Literal[\"png\"], Literal[\"webp\"], Literal[\"jpeg\"]""" - output_compression: int - """Compression level for the output image. Default: 100.""" - moderation: Literal["auto", "low"] - """Moderation level for the generated image. Default: ``auto``. Is either a Literal[\"auto\"] type - or a Literal[\"low\"] type.""" - background: Literal["transparent", "opaque", "auto"] - """Background type for the generated image. One of ``transparent``, ``opaque``, or ``auto``. - Default: ``auto``. Is one of the following types: Literal[\"transparent\"], - Literal[\"opaque\"], Literal[\"auto\"]""" - input_fidelity: Optional[InputFidelity] - """Known values are: \"high\" and \"low\".""" - input_image_mask: "ImageGenToolInputImageMask" - """Optional mask for inpainting. Contains ``image_url`` (string, optional) and ``file_id`` - (string, optional).""" - partial_images: int - """Number of partial images to generate in streaming mode, from 0 (default value) to 3.""" - action: ImageGenAction - """Whether to generate a new image or edit an existing image. Default: ``auto``. Known values are: - \"generate\", \"edit\", and \"auto\".""" - - -class ImageGenToolInputImageMask(TypedDict, total=False): - """ImageGenToolInputImageMask. - - :ivar image_url: - :vartype image_url: str - :ivar file_id: - :vartype file_id: str - """ - - image_url: str - file_id: str - - -class InlineSkillParam(TypedDict, total=False): - """InlineSkillParam. - - :ivar type: Defines an inline skill for this request. Required. INLINE. - :vartype type: str or ~azure.ai.projects.models.INLINE - :ivar name: The name of the skill. Required. - :vartype name: str - :ivar description: The description of the skill. Required. - :vartype description: str - :ivar source: Inline skill payload. Required. - :vartype source: ~azure.ai.projects.types.InlineSkillSourceParam - """ - - type: Required[Literal[ContainerSkillType.INLINE]] - """Defines an inline skill for this request. Required. INLINE.""" - name: Required[str] - """The name of the skill. Required.""" - description: Required[str] - """The description of the skill. Required.""" - source: Required["InlineSkillSourceParam"] - """Inline skill payload. Required.""" - - -class InlineSkillSourceParam(TypedDict, total=False): - """Inline skill payload. - - :ivar type: The type of the inline skill source. Must be ``base64``. Required. Default value is - "base64". - :vartype type: str - :ivar media_type: The media type of the inline skill payload. Must be ``application/zip``. - Required. Default value is "application/zip". - :vartype media_type: str - :ivar data: Base64-encoded skill zip bundle. Required. - :vartype data: str - """ - - type: Required[Literal["base64"]] - """The type of the inline skill source. Must be ``base64``. Required. Default value is \"base64\".""" - media_type: Required[Literal["application/zip"]] - """The media type of the inline skill payload. Must be ``application/zip``. Required. Default - value is \"application/zip\".""" - data: Required[str] - """Base64-encoded skill zip bundle. Required.""" - - -class Insight(TypedDict, total=False): - """The response body for cluster insights. - - :ivar insight_id: The unique identifier for the insights report. Required. - :vartype insight_id: str - :ivar metadata: Metadata about the insights report. Required. - :vartype metadata: ~azure.ai.projects.types.InsightsMetadata - :ivar state: The current state of the insights. Required. Known values are: "NotStarted", - "Running", "Succeeded", "Failed", and "Canceled". - :vartype state: str or ~azure.ai.projects.models.OperationState - :ivar display_name: User friendly display name for the insight. Required. - :vartype display_name: str - :ivar request: Request for the insights analysis. Required. - :vartype request: ~azure.ai.projects.types.InsightRequest - :ivar result: The result of the insights report. - :vartype result: ~azure.ai.projects.types.InsightResult - """ - - id: Required[str] - """The unique identifier for the insights report. Required.""" - metadata: Required["InsightsMetadata"] - """Metadata about the insights report. Required.""" - state: Required[OperationState] - """The current state of the insights. Required. Known values are: \"NotStarted\", \"Running\", - \"Succeeded\", \"Failed\", and \"Canceled\".""" - displayName: Required[str] - """User friendly display name for the insight. Required.""" - request: Required["InsightRequest"] - """Request for the insights analysis. Required.""" - result: "InsightResult" - """The result of the insights report.""" - - -class InsightCluster(TypedDict, total=False): - """A cluster of analysis samples. - - :ivar id: The id of the analysis cluster. Required. - :vartype id: str - :ivar label: Label for the cluster. Required. - :vartype label: str - :ivar suggestion: Suggestion for the cluster. Required. - :vartype suggestion: str - :ivar suggestion_title: The title of the suggestion for the cluster. Required. - :vartype suggestion_title: str - :ivar description: Description of the analysis cluster. Required. - :vartype description: str - :ivar weight: The weight of the analysis cluster. This indicate number of samples in the - cluster. Required. - :vartype weight: int - :ivar sub_clusters: List of subclusters within this cluster. Empty if no subclusters exist. - :vartype sub_clusters: list[~azure.ai.projects.types.InsightCluster] - :ivar samples: List of samples that belong to this cluster. Empty if samples are part of - subclusters. - :vartype samples: list[~azure.ai.projects.types.InsightSample] - """ - - id: Required[str] - """The id of the analysis cluster. Required.""" - label: Required[str] - """Label for the cluster. Required.""" - suggestion: Required[str] - """Suggestion for the cluster. Required.""" - suggestionTitle: Required[str] - """The title of the suggestion for the cluster. Required.""" - description: Required[str] - """Description of the analysis cluster. Required.""" - weight: Required[int] - """The weight of the analysis cluster. This indicate number of samples in the cluster. Required.""" - subClusters: list["InsightCluster"] - """List of subclusters within this cluster. Empty if no subclusters exist.""" - samples: list["InsightSample"] - """List of samples that belong to this cluster. Empty if samples are part of subclusters.""" - - -class InsightModelConfiguration(TypedDict, total=False): - """Configuration of the model used in the insight generation. - - :ivar model_deployment_name: The model deployment to be evaluated. Accepts either the - deployment name alone or with the connection name as '{connectionName}/'. - Required. - :vartype model_deployment_name: str - """ - - modelDeploymentName: Required[str] - """The model deployment to be evaluated. Accepts either the deployment name alone or with the - connection name as '{connectionName}/'. Required.""" - - -class InsightScheduleTask(TypedDict, total=False): - """Insight task for the schedule. - - :ivar configuration: Configuration for the task. - :vartype configuration: dict[str, str] - :ivar type: Required. Insight task. - :vartype type: str or ~azure.ai.projects.models.INSIGHT - :ivar insight: The insight payload. Required. - :vartype insight: ~azure.ai.projects.types.Insight - """ - - configuration: dict[str, str] - """Configuration for the task.""" - type: Required[Literal[ScheduleTaskType.INSIGHT]] - """Required. Insight task.""" - insight: Required["Insight"] - """The insight payload. Required.""" - - -class InsightsMetadata(TypedDict, total=False): - """Metadata about the insights. - - :ivar created_at: The timestamp when the insights were created. Required. - :vartype created_at: ~datetime.datetime - :ivar completed_at: The timestamp when the insights were completed. - :vartype completed_at: ~datetime.datetime - """ - - createdAt: Required[str] - """The timestamp when the insights were created. Required.""" - completedAt: str - """The timestamp when the insights were completed.""" - - -class InsightSummary(TypedDict, total=False): - """Summary of the error cluster analysis. - - :ivar sample_count: Total number of samples analyzed. Required. - :vartype sample_count: int - :ivar unique_subcluster_count: Total number of unique subcluster labels. Required. - :vartype unique_subcluster_count: int - :ivar unique_cluster_count: Total number of unique clusters. Required. - :vartype unique_cluster_count: int - :ivar method: Method used for clustering. Required. - :vartype method: str - :ivar usage: Token usage while performing clustering analysis. Required. - :vartype usage: ~azure.ai.projects.types.ClusterTokenUsage - """ - - sampleCount: Required[int] - """Total number of samples analyzed. Required.""" - uniqueSubclusterCount: Required[int] - """Total number of unique subcluster labels. Required.""" - uniqueClusterCount: Required[int] - """Total number of unique clusters. Required.""" - method: Required[str] - """Method used for clustering. Required.""" - usage: Required["ClusterTokenUsage"] - """Token usage while performing clustering analysis. Required.""" - - -class LocalShellToolParam(TypedDict, total=False): - """Local shell tool. - - :ivar type: The type of the local shell tool. Always ``local_shell``. Required. LOCAL_SHELL. - :vartype type: str or ~azure.ai.projects.models.LOCAL_SHELL - """ - - type: Required[Literal[ToolType.LOCAL_SHELL]] - """The type of the local shell tool. Always ``local_shell``. Required. LOCAL_SHELL.""" - - -class LocalSkillParam(TypedDict, total=False): - """LocalSkillParam. - - :ivar name: The name of the skill. Required. - :vartype name: str - :ivar description: The description of the skill. Required. - :vartype description: str - :ivar path: The path to the directory containing the skill. Required. - :vartype path: str - """ - - name: Required[str] - """The name of the skill. Required.""" - description: Required[str] - """The description of the skill. Required.""" - path: Required[str] - """The path to the directory containing the skill. Required.""" - - -class ManagedAzureAISearchIndex(TypedDict, total=False): - """Managed Azure AI Search Index Definition. - - :ivar id: Asset ID, a unique identifier for the asset. - :vartype id: str - :ivar name: The name of the resource. Required. - :vartype name: str - :ivar version: The version of the resource. Required. - :vartype version: str - :ivar description: The asset description text. - :vartype description: str - :ivar tags: Tag dictionary. Tags can be added, removed, and updated. - :vartype tags: dict[str, str] - :ivar type: Type of index. Required. Managed Azure Search. - :vartype type: str or ~azure.ai.projects.models.MANAGED_AZURE_SEARCH - :ivar vector_store_id: Vector store id of managed index. Required. - :vartype vector_store_id: str - """ - - id: str - """Asset ID, a unique identifier for the asset.""" - name: Required[str] - """The name of the resource. Required.""" - version: Required[str] - """The version of the resource. Required.""" - description: str - """The asset description text.""" - tags: dict[str, str] - """Tag dictionary. Tags can be added, removed, and updated.""" - type: Required[Literal[IndexType.MANAGED_AZURE_SEARCH]] - """Type of index. Required. Managed Azure Search.""" - vectorStoreId: Required[str] - """Vector store id of managed index. Required.""" - - -class MCPTool(TypedDict, total=False): - """MCP tool. - - :ivar type: The type of the MCP tool. Always ``mcp``. Required. MCP. - :vartype type: str or ~azure.ai.projects.models.MCP - :ivar server_label: A label for this MCP server, used to identify it in tool calls. Required. - :vartype server_label: str - :ivar server_url: The URL for the MCP server. One of ``server_url`` or ``connector_id`` must be - provided. - :vartype server_url: str - :ivar connector_id: Identifier for service connectors, like those available in ChatGPT. One of - ``server_url`` or ``connector_id`` must be provided. Learn more about service connectors `here - `_. Currently supported ``connector_id`` values are: - - * Dropbox: `connector_dropbox` - * Gmail: `connector_gmail` - * Google Calendar: `connector_googlecalendar` - * Google Drive: `connector_googledrive` - * Microsoft Teams: `connector_microsoftteams` - * Outlook Calendar: `connector_outlookcalendar` - * Outlook Email: `connector_outlookemail` - * SharePoint: `connector_sharepoint`. Is one of the following types: - Literal["connector_dropbox"], Literal["connector_gmail"], Literal["connector_googlecalendar"], - Literal["connector_googledrive"], Literal["connector_microsoftteams"], - Literal["connector_outlookcalendar"], Literal["connector_outlookemail"], - Literal["connector_sharepoint"] - :vartype connector_id: str or str or str or str or str or str or str or str - :ivar authorization: An OAuth access token that can be used with a remote MCP server, either - with a custom MCP server URL or a service connector. Your application must handle the OAuth - authorization flow and provide the token here. - :vartype authorization: str - :ivar server_description: Optional description of the MCP server, used to provide more context. - :vartype server_description: str - :ivar headers: - :vartype headers: dict[str, str] - :ivar allowed_tools: Is either a [str] type or a MCPToolFilter type. - :vartype allowed_tools: list[str] or ~azure.ai.projects.types.MCPToolFilter - :ivar require_approval: Is one of the following types: MCPToolRequireApproval, - Literal["always"], Literal["never"] - :vartype require_approval: ~azure.ai.projects.types.MCPToolRequireApproval or str or str - :ivar project_connection_id: The connection ID in the project for the MCP server. The - connection stores authentication and other connection details needed to connect to the MCP - server. - :vartype project_connection_id: str - """ - - type: Required[Literal[ToolType.MCP]] - """The type of the MCP tool. Always ``mcp``. Required. MCP.""" - server_label: Required[str] - """A label for this MCP server, used to identify it in tool calls. Required.""" - server_url: str - """The URL for the MCP server. One of ``server_url`` or ``connector_id`` must be provided.""" - connector_id: Literal[ - "connector_dropbox", - "connector_gmail", - "connector_googlecalendar", - "connector_googledrive", - "connector_microsoftteams", - "connector_outlookcalendar", - "connector_outlookemail", - "connector_sharepoint", - ] - """Identifier for service connectors, like those available in ChatGPT. One of ``server_url`` or - ``connector_id`` must be provided. Learn more about service connectors `here - `_. Currently supported ``connector_id`` values are: - - * Dropbox: `connector_dropbox` - * Gmail: `connector_gmail` - * Google Calendar: `connector_googlecalendar` - * Google Drive: `connector_googledrive` - * Microsoft Teams: `connector_microsoftteams` - * Outlook Calendar: `connector_outlookcalendar` - * Outlook Email: `connector_outlookemail` - * SharePoint: `connector_sharepoint`. Is one of the following types: - Literal[\"connector_dropbox\"], Literal[\"connector_gmail\"], - Literal[\"connector_googlecalendar\"], Literal[\"connector_googledrive\"], - Literal[\"connector_microsoftteams\"], Literal[\"connector_outlookcalendar\"], - Literal[\"connector_outlookemail\"], Literal[\"connector_sharepoint\"]""" - authorization: str - """An OAuth access token that can be used with a remote MCP server, either with a custom MCP - server URL or a service connector. Your application must handle the OAuth authorization flow - and provide the token here.""" - server_description: str - """Optional description of the MCP server, used to provide more context.""" - headers: Optional[dict[str, str]] - allowed_tools: Optional[Union[list[str], "MCPToolFilter"]] - """Is either a [str] type or a MCPToolFilter type.""" - require_approval: Optional[Union["MCPToolRequireApproval", Literal["always"], Literal["never"]]] - """Is one of the following types: MCPToolRequireApproval, Literal[\"always\"], Literal[\"never\"]""" - project_connection_id: str - """The connection ID in the project for the MCP server. The connection stores authentication and - other connection details needed to connect to the MCP server.""" - - -class MCPToolFilter(TypedDict, total=False): - """MCP tool filter. - - :ivar tool_names: MCP allowed tools. - :vartype tool_names: list[str] - :ivar read_only: Indicates whether or not a tool modifies data or is read-only. If an MCP - server is `annotated with `readOnlyHint` - `_, - it will match this filter. - :vartype read_only: bool - """ - - tool_names: list[str] - """MCP allowed tools.""" - read_only: bool - """Indicates whether or not a tool modifies data or is read-only. If an MCP server is `annotated - with `readOnlyHint` - `_, - it will match this filter.""" - - -class MCPToolRequireApproval(TypedDict, total=False): - """MCPToolRequireApproval. - - :ivar always: - :vartype always: ~azure.ai.projects.types.MCPToolFilter - :ivar never: - :vartype never: ~azure.ai.projects.types.MCPToolFilter - """ - - always: "MCPToolFilter" - never: "MCPToolFilter" - - -class MemoryOperation(TypedDict, total=False): - """Represents a single memory operation (create, update, or delete) performed on a memory item. - - :ivar kind: The type of memory operation being performed. Required. Known values are: "create", - "update", and "delete". - :vartype kind: str or ~azure.ai.projects.models.MemoryOperationKind - :ivar memory_item: The memory item to create, update, or delete. Required. - :vartype memory_item: ~azure.ai.projects.types.MemoryItem - """ - - kind: Required[MemoryOperationKind] - """The type of memory operation being performed. Required. Known values are: \"create\", - \"update\", and \"delete\".""" - memory_item: Required["MemoryItem"] - """The memory item to create, update, or delete. Required.""" - - -class MemorySearchItem(TypedDict, total=False): - """A retrieved memory item from memory search. - - :ivar memory_item: Retrieved memory item. Required. - :vartype memory_item: ~azure.ai.projects.types.MemoryItem - """ - - memory_item: Required["MemoryItem"] - """Retrieved memory item. Required.""" - - -class MemorySearchOptions(TypedDict, total=False): - """Memory search options. - - :ivar max_memories: Maximum number of memory items to return. - :vartype max_memories: int - """ - - max_memories: int - """Maximum number of memory items to return.""" - - -class MemorySearchPreviewTool(TypedDict, total=False): - """A tool for integrating memories into the agent. - - :ivar type: The type of the tool. Always ``memory_search_preview``. Required. - MEMORY_SEARCH_PREVIEW. - :vartype type: str or ~azure.ai.projects.models.MEMORY_SEARCH_PREVIEW - :ivar memory_store_name: The name of the memory store to use. Required. - :vartype memory_store_name: str - :ivar scope: The namespace used to group and isolate memories, such as a user ID. Limits which - memories can be retrieved or updated. Use special variable ``{{$userId}}`` to scope memories to - the current signed-in user. Required. - :vartype scope: str - :ivar search_options: Options for searching the memory store. - :vartype search_options: ~azure.ai.projects.types.MemorySearchOptions - :ivar update_delay: Time to wait before updating memories after inactivity (seconds). Default - 300. - :vartype update_delay: int - """ - - type: Required[Literal[ToolType.MEMORY_SEARCH_PREVIEW]] - """The type of the tool. Always ``memory_search_preview``. Required. MEMORY_SEARCH_PREVIEW.""" - memory_store_name: Required[str] - """The name of the memory store to use. Required.""" - scope: Required[str] - """The namespace used to group and isolate memories, such as a user ID. Limits which memories can - be retrieved or updated. Use special variable ``{{$userId}}`` to scope memories to the current - signed-in user. Required.""" - search_options: "MemorySearchOptions" - """Options for searching the memory store.""" - update_delay: int - """Time to wait before updating memories after inactivity (seconds). Default 300.""" - - -class MemoryStoreDefaultDefinition(TypedDict, total=False): - """Default memory store implementation. - - :ivar kind: The kind of the memory store. Required. The default memory store implementation. - :vartype kind: str or ~azure.ai.projects.models.DEFAULT - :ivar chat_model: The name or identifier of the chat completion model deployment used for - memory processing. Required. - :vartype chat_model: str - :ivar embedding_model: The name or identifier of the embedding model deployment used for memory - processing. Required. - :vartype embedding_model: str - :ivar options: Default memory store options. - :vartype options: ~azure.ai.projects.types.MemoryStoreDefaultOptions - """ - - kind: Required[Literal[MemoryStoreKind.DEFAULT]] - """The kind of the memory store. Required. The default memory store implementation.""" - chat_model: Required[str] - """The name or identifier of the chat completion model deployment used for memory processing. - Required.""" - embedding_model: Required[str] - """The name or identifier of the embedding model deployment used for memory processing. Required.""" - options: "MemoryStoreDefaultOptions" - """Default memory store options.""" - - -class MemoryStoreDefaultOptions(TypedDict, total=False): - """Default memory store configurations. - - :ivar user_profile_enabled: Whether to enable user profile extraction and storage. Default is - true. Required. - :vartype user_profile_enabled: bool - :ivar user_profile_details: Specific categories or types of user profile information to extract - and store. - :vartype user_profile_details: str - :ivar chat_summary_enabled: Whether to enable chat summary extraction and storage. Default is - true. Required. - :vartype chat_summary_enabled: bool - """ - - user_profile_enabled: Required[bool] - """Whether to enable user profile extraction and storage. Default is true. Required.""" - user_profile_details: str - """Specific categories or types of user profile information to extract and store.""" - chat_summary_enabled: Required[bool] - """Whether to enable chat summary extraction and storage. Default is true. Required.""" - - -class MemoryStoreDeleteScopeResult(TypedDict, total=False): - """Response for deleting memories from a scope. - - :ivar object: The object type. Always 'memory_store.scope.deleted'. Required. - MEMORY_STORE_SCOPE_DELETED. - :vartype object: str or ~azure.ai.projects.models.MEMORY_STORE_SCOPE_DELETED - :ivar name: The name of the memory store. Required. - :vartype name: str - :ivar scope: The scope from which memories were deleted. Required. - :vartype scope: str - :ivar deleted: Whether the deletion operation was successful. Required. - :vartype deleted: bool - """ - - object: Required[Literal[MemoryStoreObjectType.MEMORY_STORE_SCOPE_DELETED]] - """The object type. Always 'memory_store.scope.deleted'. Required. MEMORY_STORE_SCOPE_DELETED.""" - name: Required[str] - """The name of the memory store. Required.""" - scope: Required[str] - """The scope from which memories were deleted. Required.""" - deleted: Required[bool] - """Whether the deletion operation was successful. Required.""" - - -class MemoryStoreDetails(TypedDict, total=False): - """A memory store that can store and retrieve user memories. - - :ivar object: The object type, which is always 'memory_store'. Required. MEMORY_STORE. - :vartype object: str or ~azure.ai.projects.models.MEMORY_STORE - :ivar id: The unique identifier of the memory store. Required. - :vartype id: str - :ivar created_at: The Unix timestamp (seconds) when the memory store was created. Required. - :vartype created_at: ~datetime.datetime - :ivar updated_at: The Unix timestamp (seconds) when the memory store was last updated. - Required. - :vartype updated_at: ~datetime.datetime - :ivar name: The name of the memory store. Required. - :vartype name: str - :ivar description: A human-readable description of the memory store. - :vartype description: str - :ivar metadata: Arbitrary key-value metadata to associate with the memory store. - :vartype metadata: dict[str, str] - :ivar definition: The definition of the memory store. Required. - :vartype definition: ~azure.ai.projects.types.MemoryStoreDefinition - """ - - object: Required[Literal[MemoryStoreObjectType.MEMORY_STORE]] - """The object type, which is always 'memory_store'. Required. MEMORY_STORE.""" - id: Required[str] - """The unique identifier of the memory store. Required.""" - created_at: Required[int] - """The Unix timestamp (seconds) when the memory store was created. Required.""" - updated_at: Required[int] - """The Unix timestamp (seconds) when the memory store was last updated. Required.""" - name: Required[str] - """The name of the memory store. Required.""" - description: str - """A human-readable description of the memory store.""" - metadata: dict[str, str] - """Arbitrary key-value metadata to associate with the memory store.""" - definition: Required["MemoryStoreDefinition"] - """The definition of the memory store. Required.""" - - -class MemoryStoreOperationUsage(TypedDict, total=False): - """Usage statistics of a memory store operation. - - :ivar embedding_tokens: The number of embedding tokens. Required. - :vartype embedding_tokens: int - :ivar input_tokens: The number of input tokens. Required. - :vartype input_tokens: int - :ivar input_tokens_details: A detailed breakdown of the input tokens. Required. - :vartype input_tokens_details: ~azure.ai.projects.types.ResponseUsageInputTokensDetails - :ivar output_tokens: The number of output tokens. Required. - :vartype output_tokens: int - :ivar output_tokens_details: A detailed breakdown of the output tokens. Required. - :vartype output_tokens_details: ~azure.ai.projects.types.ResponseUsageOutputTokensDetails - :ivar total_tokens: The total number of tokens used. Required. - :vartype total_tokens: int - """ - - embedding_tokens: Required[int] - """The number of embedding tokens. Required.""" - input_tokens: Required[int] - """The number of input tokens. Required.""" - input_tokens_details: Required["ResponseUsageInputTokensDetails"] - """A detailed breakdown of the input tokens. Required.""" - output_tokens: Required[int] - """The number of output tokens. Required.""" - output_tokens_details: Required["ResponseUsageOutputTokensDetails"] - """A detailed breakdown of the output tokens. Required.""" - total_tokens: Required[int] - """The total number of tokens used. Required.""" - - -class MemoryStoreSearchResult(TypedDict, total=False): - """Memory search response. - - :ivar search_id: The unique ID of this search request. Use this value as previous_search_id in - subsequent requests to perform incremental searches. Required. - :vartype search_id: str - :ivar memories: Related memory items found during the search operation. Required. - :vartype memories: list[~azure.ai.projects.types.MemorySearchItem] - :ivar usage: Usage statistics associated with the memory search operation. Required. - :vartype usage: ~azure.ai.projects.types.MemoryStoreOperationUsage - """ - - search_id: Required[str] - """The unique ID of this search request. Use this value as previous_search_id in subsequent - requests to perform incremental searches. Required.""" - memories: Required[list["MemorySearchItem"]] - """Related memory items found during the search operation. Required.""" - usage: Required["MemoryStoreOperationUsage"] - """Usage statistics associated with the memory search operation. Required.""" - - -class MemoryStoreUpdateCompletedResult(TypedDict, total=False): - """Memory update result. - - :ivar memory_operations: A list of individual memory operations that were performed during the - update. Required. - :vartype memory_operations: list[~azure.ai.projects.types.MemoryOperation] - :ivar usage: Usage statistics associated with the memory update operation. Required. - :vartype usage: ~azure.ai.projects.types.MemoryStoreOperationUsage - """ - - memory_operations: Required[list["MemoryOperation"]] - """A list of individual memory operations that were performed during the update. Required.""" - usage: Required["MemoryStoreOperationUsage"] - """Usage statistics associated with the memory update operation. Required.""" - - -class MemoryStoreUpdateResult(TypedDict, total=False): - """Provides the status of a memory store update operation. - - :ivar update_id: The unique ID of this update request. Use this value as previous_update_id in - subsequent requests to perform incremental updates. Required. - :vartype update_id: str - :ivar status: The status of the memory update operation. One of "queued", "in_progress", - "completed", "failed", or "superseded". Required. Known values are: "queued", "in_progress", - "completed", "failed", and "superseded". - :vartype status: str or ~azure.ai.projects.models.MemoryStoreUpdateStatus - :ivar superseded_by: The update_id the operation was superseded by when status is "superseded". - :vartype superseded_by: str - :ivar result: The result of memory store update operation when status is "completed". - :vartype result: ~azure.ai.projects.types.MemoryStoreUpdateCompletedResult - :ivar error: Error object that describes the error when status is "failed". - :vartype error: ~azure.ai.projects.types.ApiError - """ - - update_id: Required[str] - """The unique ID of this update request. Use this value as previous_update_id in subsequent - requests to perform incremental updates. Required.""" - status: Required[MemoryStoreUpdateStatus] - """The status of the memory update operation. One of \"queued\", \"in_progress\", \"completed\", - \"failed\", or \"superseded\". Required. Known values are: \"queued\", \"in_progress\", - \"completed\", \"failed\", and \"superseded\".""" - superseded_by: str - """The update_id the operation was superseded by when status is \"superseded\".""" - result: "MemoryStoreUpdateCompletedResult" - """The result of memory store update operation when status is \"completed\".""" - error: "ApiError" - """Error object that describes the error when status is \"failed\".""" - - -class MicrosoftFabricPreviewTool(TypedDict, total=False): - """The input definition information for a Microsoft Fabric tool as used to configure an agent. - - :ivar type: The object type, which is always 'fabric_dataagent_preview'. Required. - FABRIC_DATAAGENT_PREVIEW. - :vartype type: str or ~azure.ai.projects.models.FABRIC_DATAAGENT_PREVIEW - :ivar fabric_dataagent_preview: The fabric data agent tool parameters. Required. - :vartype fabric_dataagent_preview: ~azure.ai.projects.types.FabricDataAgentToolParameters - """ - - type: Required[Literal[ToolType.FABRIC_DATAAGENT_PREVIEW]] - """The object type, which is always 'fabric_dataagent_preview'. Required. - FABRIC_DATAAGENT_PREVIEW.""" - fabric_dataagent_preview: Required["FabricDataAgentToolParameters"] - """The fabric data agent tool parameters. Required.""" - - -class ModelDeployment(TypedDict, total=False): - """Model Deployment Definition. - - :ivar name: Name of the deployment. Required. - :vartype name: str - :ivar type: The type of the deployment. Required. Model deployment. - :vartype type: str or ~azure.ai.projects.models.MODEL_DEPLOYMENT - :ivar model_name: Publisher-specific name of the deployed model. Required. - :vartype model_name: str - :ivar model_version: Publisher-specific version of the deployed model. Required. - :vartype model_version: str - :ivar model_publisher: Name of the deployed model's publisher. Required. - :vartype model_publisher: str - :ivar capabilities: Capabilities of deployed model. Required. - :vartype capabilities: dict[str, str] - :ivar sku: Sku of the model deployment. Required. - :vartype sku: ~azure.ai.projects.types.ModelDeploymentSku - :ivar connection_name: Name of the connection the deployment comes from. - :vartype connection_name: str - """ - - name: Required[str] - """Name of the deployment. Required.""" - type: Required[Literal[DeploymentType.MODEL_DEPLOYMENT]] - """The type of the deployment. Required. Model deployment.""" - modelName: Required[str] - """Publisher-specific name of the deployed model. Required.""" - modelVersion: Required[str] - """Publisher-specific version of the deployed model. Required.""" - modelPublisher: Required[str] - """Name of the deployed model's publisher. Required.""" - capabilities: Required[dict[str, str]] - """Capabilities of deployed model. Required.""" - sku: Required["ModelDeploymentSku"] - """Sku of the model deployment. Required.""" - connectionName: str - """Name of the connection the deployment comes from.""" - - -class ModelDeploymentSku(TypedDict, total=False): - """Sku information. - - :ivar capacity: Sku capacity. Required. - :vartype capacity: int - :ivar family: Sku family. Required. - :vartype family: str - :ivar name: Sku name. Required. - :vartype name: str - :ivar size: Sku size. Required. - :vartype size: str - :ivar tier: Sku tier. Required. - :vartype tier: str - """ - - capacity: Required[int] - """Sku capacity. Required.""" - family: Required[str] - """Sku family. Required.""" - name: Required[str] - """Sku name. Required.""" - size: Required[str] - """Sku size. Required.""" - tier: Required[str] - """Sku tier. Required.""" - - -class ModelSamplingParams(TypedDict, total=False): - """Represents a set of parameters used to control the sampling behavior of a language model during - text generation. - - :ivar temperature: The temperature parameter for sampling. Required. - :vartype temperature: float - :ivar top_p: The top-p parameter for nucleus sampling. Required. - :vartype top_p: float - :ivar seed: The random seed for reproducibility. Required. - :vartype seed: int - :ivar max_completion_tokens: The maximum number of tokens allowed in the completion. Required. - :vartype max_completion_tokens: int - """ - - temperature: Required[float] - """The temperature parameter for sampling. Required.""" - top_p: Required[float] - """The top-p parameter for nucleus sampling. Required.""" - seed: Required[int] - """The random seed for reproducibility. Required.""" - max_completion_tokens: Required[int] - """The maximum number of tokens allowed in the completion. Required.""" - - -class MonthlyRecurrenceSchedule(TypedDict, total=False): - """Monthly recurrence schedule. - - :ivar type: Monthly recurrence type. Required. Monthly recurrence pattern. - :vartype type: str or ~azure.ai.projects.models.MONTHLY - :ivar days_of_month: Days of the month for the recurrence schedule. Required. - :vartype days_of_month: list[int] - """ - - type: Required[Literal[RecurrenceType.MONTHLY]] - """Monthly recurrence type. Required. Monthly recurrence pattern.""" - daysOfMonth: Required[list[int]] - """Days of the month for the recurrence schedule. Required.""" - - -class NoAuthenticationCredentials(TypedDict, total=False): - """Credentials that do not require authentication. - - :ivar type: The credential type. Required. No credential. - :vartype type: str or ~azure.ai.projects.models.NONE - """ - - type: Required[Literal[CredentialType.NONE]] - """The credential type. Required. No credential.""" - - -class OneTimeTrigger(TypedDict, total=False): - """One-time trigger. - - :ivar type: Required. One-time trigger. - :vartype type: str or ~azure.ai.projects.models.ONE_TIME - :ivar trigger_at: Date and time for the one-time trigger in ISO 8601 format. Required. - :vartype trigger_at: ~datetime.datetime - :ivar time_zone: Time zone for the one-time trigger. - :vartype time_zone: str - """ - - type: Required[Literal[TriggerType.ONE_TIME]] - """Required. One-time trigger.""" - triggerAt: Required[str] - """Date and time for the one-time trigger in ISO 8601 format. Required.""" - timeZone: str - """Time zone for the one-time trigger.""" - - -class OpenApiAnonymousAuthDetails(TypedDict, total=False): - """Security details for OpenApi anonymous authentication. - - :ivar type: The object type, which is always 'anonymous'. Required. ANONYMOUS. - :vartype type: str or ~azure.ai.projects.models.ANONYMOUS - """ - - type: Required[Literal[OpenApiAuthType.ANONYMOUS]] - """The object type, which is always 'anonymous'. Required. ANONYMOUS.""" - - -class OpenApiFunctionDefinition(TypedDict, total=False): - """The input definition information for an openapi function. - - :ivar name: The name of the function to be called. Required. - :vartype name: str - :ivar description: A description of what the function does, used by the model to choose when - and how to call the function. - :vartype description: str - :ivar spec: The openapi function shape, described as a JSON Schema object. Required. - :vartype spec: dict[str, any] - :ivar auth: Open API authentication details. Required. - :vartype auth: ~azure.ai.projects.types.OpenApiAuthDetails - :ivar default_params: List of OpenAPI spec parameters that will use user-provided defaults. - :vartype default_params: list[str] - :ivar functions: List of function definitions used by OpenApi tool. - :vartype functions: list[~azure.ai.projects.types.OpenApiFunctionDefinitionFunction] - """ - - name: Required[str] - """The name of the function to be called. Required.""" - description: str - """A description of what the function does, used by the model to choose when and how to call the - function.""" - spec: Required[dict[str, Any]] - """The openapi function shape, described as a JSON Schema object. Required.""" - auth: Required["OpenApiAuthDetails"] - """Open API authentication details. Required.""" - default_params: list[str] - """List of OpenAPI spec parameters that will use user-provided defaults.""" - functions: list["OpenApiFunctionDefinitionFunction"] - """List of function definitions used by OpenApi tool.""" - - -class OpenApiFunctionDefinitionFunction(TypedDict, total=False): - """OpenApiFunctionDefinitionFunction. - - :ivar name: The name of the function to be called. Required. - :vartype name: str - :ivar description: A description of what the function does, used by the model to choose when - and how to call the function. - :vartype description: str - :ivar parameters: The parameters the functions accepts, described as a JSON Schema object. - Required. - :vartype parameters: dict[str, any] - """ - - name: Required[str] - """The name of the function to be called. Required.""" - description: str - """A description of what the function does, used by the model to choose when and how to call the - function.""" - parameters: Required[dict[str, Any]] - """The parameters the functions accepts, described as a JSON Schema object. Required.""" - - -class OpenApiManagedAuthDetails(TypedDict, total=False): - """Security details for OpenApi managed_identity authentication. - - :ivar type: The object type, which is always 'managed_identity'. Required. MANAGED_IDENTITY. - :vartype type: str or ~azure.ai.projects.models.MANAGED_IDENTITY - :ivar security_scheme: Connection auth security details. Required. - :vartype security_scheme: ~azure.ai.projects.types.OpenApiManagedSecurityScheme - """ - - type: Required[Literal[OpenApiAuthType.MANAGED_IDENTITY]] - """The object type, which is always 'managed_identity'. Required. MANAGED_IDENTITY.""" - security_scheme: Required["OpenApiManagedSecurityScheme"] - """Connection auth security details. Required.""" - - -class OpenApiManagedSecurityScheme(TypedDict, total=False): - """Security scheme for OpenApi managed_identity authentication. - - :ivar audience: Authentication scope for managed_identity auth type. Required. - :vartype audience: str - """ - - audience: Required[str] - """Authentication scope for managed_identity auth type. Required.""" - - -class OpenApiProjectConnectionAuthDetails(TypedDict, total=False): - """Security details for OpenApi project connection authentication. - - :ivar type: The object type, which is always 'project_connection'. Required. - PROJECT_CONNECTION. - :vartype type: str or ~azure.ai.projects.models.PROJECT_CONNECTION - :ivar security_scheme: Project connection auth security details. Required. - :vartype security_scheme: ~azure.ai.projects.types.OpenApiProjectConnectionSecurityScheme - """ - - type: Required[Literal[OpenApiAuthType.PROJECT_CONNECTION]] - """The object type, which is always 'project_connection'. Required. PROJECT_CONNECTION.""" - security_scheme: Required["OpenApiProjectConnectionSecurityScheme"] - """Project connection auth security details. Required.""" - - -class OpenApiProjectConnectionSecurityScheme(TypedDict, total=False): - """Security scheme for OpenApi managed_identity authentication. - - :ivar project_connection_id: Project connection id for Project Connection auth type. Required. - :vartype project_connection_id: str - """ - - project_connection_id: Required[str] - """Project connection id for Project Connection auth type. Required.""" - - -class OpenApiTool(TypedDict, total=False): - """The input definition information for an OpenAPI tool as used to configure an agent. - - :ivar type: The object type, which is always 'openapi'. Required. OPENAPI. - :vartype type: str or ~azure.ai.projects.models.OPENAPI - :ivar openapi: The openapi function definition. Required. - :vartype openapi: ~azure.ai.projects.types.OpenApiFunctionDefinition - """ - - type: Required[Literal[ToolType.OPENAPI]] - """The object type, which is always 'openapi'. Required. OPENAPI.""" - openapi: Required["OpenApiFunctionDefinition"] - """The openapi function definition. Required.""" - - -class PendingUploadRequest(TypedDict, total=False): - """Represents a request for a pending upload. - - :ivar pending_upload_id: If PendingUploadId is not provided, a random GUID will be used. - :vartype pending_upload_id: str - :ivar connection_name: Azure Storage Account connection name to use for generating temporary - SAS token. - :vartype connection_name: str - :ivar pending_upload_type: BlobReference is the only supported type. Required. Blob Reference - is the only supported type. - :vartype pending_upload_type: str or ~azure.ai.projects.models.BLOB_REFERENCE - """ - - pendingUploadId: str - """If PendingUploadId is not provided, a random GUID will be used.""" - connectionName: str - """Azure Storage Account connection name to use for generating temporary SAS token.""" - pendingUploadType: Required[Literal[PendingUploadType.BLOB_REFERENCE]] - """BlobReference is the only supported type. Required. Blob Reference is the only supported type.""" - - -class PendingUploadResponse(TypedDict, total=False): - """Represents the response for a pending upload request. - - :ivar blob_reference: Container-level read, write, list SAS. Required. - :vartype blob_reference: ~azure.ai.projects.types.BlobReference - :ivar pending_upload_id: ID for this upload request. Required. - :vartype pending_upload_id: str - :ivar version: Version of asset to be created if user did not specify version when initially - creating upload. - :vartype version: str - :ivar pending_upload_type: BlobReference is the only supported type. Required. Blob Reference - is the only supported type. - :vartype pending_upload_type: str or ~azure.ai.projects.models.BLOB_REFERENCE - """ - - blobReference: Required["BlobReference"] - """Container-level read, write, list SAS. Required.""" - pendingUploadId: Required[str] - """ID for this upload request. Required.""" - version: str - """Version of asset to be created if user did not specify version when initially creating upload.""" - pendingUploadType: Required[Literal[PendingUploadType.BLOB_REFERENCE]] - """BlobReference is the only supported type. Required. Blob Reference is the only supported type.""" - - -class PromptAgentDefinition(TypedDict, total=False): - """The prompt agent definition. - - :ivar rai_config: Configuration for Responsible AI (RAI) content filtering and safety features. - :vartype rai_config: ~azure.ai.projects.types.RaiConfig - :ivar kind: Required. PROMPT. - :vartype kind: str or ~azure.ai.projects.models.PROMPT - :ivar model: The model deployment to use for this agent. Required. - :vartype model: str - :ivar instructions: A system (or developer) message inserted into the model's context. - :vartype instructions: str - :ivar temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 - will make the output more random, while lower values like 0.2 will make it more focused and - deterministic. We generally recommend altering this or ``top_p`` but not both. - :vartype temperature: float - :ivar top_p: 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. - :vartype top_p: float - :ivar reasoning: - :vartype reasoning: ~azure.ai.projects.types.Reasoning - :ivar tools: An array of tools the model may call while generating a response. You can specify - which tool to use by setting the ``tool_choice`` parameter. - :vartype tools: list[~azure.ai.projects.types.Tool] - :ivar tool_choice: How the model should select which tool (or tools) to use when generating a - response. See the ``tools`` parameter to see how to specify which tools the model can call. Is - either a str type or a ToolChoiceParam type. - :vartype tool_choice: str or ~azure.ai.projects.types.ToolChoiceParam - :ivar text: Configuration options for a text response from the model. Can be plain text or - structured JSON data. - :vartype text: ~azure.ai.projects.types.PromptAgentDefinitionTextOptions - :ivar structured_inputs: Set of structured inputs that can participate in prompt template - substitution or tool argument bindings. - :vartype structured_inputs: dict[str, ~azure.ai.projects.types.StructuredInputDefinition] - """ - - rai_config: "RaiConfig" - """Configuration for Responsible AI (RAI) content filtering and safety features.""" - kind: Required[Literal[AgentKind.PROMPT]] - """Required. PROMPT.""" - model: Required[str] - """The model deployment to use for this agent. Required.""" - instructions: Optional[str] - """A system (or developer) message inserted into the model's context.""" - temperature: Optional[float] - """What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output - more random, while lower values like 0.2 will make it more focused and deterministic. We - generally recommend altering this or ``top_p`` but not both.""" - top_p: Optional[float] - """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.""" - reasoning: Optional["Reasoning"] - tools: list["Tool"] - """An array of tools the model may call while generating a response. You can specify which tool to - use by setting the ``tool_choice`` parameter.""" - tool_choice: Union[str, "ToolChoiceParam"] - """How the model should select which tool (or tools) to use when generating a response. See the - ``tools`` parameter to see how to specify which tools the model can call. Is either a str type - or a ToolChoiceParam type.""" - text: "PromptAgentDefinitionTextOptions" - """Configuration options for a text response from the model. Can be plain text or structured JSON - data.""" - structured_inputs: dict[str, "StructuredInputDefinition"] - """Set of structured inputs that can participate in prompt template substitution or tool argument - bindings.""" - - -class PromptAgentDefinitionTextOptions(TypedDict, total=False): - """Configuration options for a text response from the model. Can be plain text or structured JSON - data. - - :ivar format: - :vartype format: ~azure.ai.projects.types.TextResponseFormat - """ - - format: "TextResponseFormat" - - -class PromptBasedEvaluatorDefinition(TypedDict, total=False): - """Prompt-based evaluator. - - :ivar init_parameters: The JSON schema (Draft 2020-12) for the evaluator's input parameters. - This includes parameters like type, properties, required. - :vartype init_parameters: dict[str, any] - :ivar data_schema: The JSON schema (Draft 2020-12) for the evaluator's input data. This - includes parameters like type, properties, required. - :vartype data_schema: dict[str, any] - :ivar metrics: List of output metrics produced by this evaluator. - :vartype metrics: dict[str, ~azure.ai.projects.types.EvaluatorMetric] - :ivar type: Required. Prompt-based definition. - :vartype type: str or ~azure.ai.projects.models.PROMPT - :ivar prompt_text: The prompt text used for evaluation. Required. - :vartype prompt_text: str - """ - - init_parameters: dict[str, Any] - """The JSON schema (Draft 2020-12) for the evaluator's input parameters. This includes parameters - like type, properties, required.""" - data_schema: dict[str, Any] - """The JSON schema (Draft 2020-12) for the evaluator's input data. This includes parameters like - type, properties, required.""" - metrics: dict[str, "EvaluatorMetric"] - """List of output metrics produced by this evaluator.""" - type: Required[Literal[EvaluatorDefinitionType.PROMPT]] - """Required. Prompt-based definition.""" - prompt_text: Required[str] - """The prompt text used for evaluation. Required.""" - - -class ProtocolVersionRecord(TypedDict, total=False): - """A record mapping for a single protocol and its version. - - :ivar protocol: The protocol type. Required. Known values are: "activity_protocol" and - "responses". - :vartype protocol: str or ~azure.ai.projects.models.AgentProtocol - :ivar version: The version string for the protocol, e.g. 'v0.1.1'. Required. - :vartype version: str - """ - - protocol: Required[AgentProtocol] - """The protocol type. Required. Known values are: \"activity_protocol\" and \"responses\".""" - version: Required[str] - """The version string for the protocol, e.g. 'v0.1.1'. Required.""" - - -class RaiConfig(TypedDict, total=False): - """Configuration for Responsible AI (RAI) content filtering and safety features. - - :ivar rai_policy_name: The name of the RAI policy to apply. Required. - :vartype rai_policy_name: str - """ - - rai_policy_name: Required[str] - """The name of the RAI policy to apply. Required.""" - - -class RankingOptions(TypedDict, total=False): - """RankingOptions. - - :ivar ranker: The ranker to use for the file search. Known values are: "auto" and - "default-2024-11-15". - :vartype ranker: str or ~azure.ai.projects.models.RankerVersionType - :ivar score_threshold: The score threshold for the file search, a number between 0 and 1. - Numbers closer to 1 will attempt to return only the most relevant results, but may return fewer - results. - :vartype score_threshold: float - :ivar hybrid_search: Weights that control how reciprocal rank fusion balances semantic - embedding matches versus sparse keyword matches when hybrid search is enabled. - :vartype hybrid_search: ~azure.ai.projects.types.HybridSearchOptions - """ - - ranker: RankerVersionType - """The ranker to use for the file search. Known values are: \"auto\" and \"default-2024-11-15\".""" - score_threshold: float - """The score threshold for the file search, a number between 0 and 1. Numbers closer to 1 will - attempt to return only the most relevant results, but may return fewer results.""" - hybrid_search: "HybridSearchOptions" - """Weights that control how reciprocal rank fusion balances semantic embedding matches versus - sparse keyword matches when hybrid search is enabled.""" - - -class Reasoning(TypedDict, total=False): - """Reasoning. - - :ivar effort: Is one of the following types: Literal["none"], Literal["minimal"], - Literal["low"], Literal["medium"], Literal["high"], Literal["xhigh"] - :vartype effort: str or str or str or str or str or str - :ivar summary: Is one of the following types: Literal["auto"], Literal["concise"], - Literal["detailed"] - :vartype summary: str or str or str - :ivar generate_summary: Is one of the following types: Literal["auto"], Literal["concise"], - Literal["detailed"] - :vartype generate_summary: str or str or str - """ - - effort: Optional[Literal["none", "minimal", "low", "medium", "high", "xhigh"]] - """Is one of the following types: Literal[\"none\"], Literal[\"minimal\"], Literal[\"low\"], - Literal[\"medium\"], Literal[\"high\"], Literal[\"xhigh\"]""" - summary: Optional[Literal["auto", "concise", "detailed"]] - """Is one of the following types: Literal[\"auto\"], Literal[\"concise\"], Literal[\"detailed\"]""" - generate_summary: Optional[Literal["auto", "concise", "detailed"]] - """Is one of the following types: Literal[\"auto\"], Literal[\"concise\"], Literal[\"detailed\"]""" - - -class RecurrenceTrigger(TypedDict, total=False): - """Recurrence based trigger. - - :ivar type: Type of the trigger. Required. Recurrence based trigger. - :vartype type: str or ~azure.ai.projects.models.RECURRENCE - :ivar start_time: Start time for the recurrence schedule in ISO 8601 format. - :vartype start_time: ~datetime.datetime - :ivar end_time: End time for the recurrence schedule in ISO 8601 format. - :vartype end_time: ~datetime.datetime - :ivar time_zone: Time zone for the recurrence schedule. - :vartype time_zone: str - :ivar interval: Interval for the recurrence schedule. Required. - :vartype interval: int - :ivar schedule: Recurrence schedule for the recurrence trigger. Required. - :vartype schedule: ~azure.ai.projects.types.RecurrenceSchedule - """ - - type: Required[Literal[TriggerType.RECURRENCE]] - """Type of the trigger. Required. Recurrence based trigger.""" - startTime: str - """Start time for the recurrence schedule in ISO 8601 format.""" - endTime: str - """End time for the recurrence schedule in ISO 8601 format.""" - timeZone: str - """Time zone for the recurrence schedule.""" - interval: Required[int] - """Interval for the recurrence schedule. Required.""" - schedule: Required["RecurrenceSchedule"] - """Recurrence schedule for the recurrence trigger. Required.""" - - -class RedTeam(TypedDict, total=False): - """Red team details. - - :ivar name: Identifier of the red team run. Required. - :vartype name: str - :ivar display_name: Name of the red-team run. - :vartype display_name: str - :ivar num_turns: Number of simulation rounds. - :vartype num_turns: int - :ivar attack_strategies: List of attack strategies or nested lists of attack strategies. - :vartype attack_strategies: list[str or ~azure.ai.projects.models.AttackStrategy] - :ivar simulation_only: Simulation-only or Simulation + Evaluation. Default false, if true the - scan outputs conversation not evaluation result. - :vartype simulation_only: bool - :ivar risk_categories: List of risk categories to generate attack objectives for. - :vartype risk_categories: list[str or ~azure.ai.projects.models.RiskCategory] - :ivar application_scenario: Application scenario for the red team operation, to generate - scenario specific attacks. - :vartype application_scenario: str - :ivar tags: Red team's tags. Unlike properties, tags are fully mutable. - :vartype tags: dict[str, str] - :ivar properties: Red team's properties. Unlike tags, properties are add-only. Once added, a - property cannot be removed. - :vartype properties: dict[str, str] - :ivar status: Status of the red-team. It is set by service and is read-only. - :vartype status: str - :ivar target: Target configuration for the red-team run. Required. - :vartype target: ~azure.ai.projects.types.TargetConfig - """ - - id: Required[str] - """Identifier of the red team run. Required.""" - displayName: str - """Name of the red-team run.""" - numTurns: int - """Number of simulation rounds.""" - attackStrategies: list[AttackStrategy] - """List of attack strategies or nested lists of attack strategies.""" - simulationOnly: bool - """Simulation-only or Simulation + Evaluation. Default false, if true the scan outputs - conversation not evaluation result.""" - riskCategories: list[RiskCategory] - """List of risk categories to generate attack objectives for.""" - applicationScenario: str - """Application scenario for the red team operation, to generate scenario specific attacks.""" - tags: dict[str, str] - """Red team's tags. Unlike properties, tags are fully mutable.""" - properties: dict[str, str] - """Red team's properties. Unlike tags, properties are add-only. Once added, a property cannot be - removed.""" - status: str - """Status of the red-team. It is set by service and is read-only.""" - target: Required["TargetConfig"] - """Target configuration for the red-team run. Required.""" - - -class ResponseUsageInputTokensDetails(TypedDict, total=False): - """ResponseUsageInputTokensDetails. - - :ivar cached_tokens: Required. - :vartype cached_tokens: int - """ - - cached_tokens: Required[int] - """Required.""" - - -class ResponseUsageOutputTokensDetails(TypedDict, total=False): - """ResponseUsageOutputTokensDetails. - - :ivar reasoning_tokens: Required. - :vartype reasoning_tokens: int - """ - - reasoning_tokens: Required[int] - """Required.""" - - -class SASCredentials(TypedDict, total=False): - """Shared Access Signature (SAS) credential definition. - - :ivar type: The credential type. Required. Shared Access Signature (SAS) credential. - :vartype type: str or ~azure.ai.projects.models.SAS - :ivar sas_token: SAS token. - :vartype sas_token: str - """ - - type: Required[Literal[CredentialType.SAS]] - """The credential type. Required. Shared Access Signature (SAS) credential.""" - SAS: str - """SAS token.""" - - -class Schedule(TypedDict, total=False): - """Schedule model. - - :ivar schedule_id: Identifier of the schedule. Required. - :vartype schedule_id: str - :ivar display_name: Name of the schedule. - :vartype display_name: str - :ivar description: Description of the schedule. - :vartype description: str - :ivar enabled: Enabled status of the schedule. Required. - :vartype enabled: bool - :ivar provisioning_status: Provisioning status of the schedule. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", and "Failed". - :vartype provisioning_status: str or ~azure.ai.projects.models.ScheduleProvisioningStatus - :ivar trigger: Trigger for the schedule. Required. - :vartype trigger: ~azure.ai.projects.types.Trigger - :ivar task: Task for the schedule. Required. - :vartype task: ~azure.ai.projects.types.ScheduleTask - :ivar tags: Schedule's tags. Unlike properties, tags are fully mutable. - :vartype tags: dict[str, str] - :ivar properties: Schedule's properties. Unlike tags, properties are add-only. Once added, a - property cannot be removed. - :vartype properties: dict[str, str] - :ivar system_data: System metadata for the resource. Required. - :vartype system_data: dict[str, str] - """ - - id: Required[str] - """Identifier of the schedule. Required.""" - displayName: str - """Name of the schedule.""" - description: str - """Description of the schedule.""" - enabled: Required[bool] - """Enabled status of the schedule. Required.""" - provisioningStatus: ScheduleProvisioningStatus - """Provisioning status of the schedule. Known values are: \"Creating\", \"Updating\", - \"Deleting\", \"Succeeded\", and \"Failed\".""" - trigger: Required["Trigger"] - """Trigger for the schedule. Required.""" - task: Required["ScheduleTask"] - """Task for the schedule. Required.""" - tags: dict[str, str] - """Schedule's tags. Unlike properties, tags are fully mutable.""" - properties: dict[str, str] - """Schedule's properties. Unlike tags, properties are add-only. Once added, a property cannot be - removed.""" - systemData: Required[dict[str, str]] - """System metadata for the resource. Required.""" - - -class ScheduleRun(TypedDict, total=False): - """Schedule run model. - - :ivar run_id: Identifier of the schedule run. Required. - :vartype run_id: str - :ivar schedule_id: Identifier of the schedule. Required. - :vartype schedule_id: str - :ivar success: Trigger success status of the schedule run. Required. - :vartype success: bool - :ivar trigger_time: Trigger time of the schedule run. - :vartype trigger_time: ~datetime.datetime - :ivar error: Error information for the schedule run. - :vartype error: str - :ivar properties: Properties of the schedule run. Required. - :vartype properties: dict[str, str] - """ - - id: Required[str] - """Identifier of the schedule run. Required.""" - scheduleId: Required[str] - """Identifier of the schedule. Required.""" - success: Required[bool] - """Trigger success status of the schedule run. Required.""" - triggerTime: str - """Trigger time of the schedule run.""" - error: str - """Error information for the schedule run.""" - properties: Required[dict[str, str]] - """Properties of the schedule run. Required.""" - - -class SharepointGroundingToolParameters(TypedDict, total=False): - """The sharepoint grounding tool parameters. - - :ivar project_connections: The project connections attached to this tool. There can be a - maximum of 1 connection resource attached to the tool. - :vartype project_connections: list[~azure.ai.projects.types.ToolProjectConnection] - """ - - project_connections: list["ToolProjectConnection"] - """The project connections attached to this tool. There can be a maximum of 1 connection resource - attached to the tool.""" - - -class SharepointPreviewTool(TypedDict, total=False): - """The input definition information for a sharepoint tool as used to configure an agent. - - :ivar type: The object type, which is always 'sharepoint_grounding_preview'. Required. - SHAREPOINT_GROUNDING_PREVIEW. - :vartype type: str or ~azure.ai.projects.models.SHAREPOINT_GROUNDING_PREVIEW - :ivar sharepoint_grounding_preview: The sharepoint grounding tool parameters. Required. - :vartype sharepoint_grounding_preview: - ~azure.ai.projects.types.SharepointGroundingToolParameters - """ - - type: Required[Literal[ToolType.SHAREPOINT_GROUNDING_PREVIEW]] - """The object type, which is always 'sharepoint_grounding_preview'. Required. - SHAREPOINT_GROUNDING_PREVIEW.""" - sharepoint_grounding_preview: Required["SharepointGroundingToolParameters"] - """The sharepoint grounding tool parameters. Required.""" - - -class SkillReferenceParam(TypedDict, total=False): - """SkillReferenceParam. - - :ivar type: References a skill created with the /v1/skills endpoint. Required. SKILL_REFERENCE. - :vartype type: str or ~azure.ai.projects.models.SKILL_REFERENCE - :ivar skill_id: The ID of the referenced skill. Required. - :vartype skill_id: str - :ivar version: Optional skill version. Use a positive integer or 'latest'. Omit for default. - :vartype version: str - """ - - type: Required[Literal[ContainerSkillType.SKILL_REFERENCE]] - """References a skill created with the /v1/skills endpoint. Required. SKILL_REFERENCE.""" - skill_id: Required[str] - """The ID of the referenced skill. Required.""" - version: str - """Optional skill version. Use a positive integer or 'latest'. Omit for default.""" - - -class SpecificApplyPatchParam(TypedDict, total=False): - """Specific apply patch tool choice. - - :ivar type: The tool to call. Always ``apply_patch``. Required. APPLY_PATCH. - :vartype type: str or ~azure.ai.projects.models.APPLY_PATCH - """ - - type: Required[Literal[ToolChoiceParamType.APPLY_PATCH]] - """The tool to call. Always ``apply_patch``. Required. APPLY_PATCH.""" - - -class SpecificFunctionShellParam(TypedDict, total=False): - """Specific shell tool choice. - - :ivar type: The tool to call. Always ``shell``. Required. SHELL. - :vartype type: str or ~azure.ai.projects.models.SHELL - """ - - type: Required[Literal[ToolChoiceParamType.SHELL]] - """The tool to call. Always ``shell``. Required. SHELL.""" - - -class StructuredInputDefinition(TypedDict, total=False): - """An structured input that can participate in prompt template substitutions and tool argument - binding. - - :ivar description: A human-readable description of the input. - :vartype description: str - :ivar default_value: The default value for the input if no run-time value is provided. - :vartype default_value: any - :ivar schema: The JSON schema for the structured input (optional). - :vartype schema: dict[str, any] - :ivar required: Whether the input property is required when the agent is invoked. - :vartype required: bool - """ - - description: str - """A human-readable description of the input.""" - default_value: Any - """The default value for the input if no run-time value is provided.""" - schema: dict[str, Any] - """The JSON schema for the structured input (optional).""" - required: bool - """Whether the input property is required when the agent is invoked.""" - - -class StructuredOutputDefinition(TypedDict, total=False): - """A structured output that can be produced by the agent. - - :ivar name: The name of the structured output. Required. - :vartype name: str - :ivar description: A description of the output to emit. Used by the model to determine when to - emit the output. Required. - :vartype description: str - :ivar schema: The JSON schema for the structured output. Required. - :vartype schema: dict[str, any] - :ivar strict: Whether to enforce strict validation. Default ``true``. Required. - :vartype strict: bool - """ - - name: Required[str] - """The name of the structured output. Required.""" - description: Required[str] - """A description of the output to emit. Used by the model to determine when to emit the output. - Required.""" - schema: Required[dict[str, Any]] - """The JSON schema for the structured output. Required.""" - strict: Required[Optional[bool]] - """Whether to enforce strict validation. Default ``true``. Required.""" - - -class TaxonomyCategory(TypedDict, total=False): - """Taxonomy category definition. - - :ivar id: Unique identifier of the taxonomy category. Required. - :vartype id: str - :ivar name: Name of the taxonomy category. Required. - :vartype name: str - :ivar description: Description of the taxonomy category. - :vartype description: str - :ivar risk_category: Risk category associated with this taxonomy category. Required. Known - values are: "HateUnfairness", "Violence", "Sexual", "SelfHarm", "ProtectedMaterial", - "CodeVulnerability", "UngroundedAttributes", "ProhibitedActions", "SensitiveDataLeakage", and - "TaskAdherence". - :vartype risk_category: str or ~azure.ai.projects.models.RiskCategory - :ivar sub_categories: List of taxonomy sub categories. Required. - :vartype sub_categories: list[~azure.ai.projects.types.TaxonomySubCategory] - :ivar properties: Additional properties for the taxonomy category. - :vartype properties: dict[str, str] - """ - - id: Required[str] - """Unique identifier of the taxonomy category. Required.""" - name: Required[str] - """Name of the taxonomy category. Required.""" - description: str - """Description of the taxonomy category.""" - riskCategory: Required[RiskCategory] - """Risk category associated with this taxonomy category. Required. Known values are: - \"HateUnfairness\", \"Violence\", \"Sexual\", \"SelfHarm\", \"ProtectedMaterial\", - \"CodeVulnerability\", \"UngroundedAttributes\", \"ProhibitedActions\", - \"SensitiveDataLeakage\", and \"TaskAdherence\".""" - subCategories: Required[list["TaxonomySubCategory"]] - """List of taxonomy sub categories. Required.""" - properties: dict[str, str] - """Additional properties for the taxonomy category.""" - - -class TaxonomySubCategory(TypedDict, total=False): - """Taxonomy sub-category definition. - - :ivar id: Unique identifier of the taxonomy sub-category. Required. - :vartype id: str - :ivar name: Name of the taxonomy sub-category. Required. - :vartype name: str - :ivar description: Description of the taxonomy sub-category. - :vartype description: str - :ivar enabled: List of taxonomy items under this sub-category. Required. - :vartype enabled: bool - :ivar properties: Additional properties for the taxonomy sub-category. - :vartype properties: dict[str, str] - """ - - id: Required[str] - """Unique identifier of the taxonomy sub-category. Required.""" - name: Required[str] - """Name of the taxonomy sub-category. Required.""" - description: str - """Description of the taxonomy sub-category.""" - enabled: Required[bool] - """List of taxonomy items under this sub-category. Required.""" - properties: dict[str, str] - """Additional properties for the taxonomy sub-category.""" - - -class TextResponseFormatJsonObject(TypedDict, total=False): - """JSON object. - - :ivar type: The type of response format being defined. Always ``json_object``. Required. - JSON_OBJECT. - :vartype type: str or ~azure.ai.projects.models.JSON_OBJECT - """ - - type: Required[Literal[TextResponseFormatConfigurationType.JSON_OBJECT]] - """The type of response format being defined. Always ``json_object``. Required. JSON_OBJECT.""" - - -class TextResponseFormatJsonSchema(TypedDict, total=False): - """JSON schema. - - :ivar type: The type of response format being defined. Always ``json_schema``. Required. - JSON_SCHEMA. - :vartype type: str or ~azure.ai.projects.models.JSON_SCHEMA - :ivar description: A description of what the response format is for, used by the model to - determine how to respond in the format. - :vartype description: str - :ivar name: The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and - dashes, with a maximum length of 64. Required. - :vartype name: str - :ivar schema: Required. - :vartype schema: dict[str, any] - :ivar strict: - :vartype strict: bool - """ - - type: Required[Literal[TextResponseFormatConfigurationType.JSON_SCHEMA]] - """The type of response format being defined. Always ``json_schema``. Required. JSON_SCHEMA.""" - description: str - """A description of what the response format is for, used by the model to determine how to respond - in the format.""" - name: Required[str] - """The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with - a maximum length of 64. Required.""" - schema: Required[dict[str, Any]] - """Required.""" - strict: Optional[bool] - - -class TextResponseFormatText(TypedDict, total=False): - """Text. - - :ivar type: The type of response format being defined. Always ``text``. Required. TEXT. - :vartype type: str or ~azure.ai.projects.models.TEXT - """ - - type: Required[Literal[TextResponseFormatConfigurationType.TEXT]] - """The type of response format being defined. Always ``text``. Required. TEXT.""" - - -class ToolChoiceAllowed(TypedDict, total=False): - """Allowed tools. - - :ivar type: Allowed tool configuration type. Always ``allowed_tools``. Required. ALLOWED_TOOLS. - :vartype type: str or ~azure.ai.projects.models.ALLOWED_TOOLS - :ivar mode: Constrains the tools available to the model to a pre-defined set. ``auto`` allows - the model to pick from among the allowed tools and generate a message. ``required`` requires - the model to call one or more of the allowed tools. Required. Is either a Literal["auto"] type - or a Literal["required"] type. - :vartype mode: str or str - :ivar tools: A list of tool definitions that the model should be allowed to call. For the - Responses API, the list of tool definitions might look like: - - .. code-block:: json - - [ - { "type": "function", "name": "get_weather" }, - { "type": "mcp", "server_label": "deepwiki" }, - { "type": "image_generation" } - ]. Required. - :vartype tools: list[dict[str, any]] - """ - - type: Required[Literal[ToolChoiceParamType.ALLOWED_TOOLS]] - """Allowed tool configuration type. Always ``allowed_tools``. Required. ALLOWED_TOOLS.""" - mode: Required[Literal["auto", "required"]] - """Constrains the tools available to the model to a pre-defined set. ``auto`` allows the model to - pick from among the allowed tools and generate a message. ``required`` requires the model to - call one or more of the allowed tools. Required. Is either a Literal[\"auto\"] type or a - Literal[\"required\"] type.""" - tools: Required[list[dict[str, Any]]] - """A list of tool definitions that the model should be allowed to call. For the Responses API, the - list of tool definitions might look like: - - .. code-block:: json - - [ - { \"type\": \"function\", \"name\": \"get_weather\" }, - { \"type\": \"mcp\", \"server_label\": \"deepwiki\" }, - { \"type\": \"image_generation\" } - ]. Required.""" - - -class ToolChoiceCodeInterpreter(TypedDict, total=False): - """Indicates that the model should use a built-in tool to generate a response. `Learn more about - built-in tools `_. - - :ivar type: Required. CODE_INTERPRETER. - :vartype type: str or ~azure.ai.projects.models.CODE_INTERPRETER - """ - - type: Required[Literal[ToolChoiceParamType.CODE_INTERPRETER]] - """Required. CODE_INTERPRETER.""" - - -class ToolChoiceComputerUsePreview(TypedDict, total=False): - """Indicates that the model should use a built-in tool to generate a response. `Learn more about - built-in tools `_. - - :ivar type: Required. COMPUTER_USE_PREVIEW. - :vartype type: str or ~azure.ai.projects.models.COMPUTER_USE_PREVIEW - """ - - type: Required[Literal[ToolChoiceParamType.COMPUTER_USE_PREVIEW]] - """Required. COMPUTER_USE_PREVIEW.""" - - -class ToolChoiceCustom(TypedDict, total=False): - """Custom tool. - - :ivar type: For custom tool calling, the type is always ``custom``. Required. CUSTOM. - :vartype type: str or ~azure.ai.projects.models.CUSTOM - :ivar name: The name of the custom tool to call. Required. - :vartype name: str - """ - - type: Required[Literal[ToolChoiceParamType.CUSTOM]] - """For custom tool calling, the type is always ``custom``. Required. CUSTOM.""" - name: Required[str] - """The name of the custom tool to call. Required.""" - - -class ToolChoiceFileSearch(TypedDict, total=False): - """Indicates that the model should use a built-in tool to generate a response. `Learn more about - built-in tools `_. - - :ivar type: Required. FILE_SEARCH. - :vartype type: str or ~azure.ai.projects.models.FILE_SEARCH - """ - - type: Required[Literal[ToolChoiceParamType.FILE_SEARCH]] - """Required. FILE_SEARCH.""" - - -class ToolChoiceFunction(TypedDict, total=False): - """Function tool. - - :ivar type: For function calling, the type is always ``function``. Required. FUNCTION. - :vartype type: str or ~azure.ai.projects.models.FUNCTION - :ivar name: The name of the function to call. Required. - :vartype name: str - """ - - type: Required[Literal[ToolChoiceParamType.FUNCTION]] - """For function calling, the type is always ``function``. Required. FUNCTION.""" - name: Required[str] - """The name of the function to call. Required.""" - - -class ToolChoiceImageGeneration(TypedDict, total=False): - """Indicates that the model should use a built-in tool to generate a response. `Learn more about - built-in tools `_. - - :ivar type: Required. IMAGE_GENERATION. - :vartype type: str or ~azure.ai.projects.models.IMAGE_GENERATION - """ - - type: Required[Literal[ToolChoiceParamType.IMAGE_GENERATION]] - """Required. IMAGE_GENERATION.""" - - -class ToolChoiceMCP(TypedDict, total=False): - """MCP tool. - - :ivar type: For MCP tools, the type is always ``mcp``. Required. MCP. - :vartype type: str or ~azure.ai.projects.models.MCP - :ivar server_label: The label of the MCP server to use. Required. - :vartype server_label: str - :ivar name: - :vartype name: str - """ - - type: Required[Literal[ToolChoiceParamType.MCP]] - """For MCP tools, the type is always ``mcp``. Required. MCP.""" - server_label: Required[str] - """The label of the MCP server to use. Required.""" - name: Optional[str] - - -class ToolChoiceWebSearchPreview(TypedDict, total=False): - """Indicates that the model should use a built-in tool to generate a response. `Learn more about - built-in tools `_. - - :ivar type: Required. WEB_SEARCH_PREVIEW. - :vartype type: str or ~azure.ai.projects.models.WEB_SEARCH_PREVIEW - """ - - type: Required[Literal[ToolChoiceParamType.WEB_SEARCH_PREVIEW]] - """Required. WEB_SEARCH_PREVIEW.""" - - -class ToolChoiceWebSearchPreview20250311(TypedDict, total=False): - """Indicates that the model should use a built-in tool to generate a response. `Learn more about - built-in tools `_. - - :ivar type: Required. WEB_SEARCH_PREVIEW2025_03_11. - :vartype type: str or ~azure.ai.projects.models.WEB_SEARCH_PREVIEW2025_03_11 - """ - - type: Required[Literal[ToolChoiceParamType.WEB_SEARCH_PREVIEW2025_03_11]] - """Required. WEB_SEARCH_PREVIEW2025_03_11.""" - - -class ToolDescription(TypedDict, total=False): - """Description of a tool that can be used by an agent. - - :ivar name: The name of the tool. - :vartype name: str - :ivar description: A brief description of the tool's purpose. - :vartype description: str - """ - - name: str - """The name of the tool.""" - description: str - """A brief description of the tool's purpose.""" - - -class ToolProjectConnection(TypedDict, total=False): - """A project connection resource. - - :ivar project_connection_id: A project connection in a ToolProjectConnectionList attached to - this tool. Required. - :vartype project_connection_id: str - """ - - project_connection_id: Required[str] - """A project connection in a ToolProjectConnectionList attached to this tool. Required.""" - - -class UserProfileMemoryItem(TypedDict, total=False): - """A memory item specifically containing user profile information extracted from conversations, - such as preferences, interests, and personal details. - - :ivar memory_id: The unique ID of the memory item. Required. - :vartype memory_id: str - :ivar updated_at: The last update time of the memory item. Required. - :vartype updated_at: ~datetime.datetime - :ivar scope: The namespace that logically groups and isolates memories, such as a user ID. - Required. - :vartype scope: str - :ivar content: The content of the memory. Required. - :vartype content: str - :ivar kind: The kind of the memory item. Required. User profile information extracted from - conversations. - :vartype kind: str or ~azure.ai.projects.models.USER_PROFILE - """ - - memory_id: Required[str] - """The unique ID of the memory item. Required.""" - updated_at: Required[int] - """The last update time of the memory item. Required.""" - scope: Required[str] - """The namespace that logically groups and isolates memories, such as a user ID. Required.""" - content: Required[str] - """The content of the memory. Required.""" - kind: Required[Literal[MemoryItemKind.USER_PROFILE]] - """The kind of the memory item. Required. User profile information extracted from conversations.""" - - -class WebSearchApproximateLocation(TypedDict, total=False): - """Web search approximate location. - - :ivar type: The type of location approximation. Always ``approximate``. Required. Default value - is "approximate". - :vartype type: str - :ivar country: - :vartype country: str - :ivar region: - :vartype region: str - :ivar city: - :vartype city: str - :ivar timezone: - :vartype timezone: str - """ - - type: Required[Literal["approximate"]] - """The type of location approximation. Always ``approximate``. Required. Default value is - \"approximate\".""" - country: Optional[str] - region: Optional[str] - city: Optional[str] - timezone: Optional[str] - - -class WebSearchConfiguration(TypedDict, total=False): - """A web search configuration for bing custom search. - - :ivar project_connection_id: Project connection id for grounding with bing custom search. - Required. - :vartype project_connection_id: str - :ivar instance_name: Name of the custom configuration instance given to config. Required. - :vartype instance_name: str - """ - - project_connection_id: Required[str] - """Project connection id for grounding with bing custom search. Required.""" - instance_name: Required[str] - """Name of the custom configuration instance given to config. Required.""" - - -class WebSearchPreviewTool(TypedDict, total=False): - """Web search preview. - - :ivar type: The type of the web search tool. One of ``web_search_preview`` or - ``web_search_preview_2025_03_11``. Required. WEB_SEARCH_PREVIEW. - :vartype type: str or ~azure.ai.projects.models.WEB_SEARCH_PREVIEW - :ivar user_location: - :vartype user_location: ~azure.ai.projects.types.ApproximateLocation - :ivar search_context_size: High level guidance for the amount of context window space to use - for the search. One of ``low``, ``medium``, or ``high``. ``medium`` is the default. Known - values are: "low", "medium", and "high". - :vartype search_context_size: str or ~azure.ai.projects.models.SearchContextSize - """ - - type: Required[Literal[ToolType.WEB_SEARCH_PREVIEW]] - """The type of the web search tool. One of ``web_search_preview`` or - ``web_search_preview_2025_03_11``. Required. WEB_SEARCH_PREVIEW.""" - user_location: Optional["ApproximateLocation"] - search_context_size: SearchContextSize - """High level guidance for the amount of context window space to use for the search. One of - ``low``, ``medium``, or ``high``. ``medium`` is the default. Known values are: \"low\", - \"medium\", and \"high\".""" - - -class WebSearchTool(TypedDict, total=False): - """Web search. - - :ivar type: The type of the web search tool. One of ``web_search`` or - ``web_search_2025_08_26``. Required. WEB_SEARCH. - :vartype type: str or ~azure.ai.projects.models.WEB_SEARCH - :ivar filters: - :vartype filters: ~azure.ai.projects.types.WebSearchToolFilters - :ivar user_location: - :vartype user_location: ~azure.ai.projects.types.WebSearchApproximateLocation - :ivar search_context_size: High level guidance for the amount of context window space to use - for the search. One of ``low``, ``medium``, or ``high``. ``medium`` is the default. Is one of - the following types: Literal["low"], Literal["medium"], Literal["high"] - :vartype search_context_size: str or str or str - :ivar custom_search_configuration: The project connections attached to this tool. There can be - a maximum of 1 connection resource attached to the tool. - :vartype custom_search_configuration: ~azure.ai.projects.types.WebSearchConfiguration - """ - - type: Required[Literal[ToolType.WEB_SEARCH]] - """The type of the web search tool. One of ``web_search`` or ``web_search_2025_08_26``. Required. - WEB_SEARCH.""" - filters: Optional["WebSearchToolFilters"] - user_location: Optional["WebSearchApproximateLocation"] - search_context_size: Literal["low", "medium", "high"] - """High level guidance for the amount of context window space to use for the search. One of - ``low``, ``medium``, or ``high``. ``medium`` is the default. Is one of the following types: - Literal[\"low\"], Literal[\"medium\"], Literal[\"high\"]""" - custom_search_configuration: "WebSearchConfiguration" - """The project connections attached to this tool. There can be a maximum of 1 connection resource - attached to the tool.""" - - -class WebSearchToolFilters(TypedDict, total=False): - """WebSearchToolFilters. - - :ivar allowed_domains: - :vartype allowed_domains: list[str] - """ - - allowed_domains: Optional[list[str]] - - -class WeeklyRecurrenceSchedule(TypedDict, total=False): - """Weekly recurrence schedule. - - :ivar type: Weekly recurrence type. Required. Weekly recurrence pattern. - :vartype type: str or ~azure.ai.projects.models.WEEKLY - :ivar days_of_week: Days of the week for the recurrence schedule. Required. - :vartype days_of_week: list[str or ~azure.ai.projects.models.DayOfWeek] - """ - - type: Required[Literal[RecurrenceType.WEEKLY]] - """Weekly recurrence type. Required. Weekly recurrence pattern.""" - daysOfWeek: Required[list[DayOfWeek]] - """Days of the week for the recurrence schedule. Required.""" - - -class WorkflowAgentDefinition(TypedDict, total=False): - """The workflow agent definition. - - :ivar rai_config: Configuration for Responsible AI (RAI) content filtering and safety features. - :vartype rai_config: ~azure.ai.projects.types.RaiConfig - :ivar kind: Required. WORKFLOW. - :vartype kind: str or ~azure.ai.projects.models.WORKFLOW - :ivar workflow: The CSDL YAML definition of the workflow. - :vartype workflow: str - """ - - rai_config: "RaiConfig" - """Configuration for Responsible AI (RAI) content filtering and safety features.""" - kind: Required[Literal[AgentKind.WORKFLOW]] - """Required. WORKFLOW.""" - workflow: str - """The CSDL YAML definition of the workflow.""" - - -Tool = Union[ - A2APreviewTool, - ApplyPatchToolParam, - AzureAISearchTool, - AzureFunctionTool, - BingCustomSearchPreviewTool, - BingGroundingTool, - BrowserAutomationPreviewTool, - CaptureStructuredOutputsTool, - CodeInterpreterTool, - ComputerUsePreviewTool, - CustomToolParam, - MicrosoftFabricPreviewTool, - FileSearchTool, - FunctionTool, - ImageGenTool, - LocalShellToolParam, - MCPTool, - MemorySearchPreviewTool, - OpenApiTool, - SharepointPreviewTool, - FunctionShellToolParam, - WebSearchTool, - WebSearchPreviewTool, -] -InsightRequest = Union[ - AgentClusterInsightRequest, EvaluationComparisonInsightRequest, EvaluationRunClusterInsightRequest -] -InsightResult = Union[AgentClusterInsightResult, EvaluationComparisonInsightResult, EvaluationRunClusterInsightResult] -AgentDefinition = Union[HostedAgentDefinition, PromptAgentDefinition, WorkflowAgentDefinition] -BaseCredentials = Union[ - EntraIDCredentials, - AgenticIdentityPreviewCredentials, - ApiKeyCredentials, - CustomCredential, - NoAuthenticationCredentials, - SASCredentials, -] -EvaluationTaxonomyInput = Union[AgentTaxonomyInput] -Target = Union[AzureAIAgentTarget, AzureAIModelTarget] -Index = Union[AzureAISearchIndex, CosmosDBIndex, ManagedAzureAISearchIndex] -TargetConfig = Union[AzureOpenAIModelConfiguration] -MemoryItem = Union[ChatSummaryMemoryItem, UserProfileMemoryItem] -EvaluatorDefinition = Union[CodeBasedEvaluatorDefinition, PromptBasedEvaluatorDefinition] -FunctionShellToolParamEnvironment = Union[ - ContainerAutoParam, - FunctionShellToolParamEnvironmentContainerReferenceParam, - FunctionShellToolParamEnvironmentLocalEnvironmentParam, -] -ContainerNetworkPolicyParam = Union[ContainerNetworkPolicyAllowlistParam, ContainerNetworkPolicyDisabledParam] -ContainerSkill = Union[InlineSkillParam, SkillReferenceParam] -EvaluationRuleAction = Union[ContinuousEvaluationRuleAction, HumanEvaluationPreviewRuleAction] -Trigger = Union[CronTrigger, OneTimeTrigger, RecurrenceTrigger] -CustomToolParamFormat = Union[CustomGrammarFormatParam, CustomTextFormatParam] -RecurrenceSchedule = Union[ - DailyRecurrenceSchedule, HourlyRecurrenceSchedule, MonthlyRecurrenceSchedule, WeeklyRecurrenceSchedule -] -DatasetVersion = Union[FileDatasetVersion, FolderDatasetVersion] -Deployment = Union[ModelDeployment] -InsightSample = Union[EvaluationResultSample] -ScheduleTask = Union[EvaluationScheduleTask, InsightScheduleTask] -MemoryStoreDefinition = Union[MemoryStoreDefaultDefinition] -OpenApiAuthDetails = Union[OpenApiAnonymousAuthDetails, OpenApiManagedAuthDetails, OpenApiProjectConnectionAuthDetails] -ToolChoiceParam = Union[ - ToolChoiceAllowed, - SpecificApplyPatchParam, - ToolChoiceCodeInterpreter, - ToolChoiceComputerUsePreview, - ToolChoiceCustom, - ToolChoiceFileSearch, - ToolChoiceFunction, - ToolChoiceImageGeneration, - ToolChoiceMCP, - SpecificFunctionShellParam, - ToolChoiceWebSearchPreview, - ToolChoiceWebSearchPreview20250311, -] -TextResponseFormat = Union[TextResponseFormatJsonObject, TextResponseFormatJsonSchema, TextResponseFormatText]