diff --git a/sdk/voiceagents/azure-ai-voiceagents/CHANGELOG.md b/sdk/voiceagents/azure-ai-voiceagents/CHANGELOG.md new file mode 100644 index 000000000000..d5783dcd33e6 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/CHANGELOG.md @@ -0,0 +1,7 @@ +# Release History + +## 1.0.0b1 (2026-08-06) + +### Other Changes + +- Initial version diff --git a/sdk/voiceagents/azure-ai-voiceagents/LICENSE b/sdk/voiceagents/azure-ai-voiceagents/LICENSE new file mode 100644 index 000000000000..63447fd8bbbf --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/LICENSE @@ -0,0 +1,21 @@ +Copyright (c) Microsoft Corporation. + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/sdk/voiceagents/azure-ai-voiceagents/MANIFEST.in b/sdk/voiceagents/azure-ai-voiceagents/MANIFEST.in new file mode 100644 index 000000000000..40653212ffad --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/MANIFEST.in @@ -0,0 +1,7 @@ +include *.md +include LICENSE +include azure/ai/voiceagents/py.typed +recursive-include tests *.py +recursive-include samples *.py *.md +include azure/__init__.py +include azure/ai/__init__.py diff --git a/sdk/voiceagents/azure-ai-voiceagents/README.md b/sdk/voiceagents/azure-ai-voiceagents/README.md new file mode 100644 index 000000000000..7e6e2c82f869 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/README.md @@ -0,0 +1,93 @@ +# Azure AI Voice Agents client library for Python + +The Azure AI Voice Agents client library provides APIs for creating and managing +voice agents in an Azure AI Foundry project, reading persisted voice +conversations, and connecting to a voice agent over a realtime WebSocket session. + +Use this package to: + +- Generate or create voice agents with model, instruction, voice, and tool settings. +- Manage voice agent versions and operational state. +- Stream live microphone audio to an existing voice agent and receive spoken responses. +- Read persisted conversation transcripts and audio when an agent is configured to store them. + +## Getting started + +### Install the package + +```bash +python -m pip install azure-ai-voiceagents +``` + +### Prerequisites + +- Python 3.10 or later is required to use this package. +- You need an [Azure subscription][azure_sub]. +- You need an Azure AI Foundry project endpoint, for example + `https://.services.ai.azure.com/api/projects/`. +- For Microsoft Entra ID authentication, install [`azure-identity`][azure_identity_pip]. +- For realtime async WebSocket sessions, install an async transport such as `aiohttp`. + +### Authenticate the client + +The client supports token credentials from the +[`azure-identity`][azure_identity_credentials] library. For example, +[`DefaultAzureCredential`][default_azure_credential] can authenticate from your +developer environment or configured application identity. + +```python +from azure.ai.voiceagents import VoiceAgentsClient +from azure.identity import DefaultAzureCredential + +client = VoiceAgentsClient( + endpoint="https://.services.ai.azure.com/api/projects/", + credential=DefaultAzureCredential(), +) +``` + +## Examples + +Create a voice agents client and list the voice agents in a project: + +```python +from azure.ai.voiceagents import VoiceAgentsClient +from azure.ai.voiceagents.models import AgentDefinitionOptInKeys +from azure.identity import DefaultAzureCredential + +client = VoiceAgentsClient( + endpoint="https://.services.ai.azure.com/api/projects/", + credential=DefaultAzureCredential(), +) + +for agent in client.voice_agents.list_voice_agents( + foundry_features=AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW +): + print(agent.name) +``` + +See the [samples on GitHub](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/voiceagents/azure-ai-voiceagents/samples) +for management, quickstart, and realtime conversation examples. + +## Contributing + +This project welcomes contributions and suggestions. Most contributions require +you to agree to a Contributor License Agreement (CLA) declaring that you have +the right to, and actually do, grant us the rights to use your contribution. +For details, visit . + +When you submit a pull request, a CLA-bot will automatically determine whether +you need to provide a CLA and decorate the PR appropriately (e.g., label, +comment). Simply follow the instructions provided by the bot. You will only +need to do this once across all repos using our CLA. + +This project has adopted the +[Microsoft Open Source Code of Conduct][code_of_conduct]. For more information, +see the Code of Conduct FAQ or contact with any +additional questions or comments. + + +[code_of_conduct]: https://opensource.microsoft.com/codeofconduct/ +[azure_identity_credentials]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#credentials +[azure_identity_pip]: https://pypi.org/project/azure-identity/ +[default_azure_credential]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#defaultazurecredential +[azure_sub]: https://azure.microsoft.com/free/ diff --git a/sdk/voiceagents/azure-ai-voiceagents/_metadata.json b/sdk/voiceagents/azure-ai-voiceagents/_metadata.json new file mode 100644 index 000000000000..3a000fe50d57 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/_metadata.json @@ -0,0 +1,6 @@ +{ + "apiVersion": "v1", + "apiVersions": { + "Azure.AI.Projects": "v1" + } +} \ No newline at end of file diff --git a/sdk/voiceagents/azure-ai-voiceagents/apiview-properties.json b/sdk/voiceagents/azure-ai-voiceagents/apiview-properties.json new file mode 100644 index 000000000000..8d7e108d309c --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/apiview-properties.json @@ -0,0 +1,380 @@ +{ + "CrossLanguagePackageId": "Azure.AI.Projects", + "CrossLanguageDefinitionId": { + "azure.ai.voiceagents.models.A2AProtocolConfiguration": "Azure.AI.Projects.A2AProtocolConfiguration", + "azure.ai.voiceagents.models.ActivityProtocolConfiguration": "Azure.AI.Projects.ActivityProtocolConfiguration", + "azure.ai.voiceagents.models.AgentBlueprintReference": "Azure.AI.Projects.AgentBlueprintReference", + "azure.ai.voiceagents.models.AgentCard": "Azure.AI.Projects.AgentCard", + "azure.ai.voiceagents.models.AgentCardSkill": "Azure.AI.Projects.AgentCardSkill", + "azure.ai.voiceagents.models.AgentEndpointAuthorizationScheme": "Azure.AI.Projects.AgentEndpointAuthorizationScheme", + "azure.ai.voiceagents.models.AgentEndpointConfig": "Azure.AI.Projects.AgentEndpointConfig", + "azure.ai.voiceagents.models.AgentIdentity": "Azure.AI.Projects.AgentIdentity", + "azure.ai.voiceagents.models.ApiErrorResponse": "Azure.AI.Projects.ApiErrorResponse", + "azure.ai.voiceagents.models.AzureVoice": "Azure.AI.Projects.AzureVoice", + "azure.ai.voiceagents.models.AzureAvatarVoiceSyncVoice": "Azure.AI.Projects.AzureAvatarVoiceSyncVoice", + "azure.ai.voiceagents.models.AzureCustomVoice": "Azure.AI.Projects.AzureCustomVoice", + "azure.ai.voiceagents.models.AzurePersonalVoice": "Azure.AI.Projects.AzurePersonalVoice", + "azure.ai.voiceagents.models.AzureRealtimeNativeVoice": "Azure.AI.Projects.AzureRealtimeNativeVoice", + "azure.ai.voiceagents.models.AzureStandardVoice": "Azure.AI.Projects.AzureStandardVoice", + "azure.ai.voiceagents.models.BotServiceAuthorizationScheme": "Azure.AI.Projects.BotServiceAuthorizationScheme", + "azure.ai.voiceagents.models.BotServiceRbacAuthorizationScheme": "Azure.AI.Projects.BotServiceRbacAuthorizationScheme", + "azure.ai.voiceagents.models.BotServiceTenantAuthorizationScheme": "Azure.AI.Projects.BotServiceTenantAuthorizationScheme", + "azure.ai.voiceagents.models.CreateTranscriptionResponseJsonUsage": "OpenAI.CreateTranscriptionResponseJsonUsage", + "azure.ai.voiceagents.models.EntraAuthorizationScheme": "Azure.AI.Projects.EntraAuthorizationScheme", + "azure.ai.voiceagents.models.Error": "OpenAI.Error", + "azure.ai.voiceagents.models.VersionSelectionRule": "Azure.AI.Projects.VersionSelectionRule", + "azure.ai.voiceagents.models.FixedRatioVersionSelectionRule": "Azure.AI.Projects.FixedRatioVersionSelectionRule", + "azure.ai.voiceagents.models.InvocationsProtocolConfiguration": "Azure.AI.Projects.InvocationsProtocolConfiguration", + "azure.ai.voiceagents.models.InvocationsWsProtocolConfiguration": "Azure.AI.Projects.InvocationsWsProtocolConfiguration", + "azure.ai.voiceagents.models.VoiceGreetingConfig": "Azure.AI.Projects.VoiceGreetingConfig", + "azure.ai.voiceagents.models.LlmGeneratedVoiceGreetingConfig": "Azure.AI.Projects.LlmGeneratedVoiceGreetingConfig", + "azure.ai.voiceagents.models.LogProbProperties": "OpenAI.LogProbProperties", + "azure.ai.voiceagents.models.ManagedAgentIdentityBlueprintReference": "Azure.AI.Projects.ManagedAgentIdentityBlueprintReference", + "azure.ai.voiceagents.models.MCPListToolsTool": "OpenAI.MCPListToolsTool", + "azure.ai.voiceagents.models.MCPListToolsToolAnnotations": "OpenAI.MCPListToolsToolAnnotations", + "azure.ai.voiceagents.models.MCPListToolsToolInputSchema": "OpenAI.MCPListToolsToolInputSchema", + "azure.ai.voiceagents.models.McpProtocolConfiguration": "Azure.AI.Projects.McpProtocolConfiguration", + "azure.ai.voiceagents.models.Tool": "OpenAI.Tool", + "azure.ai.voiceagents.models.MCPTool": "OpenAI.MCPTool", + "azure.ai.voiceagents.models.MCPToolFilter": "OpenAI.MCPToolFilter", + "azure.ai.voiceagents.models.MCPToolRequireApproval": "OpenAI.MCPToolRequireApproval", + "azure.ai.voiceagents.models.Metadata": "OpenAI.Metadata", + "azure.ai.voiceagents.models.OpenAIVoice": "Azure.AI.Projects.OpenAIVoice", + "azure.ai.voiceagents.models.ProtocolConfiguration": "Azure.AI.Projects.ProtocolConfiguration", + "azure.ai.voiceagents.models.RaiConfig": "Azure.AI.Projects.RaiConfig", + "azure.ai.voiceagents.models.RealtimeAudioFormats": "OpenAI.RealtimeAudioFormats", + "azure.ai.voiceagents.models.RealtimeAudioFormatsAudioPcm": "OpenAI.RealtimeAudioFormatsAudioPcm", + "azure.ai.voiceagents.models.RealtimeAudioFormatsAudioPcma": "OpenAI.RealtimeAudioFormatsAudioPcma", + "azure.ai.voiceagents.models.RealtimeAudioFormatsAudioPcmu": "OpenAI.RealtimeAudioFormatsAudioPcmu", + "azure.ai.voiceagents.models.RealtimeConversationItem": "OpenAI.RealtimeConversationItem", + "azure.ai.voiceagents.models.RealtimeConversationItemFunctionCall": "OpenAI.RealtimeConversationItemFunctionCall", + "azure.ai.voiceagents.models.RealtimeConversationItemFunctionCallOutput": "OpenAI.RealtimeConversationItemFunctionCallOutput", + "azure.ai.voiceagents.models.RealtimeConversationItemMessage": "OpenAI.RealtimeConversationItemMessage", + "azure.ai.voiceagents.models.RealtimeConversationItemMessageAssistant": "OpenAI.RealtimeConversationItemMessageAssistant", + "azure.ai.voiceagents.models.RealtimeConversationItemMessageAssistantContent": "OpenAI.RealtimeConversationItemMessageAssistantContent", + "azure.ai.voiceagents.models.RealtimeConversationItemMessageSystem": "OpenAI.RealtimeConversationItemMessageSystem", + "azure.ai.voiceagents.models.RealtimeConversationItemMessageSystemContent": "OpenAI.RealtimeConversationItemMessageSystemContent", + "azure.ai.voiceagents.models.RealtimeConversationItemMessageUser": "OpenAI.RealtimeConversationItemMessageUser", + "azure.ai.voiceagents.models.RealtimeConversationItemMessageUserContent": "OpenAI.RealtimeConversationItemMessageUserContent", + "azure.ai.voiceagents.models.RealtimeFunctionTool": "OpenAI.RealtimeFunctionTool", + "azure.ai.voiceagents.models.RealtimeFunctionToolParameters": "OpenAI.RealtimeFunctionToolParameters", + "azure.ai.voiceagents.models.RealtimeMCPApprovalRequest": "OpenAI.RealtimeMCPApprovalRequest", + "azure.ai.voiceagents.models.RealtimeMCPApprovalResponse": "OpenAI.RealtimeMCPApprovalResponse", + "azure.ai.voiceagents.models.RealtimeMCPError": "OpenAI.RealtimeMCPError", + "azure.ai.voiceagents.models.RealtimeMCPHTTPError": "OpenAI.RealtimeMCPHTTPError", + "azure.ai.voiceagents.models.RealtimeMCPListTools": "OpenAI.RealtimeMCPListTools", + "azure.ai.voiceagents.models.RealtimeMCPProtocolError": "OpenAI.RealtimeMCPProtocolError", + "azure.ai.voiceagents.models.RealtimeMCPToolCall": "OpenAI.RealtimeMCPToolCall", + "azure.ai.voiceagents.models.RealtimeMCPToolExecutionError": "OpenAI.RealtimeMCPToolExecutionError", + "azure.ai.voiceagents.models.RealtimeReasoning": "OpenAI.RealtimeReasoning", + "azure.ai.voiceagents.models.RealtimeResponseStatusDetails": "OpenAI.RealtimeResponseStatusDetails", + "azure.ai.voiceagents.models.RealtimeResponseStatusDetailsError": "OpenAI.RealtimeResponseStatusDetailsError", + "azure.ai.voiceagents.models.RealtimeResponseUsage": "OpenAI.RealtimeResponseUsage", + "azure.ai.voiceagents.models.RealtimeResponseUsageInputTokenDetails": "OpenAI.RealtimeResponseUsageInputTokenDetails", + "azure.ai.voiceagents.models.RealtimeResponseUsageInputTokenDetailsCachedTokensDetails": "OpenAI.RealtimeResponseUsageInputTokenDetailsCachedTokensDetails", + "azure.ai.voiceagents.models.RealtimeResponseUsageOutputTokenDetails": "OpenAI.RealtimeResponseUsageOutputTokenDetails", + "azure.ai.voiceagents.models.RealtimeServerEvent": "OpenAI.RealtimeServerEvent", + "azure.ai.voiceagents.models.RealtimeServerEventConversationItemInputAudioTranscriptionFailedError": "OpenAI.RealtimeServerEventConversationItemInputAudioTranscriptionFailedError", + "azure.ai.voiceagents.models.RealtimeServerEventRateLimitsUpdatedRateLimits": "OpenAI.RealtimeServerEventRateLimitsUpdatedRateLimits", + "azure.ai.voiceagents.models.RealtimeServerEventResponseContentPartAdded": "OpenAI.RealtimeServerEventResponseContentPartAdded", + "azure.ai.voiceagents.models.RealtimeServerEventResponseContentPartAddedPart": "OpenAI.RealtimeServerEventResponseContentPartAddedPart", + "azure.ai.voiceagents.models.RealtimeToolChoiceFunction": "OpenAI.RealtimeToolChoiceFunction", + "azure.ai.voiceagents.models.ResponsesProtocolConfiguration": "Azure.AI.Projects.ResponsesProtocolConfiguration", + "azure.ai.voiceagents.models.StructuredInputDefinition": "Azure.AI.Projects.StructuredInputDefinition", + "azure.ai.voiceagents.models.TemplateVoiceGreetingConfig": "Azure.AI.Projects.TemplateVoiceGreetingConfig", + "azure.ai.voiceagents.models.ToolChoiceParam": "OpenAI.ToolChoiceParam", + "azure.ai.voiceagents.models.ToolChoiceFunction": "OpenAI.ToolChoiceFunction", + "azure.ai.voiceagents.models.ToolChoiceMCP": "OpenAI.ToolChoiceMCP", + "azure.ai.voiceagents.models.ToolConfig": "Azure.AI.Projects.ToolConfig", + "azure.ai.voiceagents.models.TranscriptTextUsageDuration": "OpenAI.TranscriptTextUsageDuration", + "azure.ai.voiceagents.models.TranscriptTextUsageTokens": "OpenAI.TranscriptTextUsageTokens", + "azure.ai.voiceagents.models.TranscriptTextUsageTokensInputTokenDetails": "OpenAI.TranscriptTextUsageTokensInputTokenDetails", + "azure.ai.voiceagents.models.VersionSelector": "Azure.AI.Projects.VersionSelector", + "azure.ai.voiceagents.models.VoiceAgentAnimationConfig": "Azure.AI.Projects.VoiceAgentAnimationConfig", + "azure.ai.voiceagents.models.VoiceAgentAvatarIceServer": "Azure.AI.Projects.VoiceAgentAvatarIceServer", + "azure.ai.voiceagents.models.VoiceAgentAvatarScene": "Azure.AI.Projects.VoiceAgentAvatarScene", + "azure.ai.voiceagents.models.VoiceAgentAvatarVideoBackground": "Azure.AI.Projects.VoiceAgentAvatarVideoBackground", + "azure.ai.voiceagents.models.VoiceAgentAvatarVideoCrop": "Azure.AI.Projects.VoiceAgentAvatarVideoCrop", + "azure.ai.voiceagents.models.VoiceAgentAvatarVideoParams": "Azure.AI.Projects.VoiceAgentAvatarVideoParams", + "azure.ai.voiceagents.models.VoiceAgentAvatarVideoResolution": "Azure.AI.Projects.VoiceAgentAvatarVideoResolution", + "azure.ai.voiceagents.models.VoiceAgentAzureMultilingualSemanticVadTurnDetection": "Azure.AI.Projects.VoiceAgentAzureMultilingualSemanticVadTurnDetection", + "azure.ai.voiceagents.models.VoiceAgentAzureSemanticVadTurnDetection": "Azure.AI.Projects.VoiceAgentAzureSemanticVadTurnDetection", + "azure.ai.voiceagents.models.VoiceAgentClientEventConversationItemCreate": "Azure.AI.Projects.VoiceAgentClientEventConversationItemCreate", + "azure.ai.voiceagents.models.VoiceAgentClientEventConversationItemDelete": "Azure.AI.Projects.VoiceAgentClientEventConversationItemDelete", + "azure.ai.voiceagents.models.VoiceAgentClientEventConversationItemRetrieve": "Azure.AI.Projects.VoiceAgentClientEventConversationItemRetrieve", + "azure.ai.voiceagents.models.VoiceAgentClientEventConversationItemTruncate": "Azure.AI.Projects.VoiceAgentClientEventConversationItemTruncate", + "azure.ai.voiceagents.models.VoiceAgentClientEventInputAudioBufferAppend": "Azure.AI.Projects.VoiceAgentClientEventInputAudioBufferAppend", + "azure.ai.voiceagents.models.VoiceAgentClientEventInputAudioBufferClear": "Azure.AI.Projects.VoiceAgentClientEventInputAudioBufferClear", + "azure.ai.voiceagents.models.VoiceAgentClientEventInputAudioBufferCommit": "Azure.AI.Projects.VoiceAgentClientEventInputAudioBufferCommit", + "azure.ai.voiceagents.models.VoiceAgentClientEventOutputAudioBufferClear": "Azure.AI.Projects.VoiceAgentClientEventOutputAudioBufferClear", + "azure.ai.voiceagents.models.VoiceAgentClientEventResponseCancel": "Azure.AI.Projects.VoiceAgentClientEventResponseCancel", + "azure.ai.voiceagents.models.VoiceAgentClientEventResponseCreate": "Azure.AI.Projects.VoiceAgentClientEventResponseCreate", + "azure.ai.voiceagents.models.VoiceAgentClientEventSessionAvatarConnect": "Azure.AI.Projects.VoiceAgentClientEventSessionAvatarConnect", + "azure.ai.voiceagents.models.VoiceAgentClientEventSessionUpdate": "Azure.AI.Projects.VoiceAgentClientEventSessionUpdate", + "azure.ai.voiceagents.models.VoiceAgentDefinition": "Azure.AI.Projects.VoiceAgentDefinition", + "azure.ai.voiceagents.models.VoiceAgentEchoCancellation": "Azure.AI.Projects.VoiceAgentEchoCancellation", + "azure.ai.voiceagents.models.VoiceAgentEndOfUtteranceDetection": "Azure.AI.Projects.VoiceAgentEndOfUtteranceDetection", + "azure.ai.voiceagents.models.VoiceAgentEstimatedCost": "Azure.AI.Projects.VoiceAgentEstimatedCost", + "azure.ai.voiceagents.models.VoiceAgentFileSearchCallItem": "Azure.AI.Projects.VoiceAgentFileSearchCallItem", + "azure.ai.voiceagents.models.VoiceAgentFileSearchResult": "Azure.AI.Projects.VoiceAgentFileSearchResult", + "azure.ai.voiceagents.models.VoiceAgentHandoffEdgeConfig": "Azure.AI.Projects.VoiceAgentHandoffEdgeConfig", + "azure.ai.voiceagents.models.VoiceAgentHandoffEdgeState": "Azure.AI.Projects.VoiceAgentHandoffEdgeState", + "azure.ai.voiceagents.models.VoiceAgentHandoffGraphConfig": "Azure.AI.Projects.VoiceAgentHandoffGraphConfig", + "azure.ai.voiceagents.models.VoiceAgentHandoffNodeConfig": "Azure.AI.Projects.VoiceAgentHandoffNodeConfig", + "azure.ai.voiceagents.models.VoiceAgentHandoffNodeSessionConfig": "Azure.AI.Projects.VoiceAgentHandoffNodeSessionConfig", + "azure.ai.voiceagents.models.VoiceAgentHandoffNodeState": "Azure.AI.Projects.VoiceAgentHandoffNodeState", + "azure.ai.voiceagents.models.VoiceAgentHandoffState": "Azure.AI.Projects.VoiceAgentHandoffState", + "azure.ai.voiceagents.models.VoiceAgentInterimResponseConfig": "Azure.AI.Projects.VoiceAgentInterimResponseConfig", + "azure.ai.voiceagents.models.VoiceAgentLlmInterimResponseConfig": "Azure.AI.Projects.VoiceAgentLlmInterimResponseConfig", + "azure.ai.voiceagents.models.VoiceAgentMcpAssignedManagedIdentity": "Azure.AI.Projects.VoiceAgentMcpAssignedManagedIdentity", + "azure.ai.voiceagents.models.VoiceAgentMcpTool": "Azure.AI.Projects.VoiceAgentMcpTool", + "azure.ai.voiceagents.models.VoiceAgentObject": "Azure.AI.Projects.VoiceAgentObject", + "azure.ai.voiceagents.models.VoiceAgentObjectVersions": "Azure.AI.Projects.VoiceAgentObject.versions.anonymous", + "azure.ai.voiceagents.models.VoiceAgentRealtimeResponse": "Azure.AI.Projects.VoiceAgentRealtimeResponse", + "azure.ai.voiceagents.models.VoiceAgentResponseCreateAudio": "Azure.AI.Projects.VoiceAgentResponseCreateAudio", + "azure.ai.voiceagents.models.VoiceAgentResponseCreateParams": "Azure.AI.Projects.VoiceAgentResponseCreateParams", + "azure.ai.voiceagents.models.VoiceAgentResponseEventAudioContentPart": "Azure.AI.Projects.VoiceAgentResponseEventAudioContentPart", + "azure.ai.voiceagents.models.VoiceAgentResponseEventTextContentPart": "Azure.AI.Projects.VoiceAgentResponseEventTextContentPart", + "azure.ai.voiceagents.models.VoiceAgentSemanticVadTurnDetection": "Azure.AI.Projects.VoiceAgentSemanticVadTurnDetection", + "azure.ai.voiceagents.models.VoiceAgentServerEventConversationCreated": "Azure.AI.Projects.VoiceAgentServerEventConversationCreated", + "azure.ai.voiceagents.models.VoiceAgentServerEventConversationItemAdded": "Azure.AI.Projects.VoiceAgentServerEventConversationItemAdded", + "azure.ai.voiceagents.models.VoiceAgentServerEventConversationItemCreated": "Azure.AI.Projects.VoiceAgentServerEventConversationItemCreated", + "azure.ai.voiceagents.models.VoiceAgentServerEventConversationItemDeleted": "Azure.AI.Projects.VoiceAgentServerEventConversationItemDeleted", + "azure.ai.voiceagents.models.VoiceAgentServerEventConversationItemDone": "Azure.AI.Projects.VoiceAgentServerEventConversationItemDone", + "azure.ai.voiceagents.models.VoiceAgentServerEventConversationItemInputAudioTranscriptionCompleted": "Azure.AI.Projects.VoiceAgentServerEventConversationItemInputAudioTranscriptionCompleted", + "azure.ai.voiceagents.models.VoiceAgentServerEventConversationItemInputAudioTranscriptionDelta": "Azure.AI.Projects.VoiceAgentServerEventConversationItemInputAudioTranscriptionDelta", + "azure.ai.voiceagents.models.VoiceAgentServerEventConversationItemInputAudioTranscriptionFailed": "Azure.AI.Projects.VoiceAgentServerEventConversationItemInputAudioTranscriptionFailed", + "azure.ai.voiceagents.models.VoiceAgentServerEventConversationItemInputAudioTranscriptionSegment": "Azure.AI.Projects.VoiceAgentServerEventConversationItemInputAudioTranscriptionSegment", + "azure.ai.voiceagents.models.VoiceAgentServerEventConversationItemRetrieved": "Azure.AI.Projects.VoiceAgentServerEventConversationItemRetrieved", + "azure.ai.voiceagents.models.VoiceAgentServerEventConversationItemTruncated": "Azure.AI.Projects.VoiceAgentServerEventConversationItemTruncated", + "azure.ai.voiceagents.models.VoiceAgentServerEventError": "Azure.AI.Projects.VoiceAgentServerEventError", + "azure.ai.voiceagents.models.VoiceAgentServerEventErrorDetails": "Azure.AI.Projects.VoiceAgentServerEventErrorDetails", + "azure.ai.voiceagents.models.VoiceAgentServerEventFileSearchCallCompleted": "Azure.AI.Projects.VoiceAgentServerEventFileSearchCallCompleted", + "azure.ai.voiceagents.models.VoiceAgentServerEventFileSearchCallInProgress": "Azure.AI.Projects.VoiceAgentServerEventFileSearchCallInProgress", + "azure.ai.voiceagents.models.VoiceAgentServerEventFileSearchCallSearching": "Azure.AI.Projects.VoiceAgentServerEventFileSearchCallSearching", + "azure.ai.voiceagents.models.VoiceAgentServerEventInputAudioBufferCleared": "Azure.AI.Projects.VoiceAgentServerEventInputAudioBufferCleared", + "azure.ai.voiceagents.models.VoiceAgentServerEventInputAudioBufferCommitted": "Azure.AI.Projects.VoiceAgentServerEventInputAudioBufferCommitted", + "azure.ai.voiceagents.models.VoiceAgentServerEventInputAudioBufferSpeechStarted": "Azure.AI.Projects.VoiceAgentServerEventInputAudioBufferSpeechStarted", + "azure.ai.voiceagents.models.VoiceAgentServerEventInputAudioBufferSpeechStopped": "Azure.AI.Projects.VoiceAgentServerEventInputAudioBufferSpeechStopped", + "azure.ai.voiceagents.models.VoiceAgentServerEventInputAudioBufferTimeoutTriggered": "Azure.AI.Projects.VoiceAgentServerEventInputAudioBufferTimeoutTriggered", + "azure.ai.voiceagents.models.VoiceAgentServerEventMcpListToolsCompleted": "Azure.AI.Projects.VoiceAgentServerEventMcpListToolsCompleted", + "azure.ai.voiceagents.models.VoiceAgentServerEventMcpListToolsFailed": "Azure.AI.Projects.VoiceAgentServerEventMcpListToolsFailed", + "azure.ai.voiceagents.models.VoiceAgentServerEventMcpListToolsInProgress": "Azure.AI.Projects.VoiceAgentServerEventMcpListToolsInProgress", + "azure.ai.voiceagents.models.VoiceAgentServerEventOutputAudioBufferCleared": "Azure.AI.Projects.VoiceAgentServerEventOutputAudioBufferCleared", + "azure.ai.voiceagents.models.VoiceAgentServerEventRateLimitsUpdated": "Azure.AI.Projects.VoiceAgentServerEventRateLimitsUpdated", + "azure.ai.voiceagents.models.VoiceAgentServerEventResponseAnimationBlendshapesDelta": "Azure.AI.Projects.VoiceAgentServerEventResponseAnimationBlendshapesDelta", + "azure.ai.voiceagents.models.VoiceAgentServerEventResponseAnimationBlendshapesDone": "Azure.AI.Projects.VoiceAgentServerEventResponseAnimationBlendshapesDone", + "azure.ai.voiceagents.models.VoiceAgentServerEventResponseAnimationVisemeDelta": "Azure.AI.Projects.VoiceAgentServerEventResponseAnimationVisemeDelta", + "azure.ai.voiceagents.models.VoiceAgentServerEventResponseAnimationVisemeDone": "Azure.AI.Projects.VoiceAgentServerEventResponseAnimationVisemeDone", + "azure.ai.voiceagents.models.VoiceAgentServerEventResponseAudioDelta": "Azure.AI.Projects.VoiceAgentServerEventResponseAudioDelta", + "azure.ai.voiceagents.models.VoiceAgentServerEventResponseAudioDone": "Azure.AI.Projects.VoiceAgentServerEventResponseAudioDone", + "azure.ai.voiceagents.models.VoiceAgentServerEventResponseAudioTimestampDelta": "Azure.AI.Projects.VoiceAgentServerEventResponseAudioTimestampDelta", + "azure.ai.voiceagents.models.VoiceAgentServerEventResponseAudioTimestampDone": "Azure.AI.Projects.VoiceAgentServerEventResponseAudioTimestampDone", + "azure.ai.voiceagents.models.VoiceAgentServerEventResponseAudioTranscriptDelta": "Azure.AI.Projects.VoiceAgentServerEventResponseAudioTranscriptDelta", + "azure.ai.voiceagents.models.VoiceAgentServerEventResponseAudioTranscriptDone": "Azure.AI.Projects.VoiceAgentServerEventResponseAudioTranscriptDone", + "azure.ai.voiceagents.models.VoiceAgentServerEventResponseContentPartDone": "Azure.AI.Projects.VoiceAgentServerEventResponseContentPartDone", + "azure.ai.voiceagents.models.VoiceAgentServerEventResponseCreated": "Azure.AI.Projects.VoiceAgentServerEventResponseCreated", + "azure.ai.voiceagents.models.VoiceAgentServerEventResponseDone": "Azure.AI.Projects.VoiceAgentServerEventResponseDone", + "azure.ai.voiceagents.models.VoiceAgentServerEventResponseFunctionCallArgumentsDelta": "Azure.AI.Projects.VoiceAgentServerEventResponseFunctionCallArgumentsDelta", + "azure.ai.voiceagents.models.VoiceAgentServerEventResponseFunctionCallArgumentsDone": "Azure.AI.Projects.VoiceAgentServerEventResponseFunctionCallArgumentsDone", + "azure.ai.voiceagents.models.VoiceAgentServerEventResponseMcpCallArgumentsDelta": "Azure.AI.Projects.VoiceAgentServerEventResponseMcpCallArgumentsDelta", + "azure.ai.voiceagents.models.VoiceAgentServerEventResponseMcpCallArgumentsDone": "Azure.AI.Projects.VoiceAgentServerEventResponseMcpCallArgumentsDone", + "azure.ai.voiceagents.models.VoiceAgentServerEventResponseMcpCallCompleted": "Azure.AI.Projects.VoiceAgentServerEventResponseMcpCallCompleted", + "azure.ai.voiceagents.models.VoiceAgentServerEventResponseMcpCallFailed": "Azure.AI.Projects.VoiceAgentServerEventResponseMcpCallFailed", + "azure.ai.voiceagents.models.VoiceAgentServerEventResponseMcpCallInProgress": "Azure.AI.Projects.VoiceAgentServerEventResponseMcpCallInProgress", + "azure.ai.voiceagents.models.VoiceAgentServerEventResponseOutputItemAdded": "Azure.AI.Projects.VoiceAgentServerEventResponseOutputItemAdded", + "azure.ai.voiceagents.models.VoiceAgentServerEventResponseOutputItemDone": "Azure.AI.Projects.VoiceAgentServerEventResponseOutputItemDone", + "azure.ai.voiceagents.models.VoiceAgentServerEventResponseTextDelta": "Azure.AI.Projects.VoiceAgentServerEventResponseTextDelta", + "azure.ai.voiceagents.models.VoiceAgentServerEventResponseTextDone": "Azure.AI.Projects.VoiceAgentServerEventResponseTextDone", + "azure.ai.voiceagents.models.VoiceAgentServerEventResponseVideoDelta": "Azure.AI.Projects.VoiceAgentServerEventResponseVideoDelta", + "azure.ai.voiceagents.models.VoiceAgentServerEventSessionAvatarConnecting": "Azure.AI.Projects.VoiceAgentServerEventSessionAvatarConnecting", + "azure.ai.voiceagents.models.VoiceAgentServerEventSessionAvatarSwitchToIdle": "Azure.AI.Projects.VoiceAgentServerEventSessionAvatarSwitchToIdle", + "azure.ai.voiceagents.models.VoiceAgentServerEventSessionAvatarSwitchToSpeaking": "Azure.AI.Projects.VoiceAgentServerEventSessionAvatarSwitchToSpeaking", + "azure.ai.voiceagents.models.VoiceAgentServerEventSessionCreated": "Azure.AI.Projects.VoiceAgentServerEventSessionCreated", + "azure.ai.voiceagents.models.VoiceAgentServerEventSessionHandoffAborted": "Azure.AI.Projects.VoiceAgentServerEventSessionHandoffAborted", + "azure.ai.voiceagents.models.VoiceAgentServerEventSessionHandoffCompleted": "Azure.AI.Projects.VoiceAgentServerEventSessionHandoffCompleted", + "azure.ai.voiceagents.models.VoiceAgentServerEventSessionHandoffStarted": "Azure.AI.Projects.VoiceAgentServerEventSessionHandoffStarted", + "azure.ai.voiceagents.models.VoiceAgentServerEventSessionUpdated": "Azure.AI.Projects.VoiceAgentServerEventSessionUpdated", + "azure.ai.voiceagents.models.VoiceAgentServerEventWarning": "Azure.AI.Projects.VoiceAgentServerEventWarning", + "azure.ai.voiceagents.models.VoiceAgentServerEventWarningDetails": "Azure.AI.Projects.VoiceAgentServerEventWarningDetails", + "azure.ai.voiceagents.models.VoiceAgentServerEventWebSearchCallCompleted": "Azure.AI.Projects.VoiceAgentServerEventWebSearchCallCompleted", + "azure.ai.voiceagents.models.VoiceAgentServerEventWebSearchCallInProgress": "Azure.AI.Projects.VoiceAgentServerEventWebSearchCallInProgress", + "azure.ai.voiceagents.models.VoiceAgentServerEventWebSearchCallSearching": "Azure.AI.Projects.VoiceAgentServerEventWebSearchCallSearching", + "azure.ai.voiceagents.models.VoiceAgentServerVadTurnDetection": "Azure.AI.Projects.VoiceAgentServerVadTurnDetection", + "azure.ai.voiceagents.models.VoiceAgentSessionAvatarConfig": "Azure.AI.Projects.VoiceAgentSessionAvatarConfig", + "azure.ai.voiceagents.models.VoiceAgentSessionMcpTool": "Azure.AI.Projects.VoiceAgentSessionMcpTool", + "azure.ai.voiceagents.models.VoiceAgentSessionResponseAudio": "Azure.AI.Projects.VoiceAgentSessionResponseAudio", + "azure.ai.voiceagents.models.VoiceAgentSessionResponseAudioInput": "Azure.AI.Projects.VoiceAgentSessionResponseAudioInput", + "azure.ai.voiceagents.models.VoiceAgentSessionResponseAudioOutput": "Azure.AI.Projects.VoiceAgentSessionResponseAudioOutput", + "azure.ai.voiceagents.models.VoiceAgentSessionResponseConfig": "Azure.AI.Projects.VoiceAgentSessionResponseConfig", + "azure.ai.voiceagents.models.VoiceAgentSessionUpdateAudio": "Azure.AI.Projects.VoiceAgentSessionUpdateAudio", + "azure.ai.voiceagents.models.VoiceAgentSessionUpdateAudioInput": "Azure.AI.Projects.VoiceAgentSessionUpdateAudioInput", + "azure.ai.voiceagents.models.VoiceAgentSessionUpdateAudioOutput": "Azure.AI.Projects.VoiceAgentSessionUpdateAudioOutput", + "azure.ai.voiceagents.models.VoiceAgentSessionUpdateConfig": "Azure.AI.Projects.VoiceAgentSessionUpdateConfig", + "azure.ai.voiceagents.models.VoiceAgentStaticInterimResponseConfig": "Azure.AI.Projects.VoiceAgentStaticInterimResponseConfig", + "azure.ai.voiceagents.models.VoiceAgentTranscriptionPhrase": "Azure.AI.Projects.VoiceAgentTranscriptionPhrase", + "azure.ai.voiceagents.models.VoiceAgentTranscriptionWord": "Azure.AI.Projects.VoiceAgentTranscriptionWord", + "azure.ai.voiceagents.models.VoiceAgentVersionObject": "Azure.AI.Projects.VoiceAgentVersionObject", + "azure.ai.voiceagents.models.VoiceAgentVoiceAdaptation": "Azure.AI.Projects.VoiceAgentVoiceAdaptation", + "azure.ai.voiceagents.models.VoiceAgentWebSearchActionFind": "Azure.AI.Projects.VoiceAgentWebSearchActionFind", + "azure.ai.voiceagents.models.VoiceAgentWebSearchActionOpenPage": "Azure.AI.Projects.VoiceAgentWebSearchActionOpenPage", + "azure.ai.voiceagents.models.VoiceAgentWebSearchActionSearch": "Azure.AI.Projects.VoiceAgentWebSearchActionSearch", + "azure.ai.voiceagents.models.VoiceAgentWebSearchCallItem": "Azure.AI.Projects.VoiceAgentWebSearchCallItem", + "azure.ai.voiceagents.models.VoiceAgentWebSearchSource": "Azure.AI.Projects.VoiceAgentWebSearchSource", + "azure.ai.voiceagents.models.VoiceAgentWorkflowActionItem": "Azure.AI.Projects.VoiceAgentWorkflowActionItem", + "azure.ai.voiceagents.models.VoiceConversationItem": "Azure.AI.Projects.VoiceConversationItem", + "azure.ai.voiceagents.models.VoiceMessageItem": "Azure.AI.Projects.VoiceMessageItem", + "azure.ai.voiceagents.models.VoiceAssistantMessageItem": "Azure.AI.Projects.VoiceAssistantMessageItem", + "azure.ai.voiceagents.models.VoiceAudioConfig": "Azure.AI.Projects.VoiceAudioConfig", + "azure.ai.voiceagents.models.VoiceAudioFormat": "Azure.AI.Projects.VoiceAudioFormat", + "azure.ai.voiceagents.models.VoiceAudioInputConfig": "Azure.AI.Projects.VoiceAudioInputConfig", + "azure.ai.voiceagents.models.VoiceAudioOutputConfig": "Azure.AI.Projects.VoiceAudioOutputConfig", + "azure.ai.voiceagents.models.VoiceAvatarConfig": "Azure.AI.Projects.VoiceAvatarConfig", + "azure.ai.voiceagents.models.VoiceEndOfUtteranceDetection": "Azure.AI.Projects.VoiceEndOfUtteranceDetection", + "azure.ai.voiceagents.models.VoiceAzureSemanticDetection": "Azure.AI.Projects.VoiceAzureSemanticDetection", + "azure.ai.voiceagents.models.VoiceAzureSemanticDetectionEn": "Azure.AI.Projects.VoiceAzureSemanticDetectionEn", + "azure.ai.voiceagents.models.VoiceAzureSemanticDetectionMultilingual": "Azure.AI.Projects.VoiceAzureSemanticDetectionMultilingual", + "azure.ai.voiceagents.models.VoiceTurnDetection": "Azure.AI.Projects.VoiceTurnDetection", + "azure.ai.voiceagents.models.VoiceAzureSemanticVadEnTurnDetection": "Azure.AI.Projects.VoiceAzureSemanticVadEnTurnDetection", + "azure.ai.voiceagents.models.VoiceAzureSemanticVadMultilingualTurnDetection": "Azure.AI.Projects.VoiceAzureSemanticVadMultilingualTurnDetection", + "azure.ai.voiceagents.models.VoiceAzureSemanticVadTurnDetection": "Azure.AI.Projects.VoiceAzureSemanticVadTurnDetection", + "azure.ai.voiceagents.models.VoiceConversation": "Azure.AI.Projects.VoiceConversation", + "azure.ai.voiceagents.models.VoiceFunctionCallItem": "Azure.AI.Projects.VoiceFunctionCallItem", + "azure.ai.voiceagents.models.VoiceFunctionCallOutputItem": "Azure.AI.Projects.VoiceFunctionCallOutputItem", + "azure.ai.voiceagents.models.VoiceInputTranscription": "Azure.AI.Projects.VoiceInputTranscription", + "azure.ai.voiceagents.models.VoiceItemAudioResponse": "Azure.AI.Projects.VoiceItemAudioResponse", + "azure.ai.voiceagents.models.VoiceMcpApprovalRequestItem": "Azure.AI.Projects.VoiceMcpApprovalRequestItem", + "azure.ai.voiceagents.models.VoiceMcpApprovalResponseItem": "Azure.AI.Projects.VoiceMcpApprovalResponseItem", + "azure.ai.voiceagents.models.VoiceMcpCallItem": "Azure.AI.Projects.VoiceMcpCallItem", + "azure.ai.voiceagents.models.VoiceMcpListToolsItem": "Azure.AI.Projects.VoiceMcpListToolsItem", + "azure.ai.voiceagents.models.VoiceNoiseReduction": "Azure.AI.Projects.VoiceNoiseReduction", + "azure.ai.voiceagents.models.VoiceRecordingChannelLayout": "Azure.AI.Projects.VoiceRecordingChannelLayout", + "azure.ai.voiceagents.models.VoiceRecordingResponse": "Azure.AI.Projects.VoiceRecordingResponse", + "azure.ai.voiceagents.models.VoiceResponse": "Azure.AI.Projects.VoiceResponse", + "azure.ai.voiceagents.models.VoiceResponseAudio": "Azure.AI.Projects.VoiceResponseAudio", + "azure.ai.voiceagents.models.VoiceResponseAudioOutput": "Azure.AI.Projects.VoiceResponseAudioOutput", + "azure.ai.voiceagents.models.VoiceSemanticVadTurnDetection": "Azure.AI.Projects.VoiceSemanticVadTurnDetection", + "azure.ai.voiceagents.models.VoiceServerVadTurnDetection": "Azure.AI.Projects.VoiceServerVadTurnDetection", + "azure.ai.voiceagents.models.VoiceSystemMessageItem": "Azure.AI.Projects.VoiceSystemMessageItem", + "azure.ai.voiceagents.models.VoiceSystemTool": "Azure.AI.Projects.VoiceSystemTool", + "azure.ai.voiceagents.models.VoiceToolboxTool": "Azure.AI.Projects.VoiceToolboxTool", + "azure.ai.voiceagents.models.VoiceUserMessageItem": "Azure.AI.Projects.VoiceUserMessageItem", + "azure.ai.voiceagents.models.VoiceAgentWebSocketSubprotocol": "Azure.AI.Projects.VoiceAgentWebSocketSubprotocol", + "azure.ai.voiceagents.models.AgentDefinitionOptInKeys": "Azure.AI.Projects.AgentDefinitionOptInKeys", + "azure.ai.voiceagents.models.VoiceConversationStatus": "Azure.AI.Projects.VoiceConversationStatus", + "azure.ai.voiceagents.models.VoiceResponseStatus": "Azure.AI.Projects.VoiceResponseStatus", + "azure.ai.voiceagents.models.VoiceConversationItemType": "Azure.AI.Projects.VoiceConversationItemType", + "azure.ai.voiceagents.models.RealtimeMcpErrorType": "OpenAI.RealtimeMcpErrorType", + "azure.ai.voiceagents.models.RealtimeConversationItemMessageType": "OpenAI.RealtimeConversationItemMessageType", + "azure.ai.voiceagents.models.VoiceIdsShared": "OpenAI.VoiceIdsShared", + "azure.ai.voiceagents.models.AzureVoiceType": "Azure.AI.Projects.AzureVoiceType", + "azure.ai.voiceagents.models.PersonalVoiceModel": "Azure.AI.Projects.PersonalVoiceModel", + "azure.ai.voiceagents.models.AzureRealtimeNativeVoiceName": "Azure.AI.Projects.AzureRealtimeNativeVoiceName", + "azure.ai.voiceagents.models.RealtimeAudioFormatsType": "OpenAI.RealtimeAudioFormatsType", + "azure.ai.voiceagents.models.PageOrder": "Azure.AI.Projects.PageOrder", + "azure.ai.voiceagents.models.VoiceAudioRole": "Azure.AI.Projects.VoiceAudioRole", + "azure.ai.voiceagents.models.VoiceAudioContainerFormat": "Azure.AI.Projects.VoiceAudioContainerFormat", + "azure.ai.voiceagents.models.VoiceAudioCodec": "Azure.AI.Projects.VoiceAudioCodec", + "azure.ai.voiceagents.models.AgentObjectType": "Azure.AI.Projects.AgentObjectType", + "azure.ai.voiceagents.models.AgentState": "Azure.AI.Projects.AgentState", + "azure.ai.voiceagents.models.AgentStateSource": "Azure.AI.Projects.AgentStateSource", + "azure.ai.voiceagents.models.VersionSelectorType": "Azure.AI.Projects.VersionSelectorType", + "azure.ai.voiceagents.models.AgentEndpointAuthorizationSchemeType": "Azure.AI.Projects.AgentEndpointAuthorizationSchemeType", + "azure.ai.voiceagents.models.AgentIdentityStatus": "Azure.AI.Projects.AgentIdentityStatus", + "azure.ai.voiceagents.models.AgentBlueprintReferenceType": "Azure.AI.Projects.AgentBlueprintReferenceType", + "azure.ai.voiceagents.models.AgentVersionStatus": "Azure.AI.Projects.AgentVersionStatus", + "azure.ai.voiceagents.models.VoiceModelType": "Azure.AI.Projects.VoiceModelType", + "azure.ai.voiceagents.models.VoiceGreetingToolChoice": "Azure.AI.Projects.VoiceGreetingToolChoice", + "azure.ai.voiceagents.models.VoiceAudioFormatType": "Azure.AI.Projects.VoiceAudioFormatType", + "azure.ai.voiceagents.models.VoiceNoiseReductionType": "Azure.AI.Projects.VoiceNoiseReductionType", + "azure.ai.voiceagents.models.VoiceTurnDetectionType": "Azure.AI.Projects.VoiceTurnDetectionType", + "azure.ai.voiceagents.models.VoiceEndOfUtteranceDetectionModel": "Azure.AI.Projects.VoiceEndOfUtteranceDetectionModel", + "azure.ai.voiceagents.models.VoiceEndOfUtteranceThresholdLevel": "Azure.AI.Projects.VoiceEndOfUtteranceThresholdLevel", + "azure.ai.voiceagents.models.VoiceInputTranscriptionModel": "Azure.AI.Projects.VoiceInputTranscriptionModel", + "azure.ai.voiceagents.models.VoiceAudioTimestampType": "Azure.AI.Projects.VoiceAudioTimestampType", + "azure.ai.voiceagents.models.VoiceOutputModality": "Azure.AI.Projects.VoiceOutputModality", + "azure.ai.voiceagents.models.VoiceAvatarType": "Azure.AI.Projects.VoiceAvatarType", + "azure.ai.voiceagents.models.VoiceAvatarOutputProtocol": "Azure.AI.Projects.VoiceAvatarOutputProtocol", + "azure.ai.voiceagents.models.ToolType": "OpenAI.ToolType", + "azure.ai.voiceagents.models.CallableToolAllowedCaller": "OpenAI.CallableToolAllowedCaller", + "azure.ai.voiceagents.models.VoiceAgentMcpResponseScheduling": "Azure.AI.Projects.VoiceAgentMcpResponseScheduling", + "azure.ai.voiceagents.models.VoiceSystemToolName": "Azure.AI.Projects.VoiceSystemToolName", + "azure.ai.voiceagents.models.VoiceAgentType": "Azure.AI.Projects.VoiceAgentType", + "azure.ai.voiceagents.models.VoiceAgentUseCase": "Azure.AI.Projects.VoiceAgentUseCase", + "azure.ai.voiceagents.models.RealtimeClientEventType": "OpenAI.RealtimeClientEventType", + "azure.ai.voiceagents.models.RealtimeConversationItemType": "OpenAI.RealtimeConversationItemType", + "azure.ai.voiceagents.models.ToolChoiceOptions": "OpenAI.ToolChoiceOptions", + "azure.ai.voiceagents.models.ToolChoiceParamType": "OpenAI.ToolChoiceParamType", + "azure.ai.voiceagents.models.RealtimeReasoningEffort": "OpenAI.RealtimeReasoningEffort", + "azure.ai.voiceagents.models.VoiceAgentInterimResponseTrigger": "Azure.AI.Projects.VoiceAgentInterimResponseTrigger", + "azure.ai.voiceagents.models.VoiceAgentEndOfUtteranceModel": "Azure.AI.Projects.VoiceAgentEndOfUtteranceModel", + "azure.ai.voiceagents.models.VoiceAgentEndOfUtteranceThresholdLevel": "Azure.AI.Projects.VoiceAgentEndOfUtteranceThresholdLevel", + "azure.ai.voiceagents.models.VoiceAgentAzureSemanticVadType": "Azure.AI.Projects.VoiceAgentAzureSemanticVadType", + "azure.ai.voiceagents.models.VoiceAgentEchoCancellationReferenceSource": "Azure.AI.Projects.VoiceAgentEchoCancellationReferenceSource", + "azure.ai.voiceagents.models.VoiceAgentAvatarType": "Azure.AI.Projects.VoiceAgentAvatarType", + "azure.ai.voiceagents.models.VoiceAgentAvatarOutputProtocol": "Azure.AI.Projects.VoiceAgentAvatarOutputProtocol", + "azure.ai.voiceagents.models.VoiceAgentAnimationOutputType": "Azure.AI.Projects.VoiceAgentAnimationOutputType", + "azure.ai.voiceagents.models.VoiceAgentMcpApprovalMode": "Azure.AI.Projects.VoiceAgentMcpApprovalMode", + "azure.ai.voiceagents.models.VoiceAgentSessionIncludeOption": "Azure.AI.Projects.VoiceAgentSessionIncludeOption", + "azure.ai.voiceagents.models.VoiceAgentHandoffReasoningEffort": "Azure.AI.Projects.VoiceAgentHandoffReasoningEffort", + "azure.ai.voiceagents.models.VoiceAgentHandoffTargetResponse": "Azure.AI.Projects.VoiceAgentHandoffTargetResponse", + "azure.ai.voiceagents.models.RealtimeServerEventType": "OpenAI.RealtimeServerEventType", + "azure.ai.voiceagents.models.VoiceAgentWebSearchCallStatus": "Azure.AI.Projects.VoiceAgentWebSearchCallStatus", + "azure.ai.voiceagents.models.VoiceAgentFileSearchCallStatus": "Azure.AI.Projects.VoiceAgentFileSearchCallStatus", + "azure.ai.voiceagents.models.CreateTranscriptionResponseJsonUsageType": "OpenAI.CreateTranscriptionResponseJsonUsageType", + "azure.ai.voiceagents.models.VoiceAgentResponseStatus": "Azure.AI.Projects.VoiceAgentResponseStatus", + "azure.ai.voiceagents.models.VoiceAgentEstimatedCostStatus": "Azure.AI.Projects.VoiceAgentEstimatedCostStatus", + "azure.ai.voiceagents.models.VoiceAgentResponseAudioFormat": "Azure.AI.Projects.VoiceAgentResponseAudioFormat", + "azure.ai.voiceagents.models.VoiceAgentPipelineFamily": "Azure.AI.Projects.VoiceAgentPipelineFamily", + "azure.ai.voiceagents.models.VoiceAgentHandoffAbortReason": "Azure.AI.Projects.VoiceAgentHandoffAbortReason", + "azure.ai.voiceagents.operations.VoiceAgentWebSocketOperations.connect_voice_agent": "Azure.AI.Projects.VoiceAgentWebSocket.connectVoiceAgent", + "azure.ai.voiceagents.aio.operations.VoiceAgentWebSocketOperations.connect_voice_agent": "Azure.AI.Projects.VoiceAgentWebSocket.connectVoiceAgent", + "azure.ai.voiceagents.operations.AgentEndpointConversationsOperations.get_agent_conversation": "Azure.AI.Projects.AgentEndpointConversations.getAgentConversation", + "azure.ai.voiceagents.aio.operations.AgentEndpointConversationsOperations.get_agent_conversation": "Azure.AI.Projects.AgentEndpointConversations.getAgentConversation", + "azure.ai.voiceagents.operations.AgentEndpointConversationsOperations.delete_agent_conversation": "Azure.AI.Projects.AgentEndpointConversations.deleteAgentConversation", + "azure.ai.voiceagents.aio.operations.AgentEndpointConversationsOperations.delete_agent_conversation": "Azure.AI.Projects.AgentEndpointConversations.deleteAgentConversation", + "azure.ai.voiceagents.operations.AgentEndpointConversationsOperations.list_agent_conversation_responses": "Azure.AI.Projects.AgentEndpointConversations.listAgentConversationResponses", + "azure.ai.voiceagents.aio.operations.AgentEndpointConversationsOperations.list_agent_conversation_responses": "Azure.AI.Projects.AgentEndpointConversations.listAgentConversationResponses", + "azure.ai.voiceagents.operations.AgentEndpointConversationsOperations.get_agent_conversation_response": "Azure.AI.Projects.AgentEndpointConversations.getAgentConversationResponse", + "azure.ai.voiceagents.aio.operations.AgentEndpointConversationsOperations.get_agent_conversation_response": "Azure.AI.Projects.AgentEndpointConversations.getAgentConversationResponse", + "azure.ai.voiceagents.operations.AgentEndpointConversationsOperations.list_agent_conversation_response_items": "Azure.AI.Projects.AgentEndpointConversations.listAgentConversationResponseItems", + "azure.ai.voiceagents.aio.operations.AgentEndpointConversationsOperations.list_agent_conversation_response_items": "Azure.AI.Projects.AgentEndpointConversations.listAgentConversationResponseItems", + "azure.ai.voiceagents.operations.AgentEndpointConversationsOperations.list_agent_conversation_items": "Azure.AI.Projects.AgentEndpointConversations.listAgentConversationItems", + "azure.ai.voiceagents.aio.operations.AgentEndpointConversationsOperations.list_agent_conversation_items": "Azure.AI.Projects.AgentEndpointConversations.listAgentConversationItems", + "azure.ai.voiceagents.operations.AgentEndpointConversationsOperations.get_agent_conversation_item": "Azure.AI.Projects.AgentEndpointConversations.getAgentConversationItem", + "azure.ai.voiceagents.aio.operations.AgentEndpointConversationsOperations.get_agent_conversation_item": "Azure.AI.Projects.AgentEndpointConversations.getAgentConversationItem", + "azure.ai.voiceagents.operations.AgentEndpointConversationsOperations.get_agent_conversation_item_audio": "Azure.AI.Projects.AgentEndpointConversations.getAgentConversationItemAudio", + "azure.ai.voiceagents.aio.operations.AgentEndpointConversationsOperations.get_agent_conversation_item_audio": "Azure.AI.Projects.AgentEndpointConversations.getAgentConversationItemAudio", + "azure.ai.voiceagents.operations.AgentEndpointConversationsOperations.get_agent_conversation_item_audio_content": "Azure.AI.Projects.AgentEndpointConversations.getAgentConversationItemAudioContent", + "azure.ai.voiceagents.aio.operations.AgentEndpointConversationsOperations.get_agent_conversation_item_audio_content": "Azure.AI.Projects.AgentEndpointConversations.getAgentConversationItemAudioContent", + "azure.ai.voiceagents.operations.AgentEndpointConversationsOperations.get_agent_conversation_audio": "Azure.AI.Projects.AgentEndpointConversations.getAgentConversationAudio", + "azure.ai.voiceagents.aio.operations.AgentEndpointConversationsOperations.get_agent_conversation_audio": "Azure.AI.Projects.AgentEndpointConversations.getAgentConversationAudio", + "azure.ai.voiceagents.operations.AgentEndpointConversationsOperations.get_agent_conversation_audio_content": "Azure.AI.Projects.AgentEndpointConversations.getAgentConversationAudioContent", + "azure.ai.voiceagents.aio.operations.AgentEndpointConversationsOperations.get_agent_conversation_audio_content": "Azure.AI.Projects.AgentEndpointConversations.getAgentConversationAudioContent", + "azure.ai.voiceagents.operations.VoiceAgentsOperations.create_voice_agent": "Azure.AI.Projects.VoiceAgents.createVoiceAgent", + "azure.ai.voiceagents.aio.operations.VoiceAgentsOperations.create_voice_agent": "Azure.AI.Projects.VoiceAgents.createVoiceAgent", + "azure.ai.voiceagents.operations.VoiceAgentsOperations.list_voice_agents": "Azure.AI.Projects.VoiceAgents.listVoiceAgents", + "azure.ai.voiceagents.aio.operations.VoiceAgentsOperations.list_voice_agents": "Azure.AI.Projects.VoiceAgents.listVoiceAgents", + "azure.ai.voiceagents.operations.VoiceAgentsOperations.get_voice_agent": "Azure.AI.Projects.VoiceAgents.getVoiceAgent", + "azure.ai.voiceagents.aio.operations.VoiceAgentsOperations.get_voice_agent": "Azure.AI.Projects.VoiceAgents.getVoiceAgent", + "azure.ai.voiceagents.operations.VoiceAgentsOperations.update_voice_agent": "Azure.AI.Projects.VoiceAgents.updateVoiceAgent", + "azure.ai.voiceagents.aio.operations.VoiceAgentsOperations.update_voice_agent": "Azure.AI.Projects.VoiceAgents.updateVoiceAgent", + "azure.ai.voiceagents.operations.VoiceAgentsOperations.delete_voice_agent": "Azure.AI.Projects.VoiceAgents.deleteVoiceAgent", + "azure.ai.voiceagents.aio.operations.VoiceAgentsOperations.delete_voice_agent": "Azure.AI.Projects.VoiceAgents.deleteVoiceAgent", + "azure.ai.voiceagents.operations.VoiceAgentsOperations.enable_voice_agent": "Azure.AI.Projects.VoiceAgents.enableVoiceAgent", + "azure.ai.voiceagents.aio.operations.VoiceAgentsOperations.enable_voice_agent": "Azure.AI.Projects.VoiceAgents.enableVoiceAgent", + "azure.ai.voiceagents.operations.VoiceAgentsOperations.disable_voice_agent": "Azure.AI.Projects.VoiceAgents.disableVoiceAgent", + "azure.ai.voiceagents.aio.operations.VoiceAgentsOperations.disable_voice_agent": "Azure.AI.Projects.VoiceAgents.disableVoiceAgent", + "azure.ai.voiceagents.operations.VoiceAgentsOperations.generate_voice_agent": "Azure.AI.Projects.VoiceAgents.generateVoiceAgent", + "azure.ai.voiceagents.aio.operations.VoiceAgentsOperations.generate_voice_agent": "Azure.AI.Projects.VoiceAgents.generateVoiceAgent", + "azure.ai.voiceagents.operations.VoiceAgentsOperations.create_voice_agent_version": "Azure.AI.Projects.VoiceAgents.createVoiceAgentVersion", + "azure.ai.voiceagents.aio.operations.VoiceAgentsOperations.create_voice_agent_version": "Azure.AI.Projects.VoiceAgents.createVoiceAgentVersion", + "azure.ai.voiceagents.operations.VoiceAgentsOperations.list_voice_agent_versions": "Azure.AI.Projects.VoiceAgents.listVoiceAgentVersions", + "azure.ai.voiceagents.aio.operations.VoiceAgentsOperations.list_voice_agent_versions": "Azure.AI.Projects.VoiceAgents.listVoiceAgentVersions", + "azure.ai.voiceagents.operations.VoiceAgentsOperations.get_voice_agent_version": "Azure.AI.Projects.VoiceAgents.getVoiceAgentVersion", + "azure.ai.voiceagents.aio.operations.VoiceAgentsOperations.get_voice_agent_version": "Azure.AI.Projects.VoiceAgents.getVoiceAgentVersion", + "azure.ai.voiceagents.operations.VoiceAgentsOperations.delete_voice_agent_version": "Azure.AI.Projects.VoiceAgents.deleteVoiceAgentVersion", + "azure.ai.voiceagents.aio.operations.VoiceAgentsOperations.delete_voice_agent_version": "Azure.AI.Projects.VoiceAgents.deleteVoiceAgentVersion" + }, + "CrossLanguageVersion": "a102b6cbed5d" +} \ No newline at end of file diff --git a/sdk/voiceagents/azure-ai-voiceagents/assets.json b/sdk/voiceagents/azure-ai-voiceagents/assets.json new file mode 100644 index 000000000000..703d21fc1f3a --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/assets.json @@ -0,0 +1,6 @@ +{ + "AssetsRepo": "Azure/azure-sdk-assets", + "AssetsRepoPrefixPath": "python", + "TagPrefix": "python/voiceagents/azure-ai-voiceagents", + "Tag": "python/voiceagents/azure-ai-voiceagents_d69733ae81" +} diff --git a/sdk/voiceagents/azure-ai-voiceagents/azure/__init__.py b/sdk/voiceagents/azure-ai-voiceagents/azure/__init__.py new file mode 100644 index 000000000000..d55ccad1f573 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/azure/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/sdk/voiceagents/azure-ai-voiceagents/azure/ai/__init__.py b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/__init__.py new file mode 100644 index 000000000000..d55ccad1f573 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/__init__.py b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/__init__.py new file mode 100644 index 000000000000..99bf20879f5b --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/__init__.py @@ -0,0 +1,32 @@ +# 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 VoiceAgentsClient # type: ignore +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "VoiceAgentsClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore + +_patch_sdk() diff --git a/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/_client.py b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/_client.py new file mode 100644 index 000000000000..b378f1a3a9f9 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/_client.py @@ -0,0 +1,122 @@ +# 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 + +from azure.core import PipelineClient +from azure.core.pipeline import policies +from azure.core.rest import HttpRequest, HttpResponse + +from ._configuration import VoiceAgentsClientConfiguration +from ._utils.serialization import Deserializer, Serializer +from .operations import AgentEndpointConversationsOperations, VoiceAgentWebSocketOperations, VoiceAgentsOperations + +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 VoiceAgentsClient: # pylint: disable=docstring-keyword-should-match-keyword-only + """VoiceAgentsClient. + + :ivar voice_agent_web_socket: VoiceAgentWebSocketOperations operations + :vartype voice_agent_web_socket: azure.ai.voiceagents.operations.VoiceAgentWebSocketOperations + :ivar agent_endpoint_conversations: AgentEndpointConversationsOperations operations + :vartype agent_endpoint_conversations: + azure.ai.voiceagents.operations.AgentEndpointConversationsOperations + :ivar voice_agents: VoiceAgentsOperations operations + :vartype voice_agents: azure.ai.voiceagents.operations.VoiceAgentsOperations + :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. 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: + _endpoint = "{endpoint}" + self._config = VoiceAgentsClientConfiguration(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.voice_agent_web_socket = VoiceAgentWebSocketOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.agent_endpoint_conversations = AgentEndpointConversationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.voice_agents = VoiceAgentsOperations(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/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/_configuration.py b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/_configuration.py new file mode 100644 index 000000000000..6f48c8a3aec0 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/_configuration.py @@ -0,0 +1,69 @@ +# pylint: disable=line-too-long,useless-suppression +# 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 + +from azure.core.pipeline import policies + +from ._version import VERSION + +if TYPE_CHECKING: + from azure.core.credentials import TokenCredential + + +class VoiceAgentsClientConfiguration: # pylint: disable=too-many-instance-attributes,docstring-keyword-should-match-keyword-only + """Configuration for VoiceAgentsClient. + + 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. Required. + :type credential: ~azure.core.credentials.TokenCredential + :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", "v1") + + 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.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://ai.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "ai-voiceagents/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) + self._configure(**kwargs) + + 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 = policies.BearerTokenCredentialPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/_patch.py b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/_patch.py new file mode 100644 index 000000000000..87676c65a8f0 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/_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/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/_unions.py b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/_unions.py new file mode 100644 index 000000000000..62e6b75a05c2 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/_unions.py @@ -0,0 +1,72 @@ +# 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 Literal, TYPE_CHECKING, Union + +if TYPE_CHECKING: + from . import _unions as _unions + from . import models as _models +VoiceResponseVoice = Union["_models.OpenAIVoice", "_models.AzureVoice", "_models.AzureRealtimeNativeVoice"] +VoiceAgentVoice = Union["_models.OpenAIVoice", "_models.AzureVoice", "_models.AzureRealtimeNativeVoice"] +VoiceAgentTool = Union[ + "_models.RealtimeFunctionTool", "_models.VoiceAgentMcpTool", "_models.VoiceSystemTool", "_models.VoiceToolboxTool" +] +VoiceAgentRequestConversationItem = Union[ + "_models.RealtimeConversationItemMessageSystem", + "_models.RealtimeConversationItemMessageUser", + "_models.RealtimeConversationItemMessageAssistant", + "_models.RealtimeConversationItemFunctionCall", + "_models.RealtimeConversationItemFunctionCallOutput", +] +VoiceAgentCreateConversationItem = Union[ + "VoiceAgentRequestConversationItem", "_models.RealtimeMCPApprovalResponse" +] +VoiceAgentInterimResponse = Union[ + "_models.VoiceAgentStaticInterimResponseConfig", "_models.VoiceAgentLlmInterimResponseConfig" +] +VoiceAgentTurnDetection = Union[ + "_models.VoiceAgentServerVadTurnDetection", + "_models.VoiceAgentSemanticVadTurnDetection", + "_models.VoiceAgentAzureSemanticVadTurnDetection", + "_models.VoiceAgentAzureMultilingualSemanticVadTurnDetection", +] +VoiceAgentMaxOutputTokens = Union[int, Literal["inf"]] +VoiceAgentMcpApprovalPolicy = Union[str, "_models.VoiceAgentMcpApprovalMode", dict[str, list[str]]] +VoiceAgentSessionTool = Union[ + "_models.RealtimeFunctionTool", + "_models.VoiceAgentSessionMcpTool", + "_models.VoiceToolboxTool", + "_models.VoiceSystemTool", +] +VoiceAgentToolChoice = Union[str, "_models.ToolChoiceOptions", "_models.RealtimeToolChoiceFunction"] +VoiceAgentResponseMessageItem = Union[ + "_models.RealtimeConversationItemMessageSystem", + "_models.RealtimeConversationItemMessageUser", + "_models.RealtimeConversationItemMessageAssistant", +] +VoiceAgentWebSearchAction = Union[ + "_models.VoiceAgentWebSearchActionSearch", + "_models.VoiceAgentWebSearchActionOpenPage", + "_models.VoiceAgentWebSearchActionFind", +] +VoiceAgentFileSearchAttributeValue = Union[str, float, bool] +VoiceAgentResponseItem = Union[ + "VoiceAgentResponseMessageItem", + "_models.VoiceFunctionCallItem", + "_models.VoiceFunctionCallOutputItem", + "_models.VoiceMcpListToolsItem", + "_models.VoiceMcpCallItem", + "_models.VoiceMcpApprovalRequestItem", + "_models.VoiceMcpApprovalResponseItem", + "_models.VoiceAgentWorkflowActionItem", + "_models.VoiceAgentWebSearchCallItem", + "_models.VoiceAgentFileSearchCallItem", +] +VoiceAgentResponseEventContentPart = Union[ + "_models.VoiceAgentResponseEventTextContentPart", "_models.VoiceAgentResponseEventAudioContentPart" +] diff --git a/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/_utils/__init__.py b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/_utils/__init__.py new file mode 100644 index 000000000000..8026245c2abc --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/_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/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/_utils/model_base.py b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/_utils/model_base.py new file mode 100644 index 000000000000..35d5fc024978 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/_utils/model_base.py @@ -0,0 +1,1787 @@ +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=protected-access, broad-except + +import copy +import calendar +import decimal +import functools +import sys +import logging +import base64 +import re +import typing +import enum +import email.utils +from datetime import datetime, date, time, timedelta, timezone +from json import JSONEncoder +import xml.etree.ElementTree as ET +from collections.abc import MutableMapping +import isodate +from azure.core.exceptions import DeserializationError +from azure.core import CaseInsensitiveEnumMeta +from azure.core.pipeline import PipelineResponse +from azure.core.serialization import _Null + +from azure.core.rest import HttpResponse + +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self + +_LOGGER = logging.getLogger(__name__) + +__all__ = ["SdkJSONEncoder", "Model", "rest_field", "rest_discriminator"] + +TZ_UTC = timezone.utc +_T = typing.TypeVar("_T") +_NONE_TYPE = type(None) + + +def _timedelta_as_isostr(td: timedelta) -> str: + """Converts a datetime.timedelta object into an ISO 8601 formatted string, e.g. 'P4DT12H30M05S' + + Function adapted from the Tin Can Python project: https://github.com/RusticiSoftware/TinCanPython + + :param timedelta td: The timedelta to convert + :rtype: str + :return: ISO8601 version of this timedelta + """ + + # Split seconds to larger units + seconds = td.total_seconds() + minutes, seconds = divmod(seconds, 60) + hours, minutes = divmod(minutes, 60) + days, hours = divmod(hours, 24) + + days, hours, minutes = list(map(int, (days, hours, minutes))) + seconds = round(seconds, 6) + + # Build date + date_str = "" + if days: + date_str = "%sD" % days + + if hours or minutes or seconds: + # Build time + time_str = "T" + + # Hours + bigger_exists = date_str or hours + if bigger_exists: + time_str += "{:02}H".format(hours) + + # Minutes + bigger_exists = bigger_exists or minutes + if bigger_exists: + time_str += "{:02}M".format(minutes) + + # Seconds + try: + if seconds.is_integer(): + seconds_string = "{:02}".format(int(seconds)) + else: + # 9 chars long w/ leading 0, 6 digits after decimal + seconds_string = "%09.6f" % seconds + # Remove trailing zeros + seconds_string = seconds_string.rstrip("0") + except AttributeError: # int.is_integer() raises + seconds_string = "{:02}".format(seconds) + + time_str += "{}S".format(seconds_string) + else: + time_str = "" + + return "P" + date_str + time_str + + +def _serialize_bytes(o, format: typing.Optional[str] = None) -> str: + encoded = base64.b64encode(o).decode() + if format == "base64url": + return encoded.strip("=").replace("+", "-").replace("/", "_") + return encoded + + +def _serialize_duration(td: timedelta, format: typing.Optional[str] = None): + """Serialize a timedelta to its wire representation. + + For the ``seconds``/``milliseconds`` encodings the value is converted to a + numeric value, otherwise it falls back to an ISO 8601 duration string. + + :param timedelta td: The timedelta to serialize. + :param str format: The duration encoding format. + :rtype: int or float or str + :return: serialized duration + """ + seconds = td.total_seconds() + if format == "duration-seconds-int": + return int(seconds) + if format == "duration-seconds-float": + return seconds + if format == "duration-milliseconds-int": + return int(seconds * 1000) + if format == "duration-milliseconds-float": + return seconds * 1000 + return _timedelta_as_isostr(td) + + +def _serialize_datetime(o, format: typing.Optional[str] = None): + if hasattr(o, "year") and hasattr(o, "hour"): + if format == "rfc7231": + return email.utils.format_datetime(o, usegmt=True) + if format == "unix-timestamp": + return int(calendar.timegm(o.utctimetuple())) + + # astimezone() fails for naive times in Python 2.7, so make make sure o is aware (tzinfo is set) + if not o.tzinfo: + iso_formatted = o.replace(tzinfo=TZ_UTC).isoformat() + else: + iso_formatted = o.astimezone(TZ_UTC).isoformat() + # Replace the trailing "+00:00" UTC offset with "Z" (RFC 3339: https://www.ietf.org/rfc/rfc3339.txt) + return iso_formatted.replace("+00:00", "Z") + # Next try datetime.date or datetime.time + return o.isoformat() + + +def _is_readonly(p): + try: + return p._visibility == ["read"] + except AttributeError: + return False + + +class SdkJSONEncoder(JSONEncoder): + """A JSON encoder that's capable of serializing datetime objects and bytes. + + :param args: Additional positional arguments passed to the base ``JSONEncoder``. + :type args: typing.Any + :keyword exclude_readonly: Whether to exclude readonly properties. Defaults to False. + :paramtype exclude_readonly: bool + :keyword format: The format to use for serialization. Defaults to None. + :paramtype format: typing.Optional[str] + """ + + def __init__(self, *args, exclude_readonly: bool = False, format: typing.Optional[str] = None, **kwargs): + super().__init__(*args, **kwargs) + self.exclude_readonly = exclude_readonly + self.format = format + + def default(self, o): # pylint: disable=too-many-return-statements + if _is_model(o): + if self.exclude_readonly: + readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] + return {k: v for k, v in o.items() if k not in readonly_props} + return dict(o.items()) + try: + return super(SdkJSONEncoder, self).default(o) + except TypeError: + if isinstance(o, _Null): + return None + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, self.format) + try: + # First try datetime.datetime + return _serialize_datetime(o, self.format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _timedelta_as_isostr(o) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return super(SdkJSONEncoder, self).default(o) + + +_VALID_DATE = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" + r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") +_VALID_RFC7231 = re.compile( + r"(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s\d{2}\s" + r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT" +) + +_ARRAY_ENCODE_MAPPING = { + "pipeDelimited": "|", + "spaceDelimited": " ", + "commaDelimited": ",", + "newlineDelimited": "\n", +} + + +def _deserialize_array_encoded(delimit: str, attr): + if isinstance(attr, str): + if attr == "": + return [] + return attr.split(delimit) + return attr + + +def _deserialize_datetime(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + attr = attr.upper() + match = _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") + return date_obj # type: ignore[no-any-return] + + +def _deserialize_datetime_rfc7231(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize RFC7231 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + match = _VALID_RFC7231.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + return email.utils.parsedate_to_datetime(attr) + + +def _deserialize_datetime_unix_timestamp(attr: typing.Union[float, datetime]) -> datetime: + """Deserialize unix timestamp into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + return datetime.fromtimestamp(attr, TZ_UTC) + + +def _deserialize_date(attr: typing.Union[str, date]) -> date: + """Deserialize ISO-8601 formatted string into Date object. + :param str attr: response string to be deserialized. + :rtype: date + :returns: The date object from that input + """ + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + if isinstance(attr, date): + return attr + return isodate.parse_date(attr, defaultmonth=None, defaultday=None) # type: ignore + + +def _deserialize_time(attr: typing.Union[str, time]) -> time: + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :returns: The time object from that input + """ + if isinstance(attr, time): + return attr + return isodate.parse_time(attr) # type: ignore[no-any-return] + + +def _deserialize_bytes(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + return bytes(base64.b64decode(attr)) + + +def _deserialize_bytes_base64(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore + encoded = attr.replace("-", "+").replace("_", "/") + return bytes(base64.b64decode(encoded)) + + +def _deserialize_duration(attr): + if isinstance(attr, timedelta): + return attr + return isodate.parse_duration(attr) + + +def _deserialize_duration_numeric(attr, unit): + if isinstance(attr, timedelta): + return attr + return timedelta(**{unit: float(attr)}) + + +def _deserialize_decimal(attr): + if isinstance(attr, decimal.Decimal): + return attr + return decimal.Decimal(str(attr)) + + +def _deserialize_int_as_str(attr): + if isinstance(attr, int): + return attr + return int(attr) + + +def _deserialize_bool_as_str(attr): + if isinstance(attr, bool): + return attr + return attr.lower() == "true" + + +_DESERIALIZE_MAPPING = { + datetime: _deserialize_datetime, + date: _deserialize_date, + time: _deserialize_time, + bytes: _deserialize_bytes, + bytearray: _deserialize_bytes, + timedelta: _deserialize_duration, + typing.Any: lambda x: x, + decimal.Decimal: _deserialize_decimal, +} + +_DESERIALIZE_MAPPING_WITHFORMAT = { + "rfc3339": _deserialize_datetime, + "rfc7231": _deserialize_datetime_rfc7231, + "unix-timestamp": _deserialize_datetime_unix_timestamp, + "base64": _deserialize_bytes, + "base64url": _deserialize_bytes_base64, + "duration-seconds-int": functools.partial(_deserialize_duration_numeric, unit="seconds"), + "duration-seconds-float": functools.partial(_deserialize_duration_numeric, unit="seconds"), + "duration-milliseconds-int": functools.partial(_deserialize_duration_numeric, unit="milliseconds"), + "duration-milliseconds-float": functools.partial(_deserialize_duration_numeric, unit="milliseconds"), +} + + +def get_deserializer(annotation: typing.Any, rf: typing.Optional["_RestField"] = None): + if annotation is int and rf and rf._format == "str": + return _deserialize_int_as_str + if annotation is bool and rf and rf._format == "str": + return _deserialize_bool_as_str + if annotation is str and rf and rf._format in _ARRAY_ENCODE_MAPPING: + return functools.partial(_deserialize_array_encoded, _ARRAY_ENCODE_MAPPING[rf._format]) + if rf and rf._format: + return _DESERIALIZE_MAPPING_WITHFORMAT.get(rf._format) + return _DESERIALIZE_MAPPING.get(annotation) # pyright: ignore + + +def _get_type_alias_type(module_name: str, alias_name: str): + types = { + k: v + for k, v in sys.modules[module_name].__dict__.items() + if isinstance(v, typing._GenericAlias) # type: ignore + } + if alias_name not in types: + return alias_name + return types[alias_name] + + +def _get_model(module_name: str, model_name: str): + models = {k: v for k, v in sys.modules[module_name].__dict__.items() if isinstance(v, type)} + module_end = module_name.rsplit(".", 1)[0] + models.update({k: v for k, v in sys.modules[module_end].__dict__.items() if isinstance(v, type)}) + if isinstance(model_name, str): + model_name = model_name.split(".")[-1] + if model_name not in models: + return model_name + return models[model_name] + + +_UNSET = object() + + +class _MyMutableMapping(MutableMapping[str, typing.Any]): + def __init__(self, data: dict[str, typing.Any]) -> None: + self._data = data + + def __contains__(self, key: typing.Any) -> bool: + return key in self._data + + def __getitem__(self, key: str) -> typing.Any: + # If this key has been deserialized (for mutable types), we need to handle serialization + if hasattr(self, "_attr_to_rest_field"): + cache_attr = f"_deserialized_{key}" + if hasattr(self, cache_attr): + rf = _get_rest_field(getattr(self, "_attr_to_rest_field"), key) + if rf: + value = self._data.get(key) + if isinstance(value, (dict, list, set)): + # For mutable types, serialize and return + # But also update _data with serialized form and clear flag + # so mutations via this returned value affect _data + serialized = _serialize(value, rf._format) + # If serialized form is same type (no transformation needed), + # return _data directly so mutations work + if isinstance(serialized, type(value)) and serialized == value: + return self._data.get(key) + # Otherwise return serialized copy and clear flag + try: + object.__delattr__(self, cache_attr) + except AttributeError: + pass + # Store serialized form back + self._data[key] = serialized + return serialized + return self._data.__getitem__(key) + + def __setitem__(self, key: str, value: typing.Any) -> None: + # Clear any cached deserialized value when setting through dictionary access + cache_attr = f"_deserialized_{key}" + try: + object.__delattr__(self, cache_attr) + except AttributeError: + pass + self._data.__setitem__(key, value) + + def __delitem__(self, key: str) -> None: + self._data.__delitem__(key) + + def __iter__(self) -> typing.Iterator[typing.Any]: + return self._data.__iter__() + + def __len__(self) -> int: + return self._data.__len__() + + def __ne__(self, other: typing.Any) -> bool: + return not self.__eq__(other) + + def keys(self) -> typing.KeysView[str]: + """ + :returns: a set-like object providing a view on the mapping's keys + :rtype: ~typing.KeysView + """ + return self._data.keys() + + def values(self) -> typing.ValuesView[typing.Any]: + """ + :returns: an object providing a view on the mapping's values + :rtype: ~typing.ValuesView + """ + return self._data.values() + + def items(self) -> typing.ItemsView[str, typing.Any]: + """ + :returns: a set-like object providing a view on the mapping's items + :rtype: ~typing.ItemsView + """ + return self._data.items() + + def get(self, key: str, default: typing.Any = None) -> typing.Any: + """ + Get the value for key if key is in the dictionary, else default. + :param str key: The key to look up. + :param any default: The value to return if key is not in the dictionary. Defaults to None + :returns: The value for key if key is in the dictionary, else default. + :rtype: any + """ + try: + return self[key] + except KeyError: + return default + + @typing.overload + def pop(self, key: str) -> typing.Any: ... # pylint: disable=arguments-differ + + @typing.overload + def pop(self, key: str, default: _T) -> _T: ... # pylint: disable=signature-differs + + @typing.overload + def pop(self, key: str, default: typing.Any) -> typing.Any: ... # pylint: disable=signature-differs + + def pop(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Removes specified key and return the corresponding value. + :param str key: The key to pop. + :param any default: The value to return if key is not in the dictionary + :returns: The value corresponding to the key. + :rtype: any + :raises KeyError: If key is not found and default is not given. + """ + if default is _UNSET: + return self._data.pop(key) + return self._data.pop(key, default) + + def popitem(self) -> tuple[str, typing.Any]: + """ + Removes and returns some (key, value) pair + :returns: The (key, value) pair. + :rtype: tuple + :raises KeyError: if the dictionary is empty. + """ + return self._data.popitem() + + def clear(self) -> None: + """ + Remove all items from the dictionary. + """ + self._data.clear() + + def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: # pylint: disable=arguments-differ + """ + Update the dictionary from a mapping or an iterable of key-value pairs. + :param any args: Either a mapping object or an iterable of key-value pairs. + """ + self._data.update(*args, **kwargs) + + @typing.overload + def setdefault(self, key: str, default: None = None) -> None: ... + + @typing.overload + def setdefault(self, key: str, default: typing.Any) -> typing.Any: ... # pylint: disable=signature-differs + + def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Return the value for key if key is in the dictionary; otherwise set the key to + default and return default. + :param str key: The key to look up. + :param any default: The value to set if key is not in the dictionary + :returns: The value for key if key is in the dictionary, else default. + :rtype: any + """ + if default is _UNSET: + return self._data.setdefault(key) + return self._data.setdefault(key, default) + + def __eq__(self, other: typing.Any) -> bool: + if isinstance(other, _MyMutableMapping): + return self._data == other._data + try: + other_model = self.__class__(other) + except Exception: + return False + return self._data == other_model._data + + def __repr__(self) -> str: + return str(self._data) + + +def _is_model(obj: typing.Any) -> bool: + return getattr(obj, "_is_model", False) + + +def _serialize(o, format: typing.Optional[str] = None): # pylint: disable=too-many-return-statements + if isinstance(o, list): + if format in _ARRAY_ENCODE_MAPPING and all(isinstance(x, str) for x in o): + return _ARRAY_ENCODE_MAPPING[format].join(o) + return [_serialize(x, format) for x in o] + if isinstance(o, dict): + return {k: _serialize(v, format) for k, v in o.items()} + if isinstance(o, set): + return {_serialize(x, format) for x in o} + if isinstance(o, tuple): + return tuple(_serialize(x, format) for x in o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, format) + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, enum.Enum): + return o.value + if isinstance(o, int): + if format == "str": + return str(o) + return o + try: + # First try datetime.datetime + return _serialize_datetime(o, format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _serialize_duration(o, format) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return o + + +def _get_rest_field(attr_to_rest_field: dict[str, "_RestField"], rest_name: str) -> typing.Optional["_RestField"]: + try: + return next(rf for rf in attr_to_rest_field.values() if rf._rest_name == rest_name) + except StopIteration: + return None + + +def _create_value(rf: typing.Optional["_RestField"], value: typing.Any) -> typing.Any: + if not rf: + return _serialize(value, None) + if rf._is_multipart_file_input: + return value + if rf._is_model: + return _deserialize(rf._type, value) + if isinstance(value, ET.Element): + value = _deserialize(rf._type, value) + return _serialize(value, rf._format) + + +# ============================================================================ +# Fast-path scalar deserializer functions for rest_field(deserializer=...) +# These are referenced from rest_field declarations to bypass the generic +# _deserialize -> _deserialize_with_callable chain. +# Only simple/primitive types — no models or container types. +# ============================================================================ + + +def _xml_deser_str(value): + if isinstance(value, ET.Element): + return value.text or "" + return str(value) if value is not None else None + + +def _xml_deser_int(value): + if isinstance(value, ET.Element): + return int(value.text) if value.text else None + return int(value) if value is not None else None + + +def _xml_deser_float(value): + if isinstance(value, ET.Element): + return float(value.text) if value.text else None + return float(value) if value is not None else None + + +def _xml_deser_bool(value): + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + if text in (True, False): + return text + return text.lower() == "true" + + +# pylint: disable=docstring-missing-param +def _xml_deser_bytes(value): + """Deserialize bytes from XML (base64).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_bytes(text) + + +def _xml_deser_bytes_base64url(value): + """Deserialize bytes from XML (base64url).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_bytes_base64(text) + + +def _xml_deser_datetime(value): + """Deserialize a datetime from XML (ISO 8601 / rfc3339).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_datetime(text) + + +def _xml_deser_datetime_rfc7231(value): + """Deserialize a datetime from XML (RFC7231 format).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_datetime_rfc7231(text) + + +def _xml_deser_datetime_unix_timestamp(value): + """Deserialize a datetime from XML (Unix timestamp).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_datetime_unix_timestamp(float(text)) + + +def _xml_deser_date(value): + """Deserialize a date from XML (ISO 8601).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_date(text) + + +def _xml_deser_time(value): + """Deserialize a time from XML (ISO 8601).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_time(text) + + +def _xml_deser_duration(value): + """Deserialize a timedelta from XML (ISO 8601 duration).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_duration(text) + + +def _xml_deser_decimal(value): + """Deserialize a Decimal from XML.""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_decimal(text) + + +def _xml_deser_enum_or_str(enum_cls, value): + """Deserialize a Union[EnumType, str] from XML.""" + text = value.text if isinstance(value, ET.Element) else value + if text is None: + return None + try: + return enum_cls(text) + except ValueError: + return text + + +def _extract_xml_model_type(rf_type): + """Extract the concrete Model class from a resolved rf._type partial chain. + + Unwraps ``Optional[Model]`` and ``_deserialize_model(Model, ...)`` + wrappers. Only handles Model and Optional[Model] — other composite + types (List, Dict, Union, etc.) return None and fall through to the + generic ``_deserialize`` path at runtime. + """ + if rf_type is None: + return None + if isinstance(rf_type, type) and _is_model(rf_type): + return rf_type + if not isinstance(rf_type, functools.partial): + return None + func = rf_type.func + args = rf_type.args + if func is _deserialize_with_optional and args: + return _extract_xml_model_type(args[0]) + if func is _deserialize_model and args: + cls = args[0] + return cls if isinstance(cls, type) and _is_model(cls) else None + return None + + +def _build_xml_field_plan( # pylint: disable=docstring-missing-return, docstring-missing-rtype, unused-variable + cls, attr_to_rest_field: dict +) -> list: + """Build a precomputed XML field plan for fast _init_from_xml iteration. + + Called once per model class in __new__. Returns a list of tuples: + (rest_name, xml_name, kind, deser, rf_type, is_optional, items_name) + + kind: 0=wrapped, 1=attribute, 2=unwrapped, 3=text + + For Model and Optional[Model] fields that lack a scalar + ``_deserializer``, this function precomputes the Model class as the + deserializer so ``_init_from_xml`` can call ``ModelClass(element)`` + directly instead of going through the expensive + ``_get_deserialize_callable_from_annotation`` chain at runtime. + """ + model_meta = getattr(cls, "_xml", {}) + model_ns = model_meta.get("ns") or model_meta.get("namespace") + plan = [] + + for rf in attr_to_rest_field.values(): + prop_meta = getattr(rf, "_xml", {}) + deser = rf._deserializer + + xml_name = prop_meta.get("name", rf._rest_name) + xml_ns = _resolve_xml_ns(prop_meta, model_meta) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + is_optional = rf._is_optional + + # For Model / Optional[Model] fields without a scalar deserializer, + # precompute the Model class as the deserializer. + if deser is None and rf._type is not None: + model_cls = _extract_xml_model_type(rf._type) + if model_cls is not None: + deser = model_cls + + if prop_meta.get("attribute", False): + plan.append((rf._rest_name, xml_name, 1, deser, rf._type, is_optional, None)) + elif prop_meta.get("unwrapped", False): + items_name = prop_meta.get("itemsName") + if items_name: + items_ns = prop_meta.get("itemsNs") + if items_ns is not None: + xml_ns = items_ns + if xml_ns: + items_name = "{" + xml_ns + "}" + items_name + else: + items_name = xml_name + plan.append((rf._rest_name, xml_name, 2, deser, rf._type, is_optional, items_name)) + elif prop_meta.get("text", False): + plan.append((rf._rest_name, xml_name, 3, deser, rf._type, is_optional, None)) + else: + plan.append((rf._rest_name, xml_name, 0, deser, rf._type, is_optional, None)) + + return plan + + +# pylint: enable=docstring-missing-param +class Model(_MyMutableMapping): + _is_model = True + # label whether current class's _attr_to_rest_field has been calculated + # could not see _attr_to_rest_field directly because subclass inherits it from parent class + _calculated: set[str] = set() + + def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None: + class_name = self.__class__.__name__ + if len(args) > 1: + raise TypeError(f"{class_name}.__init__() takes 2 positional arguments but {len(args) + 1} were given") + dict_to_pass: dict[str, typing.Any] = {} + if args: + if isinstance(args[0], ET.Element): + dict_to_pass.update(self._init_from_xml(args[0])) + else: + dict_to_pass.update( + {k: _create_value(_get_rest_field(self._attr_to_rest_field, k), v) for k, v in args[0].items()} + ) + else: + non_attr_kwargs = [k for k in kwargs if k not in self._attr_to_rest_field] + if non_attr_kwargs: + # actual type errors only throw the first wrong keyword arg they see, so following that. + raise TypeError(f"{class_name}.__init__() got an unexpected keyword argument '{non_attr_kwargs[0]}'") + dict_to_pass.update( + { + self._attr_to_rest_field[k]._rest_name: _create_value(self._attr_to_rest_field[k], v) + for k, v in kwargs.items() + if v is not None + } + ) + # Apply client default values for fields the caller didn't set so that + # defaults are part of `_data` and therefore included during serialization. + for rf in self._attr_to_rest_field.values(): + if rf._default is _UNSET: + continue + if rf._rest_name in dict_to_pass: + continue + dict_to_pass[rf._rest_name] = _create_value(rf, rf._default) + super().__init__(dict_to_pass) + + def _init_from_xml( # pylint: disable=too-many-branches, too-many-statements + self, element: ET.Element + ) -> dict[str, typing.Any]: + """Deserialize an XML element into a dict mapping rest field names to values. + + :param ET.Element element: The XML element to deserialize from. + :returns: A dictionary of rest_name to deserialized value pairs. + :rtype: dict + """ + result: dict[str, typing.Any] = {} + existed_attr_keys: list[str] = [] + + field_plan = getattr(self, "_xml_field_plan", None) + if field_plan: + for rest_name, xml_name, kind, deser, rf_type, is_optional, items_name in field_plan: + if kind == 0: # wrapped element (most common) + item = element.find(xml_name) + if item is not None: + existed_attr_keys.append(xml_name) + if deser: + result[rest_name] = deser(item) + else: + result[rest_name] = _deserialize(rf_type, item) + elif kind == 1: # attribute + attr_val = element.get(xml_name) + if attr_val is not None: + existed_attr_keys.append(xml_name) + if deser: + result[rest_name] = deser(attr_val) + else: + result[rest_name] = attr_val + elif kind == 2: # unwrapped array + items = element.findall(items_name) # pyright: ignore + if len(items) > 0: + existed_attr_keys.append(items_name) + if deser: + result[rest_name] = deser(items) + else: + result[rest_name] = _deserialize(rf_type, items) + elif not is_optional: + existed_attr_keys.append(items_name) + result[rest_name] = [] + elif kind == 3: # text + if element.text is not None: + if deser: + result[rest_name] = deser(element.text) + else: + result[rest_name] = element.text + else: + model_meta = getattr(self, "_xml", {}) + for rf in self._attr_to_rest_field.values(): + prop_meta = getattr(rf, "_xml", {}) + xml_name = prop_meta.get("name", rf._rest_name) + xml_ns = _resolve_xml_ns(prop_meta, model_meta) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + # attribute + if prop_meta.get("attribute", False) and element.get(xml_name) is not None: + existed_attr_keys.append(xml_name) + result[rf._rest_name] = _deserialize(rf._type, element.get(xml_name)) + continue + + # unwrapped element is array + if prop_meta.get("unwrapped", False): + _items_name = prop_meta.get("itemsName") + if _items_name: + xml_name = _items_name + _items_ns = prop_meta.get("itemsNs") + if _items_ns is not None: + xml_ns = _items_ns + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + items = element.findall(xml_name) # pyright: ignore + if len(items) > 0: + existed_attr_keys.append(xml_name) + result[rf._rest_name] = _deserialize(rf._type, items) + elif not rf._is_optional: + existed_attr_keys.append(xml_name) + result[rf._rest_name] = [] + continue + + # text element is primitive type + if prop_meta.get("text", False): + if element.text is not None: + result[rf._rest_name] = _deserialize(rf._type, element.text) + continue + + # wrapped element could be normal property or array + item = element.find(xml_name) + if item is not None: + existed_attr_keys.append(xml_name) + result[rf._rest_name] = _deserialize(rf._type, item) + + # rest thing is additional properties + for e in element: + if e.tag not in existed_attr_keys: + result[e.tag] = _convert_element(e) + + return result + + def copy(self) -> "Model": + return Model(self.__dict__) + + def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: + if f"{cls.__module__}.{cls.__qualname__}" not in cls._calculated: + # we know the last nine classes in mro are going to be 'Model', '_MyMutableMapping', 'MutableMapping', + # 'Mapping', 'Collection', 'Sized', 'Iterable', 'Container' and 'object' + mros = cls.__mro__[:-9][::-1] # ignore parents, and reverse the mro order + attr_to_rest_field: dict[str, _RestField] = { # map attribute name to rest_field property + k: v for mro_class in mros for k, v in mro_class.__dict__.items() if k[0] != "_" and hasattr(v, "_type") + } + annotations = { + k: v + for mro_class in mros + if hasattr(mro_class, "__annotations__") + for k, v in mro_class.__annotations__.items() + } + for attr, rf in attr_to_rest_field.items(): + rf._module = cls.__module__ + if not rf._type: + rf._type = rf._get_deserialize_callable_from_annotation(annotations.get(attr, None)) + if not rf._rest_name_input: + rf._rest_name_input = attr + cls._attr_to_rest_field: dict[str, _RestField] = dict(attr_to_rest_field.items()) + # Build XML field plan for fast _init_from_xml (only for XML models) + if getattr(cls, "_xml", None): + cls._xml_field_plan = _build_xml_field_plan(cls, attr_to_rest_field) + cls._calculated.add(f"{cls.__module__}.{cls.__qualname__}") + + return super().__new__(cls) + + def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None: + for base in cls.__bases__: + if hasattr(base, "__mapping__"): + base.__mapping__[discriminator or cls.__name__] = cls # type: ignore + + @classmethod + def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField"]: + for v in cls.__dict__.values(): + if isinstance(v, _RestField) and v._is_discriminator and v._rest_name not in exist_discriminators: + return v + return None + + @classmethod + def _deserialize(cls, data, exist_discriminators): + if not hasattr(cls, "__mapping__"): + return cls(data) + discriminator = cls._get_discriminator(exist_discriminators) + if discriminator is None: + return cls(data) + exist_discriminators.append(discriminator._rest_name) + if isinstance(data, ET.Element): + model_meta = getattr(cls, "_xml", {}) + prop_meta = getattr(discriminator, "_xml", {}) + xml_name = prop_meta.get("name", discriminator._rest_name) + xml_ns = _resolve_xml_ns(prop_meta, model_meta) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + if data.get(xml_name) is not None: + discriminator_value = data.get(xml_name) + else: + discriminator_value = data.find(xml_name).text # pyright: ignore + else: + discriminator_value = data.get(discriminator._rest_name) + mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore # pylint: disable=no-member + return mapped_cls._deserialize(data, exist_discriminators) + + def as_dict(self, *, exclude_readonly: bool = False) -> dict[str, typing.Any]: + """Return a dict that can be turned into json using json.dump. + + :keyword bool exclude_readonly: Whether to remove the readonly properties. + :returns: A dict JSON compatible object + :rtype: dict + """ + + result = {} + readonly_props = [] + if exclude_readonly: + readonly_props = [p._rest_name for p in self._attr_to_rest_field.values() if _is_readonly(p)] + for k, v in self.items(): + if exclude_readonly and k in readonly_props: # pyright: ignore + continue + is_multipart_file_input = False + try: + is_multipart_file_input = next( + rf for rf in self._attr_to_rest_field.values() if rf._rest_name == k + )._is_multipart_file_input + except StopIteration: + pass + result[k] = v if is_multipart_file_input else Model._as_dict_value(v, exclude_readonly=exclude_readonly) + return result + + @staticmethod + def _as_dict_value(v: typing.Any, exclude_readonly: bool = False) -> typing.Any: + if v is None or isinstance(v, _Null): + return None + if isinstance(v, (list, tuple, set)): + return type(v)(Model._as_dict_value(x, exclude_readonly=exclude_readonly) for x in v) + if isinstance(v, dict): + return {dk: Model._as_dict_value(dv, exclude_readonly=exclude_readonly) for dk, dv in v.items()} + return v.as_dict(exclude_readonly=exclude_readonly) if hasattr(v, "as_dict") else v + + +def _deserialize_model(model_deserializer: typing.Optional[typing.Callable], obj): + if _is_model(obj): + return obj + return _deserialize(model_deserializer, obj) + + +def _deserialize_with_optional(if_obj_deserializer: typing.Optional[typing.Callable], obj): + if obj is None: + return obj + return _deserialize_with_callable(if_obj_deserializer, obj) + + +def _deserialize_with_union(deserializers, obj): + for deserializer in deserializers: + try: + return _deserialize(deserializer, obj) + except DeserializationError: + pass + raise DeserializationError() + + +def _deserialize_dict( + value_deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj: dict[typing.Any, typing.Any], +): + if obj is None: + return obj + if isinstance(obj, ET.Element): + obj = {child.tag: child for child in obj} + return {k: _deserialize(value_deserializer, v, module) for k, v in obj.items()} + + +def _deserialize_multiple_sequence( + entry_deserializers: list[typing.Optional[typing.Callable]], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + return type(obj)(_deserialize(deserializer, entry, module) for entry, deserializer in zip(obj, entry_deserializers)) + + +def _is_array_encoded_deserializer(deserializer: functools.partial) -> bool: + return ( + isinstance(deserializer, functools.partial) + and isinstance(deserializer.args[0], functools.partial) + and deserializer.args[0].func == _deserialize_array_encoded # pylint: disable=comparison-with-callable + ) + + +def _deserialize_sequence( + deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + if isinstance(obj, ET.Element): + obj = list(obj) + + # encoded string may be deserialized to sequence + if isinstance(obj, str) and isinstance(deserializer, functools.partial): + # for list[str] + if _is_array_encoded_deserializer(deserializer): + return deserializer(obj) + + # for list[Union[...]] + if isinstance(deserializer.args[0], list): + for sub_deserializer in deserializer.args[0]: + if _is_array_encoded_deserializer(sub_deserializer): + return sub_deserializer(obj) + + return type(obj)(_deserialize(deserializer, entry, module) for entry in obj) + + +def _sorted_annotations(types: list[typing.Any]) -> list[typing.Any]: + return sorted( + types, + key=lambda x: hasattr(x, "__name__") and x.__name__.lower() in ("str", "float", "int", "bool"), + ) + + +def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-return-statements, too-many-statements, too-many-branches + annotation: typing.Any, + module: typing.Optional[str], + rf: typing.Optional["_RestField"] = None, +) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + if not annotation: + return None + + # is it a type alias? + if isinstance(annotation, str): + if module is not None: + annotation = _get_type_alias_type(module, annotation) + + # is it a forward ref / in quotes? + if isinstance(annotation, (str, typing.ForwardRef)): + try: + model_name = annotation.__forward_arg__ # type: ignore + except AttributeError: + model_name = annotation + if module is not None: + annotation = _get_model(module, model_name) # type: ignore + + try: + if module and _is_model(annotation): + if rf: + rf._is_model = True + + return functools.partial(_deserialize_model, annotation) # pyright: ignore + except Exception: + pass + + # is it a literal? + try: + if annotation.__origin__ is typing.Literal: # pyright: ignore + return None + except AttributeError: + pass + + # is it optional? + try: + if any(a is _NONE_TYPE for a in annotation.__args__): # pyright: ignore + if rf: + rf._is_optional = True + if len(annotation.__args__) <= 2: # pyright: ignore + if_obj_deserializer = _get_deserialize_callable_from_annotation( + next(a for a in annotation.__args__ if a is not _NONE_TYPE), module, rf # pyright: ignore + ) + + 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 is not _NONE_TYPE] # pyright: ignore + return _get_deserialize_callable_from_annotation(annotation_copy, module, rf) + except AttributeError: + pass + + # is it union? + if getattr(annotation, "__origin__", None) is typing.Union: + # initial ordering is we make `string` the last deserialization option, because it is often them most generic + deserializers = [ + _get_deserialize_callable_from_annotation(arg, module, rf) + for arg in _sorted_annotations(annotation.__args__) # pyright: ignore + ] + + return functools.partial(_deserialize_with_union, deserializers) + + try: + annotation_name = ( + annotation.__name__ if hasattr(annotation, "__name__") else annotation._name # pyright: ignore + ) + if annotation_name.lower() == "dict": + value_deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[1], module, rf # pyright: ignore + ) + + return functools.partial( + _deserialize_dict, + value_deserializer, + module, + ) + except (AttributeError, IndexError): + pass + try: + annotation_name = ( + annotation.__name__ if hasattr(annotation, "__name__") else annotation._name # pyright: ignore + ) + if annotation_name.lower() in ["list", "set", "tuple", "sequence"]: + if len(annotation.__args__) > 1: # pyright: ignore + entry_deserializers = [ + _get_deserialize_callable_from_annotation(dt, module, rf) + for dt in annotation.__args__ # pyright: ignore + ] + return functools.partial(_deserialize_multiple_sequence, entry_deserializers, module) + deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[0], module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_sequence, deserializer, module) + except (TypeError, IndexError, AttributeError, SyntaxError): + pass + + def _deserialize_default( + deserializer, + obj, + ): + if obj is None: + return obj + try: + return _deserialize_with_callable(deserializer, obj) + except Exception: + pass + return obj + + if get_deserializer(annotation, rf): + return functools.partial(_deserialize_default, get_deserializer(annotation, rf)) + + return functools.partial(_deserialize_default, annotation) + + +def _deserialize_with_callable( + deserializer: typing.Optional[typing.Callable[[typing.Any], typing.Any]], + value: typing.Any, +): # pylint: disable=too-many-return-statements + try: + if value is None or isinstance(value, _Null): + return None + if isinstance(value, ET.Element): + if deserializer is str: + return value.text or "" + if deserializer is int: + return int(value.text) if value.text else None + if deserializer is float: + return float(value.text) if value.text else None + if deserializer is bool: + return value.text == "true" if value.text else None + if deserializer and deserializer in _DESERIALIZE_MAPPING.values(): + return deserializer(value.text) if value.text else None + if deserializer and deserializer in _DESERIALIZE_MAPPING_WITHFORMAT.values(): + return deserializer(value.text) if value.text else None + if deserializer is None: + return value + if deserializer in [int, float, bool]: + return deserializer(value) + if isinstance(deserializer, CaseInsensitiveEnumMeta): + try: + return deserializer(value.text if isinstance(value, ET.Element) else value) + except ValueError: + # for unknown value, return raw value + return value.text if isinstance(value, ET.Element) else value + if isinstance(deserializer, type) and issubclass(deserializer, Model): + return deserializer._deserialize(value, []) + return typing.cast(typing.Callable[[typing.Any], typing.Any], deserializer)(value) + except Exception as e: + raise DeserializationError() from e + + +def _deserialize( + deserializer: typing.Any, + value: typing.Any, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + if isinstance(value, PipelineResponse): + value = value.http_response.json() + if rf is None and format: + rf = _RestField(format=format) + if not isinstance(deserializer, functools.partial): + deserializer = _get_deserialize_callable_from_annotation(deserializer, module, rf) + return _deserialize_with_callable(deserializer, value) + + +def _failsafe_deserialize( + deserializer: typing.Any, + response: HttpResponse, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + try: + return _deserialize(deserializer, response.json(), module, rf, format) + except Exception: # pylint: disable=broad-except + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +def _failsafe_deserialize_xml( + deserializer: typing.Any, + response: HttpResponse, +) -> typing.Any: + try: + return _deserialize_xml(deserializer, response.text()) + except Exception: # pylint: disable=broad-except + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +# pylint: disable=too-many-instance-attributes +class _RestField: + def __init__( + self, + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + is_discriminator: bool = False, + visibility: typing.Optional[list[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, + xml: typing.Optional[dict[str, typing.Any]] = None, + deserializer: typing.Optional[typing.Callable] = None, + ): + self._type = type + self._rest_name_input = name + self._module: typing.Optional[str] = None + self._is_discriminator = is_discriminator + self._visibility = visibility + self._is_model = False + self._is_optional = False + self._default = default + self._format = format + self._is_multipart_file_input = is_multipart_file_input + self._xml = xml if xml is not None else {} + self._deserializer = deserializer + + @property + def _class_type(self) -> typing.Any: + result = getattr(self._type, "args", [None])[0] + # type may be wrapped by nested functools.partial so we need to check for that + if isinstance(result, functools.partial): + return getattr(result, "args", [None])[0] + return result + + @property + def _rest_name(self) -> str: + if self._rest_name_input is None: + raise ValueError("Rest name was never set") + return self._rest_name_input + + def __get__(self, obj: Model, type=None): # pylint: disable=redefined-builtin + # by this point, type and rest_name will have a value bc we default + # them in __new__ of the Model class + # Use _data.get() directly to avoid triggering __getitem__ which clears the cache + item = obj._data.get(self._rest_name, _UNSET) + if item is _UNSET: + # Field not set by user; return the client default if one exists, otherwise None + return self._default if self._default is not _UNSET else None + if item is None: + return item + if self._is_model: + return item + + # For mutable types, we want mutations to directly affect _data + # Check if we've already deserialized this value + cache_attr = f"_deserialized_{self._rest_name}" + if hasattr(obj, cache_attr): + # Return the value from _data directly (it's been deserialized in place) + return obj._data.get(self._rest_name) + + # Fast path: use _deserializer directly (avoids _serialize/_deserialize chain) + if self._deserializer: + deserialized = self._deserializer(item) + else: + deserialized = _deserialize(self._type, _serialize(item, self._format), rf=self) + + # For mutable types, store the deserialized value back in _data + # so mutations directly affect _data + if isinstance(deserialized, (dict, list, set)): + obj._data[self._rest_name] = deserialized + object.__setattr__(obj, cache_attr, True) # Mark as deserialized + return deserialized + + return deserialized + + def __set__(self, obj: Model, value) -> None: + # Clear the cached deserialized object when setting a new value + cache_attr = f"_deserialized_{self._rest_name}" + if hasattr(obj, cache_attr): + object.__delattr__(obj, cache_attr) + + if value is None: + # we want to wipe out entries if users set attr to None + try: + obj.__delitem__(self._rest_name) + except KeyError: + pass + return + if self._is_model: + if not _is_model(value): + value = _deserialize(self._type, value) + obj.__setitem__(self._rest_name, value) + return + obj.__setitem__(self._rest_name, _serialize(value, self._format)) + + def _get_deserialize_callable_from_annotation( + self, annotation: typing.Any + ) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + return _get_deserialize_callable_from_annotation(annotation, self._module, self) + + +def rest_field( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[list[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, + xml: typing.Optional[dict[str, typing.Any]] = None, + deserializer: typing.Optional[typing.Callable] = None, +) -> typing.Any: + return _RestField( + name=name, + type=type, + visibility=visibility, + default=default, + format=format, + is_multipart_file_input=is_multipart_file_input, + xml=xml, + deserializer=deserializer, + ) + + +def rest_discriminator( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[list[str]] = None, + xml: typing.Optional[dict[str, typing.Any]] = None, +) -> typing.Any: + return _RestField(name=name, type=type, is_discriminator=True, visibility=visibility, xml=xml) + + +def serialize_xml(model: Model, exclude_readonly: bool = False) -> str: + """Serialize a model to XML. + + :param Model model: The model to serialize. + :param bool exclude_readonly: Whether to exclude readonly properties. + :returns: The XML representation of the model. + :rtype: str + """ + return ET.tostring(_get_element(model, exclude_readonly), encoding="unicode") # type: ignore + + +def _get_xml_ns(meta: dict[str, typing.Any]) -> typing.Optional[str]: + """Return the XML namespace from a metadata dict, checking both 'ns' (old-style) and 'namespace' (DPG) keys. + + :param dict meta: The metadata dictionary to extract namespace from. + :returns: The namespace string if 'ns' or 'namespace' key is present, None otherwise. + :rtype: str or None + """ + ns = meta.get("ns") + if ns is None: + ns = meta.get("namespace") + return ns + + +def _resolve_xml_ns( + prop_meta: dict[str, typing.Any], model_meta: typing.Optional[dict[str, typing.Any]] = None +) -> typing.Optional[str]: + """Resolve XML namespace for a property, falling back to model namespace when appropriate. + + Checks the property metadata first; if no namespace is found and the model does not declare + an explicit prefix, falls back to the model-level namespace. + + :param dict prop_meta: The property metadata dictionary. + :param dict model_meta: The model metadata dictionary, used as fallback. + :returns: The resolved namespace string, or None. + :rtype: str or None + """ + ns = _get_xml_ns(prop_meta) + if ns is None and model_meta is not None and not model_meta.get("prefix"): + ns = _get_xml_ns(model_meta) + return ns + + +def _set_xml_attribute(element: ET.Element, name: str, value: typing.Any, prop_meta: dict[str, typing.Any]) -> None: + """Set an XML attribute on an element, handling namespace prefix registration. + + :param ET.Element element: The element to set the attribute on. + :param str name: The default attribute name (wire name). + :param any value: The attribute value. + :param dict prop_meta: The property metadata dictionary. + """ + xml_name = prop_meta.get("name", name) + _attr_ns = _get_xml_ns(prop_meta) + if _attr_ns: + _attr_prefix = prop_meta.get("prefix") + if _attr_prefix: + _safe_register_namespace(_attr_prefix, _attr_ns) + xml_name = "{" + _attr_ns + "}" + xml_name + element.set(xml_name, _get_primitive_type_value(value)) + + +def _get_element( + o: typing.Any, + exclude_readonly: bool = False, + parent_meta: typing.Optional[dict[str, typing.Any]] = None, + wrapped_element: typing.Optional[ET.Element] = None, +) -> typing.Union[ET.Element, list[ET.Element]]: + if _is_model(o): + model_meta = getattr(o, "_xml", {}) + + # if prop is a model, then use the prop element directly, else generate a wrapper of model + if wrapped_element is None: + # When serializing as an array item (parent_meta is set), check if the parent has an + # explicit itemsName. This ensures correct element names for unwrapped arrays (where + # the element tag is the property/items name, not the model type name). + _items_name = parent_meta.get("itemsName") if parent_meta is not None else None + element_name = _items_name if _items_name else (model_meta.get("name") or o.__class__.__name__) + _model_ns = _get_xml_ns(model_meta) + wrapped_element = _create_xml_element( + element_name, + model_meta.get("prefix"), + _model_ns, + ) + + readonly_props = [] + if exclude_readonly: + readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] + + for k, v in o.items(): + # do not serialize readonly properties + if exclude_readonly and k in readonly_props: + continue + + prop_rest_field = _get_rest_field(o._attr_to_rest_field, k) + if prop_rest_field: + prop_meta = getattr(prop_rest_field, "_xml").copy() + # use the wire name as xml name if no specific name is set + if prop_meta.get("name") is None: + prop_meta["name"] = k + else: + # additional properties will not have rest field, use the wire name as xml name + prop_meta = {"name": k} + + # Propagate model namespace to properties only for old-style "ns"-keyed models. + # DPG-generated models use the "namespace" key and explicitly declare namespace on + # each property that needs it, so propagation is intentionally skipped for them. + if prop_meta.get("ns") is None and model_meta.get("ns"): + prop_meta["ns"] = model_meta.get("ns") + prop_meta["prefix"] = model_meta.get("prefix") + + if prop_meta.get("unwrapped", False): + # unwrapped could only set on array + wrapped_element.extend(_get_element(v, exclude_readonly, prop_meta)) + elif prop_meta.get("text", False): + # text could only set on primitive type + wrapped_element.text = _get_primitive_type_value(v) + elif prop_meta.get("attribute", False): + _set_xml_attribute(wrapped_element, k, v, prop_meta) + else: + # other wrapped prop element + wrapped_element.append(_get_wrapped_element(v, exclude_readonly, prop_meta)) + return wrapped_element + if isinstance(o, list): + return [_get_element(x, exclude_readonly, parent_meta) for x in o] # type: ignore + if isinstance(o, dict): + result = [] + _dict_ns = _get_xml_ns(parent_meta) if parent_meta else None + for k, v in o.items(): + result.append( + _get_wrapped_element( + v, + exclude_readonly, + { + "name": k, + "ns": _dict_ns, + "prefix": parent_meta.get("prefix") if parent_meta else None, + }, + ) + ) + return result + + # primitive case need to create element based on parent_meta + if parent_meta: + _items_ns = parent_meta.get("itemsNs") + if _items_ns is None: + _items_ns = _get_xml_ns(parent_meta) + return _get_wrapped_element( + o, + exclude_readonly, + { + "name": parent_meta.get("itemsName", parent_meta.get("name")), + "prefix": parent_meta.get("itemsPrefix", parent_meta.get("prefix")), + "ns": _items_ns, + }, + ) + + raise ValueError("Could not serialize value into xml: " + o) + + +def _get_wrapped_element( + v: typing.Any, + exclude_readonly: bool, + meta: typing.Optional[dict[str, typing.Any]], +) -> ET.Element: + _meta_ns = _get_xml_ns(meta) if meta else None + wrapped_element = _create_xml_element( + meta.get("name") if meta else None, meta.get("prefix") if meta else None, _meta_ns + ) + if isinstance(v, (dict, list)): + wrapped_element.extend(_get_element(v, exclude_readonly, meta)) + elif _is_model(v): + _get_element(v, exclude_readonly, meta, wrapped_element) + else: + wrapped_element.text = _get_primitive_type_value(v) + return wrapped_element # type: ignore[no-any-return] + + +def _get_primitive_type_value(v) -> str: + if v is True: + return "true" + if v is False: + return "false" + if isinstance(v, _Null): + return "" + return str(v) + + +def _safe_register_namespace(prefix: str, ns: str) -> None: + """Register an XML namespace prefix, handling reserved prefix patterns. + + Some prefixes (e.g. 'ns2') match Python's reserved 'ns\\d+' pattern used for + auto-generated prefixes, causing register_namespace to raise ValueError. + Falls back to directly registering in the internal namespace map. + + :param str prefix: The namespace prefix to register. + :param str ns: The namespace URI. + """ + try: + ET.register_namespace(prefix, ns) + except ValueError: + _ns_map = getattr(ET, "_namespace_map", None) + if _ns_map is not None: + _ns_map[ns] = prefix + + +def _create_xml_element( + tag: typing.Any, prefix: typing.Optional[str] = None, ns: typing.Optional[str] = None +) -> ET.Element: + if prefix and ns: + _safe_register_namespace(prefix, ns) + if ns: + return ET.Element("{" + ns + "}" + tag) + return ET.Element(tag) + + +def _deserialize_xml( + deserializer: typing.Any, + value: str, +) -> typing.Any: + element = ET.fromstring(value) # nosec + if _is_model(deserializer): + return deserializer._deserialize(element, []) + return _deserialize(deserializer, element) + + +def _convert_element(e: ET.Element): + # dict case + if len(e.attrib) > 0 or len({child.tag for child in e}) > 1: + dict_result: dict[str, typing.Any] = {} + for child in e: + if dict_result.get(child.tag) is not None: + if isinstance(dict_result[child.tag], list): + dict_result[child.tag].append(_convert_element(child)) + else: + dict_result[child.tag] = [dict_result[child.tag], _convert_element(child)] + else: + dict_result[child.tag] = _convert_element(child) + dict_result.update(e.attrib) + return dict_result + # array case + if len(e) > 0: + array_result: list[typing.Any] = [] + for child in e: + array_result.append(_convert_element(child)) + return array_result + # primitive case + return e.text diff --git a/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/_utils/serialization.py b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/_utils/serialization.py new file mode 100644 index 000000000000..ae08f9d89f74 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/_utils/serialization.py @@ -0,0 +1,2179 @@ +# 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. + + :param classes: Mapping of model names to model types, used to resolve models during serialization. + :type classes: typing.Optional[typing.Mapping[str, type]] + """ + + 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, + "duration-seconds-int": Serializer.serialize_duration_seconds_int, + "duration-seconds-float": Serializer.serialize_duration_seconds_float, + "duration-milliseconds-int": Serializer.serialize_duration_milliseconds_int, + "duration-milliseconds-float": Serializer.serialize_duration_milliseconds_float, + "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_duration_numeric(attr, scale, as_int): + """Serialize a TimeDelta into a numeric value scaled to the wire unit. + + :param TimeDelta attr: Object to be serialized. + :param int scale: Multiplier applied to total seconds (1 for seconds, 1000 for milliseconds). + :param bool as_int: Whether to truncate the result to an int. + :rtype: int or float + :return: serialized duration + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + value = attr.total_seconds() * scale if isinstance(attr, datetime.timedelta) else attr + return int(value) if as_int else float(value) + + @staticmethod + def serialize_duration_seconds_int(attr, **kwargs): # pylint: disable=unused-argument + """Serialize TimeDelta object into an integer number of seconds. + + :param TimeDelta attr: Object to be serialized. + :rtype: int + :return: serialized duration + """ + return Serializer._serialize_duration_numeric(attr, 1, True) + + @staticmethod + def serialize_duration_seconds_float(attr, **kwargs): # pylint: disable=unused-argument + """Serialize TimeDelta object into a floating point number of seconds. + + :param TimeDelta attr: Object to be serialized. + :rtype: float + :return: serialized duration + """ + return Serializer._serialize_duration_numeric(attr, 1, False) + + @staticmethod + def serialize_duration_milliseconds_int(attr, **kwargs): # pylint: disable=unused-argument + """Serialize TimeDelta object into an integer number of milliseconds. + + :param TimeDelta attr: Object to be serialized. + :rtype: int + :return: serialized duration + """ + return Serializer._serialize_duration_numeric(attr, 1000, True) + + @staticmethod + def serialize_duration_milliseconds_float(attr, **kwargs): # pylint: disable=unused-argument + """Serialize TimeDelta object into a floating point number of milliseconds. + + :param TimeDelta attr: Object to be serialized. + :rtype: float + :return: serialized duration + """ + return Serializer._serialize_duration_numeric(attr, 1000, False) + + @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, + "duration-seconds-int": Deserializer.deserialize_duration_seconds, + "duration-seconds-float": Deserializer.deserialize_duration_seconds, + "duration-milliseconds-int": Deserializer.deserialize_duration_milliseconds, + "duration-milliseconds-float": Deserializer.deserialize_duration_milliseconds, + "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), + "duration-seconds-int": (isodate.Duration, datetime.timedelta), + "duration-seconds-float": (isodate.Duration, datetime.timedelta), + "duration-milliseconds-int": (isodate.Duration, datetime.timedelta), + "duration-milliseconds-float": (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_duration_numeric(attr, unit): + """Deserialize a numeric duration value into a TimeDelta object. + + :param float attr: response value to be deserialized. + :param str unit: The wire unit, used as the ``timedelta`` keyword + (``"seconds"`` or ``"milliseconds"``). + :return: Deserialized duration + :rtype: TimeDelta + :raises DeserializationError: if value is invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = datetime.timedelta(**{unit: float(attr)}) # type: ignore + except (ValueError, OverflowError, TypeError) as err: + msg = "Cannot deserialize duration object." + raise DeserializationError(msg) from err + return duration + + @staticmethod + def deserialize_duration_seconds(attr): + """Deserialize a numeric number of seconds into a TimeDelta object. + + :param float attr: response value to be deserialized. + :return: Deserialized duration + :rtype: TimeDelta + :raises DeserializationError: if value is invalid. + """ + return Deserializer._deserialize_duration_numeric(attr, "seconds") + + @staticmethod + def deserialize_duration_milliseconds(attr): + """Deserialize a numeric number of milliseconds into a TimeDelta object. + + :param float attr: response value to be deserialized. + :return: Deserialized duration + :rtype: TimeDelta + :raises DeserializationError: if value is invalid. + """ + return Deserializer._deserialize_duration_numeric(attr, "milliseconds") + + @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/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/_version.py b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/_version.py new file mode 100644 index 000000000000..be71c81bd282 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/_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/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/aio/__init__.py b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/aio/__init__.py new file mode 100644 index 000000000000..e670329dd024 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/aio/__init__.py @@ -0,0 +1,29 @@ +# 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 VoiceAgentsClient # 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__ = [ + "VoiceAgentsClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore + +_patch_sdk() diff --git a/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/aio/_client.py b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/aio/_client.py new file mode 100644 index 000000000000..9af42224fc60 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/aio/_client.py @@ -0,0 +1,125 @@ +# 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 + +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 VoiceAgentsClientConfiguration +from .operations import AgentEndpointConversationsOperations, VoiceAgentWebSocketOperations, VoiceAgentsOperations + +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 VoiceAgentsClient: # pylint: disable=docstring-keyword-should-match-keyword-only + """VoiceAgentsClient. + + :ivar voice_agent_web_socket: VoiceAgentWebSocketOperations operations + :vartype voice_agent_web_socket: + azure.ai.voiceagents.aio.operations.VoiceAgentWebSocketOperations + :ivar agent_endpoint_conversations: AgentEndpointConversationsOperations operations + :vartype agent_endpoint_conversations: + azure.ai.voiceagents.aio.operations.AgentEndpointConversationsOperations + :ivar voice_agents: VoiceAgentsOperations operations + :vartype voice_agents: azure.ai.voiceagents.aio.operations.VoiceAgentsOperations + :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. 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: + _endpoint = "{endpoint}" + self._config = VoiceAgentsClientConfiguration(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.voice_agent_web_socket = VoiceAgentWebSocketOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.agent_endpoint_conversations = AgentEndpointConversationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.voice_agents = VoiceAgentsOperations(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/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/aio/_configuration.py b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/aio/_configuration.py new file mode 100644 index 000000000000..bbdeb569378e --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/aio/_configuration.py @@ -0,0 +1,69 @@ +# pylint: disable=line-too-long,useless-suppression +# 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 + +from azure.core.pipeline import policies + +from .._version import VERSION + +if TYPE_CHECKING: + from azure.core.credentials_async import AsyncTokenCredential + + +class VoiceAgentsClientConfiguration: # pylint: disable=too-many-instance-attributes,docstring-keyword-should-match-keyword-only + """Configuration for VoiceAgentsClient. + + 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. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :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", "v1") + + 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.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://ai.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "ai-voiceagents/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) + self._configure(**kwargs) + + 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 = policies.AsyncBearerTokenCredentialPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/aio/_patch.py b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/aio/_patch.py new file mode 100644 index 000000000000..9c8be6a1f5db --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/aio/_patch.py @@ -0,0 +1,74 @@ +# 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 +""" +from typing import Any, Optional, TYPE_CHECKING + +from ._client import VoiceAgentsClient as _GeneratedVoiceAgentsClient +from ._realtime import AsyncRealtime, AsyncRealtimeConnection, AsyncRealtimeConnectionManager + +if TYPE_CHECKING: + from azure.core.credentials_async import AsyncTokenCredential + + +class VoiceAgentsClient(_GeneratedVoiceAgentsClient): + """VoiceAgentsClient with a realtime streaming namespace. + + Adds the :attr:`realtime` namespace on top of the generated HTTP client, exposing + ``connect(...)`` for realtime WebSocket sessions. + """ + + _realtime: Optional[AsyncRealtime] = None + + def __init__(self, endpoint: str, credential: "AsyncTokenCredential", **kwargs: Any) -> None: + # Work around an azure-core/aiohttp limitation: azure-core's AioHttpTransport + # disables aiohttp's native response decompression and only re-implements + # gzip/deflate itself (no brotli support), while aiohttp advertises + # "Accept-Encoding: br" by default. If the service responds with a + # brotli-compressed body, azure-core fails to decode it. Unless the caller + # already supplied their own transport or session, default to only + # advertising the encodings azure-core can actually decompress. + if "transport" not in kwargs and "session" not in kwargs: + try: + import aiohttp + from azure.core.pipeline.transport import AioHttpTransport + + kwargs["transport"] = AioHttpTransport( + session=aiohttp.ClientSession(auto_decompress=False, headers={"Accept-Encoding": "gzip, deflate"}) + ) + except ImportError: + pass + super().__init__(endpoint, credential, **kwargs) + + @property + def realtime(self) -> AsyncRealtime: + """Realtime streaming entry point. + + :return: The realtime namespace, exposing ``connect(...)``. + :rtype: ~azure.ai.voiceagents.aio.AsyncRealtime + """ + if self._realtime is None: + self._realtime = AsyncRealtime(self) + return self._realtime + + +__all__: list[str] = [ + "VoiceAgentsClient", + "AsyncRealtime", + "AsyncRealtimeConnection", + "AsyncRealtimeConnectionManager", +] # 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/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/aio/_realtime.py b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/aio/_realtime.py new file mode 100644 index 000000000000..291cdc3ffe5b --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/aio/_realtime.py @@ -0,0 +1,757 @@ +# pylint: disable=networking-import-outside-azure-core-transport +# 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. +# -------------------------------------------------------------------------- +"""Hand-written async realtime (WebSocket) streaming client for voice agents. + +Realtime uses a fundamentally different transport (a persistent WebSocket) than the +request/response HTTP surface generated from the service's TypeSpec definition, so it is +hand-written and exposed as the ``VoiceAgentsClient.realtime`` namespace. + +The connection ergonomics follow the OpenAI Python realtime client (and this package's +sibling ``azure-ai-voicelive``) so that developers moving between the libraries get a +familiar surface: + +* :meth:`AsyncRealtime.connect` returns an async context manager. +* Entering the context yields an :class:`AsyncRealtimeConnection`. +* The connection is async-iterable over inbound, strongly-typed server events and exposes + sub-namespaces (``session``, ``input_audio_buffer``, ``output_audio_buffer``, + ``conversation``, ``response``) for sending strongly-typed outbound client events. + +Unlike the private-preview implementation, outbound and inbound events use the generated +``VoiceAgentClientEventXxx``/``VoiceAgentServerEventXxx`` models directly. ``send`` and +``recv`` still accept/return plain ``dict`` objects as a forward-compatible fallback for any +event ``type`` the generated models don't yet know about. + +``aiohttp`` is required for this feature and is *not* a hard dependency of the package; it is +imported lazily so importing the SDK never fails when it is absent. +""" +from __future__ import annotations + +import base64 +import json +from typing import Any, AsyncIterator, cast, Dict, List, Mapping, Optional, Type, TYPE_CHECKING, Union + +from .. import models as _models +from .._utils.model_base import Model as _Model, SdkJSONEncoder + +if TYPE_CHECKING: + from aiohttp import ClientSession, ClientWebSocketResponse + from azure.core.credentials_async import AsyncTokenCredential + + from ._client import VoiceAgentsClient + + +__all__ = [ + "AsyncRealtime", + "AsyncRealtimeConnection", + "AsyncRealtimeConnectionManager", +] + +# Union of the client event models sendable over the connection, plus a raw mapping escape +# hatch for forward compatibility with event types not yet represented in the generated models. +ClientEvent = Union[ + _models.VoiceAgentClientEventConversationItemCreate, + _models.VoiceAgentClientEventConversationItemDelete, + _models.VoiceAgentClientEventConversationItemRetrieve, + _models.VoiceAgentClientEventConversationItemTruncate, + _models.VoiceAgentClientEventInputAudioBufferAppend, + _models.VoiceAgentClientEventInputAudioBufferClear, + _models.VoiceAgentClientEventInputAudioBufferCommit, + _models.VoiceAgentClientEventOutputAudioBufferClear, + _models.VoiceAgentClientEventResponseCancel, + _models.VoiceAgentClientEventResponseCreate, + _models.VoiceAgentClientEventSessionAvatarConnect, + _models.VoiceAgentClientEventSessionUpdate, + str, + Mapping[str, Any], +] + +# The conversation item variants accepted by ``conversation.item.create``. +ConversationItem = Union[ + _models.RealtimeConversationItemMessageSystem, + _models.RealtimeConversationItemMessageUser, + _models.RealtimeConversationItemMessageAssistant, + _models.RealtimeConversationItemFunctionCall, + _models.RealtimeConversationItemFunctionCallOutput, + _models.RealtimeMCPApprovalResponse, + Mapping[str, Any], +] + +# Every server event ``type`` string mapped to its generated model, used to deserialize +# inbound frames into strongly-typed objects. Unrecognized ``type`` values fall back to a +# plain ``dict`` so newly-added service events never break an older client. +_SERVER_EVENT_TYPES: Dict[str, Type[_Model]] = { + "conversation.created": _models.VoiceAgentServerEventConversationCreated, + "conversation.item.added": _models.VoiceAgentServerEventConversationItemAdded, + "conversation.item.created": _models.VoiceAgentServerEventConversationItemCreated, + "conversation.item.deleted": _models.VoiceAgentServerEventConversationItemDeleted, + "conversation.item.done": _models.VoiceAgentServerEventConversationItemDone, + "conversation.item.input_audio_transcription.completed": ( + _models.VoiceAgentServerEventConversationItemInputAudioTranscriptionCompleted + ), + "conversation.item.input_audio_transcription.delta": ( + _models.VoiceAgentServerEventConversationItemInputAudioTranscriptionDelta + ), + "conversation.item.input_audio_transcription.failed": ( + _models.VoiceAgentServerEventConversationItemInputAudioTranscriptionFailed + ), + "conversation.item.input_audio_transcription.segment": ( + _models.VoiceAgentServerEventConversationItemInputAudioTranscriptionSegment + ), + "conversation.item.retrieved": _models.VoiceAgentServerEventConversationItemRetrieved, + "conversation.item.truncated": _models.VoiceAgentServerEventConversationItemTruncated, + "error": _models.VoiceAgentServerEventError, + "input_audio_buffer.cleared": _models.VoiceAgentServerEventInputAudioBufferCleared, + "input_audio_buffer.committed": _models.VoiceAgentServerEventInputAudioBufferCommitted, + "input_audio_buffer.speech_started": _models.VoiceAgentServerEventInputAudioBufferSpeechStarted, + "input_audio_buffer.speech_stopped": _models.VoiceAgentServerEventInputAudioBufferSpeechStopped, + "input_audio_buffer.timeout_triggered": _models.VoiceAgentServerEventInputAudioBufferTimeoutTriggered, + "mcp_list_tools.completed": _models.VoiceAgentServerEventMcpListToolsCompleted, + "mcp_list_tools.failed": _models.VoiceAgentServerEventMcpListToolsFailed, + "mcp_list_tools.in_progress": _models.VoiceAgentServerEventMcpListToolsInProgress, + "output_audio_buffer.cleared": _models.VoiceAgentServerEventOutputAudioBufferCleared, + "rate_limits.updated": _models.VoiceAgentServerEventRateLimitsUpdated, + "response.animation_blendshapes.delta": _models.VoiceAgentServerEventResponseAnimationBlendshapesDelta, + "response.animation_blendshapes.done": _models.VoiceAgentServerEventResponseAnimationBlendshapesDone, + "response.animation_viseme.delta": _models.VoiceAgentServerEventResponseAnimationVisemeDelta, + "response.animation_viseme.done": _models.VoiceAgentServerEventResponseAnimationVisemeDone, + "response.audio_timestamp.delta": _models.VoiceAgentServerEventResponseAudioTimestampDelta, + "response.audio_timestamp.done": _models.VoiceAgentServerEventResponseAudioTimestampDone, + "response.content_part.added": _models.RealtimeServerEventResponseContentPartAdded, + "response.content_part.done": _models.VoiceAgentServerEventResponseContentPartDone, + "response.created": _models.VoiceAgentServerEventResponseCreated, + "response.done": _models.VoiceAgentServerEventResponseDone, + "response.file_search_call.completed": _models.VoiceAgentServerEventFileSearchCallCompleted, + "response.file_search_call.in_progress": _models.VoiceAgentServerEventFileSearchCallInProgress, + "response.file_search_call.searching": _models.VoiceAgentServerEventFileSearchCallSearching, + "response.function_call_arguments.delta": _models.VoiceAgentServerEventResponseFunctionCallArgumentsDelta, + "response.function_call_arguments.done": _models.VoiceAgentServerEventResponseFunctionCallArgumentsDone, + "response.mcp_call.completed": _models.VoiceAgentServerEventResponseMcpCallCompleted, + "response.mcp_call.failed": _models.VoiceAgentServerEventResponseMcpCallFailed, + "response.mcp_call.in_progress": _models.VoiceAgentServerEventResponseMcpCallInProgress, + "response.mcp_call_arguments.delta": _models.VoiceAgentServerEventResponseMcpCallArgumentsDelta, + "response.mcp_call_arguments.done": _models.VoiceAgentServerEventResponseMcpCallArgumentsDone, + "response.output_audio.delta": _models.VoiceAgentServerEventResponseAudioDelta, + "response.output_audio.done": _models.VoiceAgentServerEventResponseAudioDone, + "response.output_audio_transcript.delta": _models.VoiceAgentServerEventResponseAudioTranscriptDelta, + "response.output_audio_transcript.done": _models.VoiceAgentServerEventResponseAudioTranscriptDone, + "response.output_item.added": _models.VoiceAgentServerEventResponseOutputItemAdded, + "response.output_item.done": _models.VoiceAgentServerEventResponseOutputItemDone, + "response.output_text.delta": _models.VoiceAgentServerEventResponseTextDelta, + "response.output_text.done": _models.VoiceAgentServerEventResponseTextDone, + "response.video.delta": _models.VoiceAgentServerEventResponseVideoDelta, + "response.web_search_call.completed": _models.VoiceAgentServerEventWebSearchCallCompleted, + "response.web_search_call.in_progress": _models.VoiceAgentServerEventWebSearchCallInProgress, + "response.web_search_call.searching": _models.VoiceAgentServerEventWebSearchCallSearching, + "session.avatar.connecting": _models.VoiceAgentServerEventSessionAvatarConnecting, + "session.avatar.switch_to_idle": _models.VoiceAgentServerEventSessionAvatarSwitchToIdle, + "session.avatar.switch_to_speaking": _models.VoiceAgentServerEventSessionAvatarSwitchToSpeaking, + "session.created": _models.VoiceAgentServerEventSessionCreated, + "session.handoff.aborted": _models.VoiceAgentServerEventSessionHandoffAborted, + "session.handoff.completed": _models.VoiceAgentServerEventSessionHandoffCompleted, + "session.handoff.started": _models.VoiceAgentServerEventSessionHandoffStarted, + "session.updated": _models.VoiceAgentServerEventSessionUpdated, + "warning": _models.VoiceAgentServerEventWarning, +} + +# Every generated server event model, for consumers that want a precise return type. +ServerEvent = Union[ + _models.RealtimeServerEventResponseContentPartAdded, + _models.VoiceAgentServerEventConversationCreated, + _models.VoiceAgentServerEventConversationItemAdded, + _models.VoiceAgentServerEventConversationItemCreated, + _models.VoiceAgentServerEventConversationItemDeleted, + _models.VoiceAgentServerEventConversationItemDone, + _models.VoiceAgentServerEventConversationItemInputAudioTranscriptionCompleted, + _models.VoiceAgentServerEventConversationItemInputAudioTranscriptionDelta, + _models.VoiceAgentServerEventConversationItemInputAudioTranscriptionFailed, + _models.VoiceAgentServerEventConversationItemInputAudioTranscriptionSegment, + _models.VoiceAgentServerEventConversationItemRetrieved, + _models.VoiceAgentServerEventConversationItemTruncated, + _models.VoiceAgentServerEventError, + _models.VoiceAgentServerEventFileSearchCallCompleted, + _models.VoiceAgentServerEventFileSearchCallInProgress, + _models.VoiceAgentServerEventFileSearchCallSearching, + _models.VoiceAgentServerEventInputAudioBufferCleared, + _models.VoiceAgentServerEventInputAudioBufferCommitted, + _models.VoiceAgentServerEventInputAudioBufferSpeechStarted, + _models.VoiceAgentServerEventInputAudioBufferSpeechStopped, + _models.VoiceAgentServerEventInputAudioBufferTimeoutTriggered, + _models.VoiceAgentServerEventMcpListToolsCompleted, + _models.VoiceAgentServerEventMcpListToolsFailed, + _models.VoiceAgentServerEventMcpListToolsInProgress, + _models.VoiceAgentServerEventOutputAudioBufferCleared, + _models.VoiceAgentServerEventRateLimitsUpdated, + _models.VoiceAgentServerEventResponseAnimationBlendshapesDelta, + _models.VoiceAgentServerEventResponseAnimationBlendshapesDone, + _models.VoiceAgentServerEventResponseAnimationVisemeDelta, + _models.VoiceAgentServerEventResponseAnimationVisemeDone, + _models.VoiceAgentServerEventResponseAudioDelta, + _models.VoiceAgentServerEventResponseAudioDone, + _models.VoiceAgentServerEventResponseAudioTimestampDelta, + _models.VoiceAgentServerEventResponseAudioTimestampDone, + _models.VoiceAgentServerEventResponseAudioTranscriptDelta, + _models.VoiceAgentServerEventResponseAudioTranscriptDone, + _models.VoiceAgentServerEventResponseContentPartDone, + _models.VoiceAgentServerEventResponseCreated, + _models.VoiceAgentServerEventResponseDone, + _models.VoiceAgentServerEventResponseFunctionCallArgumentsDelta, + _models.VoiceAgentServerEventResponseFunctionCallArgumentsDone, + _models.VoiceAgentServerEventResponseMcpCallArgumentsDelta, + _models.VoiceAgentServerEventResponseMcpCallArgumentsDone, + _models.VoiceAgentServerEventResponseMcpCallCompleted, + _models.VoiceAgentServerEventResponseMcpCallFailed, + _models.VoiceAgentServerEventResponseMcpCallInProgress, + _models.VoiceAgentServerEventResponseOutputItemAdded, + _models.VoiceAgentServerEventResponseOutputItemDone, + _models.VoiceAgentServerEventResponseTextDelta, + _models.VoiceAgentServerEventResponseTextDone, + _models.VoiceAgentServerEventResponseVideoDelta, + _models.VoiceAgentServerEventSessionAvatarConnecting, + _models.VoiceAgentServerEventSessionAvatarSwitchToIdle, + _models.VoiceAgentServerEventSessionAvatarSwitchToSpeaking, + _models.VoiceAgentServerEventSessionCreated, + _models.VoiceAgentServerEventSessionHandoffAborted, + _models.VoiceAgentServerEventSessionHandoffCompleted, + _models.VoiceAgentServerEventSessionHandoffStarted, + _models.VoiceAgentServerEventSessionUpdated, + _models.VoiceAgentServerEventWarning, + _models.VoiceAgentServerEventWebSearchCallCompleted, + _models.VoiceAgentServerEventWebSearchCallInProgress, + _models.VoiceAgentServerEventWebSearchCallSearching, + Mapping[str, Any], +] + + +def _to_ws_url(endpoint: str, agent_name: str) -> str: + """Build the realtime WebSocket URL from the HTTP project endpoint. + + :param str endpoint: The Foundry project endpoint (``https://.../api/projects/...``). + :param str agent_name: The name of the voice agent to connect to. + :return: A ``wss://``/``ws://`` URL targeting the realtime route. + :rtype: str + """ + base = endpoint.rstrip("/") + if base.startswith("https://"): + base = "wss://" + base[len("https://") :] + elif base.startswith("http://"): + base = "ws://" + base[len("http://") :] + return f"{base}/agents/{agent_name}/endpoint/protocols/voice" + + +class _BaseResource: + """Base helper that forwards typed helpers to the parent connection.""" + + def __init__(self, connection: "AsyncRealtimeConnection") -> None: + self._connection = connection + + async def _send(self, event: ClientEvent) -> None: + await self._connection.send(event) + + +class SessionResource(_BaseResource): + """Send ``session.*`` client events.""" + + async def update( + self, + *, + session: Union["_models.VoiceAgentSessionUpdateConfig", Mapping[str, Any]], + event_id: Optional[str] = None, + ) -> None: + """Update the realtime session configuration. + + :keyword session: The session configuration to apply. + :paramtype session: ~azure.ai.voiceagents.models.VoiceAgentSessionUpdateConfig or Mapping[str, Any] + :keyword event_id: Optional client-generated ID used to identify this event. + :paramtype event_id: str or None + """ + await self._send( + cast(Any, _models.VoiceAgentClientEventSessionUpdate)( + type=_models.RealtimeClientEventType.SESSION_UPDATE, + session=session, + event_id=event_id, + ) + ) + + async def avatar_connect(self, *, client_sdp: str, event_id: Optional[str] = None) -> None: + """Negotiate an avatar media session over WebRTC. + + :keyword str client_sdp: The client's SDP offer for avatar media negotiation. + :keyword event_id: An optional client-generated event identifier. + :paramtype event_id: str or None + """ + await self._send(_models.VoiceAgentClientEventSessionAvatarConnect(client_sdp=client_sdp, event_id=event_id)) + + +class InputAudioBufferResource(_BaseResource): + """Send ``input_audio_buffer.*`` client events.""" + + async def append(self, *, audio: Union[str, bytes], event_id: Optional[str] = None) -> None: + """Append audio bytes to the input buffer. + + :keyword audio: Raw audio bytes, or an already base64-encoded string. + :paramtype audio: str or bytes + :keyword event_id: Optional client-generated ID used to identify this event. + :paramtype event_id: str or None + """ + if isinstance(audio, (bytes, bytearray)): + audio = base64.b64encode(bytes(audio)).decode("ascii") + await self._send( + _models.VoiceAgentClientEventInputAudioBufferAppend( + type=_models.RealtimeClientEventType.INPUT_AUDIO_BUFFER_APPEND, + audio=audio, + event_id=event_id, + ) + ) + + async def commit(self, *, event_id: Optional[str] = None) -> None: + """Commit the buffered input audio as a user turn. + + :keyword event_id: Optional client-generated ID used to identify this event. + :paramtype event_id: str or None + """ + await self._send( + _models.VoiceAgentClientEventInputAudioBufferCommit( + type=_models.RealtimeClientEventType.INPUT_AUDIO_BUFFER_COMMIT, event_id=event_id + ) + ) + + async def clear(self, *, event_id: Optional[str] = None) -> None: + """Discard any buffered input audio. + + :keyword event_id: Optional client-generated ID used to identify this event. + :paramtype event_id: str or None + """ + await self._send( + _models.VoiceAgentClientEventInputAudioBufferClear( + type=_models.RealtimeClientEventType.INPUT_AUDIO_BUFFER_CLEAR, event_id=event_id + ) + ) + + +class OutputAudioBufferResource(_BaseResource): + """Send ``output_audio_buffer.*`` client events.""" + + async def clear(self, *, event_id: Optional[str] = None) -> None: + """Stop and clear any audio the service is currently playing back (barge-in). + + :keyword event_id: Optional client-generated ID used to identify this event. + :paramtype event_id: str or None + """ + await self._send( + _models.VoiceAgentClientEventOutputAudioBufferClear( + type=_models.RealtimeClientEventType.OUTPUT_AUDIO_BUFFER_CLEAR, event_id=event_id + ) + ) + + +class ConversationItemResource(_BaseResource): + """Send ``conversation.item.*`` client events.""" + + async def create( + self, + *, + item: ConversationItem, + previous_item_id: Optional[str] = None, + event_id: Optional[str] = None, + ) -> None: + """Insert an item into the conversation. + + :keyword item: The conversation item to create. + :paramtype item: ~azure.ai.voiceagents.models.RealtimeConversationItemMessageSystem or + ~azure.ai.voiceagents.models.RealtimeConversationItemMessageUser or + ~azure.ai.voiceagents.models.RealtimeConversationItemMessageAssistant or + ~azure.ai.voiceagents.models.RealtimeConversationItemFunctionCall or + ~azure.ai.voiceagents.models.RealtimeConversationItemFunctionCallOutput or + ~azure.ai.voiceagents.models.RealtimeMCPApprovalResponse or Mapping[str, Any] + :keyword previous_item_id: The ID of the preceding item after which the new item will be + inserted. Default value is None. + :paramtype previous_item_id: str or None + :keyword event_id: Optional client-generated ID used to identify this event. + :paramtype event_id: str or None + """ + await self._send( + cast(Any, _models.VoiceAgentClientEventConversationItemCreate)( + type=_models.RealtimeClientEventType.CONVERSATION_ITEM_CREATE, + item=item, + previous_item_id=previous_item_id, + event_id=event_id, + ) + ) + + async def delete(self, *, item_id: str, event_id: Optional[str] = None) -> None: + """Delete an item from the conversation. + + :keyword str item_id: The ID of the item to delete. + :keyword event_id: Optional client-generated ID used to identify this event. + :paramtype event_id: str or None + """ + await self._send( + _models.VoiceAgentClientEventConversationItemDelete( + type=_models.RealtimeClientEventType.CONVERSATION_ITEM_DELETE, item_id=item_id, event_id=event_id + ) + ) + + async def retrieve(self, *, item_id: str, event_id: Optional[str] = None) -> None: + """Ask the server to emit a ``conversation.item.retrieved`` event for an item. + + :keyword str item_id: The ID of the item to retrieve. + :keyword event_id: Optional client-generated ID used to identify this event. + :paramtype event_id: str or None + """ + await self._send( + _models.VoiceAgentClientEventConversationItemRetrieve( + type=_models.RealtimeClientEventType.CONVERSATION_ITEM_RETRIEVE, item_id=item_id, event_id=event_id + ) + ) + + async def truncate( + self, *, item_id: str, content_index: int, audio_end_ms: int, event_id: Optional[str] = None + ) -> None: + """Truncate a previously produced assistant audio item (used for barge-in). + + :keyword str item_id: The ID of the assistant message item to truncate. + :keyword int content_index: The index of the content part to truncate. Use ``0``. + :keyword int audio_end_ms: The point, in milliseconds, to truncate the audio to. + :keyword event_id: Optional client-generated ID used to identify this event. + :paramtype event_id: str or None + """ + await self._send( + _models.VoiceAgentClientEventConversationItemTruncate( + type=_models.RealtimeClientEventType.CONVERSATION_ITEM_TRUNCATE, + item_id=item_id, + content_index=content_index, + audio_end_ms=audio_end_ms, + event_id=event_id, + ) + ) + + +class ConversationResource(_BaseResource): + """Send ``conversation.*`` client events.""" + + def __init__(self, connection: "AsyncRealtimeConnection") -> None: + super().__init__(connection) + self.item: ConversationItemResource = ConversationItemResource(connection) + + +class ResponseResource(_BaseResource): + """Send ``response.*`` client events.""" + + async def create( + self, + *, + response: Optional[Union["_models.VoiceAgentResponseCreateParams", Mapping[str, Any]]] = None, + event_id: Optional[str] = None, + ) -> None: + """Ask the model to generate a response. + + :keyword response: Optional per-response overrides. Default value is None. + :paramtype response: ~azure.ai.voiceagents.models.VoiceAgentResponseCreateParams or Mapping[str, Any] or None + :keyword event_id: Optional client-generated ID used to identify this event. + :paramtype event_id: str or None + """ + await self._send( + cast(Any, _models.VoiceAgentClientEventResponseCreate)( + type=_models.RealtimeClientEventType.RESPONSE_CREATE, + response=response, + event_id=event_id, + ) + ) + + async def cancel(self, *, response_id: Optional[str] = None, event_id: Optional[str] = None) -> None: + """Cancel an in-progress response. + + :keyword response_id: The ID of the response to cancel, if targeting a specific one. + Default value is None. + :paramtype response_id: str or None + :keyword event_id: Optional client-generated ID used to identify this event. + :paramtype event_id: str or None + """ + await self._send( + _models.VoiceAgentClientEventResponseCancel( + type=_models.RealtimeClientEventType.RESPONSE_CANCEL, response_id=response_id, event_id=event_id + ) + ) + + +class AsyncRealtimeConnection: # pylint: disable=too-many-instance-attributes + """An open realtime WebSocket connection to a voice agent. + + Iterate over the connection to receive strongly-typed server events, and use the + sub-namespaces to send strongly-typed client events:: + + async with client.realtime.connect(agent_name="my-agent") as conn: + await conn.session.update(session={"modalities": ["audio", "text"]}) + await conn.input_audio_buffer.append(audio=chunk) + await conn.input_audio_buffer.commit() + await conn.response.create() + async for event in conn: + if event.type == RealtimeServerEventType.RESPONSE_DONE: + break + """ + + def __init__(self, connection: "ClientWebSocketResponse", session: "ClientSession") -> None: + self._connection = connection + self._session = session + self.session: SessionResource = SessionResource(self) + self.input_audio_buffer: InputAudioBufferResource = InputAudioBufferResource(self) + self.output_audio_buffer: OutputAudioBufferResource = OutputAudioBufferResource(self) + self.conversation: ConversationResource = ConversationResource(self) + self.response: ResponseResource = ResponseResource(self) + + async def __aenter__(self) -> "AsyncRealtimeConnection": + return self + + async def __aexit__(self, *exc_details: Any) -> None: + await self.close() + + def __aiter__(self) -> AsyncIterator[ServerEvent]: + return self._iter() + + async def _iter(self) -> AsyncIterator[ServerEvent]: + while True: + try: + yield await self.recv() + except ConnectionResetError: + return + + async def recv(self) -> ServerEvent: + """Receive and parse the next server event. + + Known event types are returned as their strongly-typed + ``VoiceAgentServerEventXxx`` model. Event types not (yet) represented by a + generated model are returned as a plain ``dict`` for forward compatibility. + + :return: The parsed server event. + :rtype: ~azure.ai.voiceagents.aio.ServerEvent + :raises ConnectionResetError: If the connection was closed by the server. + """ + import aiohttp # pylint: disable=import-outside-toplevel + + msg = await self._connection.receive() + if msg.type in (aiohttp.WSMsgType.CLOSE, aiohttp.WSMsgType.CLOSING, aiohttp.WSMsgType.CLOSED): + raise ConnectionResetError("The realtime connection was closed.") + if msg.type == aiohttp.WSMsgType.ERROR: + raise ConnectionResetError( + "The realtime connection encountered an error." + ) from self._connection.exception() + raw = msg.data.decode("utf-8") if msg.type == aiohttp.WSMsgType.BINARY else msg.data + payload: Dict[str, Any] = json.loads(raw) + event_type = payload.get("type") + if not isinstance(event_type, str): + return payload + event_cls = _SERVER_EVENT_TYPES.get(event_type) + if event_cls is None: + return payload + return event_cls(payload) + + async def send(self, event: ClientEvent) -> None: + """Send a client event over the connection. + + :param event: A strongly-typed client event, a ready-made mapping, or a raw JSON string. + :type event: ~azure.ai.voiceagents.aio.ClientEvent or str + """ + payload = event if isinstance(event, str) else json.dumps(event, cls=SdkJSONEncoder) + await self._connection.send_str(payload) + + async def close(self, *, code: int = 1000, reason: str = "") -> None: + """Close the connection and release the underlying HTTP session. + + :keyword int code: The WebSocket close code. + :keyword str reason: The close reason. + """ + try: + await self._connection.close(code=code, message=reason.encode("utf-8")) + finally: + await self._session.close() + + +class AsyncRealtimeConnectionManager: # pylint: disable=too-many-instance-attributes + """Async context manager that opens an :class:`AsyncRealtimeConnection`. + + Returned by :meth:`AsyncRealtime.connect`; you normally use it as + ``async with client.realtime.connect(...) as conn:``. + """ + + def __init__( # pylint: disable=too-many-arguments + self, + *, + endpoint: str, + credential: "AsyncTokenCredential", + credential_scopes: List[str], + api_version: str, + agent_name: str, + foundry_features: Union[str, "_models.AgentDefinitionOptInKeys"], + agent_session_id: Optional[str] = None, + agent_version_override: Optional[str] = None, + structured_inputs: Optional[str] = None, + connection_url: Optional[str] = None, + extra_query: Optional[Mapping[str, str]] = None, + extra_headers: Optional[Mapping[str, str]] = None, + **kwargs: Any, + ) -> None: + self._endpoint = endpoint + self._credential = credential + self._credential_scopes = credential_scopes + self._api_version = api_version + self._agent_name = agent_name + self._foundry_features = foundry_features + self._agent_session_id = agent_session_id + self._agent_version_override = agent_version_override + self._structured_inputs = structured_inputs + self._connection_url = connection_url + self._extra_query = dict(extra_query or {}) + self._extra_headers = dict(extra_headers or {}) + self._kwargs = kwargs + self._connection: Optional[AsyncRealtimeConnection] = None + + async def __aenter__(self) -> AsyncRealtimeConnection: + return await self.enter() + + async def enter(self) -> AsyncRealtimeConnection: # pylint: disable=too-many-locals + """Open the connection. + + :return: The live realtime connection. + :rtype: ~azure.ai.voiceagents.aio.AsyncRealtimeConnection + """ + try: + import aiohttp # pylint: disable=import-outside-toplevel + except ImportError as exc: # pragma: no cover - dependency guard + raise RuntimeError( + "The realtime client requires `aiohttp`. Install it with `pip install aiohttp`." + ) from exc + + # ``connection_url`` fully overrides the computed route (scheme/host/path). This is the + # escape hatch used to reach a specific data-plane host/path directly. + url = self._connection_url or _to_ws_url(self._endpoint, self._agent_name) + + params: Dict[str, str] = {"api-version": self._api_version} + if self._agent_session_id is not None: + params["agent_session_id"] = self._agent_session_id + if self._agent_version_override is not None: + params["x-agent-version-override"] = self._agent_version_override + params.update(self._extra_query) + + token = await self._credential.get_token(*self._credential_scopes) + # Coerce enum members (e.g. ``AgentDefinitionOptInKeys``) to their string value so the + # header carries ``VoiceAgents=V1Preview`` rather than the enum's ``repr``/``str`` form, + # which the gateway rejects with a 403 during the WebSocket handshake. + foundry_features = getattr(self._foundry_features, "value", self._foundry_features) + headers: Dict[str, str] = { + "Authorization": f"Bearer {token.token}", + "Foundry-Features": str(foundry_features), + "Sec-WebSocket-Protocol": "realtime", + } + if self._structured_inputs is not None: + headers["x-ms-voice-structured-inputs"] = self._structured_inputs + headers.update(self._extra_headers) + + session = aiohttp.ClientSession() + try: + connection = await session.ws_connect(url, headers=headers, params=params, **self._kwargs) + except BaseException: + await session.close() + raise + self._connection = AsyncRealtimeConnection(cast("ClientWebSocketResponse", connection), session) + return self._connection + + async def __aexit__(self, *exc_details: Any) -> None: + if self._connection is not None: + await self._connection.close() + self._connection = None + + +class AsyncRealtime: + """Realtime streaming entry point, exposed as ``client.realtime``. + + Follows the OpenAI Python realtime surface: obtain it from the HTTP client and open a + connection with :meth:`connect`:: + + from azure.ai.voiceagents.aio import VoiceAgentsClient + from azure.identity.aio import DefaultAzureCredential + + client = VoiceAgentsClient(endpoint, DefaultAzureCredential()) + async with client.realtime.connect(agent_name="my-agent") as conn: + await conn.session.update(session={"modalities": ["audio", "text"]}) + await conn.input_audio_buffer.append(audio=chunk) + await conn.input_audio_buffer.commit() + await conn.response.create() + async for event in conn: + if event.type == RealtimeServerEventType.RESPONSE_DONE: + break + + :param client: The HTTP client whose endpoint and credential are reused for the realtime + handshake. + :type client: ~azure.ai.voiceagents.aio.VoiceAgentsClient + """ + + def __init__(self, client: "VoiceAgentsClient") -> None: + self._config = client._config # pylint: disable=protected-access + + def connect( # pylint: disable=too-many-arguments + self, + *, + agent_name: str, + foundry_features: Union[ + str, "_models.AgentDefinitionOptInKeys" + ] = _models.AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW, + agent_session_id: Optional[str] = None, + agent_version_override: Optional[str] = None, + structured_inputs: Optional[str] = None, + connection_url: Optional[str] = None, + api_version: Optional[str] = None, + credential_scopes: Optional[List[str]] = None, + extra_query: Optional[Mapping[str, str]] = None, + extra_headers: Optional[Mapping[str, str]] = None, + **kwargs: Any, + ) -> AsyncRealtimeConnectionManager: + """Open a realtime WebSocket connection to a voice agent. + + :keyword str agent_name: The name of the voice agent to connect to. + :keyword foundry_features: Preview opt-in value for the ``Foundry-Features`` header. + Default value is ``AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW``. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.AgentDefinitionOptInKeys + :keyword agent_session_id: An optional identifier used to correlate the voice session. + Default value is None. + :paramtype agent_session_id: str or None + :keyword agent_version_override: Selects a specific version of the voice agent for this + session. Default value is None. + :paramtype agent_version_override: str or None + :keyword structured_inputs: A JSON object that maps structured-input names to their + values for this session. Default value is None. + :paramtype structured_inputs: str or None + :keyword connection_url: Full ``wss://``/``ws://`` URL that overrides the route computed + from the client endpoint. Query parameters are still appended. Default value is None. + :paramtype connection_url: str or None + :keyword api_version: Overrides the client's API version for the handshake. Default + value is None. + :paramtype api_version: str or None + :keyword credential_scopes: Overrides the client's token scopes for the handshake. + Default value is None. + :paramtype credential_scopes: list[str] or None + :keyword extra_query: Additional query-string parameters for the handshake. + :paramtype extra_query: Mapping[str, str] or None + :keyword extra_headers: Additional headers for the handshake. + :paramtype extra_headers: Mapping[str, str] or None + :return: An async context manager yielding an :class:`AsyncRealtimeConnection`. + :rtype: ~azure.ai.voiceagents.aio.AsyncRealtimeConnectionManager + """ + return AsyncRealtimeConnectionManager( + endpoint=self._config.endpoint, + credential=self._config.credential, + credential_scopes=credential_scopes or self._config.credential_scopes, + api_version=api_version or self._config.api_version, + agent_name=agent_name, + foundry_features=foundry_features, + agent_session_id=agent_session_id, + agent_version_override=agent_version_override, + structured_inputs=structured_inputs, + connection_url=connection_url, + extra_query=extra_query, + extra_headers=extra_headers, + **kwargs, + ) diff --git a/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/aio/operations/__init__.py b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/aio/operations/__init__.py new file mode 100644 index 000000000000..af8ff4734a8f --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/aio/operations/__init__.py @@ -0,0 +1,29 @@ +# 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 VoiceAgentWebSocketOperations # type: ignore +from ._operations import AgentEndpointConversationsOperations # type: ignore +from ._operations import VoiceAgentsOperations # type: ignore + +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "VoiceAgentWebSocketOperations", + "AgentEndpointConversationsOperations", + "VoiceAgentsOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/aio/operations/_operations.py b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/aio/operations/_operations.py new file mode 100644 index 000000000000..df409bd422bf --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/aio/operations/_operations.py @@ -0,0 +1,2854 @@ +# 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 +import json +from typing import Any, AsyncIterator, Callable, IO, Literal, Optional, TYPE_CHECKING, TypeVar, Union, overload +import urllib.parse + +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 models as _models, types as _types +from ..._utils.model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize +from ..._utils.serialization import Deserializer, Serializer +from ...models._enums import AgentDefinitionOptInKeys +from ...operations._operations import ( + build_agent_endpoint_conversations_delete_agent_conversation_request, + build_agent_endpoint_conversations_get_agent_conversation_audio_content_request, + build_agent_endpoint_conversations_get_agent_conversation_audio_request, + build_agent_endpoint_conversations_get_agent_conversation_item_audio_content_request, + build_agent_endpoint_conversations_get_agent_conversation_item_audio_request, + build_agent_endpoint_conversations_get_agent_conversation_item_request, + build_agent_endpoint_conversations_get_agent_conversation_request, + build_agent_endpoint_conversations_get_agent_conversation_response_request, + build_agent_endpoint_conversations_list_agent_conversation_items_request, + build_agent_endpoint_conversations_list_agent_conversation_response_items_request, + build_agent_endpoint_conversations_list_agent_conversation_responses_request, + build_voice_agent_web_socket_connect_voice_agent_request, + build_voice_agents_create_voice_agent_request, + build_voice_agents_create_voice_agent_version_request, + build_voice_agents_delete_voice_agent_request, + build_voice_agents_delete_voice_agent_version_request, + build_voice_agents_disable_voice_agent_request, + build_voice_agents_enable_voice_agent_request, + build_voice_agents_generate_voice_agent_request, + build_voice_agents_get_voice_agent_request, + build_voice_agents_get_voice_agent_version_request, + build_voice_agents_list_voice_agent_versions_request, + build_voice_agents_list_voice_agents_request, + build_voice_agents_update_voice_agent_request, +) +from .._configuration import VoiceAgentsClientConfiguration + +if TYPE_CHECKING: + from ... import _unions +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +JSON = MutableMapping[str, Any] +_Unset: Any = object() + + +class VoiceAgentWebSocketOperations: # pylint: disable=docstring-missing-param + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.voiceagents.aio.VoiceAgentsClient`'s + :attr:`voice_agent_web_socket` 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: VoiceAgentsClientConfiguration = 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 connect_voice_agent( + self, + agent_name: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + agent_session_id: Optional[str] = None, + agent_version_override: Optional[str] = None, + websocket_subprotocol: Optional[Union[str, _models.VoiceAgentWebSocketSubprotocol]] = None, + structured_inputs: Optional[str] = None, + **kwargs: Any + ) -> None: + """Connect to a voice agent. + + Connects to a voice agent over WebSocket. The client must send an HTTP GET with ``Upgrade: + websocket`` headers. The optional ``realtime`` subprotocol is the only accepted subprotocol + value. + + :param agent_name: The name of the voice agent. Required. + :type agent_name: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_V1_PREVIEW + :keyword agent_session_id: An optional identifier used to correlate the voice session. Default + value is None. + :paramtype agent_session_id: str + :keyword agent_version_override: Selects a specific version of the voice agent for this + session. Default value is None. + :paramtype agent_version_override: str + :keyword websocket_subprotocol: The requested WebSocket subprotocol. Omit this header or + request exactly ``realtime``. "realtime" Default value is None. + :paramtype websocket_subprotocol: str or + ~azure.ai.voiceagents.models.VoiceAgentWebSocketSubprotocol + :keyword structured_inputs: A JSON object that maps structured-input names to their values for + this session. Default value is None. + :paramtype structured_inputs: 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_voice_agent_web_socket_connect_voice_agent_request( + agent_name=agent_name, + foundry_features=foundry_features, + agent_session_id=agent_session_id, + agent_version_override=agent_version_override, + websocket_subprotocol=websocket_subprotocol, + structured_inputs=structured_inputs, + 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 [101]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["Sec-WebSocket-Protocol"] = self._deserialize( + "str", response.headers.get("Sec-WebSocket-Protocol") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + +class AgentEndpointConversationsOperations: # pylint: disable=docstring-missing-param + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.voiceagents.aio.VoiceAgentsClient`'s + :attr:`agent_endpoint_conversations` 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: VoiceAgentsClientConfiguration = 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_agent_conversation( + self, + agent_name: str, + conversation_id: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + **kwargs: Any + ) -> _models.VoiceConversation: + """Get a voice agent conversation. + + Retrieves a single conversation recorded for the specified voice agent endpoint by its id. + Returns ``404`` when the conversation was not persisted (``store = false``) or does not exist. + + :param agent_name: The name of the agent. Required. + :type agent_name: str + :param conversation_id: The id of the conversation to retrieve. Required. + :type conversation_id: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_V1_PREVIEW + :return: VoiceConversation. The VoiceConversation is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceConversation + :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.VoiceConversation] = kwargs.pop("cls", None) + + _request = build_agent_endpoint_conversations_get_agent_conversation_request( + agent_name=agent_name, + conversation_id=conversation_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) + + _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 = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.VoiceConversation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete_agent_conversation( + self, + agent_name: str, + conversation_id: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + **kwargs: Any + ) -> None: + """Delete a voice agent conversation. + + Deletes a conversation and all of its stored data — responses, items, and any audio (cascade). + This is the customer's explicit data-deletion control for voice conversations. + + :param agent_name: The name of the agent. Required. + :type agent_name: str + :param conversation_id: The id of the conversation to delete. Required. + :type conversation_id: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_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_agent_endpoint_conversations_delete_agent_conversation_request( + agent_name=agent_name, + conversation_id=conversation_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) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_agent_conversation_responses( + self, + agent_name: str, + conversation_id: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + limit: Optional[int] = None, + order: Optional[Union[str, _models.PageOrder]] = None, + before: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.VoiceResponse"]: + """List responses in a voice agent conversation. + + Returns a paged collection of the responses (model inference turns) recorded for the specified + conversation. The per-response ``output`` projection may be omitted here; use the + response-items route for the canonical paged output. Returns ``404`` when the conversation was + not persisted (``store = false``). + + :param agent_name: The name of the agent. Required. + :type agent_name: str + :param conversation_id: The id of the conversation whose responses are listed. Required. + :type conversation_id: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_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. + :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.voiceagents.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 VoiceResponse + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.voiceagents.models.VoiceResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_models.VoiceResponse]] = 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_agent_endpoint_conversations_list_agent_conversation_responses_request( + agent_name=agent_name, + conversation_id=conversation_id, + foundry_features=foundry_features, + 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.VoiceResponse], + 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.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_agent_conversation_response( + self, + agent_name: str, + conversation_id: str, + response_id: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + **kwargs: Any + ) -> _models.VoiceResponse: + """Get a voice agent conversation response. + + Retrieves a single response from the specified conversation by its id, including its ``output`` + items, ``usage``, and status. Returns ``404`` when the conversation or response was not + persisted (``store = false``). + + :param agent_name: The name of the agent. Required. + :type agent_name: str + :param conversation_id: The id of the conversation that contains the response. Required. + :type conversation_id: str + :param response_id: The id of the response to retrieve. Required. + :type response_id: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_V1_PREVIEW + :return: VoiceResponse. The VoiceResponse is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceResponse + :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.VoiceResponse] = kwargs.pop("cls", None) + + _request = build_agent_endpoint_conversations_get_agent_conversation_response_request( + agent_name=agent_name, + conversation_id=conversation_id, + response_id=response_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) + + _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 = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.VoiceResponse, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_agent_conversation_response_items( + self, + agent_name: str, + conversation_id: str, + response_id: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + limit: Optional[int] = None, + order: Optional[Union[str, _models.PageOrder]] = None, + before: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.VoiceConversationItem"]: + """List items produced by a voice agent conversation response. + + Returns a paged collection of the output items produced by a specific response (the response's + output projection). For the complete ordered conversation history — including user input and + client-created tool outputs — use the conversation items route instead. Returns ``404`` when + the conversation or response was not persisted (``store = false``). + + :param agent_name: The name of the agent. Required. + :type agent_name: str + :param conversation_id: The id of the conversation that contains the response. Required. + :type conversation_id: str + :param response_id: The id of the response whose output items are listed. Required. + :type response_id: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_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. + :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.voiceagents.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 VoiceConversationItem + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.ai.voiceagents.models.VoiceConversationItem] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_models.VoiceConversationItem]] = 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_agent_endpoint_conversations_list_agent_conversation_response_items_request( + agent_name=agent_name, + conversation_id=conversation_id, + response_id=response_id, + foundry_features=foundry_features, + 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.VoiceConversationItem], + 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.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_agent_conversation_items( + self, + agent_name: str, + conversation_id: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + limit: Optional[int] = None, + order: Optional[Union[str, _models.PageOrder]] = None, + before: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.VoiceConversationItem"]: + """List items in a voice agent conversation. + + Returns a paged collection of items — the complete ordered conversation history, including user + input, assistant output, and client-created tool outputs (transcripts + tool events). Returns + ``404`` when the conversation was not persisted (``store = false``). + + :param agent_name: The name of the agent. Required. + :type agent_name: str + :param conversation_id: The id of the conversation whose items are listed. Required. + :type conversation_id: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_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. + :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.voiceagents.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 VoiceConversationItem + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.ai.voiceagents.models.VoiceConversationItem] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_models.VoiceConversationItem]] = 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_agent_endpoint_conversations_list_agent_conversation_items_request( + agent_name=agent_name, + conversation_id=conversation_id, + foundry_features=foundry_features, + 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.VoiceConversationItem], + 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.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_agent_conversation_item( + self, + agent_name: str, + conversation_id: str, + item_id: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + **kwargs: Any + ) -> _models.VoiceConversationItem: + """Get a voice agent conversation item. + + Retrieves a single item from the specified conversation by its id, including its transcript. An + ``input_audio``/``output_audio`` content part indicates that audio is available for the item; + the canonical per-item audio metadata is the ``/items/{item_id}/audio`` resource, and the bytes + are streamed by ``/items/{item_id}/audio/content``. Returns ``404`` when the conversation or + item was not persisted (``store = false``). + + :param agent_name: The name of the agent. Required. + :type agent_name: str + :param conversation_id: The id of the conversation that contains the item. Required. + :type conversation_id: str + :param item_id: The id of the conversation item to retrieve. Required. + :type item_id: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_V1_PREVIEW + :return: VoiceConversationItem. The VoiceConversationItem is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceConversationItem + :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.VoiceConversationItem] = kwargs.pop("cls", None) + + _request = build_agent_endpoint_conversations_get_agent_conversation_item_request( + agent_name=agent_name, + conversation_id=conversation_id, + item_id=item_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) + + _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 = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.VoiceConversationItem, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_agent_conversation_item_audio( + self, + agent_name: str, + conversation_id: str, + item_id: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + **kwargs: Any + ) -> _models.VoiceItemAudioResponse: + """Get a voice agent conversation item's audio metadata. + + Returns metadata for a single conversation item's audio segment, including the common playback + facts (role, format/codec, sample rate, channels, offset, duration) for both Foundry-managed + and bring-your-own-storage (BYOS) recordings; for BYOS the response additionally includes + ``blob_uri``, the URI of the recording in the customer's own storage (no SAS) that the customer + downloads with their own credentials. Requires the conversation to have persisted audio + (``store = true``); returns ``404`` when the conversation, item, or its audio was not + persisted. + + :param agent_name: The name of the agent. Required. + :type agent_name: str + :param conversation_id: The id of the conversation that contains the item. Required. + :type conversation_id: str + :param item_id: The id of the conversation item whose audio metadata is retrieved. Required. + :type item_id: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_V1_PREVIEW + :return: VoiceItemAudioResponse. The VoiceItemAudioResponse is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceItemAudioResponse + :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.VoiceItemAudioResponse] = kwargs.pop("cls", None) + + _request = build_agent_endpoint_conversations_get_agent_conversation_item_audio_request( + agent_name=agent_name, + conversation_id=conversation_id, + item_id=item_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) + + _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 = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.VoiceItemAudioResponse, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_agent_conversation_item_audio_content( # pylint: disable=name-too-long + self, + agent_name: str, + conversation_id: str, + item_id: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + **kwargs: Any + ) -> AsyncIterator[bytes]: + """Stream a voice agent conversation item's audio. + + Streams a single conversation item's audio as a WAV (``audio/wav``) byte stream through the + service (no SAS URL). This route serves Foundry-managed storage only. For + bring-your-own-storage (BYOS) recordings the bytes are not proxied — the caller must download + directly from customer storage using the ``blob_uri`` returned by the item's ``/audio`` + metadata route — so this route returns ``409 Conflict`` for BYOS recordings. Returns ``404`` + when the conversation, item, or its audio was not persisted (``store = false``). + + :param agent_name: The name of the agent. Required. + :type agent_name: str + :param conversation_id: The id of the conversation that contains the item. Required. + :type conversation_id: str + :param item_id: The id of the conversation item whose audio is streamed. Required. + :type item_id: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_V1_PREVIEW + :return: AsyncIterator[bytes] + :rtype: AsyncIterator[bytes] + :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[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_agent_endpoint_conversations_get_agent_conversation_item_audio_content_request( + agent_name=agent_name, + conversation_id=conversation_id, + item_id=item_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) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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 + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_agent_conversation_audio( + self, + agent_name: str, + conversation_id: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + **kwargs: Any + ) -> _models.VoiceRecordingResponse: + """Get a voice agent conversation's merged recording metadata. + + Returns metadata for the whole-call merged stereo recording (user audio on the left channel, + agent audio on the right). The common metadata (format, sample rate, channels, channel layout, + duration) is returned for both Foundry-managed and bring-your-own-storage (BYOS) recordings; + for BYOS the response additionally includes ``blob_uri``, the URI of the recording in the + customer's own storage (no SAS) that the customer downloads with their own credentials. The + recording is built once from the per-turn segments after the session ends; a request against an + in-progress session returns ``409``. Requires the conversation to have persisted audio (``store + = true``); otherwise returns ``404``. + + :param agent_name: The name of the agent. Required. + :type agent_name: str + :param conversation_id: The id of the conversation whose merged recording metadata is + retrieved. Required. + :type conversation_id: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_V1_PREVIEW + :return: VoiceRecordingResponse. The VoiceRecordingResponse is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceRecordingResponse + :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.VoiceRecordingResponse] = kwargs.pop("cls", None) + + _request = build_agent_endpoint_conversations_get_agent_conversation_audio_request( + agent_name=agent_name, + conversation_id=conversation_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) + + _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 = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.VoiceRecordingResponse, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_agent_conversation_audio_content( + self, + agent_name: str, + conversation_id: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + **kwargs: Any + ) -> AsyncIterator[bytes]: + """Stream a voice agent conversation's merged recording. + + Streams the whole-call merged stereo recording as a WAV (``audio/wav``) byte stream through the + service (no SAS URL). This route serves Foundry-managed storage only. For + bring-your-own-storage (BYOS) recordings the bytes are not proxied — the caller must download + directly from customer storage using the ``blob_uri`` returned by the metadata route — so this + route returns ``409 Conflict`` for BYOS recordings. A request against an in-progress session + also returns ``409`` (a distinct condition: session-not-ended versus BYOS-download-required). A + conversation without persisted audio (``store = false``) returns ``404``. + + :param agent_name: The name of the agent. Required. + :type agent_name: str + :param conversation_id: The id of the conversation whose merged recording is streamed. + Required. + :type conversation_id: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_V1_PREVIEW + :return: AsyncIterator[bytes] + :rtype: AsyncIterator[bytes] + :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[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_agent_endpoint_conversations_get_agent_conversation_audio_content_request( + agent_name=agent_name, + conversation_id=conversation_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) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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 + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + +class VoiceAgentsOperations: # pylint: disable=docstring-missing-param + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.voiceagents.aio.VoiceAgentsClient`'s + :attr:`voice_agents` 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: VoiceAgentsClientConfiguration = 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_voice_agent( + self, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + name: str, + definition: _models.VoiceAgentDefinition, + content_type: str = "application/json", + state: Optional[Union[str, _models.AgentState]] = None, + metadata: Optional[dict[str, str]] = None, + description: Optional[str] = None, + blueprint_reference: Optional[_models.AgentBlueprintReference] = None, + draft: Optional[bool] = None, + agent_endpoint: Optional[_models.AgentEndpointConfig] = None, + agent_card: Optional[_models.AgentCard] = None, + **kwargs: Any + ) -> _models.VoiceAgentObject: + """Create a voice agent. + + Creates a new voice agent, or a new version of an existing one. + + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_V1_PREVIEW + :keyword 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. + :paramtype name: str + :keyword definition: The voice agent definition. Required. + :paramtype definition: ~azure.ai.voiceagents.models.VoiceAgentDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword state: The initial operational state of the agent. Defaults to 'enabled' if not + specified. Known values are: "enabled" and "disabled". Default value is None. + :paramtype state: str or ~azure.ai.voiceagents.models.AgentState + :keyword 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. + :paramtype metadata: dict[str, str] + :keyword description: A human-readable description of the agent. Default value is None. + :paramtype description: str + :keyword blueprint_reference: The blueprint reference for the agent. Default value is None. + :paramtype blueprint_reference: ~azure.ai.voiceagents.models.AgentBlueprintReference + :keyword draft: (Preview) Whether this agent version is a draft (candidate) rather than a + release. The service defaults to ``false`` if a value is not specified by the caller. Draft + versions are recorded but excluded from default 'latest' resolution and are not auto-promoted. + Default value is None. + :paramtype draft: bool + :keyword agent_endpoint: An optional endpoint configuration. If not specified, a default + endpoint configuration will be set for the agent. Default value is None. + :paramtype agent_endpoint: ~azure.ai.voiceagents.models.AgentEndpointConfig + :keyword agent_card: Optional agent card for the agent. Default value is None. + :paramtype agent_card: ~azure.ai.voiceagents.models.AgentCard + :return: VoiceAgentObject. The VoiceAgentObject is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceAgentObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_voice_agent( + self, + body: _types.CreateVoiceAgentRequest, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VoiceAgentObject: + """Create a voice agent. + + Creates a new voice agent, or a new version of an existing one. + + :param body: Required. + :type body: ~azure.ai.voiceagents.types.CreateVoiceAgentRequest + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_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: VoiceAgentObject. The VoiceAgentObject is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceAgentObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_voice_agent( + self, + body: IO[bytes], + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VoiceAgentObject: + """Create a voice agent. + + Creates a new voice agent, or a new version of an existing one. + + :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. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_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: VoiceAgentObject. The VoiceAgentObject is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceAgentObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_voice_agent( # pylint: disable=too-many-locals + self, + body: Union[JSON, _types.CreateVoiceAgentRequest, IO[bytes]] = _Unset, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + name: str = _Unset, + definition: _models.VoiceAgentDefinition = _Unset, + state: Optional[Union[str, _models.AgentState]] = None, + metadata: Optional[dict[str, str]] = None, + description: Optional[str] = None, + blueprint_reference: Optional[_models.AgentBlueprintReference] = None, + draft: Optional[bool] = None, + agent_endpoint: Optional[_models.AgentEndpointConfig] = None, + agent_card: Optional[_models.AgentCard] = None, + **kwargs: Any + ) -> _models.VoiceAgentObject: + """Create a voice agent. + + Creates a new voice agent, or a new version of an existing one. + + :param body: Is one of the following types: JSON, CreateVoiceAgentRequest, IO[bytes] Required. + :type body: JSON or ~azure.ai.voiceagents.types.CreateVoiceAgentRequest or IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_V1_PREVIEW + :keyword 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. + :paramtype name: str + :keyword definition: The voice agent definition. Required. + :paramtype definition: ~azure.ai.voiceagents.models.VoiceAgentDefinition + :keyword state: The initial operational state of the agent. Defaults to 'enabled' if not + specified. Known values are: "enabled" and "disabled". Default value is None. + :paramtype state: str or ~azure.ai.voiceagents.models.AgentState + :keyword 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. + :paramtype metadata: dict[str, str] + :keyword description: A human-readable description of the agent. Default value is None. + :paramtype description: str + :keyword blueprint_reference: The blueprint reference for the agent. Default value is None. + :paramtype blueprint_reference: ~azure.ai.voiceagents.models.AgentBlueprintReference + :keyword draft: (Preview) Whether this agent version is a draft (candidate) rather than a + release. The service defaults to ``false`` if a value is not specified by the caller. Draft + versions are recorded but excluded from default 'latest' resolution and are not auto-promoted. + Default value is None. + :paramtype draft: bool + :keyword agent_endpoint: An optional endpoint configuration. If not specified, a default + endpoint configuration will be set for the agent. Default value is None. + :paramtype agent_endpoint: ~azure.ai.voiceagents.models.AgentEndpointConfig + :keyword agent_card: Optional agent card for the agent. Default value is None. + :paramtype agent_card: ~azure.ai.voiceagents.models.AgentCard + :return: VoiceAgentObject. The VoiceAgentObject is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceAgentObject + :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.VoiceAgentObject] = 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 = { + "agent_card": agent_card, + "agent_endpoint": agent_endpoint, + "blueprint_reference": blueprint_reference, + "definition": definition, + "description": description, + "draft": draft, + "metadata": metadata, + "name": name, + "state": state, + } + 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_voice_agents_create_voice_agent_request( + foundry_features=foundry_features, + 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) + + _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 = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.VoiceAgentObject, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_voice_agents( + self, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + limit: Optional[int] = None, + order: Optional[Union[str, _models.PageOrder]] = None, + before: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.VoiceAgentObject"]: + """List voice agents. + + Returns a paged collection of voice agents. + + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_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. + :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.voiceagents.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 VoiceAgentObject + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.voiceagents.models.VoiceAgentObject] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_models.VoiceAgentObject]] = 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_voice_agents_list_voice_agents_request( + foundry_features=foundry_features, + 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.VoiceAgentObject], + 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.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_voice_agent( + self, + agent_name: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + **kwargs: Any + ) -> _models.VoiceAgentObject: + """Get a voice agent. + + Retrieves a voice agent by its unique name. + + :param agent_name: The name of the voice agent to retrieve. Required. + :type agent_name: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_V1_PREVIEW + :return: VoiceAgentObject. The VoiceAgentObject is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceAgentObject + :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.VoiceAgentObject] = kwargs.pop("cls", None) + + _request = build_voice_agents_get_voice_agent_request( + agent_name=agent_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) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.VoiceAgentObject, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update_voice_agent( + self, + agent_name: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + definition: _models.VoiceAgentDefinition, + content_type: str = "application/json", + metadata: Optional[dict[str, str]] = None, + description: Optional[str] = None, + blueprint_reference: Optional[_models.AgentBlueprintReference] = None, + **kwargs: Any + ) -> _models.VoiceAgentObject: + """Update a voice agent. + + Updates a voice 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 voice agent to update. Required. + :type agent_name: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_V1_PREVIEW + :keyword definition: The voice agent definition. Required. + :paramtype definition: ~azure.ai.voiceagents.models.VoiceAgentDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword 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. + :paramtype metadata: dict[str, str] + :keyword description: A human-readable description of the agent. Default value is None. + :paramtype description: str + :keyword blueprint_reference: The blueprint reference for the agent. Default value is None. + :paramtype blueprint_reference: ~azure.ai.voiceagents.models.AgentBlueprintReference + :return: VoiceAgentObject. The VoiceAgentObject is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceAgentObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_voice_agent( + self, + agent_name: str, + body: _types.UpdateVoiceAgentRequest, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VoiceAgentObject: + """Update a voice agent. + + Updates a voice 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 voice agent to update. Required. + :type agent_name: str + :param body: Required. + :type body: ~azure.ai.voiceagents.types.UpdateVoiceAgentRequest + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_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: VoiceAgentObject. The VoiceAgentObject is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceAgentObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_voice_agent( + self, + agent_name: str, + body: IO[bytes], + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VoiceAgentObject: + """Update a voice agent. + + Updates a voice 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 voice agent to update. 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. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_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: VoiceAgentObject. The VoiceAgentObject is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceAgentObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update_voice_agent( + self, + agent_name: str, + body: Union[JSON, _types.UpdateVoiceAgentRequest, IO[bytes]] = _Unset, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + definition: _models.VoiceAgentDefinition = _Unset, + metadata: Optional[dict[str, str]] = None, + description: Optional[str] = None, + blueprint_reference: Optional[_models.AgentBlueprintReference] = None, + **kwargs: Any + ) -> _models.VoiceAgentObject: + """Update a voice agent. + + Updates a voice 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 voice agent to update. Required. + :type agent_name: str + :param body: Is one of the following types: JSON, UpdateVoiceAgentRequest, IO[bytes] Required. + :type body: JSON or ~azure.ai.voiceagents.types.UpdateVoiceAgentRequest or IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_V1_PREVIEW + :keyword definition: The voice agent definition. Required. + :paramtype definition: ~azure.ai.voiceagents.models.VoiceAgentDefinition + :keyword 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. + :paramtype metadata: dict[str, str] + :keyword description: A human-readable description of the agent. Default value is None. + :paramtype description: str + :keyword blueprint_reference: The blueprint reference for the agent. Default value is None. + :paramtype blueprint_reference: ~azure.ai.voiceagents.models.AgentBlueprintReference + :return: VoiceAgentObject. The VoiceAgentObject is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceAgentObject + :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.VoiceAgentObject] = kwargs.pop("cls", None) + + if body is _Unset: + if definition is _Unset: + raise TypeError("missing required argument: definition") + body = { + "blueprint_reference": blueprint_reference, + "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" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_voice_agents_update_voice_agent_request( + agent_name=agent_name, + foundry_features=foundry_features, + 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) + + _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 = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.VoiceAgentObject, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete_voice_agent( + self, + agent_name: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + **kwargs: Any + ) -> None: + """Delete a voice agent. + + Deletes a voice agent and all of its versions. + + :param agent_name: The name of the voice agent to delete. Required. + :type agent_name: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_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_voice_agents_delete_voice_agent_request( + agent_name=agent_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) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def enable_voice_agent( + self, + agent_name: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + **kwargs: Any + ) -> None: + """Enable a voice agent. + + Enables the specified voice agent, allowing it to accept new requests. This operation is + idempotent — enabling an already-enabled voice agent returns success with no side effects. + + :param agent_name: The name of the voice agent to enable. Required. + :type agent_name: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_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_voice_agents_enable_voice_agent_request( + agent_name=agent_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) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def disable_voice_agent( + self, + agent_name: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + **kwargs: Any + ) -> None: + """Disable a voice agent. + + Disables the specified voice agent, preventing it from accepting new requests. This operation + is idempotent — disabling an already-disabled voice agent returns success with no side effects. + + :param agent_name: The name of the voice agent to disable. Required. + :type agent_name: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_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_voice_agents_disable_voice_agent_request( + agent_name=agent_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) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + async def generate_voice_agent( + self, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + name: str, + model_type: Union[str, _models.VoiceModelType], + model: str, + agent_type: Union[str, _models.VoiceAgentType], + use_case: Union[str, _models.VoiceAgentUseCase], + goal: str, + content_type: str = "application/json", + description: Optional[str] = None, + tools: Optional[list["_unions.VoiceAgentTool"]] = None, + draft: Optional[bool] = None, + **kwargs: Any + ) -> _models.VoiceAgentObject: + """Generate a voice agent. + + Generates and creates a voice agent from high-level inputs plus a natural-language goal. The + operation expands the goal into a full, editable definition, creates the agent through the + standard voice create path, and returns the created ``VoiceAgentObject``. The caller can edit + or override the generated fields afterward through normal versioning. + + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_V1_PREVIEW + :keyword name: The unique name for the agent to create. Required. + :paramtype name: str + :keyword model_type: How the model backing the generated agent is served: ``managed`` + (service-managed) or ``self_deployed`` (the customer's own deployment). Carried through to the + generated definition, not generated. Known values are: "managed" and "self_deployed". Required. + :paramtype model_type: str or ~azure.ai.voiceagents.models.VoiceModelType + :keyword model: The model paired with ``model_type``: the service-managed model name when + ``managed``, or the customer's Foundry deployment name when ``self_deployed``. Carried through, + not generated. Required. + :paramtype model: str + :keyword agent_type: The persona/tone to steer generation. Known values are: "personal" and + "business". Required. + :paramtype agent_type: str or ~azure.ai.voiceagents.models.VoiceAgentType + :keyword use_case: The scenario-template catalog entry the generator specializes for. Known + values are: "customer_support", "reception", "sales", "travel_assistant", "outreach", + "personal_assistant", "learning", "call_center", and "in_car". Required. + :paramtype use_case: str or ~azure.ai.voiceagents.models.VoiceAgentUseCase + :keyword goal: A natural-language description of what the agent should do; the seed for the + generated ``instructions``. Required. + :paramtype goal: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword description: An optional description for the agent. Generated from ``goal`` when + omitted. Default value is None. + :paramtype description: str + :keyword tools: Optional tools carried through verbatim onto the generated agent (see + ``VoiceAgentTool``). Default value is None. + :paramtype tools: list[~azure.ai.voiceagents.models.RealtimeFunctionTool or + ~azure.ai.voiceagents.models.VoiceAgentMcpTool or ~azure.ai.voiceagents.models.VoiceSystemTool + or ~azure.ai.voiceagents.models.VoiceToolboxTool] + :keyword draft: (Preview) When ``true``, the generated voice agent is created as a draft — an + editable, unpublished version the caller can review and refine before publishing it via the + standard create/version path. The service defaults to ``false`` if a value is not specified by + the caller, in which case the agent is created and published normally. Default value is None. + :paramtype draft: bool + :return: VoiceAgentObject. The VoiceAgentObject is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceAgentObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def generate_voice_agent( + self, + body: _types.GenerateVoiceAgentRequest, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VoiceAgentObject: + """Generate a voice agent. + + Generates and creates a voice agent from high-level inputs plus a natural-language goal. The + operation expands the goal into a full, editable definition, creates the agent through the + standard voice create path, and returns the created ``VoiceAgentObject``. The caller can edit + or override the generated fields afterward through normal versioning. + + :param body: Required. + :type body: ~azure.ai.voiceagents.types.GenerateVoiceAgentRequest + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_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: VoiceAgentObject. The VoiceAgentObject is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceAgentObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def generate_voice_agent( + self, + body: IO[bytes], + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VoiceAgentObject: + """Generate a voice agent. + + Generates and creates a voice agent from high-level inputs plus a natural-language goal. The + operation expands the goal into a full, editable definition, creates the agent through the + standard voice create path, and returns the created ``VoiceAgentObject``. The caller can edit + or override the generated fields afterward through normal versioning. + + :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. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_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: VoiceAgentObject. The VoiceAgentObject is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceAgentObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def generate_voice_agent( # pylint: disable=too-many-locals + self, + body: Union[JSON, _types.GenerateVoiceAgentRequest, IO[bytes]] = _Unset, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + name: str = _Unset, + model_type: Union[str, _models.VoiceModelType] = _Unset, + model: str = _Unset, + agent_type: Union[str, _models.VoiceAgentType] = _Unset, + use_case: Union[str, _models.VoiceAgentUseCase] = _Unset, + goal: str = _Unset, + description: Optional[str] = None, + tools: Optional[list["_unions.VoiceAgentTool"]] = None, + draft: Optional[bool] = None, + **kwargs: Any + ) -> _models.VoiceAgentObject: + """Generate a voice agent. + + Generates and creates a voice agent from high-level inputs plus a natural-language goal. The + operation expands the goal into a full, editable definition, creates the agent through the + standard voice create path, and returns the created ``VoiceAgentObject``. The caller can edit + or override the generated fields afterward through normal versioning. + + :param body: Is one of the following types: JSON, GenerateVoiceAgentRequest, IO[bytes] + Required. + :type body: JSON or ~azure.ai.voiceagents.types.GenerateVoiceAgentRequest or IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_V1_PREVIEW + :keyword name: The unique name for the agent to create. Required. + :paramtype name: str + :keyword model_type: How the model backing the generated agent is served: ``managed`` + (service-managed) or ``self_deployed`` (the customer's own deployment). Carried through to the + generated definition, not generated. Known values are: "managed" and "self_deployed". Required. + :paramtype model_type: str or ~azure.ai.voiceagents.models.VoiceModelType + :keyword model: The model paired with ``model_type``: the service-managed model name when + ``managed``, or the customer's Foundry deployment name when ``self_deployed``. Carried through, + not generated. Required. + :paramtype model: str + :keyword agent_type: The persona/tone to steer generation. Known values are: "personal" and + "business". Required. + :paramtype agent_type: str or ~azure.ai.voiceagents.models.VoiceAgentType + :keyword use_case: The scenario-template catalog entry the generator specializes for. Known + values are: "customer_support", "reception", "sales", "travel_assistant", "outreach", + "personal_assistant", "learning", "call_center", and "in_car". Required. + :paramtype use_case: str or ~azure.ai.voiceagents.models.VoiceAgentUseCase + :keyword goal: A natural-language description of what the agent should do; the seed for the + generated ``instructions``. Required. + :paramtype goal: str + :keyword description: An optional description for the agent. Generated from ``goal`` when + omitted. Default value is None. + :paramtype description: str + :keyword tools: Optional tools carried through verbatim onto the generated agent (see + ``VoiceAgentTool``). Default value is None. + :paramtype tools: list[~azure.ai.voiceagents.models.RealtimeFunctionTool or + ~azure.ai.voiceagents.models.VoiceAgentMcpTool or ~azure.ai.voiceagents.models.VoiceSystemTool + or ~azure.ai.voiceagents.models.VoiceToolboxTool] + :keyword draft: (Preview) When ``true``, the generated voice agent is created as a draft — an + editable, unpublished version the caller can review and refine before publishing it via the + standard create/version path. The service defaults to ``false`` if a value is not specified by + the caller, in which case the agent is created and published normally. Default value is None. + :paramtype draft: bool + :return: VoiceAgentObject. The VoiceAgentObject is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceAgentObject + :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.VoiceAgentObject] = kwargs.pop("cls", None) + + if body is _Unset: + if name is _Unset: + raise TypeError("missing required argument: name") + if model_type is _Unset: + raise TypeError("missing required argument: model_type") + if model is _Unset: + raise TypeError("missing required argument: model") + if agent_type is _Unset: + raise TypeError("missing required argument: agent_type") + if use_case is _Unset: + raise TypeError("missing required argument: use_case") + if goal is _Unset: + raise TypeError("missing required argument: goal") + body = { + "agent_type": agent_type, + "description": description, + "draft": draft, + "goal": goal, + "model": model, + "model_type": model_type, + "name": name, + "tools": tools, + "use_case": use_case, + } + 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_voice_agents_generate_voice_agent_request( + foundry_features=foundry_features, + 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) + + _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 = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.VoiceAgentObject, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_voice_agent_version( + self, + agent_name: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + definition: _models.VoiceAgentDefinition, + content_type: str = "application/json", + metadata: Optional[dict[str, str]] = None, + description: Optional[str] = None, + blueprint_reference: Optional[_models.AgentBlueprintReference] = None, + draft: Optional[bool] = None, + **kwargs: Any + ) -> _models.VoiceAgentVersionObject: + """Create a voice agent version. + + Creates a new version for the specified voice agent and returns the created version resource. + + :param agent_name: The name of the voice agent. Required. + :type agent_name: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_V1_PREVIEW + :keyword definition: The voice agent definition. Required. + :paramtype definition: ~azure.ai.voiceagents.models.VoiceAgentDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword 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. + :paramtype metadata: dict[str, str] + :keyword description: A human-readable description of the agent. Default value is None. + :paramtype description: str + :keyword blueprint_reference: The blueprint reference for the agent. Default value is None. + :paramtype blueprint_reference: ~azure.ai.voiceagents.models.AgentBlueprintReference + :keyword draft: (Preview) Whether this agent version is a draft (candidate) rather than a + release. The service defaults to ``false`` if a value is not specified by the caller. Draft + versions are recorded but excluded from default 'latest' resolution and are not auto-promoted. + Default value is None. + :paramtype draft: bool + :return: VoiceAgentVersionObject. The VoiceAgentVersionObject is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceAgentVersionObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_voice_agent_version( + self, + agent_name: str, + body: _types.CreateVoiceAgentVersionRequest, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VoiceAgentVersionObject: + """Create a voice agent version. + + Creates a new version for the specified voice agent and returns the created version resource. + + :param agent_name: The name of the voice agent. Required. + :type agent_name: str + :param body: Required. + :type body: ~azure.ai.voiceagents.types.CreateVoiceAgentVersionRequest + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_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: VoiceAgentVersionObject. The VoiceAgentVersionObject is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceAgentVersionObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_voice_agent_version( + self, + agent_name: str, + body: IO[bytes], + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VoiceAgentVersionObject: + """Create a voice agent version. + + Creates a new version for the specified voice agent and returns the created version resource. + + :param agent_name: The name of the voice agent. 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. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_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: VoiceAgentVersionObject. The VoiceAgentVersionObject is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceAgentVersionObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_voice_agent_version( + self, + agent_name: str, + body: Union[JSON, _types.CreateVoiceAgentVersionRequest, IO[bytes]] = _Unset, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + definition: _models.VoiceAgentDefinition = _Unset, + metadata: Optional[dict[str, str]] = None, + description: Optional[str] = None, + blueprint_reference: Optional[_models.AgentBlueprintReference] = None, + draft: Optional[bool] = None, + **kwargs: Any + ) -> _models.VoiceAgentVersionObject: + """Create a voice agent version. + + Creates a new version for the specified voice agent and returns the created version resource. + + :param agent_name: The name of the voice agent. Required. + :type agent_name: str + :param body: Is one of the following types: JSON, CreateVoiceAgentVersionRequest, IO[bytes] + Required. + :type body: JSON or ~azure.ai.voiceagents.types.CreateVoiceAgentVersionRequest or IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_V1_PREVIEW + :keyword definition: The voice agent definition. Required. + :paramtype definition: ~azure.ai.voiceagents.models.VoiceAgentDefinition + :keyword 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. + :paramtype metadata: dict[str, str] + :keyword description: A human-readable description of the agent. Default value is None. + :paramtype description: str + :keyword blueprint_reference: The blueprint reference for the agent. Default value is None. + :paramtype blueprint_reference: ~azure.ai.voiceagents.models.AgentBlueprintReference + :keyword draft: (Preview) Whether this agent version is a draft (candidate) rather than a + release. The service defaults to ``false`` if a value is not specified by the caller. Draft + versions are recorded but excluded from default 'latest' resolution and are not auto-promoted. + Default value is None. + :paramtype draft: bool + :return: VoiceAgentVersionObject. The VoiceAgentVersionObject is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceAgentVersionObject + :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.VoiceAgentVersionObject] = kwargs.pop("cls", None) + + if body is _Unset: + if definition is _Unset: + raise TypeError("missing required argument: definition") + body = { + "blueprint_reference": blueprint_reference, + "definition": definition, + "description": description, + "draft": draft, + "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_voice_agents_create_voice_agent_version_request( + agent_name=agent_name, + foundry_features=foundry_features, + 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) + + _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 = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.VoiceAgentVersionObject, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_voice_agent_versions( + self, + agent_name: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + limit: Optional[int] = None, + order: Optional[Union[str, _models.PageOrder]] = None, + before: Optional[str] = None, + include_drafts: Optional[bool] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.VoiceAgentVersionObject"]: + """List voice agent versions. + + Returns a paged collection of versions for the specified voice agent. + + :param agent_name: The name of the voice agent to retrieve versions for. Required. + :type agent_name: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_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. + :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.voiceagents.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 include_drafts: (Preview) Whether to include draft versions in the listing. The + service defaults to ``false`` if a value is not specified by the caller (only non-draft + versions are returned). Default value is None. + :paramtype include_drafts: bool + :return: An iterator like instance of VoiceAgentVersionObject + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.ai.voiceagents.models.VoiceAgentVersionObject] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_models.VoiceAgentVersionObject]] = 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_voice_agents_list_voice_agent_versions_request( + agent_name=agent_name, + foundry_features=foundry_features, + limit=limit, + order=order, + after=_continuation_token, + before=before, + include_drafts=include_drafts, + 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.VoiceAgentVersionObject], + 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.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_voice_agent_version( + self, + agent_name: str, + agent_version: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + **kwargs: Any + ) -> _models.VoiceAgentVersionObject: + """Get a voice agent version. + + Retrieves the specified version of a voice agent by its agent name and version identifier. + + :param agent_name: The name of the voice agent to retrieve. Required. + :type agent_name: str + :param agent_version: The version of the voice agent to retrieve. Required. + :type agent_version: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_V1_PREVIEW + :return: VoiceAgentVersionObject. The VoiceAgentVersionObject is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceAgentVersionObject + :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.VoiceAgentVersionObject] = kwargs.pop("cls", None) + + _request = build_voice_agents_get_voice_agent_version_request( + agent_name=agent_name, + agent_version=agent_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) + + _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 = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.VoiceAgentVersionObject, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete_voice_agent_version( + self, + agent_name: str, + agent_version: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + **kwargs: Any + ) -> None: + """Delete a voice agent version. + + Deletes a specific version of a voice agent. + + :param agent_name: The name of the voice agent to delete. Required. + :type agent_name: str + :param agent_version: The version of the voice agent to delete. Required. + :type agent_version: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_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_voice_agents_delete_voice_agent_version_request( + agent_name=agent_name, + agent_version=agent_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) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/aio/operations/_patch.py b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/aio/operations/_patch.py new file mode 100644 index 000000000000..87676c65a8f0 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/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/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/models/__init__.py b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/models/__init__.py new file mode 100644 index 000000000000..35ef5a6a7339 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/models/__init__.py @@ -0,0 +1,680 @@ +# 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 ._models import ( # type: ignore + A2AProtocolConfiguration, + ActivityProtocolConfiguration, + AgentBlueprintReference, + AgentCard, + AgentCardSkill, + AgentEndpointAuthorizationScheme, + AgentEndpointConfig, + AgentIdentity, + ApiErrorResponse, + AzureAvatarVoiceSyncVoice, + AzureCustomVoice, + AzurePersonalVoice, + AzureRealtimeNativeVoice, + AzureStandardVoice, + AzureVoice, + BotServiceAuthorizationScheme, + BotServiceRbacAuthorizationScheme, + BotServiceTenantAuthorizationScheme, + CreateTranscriptionResponseJsonUsage, + EntraAuthorizationScheme, + Error, + FixedRatioVersionSelectionRule, + InvocationsProtocolConfiguration, + InvocationsWsProtocolConfiguration, + LlmGeneratedVoiceGreetingConfig, + LogProbProperties, + MCPListToolsTool, + MCPListToolsToolAnnotations, + MCPListToolsToolInputSchema, + MCPTool, + MCPToolFilter, + MCPToolRequireApproval, + ManagedAgentIdentityBlueprintReference, + McpProtocolConfiguration, + Metadata, + OpenAIVoice, + ProtocolConfiguration, + RaiConfig, + RealtimeAudioFormats, + RealtimeAudioFormatsAudioPcm, + RealtimeAudioFormatsAudioPcma, + RealtimeAudioFormatsAudioPcmu, + RealtimeConversationItem, + RealtimeConversationItemFunctionCall, + RealtimeConversationItemFunctionCallOutput, + RealtimeConversationItemMessage, + RealtimeConversationItemMessageAssistant, + RealtimeConversationItemMessageAssistantContent, + RealtimeConversationItemMessageSystem, + RealtimeConversationItemMessageSystemContent, + RealtimeConversationItemMessageUser, + RealtimeConversationItemMessageUserContent, + RealtimeFunctionTool, + RealtimeFunctionToolParameters, + RealtimeMCPApprovalRequest, + RealtimeMCPApprovalResponse, + RealtimeMCPError, + RealtimeMCPHTTPError, + RealtimeMCPListTools, + RealtimeMCPProtocolError, + RealtimeMCPToolCall, + RealtimeMCPToolExecutionError, + RealtimeReasoning, + RealtimeResponseStatusDetails, + RealtimeResponseStatusDetailsError, + RealtimeResponseUsage, + RealtimeResponseUsageInputTokenDetails, + RealtimeResponseUsageInputTokenDetailsCachedTokensDetails, + RealtimeResponseUsageOutputTokenDetails, + RealtimeServerEvent, + RealtimeServerEventConversationItemInputAudioTranscriptionFailedError, + RealtimeServerEventRateLimitsUpdatedRateLimits, + RealtimeServerEventResponseContentPartAdded, + RealtimeServerEventResponseContentPartAddedPart, + RealtimeToolChoiceFunction, + ResponsesProtocolConfiguration, + StructuredInputDefinition, + TemplateVoiceGreetingConfig, + Tool, + ToolChoiceFunction, + ToolChoiceMCP, + ToolChoiceParam, + ToolConfig, + TranscriptTextUsageDuration, + TranscriptTextUsageTokens, + TranscriptTextUsageTokensInputTokenDetails, + VersionSelectionRule, + VersionSelector, + VoiceAgentAnimationConfig, + VoiceAgentAvatarIceServer, + VoiceAgentAvatarScene, + VoiceAgentAvatarVideoBackground, + VoiceAgentAvatarVideoCrop, + VoiceAgentAvatarVideoParams, + VoiceAgentAvatarVideoResolution, + VoiceAgentAzureMultilingualSemanticVadTurnDetection, + VoiceAgentAzureSemanticVadTurnDetection, + VoiceAgentClientEventConversationItemCreate, + VoiceAgentClientEventConversationItemDelete, + VoiceAgentClientEventConversationItemRetrieve, + VoiceAgentClientEventConversationItemTruncate, + VoiceAgentClientEventInputAudioBufferAppend, + VoiceAgentClientEventInputAudioBufferClear, + VoiceAgentClientEventInputAudioBufferCommit, + VoiceAgentClientEventOutputAudioBufferClear, + VoiceAgentClientEventResponseCancel, + VoiceAgentClientEventResponseCreate, + VoiceAgentClientEventSessionAvatarConnect, + VoiceAgentClientEventSessionUpdate, + VoiceAgentDefinition, + VoiceAgentEchoCancellation, + VoiceAgentEndOfUtteranceDetection, + VoiceAgentEstimatedCost, + VoiceAgentFileSearchCallItem, + VoiceAgentFileSearchResult, + VoiceAgentHandoffEdgeConfig, + VoiceAgentHandoffEdgeState, + VoiceAgentHandoffGraphConfig, + VoiceAgentHandoffNodeConfig, + VoiceAgentHandoffNodeSessionConfig, + VoiceAgentHandoffNodeState, + VoiceAgentHandoffState, + VoiceAgentInterimResponseConfig, + VoiceAgentLlmInterimResponseConfig, + VoiceAgentMcpAssignedManagedIdentity, + VoiceAgentMcpTool, + VoiceAgentObject, + VoiceAgentObjectVersions, + VoiceAgentRealtimeResponse, + VoiceAgentResponseCreateAudio, + VoiceAgentResponseCreateParams, + VoiceAgentResponseEventAudioContentPart, + VoiceAgentResponseEventTextContentPart, + VoiceAgentSemanticVadTurnDetection, + VoiceAgentServerEventConversationCreated, + VoiceAgentServerEventConversationItemAdded, + VoiceAgentServerEventConversationItemCreated, + VoiceAgentServerEventConversationItemDeleted, + VoiceAgentServerEventConversationItemDone, + VoiceAgentServerEventConversationItemInputAudioTranscriptionCompleted, + VoiceAgentServerEventConversationItemInputAudioTranscriptionDelta, + VoiceAgentServerEventConversationItemInputAudioTranscriptionFailed, + VoiceAgentServerEventConversationItemInputAudioTranscriptionSegment, + VoiceAgentServerEventConversationItemRetrieved, + VoiceAgentServerEventConversationItemTruncated, + VoiceAgentServerEventError, + VoiceAgentServerEventErrorDetails, + VoiceAgentServerEventFileSearchCallCompleted, + VoiceAgentServerEventFileSearchCallInProgress, + VoiceAgentServerEventFileSearchCallSearching, + VoiceAgentServerEventInputAudioBufferCleared, + VoiceAgentServerEventInputAudioBufferCommitted, + VoiceAgentServerEventInputAudioBufferSpeechStarted, + VoiceAgentServerEventInputAudioBufferSpeechStopped, + VoiceAgentServerEventInputAudioBufferTimeoutTriggered, + VoiceAgentServerEventMcpListToolsCompleted, + VoiceAgentServerEventMcpListToolsFailed, + VoiceAgentServerEventMcpListToolsInProgress, + VoiceAgentServerEventOutputAudioBufferCleared, + VoiceAgentServerEventRateLimitsUpdated, + VoiceAgentServerEventResponseAnimationBlendshapesDelta, + VoiceAgentServerEventResponseAnimationBlendshapesDone, + VoiceAgentServerEventResponseAnimationVisemeDelta, + VoiceAgentServerEventResponseAnimationVisemeDone, + VoiceAgentServerEventResponseAudioDelta, + VoiceAgentServerEventResponseAudioDone, + VoiceAgentServerEventResponseAudioTimestampDelta, + VoiceAgentServerEventResponseAudioTimestampDone, + VoiceAgentServerEventResponseAudioTranscriptDelta, + VoiceAgentServerEventResponseAudioTranscriptDone, + VoiceAgentServerEventResponseContentPartDone, + VoiceAgentServerEventResponseCreated, + VoiceAgentServerEventResponseDone, + VoiceAgentServerEventResponseFunctionCallArgumentsDelta, + VoiceAgentServerEventResponseFunctionCallArgumentsDone, + VoiceAgentServerEventResponseMcpCallArgumentsDelta, + VoiceAgentServerEventResponseMcpCallArgumentsDone, + VoiceAgentServerEventResponseMcpCallCompleted, + VoiceAgentServerEventResponseMcpCallFailed, + VoiceAgentServerEventResponseMcpCallInProgress, + VoiceAgentServerEventResponseOutputItemAdded, + VoiceAgentServerEventResponseOutputItemDone, + VoiceAgentServerEventResponseTextDelta, + VoiceAgentServerEventResponseTextDone, + VoiceAgentServerEventResponseVideoDelta, + VoiceAgentServerEventSessionAvatarConnecting, + VoiceAgentServerEventSessionAvatarSwitchToIdle, + VoiceAgentServerEventSessionAvatarSwitchToSpeaking, + VoiceAgentServerEventSessionCreated, + VoiceAgentServerEventSessionHandoffAborted, + VoiceAgentServerEventSessionHandoffCompleted, + VoiceAgentServerEventSessionHandoffStarted, + VoiceAgentServerEventSessionUpdated, + VoiceAgentServerEventWarning, + VoiceAgentServerEventWarningDetails, + VoiceAgentServerEventWebSearchCallCompleted, + VoiceAgentServerEventWebSearchCallInProgress, + VoiceAgentServerEventWebSearchCallSearching, + VoiceAgentServerVadTurnDetection, + VoiceAgentSessionAvatarConfig, + VoiceAgentSessionMcpTool, + VoiceAgentSessionResponseAudio, + VoiceAgentSessionResponseAudioInput, + VoiceAgentSessionResponseAudioOutput, + VoiceAgentSessionResponseConfig, + VoiceAgentSessionUpdateAudio, + VoiceAgentSessionUpdateAudioInput, + VoiceAgentSessionUpdateAudioOutput, + VoiceAgentSessionUpdateConfig, + VoiceAgentStaticInterimResponseConfig, + VoiceAgentTranscriptionPhrase, + VoiceAgentTranscriptionWord, + VoiceAgentVersionObject, + VoiceAgentVoiceAdaptation, + VoiceAgentWebSearchActionFind, + VoiceAgentWebSearchActionOpenPage, + VoiceAgentWebSearchActionSearch, + VoiceAgentWebSearchCallItem, + VoiceAgentWebSearchSource, + VoiceAgentWorkflowActionItem, + VoiceAssistantMessageItem, + VoiceAudioConfig, + VoiceAudioFormat, + VoiceAudioInputConfig, + VoiceAudioOutputConfig, + VoiceAvatarConfig, + VoiceAzureSemanticDetection, + VoiceAzureSemanticDetectionEn, + VoiceAzureSemanticDetectionMultilingual, + VoiceAzureSemanticVadEnTurnDetection, + VoiceAzureSemanticVadMultilingualTurnDetection, + VoiceAzureSemanticVadTurnDetection, + VoiceConversation, + VoiceConversationItem, + VoiceEndOfUtteranceDetection, + VoiceFunctionCallItem, + VoiceFunctionCallOutputItem, + VoiceGreetingConfig, + VoiceInputTranscription, + VoiceItemAudioResponse, + VoiceMcpApprovalRequestItem, + VoiceMcpApprovalResponseItem, + VoiceMcpCallItem, + VoiceMcpListToolsItem, + VoiceMessageItem, + VoiceNoiseReduction, + VoiceRecordingChannelLayout, + VoiceRecordingResponse, + VoiceResponse, + VoiceResponseAudio, + VoiceResponseAudioOutput, + VoiceSemanticVadTurnDetection, + VoiceServerVadTurnDetection, + VoiceSystemMessageItem, + VoiceSystemTool, + VoiceToolboxTool, + VoiceTurnDetection, + VoiceUserMessageItem, +) + +from ._enums import ( # type: ignore + AgentBlueprintReferenceType, + AgentDefinitionOptInKeys, + AgentEndpointAuthorizationSchemeType, + AgentIdentityStatus, + AgentObjectType, + AgentState, + AgentStateSource, + AgentVersionStatus, + AzureRealtimeNativeVoiceName, + AzureVoiceType, + CallableToolAllowedCaller, + CreateTranscriptionResponseJsonUsageType, + PageOrder, + PersonalVoiceModel, + RealtimeAudioFormatsType, + RealtimeClientEventType, + RealtimeConversationItemMessageType, + RealtimeConversationItemType, + RealtimeMcpErrorType, + RealtimeReasoningEffort, + RealtimeServerEventType, + ToolChoiceOptions, + ToolChoiceParamType, + ToolType, + VersionSelectorType, + VoiceAgentAnimationOutputType, + VoiceAgentAvatarOutputProtocol, + VoiceAgentAvatarType, + VoiceAgentAzureSemanticVadType, + VoiceAgentEchoCancellationReferenceSource, + VoiceAgentEndOfUtteranceModel, + VoiceAgentEndOfUtteranceThresholdLevel, + VoiceAgentEstimatedCostStatus, + VoiceAgentFileSearchCallStatus, + VoiceAgentHandoffAbortReason, + VoiceAgentHandoffReasoningEffort, + VoiceAgentHandoffTargetResponse, + VoiceAgentInterimResponseTrigger, + VoiceAgentMcpApprovalMode, + VoiceAgentMcpResponseScheduling, + VoiceAgentPipelineFamily, + VoiceAgentResponseAudioFormat, + VoiceAgentResponseStatus, + VoiceAgentSessionIncludeOption, + VoiceAgentType, + VoiceAgentUseCase, + VoiceAgentWebSearchCallStatus, + VoiceAgentWebSocketSubprotocol, + VoiceAudioCodec, + VoiceAudioContainerFormat, + VoiceAudioFormatType, + VoiceAudioRole, + VoiceAudioTimestampType, + VoiceAvatarOutputProtocol, + VoiceAvatarType, + VoiceConversationItemType, + VoiceConversationStatus, + VoiceEndOfUtteranceDetectionModel, + VoiceEndOfUtteranceThresholdLevel, + VoiceGreetingToolChoice, + VoiceIdsShared, + VoiceInputTranscriptionModel, + VoiceModelType, + VoiceNoiseReductionType, + VoiceOutputModality, + VoiceResponseStatus, + VoiceSystemToolName, + VoiceTurnDetectionType, +) +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "A2AProtocolConfiguration", + "ActivityProtocolConfiguration", + "AgentBlueprintReference", + "AgentCard", + "AgentCardSkill", + "AgentEndpointAuthorizationScheme", + "AgentEndpointConfig", + "AgentIdentity", + "ApiErrorResponse", + "AzureAvatarVoiceSyncVoice", + "AzureCustomVoice", + "AzurePersonalVoice", + "AzureRealtimeNativeVoice", + "AzureStandardVoice", + "AzureVoice", + "BotServiceAuthorizationScheme", + "BotServiceRbacAuthorizationScheme", + "BotServiceTenantAuthorizationScheme", + "CreateTranscriptionResponseJsonUsage", + "EntraAuthorizationScheme", + "Error", + "FixedRatioVersionSelectionRule", + "InvocationsProtocolConfiguration", + "InvocationsWsProtocolConfiguration", + "LlmGeneratedVoiceGreetingConfig", + "LogProbProperties", + "MCPListToolsTool", + "MCPListToolsToolAnnotations", + "MCPListToolsToolInputSchema", + "MCPTool", + "MCPToolFilter", + "MCPToolRequireApproval", + "ManagedAgentIdentityBlueprintReference", + "McpProtocolConfiguration", + "Metadata", + "OpenAIVoice", + "ProtocolConfiguration", + "RaiConfig", + "RealtimeAudioFormats", + "RealtimeAudioFormatsAudioPcm", + "RealtimeAudioFormatsAudioPcma", + "RealtimeAudioFormatsAudioPcmu", + "RealtimeConversationItem", + "RealtimeConversationItemFunctionCall", + "RealtimeConversationItemFunctionCallOutput", + "RealtimeConversationItemMessage", + "RealtimeConversationItemMessageAssistant", + "RealtimeConversationItemMessageAssistantContent", + "RealtimeConversationItemMessageSystem", + "RealtimeConversationItemMessageSystemContent", + "RealtimeConversationItemMessageUser", + "RealtimeConversationItemMessageUserContent", + "RealtimeFunctionTool", + "RealtimeFunctionToolParameters", + "RealtimeMCPApprovalRequest", + "RealtimeMCPApprovalResponse", + "RealtimeMCPError", + "RealtimeMCPHTTPError", + "RealtimeMCPListTools", + "RealtimeMCPProtocolError", + "RealtimeMCPToolCall", + "RealtimeMCPToolExecutionError", + "RealtimeReasoning", + "RealtimeResponseStatusDetails", + "RealtimeResponseStatusDetailsError", + "RealtimeResponseUsage", + "RealtimeResponseUsageInputTokenDetails", + "RealtimeResponseUsageInputTokenDetailsCachedTokensDetails", + "RealtimeResponseUsageOutputTokenDetails", + "RealtimeServerEvent", + "RealtimeServerEventConversationItemInputAudioTranscriptionFailedError", + "RealtimeServerEventRateLimitsUpdatedRateLimits", + "RealtimeServerEventResponseContentPartAdded", + "RealtimeServerEventResponseContentPartAddedPart", + "RealtimeToolChoiceFunction", + "ResponsesProtocolConfiguration", + "StructuredInputDefinition", + "TemplateVoiceGreetingConfig", + "Tool", + "ToolChoiceFunction", + "ToolChoiceMCP", + "ToolChoiceParam", + "ToolConfig", + "TranscriptTextUsageDuration", + "TranscriptTextUsageTokens", + "TranscriptTextUsageTokensInputTokenDetails", + "VersionSelectionRule", + "VersionSelector", + "VoiceAgentAnimationConfig", + "VoiceAgentAvatarIceServer", + "VoiceAgentAvatarScene", + "VoiceAgentAvatarVideoBackground", + "VoiceAgentAvatarVideoCrop", + "VoiceAgentAvatarVideoParams", + "VoiceAgentAvatarVideoResolution", + "VoiceAgentAzureMultilingualSemanticVadTurnDetection", + "VoiceAgentAzureSemanticVadTurnDetection", + "VoiceAgentClientEventConversationItemCreate", + "VoiceAgentClientEventConversationItemDelete", + "VoiceAgentClientEventConversationItemRetrieve", + "VoiceAgentClientEventConversationItemTruncate", + "VoiceAgentClientEventInputAudioBufferAppend", + "VoiceAgentClientEventInputAudioBufferClear", + "VoiceAgentClientEventInputAudioBufferCommit", + "VoiceAgentClientEventOutputAudioBufferClear", + "VoiceAgentClientEventResponseCancel", + "VoiceAgentClientEventResponseCreate", + "VoiceAgentClientEventSessionAvatarConnect", + "VoiceAgentClientEventSessionUpdate", + "VoiceAgentDefinition", + "VoiceAgentEchoCancellation", + "VoiceAgentEndOfUtteranceDetection", + "VoiceAgentEstimatedCost", + "VoiceAgentFileSearchCallItem", + "VoiceAgentFileSearchResult", + "VoiceAgentHandoffEdgeConfig", + "VoiceAgentHandoffEdgeState", + "VoiceAgentHandoffGraphConfig", + "VoiceAgentHandoffNodeConfig", + "VoiceAgentHandoffNodeSessionConfig", + "VoiceAgentHandoffNodeState", + "VoiceAgentHandoffState", + "VoiceAgentInterimResponseConfig", + "VoiceAgentLlmInterimResponseConfig", + "VoiceAgentMcpAssignedManagedIdentity", + "VoiceAgentMcpTool", + "VoiceAgentObject", + "VoiceAgentObjectVersions", + "VoiceAgentRealtimeResponse", + "VoiceAgentResponseCreateAudio", + "VoiceAgentResponseCreateParams", + "VoiceAgentResponseEventAudioContentPart", + "VoiceAgentResponseEventTextContentPart", + "VoiceAgentSemanticVadTurnDetection", + "VoiceAgentServerEventConversationCreated", + "VoiceAgentServerEventConversationItemAdded", + "VoiceAgentServerEventConversationItemCreated", + "VoiceAgentServerEventConversationItemDeleted", + "VoiceAgentServerEventConversationItemDone", + "VoiceAgentServerEventConversationItemInputAudioTranscriptionCompleted", + "VoiceAgentServerEventConversationItemInputAudioTranscriptionDelta", + "VoiceAgentServerEventConversationItemInputAudioTranscriptionFailed", + "VoiceAgentServerEventConversationItemInputAudioTranscriptionSegment", + "VoiceAgentServerEventConversationItemRetrieved", + "VoiceAgentServerEventConversationItemTruncated", + "VoiceAgentServerEventError", + "VoiceAgentServerEventErrorDetails", + "VoiceAgentServerEventFileSearchCallCompleted", + "VoiceAgentServerEventFileSearchCallInProgress", + "VoiceAgentServerEventFileSearchCallSearching", + "VoiceAgentServerEventInputAudioBufferCleared", + "VoiceAgentServerEventInputAudioBufferCommitted", + "VoiceAgentServerEventInputAudioBufferSpeechStarted", + "VoiceAgentServerEventInputAudioBufferSpeechStopped", + "VoiceAgentServerEventInputAudioBufferTimeoutTriggered", + "VoiceAgentServerEventMcpListToolsCompleted", + "VoiceAgentServerEventMcpListToolsFailed", + "VoiceAgentServerEventMcpListToolsInProgress", + "VoiceAgentServerEventOutputAudioBufferCleared", + "VoiceAgentServerEventRateLimitsUpdated", + "VoiceAgentServerEventResponseAnimationBlendshapesDelta", + "VoiceAgentServerEventResponseAnimationBlendshapesDone", + "VoiceAgentServerEventResponseAnimationVisemeDelta", + "VoiceAgentServerEventResponseAnimationVisemeDone", + "VoiceAgentServerEventResponseAudioDelta", + "VoiceAgentServerEventResponseAudioDone", + "VoiceAgentServerEventResponseAudioTimestampDelta", + "VoiceAgentServerEventResponseAudioTimestampDone", + "VoiceAgentServerEventResponseAudioTranscriptDelta", + "VoiceAgentServerEventResponseAudioTranscriptDone", + "VoiceAgentServerEventResponseContentPartDone", + "VoiceAgentServerEventResponseCreated", + "VoiceAgentServerEventResponseDone", + "VoiceAgentServerEventResponseFunctionCallArgumentsDelta", + "VoiceAgentServerEventResponseFunctionCallArgumentsDone", + "VoiceAgentServerEventResponseMcpCallArgumentsDelta", + "VoiceAgentServerEventResponseMcpCallArgumentsDone", + "VoiceAgentServerEventResponseMcpCallCompleted", + "VoiceAgentServerEventResponseMcpCallFailed", + "VoiceAgentServerEventResponseMcpCallInProgress", + "VoiceAgentServerEventResponseOutputItemAdded", + "VoiceAgentServerEventResponseOutputItemDone", + "VoiceAgentServerEventResponseTextDelta", + "VoiceAgentServerEventResponseTextDone", + "VoiceAgentServerEventResponseVideoDelta", + "VoiceAgentServerEventSessionAvatarConnecting", + "VoiceAgentServerEventSessionAvatarSwitchToIdle", + "VoiceAgentServerEventSessionAvatarSwitchToSpeaking", + "VoiceAgentServerEventSessionCreated", + "VoiceAgentServerEventSessionHandoffAborted", + "VoiceAgentServerEventSessionHandoffCompleted", + "VoiceAgentServerEventSessionHandoffStarted", + "VoiceAgentServerEventSessionUpdated", + "VoiceAgentServerEventWarning", + "VoiceAgentServerEventWarningDetails", + "VoiceAgentServerEventWebSearchCallCompleted", + "VoiceAgentServerEventWebSearchCallInProgress", + "VoiceAgentServerEventWebSearchCallSearching", + "VoiceAgentServerVadTurnDetection", + "VoiceAgentSessionAvatarConfig", + "VoiceAgentSessionMcpTool", + "VoiceAgentSessionResponseAudio", + "VoiceAgentSessionResponseAudioInput", + "VoiceAgentSessionResponseAudioOutput", + "VoiceAgentSessionResponseConfig", + "VoiceAgentSessionUpdateAudio", + "VoiceAgentSessionUpdateAudioInput", + "VoiceAgentSessionUpdateAudioOutput", + "VoiceAgentSessionUpdateConfig", + "VoiceAgentStaticInterimResponseConfig", + "VoiceAgentTranscriptionPhrase", + "VoiceAgentTranscriptionWord", + "VoiceAgentVersionObject", + "VoiceAgentVoiceAdaptation", + "VoiceAgentWebSearchActionFind", + "VoiceAgentWebSearchActionOpenPage", + "VoiceAgentWebSearchActionSearch", + "VoiceAgentWebSearchCallItem", + "VoiceAgentWebSearchSource", + "VoiceAgentWorkflowActionItem", + "VoiceAssistantMessageItem", + "VoiceAudioConfig", + "VoiceAudioFormat", + "VoiceAudioInputConfig", + "VoiceAudioOutputConfig", + "VoiceAvatarConfig", + "VoiceAzureSemanticDetection", + "VoiceAzureSemanticDetectionEn", + "VoiceAzureSemanticDetectionMultilingual", + "VoiceAzureSemanticVadEnTurnDetection", + "VoiceAzureSemanticVadMultilingualTurnDetection", + "VoiceAzureSemanticVadTurnDetection", + "VoiceConversation", + "VoiceConversationItem", + "VoiceEndOfUtteranceDetection", + "VoiceFunctionCallItem", + "VoiceFunctionCallOutputItem", + "VoiceGreetingConfig", + "VoiceInputTranscription", + "VoiceItemAudioResponse", + "VoiceMcpApprovalRequestItem", + "VoiceMcpApprovalResponseItem", + "VoiceMcpCallItem", + "VoiceMcpListToolsItem", + "VoiceMessageItem", + "VoiceNoiseReduction", + "VoiceRecordingChannelLayout", + "VoiceRecordingResponse", + "VoiceResponse", + "VoiceResponseAudio", + "VoiceResponseAudioOutput", + "VoiceSemanticVadTurnDetection", + "VoiceServerVadTurnDetection", + "VoiceSystemMessageItem", + "VoiceSystemTool", + "VoiceToolboxTool", + "VoiceTurnDetection", + "VoiceUserMessageItem", + "AgentBlueprintReferenceType", + "AgentDefinitionOptInKeys", + "AgentEndpointAuthorizationSchemeType", + "AgentIdentityStatus", + "AgentObjectType", + "AgentState", + "AgentStateSource", + "AgentVersionStatus", + "AzureRealtimeNativeVoiceName", + "AzureVoiceType", + "CallableToolAllowedCaller", + "CreateTranscriptionResponseJsonUsageType", + "PageOrder", + "PersonalVoiceModel", + "RealtimeAudioFormatsType", + "RealtimeClientEventType", + "RealtimeConversationItemMessageType", + "RealtimeConversationItemType", + "RealtimeMcpErrorType", + "RealtimeReasoningEffort", + "RealtimeServerEventType", + "ToolChoiceOptions", + "ToolChoiceParamType", + "ToolType", + "VersionSelectorType", + "VoiceAgentAnimationOutputType", + "VoiceAgentAvatarOutputProtocol", + "VoiceAgentAvatarType", + "VoiceAgentAzureSemanticVadType", + "VoiceAgentEchoCancellationReferenceSource", + "VoiceAgentEndOfUtteranceModel", + "VoiceAgentEndOfUtteranceThresholdLevel", + "VoiceAgentEstimatedCostStatus", + "VoiceAgentFileSearchCallStatus", + "VoiceAgentHandoffAbortReason", + "VoiceAgentHandoffReasoningEffort", + "VoiceAgentHandoffTargetResponse", + "VoiceAgentInterimResponseTrigger", + "VoiceAgentMcpApprovalMode", + "VoiceAgentMcpResponseScheduling", + "VoiceAgentPipelineFamily", + "VoiceAgentResponseAudioFormat", + "VoiceAgentResponseStatus", + "VoiceAgentSessionIncludeOption", + "VoiceAgentType", + "VoiceAgentUseCase", + "VoiceAgentWebSearchCallStatus", + "VoiceAgentWebSocketSubprotocol", + "VoiceAudioCodec", + "VoiceAudioContainerFormat", + "VoiceAudioFormatType", + "VoiceAudioRole", + "VoiceAudioTimestampType", + "VoiceAvatarOutputProtocol", + "VoiceAvatarType", + "VoiceConversationItemType", + "VoiceConversationStatus", + "VoiceEndOfUtteranceDetectionModel", + "VoiceEndOfUtteranceThresholdLevel", + "VoiceGreetingToolChoice", + "VoiceIdsShared", + "VoiceInputTranscriptionModel", + "VoiceModelType", + "VoiceNoiseReductionType", + "VoiceOutputModality", + "VoiceResponseStatus", + "VoiceSystemToolName", + "VoiceTurnDetectionType", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/models/_enums.py b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/models/_enums.py new file mode 100644 index 000000000000..20bcab760940 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/models/_enums.py @@ -0,0 +1,1084 @@ +# 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 enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class AgentBlueprintReferenceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of AgentBlueprintReferenceType.""" + + MANAGED_AGENT_IDENTITY_BLUEPRINT = "ManagedAgentIdentityBlueprint" + """MANAGED_AGENT_IDENTITY_BLUEPRINT.""" + + +class AgentDefinitionOptInKeys(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Feature opt-in keys for agent definition operations supporting hosted or workflow agents.""" + + WORKFLOW_AGENTS_V1_PREVIEW = "WorkflowAgents=V1Preview" + """WORKFLOW_AGENTS_V1_PREVIEW.""" + EXTERNAL_AGENTS_V1_PREVIEW = "ExternalAgents=V1Preview" + """EXTERNAL_AGENTS_V1_PREVIEW.""" + DRAFT_AGENTS_V1_PREVIEW = "DraftAgents=V1Preview" + """DRAFT_AGENTS_V1_PREVIEW.""" + VOICE_AGENTS_V1_PREVIEW = "VoiceAgents=V1Preview" + """VOICE_AGENTS_V1_PREVIEW.""" + + +class AgentEndpointAuthorizationSchemeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of AgentEndpointAuthorizationSchemeType.""" + + ENTRA = "Entra" + """ENTRA.""" + BOT_SERVICE = "BotService" + """BOT_SERVICE.""" + BOT_SERVICE_RBAC = "BotServiceRbac" + """BOT_SERVICE_RBAC.""" + BOT_SERVICE_TENANT = "BotServiceTenant" + """BOT_SERVICE_TENANT.""" + + +class AgentIdentityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of an agent identity, applicable to both the agent instance identity and the agent + blueprint. + """ + + ACTIVE = "active" + """The agent identity is active and can be used to access resources.""" + DISABLED = "disabled" + """The agent identity is disabled and cannot be used to access resources.""" + + +class AgentObjectType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of AgentObjectType.""" + + AGENT = "agent" + """AGENT.""" + AGENT_VERSION = "agent.version" + """AGENT_VERSION.""" + AGENT_DELETED = "agent.deleted" + """AGENT_DELETED.""" + AGENT_VERSION_DELETED = "agent.version.deleted" + """AGENT_VERSION_DELETED.""" + AGENT_CONTAINER = "agent.container" + """AGENT_CONTAINER.""" + + +class AgentState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The operational state of an agent.""" + + ENABLED = "enabled" + """Agent endpoint accepts requests. This is the default state on creation.""" + DISABLED = "disabled" + """Agent endpoint rejects all requests.""" + + +class AgentStateSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates the source of an agent's operational state. Empty when the state is not derived from + a specific source. + """ + + AGENT_INSTANCE_IDENTITY = "agent_instance_identity" + """The state is derived from the agent's instance identity.""" + AGENT_BLUEPRINT = "agent_blueprint" + """The state is derived from the agent's blueprint.""" + + +class AgentVersionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning status of an agent version.""" + + CREATING = "creating" + """The agent version is being provisioned.""" + ACTIVE = "active" + """The agent version is active and ready to serve requests.""" + FAILED = "failed" + """The agent version provisioning failed.""" + DELETING = "deleting" + """The agent version is being deleted.""" + DELETED = "deleted" + """The agent version has been deleted.""" + + +class AzureRealtimeNativeVoiceName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """A known Azure realtime-native voice name. This union is extensible, so additional + service-supported names do not require an SDK update. + """ + + AARTI = "aarti" + """The Aarti voice.""" + ALVARO = "alvaro" + """The Alvaro voice.""" + ANDREW = "andrew" + """The Andrew voice.""" + ANTONIO = "antonio" + """The Antonio voice.""" + AVA = "ava" + """The Ava voice.""" + CLARA = "clara" + """The Clara voice.""" + DALIA = "dalia" + """The Dalia voice.""" + DENISE = "denise" + """The Denise voice.""" + DIEGO = "diego" + """The Diego voice.""" + DIYA = "diya" + """The Diya voice.""" + ELSA = "elsa" + """The Elsa voice.""" + EMMA = "emma" + """The Emma voice.""" + FLORIAN = "florian" + """The Florian voice.""" + FRANCISCA = "francisca" + """The Francisca voice.""" + HYUNSU = "hyunsu" + """The Hyunsu voice.""" + JORGE = "jorge" + """The Jorge voice.""" + KEITA = "keita" + """The Keita voice.""" + LIAM = "liam" + """The Liam voice.""" + MEERA = "meera" + """The Meera voice.""" + NANAMI = "nanami" + """The Nanami voice.""" + NATASHA = "natasha" + """The Natasha voice.""" + NIWAT = "niwat" + """The Niwat voice.""" + PREMWADEE = "premwadee" + """The Premwadee voice.""" + REMY = "remy" + """The Remy voice.""" + RYAN = "ryan" + """The Ryan voice.""" + SERAPHINA = "seraphina" + """The Seraphina voice.""" + SONIA = "sonia" + """The Sonia voice.""" + SUNHI = "sunhi" + """The Sunhi voice.""" + SYLVIE = "sylvie" + """The Sylvie voice.""" + THIERRY = "thierry" + """The Thierry voice.""" + WILLIAM = "william" + """The William voice.""" + XIAOXIAO = "xiaoxiao" + """The Xiaoxiao voice.""" + XIMENA = "ximena" + """The Ximena voice.""" + YUNXI = "yunxi" + """The Yunxi voice.""" + + +class AzureVoiceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The Azure synthesized voice kind. Additional values may be added over time.""" + + AZURE_STANDARD = "azure-standard" + """An Azure standard neural voice.""" + AZURE_CUSTOM = "azure-custom" + """An Azure custom neural voice.""" + AZURE_PERSONAL = "azure-personal" + """An Azure personal voice.""" + AVATAR_VOICE_SYNC = "avatar-voice-sync" + """An Azure avatar voice-synchronization voice.""" + + +class CallableToolAllowedCaller(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of CallableToolAllowedCaller.""" + + DIRECT = "direct" + """DIRECT.""" + PROGRAMMATIC = "programmatic" + """PROGRAMMATIC.""" + + +class CreateTranscriptionResponseJsonUsageType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of CreateTranscriptionResponseJsonUsageType.""" + + TOKENS = "tokens" + """TOKENS.""" + DURATION = "duration" + """DURATION.""" + + +class PageOrder(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of PageOrder.""" + + ASC = "asc" + """ASC.""" + DESC = "desc" + """DESC.""" + + +class PersonalVoiceModel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """A known neural model for an Azure personal or avatar voice. Additional values may be added over + time. + """ + + DRAGON_LATEST_NEURAL = "DragonLatestNeural" + """The latest Dragon model.""" + DRAGON_HD_OMNI_LATEST_NEURAL = "DragonHDOmniLatestNeural" + """The latest Dragon HD Omni model.""" + MAI_VOICE = "MAI-Voice" + """The MAI-Voice model.""" + + +class RealtimeAudioFormatsType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of RealtimeAudioFormatsType.""" + + AUDIO_PCM = "audio/pcm" + """AUDIO_PCM.""" + AUDIO_PCMU = "audio/pcmu" + """AUDIO_PCMU.""" + AUDIO_PCMA = "audio/pcma" + """AUDIO_PCMA.""" + + +class RealtimeClientEventType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of RealtimeClientEventType.""" + + CONVERSATION_ITEM_CREATE = "conversation.item.create" + """CONVERSATION_ITEM_CREATE.""" + CONVERSATION_ITEM_DELETE = "conversation.item.delete" + """CONVERSATION_ITEM_DELETE.""" + CONVERSATION_ITEM_RETRIEVE = "conversation.item.retrieve" + """CONVERSATION_ITEM_RETRIEVE.""" + CONVERSATION_ITEM_TRUNCATE = "conversation.item.truncate" + """CONVERSATION_ITEM_TRUNCATE.""" + INPUT_AUDIO_BUFFER_APPEND = "input_audio_buffer.append" + """INPUT_AUDIO_BUFFER_APPEND.""" + INPUT_AUDIO_BUFFER_CLEAR = "input_audio_buffer.clear" + """INPUT_AUDIO_BUFFER_CLEAR.""" + OUTPUT_AUDIO_BUFFER_CLEAR = "output_audio_buffer.clear" + """OUTPUT_AUDIO_BUFFER_CLEAR.""" + INPUT_AUDIO_BUFFER_COMMIT = "input_audio_buffer.commit" + """INPUT_AUDIO_BUFFER_COMMIT.""" + RESPONSE_CANCEL = "response.cancel" + """RESPONSE_CANCEL.""" + RESPONSE_CREATE = "response.create" + """RESPONSE_CREATE.""" + SESSION_UPDATE = "session.update" + """SESSION_UPDATE.""" + + +class RealtimeConversationItemMessageType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of RealtimeConversationItemMessageType.""" + + SYSTEM = "system" + """SYSTEM.""" + USER = "user" + """USER.""" + ASSISTANT = "assistant" + """ASSISTANT.""" + + +class RealtimeConversationItemType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of RealtimeConversationItemType.""" + + FUNCTION_CALL = "function_call" + """FUNCTION_CALL.""" + FUNCTION_CALL_OUTPUT = "function_call_output" + """FUNCTION_CALL_OUTPUT.""" + MCP_APPROVAL_RESPONSE = "mcp_approval_response" + """MCP_APPROVAL_RESPONSE.""" + MCP_LIST_TOOLS = "mcp_list_tools" + """MCP_LIST_TOOLS.""" + MCP_CALL = "mcp_call" + """MCP_CALL.""" + MCP_APPROVAL_REQUEST = "mcp_approval_request" + """MCP_APPROVAL_REQUEST.""" + + +class RealtimeMcpErrorType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of RealtimeMcpErrorType.""" + + PROTOCOL_ERROR = "protocol_error" + """PROTOCOL_ERROR.""" + TOOL_EXECUTION_ERROR = "tool_execution_error" + """TOOL_EXECUTION_ERROR.""" + HTTP_ERROR = "http_error" + """HTTP_ERROR.""" + + +class RealtimeReasoningEffort(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Constrains effort on reasoning for reasoning-capable Realtime models such as + ``gpt-realtime-2``. + """ + + MINIMAL = "minimal" + """MINIMAL.""" + LOW = "low" + """LOW.""" + MEDIUM = "medium" + """MEDIUM.""" + HIGH = "high" + """HIGH.""" + XHIGH = "xhigh" + """XHIGH.""" + + +class RealtimeServerEventType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of RealtimeServerEventType.""" + + CONVERSATION_CREATED = "conversation.created" + """CONVERSATION_CREATED.""" + CONVERSATION_ITEM_CREATED = "conversation.item.created" + """CONVERSATION_ITEM_CREATED.""" + CONVERSATION_ITEM_DELETED = "conversation.item.deleted" + """CONVERSATION_ITEM_DELETED.""" + CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_COMPLETED = "conversation.item.input_audio_transcription.completed" + """CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_COMPLETED.""" + CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_DELTA = "conversation.item.input_audio_transcription.delta" + """CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_DELTA.""" + CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_FAILED = "conversation.item.input_audio_transcription.failed" + """CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_FAILED.""" + CONVERSATION_ITEM_RETRIEVED = "conversation.item.retrieved" + """CONVERSATION_ITEM_RETRIEVED.""" + CONVERSATION_ITEM_TRUNCATED = "conversation.item.truncated" + """CONVERSATION_ITEM_TRUNCATED.""" + ERROR = "error" + """ERROR.""" + INPUT_AUDIO_BUFFER_CLEARED = "input_audio_buffer.cleared" + """INPUT_AUDIO_BUFFER_CLEARED.""" + INPUT_AUDIO_BUFFER_COMMITTED = "input_audio_buffer.committed" + """INPUT_AUDIO_BUFFER_COMMITTED.""" + INPUT_AUDIO_BUFFER_DTMF_EVENT_RECEIVED = "input_audio_buffer.dtmf_event_received" + """INPUT_AUDIO_BUFFER_DTMF_EVENT_RECEIVED.""" + INPUT_AUDIO_BUFFER_SPEECH_STARTED = "input_audio_buffer.speech_started" + """INPUT_AUDIO_BUFFER_SPEECH_STARTED.""" + INPUT_AUDIO_BUFFER_SPEECH_STOPPED = "input_audio_buffer.speech_stopped" + """INPUT_AUDIO_BUFFER_SPEECH_STOPPED.""" + RATE_LIMITS_UPDATED = "rate_limits.updated" + """RATE_LIMITS_UPDATED.""" + RESPONSE_OUTPUT_AUDIO_DELTA = "response.output_audio.delta" + """RESPONSE_OUTPUT_AUDIO_DELTA.""" + RESPONSE_OUTPUT_AUDIO_DONE = "response.output_audio.done" + """RESPONSE_OUTPUT_AUDIO_DONE.""" + RESPONSE_OUTPUT_AUDIO_TRANSCRIPT_DELTA = "response.output_audio_transcript.delta" + """RESPONSE_OUTPUT_AUDIO_TRANSCRIPT_DELTA.""" + RESPONSE_OUTPUT_AUDIO_TRANSCRIPT_DONE = "response.output_audio_transcript.done" + """RESPONSE_OUTPUT_AUDIO_TRANSCRIPT_DONE.""" + RESPONSE_CONTENT_PART_ADDED = "response.content_part.added" + """RESPONSE_CONTENT_PART_ADDED.""" + RESPONSE_CONTENT_PART_DONE = "response.content_part.done" + """RESPONSE_CONTENT_PART_DONE.""" + RESPONSE_CREATED = "response.created" + """RESPONSE_CREATED.""" + RESPONSE_DONE = "response.done" + """RESPONSE_DONE.""" + RESPONSE_FUNCTION_CALL_ARGUMENTS_DELTA = "response.function_call_arguments.delta" + """RESPONSE_FUNCTION_CALL_ARGUMENTS_DELTA.""" + RESPONSE_FUNCTION_CALL_ARGUMENTS_DONE = "response.function_call_arguments.done" + """RESPONSE_FUNCTION_CALL_ARGUMENTS_DONE.""" + RESPONSE_OUTPUT_ITEM_ADDED = "response.output_item.added" + """RESPONSE_OUTPUT_ITEM_ADDED.""" + RESPONSE_OUTPUT_ITEM_DONE = "response.output_item.done" + """RESPONSE_OUTPUT_ITEM_DONE.""" + RESPONSE_OUTPUT_TEXT_DELTA = "response.output_text.delta" + """RESPONSE_OUTPUT_TEXT_DELTA.""" + RESPONSE_OUTPUT_TEXT_DONE = "response.output_text.done" + """RESPONSE_OUTPUT_TEXT_DONE.""" + SESSION_CREATED = "session.created" + """SESSION_CREATED.""" + SESSION_UPDATED = "session.updated" + """SESSION_UPDATED.""" + OUTPUT_AUDIO_BUFFER_STARTED = "output_audio_buffer.started" + """OUTPUT_AUDIO_BUFFER_STARTED.""" + OUTPUT_AUDIO_BUFFER_STOPPED = "output_audio_buffer.stopped" + """OUTPUT_AUDIO_BUFFER_STOPPED.""" + OUTPUT_AUDIO_BUFFER_CLEARED = "output_audio_buffer.cleared" + """OUTPUT_AUDIO_BUFFER_CLEARED.""" + CONVERSATION_ITEM_ADDED = "conversation.item.added" + """CONVERSATION_ITEM_ADDED.""" + CONVERSATION_ITEM_DONE = "conversation.item.done" + """CONVERSATION_ITEM_DONE.""" + INPUT_AUDIO_BUFFER_TIMEOUT_TRIGGERED = "input_audio_buffer.timeout_triggered" + """INPUT_AUDIO_BUFFER_TIMEOUT_TRIGGERED.""" + CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_SEGMENT = "conversation.item.input_audio_transcription.segment" + """CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_SEGMENT.""" + MCP_LIST_TOOLS_IN_PROGRESS = "mcp_list_tools.in_progress" + """MCP_LIST_TOOLS_IN_PROGRESS.""" + MCP_LIST_TOOLS_COMPLETED = "mcp_list_tools.completed" + """MCP_LIST_TOOLS_COMPLETED.""" + MCP_LIST_TOOLS_FAILED = "mcp_list_tools.failed" + """MCP_LIST_TOOLS_FAILED.""" + RESPONSE_MCP_CALL_ARGUMENTS_DELTA = "response.mcp_call_arguments.delta" + """RESPONSE_MCP_CALL_ARGUMENTS_DELTA.""" + RESPONSE_MCP_CALL_ARGUMENTS_DONE = "response.mcp_call_arguments.done" + """RESPONSE_MCP_CALL_ARGUMENTS_DONE.""" + RESPONSE_MCP_CALL_IN_PROGRESS = "response.mcp_call.in_progress" + """RESPONSE_MCP_CALL_IN_PROGRESS.""" + RESPONSE_MCP_CALL_COMPLETED = "response.mcp_call.completed" + """RESPONSE_MCP_CALL_COMPLETED.""" + RESPONSE_MCP_CALL_FAILED = "response.mcp_call.failed" + """RESPONSE_MCP_CALL_FAILED.""" + + +class ToolChoiceOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Tool choice mode.""" + + NONE = "none" + """NONE.""" + AUTO = "auto" + """AUTO.""" + REQUIRED = "required" + """REQUIRED.""" + + +class ToolChoiceParamType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of ToolChoiceParamType.""" + + ALLOWED_TOOLS = "allowed_tools" + """ALLOWED_TOOLS.""" + FUNCTION = "function" + """FUNCTION.""" + MCP = "mcp" + """MCP.""" + CUSTOM = "custom" + """CUSTOM.""" + PROGRAMMATIC_TOOL_CALLING = "programmatic_tool_calling" + """PROGRAMMATIC_TOOL_CALLING.""" + APPLY_PATCH = "apply_patch" + """APPLY_PATCH.""" + SHELL = "shell" + """SHELL.""" + FILE_SEARCH = "file_search" + """FILE_SEARCH.""" + WEB_SEARCH_PREVIEW = "web_search_preview" + """WEB_SEARCH_PREVIEW.""" + COMPUTER_USE_PREVIEW = "computer_use_preview" + """COMPUTER_USE_PREVIEW.""" + WEB_SEARCH_PREVIEW2025_03_11 = "web_search_preview_2025_03_11" + """WEB_SEARCH_PREVIEW2025_03_11.""" + IMAGE_GENERATION = "image_generation" + """IMAGE_GENERATION.""" + CODE_INTERPRETER = "code_interpreter" + """CODE_INTERPRETER.""" + COMPUTER = "computer" + """COMPUTER.""" + COMPUTER_USE = "computer_use" + """COMPUTER_USE.""" + + +class ToolType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of ToolType.""" + + FUNCTION = "function" + """FUNCTION.""" + FILE_SEARCH = "file_search" + """FILE_SEARCH.""" + COMPUTER = "computer" + """COMPUTER.""" + COMPUTER_USE_PREVIEW = "computer_use_preview" + """COMPUTER_USE_PREVIEW.""" + WEB_SEARCH = "web_search" + """WEB_SEARCH.""" + MCP = "mcp" + """MCP.""" + CODE_INTERPRETER = "code_interpreter" + """CODE_INTERPRETER.""" + PROGRAMMATIC_TOOL_CALLING = "programmatic_tool_calling" + """PROGRAMMATIC_TOOL_CALLING.""" + IMAGE_GENERATION = "image_generation" + """IMAGE_GENERATION.""" + LOCAL_SHELL = "local_shell" + """LOCAL_SHELL.""" + SHELL = "shell" + """SHELL.""" + CUSTOM = "custom" + """CUSTOM.""" + NAMESPACE = "namespace" + """NAMESPACE.""" + TOOL_SEARCH = "tool_search" + """TOOL_SEARCH.""" + WEB_SEARCH_PREVIEW = "web_search_preview" + """WEB_SEARCH_PREVIEW.""" + APPLY_PATCH = "apply_patch" + """APPLY_PATCH.""" + A2_A_PREVIEW = "a2a_preview" + """A2_A_PREVIEW.""" + BING_CUSTOM_SEARCH_PREVIEW = "bing_custom_search_preview" + """BING_CUSTOM_SEARCH_PREVIEW.""" + BROWSER_AUTOMATION_PREVIEW = "browser_automation_preview" + """BROWSER_AUTOMATION_PREVIEW.""" + FABRIC_DATAAGENT_PREVIEW = "fabric_dataagent_preview" + """FABRIC_DATAAGENT_PREVIEW.""" + SHAREPOINT_GROUNDING_PREVIEW = "sharepoint_grounding_preview" + """SHAREPOINT_GROUNDING_PREVIEW.""" + MEMORY_SEARCH_PREVIEW = "memory_search_preview" + """MEMORY_SEARCH_PREVIEW.""" + WORK_IQ_PREVIEW = "work_iq_preview" + """WORK_IQ_PREVIEW.""" + FABRIC_IQ_PREVIEW = "fabric_iq_preview" + """FABRIC_IQ_PREVIEW.""" + TOOLBOX_SEARCH_PREVIEW = "toolbox_search_preview" + """TOOLBOX_SEARCH_PREVIEW.""" + AZURE_AI_SEARCH = "azure_ai_search" + """AZURE_AI_SEARCH.""" + AZURE_FUNCTION = "azure_function" + """AZURE_FUNCTION.""" + BING_GROUNDING = "bing_grounding" + """BING_GROUNDING.""" + CAPTURE_STRUCTURED_OUTPUTS = "capture_structured_outputs" + """CAPTURE_STRUCTURED_OUTPUTS.""" + OPENAPI = "openapi" + """OPENAPI.""" + + +class VersionSelectorType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of VersionSelectorType.""" + + FIXED_RATIO = "FixedRatio" + """FIXED_RATIO.""" + + +class VoiceAgentAnimationOutputType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """An animation output produced by a voice-agent session.""" + + BLENDSHAPES = "blendshapes" + """BLENDSHAPES.""" + VISEME_ID = "viseme_id" + """VISEME_ID.""" + + +class VoiceAgentAvatarOutputProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The transport used to deliver avatar media.""" + + WEBSOCKET = "websocket" + """WEBSOCKET.""" + WEBSOCKET_BINARY = "websocket-binary" + """WEBSOCKET_BINARY.""" + WEBRTC = "webrtc" + """WEBRTC.""" + + +class VoiceAgentAvatarType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The avatar implementation.""" + + VIDEO_AVATAR = "video_avatar" + """VIDEO_AVATAR.""" + PHOTO_AVATAR = "photo_avatar" + """PHOTO_AVATAR.""" + + +class VoiceAgentAzureSemanticVadType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The discriminator for an Azure semantic VAD configuration.""" + + DEFAULT = "azure_semantic_vad" + """DEFAULT.""" + ENGLISH = "azure_semantic_vad_en" + """ENGLISH.""" + + +class VoiceAgentEchoCancellationReferenceSource( # pylint: disable=name-too-long + str, Enum, metaclass=CaseInsensitiveEnumMeta +): + """The source of reference audio used for echo cancellation.""" + + SERVER = "server" + """SERVER.""" + CLIENT = "client" + """CLIENT.""" + + +class VoiceAgentEndOfUtteranceModel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """An end-of-utterance detector model.""" + + SEMANTIC_DETECTION_V1 = "semantic_detection_v1" + """SEMANTIC_DETECTION_V1.""" + SEMANTIC_DETECTION_V1_EN = "semantic_detection_v1_en" + """SEMANTIC_DETECTION_V1_EN.""" + SEMANTIC_DETECTION_V1_MULTILINGUAL = "semantic_detection_v1_multilingual" + """SEMANTIC_DETECTION_V1_MULTILINGUAL.""" + SMART_END_OF_TURN_DETECTION = "smart_end_of_turn_detection" + """SMART_END_OF_TURN_DETECTION.""" + + +class VoiceAgentEndOfUtteranceThresholdLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """A threshold preset for end-of-utterance detection.""" + + LOW = "low" + """LOW.""" + MEDIUM = "medium" + """MEDIUM.""" + HIGH = "high" + """HIGH.""" + DEFAULT = "default" + """DEFAULT.""" + + +class VoiceAgentEstimatedCostStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Completeness of a best-effort cost estimate.""" + + COMPLETE = "complete" + """COMPLETE.""" + PARTIAL = "partial" + """PARTIAL.""" + UNAVAILABLE = "unavailable" + """UNAVAILABLE.""" + + +class VoiceAgentFileSearchCallStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of a file-search call.""" + + IN_PROGRESS = "in_progress" + """IN_PROGRESS.""" + SEARCHING = "searching" + """SEARCHING.""" + COMPLETED = "completed" + """COMPLETED.""" + INCOMPLETE = "incomplete" + """INCOMPLETE.""" + FAILED = "failed" + """FAILED.""" + + +class VoiceAgentHandoffAbortReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Why a handoff ended before the target behavior committed.""" + + USER_INTERRUPTION = "user_interruption" + """USER_INTERRUPTION.""" + ERROR = "error" + """ERROR.""" + + +class VoiceAgentHandoffReasoningEffort(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Reasoning effort accepted by a handoff target.""" + + NONE = "none" + """NONE.""" + MINIMAL = "minimal" + """MINIMAL.""" + LOW = "low" + """LOW.""" + MEDIUM = "medium" + """MEDIUM.""" + HIGH = "high" + """HIGH.""" + XHIGH = "xhigh" + """XHIGH.""" + + +class VoiceAgentHandoffTargetResponse(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether a handoff target creates a response after transfer.""" + + AUTO = "auto" + """AUTO.""" + NONE = "none" + """NONE.""" + + +class VoiceAgentInterimResponseTrigger(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """A condition that may trigger an interim response.""" + + LATENCY = "latency" + """LATENCY.""" + TOOL = "tool" + """TOOL.""" + + +class VoiceAgentMcpApprovalMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """An MCP approval mode.""" + + NEVER_REQUIRE = "never" + """NEVER_REQUIRE.""" + ALWAYS = "always" + """ALWAYS.""" + + +class VoiceAgentMcpResponseScheduling(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """When an MCP invocation creates a follow-up response. Additional values may be added over time.""" + + SILENT = "silent" + """Do not create a follow-up response after the MCP invocation completes.""" + WHEN_IDLE = "when_idle" + """Create a follow-up response when the conversation is idle.""" + INTERRUPT = "interrupt" + """Interrupt the active response and create a follow-up response.""" + SKIP_IF_BUSY = "skip_if_busy" + """Create a follow-up response only when no response is active.""" + + +class VoiceAgentPipelineFamily(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The runtime pipeline family used by an effective handoff graph.""" + + CASCADED = "cascaded" + """CASCADED.""" + REALTIME = "realtime" + """REALTIME.""" + + +class VoiceAgentResponseAudioFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """An audio format reported on a voice-agent response resource.""" + + PCM16 = "pcm16" + """PCM16.""" + PCM16_8000_HZ = "pcm16_8000hz" + """PCM16_8000_HZ.""" + PCM16_16000_HZ = "pcm16_16000hz" + """PCM16_16000_HZ.""" + PCM16_22050_HZ = "pcm16_22050hz" + """PCM16_22050_HZ.""" + PCM16_24000_HZ = "pcm16_24000hz" + """PCM16_24000_HZ.""" + PCM16_44100_HZ = "pcm16_44100hz" + """PCM16_44100_HZ.""" + PCM16_48000_HZ = "pcm16_48000hz" + """PCM16_48000_HZ.""" + G711_ULAW = "g711_ulaw" + """G711_ULAW.""" + G711_ALAW = "g711_alaw" + """G711_ALAW.""" + MP3 = "mp3" + """MP3.""" + MP3_24_KHZ48_KBPS = "mp3_24khz_48kbps" + """MP3_24_KHZ48_KBPS.""" + MP3_24_KHZ96_KBPS = "mp3_24khz_96kbps" + """MP3_24_KHZ96_KBPS.""" + MP3_24_KHZ160_KBPS = "mp3_24khz_160kbps" + """MP3_24_KHZ160_KBPS.""" + + +class VoiceAgentResponseStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The lifecycle status of a voice-agent response.""" + + IN_PROGRESS = "in_progress" + """IN_PROGRESS.""" + COMPLETED = "completed" + """COMPLETED.""" + CANCELLED = "cancelled" + """CANCELLED.""" + INCOMPLETE = "incomplete" + """INCOMPLETE.""" + FAILED = "failed" + """FAILED.""" + + +class VoiceAgentSessionIncludeOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Additional server-output fields that a voice-agent session may request.""" + + INPUT_AUDIO_TRANSCRIPTION_LOGPROBS = "item.input_audio_transcription.logprobs" + """INPUT_AUDIO_TRANSCRIPTION_LOGPROBS.""" + INPUT_AUDIO_TRANSCRIPTION_PHRASES = "item.input_audio_transcription.phrases" + """INPUT_AUDIO_TRANSCRIPTION_PHRASES.""" + FILE_SEARCH_CALL_RESULTS = "file_search_call.results" + """FILE_SEARCH_CALL_RESULTS.""" + + +class VoiceAgentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The persona/tone a guided-authoring request steers the generated voice agent toward.""" + + PERSONAL = "personal" + """A personal-assistant persona.""" + BUSINESS = "business" + """A business / professional persona.""" + + +class VoiceAgentUseCase(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The scenario-template catalog entry a guided-authoring request specializes the generated voice + agent for. Extensible: additional use cases may be added over time. + """ + + CUSTOMER_SUPPORT = "customer_support" + """CUSTOMER_SUPPORT.""" + RECEPTION = "reception" + """RECEPTION.""" + SALES = "sales" + """SALES.""" + TRAVEL_ASSISTANT = "travel_assistant" + """TRAVEL_ASSISTANT.""" + OUTREACH = "outreach" + """OUTREACH.""" + PERSONAL_ASSISTANT = "personal_assistant" + """PERSONAL_ASSISTANT.""" + LEARNING = "learning" + """LEARNING.""" + CALL_CENTER = "call_center" + """CALL_CENTER.""" + IN_CAR = "in_car" + """IN_CAR.""" + + +class VoiceAgentWebSearchCallStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of a web-search call.""" + + IN_PROGRESS = "in_progress" + """IN_PROGRESS.""" + SEARCHING = "searching" + """SEARCHING.""" + COMPLETED = "completed" + """COMPLETED.""" + FAILED = "failed" + """FAILED.""" + + +class VoiceAgentWebSocketSubprotocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The WebSocket subprotocol supported by a voice-agent connection.""" + + REALTIME = "realtime" + """REALTIME.""" + + +class VoiceAudioCodec(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """An audio codec. Additional values may be added over time.""" + + PCM16 = "pcm16" + """16-bit pulse-code modulation.""" + PCMU = "pcmu" + """G.711 mu-law.""" + PCMA = "pcma" + """G.711 A-law.""" + + +class VoiceAudioContainerFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """An audio container format. Additional values may be added over time.""" + + WAV = "wav" + """Waveform Audio File Format.""" + + +class VoiceAudioFormatType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The audio format type. Values follow the OpenAI Realtime wire schema and are exempt from the + snake_case enum-value rule. + """ + + PCM = "audio/pcm" + """16-bit PCM.""" + PCMU = "audio/pcmu" + """G.711 mu-law (telephony).""" + PCMA = "audio/pcma" + """G.711 A-law (telephony).""" + + +class VoiceAudioRole(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """A voice-audio participant role. Additional values may be added over time.""" + + USER = "user" + """Audio produced by the user.""" + AGENT = "agent" + """Audio produced by the agent.""" + + +class VoiceAudioTimestampType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """An output-audio timestamp kind supported by a voice agent.""" + + WORD = "word" + """Word-level timestamps.""" + + +class VoiceAvatarOutputProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The transport used to deliver the avatar video stream.""" + + WEBRTC = "webrtc" + """WEBRTC.""" + WEBSOCKET = "websocket" + """WEBSOCKET.""" + + +class VoiceAvatarType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The avatar type.""" + + VIDEO_AVATAR = "video_avatar" + """VIDEO_AVATAR.""" + PHOTO_AVATAR = "photo_avatar" + """PHOTO_AVATAR.""" + + +class VoiceConversationItemType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of a persisted voice conversation item.""" + + MESSAGE = "message" + """A message item.""" + FUNCTION_CALL = "function_call" + """A function-call request item.""" + FUNCTION_CALL_OUTPUT = "function_call_output" + """A function-call output item.""" + MCP_LIST_TOOLS = "mcp_list_tools" + """An MCP list-tools item.""" + MCP_CALL = "mcp_call" + """An MCP call item.""" + MCP_APPROVAL_REQUEST = "mcp_approval_request" + """An MCP approval request item.""" + MCP_APPROVAL_RESPONSE = "mcp_approval_response" + """An MCP approval response item.""" + + +class VoiceConversationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The lifecycle status of a persisted voice conversation.""" + + IN_PROGRESS = "in_progress" + """The conversation's live session is still in progress.""" + COMPLETED = "completed" + """The conversation's live session has ended.""" + + +class VoiceEndOfUtteranceDetectionModel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The semantic end-of-utterance detection model.""" + + SEMANTIC_DETECTION_V1 = "semantic_detection_v1" + """The default semantic detection model.""" + SEMANTIC_DETECTION_V1_EN = "semantic_detection_v1_en" + """The English-optimized semantic detection model.""" + SEMANTIC_DETECTION_V1_MULTILINGUAL = "semantic_detection_v1_multilingual" + """The multilingual semantic detection model.""" + + +class VoiceEndOfUtteranceThresholdLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The sensitivity threshold for semantic end-of-utterance detection.""" + + LOW = "low" + """The low sensitivity threshold.""" + MEDIUM = "medium" + """The medium sensitivity threshold.""" + HIGH = "high" + """The high sensitivity threshold.""" + DEFAULT = "default" + """The service-selected sensitivity threshold.""" + + +class VoiceGreetingToolChoice(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The tool-selection policy for an LLM-generated greeting.""" + + NONE = "none" + """Do not use tools for the opening response.""" + AUTO = "auto" + """Allow the model to select configured tools for the opening response.""" + REQUIRED = "required" + """Require the opening response to use a configured tool.""" + + +class VoiceIdsShared(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of VoiceIdsShared.""" + + ALLOY = "alloy" + """ALLOY.""" + ASH = "ash" + """ASH.""" + BALLAD = "ballad" + """BALLAD.""" + CORAL = "coral" + """CORAL.""" + ECHO = "echo" + """ECHO.""" + SAGE = "sage" + """SAGE.""" + SHIMMER = "shimmer" + """SHIMMER.""" + VERSE = "verse" + """VERSE.""" + MARIN = "marin" + """MARIN.""" + CEDAR = "cedar" + """CEDAR.""" + + +class VoiceInputTranscriptionModel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The input-audio transcription model. Mirrors the transcription models supported by the managed + voice backend, covering the OpenAI Realtime transcription models plus the Azure and MAI models. + Additional values may be added over time. + """ + + WHISPER1 = "whisper-1" + """OpenAI Whisper.""" + GPT_REALTIME_WHISPER = "gpt-realtime-whisper" + """OpenAI GPT Realtime Whisper.""" + GPT4_O_TRANSCRIBE = "gpt-4o-transcribe" + """OpenAI GPT-4o transcribe.""" + GPT4_O_MINI_TRANSCRIBE = "gpt-4o-mini-transcribe" + """OpenAI GPT-4o mini transcribe.""" + GPT4_O_TRANSCRIBE_DIARIZE = "gpt-4o-transcribe-diarize" + """OpenAI GPT-4o transcribe with speaker diarization.""" + GPT_TRANSCRIBE = "gpt-transcribe" + """OpenAI GPT Transcribe.""" + GPT_LIVE_TRANSCRIBE = "gpt-live-transcribe" + """OpenAI GPT Live Transcribe.""" + MAI_TRANSCRIBE = "mai-transcribe" + """MAI transcription.""" + AZURE_SPEECH = "azure-speech" + """Azure AI Speech to text.""" + + +class VoiceModelType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """How the model backing a voice agent is served. This is independent of the architecture + (realtime or cascaded), which the service derives from the selected model. + """ + + MANAGED = "managed" + """The service hosts and manages the named model, for example ``gpt-realtime``.""" + SELF_DEPLOYED = "self_deployed" + """The service uses the customer's own Foundry deployment named by ``model``.""" + + +class VoiceNoiseReductionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The input audio noise reduction mode.""" + + NEAR_FIELD = "near_field" + """NEAR_FIELD.""" + FAR_FIELD = "far_field" + """FAR_FIELD.""" + AZURE_DEEP_NOISE_SUPPRESSION = "azure_deep_noise_suppression" + """Azure deep noise suppression.""" + + +class VoiceOutputModality(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """An output modality the agent may produce. ``animation`` and ``avatar`` are used when an avatar + is configured. + """ + + TEXT = "text" + """TEXT.""" + AUDIO = "audio" + """AUDIO.""" + ANIMATION = "animation" + """ANIMATION.""" + AVATAR = "avatar" + """AVATAR.""" + + +class VoiceResponseStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of a voice response.""" + + IN_PROGRESS = "in_progress" + """IN_PROGRESS.""" + COMPLETED = "completed" + """COMPLETED.""" + CANCELLED = "cancelled" + """CANCELLED.""" + INCOMPLETE = "incomplete" + """INCOMPLETE.""" + FAILED = "failed" + """FAILED.""" + + +class VoiceSystemToolName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """A service-managed voice-session control action. Known values are stable; additional values may + be added over time. + """ + + END_CONVERSATION = "end_conversation" + """Ends the active conversation.""" + + +class VoiceTurnDetectionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The turn-detection strategy. Additional values may be added over time.""" + + SERVER_VAD = "server_vad" + """Server-side voice activity detection.""" + SEMANTIC_VAD = "semantic_vad" + """Semantic voice activity detection.""" + AZURE_SEMANTIC_VAD = "azure_semantic_vad" + """Azure semantic voice activity detection.""" + AZURE_SEMANTIC_VAD_EN = "azure_semantic_vad_en" + """English-optimized Azure semantic voice activity detection.""" + AZURE_SEMANTIC_VAD_MULTILINGUAL = "azure_semantic_vad_multilingual" + """Multilingual Azure semantic voice activity detection.""" diff --git a/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/models/_models.py b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/models/_models.py new file mode 100644 index 000000000000..5a8c269e3943 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/models/_models.py @@ -0,0 +1,13395 @@ +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=useless-super-delegation + +import datetime +from typing import Any, Literal, Mapping, Optional, TYPE_CHECKING, Union, overload + +from .._utils.model_base import Model as _Model, rest_discriminator, rest_field +from ._enums import ( + AgentBlueprintReferenceType, + AgentEndpointAuthorizationSchemeType, + AgentObjectType, + AzureVoiceType, + CreateTranscriptionResponseJsonUsageType, + RealtimeAudioFormatsType, + RealtimeClientEventType, + RealtimeConversationItemMessageType, + RealtimeConversationItemType, + RealtimeMcpErrorType, + RealtimeServerEventType, + ToolChoiceParamType, + ToolType, + VersionSelectorType, + VoiceConversationItemType, + VoiceEndOfUtteranceDetectionModel, + VoiceTurnDetectionType, +) + +if TYPE_CHECKING: + from .. import _unions, models as _models + + +class A2AProtocolConfiguration(_Model): + """Configuration specific to the A2A protocol.""" + + +class ActivityProtocolConfiguration(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Configuration specific to the activity protocol. + + :ivar enable_m365_public_endpoint: Whether to enable the M365 public endpoint for the activity + protocol. + :vartype enable_m365_public_endpoint: bool + """ + + enable_m365_public_endpoint: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Whether to enable the M365 public endpoint for the activity protocol.""" + + @overload + def __init__( + self, + *, + enable_m365_public_endpoint: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AgentBlueprintReference(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """AgentBlueprintReference. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ManagedAgentIdentityBlueprintReference + + :ivar type: Required. "ManagedAgentIdentityBlueprint" + :vartype type: str or ~azure.ai.voiceagents.models.AgentBlueprintReferenceType + """ + + __mapping__: dict[str, _Model] = {} + type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) + """Required. \"ManagedAgentIdentityBlueprint\"""" + + @overload + def __init__( + self, + *, + type: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AgentCard(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """AgentCard. + + :ivar version: The version of the agent card. Required. + :vartype version: str + :ivar description: The description of the agent card. + :vartype description: str + :ivar skills: The set of skills that an agent can perform. Required. + :vartype skills: list[~azure.ai.voiceagents.models.AgentCardSkill] + """ + + version: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The version of the agent card. Required.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The description of the agent card.""" + skills: list["_models.AgentCardSkill"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The set of skills that an agent can perform. Required.""" + + @overload + def __init__( + self, + *, + version: str, + skills: list["_models.AgentCardSkill"], + description: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AgentCardSkill(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """AgentCardSkill. + + :ivar id: a unique identifier for the skill. Required. + :vartype id: str + :ivar name: The name of the skill. Required. + :vartype name: str + :ivar description: A description of the skill. + :vartype description: str + :ivar tags: set of tagwords describing classes of capabilities for the skill. + :vartype tags: list[str] + :ivar examples: A list of example scenarios that the skill can perform. + :vartype examples: list[str] + """ + + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """a unique identifier for the skill. Required.""" + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of the skill. Required.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """A description of the skill.""" + tags: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """set of tagwords describing classes of capabilities for the skill.""" + examples: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """A list of example scenarios that the skill can perform.""" + + @overload + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + name: str, + description: Optional[str] = None, + tags: Optional[list[str]] = None, + examples: Optional[list[str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AgentEndpointAuthorizationScheme(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """AgentEndpointAuthorizationScheme. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + BotServiceAuthorizationScheme, BotServiceRbacAuthorizationScheme, + BotServiceTenantAuthorizationScheme, EntraAuthorizationScheme + + :ivar type: Required. Known values are: "Entra", "BotService", "BotServiceRbac", and + "BotServiceTenant". + :vartype type: str or ~azure.ai.voiceagents.models.AgentEndpointAuthorizationSchemeType + """ + + __mapping__: dict[str, _Model] = {} + type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) + """Required. Known values are: \"Entra\", \"BotService\", \"BotServiceRbac\", and + \"BotServiceTenant\".""" + + @overload + def __init__( + self, + *, + type: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AgentEndpointConfig(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """AgentEndpointConfig. + + :ivar version_selector: The version selector of the agent endpoint determines how traffic is + routed to different versions of the agent. + :vartype version_selector: ~azure.ai.voiceagents.models.VersionSelector + :ivar protocol_configuration: Per-protocol configuration for the agent endpoint. + :vartype protocol_configuration: ~azure.ai.voiceagents.models.ProtocolConfiguration + :ivar authorization_schemes: The authorization schemes supported by the agent endpoint. + :vartype authorization_schemes: + list[~azure.ai.voiceagents.models.AgentEndpointAuthorizationScheme] + """ + + version_selector: Optional["_models.VersionSelector"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The version selector of the agent endpoint determines how traffic is routed to different + versions of the agent.""" + protocol_configuration: Optional["_models.ProtocolConfiguration"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Per-protocol configuration for the agent endpoint.""" + authorization_schemes: Optional[list["_models.AgentEndpointAuthorizationScheme"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The authorization schemes supported by the agent endpoint.""" + + @overload + def __init__( + self, + *, + version_selector: Optional["_models.VersionSelector"] = None, + protocol_configuration: Optional["_models.ProtocolConfiguration"] = None, + authorization_schemes: Optional[list["_models.AgentEndpointAuthorizationScheme"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AgentIdentity(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """AgentIdentity. + + :ivar principal_id: The principal ID of the agent instance. Required. + :vartype principal_id: str + :ivar client_id: The client ID of the agent instance. Also referred to as the instance ID. + Required. + :vartype client_id: str + :ivar status: The status of the agent identity. Present for both the agent instance identity + and the agent blueprint. Known values are: "active" and "disabled". + :vartype status: str or ~azure.ai.voiceagents.models.AgentIdentityStatus + """ + + principal_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The principal ID of the agent instance. Required.""" + client_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The client ID of the agent instance. Also referred to as the instance ID. Required.""" + status: Optional[Union[str, "_models.AgentIdentityStatus"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The status of the agent identity. Present for both the agent instance identity and the agent + blueprint. Known values are: \"active\" and \"disabled\".""" + + @overload + def __init__( + self, + *, + principal_id: str, + client_id: str, + status: Optional[Union[str, "_models.AgentIdentityStatus"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApiErrorResponse(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Error response for API failures. + + :ivar error: Required. + :vartype error: ~azure.ai.voiceagents.models.Error + """ + + error: "_models.Error" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + + @overload + def __init__( + self, + *, + error: "_models.Error", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AzureVoice(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Base configuration shared by Azure synthesized voices. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AzureAvatarVoiceSyncVoice, AzureCustomVoice, AzurePersonalVoice, AzureStandardVoice + + :ivar type: The Azure voice kind. Required. Known values are: "azure-standard", "azure-custom", + "azure-personal", and "avatar-voice-sync". + :vartype type: str or ~azure.ai.voiceagents.models.AzureVoiceType + :ivar temperature: The synthesis temperature, from 0 to 1. + :vartype temperature: float + :ivar custom_lexicon_url: The URL of a custom pronunciation lexicon. + :vartype custom_lexicon_url: str + :ivar custom_text_normalization_url: The URL of a custom text-normalization service. + :vartype custom_text_normalization_url: str + :ivar prefer_locales: Preferred BCP-47 locales that influence language accents. + :vartype prefer_locales: list[str] + :ivar locale: The enforced BCP-47 locale. When omitted, the language is detected from the text. + :vartype locale: str + :ivar style: The speaking style, such as ``cheerful`` or ``sad``. + :vartype style: str + :ivar pitch: The SSML-compatible pitch adjustment, such as ``+5%``. + :vartype pitch: str + :ivar rate: The SSML-compatible speaking-rate adjustment, such as ``+10%``. + :vartype rate: str + :ivar volume: The SSML-compatible volume adjustment, such as ``+10`` or ``-6dB``. + :vartype volume: str + """ + + __mapping__: dict[str, _Model] = {} + type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) + """The Azure voice kind. Required. Known values are: \"azure-standard\", \"azure-custom\", + \"azure-personal\", and \"avatar-voice-sync\".""" + temperature: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The synthesis temperature, from 0 to 1.""" + custom_lexicon_url: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The URL of a custom pronunciation lexicon.""" + custom_text_normalization_url: Optional[str] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The URL of a custom text-normalization service.""" + prefer_locales: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Preferred BCP-47 locales that influence language accents.""" + locale: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The enforced BCP-47 locale. When omitted, the language is detected from the text.""" + style: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The speaking style, such as ``cheerful`` or ``sad``.""" + pitch: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The SSML-compatible pitch adjustment, such as ``+5%``.""" + rate: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The SSML-compatible speaking-rate adjustment, such as ``+10%``.""" + volume: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The SSML-compatible volume adjustment, such as ``+10`` or ``-6dB``.""" + + @overload + def __init__( + self, + *, + type: str, + temperature: Optional[float] = None, + custom_lexicon_url: Optional[str] = None, + custom_text_normalization_url: Optional[str] = None, + prefer_locales: Optional[list[str]] = None, + locale: Optional[str] = None, + style: Optional[str] = None, + pitch: Optional[str] = None, + rate: Optional[str] = None, + volume: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AzureAvatarVoiceSyncVoice( + AzureVoice, discriminator="avatar-voice-sync" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """An Azure avatar voice-synchronization configuration. The runtime derives its voice name from + the avatar character and style. + + :ivar temperature: The synthesis temperature, from 0 to 1. + :vartype temperature: float + :ivar custom_lexicon_url: The URL of a custom pronunciation lexicon. + :vartype custom_lexicon_url: str + :ivar custom_text_normalization_url: The URL of a custom text-normalization service. + :vartype custom_text_normalization_url: str + :ivar prefer_locales: Preferred BCP-47 locales that influence language accents. + :vartype prefer_locales: list[str] + :ivar locale: The enforced BCP-47 locale. When omitted, the language is detected from the text. + :vartype locale: str + :ivar style: The speaking style, such as ``cheerful`` or ``sad``. + :vartype style: str + :ivar pitch: The SSML-compatible pitch adjustment, such as ``+5%``. + :vartype pitch: str + :ivar rate: The SSML-compatible speaking-rate adjustment, such as ``+10%``. + :vartype rate: str + :ivar volume: The SSML-compatible volume adjustment, such as ``+10`` or ``-6dB``. + :vartype volume: str + :ivar type: Required. An Azure avatar voice-synchronization voice. + :vartype type: str or ~azure.ai.voiceagents.models.AVATAR_VOICE_SYNC + :ivar model: The neural model used to synthesize the avatar voice. Required. Known values are: + "DragonLatestNeural", "DragonHDOmniLatestNeural", and "MAI-Voice". + :vartype model: str or ~azure.ai.voiceagents.models.PersonalVoiceModel + """ + + type: Literal[AzureVoiceType.AVATAR_VOICE_SYNC] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. An Azure avatar voice-synchronization voice.""" + model: Union[str, "_models.PersonalVoiceModel"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The neural model used to synthesize the avatar voice. Required. Known values are: + \"DragonLatestNeural\", \"DragonHDOmniLatestNeural\", and \"MAI-Voice\".""" + + @overload + def __init__( + self, + *, + model: Union[str, "_models.PersonalVoiceModel"], + temperature: Optional[float] = None, + custom_lexicon_url: Optional[str] = None, + custom_text_normalization_url: Optional[str] = None, + prefer_locales: Optional[list[str]] = None, + locale: Optional[str] = None, + style: Optional[str] = None, + pitch: Optional[str] = None, + rate: Optional[str] = None, + volume: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = AzureVoiceType.AVATAR_VOICE_SYNC # type: ignore + + +class AzureCustomVoice( + AzureVoice, discriminator="azure-custom" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """An Azure custom neural voice configuration. + + :ivar temperature: The synthesis temperature, from 0 to 1. + :vartype temperature: float + :ivar custom_lexicon_url: The URL of a custom pronunciation lexicon. + :vartype custom_lexicon_url: str + :ivar custom_text_normalization_url: The URL of a custom text-normalization service. + :vartype custom_text_normalization_url: str + :ivar prefer_locales: Preferred BCP-47 locales that influence language accents. + :vartype prefer_locales: list[str] + :ivar locale: The enforced BCP-47 locale. When omitted, the language is detected from the text. + :vartype locale: str + :ivar style: The speaking style, such as ``cheerful`` or ``sad``. + :vartype style: str + :ivar pitch: The SSML-compatible pitch adjustment, such as ``+5%``. + :vartype pitch: str + :ivar rate: The SSML-compatible speaking-rate adjustment, such as ``+10%``. + :vartype rate: str + :ivar volume: The SSML-compatible volume adjustment, such as ``+10`` or ``-6dB``. + :vartype volume: str + :ivar type: Required. An Azure custom neural voice. + :vartype type: str or ~azure.ai.voiceagents.models.AZURE_CUSTOM + :ivar name: The custom voice name. Required. + :vartype name: str + :ivar endpoint_id: The Azure Speech custom voice deployment endpoint ID. Required. + :vartype endpoint_id: str + """ + + type: Literal[AzureVoiceType.AZURE_CUSTOM] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. An Azure custom neural voice.""" + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The custom voice name. Required.""" + endpoint_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The Azure Speech custom voice deployment endpoint ID. Required.""" + + @overload + def __init__( + self, + *, + name: str, + endpoint_id: str, + temperature: Optional[float] = None, + custom_lexicon_url: Optional[str] = None, + custom_text_normalization_url: Optional[str] = None, + prefer_locales: Optional[list[str]] = None, + locale: Optional[str] = None, + style: Optional[str] = None, + pitch: Optional[str] = None, + rate: Optional[str] = None, + volume: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = AzureVoiceType.AZURE_CUSTOM # type: ignore + + +class AzurePersonalVoice( + AzureVoice, discriminator="azure-personal" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """An Azure personal voice configuration. + + :ivar temperature: The synthesis temperature, from 0 to 1. + :vartype temperature: float + :ivar custom_lexicon_url: The URL of a custom pronunciation lexicon. + :vartype custom_lexicon_url: str + :ivar custom_text_normalization_url: The URL of a custom text-normalization service. + :vartype custom_text_normalization_url: str + :ivar prefer_locales: Preferred BCP-47 locales that influence language accents. + :vartype prefer_locales: list[str] + :ivar locale: The enforced BCP-47 locale. When omitted, the language is detected from the text. + :vartype locale: str + :ivar style: The speaking style, such as ``cheerful`` or ``sad``. + :vartype style: str + :ivar pitch: The SSML-compatible pitch adjustment, such as ``+5%``. + :vartype pitch: str + :ivar rate: The SSML-compatible speaking-rate adjustment, such as ``+10%``. + :vartype rate: str + :ivar volume: The SSML-compatible volume adjustment, such as ``+10`` or ``-6dB``. + :vartype volume: str + :ivar type: Required. An Azure personal voice. + :vartype type: str or ~azure.ai.voiceagents.models.AZURE_PERSONAL + :ivar name: The personal voice name. Required. + :vartype name: str + :ivar model: The neural model used by the personal voice. Required. Known values are: + "DragonLatestNeural", "DragonHDOmniLatestNeural", and "MAI-Voice". + :vartype model: str or ~azure.ai.voiceagents.models.PersonalVoiceModel + """ + + type: Literal[AzureVoiceType.AZURE_PERSONAL] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. An Azure personal voice.""" + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The personal voice name. Required.""" + model: Union[str, "_models.PersonalVoiceModel"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The neural model used by the personal voice. Required. Known values are: + \"DragonLatestNeural\", \"DragonHDOmniLatestNeural\", and \"MAI-Voice\".""" + + @overload + def __init__( + self, + *, + name: str, + model: Union[str, "_models.PersonalVoiceModel"], + temperature: Optional[float] = None, + custom_lexicon_url: Optional[str] = None, + custom_text_normalization_url: Optional[str] = None, + prefer_locales: Optional[list[str]] = None, + locale: Optional[str] = None, + style: Optional[str] = None, + pitch: Optional[str] = None, + rate: Optional[str] = None, + volume: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = AzureVoiceType.AZURE_PERSONAL # type: ignore + + +class AzureRealtimeNativeVoice(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """An Azure realtime-native voice configuration. + + :ivar type: The voice kind. Always ``azure-realtime-native``. Required. Default value is + "azure-realtime-native". + :vartype type: str + :ivar name: The Azure realtime-native voice name. Required. Known values are: "aarti", + "alvaro", "andrew", "antonio", "ava", "clara", "dalia", "denise", "diego", "diya", "elsa", + "emma", "florian", "francisca", "hyunsu", "jorge", "keita", "liam", "meera", "nanami", + "natasha", "niwat", "premwadee", "remy", "ryan", "seraphina", "sonia", "sunhi", "sylvie", + "thierry", "william", "xiaoxiao", "ximena", and "yunxi". + :vartype name: str or ~azure.ai.voiceagents.models.AzureRealtimeNativeVoiceName + """ + + type: Literal["azure-realtime-native"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The voice kind. Always ``azure-realtime-native``. Required. Default value is + \"azure-realtime-native\".""" + name: Union[str, "_models.AzureRealtimeNativeVoiceName"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The Azure realtime-native voice name. Required. Known values are: \"aarti\", \"alvaro\", + \"andrew\", \"antonio\", \"ava\", \"clara\", \"dalia\", \"denise\", \"diego\", \"diya\", + \"elsa\", \"emma\", \"florian\", \"francisca\", \"hyunsu\", \"jorge\", \"keita\", \"liam\", + \"meera\", \"nanami\", \"natasha\", \"niwat\", \"premwadee\", \"remy\", \"ryan\", + \"seraphina\", \"sonia\", \"sunhi\", \"sylvie\", \"thierry\", \"william\", \"xiaoxiao\", + \"ximena\", and \"yunxi\".""" + + @overload + def __init__( + self, + *, + name: Union[str, "_models.AzureRealtimeNativeVoiceName"], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["azure-realtime-native"] = "azure-realtime-native" + + +class AzureStandardVoice( + AzureVoice, discriminator="azure-standard" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """An Azure standard neural voice configuration. + + :ivar temperature: The synthesis temperature, from 0 to 1. + :vartype temperature: float + :ivar custom_lexicon_url: The URL of a custom pronunciation lexicon. + :vartype custom_lexicon_url: str + :ivar custom_text_normalization_url: The URL of a custom text-normalization service. + :vartype custom_text_normalization_url: str + :ivar prefer_locales: Preferred BCP-47 locales that influence language accents. + :vartype prefer_locales: list[str] + :ivar locale: The enforced BCP-47 locale. When omitted, the language is detected from the text. + :vartype locale: str + :ivar style: The speaking style, such as ``cheerful`` or ``sad``. + :vartype style: str + :ivar pitch: The SSML-compatible pitch adjustment, such as ``+5%``. + :vartype pitch: str + :ivar rate: The SSML-compatible speaking-rate adjustment, such as ``+10%``. + :vartype rate: str + :ivar volume: The SSML-compatible volume adjustment, such as ``+10`` or ``-6dB``. + :vartype volume: str + :ivar type: Required. An Azure standard neural voice. + :vartype type: str or ~azure.ai.voiceagents.models.AZURE_STANDARD + :ivar name: The Azure neural voice name. Required. + :vartype name: str + :ivar multi_talker_speaker_name: The speaker name used by a multi-talker voice. + :vartype multi_talker_speaker_name: str + """ + + type: Literal[AzureVoiceType.AZURE_STANDARD] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. An Azure standard neural voice.""" + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The Azure neural voice name. Required.""" + multi_talker_speaker_name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The speaker name used by a multi-talker voice.""" + + @overload + def __init__( + self, + *, + name: str, + temperature: Optional[float] = None, + custom_lexicon_url: Optional[str] = None, + custom_text_normalization_url: Optional[str] = None, + prefer_locales: Optional[list[str]] = None, + locale: Optional[str] = None, + style: Optional[str] = None, + pitch: Optional[str] = None, + rate: Optional[str] = None, + volume: Optional[str] = None, + multi_talker_speaker_name: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = AzureVoiceType.AZURE_STANDARD # type: ignore + + +class BotServiceAuthorizationScheme(AgentEndpointAuthorizationScheme, discriminator="BotService"): + """BotServiceAuthorizationScheme. + + :ivar type: Required. BOT_SERVICE. + :vartype type: str or ~azure.ai.voiceagents.models.BOT_SERVICE + """ + + type: Literal[AgentEndpointAuthorizationSchemeType.BOT_SERVICE] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. BOT_SERVICE.""" + + @overload + def __init__( + self, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = AgentEndpointAuthorizationSchemeType.BOT_SERVICE # type: ignore + + +class BotServiceRbacAuthorizationScheme(AgentEndpointAuthorizationScheme, discriminator="BotServiceRbac"): + """BotServiceRbacAuthorizationScheme. + + :ivar type: Required. BOT_SERVICE_RBAC. + :vartype type: str or ~azure.ai.voiceagents.models.BOT_SERVICE_RBAC + """ + + type: Literal[AgentEndpointAuthorizationSchemeType.BOT_SERVICE_RBAC] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. BOT_SERVICE_RBAC.""" + + @overload + def __init__( + self, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = AgentEndpointAuthorizationSchemeType.BOT_SERVICE_RBAC # type: ignore + + +class BotServiceTenantAuthorizationScheme(AgentEndpointAuthorizationScheme, discriminator="BotServiceTenant"): + """BotServiceTenantAuthorizationScheme. + + :ivar type: Required. BOT_SERVICE_TENANT. + :vartype type: str or ~azure.ai.voiceagents.models.BOT_SERVICE_TENANT + """ + + type: Literal[AgentEndpointAuthorizationSchemeType.BOT_SERVICE_TENANT] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. BOT_SERVICE_TENANT.""" + + @overload + def __init__( + self, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = AgentEndpointAuthorizationSchemeType.BOT_SERVICE_TENANT # type: ignore + + +class CreateTranscriptionResponseJsonUsage(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Token usage statistics for the request. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + TranscriptTextUsageDuration, TranscriptTextUsageTokens + + :ivar type: Required. Known values are: "tokens" and "duration". + :vartype type: str or ~azure.ai.voiceagents.models.CreateTranscriptionResponseJsonUsageType + """ + + __mapping__: dict[str, _Model] = {} + type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) + """Required. Known values are: \"tokens\" and \"duration\".""" + + @overload + def __init__( + self, + *, + type: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class EntraAuthorizationScheme(AgentEndpointAuthorizationScheme, discriminator="Entra"): + """EntraAuthorizationScheme. + + :ivar type: Required. ENTRA. + :vartype type: str or ~azure.ai.voiceagents.models.ENTRA + """ + + type: Literal[AgentEndpointAuthorizationSchemeType.ENTRA] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. ENTRA.""" + + @overload + def __init__( + self, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = AgentEndpointAuthorizationSchemeType.ENTRA # type: ignore + + +class Error(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """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.voiceagents.models.Error] + :ivar additional_info: + :vartype additional_info: dict[str, any] + :ivar debug_info: + :vartype debug_info: dict[str, any] + """ + + code: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + message: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + param: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + type: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + details: Optional[list["_models.Error"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + additional_info: Optional[dict[str, Any]] = rest_field( + name="additionalInfo", visibility=["read", "create", "update", "delete", "query"] + ) + debug_info: Optional[dict[str, Any]] = rest_field( + name="debugInfo", visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + code: str, + message: str, + param: Optional[str] = None, + type: Optional[str] = None, + details: Optional[list["_models.Error"]] = None, + additional_info: Optional[dict[str, Any]] = None, + debug_info: Optional[dict[str, Any]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VersionSelectionRule(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """VersionSelectionRule. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + FixedRatioVersionSelectionRule + + :ivar type: Required. "FixedRatio" + :vartype type: str or ~azure.ai.voiceagents.models.VersionSelectorType + :ivar agent_version: The agent version to route traffic to. Required. + :vartype agent_version: str + """ + + __mapping__: dict[str, _Model] = {} + type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) + """Required. \"FixedRatio\"""" + agent_version: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The agent version to route traffic to. Required.""" + + @overload + def __init__( + self, + *, + type: str, + agent_version: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class FixedRatioVersionSelectionRule( + VersionSelectionRule, discriminator="FixedRatio" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """FixedRatioVersionSelectionRule. + + :ivar agent_version: The agent version to route traffic to. Required. + :vartype agent_version: str + :ivar type: Required. FIXED_RATIO. + :vartype type: str or ~azure.ai.voiceagents.models.FIXED_RATIO + :ivar traffic_percentage: The percentage of traffic to route to the version. Must be between 0 + and 100. Required. + :vartype traffic_percentage: int + """ + + type: Literal[VersionSelectorType.FIXED_RATIO] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. FIXED_RATIO.""" + traffic_percentage: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The percentage of traffic to route to the version. Must be between 0 and 100. Required.""" + + @overload + def __init__( + self, + *, + agent_version: str, + traffic_percentage: int, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = VersionSelectorType.FIXED_RATIO # type: ignore + + +class InvocationsProtocolConfiguration(_Model): + """Configuration specific to the invocations protocol.""" + + +class InvocationsWsProtocolConfiguration(_Model): + """Configuration specific to the WebSocket-based invocations protocol.""" + + +class VoiceGreetingConfig(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Session-start greeting configuration for a voice agent. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + LlmGeneratedVoiceGreetingConfig, TemplateVoiceGreetingConfig + + :ivar type: The greeting mode. Required. Default value is None. + :vartype type: str + """ + + __mapping__: dict[str, _Model] = {} + type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) + """The greeting mode. Required. Default value is None.""" + + @overload + def __init__( + self, + *, + type: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class LlmGeneratedVoiceGreetingConfig( + VoiceGreetingConfig, discriminator="llm_generated" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """A greeting authored by the session model from a scoped opening-turn prompt. + + :ivar type: Required. Default value is "llm_generated". + :vartype type: str + :ivar prompt: The Handlebars prompt that guides the opening turn. Required. + :vartype prompt: str + :ivar fallback_text: The optional Handlebars text template synthesized when generation fails + before any greeting output. + :vartype fallback_text: str + :ivar tool_choice: The tool-selection policy for the opening response. Defaults to ``none``. + Known values are: "none", "auto", and "required". + :vartype tool_choice: str or ~azure.ai.voiceagents.models.VoiceGreetingToolChoice + """ + + type: Literal["llm_generated"] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. Default value is \"llm_generated\".""" + prompt: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The Handlebars prompt that guides the opening turn. Required.""" + fallback_text: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The optional Handlebars text template synthesized when generation fails before any greeting + output.""" + tool_choice: Optional[Union[str, "_models.VoiceGreetingToolChoice"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The tool-selection policy for the opening response. Defaults to ``none``. Known values are: + \"none\", \"auto\", and \"required\".""" + + @overload + def __init__( + self, + *, + prompt: str, + fallback_text: Optional[str] = None, + tool_choice: Optional[Union[str, "_models.VoiceGreetingToolChoice"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = "llm_generated" # type: ignore + + +class LogProbProperties(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """A log probability object. + + :ivar token: The token that was used to generate the log probability. Required. + :vartype token: str + :ivar logprob: The log probability of the token. Required. + :vartype logprob: float + :ivar bytes: The bytes that were used to generate the log probability. Required. + :vartype bytes: list[int] + """ + + token: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The token that was used to generate the log probability. Required.""" + logprob: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The log probability of the token. Required.""" + bytes: list[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The bytes that were used to generate the log probability. Required.""" + + @overload + def __init__( + self, + *, + token: str, + logprob: float, + bytes: list[int], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedAgentIdentityBlueprintReference( + AgentBlueprintReference, discriminator="ManagedAgentIdentityBlueprint" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """ManagedAgentIdentityBlueprintReference. + + :ivar type: Required. MANAGED_AGENT_IDENTITY_BLUEPRINT. + :vartype type: str or ~azure.ai.voiceagents.models.MANAGED_AGENT_IDENTITY_BLUEPRINT + :ivar blueprint_id: The ID of the managed blueprint. Required. + :vartype blueprint_id: str + """ + + type: Literal[AgentBlueprintReferenceType.MANAGED_AGENT_IDENTITY_BLUEPRINT] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. MANAGED_AGENT_IDENTITY_BLUEPRINT.""" + blueprint_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the managed blueprint. Required.""" + + @overload + def __init__( + self, + *, + blueprint_id: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = AgentBlueprintReferenceType.MANAGED_AGENT_IDENTITY_BLUEPRINT # type: ignore + + +class MCPListToolsTool(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """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.voiceagents.models.MCPListToolsToolInputSchema + :ivar annotations: + :vartype annotations: ~azure.ai.voiceagents.models.MCPListToolsToolAnnotations + """ + + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of the tool. Required.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + input_schema: "_models.MCPListToolsToolInputSchema" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The JSON schema describing the tool's input. Required.""" + annotations: Optional["_models.MCPListToolsToolAnnotations"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + name: str, + input_schema: "_models.MCPListToolsToolInputSchema", + description: Optional[str] = None, + annotations: Optional["_models.MCPListToolsToolAnnotations"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MCPListToolsToolAnnotations(_Model): + """MCPListToolsToolAnnotations.""" + + +class MCPListToolsToolInputSchema(_Model): + """MCPListToolsToolInputSchema.""" + + +class McpProtocolConfiguration(_Model): + """Configuration specific to the MCP protocol.""" + + +class Tool(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """A tool that can be used to generate a response. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + MCPTool + + :ivar type: Required. Known values are: "function", "file_search", "computer", + "computer_use_preview", "web_search", "mcp", "code_interpreter", "programmatic_tool_calling", + "image_generation", "local_shell", "shell", "custom", "namespace", "tool_search", + "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", "fabric_iq_preview", "toolbox_search_preview", + "azure_ai_search", "azure_function", "bing_grounding", "capture_structured_outputs", and + "openapi". + :vartype type: str or ~azure.ai.voiceagents.models.ToolType + """ + + __mapping__: dict[str, _Model] = {} + type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) + """Required. Known values are: \"function\", \"file_search\", \"computer\", + \"computer_use_preview\", \"web_search\", \"mcp\", \"code_interpreter\", + \"programmatic_tool_calling\", \"image_generation\", \"local_shell\", \"shell\", \"custom\", + \"namespace\", \"tool_search\", \"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\", + \"fabric_iq_preview\", \"toolbox_search_preview\", \"azure_ai_search\", \"azure_function\", + \"bing_grounding\", \"capture_structured_outputs\", and \"openapi\".""" + + @overload + def __init__( + self, + *, + type: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MCPTool(Tool, discriminator="mcp"): # pylint: disable=docstring-keyword-should-match-keyword-only + """MCP tool. + + :ivar type: The type of the MCP tool. Always ``mcp``. Required. MCP. + :vartype type: str or ~azure.ai.voiceagents.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``, ``connector_id``, or + ``tunnel_id`` must be provided. + :vartype server_url: str + :ivar connector_id: Identifier for service connectors, like those available in ChatGPT. One of + ``server_url``, ``connector_id``, or ``tunnel_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 tunnel_id: The Secure MCP Tunnel ID to use instead of a direct server URL. One of + ``server_url``, ``connector_id``, or ``tunnel_id`` must be provided. + :vartype tunnel_id: 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.voiceagents.models.MCPToolFilter + :ivar allowed_callers: + :vartype allowed_callers: list[str or ~azure.ai.voiceagents.models.CallableToolAllowedCaller] + :ivar require_approval: Is one of the following types: MCPToolRequireApproval, + Literal["always"], Literal["never"] + :vartype require_approval: ~azure.ai.voiceagents.models.MCPToolRequireApproval or str or str + :ivar defer_loading: Whether this MCP tool is deferred and discovered via tool search. + :vartype defer_loading: bool + :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 + :ivar tool_configs: Deprecated. This property is deprecated and will be removed in a future + version. + :vartype tool_configs: dict[str, ~azure.ai.voiceagents.models.ToolConfig] + """ + + type: Literal[ToolType.MCP] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The type of the MCP tool. Always ``mcp``. Required. MCP.""" + server_label: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """A label for this MCP server, used to identify it in tool calls. Required.""" + server_url: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The URL for the MCP server. One of ``server_url``, ``connector_id``, or ``tunnel_id`` must be + provided.""" + connector_id: Optional[ + Literal[ + "connector_dropbox", + "connector_gmail", + "connector_googlecalendar", + "connector_googledrive", + "connector_microsoftteams", + "connector_outlookcalendar", + "connector_outlookemail", + "connector_sharepoint", + ] + ] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Identifier for service connectors, like those available in ChatGPT. One of ``server_url``, + ``connector_id``, or ``tunnel_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\"]""" + tunnel_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The Secure MCP Tunnel ID to use instead of a direct server URL. One of ``server_url``, + ``connector_id``, or ``tunnel_id`` must be provided.""" + authorization: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """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: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Optional description of the MCP server, used to provide more context.""" + headers: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + allowed_tools: Optional[Union[list[str], "_models.MCPToolFilter"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Is either a [str] type or a MCPToolFilter type.""" + allowed_callers: Optional[list[Union[str, "_models.CallableToolAllowedCaller"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + require_approval: Optional[Union["_models.MCPToolRequireApproval", Literal["always"], Literal["never"]]] = ( + rest_field(visibility=["read", "create", "update", "delete", "query"]) + ) + """Is one of the following types: MCPToolRequireApproval, Literal[\"always\"], Literal[\"never\"]""" + defer_loading: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Whether this MCP tool is deferred and discovered via tool search.""" + project_connection_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """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.""" + tool_configs: Optional[dict[str, "_models.ToolConfig"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Deprecated. This property is deprecated and will be removed in a future version.""" + + @overload + def __init__( + self, + *, + server_label: str, + server_url: Optional[str] = None, + connector_id: Optional[ + Literal[ + "connector_dropbox", + "connector_gmail", + "connector_googlecalendar", + "connector_googledrive", + "connector_microsoftteams", + "connector_outlookcalendar", + "connector_outlookemail", + "connector_sharepoint", + ] + ] = None, + tunnel_id: Optional[str] = None, + authorization: Optional[str] = None, + server_description: Optional[str] = None, + headers: Optional[dict[str, str]] = None, + allowed_tools: Optional[Union[list[str], "_models.MCPToolFilter"]] = None, + allowed_callers: Optional[list[Union[str, "_models.CallableToolAllowedCaller"]]] = None, + require_approval: Optional[Union["_models.MCPToolRequireApproval", Literal["always"], Literal["never"]]] = None, + defer_loading: Optional[bool] = None, + project_connection_id: Optional[str] = None, + tool_configs: Optional[dict[str, "_models.ToolConfig"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = ToolType.MCP # type: ignore + + +class MCPToolFilter(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """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: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """MCP allowed tools.""" + read_only: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """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.""" + + @overload + def __init__( + self, + *, + tool_names: Optional[list[str]] = None, + read_only: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MCPToolRequireApproval(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """MCPToolRequireApproval. + + :ivar always: + :vartype always: ~azure.ai.voiceagents.models.MCPToolFilter + :ivar never: + :vartype never: ~azure.ai.voiceagents.models.MCPToolFilter + """ + + always: Optional["_models.MCPToolFilter"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + never: Optional["_models.MCPToolFilter"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + always: Optional["_models.MCPToolFilter"] = None, + never: Optional["_models.MCPToolFilter"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Metadata(_Model): + """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 OpenAIVoice(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """An OpenAI built-in voice configuration with an explicit type discriminator. + + :ivar type: The voice kind. Always ``openai``. Required. Default value is "openai". + :vartype type: str + :ivar name: The OpenAI built-in voice name. Required. Known values are: "alloy", "ash", + "ballad", "coral", "echo", "sage", "shimmer", "verse", "marin", and "cedar". + :vartype name: str or ~azure.ai.voiceagents.models.VoiceIdsShared + """ + + type: Literal["openai"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The voice kind. Always ``openai``. Required. Default value is \"openai\".""" + name: Union[str, "_models.VoiceIdsShared"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The OpenAI built-in voice name. Required. Known values are: \"alloy\", \"ash\", \"ballad\", + \"coral\", \"echo\", \"sage\", \"shimmer\", \"verse\", \"marin\", and \"cedar\".""" + + @overload + def __init__( + self, + *, + name: Union[str, "_models.VoiceIdsShared"], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["openai"] = "openai" + + +class ProtocolConfiguration(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Per-protocol configuration for the agent endpoint. + + :ivar activity: Configuration for the activity protocol. + :vartype activity: ~azure.ai.voiceagents.models.ActivityProtocolConfiguration + :ivar responses: Configuration for the responses protocol. + :vartype responses: ~azure.ai.voiceagents.models.ResponsesProtocolConfiguration + :ivar a2_a: Configuration for the A2A protocol. + :vartype a2_a: ~azure.ai.voiceagents.models.A2AProtocolConfiguration + :ivar mcp: Configuration for the MCP protocol. + :vartype mcp: ~azure.ai.voiceagents.models.McpProtocolConfiguration + :ivar invocations: Configuration for the invocations protocol. + :vartype invocations: ~azure.ai.voiceagents.models.InvocationsProtocolConfiguration + :ivar invocations_ws: Configuration for the WebSocket-based invocations protocol. + :vartype invocations_ws: ~azure.ai.voiceagents.models.InvocationsWsProtocolConfiguration + """ + + activity: Optional["_models.ActivityProtocolConfiguration"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Configuration for the activity protocol.""" + responses: Optional["_models.ResponsesProtocolConfiguration"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Configuration for the responses protocol.""" + a2_a: Optional["_models.A2AProtocolConfiguration"] = rest_field( + name="a2a", visibility=["read", "create", "update", "delete", "query"] + ) + """Configuration for the A2A protocol.""" + mcp: Optional["_models.McpProtocolConfiguration"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Configuration for the MCP protocol.""" + invocations: Optional["_models.InvocationsProtocolConfiguration"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Configuration for the invocations protocol.""" + invocations_ws: Optional["_models.InvocationsWsProtocolConfiguration"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Configuration for the WebSocket-based invocations protocol.""" + + @overload + def __init__( + self, + *, + activity: Optional["_models.ActivityProtocolConfiguration"] = None, + responses: Optional["_models.ResponsesProtocolConfiguration"] = None, + a2_a: Optional["_models.A2AProtocolConfiguration"] = None, + mcp: Optional["_models.McpProtocolConfiguration"] = None, + invocations: Optional["_models.InvocationsProtocolConfiguration"] = None, + invocations_ws: Optional["_models.InvocationsWsProtocolConfiguration"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RaiConfig(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """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: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of the RAI policy to apply. Required.""" + + @overload + def __init__( + self, + *, + rai_policy_name: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RealtimeAudioFormats(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """RealtimeAudioFormats. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + RealtimeAudioFormatsAudioPcm, RealtimeAudioFormatsAudioPcma, RealtimeAudioFormatsAudioPcmu + + :ivar type: Required. Known values are: "audio/pcm", "audio/pcmu", and "audio/pcma". + :vartype type: str or ~azure.ai.voiceagents.models.RealtimeAudioFormatsType + """ + + __mapping__: dict[str, _Model] = {} + type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) + """Required. Known values are: \"audio/pcm\", \"audio/pcmu\", and \"audio/pcma\".""" + + @overload + def __init__( + self, + *, + type: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RealtimeAudioFormatsAudioPcm( + RealtimeAudioFormats, discriminator="audio/pcm" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """RealtimeAudioFormatsAudioPcm. + + :ivar type: Required. AUDIO_PCM. + :vartype type: str or ~azure.ai.voiceagents.models.AUDIO_PCM + :ivar rate: Default value is 24000. + :vartype rate: int + """ + + type: Literal[RealtimeAudioFormatsType.AUDIO_PCM] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. AUDIO_PCM.""" + rate: Optional[Literal[24000]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Default value is 24000.""" + + @overload + def __init__( + self, + *, + rate: Optional[Literal[24000]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = RealtimeAudioFormatsType.AUDIO_PCM # type: ignore + + +class RealtimeAudioFormatsAudioPcma(RealtimeAudioFormats, discriminator="audio/pcma"): + """RealtimeAudioFormatsAudioPcma. + + :ivar type: Required. AUDIO_PCMA. + :vartype type: str or ~azure.ai.voiceagents.models.AUDIO_PCMA + """ + + type: Literal[RealtimeAudioFormatsType.AUDIO_PCMA] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. AUDIO_PCMA.""" + + @overload + def __init__( + self, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = RealtimeAudioFormatsType.AUDIO_PCMA # type: ignore + + +class RealtimeAudioFormatsAudioPcmu(RealtimeAudioFormats, discriminator="audio/pcmu"): + """RealtimeAudioFormatsAudioPcmu. + + :ivar type: Required. AUDIO_PCMU. + :vartype type: str or ~azure.ai.voiceagents.models.AUDIO_PCMU + """ + + type: Literal[RealtimeAudioFormatsType.AUDIO_PCMU] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. AUDIO_PCMU.""" + + @overload + def __init__( + self, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = RealtimeAudioFormatsType.AUDIO_PCMU # type: ignore + + +class RealtimeConversationItem(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """A single item within a Realtime conversation. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + RealtimeConversationItemFunctionCall, RealtimeConversationItemFunctionCallOutput, + RealtimeMCPApprovalRequest, RealtimeMCPApprovalResponse, RealtimeMCPToolCall, + RealtimeMCPListTools + + :ivar type: Required. Known values are: "function_call", "function_call_output", + "mcp_approval_response", "mcp_list_tools", "mcp_call", and "mcp_approval_request". + :vartype type: str or ~azure.ai.voiceagents.models.RealtimeConversationItemType + """ + + __mapping__: dict[str, _Model] = {} + type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) + """Required. Known values are: \"function_call\", \"function_call_output\", + \"mcp_approval_response\", \"mcp_list_tools\", \"mcp_call\", and \"mcp_approval_request\".""" + + @overload + def __init__( + self, + *, + type: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RealtimeConversationItemFunctionCall( + RealtimeConversationItem, discriminator="function_call" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """Realtime function call item. + + :ivar id: The unique ID of the item. This may be provided by the client or generated by the + server. + :vartype id: str + :ivar object: Identifier for the API object being returned - always ``realtime.item``. Optional + when creating a new item. Default value is "realtime.item". + :vartype object: str + :ivar type: The type of the item. Always ``function_call``. Required. FUNCTION_CALL. + :vartype type: str or ~azure.ai.voiceagents.models.FUNCTION_CALL + :ivar status: The status of the item. Has no effect on the conversation. Is one of the + following types: Literal["completed"], Literal["incomplete"], Literal["in_progress"] + :vartype status: str or str or str + :ivar call_id: The ID of the function call. + :vartype call_id: str + :ivar name: The name of the function being called. Required. + :vartype name: str + :ivar arguments: The arguments of the function call. This is a JSON-encoded string representing + the arguments passed to the function, for example ``{"arg1": "value1", "arg2": 42}``. Required. + :vartype arguments: str + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the item. This may be provided by the client or generated by the server.""" + object: Optional[Literal["realtime.item"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Identifier for the API object being returned - always ``realtime.item``. Optional when creating + a new item. Default value is \"realtime.item\".""" + type: Literal[RealtimeConversationItemType.FUNCTION_CALL] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The type of the item. Always ``function_call``. Required. FUNCTION_CALL.""" + status: Optional[Literal["completed", "incomplete", "in_progress"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The status of the item. Has no effect on the conversation. Is one of the following types: + Literal[\"completed\"], Literal[\"incomplete\"], Literal[\"in_progress\"]""" + call_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the function call.""" + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of the function being called. Required.""" + arguments: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The arguments of the function call. This is a JSON-encoded string representing the arguments + passed to the function, for example ``{\"arg1\": \"value1\", \"arg2\": 42}``. Required.""" + + @overload + def __init__( + self, + *, + name: str, + arguments: str, + id: Optional[str] = None, # pylint: disable=redefined-builtin + object: Optional[Literal["realtime.item"]] = None, + status: Optional[Literal["completed", "incomplete", "in_progress"]] = None, + call_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = RealtimeConversationItemType.FUNCTION_CALL # type: ignore + + +class RealtimeConversationItemFunctionCallOutput( + RealtimeConversationItem, discriminator="function_call_output" +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """Realtime function call output item. + + :ivar id: The unique ID of the item. This may be provided by the client or generated by the + server. + :vartype id: str + :ivar object: Identifier for the API object being returned - always ``realtime.item``. Optional + when creating a new item. Default value is "realtime.item". + :vartype object: str + :ivar type: The type of the item. Always ``function_call_output``. Required. + FUNCTION_CALL_OUTPUT. + :vartype type: str or ~azure.ai.voiceagents.models.FUNCTION_CALL_OUTPUT + :ivar status: The status of the item. Has no effect on the conversation. Is one of the + following types: Literal["completed"], Literal["incomplete"], Literal["in_progress"] + :vartype status: str or str or str + :ivar call_id: The ID of the function call this output is for. Required. + :vartype call_id: str + :ivar output: The output of the function call, this is free text and can contain any + information or simply be empty. Required. + :vartype output: str + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the item. This may be provided by the client or generated by the server.""" + object: Optional[Literal["realtime.item"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Identifier for the API object being returned - always ``realtime.item``. Optional when creating + a new item. Default value is \"realtime.item\".""" + type: Literal[RealtimeConversationItemType.FUNCTION_CALL_OUTPUT] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The type of the item. Always ``function_call_output``. Required. FUNCTION_CALL_OUTPUT.""" + status: Optional[Literal["completed", "incomplete", "in_progress"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The status of the item. Has no effect on the conversation. Is one of the following types: + Literal[\"completed\"], Literal[\"incomplete\"], Literal[\"in_progress\"]""" + call_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the function call this output is for. Required.""" + output: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The output of the function call, this is free text and can contain any information or simply be + empty. Required.""" + + @overload + def __init__( + self, + *, + call_id: str, + output: str, + id: Optional[str] = None, # pylint: disable=redefined-builtin + object: Optional[Literal["realtime.item"]] = None, + status: Optional[Literal["completed", "incomplete", "in_progress"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = RealtimeConversationItemType.FUNCTION_CALL_OUTPUT # type: ignore + + +class RealtimeConversationItemMessage(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """RealtimeConversationItemMessage. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + RealtimeConversationItemMessageAssistant, RealtimeConversationItemMessageSystem, + RealtimeConversationItemMessageUser + + :ivar role: Required. Known values are: "system", "user", and "assistant". + :vartype role: str or ~azure.ai.voiceagents.models.RealtimeConversationItemMessageType + """ + + __mapping__: dict[str, _Model] = {} + role: str = rest_discriminator(name="role", visibility=["read", "create", "update", "delete", "query"]) + """Required. Known values are: \"system\", \"user\", and \"assistant\".""" + + @overload + def __init__( + self, + *, + role: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RealtimeConversationItemMessageAssistant( + RealtimeConversationItemMessage, discriminator="assistant" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """Realtime assistant message item. + + :ivar id: The unique ID of the item. This may be provided by the client or generated by the + server. + :vartype id: str + :ivar object: Identifier for the API object being returned - always ``realtime.item``. Optional + when creating a new item. Default value is "realtime.item". + :vartype object: str + :ivar type: The type of the item. Always ``message``. Required. Default value is "message". + :vartype type: str + :ivar status: The status of the item. Has no effect on the conversation. Is one of the + following types: Literal["completed"], Literal["incomplete"], Literal["in_progress"] + :vartype status: str or str or str + :ivar role: The role of the message sender. Always ``assistant``. Required. ASSISTANT. + :vartype role: str or ~azure.ai.voiceagents.models.ASSISTANT + :ivar content: The content of the message. Required. + :vartype content: + list[~azure.ai.voiceagents.models.RealtimeConversationItemMessageAssistantContent] + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the item. This may be provided by the client or generated by the server.""" + object: Optional[Literal["realtime.item"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Identifier for the API object being returned - always ``realtime.item``. Optional when creating + a new item. Default value is \"realtime.item\".""" + type: Literal["message"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The type of the item. Always ``message``. Required. Default value is \"message\".""" + status: Optional[Literal["completed", "incomplete", "in_progress"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The status of the item. Has no effect on the conversation. Is one of the following types: + Literal[\"completed\"], Literal[\"incomplete\"], Literal[\"in_progress\"]""" + role: Literal[RealtimeConversationItemMessageType.ASSISTANT] = rest_discriminator(name="role", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The role of the message sender. Always ``assistant``. Required. ASSISTANT.""" + content: list["_models.RealtimeConversationItemMessageAssistantContent"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The content of the message. Required.""" + + @overload + def __init__( + self, + *, + content: list["_models.RealtimeConversationItemMessageAssistantContent"], + id: Optional[str] = None, # pylint: disable=redefined-builtin + object: Optional[Literal["realtime.item"]] = None, + status: Optional[Literal["completed", "incomplete", "in_progress"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.role = RealtimeConversationItemMessageType.ASSISTANT # type: ignore + self.type: Literal["message"] = "message" + + +class RealtimeConversationItemMessageAssistantContent( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """RealtimeConversationItemMessageAssistantContent. + + :ivar type: Is either a Literal["output_text"] type or a Literal["output_audio"] type. + :vartype type: str or str + :ivar text: + :vartype text: str + :ivar audio: + :vartype audio: str + :ivar transcript: + :vartype transcript: str + """ + + type: Optional[Literal["output_text", "output_audio"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Is either a Literal[\"output_text\"] type or a Literal[\"output_audio\"] type.""" + text: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + audio: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + transcript: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + type: Optional[Literal["output_text", "output_audio"]] = None, + text: Optional[str] = None, + audio: Optional[str] = None, + transcript: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RealtimeConversationItemMessageSystem( + RealtimeConversationItemMessage, discriminator="system" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """Realtime system message item. + + :ivar id: The unique ID of the item. This may be provided by the client or generated by the + server. + :vartype id: str + :ivar object: Identifier for the API object being returned - always ``realtime.item``. Optional + when creating a new item. Default value is "realtime.item". + :vartype object: str + :ivar type: The type of the item. Always ``message``. Required. Default value is "message". + :vartype type: str + :ivar status: The status of the item. Has no effect on the conversation. Is one of the + following types: Literal["completed"], Literal["incomplete"], Literal["in_progress"] + :vartype status: str or str or str + :ivar role: The role of the message sender. Always ``system``. Required. SYSTEM. + :vartype role: str or ~azure.ai.voiceagents.models.SYSTEM + :ivar content: The content of the message. Required. + :vartype content: + list[~azure.ai.voiceagents.models.RealtimeConversationItemMessageSystemContent] + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the item. This may be provided by the client or generated by the server.""" + object: Optional[Literal["realtime.item"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Identifier for the API object being returned - always ``realtime.item``. Optional when creating + a new item. Default value is \"realtime.item\".""" + type: Literal["message"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The type of the item. Always ``message``. Required. Default value is \"message\".""" + status: Optional[Literal["completed", "incomplete", "in_progress"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The status of the item. Has no effect on the conversation. Is one of the following types: + Literal[\"completed\"], Literal[\"incomplete\"], Literal[\"in_progress\"]""" + role: Literal[RealtimeConversationItemMessageType.SYSTEM] = rest_discriminator(name="role", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The role of the message sender. Always ``system``. Required. SYSTEM.""" + content: list["_models.RealtimeConversationItemMessageSystemContent"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The content of the message. Required.""" + + @overload + def __init__( + self, + *, + content: list["_models.RealtimeConversationItemMessageSystemContent"], + id: Optional[str] = None, # pylint: disable=redefined-builtin + object: Optional[Literal["realtime.item"]] = None, + status: Optional[Literal["completed", "incomplete", "in_progress"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.role = RealtimeConversationItemMessageType.SYSTEM # type: ignore + self.type: Literal["message"] = "message" + + +class RealtimeConversationItemMessageSystemContent( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """RealtimeConversationItemMessageSystemContent. + + :ivar type: Default value is "input_text". + :vartype type: str + :ivar text: + :vartype text: str + """ + + type: Optional[Literal["input_text"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Default value is \"input_text\".""" + text: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + type: Optional[Literal["input_text"]] = None, + text: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RealtimeConversationItemMessageUser( + RealtimeConversationItemMessage, discriminator="user" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """Realtime user message item. + + :ivar id: The unique ID of the item. This may be provided by the client or generated by the + server. + :vartype id: str + :ivar object: Identifier for the API object being returned - always ``realtime.item``. Optional + when creating a new item. Default value is "realtime.item". + :vartype object: str + :ivar type: The type of the item. Always ``message``. Required. Default value is "message". + :vartype type: str + :ivar status: The status of the item. Has no effect on the conversation. Is one of the + following types: Literal["completed"], Literal["incomplete"], Literal["in_progress"] + :vartype status: str or str or str + :ivar role: The role of the message sender. Always ``user``. Required. USER. + :vartype role: str or ~azure.ai.voiceagents.models.USER + :ivar content: The content of the message. Required. + :vartype content: list[~azure.ai.voiceagents.models.RealtimeConversationItemMessageUserContent] + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the item. This may be provided by the client or generated by the server.""" + object: Optional[Literal["realtime.item"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Identifier for the API object being returned - always ``realtime.item``. Optional when creating + a new item. Default value is \"realtime.item\".""" + type: Literal["message"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The type of the item. Always ``message``. Required. Default value is \"message\".""" + status: Optional[Literal["completed", "incomplete", "in_progress"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The status of the item. Has no effect on the conversation. Is one of the following types: + Literal[\"completed\"], Literal[\"incomplete\"], Literal[\"in_progress\"]""" + role: Literal[RealtimeConversationItemMessageType.USER] = rest_discriminator(name="role", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The role of the message sender. Always ``user``. Required. USER.""" + content: list["_models.RealtimeConversationItemMessageUserContent"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The content of the message. Required.""" + + @overload + def __init__( + self, + *, + content: list["_models.RealtimeConversationItemMessageUserContent"], + id: Optional[str] = None, # pylint: disable=redefined-builtin + object: Optional[Literal["realtime.item"]] = None, + status: Optional[Literal["completed", "incomplete", "in_progress"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.role = RealtimeConversationItemMessageType.USER # type: ignore + self.type: Literal["message"] = "message" + + +class RealtimeConversationItemMessageUserContent( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """RealtimeConversationItemMessageUserContent. + + :ivar type: Is one of the following types: Literal["input_text"], Literal["input_audio"], + Literal["input_image"] + :vartype type: str or str or str + :ivar text: + :vartype text: str + :ivar audio: + :vartype audio: str + :ivar image_url: + :vartype image_url: str + :ivar detail: Is one of the following types: Literal["auto"], Literal["low"], Literal["high"] + :vartype detail: str or str or str + :ivar transcript: + :vartype transcript: str + """ + + type: Optional[Literal["input_text", "input_audio", "input_image"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Is one of the following types: Literal[\"input_text\"], Literal[\"input_audio\"], + Literal[\"input_image\"]""" + text: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + audio: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + image_url: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + detail: Optional[Literal["auto", "low", "high"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Is one of the following types: Literal[\"auto\"], Literal[\"low\"], Literal[\"high\"]""" + transcript: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + type: Optional[Literal["input_text", "input_audio", "input_image"]] = None, + text: Optional[str] = None, + audio: Optional[str] = None, + image_url: Optional[str] = None, + detail: Optional[Literal["auto", "low", "high"]] = None, + transcript: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RealtimeFunctionTool(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Function tool. + + :ivar type: The type of the tool, i.e. ``function``. Default value is "function". + :vartype type: str + :ivar name: The name of the function. + :vartype name: str + :ivar description: The description of the function, including guidance on when and how to call + it, and guidance about what to tell the user when calling (if anything). + :vartype description: str + :ivar parameters: Parameters of the function in JSON Schema. + :vartype parameters: ~azure.ai.voiceagents.models.RealtimeFunctionToolParameters + """ + + type: Optional[Literal["function"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The type of the tool, i.e. ``function``. Default value is \"function\".""" + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of the function.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The description of the function, including guidance on when and how to call it, and guidance + about what to tell the user when calling (if anything).""" + parameters: Optional["_models.RealtimeFunctionToolParameters"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Parameters of the function in JSON Schema.""" + + @overload + def __init__( + self, + *, + type: Optional[Literal["function"]] = None, + name: Optional[str] = None, + description: Optional[str] = None, + parameters: Optional["_models.RealtimeFunctionToolParameters"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RealtimeFunctionToolParameters(_Model): + """RealtimeFunctionToolParameters.""" + + +class RealtimeMCPApprovalRequest( + RealtimeConversationItem, discriminator="mcp_approval_request" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """Realtime MCP approval request. + + :ivar type: The type of the item. Always ``mcp_approval_request``. Required. + MCP_APPROVAL_REQUEST. + :vartype type: str or ~azure.ai.voiceagents.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: Literal[RealtimeConversationItemType.MCP_APPROVAL_REQUEST] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The type of the item. Always ``mcp_approval_request``. Required. MCP_APPROVAL_REQUEST.""" + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the approval request. Required.""" + server_label: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The label of the MCP server making the request. Required.""" + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of the tool to run. Required.""" + arguments: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """A JSON string of arguments for the tool. Required.""" + + @overload + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + server_label: str, + name: str, + arguments: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = RealtimeConversationItemType.MCP_APPROVAL_REQUEST # type: ignore + + +class RealtimeMCPApprovalResponse( + RealtimeConversationItem, discriminator="mcp_approval_response" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """Realtime MCP approval response. + + :ivar type: The type of the item. Always ``mcp_approval_response``. Required. + MCP_APPROVAL_RESPONSE. + :vartype type: str or ~azure.ai.voiceagents.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: Literal[RealtimeConversationItemType.MCP_APPROVAL_RESPONSE] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The type of the item. Always ``mcp_approval_response``. Required. MCP_APPROVAL_RESPONSE.""" + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the approval response. Required.""" + approval_request_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the approval request being answered. Required.""" + approve: bool = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Whether the request was approved. Required.""" + reason: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + approval_request_id: str, + approve: bool, + reason: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = RealtimeConversationItemType.MCP_APPROVAL_RESPONSE # type: ignore + + +class RealtimeMCPError(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """RealtimeMCPError. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + RealtimeMCPHTTPError, RealtimeMCPProtocolError, RealtimeMCPToolExecutionError + + :ivar type: Required. Known values are: "protocol_error", "tool_execution_error", and + "http_error". + :vartype type: str or ~azure.ai.voiceagents.models.RealtimeMcpErrorType + """ + + __mapping__: dict[str, _Model] = {} + type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) + """Required. Known values are: \"protocol_error\", \"tool_execution_error\", and \"http_error\".""" + + @overload + def __init__( + self, + *, + type: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RealtimeMCPHTTPError( + RealtimeMCPError, discriminator="http_error" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """Realtime MCP HTTP error. + + :ivar type: Required. HTTP_ERROR. + :vartype type: str or ~azure.ai.voiceagents.models.HTTP_ERROR + :ivar code: Required. + :vartype code: int + :ivar message: Required. + :vartype message: str + """ + + type: Literal[RealtimeMcpErrorType.HTTP_ERROR] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. HTTP_ERROR.""" + code: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + message: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + + @overload + def __init__( + self, + *, + code: int, + message: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = RealtimeMcpErrorType.HTTP_ERROR # type: ignore + + +class RealtimeMCPListTools( + RealtimeConversationItem, discriminator="mcp_list_tools" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """Realtime MCP list tools. + + :ivar type: The type of the item. Always ``mcp_list_tools``. Required. MCP_LIST_TOOLS. + :vartype type: str or ~azure.ai.voiceagents.models.MCP_LIST_TOOLS + :ivar id: The unique ID of the list. + :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.voiceagents.models.MCPListToolsTool] + """ + + type: Literal[RealtimeConversationItemType.MCP_LIST_TOOLS] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The type of the item. Always ``mcp_list_tools``. Required. MCP_LIST_TOOLS.""" + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the list.""" + server_label: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The label of the MCP server. Required.""" + tools: list["_models.MCPListToolsTool"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The tools available on the server. Required.""" + + @overload + def __init__( + self, + *, + server_label: str, + tools: list["_models.MCPListToolsTool"], + id: Optional[str] = None, # pylint: disable=redefined-builtin + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = RealtimeConversationItemType.MCP_LIST_TOOLS # type: ignore + + +class RealtimeMCPProtocolError( + RealtimeMCPError, discriminator="protocol_error" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """Realtime MCP protocol error. + + :ivar type: Required. PROTOCOL_ERROR. + :vartype type: str or ~azure.ai.voiceagents.models.PROTOCOL_ERROR + :ivar code: Required. + :vartype code: int + :ivar message: Required. + :vartype message: str + """ + + type: Literal[RealtimeMcpErrorType.PROTOCOL_ERROR] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. PROTOCOL_ERROR.""" + code: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + message: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + + @overload + def __init__( + self, + *, + code: int, + message: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = RealtimeMcpErrorType.PROTOCOL_ERROR # type: ignore + + +class RealtimeMCPToolCall( + RealtimeConversationItem, discriminator="mcp_call" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """Realtime MCP tool call. + + :ivar type: The type of the item. Always ``mcp_call``. Required. MCP_CALL. + :vartype type: str or ~azure.ai.voiceagents.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 approval_request_id: + :vartype approval_request_id: str + :ivar output: + :vartype output: str + :ivar error: + :vartype error: ~azure.ai.voiceagents.models.RealtimeMCPError + """ + + type: Literal[RealtimeConversationItemType.MCP_CALL] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The type of the item. Always ``mcp_call``. Required. MCP_CALL.""" + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the tool call. Required.""" + server_label: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The label of the MCP server running the tool. Required.""" + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of the tool that was run. Required.""" + arguments: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """A JSON string of the arguments passed to the tool. Required.""" + approval_request_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + output: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + error: Optional["_models.RealtimeMCPError"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + server_label: str, + name: str, + arguments: str, + approval_request_id: Optional[str] = None, + output: Optional[str] = None, + error: Optional["_models.RealtimeMCPError"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = RealtimeConversationItemType.MCP_CALL # type: ignore + + +class RealtimeMCPToolExecutionError( + RealtimeMCPError, discriminator="tool_execution_error" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """Realtime MCP tool execution error. + + :ivar type: Required. TOOL_EXECUTION_ERROR. + :vartype type: str or ~azure.ai.voiceagents.models.TOOL_EXECUTION_ERROR + :ivar message: Required. + :vartype message: str + """ + + type: Literal[RealtimeMcpErrorType.TOOL_EXECUTION_ERROR] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. TOOL_EXECUTION_ERROR.""" + message: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + + @overload + def __init__( + self, + *, + message: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = RealtimeMcpErrorType.TOOL_EXECUTION_ERROR # type: ignore + + +class RealtimeReasoning(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Realtime reasoning configuration. + + :ivar effort: Known values are: "minimal", "low", "medium", "high", and "xhigh". + :vartype effort: str or ~azure.ai.voiceagents.models.RealtimeReasoningEffort + """ + + effort: Optional[Union[str, "_models.RealtimeReasoningEffort"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Known values are: \"minimal\", \"low\", \"medium\", \"high\", and \"xhigh\".""" + + @overload + def __init__( + self, + *, + effort: Optional[Union[str, "_models.RealtimeReasoningEffort"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RealtimeResponseStatusDetails(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """RealtimeResponseStatusDetails. + + :ivar type: Is one of the following types: Literal["completed"], Literal["cancelled"], + Literal["failed"], Literal["incomplete"] + :vartype type: str or str or str or str + :ivar reason: Is one of the following types: Literal["turn_detected"], + Literal["client_cancelled"], Literal["max_output_tokens"], Literal["content_filter"] + :vartype reason: str or str or str or str + :ivar error: + :vartype error: ~azure.ai.voiceagents.models.RealtimeResponseStatusDetailsError + """ + + type: Optional[Literal["completed", "cancelled", "failed", "incomplete"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Is one of the following types: Literal[\"completed\"], Literal[\"cancelled\"], + Literal[\"failed\"], Literal[\"incomplete\"]""" + reason: Optional[Literal["turn_detected", "client_cancelled", "max_output_tokens", "content_filter"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Is one of the following types: Literal[\"turn_detected\"], Literal[\"client_cancelled\"], + Literal[\"max_output_tokens\"], Literal[\"content_filter\"]""" + error: Optional["_models.RealtimeResponseStatusDetailsError"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + type: Optional[Literal["completed", "cancelled", "failed", "incomplete"]] = None, + reason: Optional[Literal["turn_detected", "client_cancelled", "max_output_tokens", "content_filter"]] = None, + error: Optional["_models.RealtimeResponseStatusDetailsError"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RealtimeResponseStatusDetailsError(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """RealtimeResponseStatusDetailsError. + + :ivar type: + :vartype type: str + :ivar code: + :vartype code: str + """ + + type: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + code: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + type: Optional[str] = None, + code: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RealtimeResponseUsage(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """RealtimeResponseUsage. + + :ivar total_tokens: + :vartype total_tokens: int + :ivar input_tokens: + :vartype input_tokens: int + :ivar output_tokens: + :vartype output_tokens: int + :ivar input_token_details: + :vartype input_token_details: + ~azure.ai.voiceagents.models.RealtimeResponseUsageInputTokenDetails + :ivar output_token_details: + :vartype output_token_details: + ~azure.ai.voiceagents.models.RealtimeResponseUsageOutputTokenDetails + """ + + total_tokens: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + input_tokens: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + output_tokens: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + input_token_details: Optional["_models.RealtimeResponseUsageInputTokenDetails"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + output_token_details: Optional["_models.RealtimeResponseUsageOutputTokenDetails"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + total_tokens: Optional[int] = None, + input_tokens: Optional[int] = None, + output_tokens: Optional[int] = None, + input_token_details: Optional["_models.RealtimeResponseUsageInputTokenDetails"] = None, + output_token_details: Optional["_models.RealtimeResponseUsageOutputTokenDetails"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RealtimeResponseUsageInputTokenDetails(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """RealtimeResponseUsageInputTokenDetails. + + :ivar cached_tokens: + :vartype cached_tokens: int + :ivar text_tokens: + :vartype text_tokens: int + :ivar image_tokens: + :vartype image_tokens: int + :ivar audio_tokens: + :vartype audio_tokens: int + :ivar cached_tokens_details: + :vartype cached_tokens_details: + ~azure.ai.voiceagents.models.RealtimeResponseUsageInputTokenDetailsCachedTokensDetails + """ + + cached_tokens: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + text_tokens: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + image_tokens: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + audio_tokens: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + cached_tokens_details: Optional["_models.RealtimeResponseUsageInputTokenDetailsCachedTokensDetails"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + cached_tokens: Optional[int] = None, + text_tokens: Optional[int] = None, + image_tokens: Optional[int] = None, + audio_tokens: Optional[int] = None, + cached_tokens_details: Optional["_models.RealtimeResponseUsageInputTokenDetailsCachedTokensDetails"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RealtimeResponseUsageInputTokenDetailsCachedTokensDetails( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """RealtimeResponseUsageInputTokenDetailsCachedTokensDetails. + + :ivar text_tokens: + :vartype text_tokens: int + :ivar image_tokens: + :vartype image_tokens: int + :ivar audio_tokens: + :vartype audio_tokens: int + """ + + text_tokens: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + image_tokens: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + audio_tokens: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + text_tokens: Optional[int] = None, + image_tokens: Optional[int] = None, + audio_tokens: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RealtimeResponseUsageOutputTokenDetails(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """RealtimeResponseUsageOutputTokenDetails. + + :ivar text_tokens: + :vartype text_tokens: int + :ivar audio_tokens: + :vartype audio_tokens: int + """ + + text_tokens: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + audio_tokens: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + text_tokens: Optional[int] = None, + audio_tokens: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RealtimeServerEvent(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """A realtime server event. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + RealtimeServerEventResponseContentPartAdded + + :ivar type: Required. Known values are: "conversation.created", "conversation.item.created", + "conversation.item.deleted", "conversation.item.input_audio_transcription.completed", + "conversation.item.input_audio_transcription.delta", + "conversation.item.input_audio_transcription.failed", "conversation.item.retrieved", + "conversation.item.truncated", "error", "input_audio_buffer.cleared", + "input_audio_buffer.committed", "input_audio_buffer.dtmf_event_received", + "input_audio_buffer.speech_started", "input_audio_buffer.speech_stopped", + "rate_limits.updated", "response.output_audio.delta", "response.output_audio.done", + "response.output_audio_transcript.delta", "response.output_audio_transcript.done", + "response.content_part.added", "response.content_part.done", "response.created", + "response.done", "response.function_call_arguments.delta", + "response.function_call_arguments.done", "response.output_item.added", + "response.output_item.done", "response.output_text.delta", "response.output_text.done", + "session.created", "session.updated", "output_audio_buffer.started", + "output_audio_buffer.stopped", "output_audio_buffer.cleared", "conversation.item.added", + "conversation.item.done", "input_audio_buffer.timeout_triggered", + "conversation.item.input_audio_transcription.segment", "mcp_list_tools.in_progress", + "mcp_list_tools.completed", "mcp_list_tools.failed", "response.mcp_call_arguments.delta", + "response.mcp_call_arguments.done", "response.mcp_call.in_progress", + "response.mcp_call.completed", and "response.mcp_call.failed". + :vartype type: str or ~azure.ai.voiceagents.models.RealtimeServerEventType + """ + + __mapping__: dict[str, _Model] = {} + type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) + """Required. Known values are: \"conversation.created\", \"conversation.item.created\", + \"conversation.item.deleted\", \"conversation.item.input_audio_transcription.completed\", + \"conversation.item.input_audio_transcription.delta\", + \"conversation.item.input_audio_transcription.failed\", \"conversation.item.retrieved\", + \"conversation.item.truncated\", \"error\", \"input_audio_buffer.cleared\", + \"input_audio_buffer.committed\", \"input_audio_buffer.dtmf_event_received\", + \"input_audio_buffer.speech_started\", \"input_audio_buffer.speech_stopped\", + \"rate_limits.updated\", \"response.output_audio.delta\", \"response.output_audio.done\", + \"response.output_audio_transcript.delta\", \"response.output_audio_transcript.done\", + \"response.content_part.added\", \"response.content_part.done\", \"response.created\", + \"response.done\", \"response.function_call_arguments.delta\", + \"response.function_call_arguments.done\", \"response.output_item.added\", + \"response.output_item.done\", \"response.output_text.delta\", \"response.output_text.done\", + \"session.created\", \"session.updated\", \"output_audio_buffer.started\", + \"output_audio_buffer.stopped\", \"output_audio_buffer.cleared\", \"conversation.item.added\", + \"conversation.item.done\", \"input_audio_buffer.timeout_triggered\", + \"conversation.item.input_audio_transcription.segment\", \"mcp_list_tools.in_progress\", + \"mcp_list_tools.completed\", \"mcp_list_tools.failed\", \"response.mcp_call_arguments.delta\", + \"response.mcp_call_arguments.done\", \"response.mcp_call.in_progress\", + \"response.mcp_call.completed\", and \"response.mcp_call.failed\".""" + + @overload + def __init__( + self, + *, + type: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RealtimeServerEventConversationItemInputAudioTranscriptionFailedError( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """RealtimeServerEventConversationItemInputAudioTranscriptionFailedError. + + :ivar type: + :vartype type: str + :ivar code: + :vartype code: str + :ivar message: + :vartype message: str + :ivar param: + :vartype param: str + """ + + type: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + code: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + message: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + param: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + type: Optional[str] = None, + code: Optional[str] = None, + message: Optional[str] = None, + param: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RealtimeServerEventRateLimitsUpdatedRateLimits( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """RealtimeServerEventRateLimitsUpdatedRateLimits. + + :ivar name: Is either a Literal["requests"] type or a Literal["tokens"] type. + :vartype name: str or str + :ivar limit: + :vartype limit: int + :ivar remaining: + :vartype remaining: int + :ivar reset_seconds: + :vartype reset_seconds: float + """ + + name: Optional[Literal["requests", "tokens"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Is either a Literal[\"requests\"] type or a Literal[\"tokens\"] type.""" + limit: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + remaining: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + reset_seconds: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + name: Optional[Literal["requests", "tokens"]] = None, + limit: Optional[int] = None, + remaining: Optional[int] = None, + reset_seconds: Optional[float] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RealtimeServerEventResponseContentPartAdded( + RealtimeServerEvent, discriminator="response.content_part.added" +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """Returned when a new content part is added to an assistant message item during response + generation. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``response.content_part.added``. Required. + RESPONSE_CONTENT_PART_ADDED. + :vartype type: str or ~azure.ai.voiceagents.models.RESPONSE_CONTENT_PART_ADDED + :ivar response_id: The ID of the response. Required. + :vartype response_id: str + :ivar item_id: The ID of the item to which the content part was added. Required. + :vartype item_id: str + :ivar output_index: The index of the output item in the response. Required. + :vartype output_index: int + :ivar content_index: The index of the content part in the item's content array. Required. + :vartype content_index: int + :ivar part: The content part that was added. Required. + :vartype part: ~azure.ai.voiceagents.models.RealtimeServerEventResponseContentPartAddedPart + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the server event. Required.""" + type: Literal[RealtimeServerEventType.RESPONSE_CONTENT_PART_ADDED] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The event type, must be ``response.content_part.added``. Required. RESPONSE_CONTENT_PART_ADDED.""" + response_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the response. Required.""" + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the item to which the content part was added. Required.""" + output_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The index of the output item in the response. Required.""" + content_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The index of the content part in the item's content array. Required.""" + part: "_models.RealtimeServerEventResponseContentPartAddedPart" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The content part that was added. Required.""" + + @overload + def __init__( + self, + *, + event_id: str, + response_id: str, + item_id: str, + output_index: int, + content_index: int, + part: "_models.RealtimeServerEventResponseContentPartAddedPart", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = RealtimeServerEventType.RESPONSE_CONTENT_PART_ADDED # type: ignore + + +class RealtimeServerEventResponseContentPartAddedPart( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """RealtimeServerEventResponseContentPartAddedPart. + + :ivar type: Is either a Literal["audio"] type or a Literal["text"] type. + :vartype type: str or str + :ivar text: + :vartype text: str + :ivar audio: + :vartype audio: str + :ivar transcript: + :vartype transcript: str + """ + + type: Optional[Literal["audio", "text"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Is either a Literal[\"audio\"] type or a Literal[\"text\"] type.""" + text: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + audio: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + transcript: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + type: Optional[Literal["audio", "text"]] = None, + text: Optional[str] = None, + audio: Optional[str] = None, + transcript: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RealtimeToolChoiceFunction(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """A Realtime tool-choice object that forces the model to call a specific function. + + :ivar type: For function calling, the type is always ``function``. Required. FUNCTION. + :vartype type: str or ~azure.ai.voiceagents.models.FUNCTION + :ivar name: The name of the function to call. Required. + :vartype name: str + """ + + type: Literal[ToolChoiceParamType.FUNCTION] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """For function calling, the type is always ``function``. Required. FUNCTION.""" + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of the function to call. Required.""" + + @overload + def __init__( + self, + *, + type: Literal[ToolChoiceParamType.FUNCTION], + name: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ResponsesProtocolConfiguration(_Model): + """Configuration specific to the responses protocol.""" + + +class StructuredInputDefinition(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """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. The service + defaults to ``false`` if a value is not specified by the caller. + :vartype required: bool + """ + + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """A human-readable description of the input.""" + default_value: Optional[Any] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The default value for the input if no run-time value is provided.""" + schema: Optional[dict[str, Any]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The JSON schema for the structured input (optional).""" + required: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Whether the input property is required when the agent is invoked. The service defaults to + ``false`` if a value is not specified by the caller.""" + + @overload + def __init__( + self, + *, + description: Optional[str] = None, + default_value: Optional[Any] = None, + schema: Optional[dict[str, Any]] = None, + required: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class TemplateVoiceGreetingConfig( + VoiceGreetingConfig, discriminator="template" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """A deterministic greeting rendered with the voice agent's structured inputs and synthesized + without model-authored generation. + + :ivar type: Required. Default value is "template". + :vartype type: str + :ivar text: The Handlebars text template spoken at session start. Required. + :vartype text: str + """ + + type: Literal["template"] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. Default value is \"template\".""" + text: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The Handlebars text template spoken at session start. Required.""" + + @overload + def __init__( + self, + *, + text: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = "template" # type: ignore + + +class ToolChoiceParam(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """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. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ToolChoiceFunction, ToolChoiceMCP + + :ivar type: Required. Known values are: "allowed_tools", "function", "mcp", "custom", + "programmatic_tool_calling", "apply_patch", "shell", "file_search", "web_search_preview", + "computer_use_preview", "web_search_preview_2025_03_11", "image_generation", + "code_interpreter", "computer", and "computer_use". + :vartype type: str or ~azure.ai.voiceagents.models.ToolChoiceParamType + """ + + __mapping__: dict[str, _Model] = {} + type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) + """Required. Known values are: \"allowed_tools\", \"function\", \"mcp\", \"custom\", + \"programmatic_tool_calling\", \"apply_patch\", \"shell\", \"file_search\", + \"web_search_preview\", \"computer_use_preview\", \"web_search_preview_2025_03_11\", + \"image_generation\", \"code_interpreter\", \"computer\", and \"computer_use\".""" + + @overload + def __init__( + self, + *, + type: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ToolChoiceFunction( + ToolChoiceParam, discriminator="function" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """Function tool. + + :ivar type: For function calling, the type is always ``function``. Required. FUNCTION. + :vartype type: str or ~azure.ai.voiceagents.models.FUNCTION + :ivar name: The name of the function to call. Required. + :vartype name: str + """ + + type: Literal[ToolChoiceParamType.FUNCTION] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """For function calling, the type is always ``function``. Required. FUNCTION.""" + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of the function to call. Required.""" + + @overload + def __init__( + self, + *, + name: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = ToolChoiceParamType.FUNCTION # type: ignore + + +class ToolChoiceMCP( + ToolChoiceParam, discriminator="mcp" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """MCP tool. + + :ivar type: For MCP tools, the type is always ``mcp``. Required. MCP. + :vartype type: str or ~azure.ai.voiceagents.models.MCP + :ivar server_label: The label of the MCP server to use. Required. + :vartype server_label: str + :ivar name: + :vartype name: str + """ + + type: Literal[ToolChoiceParamType.MCP] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """For MCP tools, the type is always ``mcp``. Required. MCP.""" + server_label: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The label of the MCP server to use. Required.""" + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + server_label: str, + name: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = ToolChoiceParamType.MCP # type: ignore + + +class ToolConfig(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Per-tool configuration that controls tool visibility and search behavior. + + :ivar pin: When true, the tool is always included in agent context and visible in + ``tools/list``. When false (default), the tool is hidden from ``tools/list`` and only + discoverable via ``tool_search``. + :vartype pin: bool + :ivar additional_search_text: Additional text indexed for tool_search. Supplements the native + tool description to improve discoverability. Does not alter ``tools/list`` output. + :vartype additional_search_text: str + """ + + pin: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """When true, the tool is always included in agent context and visible in ``tools/list``. When + false (default), the tool is hidden from ``tools/list`` and only discoverable via + ``tool_search``.""" + additional_search_text: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Additional text indexed for tool_search. Supplements the native tool description to improve + discoverability. Does not alter ``tools/list`` output.""" + + @overload + def __init__( + self, + *, + pin: Optional[bool] = None, + additional_search_text: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class TranscriptTextUsageDuration( + CreateTranscriptionResponseJsonUsage, discriminator="duration" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """Duration Usage. + + :ivar type: The type of the usage object. Always ``duration`` for this variant. Required. + DURATION. + :vartype type: str or ~azure.ai.voiceagents.models.DURATION + :ivar seconds: Duration of the input audio in seconds. Required. + :vartype seconds: ~datetime.timedelta + """ + + type: Literal[CreateTranscriptionResponseJsonUsageType.DURATION] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The type of the usage object. Always ``duration`` for this variant. Required. DURATION.""" + seconds: datetime.timedelta = rest_field( + visibility=["read", "create", "update", "delete", "query"], format="duration-seconds-int" + ) + """Duration of the input audio in seconds. Required.""" + + @overload + def __init__( + self, + *, + seconds: datetime.timedelta, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = CreateTranscriptionResponseJsonUsageType.DURATION # type: ignore + + +class TranscriptTextUsageTokens( + CreateTranscriptionResponseJsonUsage, discriminator="tokens" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """Token Usage. + + :ivar type: The type of the usage object. Always ``tokens`` for this variant. Required. TOKENS. + :vartype type: str or ~azure.ai.voiceagents.models.TOKENS + :ivar input_tokens: Number of input tokens billed for this request. Required. + :vartype input_tokens: int + :ivar input_token_details: Details about the input tokens billed for this request. + :vartype input_token_details: + ~azure.ai.voiceagents.models.TranscriptTextUsageTokensInputTokenDetails + :ivar output_tokens: Number of output tokens generated. Required. + :vartype output_tokens: int + :ivar total_tokens: Total number of tokens used (input + output). Required. + :vartype total_tokens: int + """ + + type: Literal[CreateTranscriptionResponseJsonUsageType.TOKENS] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The type of the usage object. Always ``tokens`` for this variant. Required. TOKENS.""" + input_tokens: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Number of input tokens billed for this request. Required.""" + input_token_details: Optional["_models.TranscriptTextUsageTokensInputTokenDetails"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Details about the input tokens billed for this request.""" + output_tokens: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Number of output tokens generated. Required.""" + total_tokens: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Total number of tokens used (input + output). Required.""" + + @overload + def __init__( + self, + *, + input_tokens: int, + output_tokens: int, + total_tokens: int, + input_token_details: Optional["_models.TranscriptTextUsageTokensInputTokenDetails"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = CreateTranscriptionResponseJsonUsageType.TOKENS # type: ignore + + +class TranscriptTextUsageTokensInputTokenDetails( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """TranscriptTextUsageTokensInputTokenDetails. + + :ivar text_tokens: + :vartype text_tokens: int + :ivar audio_tokens: + :vartype audio_tokens: int + """ + + text_tokens: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + audio_tokens: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + text_tokens: Optional[int] = None, + audio_tokens: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VersionSelector(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """VersionSelector. + + :ivar version_selection_rules: Required. + :vartype version_selection_rules: list[~azure.ai.voiceagents.models.VersionSelectionRule] + """ + + version_selection_rules: list["_models.VersionSelectionRule"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Required.""" + + @overload + def __init__( + self, + *, + version_selection_rules: list["_models.VersionSelectionRule"], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentAnimationConfig(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Animation settings for a voice-agent session. + + :ivar model_name: The animation model name. + :vartype model_name: str + :ivar outputs: The requested animation output kinds. + :vartype outputs: list[str or ~azure.ai.voiceagents.models.VoiceAgentAnimationOutputType] + """ + + model_name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The animation model name.""" + outputs: Optional[list[Union[str, "_models.VoiceAgentAnimationOutputType"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The requested animation output kinds.""" + + @overload + def __init__( + self, + *, + model_name: Optional[str] = None, + outputs: Optional[list[Union[str, "_models.VoiceAgentAnimationOutputType"]]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentAvatarIceServer(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """An ICE server used for avatar WebRTC negotiation. + + :ivar urls: Required. + :vartype urls: list[str] + :ivar username: + :vartype username: str + :ivar credential: + :vartype credential: str + """ + + urls: list[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + username: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + credential: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + urls: list[str], + username: Optional[str] = None, + credential: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentAvatarScene(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Avatar placement and motion settings. + + :ivar zoom: + :vartype zoom: float + :ivar position_x: + :vartype position_x: float + :ivar position_y: + :vartype position_y: float + :ivar rotation_x: + :vartype rotation_x: float + :ivar rotation_y: + :vartype rotation_y: float + :ivar rotation_z: + :vartype rotation_z: float + :ivar amplitude: + :vartype amplitude: float + """ + + zoom: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + position_x: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + position_y: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + rotation_x: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + rotation_y: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + rotation_z: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + amplitude: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + zoom: Optional[float] = None, + position_x: Optional[float] = None, + position_y: Optional[float] = None, + rotation_x: Optional[float] = None, + rotation_y: Optional[float] = None, + rotation_z: Optional[float] = None, + amplitude: Optional[float] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentAvatarVideoBackground(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """The avatar video background. + + :ivar image_url: + :vartype image_url: str + :ivar color: + :vartype color: str + """ + + image_url: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + color: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + image_url: Optional[str] = None, + color: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentAvatarVideoCrop(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """The rectangular crop applied to avatar video. + + :ivar bottom_right: Required. + :vartype bottom_right: list[int] + :ivar top_left: Required. + :vartype top_left: list[int] + """ + + bottom_right: list[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + top_left: list[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + + @overload + def __init__( + self, + *, + bottom_right: list[int], + top_left: list[int], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentAvatarVideoParams(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Avatar video encoder and presentation settings. + + :ivar bitrate: + :vartype bitrate: int + :ivar codec: Default value is "h264". + :vartype codec: str + :ivar crop: + :vartype crop: ~azure.ai.voiceagents.models.VoiceAgentAvatarVideoCrop + :ivar resolution: + :vartype resolution: ~azure.ai.voiceagents.models.VoiceAgentAvatarVideoResolution + :ivar background: + :vartype background: ~azure.ai.voiceagents.models.VoiceAgentAvatarVideoBackground + :ivar gop_size: + :vartype gop_size: int + """ + + bitrate: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + codec: Optional[Literal["h264"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Default value is \"h264\".""" + crop: Optional["_models.VoiceAgentAvatarVideoCrop"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + resolution: Optional["_models.VoiceAgentAvatarVideoResolution"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + background: Optional["_models.VoiceAgentAvatarVideoBackground"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + gop_size: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + bitrate: Optional[int] = None, + codec: Optional[Literal["h264"]] = None, + crop: Optional["_models.VoiceAgentAvatarVideoCrop"] = None, + resolution: Optional["_models.VoiceAgentAvatarVideoResolution"] = None, + background: Optional["_models.VoiceAgentAvatarVideoBackground"] = None, + gop_size: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentAvatarVideoResolution(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """The avatar video resolution. + + :ivar width: Required. + :vartype width: int + :ivar height: Required. + :vartype height: int + """ + + width: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + height: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + + @overload + def __init__( + self, + *, + width: int, + height: int, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentAzureMultilingualSemanticVadTurnDetection( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """Azure multilingual semantic VAD turn-detection settings. + + :ivar remove_filler_words: Whether filler words are removed from transcription. + :vartype remove_filler_words: bool + :ivar auto_truncate: Whether the input audio buffer is truncated automatically when speech + stops. + :vartype auto_truncate: bool + :ivar create_response: Whether a response is created automatically when speech stops. + :vartype create_response: bool + :ivar interrupt_response: Whether user speech may interrupt the agent's response. + :vartype interrupt_response: bool + :ivar type: Required. Multilingual Azure semantic voice activity detection. + :vartype type: str or ~azure.ai.voiceagents.models.AZURE_SEMANTIC_VAD_MULTILINGUAL + :ivar threshold: + :vartype threshold: float + :ivar prefix_padding_ms: + :vartype prefix_padding_ms: int + :ivar silence_duration_ms: + :vartype silence_duration_ms: int + :ivar idle_timeout_ms: + :vartype idle_timeout_ms: int + :ivar speech_duration_ms: + :vartype speech_duration_ms: int + :ivar end_of_utterance_detection: + :vartype end_of_utterance_detection: + ~azure.ai.voiceagents.models.VoiceAgentEndOfUtteranceDetection + :ivar languages: + :vartype languages: list[str] + """ + + remove_filler_words: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Whether filler words are removed from transcription.""" + auto_truncate: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Whether the input audio buffer is truncated automatically when speech stops.""" + create_response: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Whether a response is created automatically when speech stops.""" + interrupt_response: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Whether user speech may interrupt the agent's response.""" + type: Literal[VoiceTurnDetectionType.AZURE_SEMANTIC_VAD_MULTILINGUAL] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Required. Multilingual Azure semantic voice activity detection.""" + threshold: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + prefix_padding_ms: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + silence_duration_ms: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + idle_timeout_ms: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + speech_duration_ms: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + end_of_utterance_detection: Optional["_models.VoiceAgentEndOfUtteranceDetection"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + languages: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + type: Literal[VoiceTurnDetectionType.AZURE_SEMANTIC_VAD_MULTILINGUAL], + remove_filler_words: Optional[bool] = None, + auto_truncate: Optional[bool] = None, + create_response: Optional[bool] = None, + interrupt_response: Optional[bool] = None, + threshold: Optional[float] = None, + prefix_padding_ms: Optional[int] = None, + silence_duration_ms: Optional[int] = None, + idle_timeout_ms: Optional[int] = None, + speech_duration_ms: Optional[int] = None, + end_of_utterance_detection: Optional["_models.VoiceAgentEndOfUtteranceDetection"] = None, + languages: Optional[list[str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentAzureSemanticVadTurnDetection(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Azure semantic VAD turn-detection settings. + + :ivar create_response: Whether a response is created automatically when speech stops. + :vartype create_response: bool + :ivar interrupt_response: Whether user speech may interrupt the agent's response. + :vartype interrupt_response: bool + :ivar type: Required. Known values are: "azure_semantic_vad" and "azure_semantic_vad_en". + :vartype type: str or ~azure.ai.voiceagents.models.VoiceAgentAzureSemanticVadType + :ivar threshold: + :vartype threshold: float + :ivar prefix_padding_ms: + :vartype prefix_padding_ms: int + :ivar silence_duration_ms: + :vartype silence_duration_ms: int + :ivar idle_timeout_ms: + :vartype idle_timeout_ms: int + :ivar speech_duration_ms: + :vartype speech_duration_ms: int + :ivar end_of_utterance_detection: + :vartype end_of_utterance_detection: + ~azure.ai.voiceagents.models.VoiceAgentEndOfUtteranceDetection + :ivar remove_filler_words: + :vartype remove_filler_words: bool + :ivar languages: + :vartype languages: list[str] + :ivar auto_truncate: + :vartype auto_truncate: bool + """ + + create_response: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Whether a response is created automatically when speech stops.""" + interrupt_response: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Whether user speech may interrupt the agent's response.""" + type: Union[str, "_models.VoiceAgentAzureSemanticVadType"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Required. Known values are: \"azure_semantic_vad\" and \"azure_semantic_vad_en\".""" + threshold: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + prefix_padding_ms: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + silence_duration_ms: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + idle_timeout_ms: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + speech_duration_ms: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + end_of_utterance_detection: Optional["_models.VoiceAgentEndOfUtteranceDetection"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + remove_filler_words: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + languages: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + auto_truncate: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + type: Union[str, "_models.VoiceAgentAzureSemanticVadType"], + create_response: Optional[bool] = None, + interrupt_response: Optional[bool] = None, + threshold: Optional[float] = None, + prefix_padding_ms: Optional[int] = None, + silence_duration_ms: Optional[int] = None, + idle_timeout_ms: Optional[int] = None, + speech_duration_ms: Optional[int] = None, + end_of_utterance_detection: Optional["_models.VoiceAgentEndOfUtteranceDetection"] = None, + remove_filler_words: Optional[bool] = None, + languages: Optional[list[str]] = None, + auto_truncate: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentClientEventConversationItemCreate( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``conversation.item.create`` client event. + + :ivar event_id: Optional client-generated ID used to identify this event. + :vartype event_id: str + :ivar type: The event type, must be ``conversation.item.create``. Required. + CONVERSATION_ITEM_CREATE. + :vartype type: str or ~azure.ai.voiceagents.models.CONVERSATION_ITEM_CREATE + :ivar previous_item_id: The ID of the preceding item after which the new item will be inserted. + If not set, the new item will be appended to the end of the conversation. If set to ``root``, + the new item will be added to the beginning of the conversation. If set to an existing ID, it + allows an item to be inserted mid-conversation. If the ID cannot be found, an error will be + returned and the item will not be added. + :vartype previous_item_id: str + :ivar item: The conversation item to create. Required. Is either a + "_unions.VoiceAgentRequestConversationItem" type or a RealtimeMCPApprovalResponse type. + :vartype item: ~azure.ai.voiceagents.models.RealtimeConversationItemMessageSystem or + ~azure.ai.voiceagents.models.RealtimeConversationItemMessageUser or + ~azure.ai.voiceagents.models.RealtimeConversationItemMessageAssistant or + ~azure.ai.voiceagents.models.RealtimeConversationItemFunctionCall or + ~azure.ai.voiceagents.models.RealtimeConversationItemFunctionCallOutput or + ~azure.ai.voiceagents.models.RealtimeMCPApprovalResponse + """ + + event_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Optional client-generated ID used to identify this event.""" + type: Literal[RealtimeClientEventType.CONVERSATION_ITEM_CREATE] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``conversation.item.create``. Required. CONVERSATION_ITEM_CREATE.""" + previous_item_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the preceding item after which the new item will be inserted. If not set, the new + item will be appended to the end of the conversation. If set to ``root``, the new item will be + added to the beginning of the conversation. If set to an existing ID, it allows an item to be + inserted mid-conversation. If the ID cannot be found, an error will be returned and the item + will not be added.""" + item: "_unions.VoiceAgentCreateConversationItem" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The conversation item to create. Required. Is either a + \"_unions.VoiceAgentRequestConversationItem\" type or a RealtimeMCPApprovalResponse type.""" + + @overload + def __init__( + self, + *, + type: Literal[RealtimeClientEventType.CONVERSATION_ITEM_CREATE], + item: "_unions.VoiceAgentCreateConversationItem", + event_id: Optional[str] = None, + previous_item_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentClientEventConversationItemDelete( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``conversation.item.delete`` client event. + + :ivar event_id: Optional client-generated ID used to identify this event. + :vartype event_id: str + :ivar type: The event type, must be ``conversation.item.delete``. Required. + CONVERSATION_ITEM_DELETE. + :vartype type: str or ~azure.ai.voiceagents.models.CONVERSATION_ITEM_DELETE + :ivar item_id: The ID of the item to delete. Required. + :vartype item_id: str + """ + + event_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Optional client-generated ID used to identify this event.""" + type: Literal[RealtimeClientEventType.CONVERSATION_ITEM_DELETE] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``conversation.item.delete``. Required. CONVERSATION_ITEM_DELETE.""" + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the item to delete. Required.""" + + @overload + def __init__( + self, + *, + type: Literal[RealtimeClientEventType.CONVERSATION_ITEM_DELETE], + item_id: str, + event_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentClientEventConversationItemRetrieve( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``conversation.item.retrieve`` client event. + + :ivar event_id: Optional client-generated ID used to identify this event. + :vartype event_id: str + :ivar type: The event type, must be ``conversation.item.retrieve``. Required. + CONVERSATION_ITEM_RETRIEVE. + :vartype type: str or ~azure.ai.voiceagents.models.CONVERSATION_ITEM_RETRIEVE + :ivar item_id: The ID of the item to retrieve. Required. + :vartype item_id: str + """ + + event_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Optional client-generated ID used to identify this event.""" + type: Literal[RealtimeClientEventType.CONVERSATION_ITEM_RETRIEVE] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``conversation.item.retrieve``. Required. CONVERSATION_ITEM_RETRIEVE.""" + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the item to retrieve. Required.""" + + @overload + def __init__( + self, + *, + type: Literal[RealtimeClientEventType.CONVERSATION_ITEM_RETRIEVE], + item_id: str, + event_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentClientEventConversationItemTruncate( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``conversation.item.truncate`` client event. + + :ivar event_id: Optional client-generated ID used to identify this event. + :vartype event_id: str + :ivar type: The event type, must be ``conversation.item.truncate``. Required. + CONVERSATION_ITEM_TRUNCATE. + :vartype type: str or ~azure.ai.voiceagents.models.CONVERSATION_ITEM_TRUNCATE + :ivar item_id: The ID of the assistant message item to truncate. Only assistant message items + can be truncated. Required. + :vartype item_id: str + :ivar content_index: The index of the content part to truncate. Set this to ``0``. Required. + :vartype content_index: int + :ivar audio_end_ms: Inclusive duration up to which audio is truncated, in milliseconds. If the + audio_end_ms is greater than the actual audio duration, the server will respond with an error. + Required. + :vartype audio_end_ms: int + """ + + event_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Optional client-generated ID used to identify this event.""" + type: Literal[RealtimeClientEventType.CONVERSATION_ITEM_TRUNCATE] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``conversation.item.truncate``. Required. CONVERSATION_ITEM_TRUNCATE.""" + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the assistant message item to truncate. Only assistant message items can be + truncated. Required.""" + content_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The index of the content part to truncate. Set this to ``0``. Required.""" + audio_end_ms: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Inclusive duration up to which audio is truncated, in milliseconds. If the audio_end_ms is + greater than the actual audio duration, the server will respond with an error. Required.""" + + @overload + def __init__( + self, + *, + type: Literal[RealtimeClientEventType.CONVERSATION_ITEM_TRUNCATE], + item_id: str, + content_index: int, + audio_end_ms: int, + event_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentClientEventInputAudioBufferAppend( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``input_audio_buffer.append`` client event. + + :ivar event_id: Optional client-generated ID used to identify this event. + :vartype event_id: str + :ivar type: The event type, must be ``input_audio_buffer.append``. Required. + INPUT_AUDIO_BUFFER_APPEND. + :vartype type: str or ~azure.ai.voiceagents.models.INPUT_AUDIO_BUFFER_APPEND + :ivar audio: Base64-encoded audio bytes. This must be in the format specified by the + ``input_audio_format`` field in the session configuration. Required. + :vartype audio: str + """ + + event_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Optional client-generated ID used to identify this event.""" + type: Literal[RealtimeClientEventType.INPUT_AUDIO_BUFFER_APPEND] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``input_audio_buffer.append``. Required. INPUT_AUDIO_BUFFER_APPEND.""" + audio: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Base64-encoded audio bytes. This must be in the format specified by the ``input_audio_format`` + field in the session configuration. Required.""" + + @overload + def __init__( + self, + *, + type: Literal[RealtimeClientEventType.INPUT_AUDIO_BUFFER_APPEND], + audio: str, + event_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentClientEventInputAudioBufferClear( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``input_audio_buffer.clear`` client event. + + :ivar event_id: Optional client-generated ID used to identify this event. + :vartype event_id: str + :ivar type: The event type, must be ``input_audio_buffer.clear``. Required. + INPUT_AUDIO_BUFFER_CLEAR. + :vartype type: str or ~azure.ai.voiceagents.models.INPUT_AUDIO_BUFFER_CLEAR + """ + + event_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Optional client-generated ID used to identify this event.""" + type: Literal[RealtimeClientEventType.INPUT_AUDIO_BUFFER_CLEAR] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``input_audio_buffer.clear``. Required. INPUT_AUDIO_BUFFER_CLEAR.""" + + @overload + def __init__( + self, + *, + type: Literal[RealtimeClientEventType.INPUT_AUDIO_BUFFER_CLEAR], + event_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentClientEventInputAudioBufferCommit( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``input_audio_buffer.commit`` client event. + + :ivar event_id: Optional client-generated ID used to identify this event. + :vartype event_id: str + :ivar type: The event type, must be ``input_audio_buffer.commit``. Required. + INPUT_AUDIO_BUFFER_COMMIT. + :vartype type: str or ~azure.ai.voiceagents.models.INPUT_AUDIO_BUFFER_COMMIT + """ + + event_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Optional client-generated ID used to identify this event.""" + type: Literal[RealtimeClientEventType.INPUT_AUDIO_BUFFER_COMMIT] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``input_audio_buffer.commit``. Required. INPUT_AUDIO_BUFFER_COMMIT.""" + + @overload + def __init__( + self, + *, + type: Literal[RealtimeClientEventType.INPUT_AUDIO_BUFFER_COMMIT], + event_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentClientEventOutputAudioBufferClear( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``output_audio_buffer.clear`` client event. + + :ivar event_id: The unique ID of the client event used for error handling. + :vartype event_id: str + :ivar type: The event type, must be ``output_audio_buffer.clear``. Required. + OUTPUT_AUDIO_BUFFER_CLEAR. + :vartype type: str or ~azure.ai.voiceagents.models.OUTPUT_AUDIO_BUFFER_CLEAR + """ + + event_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the client event used for error handling.""" + type: Literal[RealtimeClientEventType.OUTPUT_AUDIO_BUFFER_CLEAR] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``output_audio_buffer.clear``. Required. OUTPUT_AUDIO_BUFFER_CLEAR.""" + + @overload + def __init__( + self, + *, + type: Literal[RealtimeClientEventType.OUTPUT_AUDIO_BUFFER_CLEAR], + event_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentClientEventResponseCancel(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """The ``response.cancel`` client event. + + :ivar event_id: Optional client-generated ID used to identify this event. + :vartype event_id: str + :ivar type: The event type, must be ``response.cancel``. Required. RESPONSE_CANCEL. + :vartype type: str or ~azure.ai.voiceagents.models.RESPONSE_CANCEL + :ivar response_id: A specific response ID to cancel - if not provided, will cancel an + in-progress response in the default conversation. + :vartype response_id: str + """ + + event_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Optional client-generated ID used to identify this event.""" + type: Literal[RealtimeClientEventType.RESPONSE_CANCEL] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``response.cancel``. Required. RESPONSE_CANCEL.""" + response_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """A specific response ID to cancel - if not provided, will cancel an in-progress response in the + default conversation.""" + + @overload + def __init__( + self, + *, + type: Literal[RealtimeClientEventType.RESPONSE_CANCEL], + event_id: Optional[str] = None, + response_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentClientEventResponseCreate(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """The ``response.create`` client event. + + :ivar event_id: Optional client-generated ID used to identify this event. + :vartype event_id: str + :ivar type: The event type, must be ``response.create``. Required. RESPONSE_CREATE. + :vartype type: str or ~azure.ai.voiceagents.models.RESPONSE_CREATE + :ivar response: Parameters for the new response. + :vartype response: ~azure.ai.voiceagents.models.VoiceAgentResponseCreateParams + """ + + event_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Optional client-generated ID used to identify this event.""" + type: Literal[RealtimeClientEventType.RESPONSE_CREATE] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``response.create``. Required. RESPONSE_CREATE.""" + response: Optional["_models.VoiceAgentResponseCreateParams"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Parameters for the new response.""" + + @overload + def __init__( + self, + *, + type: Literal[RealtimeClientEventType.RESPONSE_CREATE], + event_id: Optional[str] = None, + response: Optional["_models.VoiceAgentResponseCreateParams"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentClientEventSessionAvatarConnect( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``session.avatar.connect`` client event. + + :ivar type: The event type. Always ``session.avatar.connect``. Required. Default value is + "session.avatar.connect". + :vartype type: str + :ivar event_id: An optional client-generated event identifier. + :vartype event_id: str + :ivar client_sdp: The client's SDP offer for avatar media negotiation. Required. + :vartype client_sdp: str + """ + + type: Literal["session.avatar.connect"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The event type. Always ``session.avatar.connect``. Required. Default value is + \"session.avatar.connect\".""" + event_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """An optional client-generated event identifier.""" + client_sdp: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The client's SDP offer for avatar media negotiation. Required.""" + + @overload + def __init__( + self, + *, + client_sdp: str, + event_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["session.avatar.connect"] = "session.avatar.connect" + + +class VoiceAgentClientEventSessionUpdate(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """The ``session.update`` client event. + + :ivar event_id: Optional client-generated ID used to identify this event. This is an arbitrary + string that a client may assign. It will be passed back if there is an error with the event, + but the corresponding ``session.updated`` event will not include it. + :vartype event_id: str + :ivar type: The event type, must be ``session.update``. Required. SESSION_UPDATE. + :vartype type: str or ~azure.ai.voiceagents.models.SESSION_UPDATE + :ivar session: The stable realtime session fields to update. Required. + :vartype session: ~azure.ai.voiceagents.models.VoiceAgentSessionUpdateConfig + """ + + event_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Optional client-generated ID used to identify this event. This is an arbitrary string that a + client may assign. It will be passed back if there is an error with the event, but the + corresponding ``session.updated`` event will not include it.""" + type: Literal[RealtimeClientEventType.SESSION_UPDATE] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``session.update``. Required. SESSION_UPDATE.""" + session: "_models.VoiceAgentSessionUpdateConfig" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The stable realtime session fields to update. Required.""" + + @overload + def __init__( + self, + *, + type: Literal[RealtimeClientEventType.SESSION_UPDATE], + session: "_models.VoiceAgentSessionUpdateConfig", + event_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentDefinition(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """The voice agent definition. Its configuration (model, instructions, audio, tools, and optional + avatar) drives a managed speech-to-speech experience. The realtime voice session is established + through a separate connect operation that is not defined in this specification. Every create or + update produces a new immutable version. + + :ivar kind: The kind discriminator for a voice agent definition. Always ``voice``. Required. + Default value is "voice". + :vartype kind: str + :ivar rai_config: Configuration for Responsible AI (RAI) content filtering and safety features. + :vartype rai_config: ~azure.ai.voiceagents.models.RaiConfig + :ivar model_type: How the model backing this agent is served. Together with ``model``, this + selects the model up front. ``managed`` uses a service-managed model; ``self_deployed`` uses + the customer's own Foundry deployment. This is independent of the architecture (realtime or + cascaded), which the service derives from the selected model. Required. Known values are: + "managed" and "self_deployed". + :vartype model_type: str or ~azure.ai.voiceagents.models.VoiceModelType + :ivar model: The model to use for this agent, paired with ``model_type``: the service-managed + model name when ``model_type`` is ``managed``, or the customer's Foundry deployment name when + ``model_type`` is ``self_deployed``. The model must support realtime or cascaded voice. The + service derives the architecture from the selected model. Required. + :vartype model: str + :ivar instructions: A system (or developer) message inserted into the model's context. Supports + template substitution via ``structured_inputs``, rendered per session before the live session + starts. + :vartype instructions: str + :ivar greeting: Optional session-start greeting. Template mode speaks exact rendered text; + LLM-generated mode asks the session model to author the opening response and may use configured + tools. + :vartype greeting: ~azure.ai.voiceagents.models.VoiceGreetingConfig + :ivar audio: The audio configuration, including input and output formats, voice, turn + detection, noise reduction, and transcription. These values are session defaults; a client may + override supported fields when connecting. + :vartype audio: ~azure.ai.voiceagents.models.VoiceAudioConfig + :ivar output_modalities: The output modalities the agent produces. Defaults to ``["audio"]``. + ``animation`` and ``avatar`` are available when an avatar is configured. + :vartype output_modalities: list[str or ~azure.ai.voiceagents.models.VoiceOutputModality] + :ivar avatar: Optional avatar configuration. These values are session defaults and may be + overridden when connecting. + :vartype avatar: ~azure.ai.voiceagents.models.VoiceAvatarConfig + :ivar tools: The tools the voice agent may use. Supported tool kinds are ``function`` (executed + by the client), ``mcp``, ``system`` (service-managed session controls), and ``toolbox``. + Server-side tools such as ``web_search``, ``azure_ai_search``, and ``openapi`` are provided + through a toolbox rather than declared directly. + :vartype tools: list[~azure.ai.voiceagents.models.RealtimeFunctionTool or + ~azure.ai.voiceagents.models.VoiceAgentMcpTool or ~azure.ai.voiceagents.models.VoiceSystemTool + or ~azure.ai.voiceagents.models.VoiceToolboxTool] + :ivar structured_inputs: Set of structured inputs that participate in prompt template + substitution, rendered per session before the live session starts. + :vartype structured_inputs: dict[str, ~azure.ai.voiceagents.models.StructuredInputDefinition] + :ivar store: Whether conversations with this agent are persisted. A single, all-or-nothing + persistence switch that defaults to ``false`` (privacy-safe: off by default). When ``true``, + Foundry persists the full conversation — the transcript/event timeline and raw audio. When + ``false``, nothing is persisted and no conversation is surfaced. There is no separate + audio-logging control; audio is persisted only as part of this switch. Latency/performance + telemetry (e.g. time-to-first-audio, inter-token latency, interruption) is observability-only + (customer trace / App Insights) and is not part of the persisted conversation content. + :vartype store: bool + """ + + kind: Literal["voice"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The kind discriminator for a voice agent definition. Always ``voice``. Required. Default value + is \"voice\".""" + rai_config: Optional["_models.RaiConfig"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Configuration for Responsible AI (RAI) content filtering and safety features.""" + model_type: Union[str, "_models.VoiceModelType"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """How the model backing this agent is served. Together with ``model``, this selects the model up + front. ``managed`` uses a service-managed model; ``self_deployed`` uses the customer's own + Foundry deployment. This is independent of the architecture (realtime or cascaded), which the + service derives from the selected model. Required. Known values are: \"managed\" and + \"self_deployed\".""" + model: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The model to use for this agent, paired with ``model_type``: the service-managed model name + when ``model_type`` is ``managed``, or the customer's Foundry deployment name when + ``model_type`` is ``self_deployed``. The model must support realtime or cascaded voice. The + service derives the architecture from the selected model. Required.""" + instructions: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """A system (or developer) message inserted into the model's context. Supports template + substitution via ``structured_inputs``, rendered per session before the live session starts.""" + greeting: Optional["_models.VoiceGreetingConfig"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Optional session-start greeting. Template mode speaks exact rendered text; LLM-generated mode + asks the session model to author the opening response and may use configured tools.""" + audio: Optional["_models.VoiceAudioConfig"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The audio configuration, including input and output formats, voice, turn detection, noise + reduction, and transcription. These values are session defaults; a client may override + supported fields when connecting.""" + output_modalities: Optional[list[Union[str, "_models.VoiceOutputModality"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The output modalities the agent produces. Defaults to ``[\"audio\"]``. ``animation`` and + ``avatar`` are available when an avatar is configured.""" + avatar: Optional["_models.VoiceAvatarConfig"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Optional avatar configuration. These values are session defaults and may be overridden when + connecting.""" + tools: Optional[list["_unions.VoiceAgentTool"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The tools the voice agent may use. Supported tool kinds are ``function`` (executed by the + client), ``mcp``, ``system`` (service-managed session controls), and ``toolbox``. Server-side + tools such as ``web_search``, ``azure_ai_search``, and ``openapi`` are provided through a + toolbox rather than declared directly.""" + structured_inputs: Optional[dict[str, "_models.StructuredInputDefinition"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Set of structured inputs that participate in prompt template substitution, rendered per session + before the live session starts.""" + store: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Whether conversations with this agent are persisted. A single, all-or-nothing persistence + switch that defaults to ``false`` (privacy-safe: off by default). When ``true``, Foundry + persists the full conversation — the transcript/event timeline and raw audio. When ``false``, + nothing is persisted and no conversation is surfaced. There is no separate audio-logging + control; audio is persisted only as part of this switch. Latency/performance telemetry (e.g. + time-to-first-audio, inter-token latency, interruption) is observability-only (customer trace / + App Insights) and is not part of the persisted conversation content.""" + + @overload + def __init__( + self, + *, + model_type: Union[str, "_models.VoiceModelType"], + model: str, + rai_config: Optional["_models.RaiConfig"] = None, + instructions: Optional[str] = None, + greeting: Optional["_models.VoiceGreetingConfig"] = None, + audio: Optional["_models.VoiceAudioConfig"] = None, + output_modalities: Optional[list[Union[str, "_models.VoiceOutputModality"]]] = None, + avatar: Optional["_models.VoiceAvatarConfig"] = None, + tools: Optional[list["_unions.VoiceAgentTool"]] = None, + structured_inputs: Optional[dict[str, "_models.StructuredInputDefinition"]] = None, + store: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.kind: Literal["voice"] = "voice" + + +class VoiceAgentEchoCancellation(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Server-side echo cancellation settings for input audio. + + :ivar type: The echo cancellation implementation. Always ``server_echo_cancellation``. + Required. Default value is "server_echo_cancellation". + :vartype type: str + :ivar reference_source: Whether reference audio comes from server playback or a client-provided + channel. Known values are: "server" and "client". + :vartype reference_source: str or + ~azure.ai.voiceagents.models.VoiceAgentEchoCancellationReferenceSource + :ivar channels: The number of input channels. Use two interleaved channels when + ``reference_source`` is ``client``. + :vartype channels: int + """ + + type: Literal["server_echo_cancellation"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The echo cancellation implementation. Always ``server_echo_cancellation``. Required. Default + value is \"server_echo_cancellation\".""" + reference_source: Optional[Union[str, "_models.VoiceAgentEchoCancellationReferenceSource"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Whether reference audio comes from server playback or a client-provided channel. Known values + are: \"server\" and \"client\".""" + channels: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The number of input channels. Use two interleaved channels when ``reference_source`` is + ``client``.""" + + @overload + def __init__( + self, + *, + reference_source: Optional[Union[str, "_models.VoiceAgentEchoCancellationReferenceSource"]] = None, + channels: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["server_echo_cancellation"] = "server_echo_cancellation" + + +class VoiceAgentEndOfUtteranceDetection(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """End-of-utterance detection settings. + + :ivar model: Required. Known values are: "semantic_detection_v1", "semantic_detection_v1_en", + "semantic_detection_v1_multilingual", and "smart_end_of_turn_detection". + :vartype model: str or ~azure.ai.voiceagents.models.VoiceAgentEndOfUtteranceModel + :ivar threshold: + :vartype threshold: float + :ivar threshold_level: Known values are: "low", "medium", "high", and "default". + :vartype threshold_level: str or + ~azure.ai.voiceagents.models.VoiceAgentEndOfUtteranceThresholdLevel + :ivar timeout: + :vartype timeout: float + :ivar timeout_ms: + :vartype timeout_ms: int + """ + + model: Union[str, "_models.VoiceAgentEndOfUtteranceModel"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Required. Known values are: \"semantic_detection_v1\", \"semantic_detection_v1_en\", + \"semantic_detection_v1_multilingual\", and \"smart_end_of_turn_detection\".""" + threshold: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + threshold_level: Optional[Union[str, "_models.VoiceAgentEndOfUtteranceThresholdLevel"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Known values are: \"low\", \"medium\", \"high\", and \"default\".""" + timeout: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + timeout_ms: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + model: Union[str, "_models.VoiceAgentEndOfUtteranceModel"], + threshold: Optional[float] = None, + threshold_level: Optional[Union[str, "_models.VoiceAgentEndOfUtteranceThresholdLevel"]] = None, + timeout: Optional[float] = None, + timeout_ms: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentEstimatedCost(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """A best-effort public-retail cost estimate for a response. + + :ivar amount: The total estimated amount, when available. Required. + :vartype amount: float + :ivar input_cost: The estimated input cost. + :vartype input_cost: float + :ivar output_cost: The estimated output cost. + :vartype output_cost: float + :ivar currency: The estimate currency. Always ``USD``. Default value is "USD". + :vartype currency: str + :ivar voice_live_amount: The portion attributed to Voice Live processing. Required. + :vartype voice_live_amount: float + :ivar byom_model_amount: The portion attributed to a customer-provided model. + :vartype byom_model_amount: float + :ivar status: Whether the estimate is complete, partial, or unavailable. Required. Known values + are: "complete", "partial", and "unavailable". + :vartype status: str or ~azure.ai.voiceagents.models.VoiceAgentEstimatedCostStatus + :ivar price_version: The Voice Live price version used for the estimate. Required. + :vartype price_version: str + :ivar byom_model_price_version: The customer-provided model price version used for the + estimate. + :vartype byom_model_price_version: str + :ivar unpriced_components: Components for which no price was available. + :vartype unpriced_components: list[str] + """ + + amount: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The total estimated amount, when available. Required.""" + input_cost: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The estimated input cost.""" + output_cost: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The estimated output cost.""" + currency: Optional[Literal["USD"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The estimate currency. Always ``USD``. Default value is \"USD\".""" + voice_live_amount: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The portion attributed to Voice Live processing. Required.""" + byom_model_amount: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The portion attributed to a customer-provided model.""" + status: Union[str, "_models.VoiceAgentEstimatedCostStatus"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Whether the estimate is complete, partial, or unavailable. Required. Known values are: + \"complete\", \"partial\", and \"unavailable\".""" + price_version: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The Voice Live price version used for the estimate. Required.""" + byom_model_price_version: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The customer-provided model price version used for the estimate.""" + unpriced_components: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Components for which no price was available.""" + + @overload + def __init__( + self, + *, + amount: float, + voice_live_amount: float, + status: Union[str, "_models.VoiceAgentEstimatedCostStatus"], + price_version: str, + input_cost: Optional[float] = None, + output_cost: Optional[float] = None, + currency: Optional[Literal["USD"]] = None, + byom_model_amount: Optional[float] = None, + byom_model_price_version: Optional[str] = None, + unpriced_components: Optional[list[str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentFileSearchCallItem(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """A file-search output item. + + :ivar id: Required. + :vartype id: str + :ivar type: Required. Default value is "file_search_call". + :vartype type: str + :ivar status: Required. Known values are: "in_progress", "searching", "completed", + "incomplete", and "failed". + :vartype status: str or ~azure.ai.voiceagents.models.VoiceAgentFileSearchCallStatus + :ivar queries: + :vartype queries: list[str] + :ivar results: + :vartype results: list[~azure.ai.voiceagents.models.VoiceAgentFileSearchResult] + """ + + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + type: Literal["file_search_call"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required. Default value is \"file_search_call\".""" + status: Union[str, "_models.VoiceAgentFileSearchCallStatus"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Required. Known values are: \"in_progress\", \"searching\", \"completed\", \"incomplete\", and + \"failed\".""" + queries: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + results: Optional[list["_models.VoiceAgentFileSearchResult"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + status: Union[str, "_models.VoiceAgentFileSearchCallStatus"], + queries: Optional[list[str]] = None, + results: Optional[list["_models.VoiceAgentFileSearchResult"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["file_search_call"] = "file_search_call" + + +class VoiceAgentFileSearchResult(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """One result returned by a file-search call. + + :ivar attributes: + :vartype attributes: dict[str, str or float or bool] + :ivar file_id: + :vartype file_id: str + :ivar filename: + :vartype filename: str + :ivar score: + :vartype score: float + :ivar text: + :vartype text: str + """ + + attributes: Optional[dict[str, "_unions.VoiceAgentFileSearchAttributeValue"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + file_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + filename: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + score: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + text: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + attributes: Optional[dict[str, "_unions.VoiceAgentFileSearchAttributeValue"]] = None, + file_id: Optional[str] = None, + filename: Optional[str] = None, + score: Optional[float] = None, + text: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentHandoffEdgeConfig(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """A directed transition between handoff nodes. + + :ivar id: The edge identifier. Required. + :vartype id: str + :ivar source: The source node identifier. Required. + :vartype source: str + :ivar target: The target node identifier. Required. + :vartype target: str + :ivar description: A non-empty description used by the model to select this transition. + Required. + :vartype description: str + :ivar cancel_on_interruption: Whether user interruption cancels the transition. + :vartype cancel_on_interruption: bool + :ivar delay_ms: The delay before the target behavior is committed, in milliseconds. + :vartype delay_ms: int + :ivar transfer_message: Optional text synthesized while transferring. + :vartype transfer_message: str + :ivar target_response: Whether the target automatically creates a response after transfer. + Known values are: "auto" and "none". + :vartype target_response: str or ~azure.ai.voiceagents.models.VoiceAgentHandoffTargetResponse + """ + + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The edge identifier. Required.""" + source: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The source node identifier. Required.""" + target: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The target node identifier. Required.""" + description: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """A non-empty description used by the model to select this transition. Required.""" + cancel_on_interruption: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Whether user interruption cancels the transition.""" + delay_ms: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The delay before the target behavior is committed, in milliseconds.""" + transfer_message: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Optional text synthesized while transferring.""" + target_response: Optional[Union[str, "_models.VoiceAgentHandoffTargetResponse"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Whether the target automatically creates a response after transfer. Known values are: \"auto\" + and \"none\".""" + + @overload + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + source: str, + target: str, + description: str, + cancel_on_interruption: Optional[bool] = None, + delay_ms: Optional[int] = None, + transfer_message: Optional[str] = None, + target_response: Optional[Union[str, "_models.VoiceAgentHandoffTargetResponse"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentHandoffEdgeState(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Non-sensitive metadata for an effective handoff edge. + + :ivar id: The edge identifier. Required. + :vartype id: str + :ivar source: The source node identifier. Required. + :vartype source: str + :ivar target: The target node identifier. Required. + :vartype target: str + :ivar cancel_on_interruption: Whether user interruption cancels the transition. + :vartype cancel_on_interruption: bool + :ivar delay_ms: The delay before the target behavior is committed, in milliseconds. + :vartype delay_ms: int + :ivar transfer_message: Optional text synthesized while transferring. + :vartype transfer_message: str + :ivar target_response: Whether the target automatically creates a response after transfer. + Known values are: "auto" and "none". + :vartype target_response: str or ~azure.ai.voiceagents.models.VoiceAgentHandoffTargetResponse + """ + + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The edge identifier. Required.""" + source: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The source node identifier. Required.""" + target: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The target node identifier. Required.""" + cancel_on_interruption: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Whether user interruption cancels the transition.""" + delay_ms: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The delay before the target behavior is committed, in milliseconds.""" + transfer_message: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Optional text synthesized while transferring.""" + target_response: Optional[Union[str, "_models.VoiceAgentHandoffTargetResponse"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Whether the target automatically creates a response after transfer. Known values are: \"auto\" + and \"none\".""" + + @overload + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + source: str, + target: str, + cancel_on_interruption: Optional[bool] = None, + delay_ms: Optional[int] = None, + transfer_message: Optional[str] = None, + target_response: Optional[Union[str, "_models.VoiceAgentHandoffTargetResponse"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentHandoffGraphConfig(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """A customer-supplied handoff graph. + + :ivar max_transfers: The maximum number of successful transfers in the session. + :vartype max_transfers: int + :ivar max_attempts: The maximum number of transfer attempts in the session. + :vartype max_attempts: int + :ivar nodes: The explicitly configured handoff targets. Required. + :vartype nodes: list[~azure.ai.voiceagents.models.VoiceAgentHandoffNodeConfig] + :ivar edges: The directed transitions between handoff nodes. Required. + :vartype edges: list[~azure.ai.voiceagents.models.VoiceAgentHandoffEdgeConfig] + """ + + max_transfers: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The maximum number of successful transfers in the session.""" + max_attempts: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The maximum number of transfer attempts in the session.""" + nodes: list["_models.VoiceAgentHandoffNodeConfig"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The explicitly configured handoff targets. Required.""" + edges: list["_models.VoiceAgentHandoffEdgeConfig"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The directed transitions between handoff nodes. Required.""" + + @overload + def __init__( + self, + *, + nodes: list["_models.VoiceAgentHandoffNodeConfig"], + edges: list["_models.VoiceAgentHandoffEdgeConfig"], + max_transfers: Optional[int] = None, + max_attempts: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentHandoffNodeConfig(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """A configured handoff target and its node-scoped behavior. + + :ivar id: The node identifier. Required. + :vartype id: str + :ivar description: A non-empty description used to select this target. Required. + :vartype description: str + :ivar config: Session behavior applied after transferring to this node. Required. + :vartype config: ~azure.ai.voiceagents.models.VoiceAgentHandoffNodeSessionConfig + """ + + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The node identifier. Required.""" + description: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """A non-empty description used to select this target. Required.""" + config: "_models.VoiceAgentHandoffNodeSessionConfig" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Session behavior applied after transferring to this node. Required.""" + + @overload + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + description: str, + config: "_models.VoiceAgentHandoffNodeSessionConfig", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentHandoffNodeSessionConfig(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Session behavior applied at a handoff target. + + :ivar model: The target model, when different from the current node. + :vartype model: str + :ivar instructions: Instructions applied at the target node. + :vartype instructions: str + :ivar tools: Tools available at the target node. + :vartype tools: list[~azure.ai.voiceagents.models.RealtimeFunctionTool or + ~azure.ai.voiceagents.models.VoiceAgentSessionMcpTool or + ~azure.ai.voiceagents.models.VoiceToolboxTool or ~azure.ai.voiceagents.models.VoiceSystemTool] + :ivar tool_choice: Tool-selection behavior at the target node. Is either a Union[str, + "_models.ToolChoiceOptions"] type or a RealtimeToolChoiceFunction type. + :vartype tool_choice: str or ~azure.ai.voiceagents.models.ToolChoiceOptions or + ~azure.ai.voiceagents.models.RealtimeToolChoiceFunction + :ivar voice: The target node's voice. Is one of the following types: OpenAIVoice, AzureVoice, + AzureRealtimeNativeVoice + :vartype voice: ~azure.ai.voiceagents.models.OpenAIVoice or + ~azure.ai.voiceagents.models.AzureVoice or + ~azure.ai.voiceagents.models.AzureRealtimeNativeVoice + :ivar temperature: The target node's sampling temperature. + :vartype temperature: float + :ivar max_response_output_tokens: The target node's maximum output-token count. Is either a int + type or a Literal["inf"] type. + :vartype max_response_output_tokens: int or str + :ivar reasoning_effort: The reasoning effort used at the target node. Known values are: "none", + "minimal", "low", "medium", "high", and "xhigh". + :vartype reasoning_effort: str or ~azure.ai.voiceagents.models.VoiceAgentHandoffReasoningEffort + :ivar voice_adaptation: Voice adaptation applied at the target node. + :vartype voice_adaptation: ~azure.ai.voiceagents.models.VoiceAgentVoiceAdaptation + :ivar interim_response: Interim-response settings applied at the target node. Is either a + VoiceAgentStaticInterimResponseConfig type or a VoiceAgentLlmInterimResponseConfig type. + :vartype interim_response: ~azure.ai.voiceagents.models.VoiceAgentStaticInterimResponseConfig + or ~azure.ai.voiceagents.models.VoiceAgentLlmInterimResponseConfig + :ivar parallel_tool_calls: Whether the target model may call multiple tools in parallel. + :vartype parallel_tool_calls: bool + """ + + model: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The target model, when different from the current node.""" + instructions: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Instructions applied at the target node.""" + tools: Optional[list["_unions.VoiceAgentSessionTool"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Tools available at the target node.""" + tool_choice: Optional["_unions.VoiceAgentToolChoice"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Tool-selection behavior at the target node. Is either a Union[str, + \"_models.ToolChoiceOptions\"] type or a RealtimeToolChoiceFunction type.""" + voice: Optional["_unions.VoiceAgentVoice"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The target node's voice. Is one of the following types: OpenAIVoice, AzureVoice, + AzureRealtimeNativeVoice""" + temperature: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The target node's sampling temperature.""" + max_response_output_tokens: Optional["_unions.VoiceAgentMaxOutputTokens"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The target node's maximum output-token count. Is either a int type or a Literal[\"inf\"] type.""" + reasoning_effort: Optional[Union[str, "_models.VoiceAgentHandoffReasoningEffort"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The reasoning effort used at the target node. Known values are: \"none\", \"minimal\", \"low\", + \"medium\", \"high\", and \"xhigh\".""" + voice_adaptation: Optional["_models.VoiceAgentVoiceAdaptation"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Voice adaptation applied at the target node.""" + interim_response: Optional["_unions.VoiceAgentInterimResponse"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Interim-response settings applied at the target node. Is either a + VoiceAgentStaticInterimResponseConfig type or a VoiceAgentLlmInterimResponseConfig type.""" + parallel_tool_calls: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Whether the target model may call multiple tools in parallel.""" + + @overload + def __init__( + self, + *, + model: Optional[str] = None, + instructions: Optional[str] = None, + tools: Optional[list["_unions.VoiceAgentSessionTool"]] = None, + tool_choice: Optional["_unions.VoiceAgentToolChoice"] = None, + voice: Optional["_unions.VoiceAgentVoice"] = None, + temperature: Optional[float] = None, + max_response_output_tokens: Optional["_unions.VoiceAgentMaxOutputTokens"] = None, + reasoning_effort: Optional[Union[str, "_models.VoiceAgentHandoffReasoningEffort"]] = None, + voice_adaptation: Optional["_models.VoiceAgentVoiceAdaptation"] = None, + interim_response: Optional["_unions.VoiceAgentInterimResponse"] = None, + parallel_tool_calls: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentHandoffNodeState(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Non-sensitive metadata for an effective handoff node. + + :ivar id: The node identifier. Required. + :vartype id: str + :ivar description: The node description. Required. + :vartype description: str + :ivar implicit: Whether the service implicitly created this node. + :vartype implicit: bool + """ + + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The node identifier. Required.""" + description: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The node description. Required.""" + implicit: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Whether the service implicitly created this node.""" + + @overload + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + description: str, + implicit: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentHandoffState(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """The effective handoff state returned by the service. + + :ivar pipeline_family: The runtime pipeline family. Required. Known values are: "cascaded" and + "realtime". + :vartype pipeline_family: str or ~azure.ai.voiceagents.models.VoiceAgentPipelineFamily + :ivar active_node_id: The active node identifier. Required. + :vartype active_node_id: str + :ivar node_generation: The active node generation. Required. + :vartype node_generation: int + :ivar transfer_count: The number of completed transfers. Required. + :vartype transfer_count: int + :ivar attempt_count: The number of transfer attempts. Required. + :vartype attempt_count: int + :ivar available_edge_ids: The edge identifiers currently available to the model. Required. + :vartype available_edge_ids: list[str] + :ivar transfer_tool: The function tool exposed to initiate transfers. Required. + :vartype transfer_tool: ~azure.ai.voiceagents.models.RealtimeFunctionTool + :ivar nodes: The compiled handoff nodes. Required. + :vartype nodes: list[~azure.ai.voiceagents.models.VoiceAgentHandoffNodeState] + :ivar edges: The compiled handoff edges. Required. + :vartype edges: list[~azure.ai.voiceagents.models.VoiceAgentHandoffEdgeState] + """ + + pipeline_family: Union[str, "_models.VoiceAgentPipelineFamily"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The runtime pipeline family. Required. Known values are: \"cascaded\" and \"realtime\".""" + active_node_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The active node identifier. Required.""" + node_generation: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The active node generation. Required.""" + transfer_count: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The number of completed transfers. Required.""" + attempt_count: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The number of transfer attempts. Required.""" + available_edge_ids: list[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The edge identifiers currently available to the model. Required.""" + transfer_tool: "_models.RealtimeFunctionTool" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The function tool exposed to initiate transfers. Required.""" + nodes: list["_models.VoiceAgentHandoffNodeState"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The compiled handoff nodes. Required.""" + edges: list["_models.VoiceAgentHandoffEdgeState"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The compiled handoff edges. Required.""" + + @overload + def __init__( + self, + *, + pipeline_family: Union[str, "_models.VoiceAgentPipelineFamily"], + active_node_id: str, + node_generation: int, + transfer_count: int, + attempt_count: int, + available_edge_ids: list[str], + transfer_tool: "_models.RealtimeFunctionTool", + nodes: list["_models.VoiceAgentHandoffNodeState"], + edges: list["_models.VoiceAgentHandoffEdgeState"], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentInterimResponseConfig(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Fields shared by interim-response configurations. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + VoiceAgentLlmInterimResponseConfig, VoiceAgentStaticInterimResponseConfig + + :ivar type: The interim-response implementation. Required. Default value is None. + :vartype type: str + :ivar triggers: Conditions that may trigger one interim response. + :vartype triggers: list[str or ~azure.ai.voiceagents.models.VoiceAgentInterimResponseTrigger] + :ivar latency_threshold_ms: The latency threshold in milliseconds. + :vartype latency_threshold_ms: int + """ + + __mapping__: dict[str, _Model] = {} + type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) + """The interim-response implementation. Required. Default value is None.""" + triggers: Optional[list[Union[str, "_models.VoiceAgentInterimResponseTrigger"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Conditions that may trigger one interim response.""" + latency_threshold_ms: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The latency threshold in milliseconds.""" + + @overload + def __init__( + self, + *, + type: str, + triggers: Optional[list[Union[str, "_models.VoiceAgentInterimResponseTrigger"]]] = None, + latency_threshold_ms: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentLlmInterimResponseConfig( + VoiceAgentInterimResponseConfig, discriminator="llm_interim_response" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """An interim response generated by a language model. + + :ivar triggers: Conditions that may trigger one interim response. + :vartype triggers: list[str or ~azure.ai.voiceagents.models.VoiceAgentInterimResponseTrigger] + :ivar latency_threshold_ms: The latency threshold in milliseconds. + :vartype latency_threshold_ms: int + :ivar type: Required. Default value is "llm_interim_response". + :vartype type: str + :ivar model: The model used to generate interim responses. + :vartype model: str + :ivar instructions: Optional instructions for generating interim responses. + :vartype instructions: str + :ivar max_completion_tokens: The maximum completion-token count for an interim response. + :vartype max_completion_tokens: int + """ + + type: Literal["llm_interim_response"] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. Default value is \"llm_interim_response\".""" + model: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The model used to generate interim responses.""" + instructions: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Optional instructions for generating interim responses.""" + max_completion_tokens: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The maximum completion-token count for an interim response.""" + + @overload + def __init__( + self, + *, + triggers: Optional[list[Union[str, "_models.VoiceAgentInterimResponseTrigger"]]] = None, + latency_threshold_ms: Optional[int] = None, + model: Optional[str] = None, + instructions: Optional[str] = None, + max_completion_tokens: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = "llm_interim_response" # type: ignore + + +class VoiceAgentMcpAssignedManagedIdentity(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """A managed identity used to authorize a voice-agent MCP connection. + + :ivar type: Required. Default value is "assigned_managed_identity". + :vartype type: str + :ivar audience: Required. + :vartype audience: str + :ivar client_id: + :vartype client_id: str + """ + + type: Literal["assigned_managed_identity"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required. Default value is \"assigned_managed_identity\".""" + audience: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + client_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + audience: str, + client_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["assigned_managed_identity"] = "assigned_managed_identity" + + +class VoiceAgentMcpTool(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """An MCP tool available to a voice agent. + + :ivar type: The type of the MCP tool. Always ``mcp``. Required. MCP. + :vartype type: str or ~azure.ai.voiceagents.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_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.voiceagents.models.MCPToolFilter + :ivar allowed_callers: + :vartype allowed_callers: list[str or ~azure.ai.voiceagents.models.CallableToolAllowedCaller] + :ivar require_approval: Is one of the following types: MCPToolRequireApproval, + Literal["always"], Literal["never"] + :vartype require_approval: ~azure.ai.voiceagents.models.MCPToolRequireApproval or str or str + :ivar defer_loading: Whether this MCP tool is deferred and discovered via tool search. + :vartype defer_loading: bool + :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 + :ivar tool_configs: Deprecated. This property is deprecated and will be removed in a future + version. + :vartype tool_configs: dict[str, ~azure.ai.voiceagents.models.ToolConfig] + :ivar server_url: The URL for the MCP server. + :vartype server_url: str + :ivar response_scheduling: When the MCP invocation creates a follow-up response. Defaults to + ``when_idle`` so the agent continues after the tool call completes. Known values are: "silent", + "when_idle", "interrupt", and "skip_if_busy". + :vartype response_scheduling: str or + ~azure.ai.voiceagents.models.VoiceAgentMcpResponseScheduling + """ + + type: Literal[ToolType.MCP] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The type of the MCP tool. Always ``mcp``. Required. MCP.""" + server_label: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """A label for this MCP server, used to identify it in tool calls. Required.""" + server_description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Optional description of the MCP server, used to provide more context.""" + headers: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + allowed_tools: Optional[Union[list[str], "_models.MCPToolFilter"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Is either a [str] type or a MCPToolFilter type.""" + allowed_callers: Optional[list[Union[str, "_models.CallableToolAllowedCaller"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + require_approval: Optional[Union["_models.MCPToolRequireApproval", Literal["always"], Literal["never"]]] = ( + rest_field(visibility=["read", "create", "update", "delete", "query"]) + ) + """Is one of the following types: MCPToolRequireApproval, Literal[\"always\"], Literal[\"never\"]""" + defer_loading: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Whether this MCP tool is deferred and discovered via tool search.""" + project_connection_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """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.""" + tool_configs: Optional[dict[str, "_models.ToolConfig"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Deprecated. This property is deprecated and will be removed in a future version.""" + server_url: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The URL for the MCP server.""" + response_scheduling: Optional[Union[str, "_models.VoiceAgentMcpResponseScheduling"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """When the MCP invocation creates a follow-up response. Defaults to ``when_idle`` so the agent + continues after the tool call completes. Known values are: \"silent\", \"when_idle\", + \"interrupt\", and \"skip_if_busy\".""" + + @overload + def __init__( + self, + *, + type: Literal[ToolType.MCP], + server_label: str, + server_description: Optional[str] = None, + headers: Optional[dict[str, str]] = None, + allowed_tools: Optional[Union[list[str], "_models.MCPToolFilter"]] = None, + allowed_callers: Optional[list[Union[str, "_models.CallableToolAllowedCaller"]]] = None, + require_approval: Optional[Union["_models.MCPToolRequireApproval", Literal["always"], Literal["never"]]] = None, + defer_loading: Optional[bool] = None, + project_connection_id: Optional[str] = None, + tool_configs: Optional[dict[str, "_models.ToolConfig"]] = None, + server_url: Optional[str] = None, + response_scheduling: Optional[Union[str, "_models.VoiceAgentMcpResponseScheduling"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentObject(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """A voice agent. Mirrors ``AgentObject``, but its latest version is a + ``VoiceAgentVersionObject``. + + :ivar object: The object type, which is always 'agent'. Required. AGENT. + :vartype object: str or ~azure.ai.voiceagents.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 state: The operational state of the agent. Controls whether the agent endpoint accepts or + rejects requests. Required. Known values are: "enabled" and "disabled". + :vartype state: str or ~azure.ai.voiceagents.models.AgentState + :ivar state_source: The source of the agent's operational state. When the agent is disabled, + indicates where the disabled state originates from. Empty when not derived from a specific + source. Known values are: "agent_instance_identity" and "agent_blueprint". + :vartype state_source: str or ~azure.ai.voiceagents.models.AgentStateSource + :ivar agent_endpoint: The endpoint configuration for the agent. + :vartype agent_endpoint: ~azure.ai.voiceagents.models.AgentEndpointConfig + :ivar instance_identity: The instance identity of the agent. + :vartype instance_identity: ~azure.ai.voiceagents.models.AgentIdentity + :ivar blueprint: The blueprint for the agent. + :vartype blueprint: ~azure.ai.voiceagents.models.AgentIdentity + :ivar blueprint_reference: The blueprint for the agent. + :vartype blueprint_reference: ~azure.ai.voiceagents.models.AgentBlueprintReference + :ivar agent_card: + :vartype agent_card: ~azure.ai.voiceagents.models.AgentCard + :ivar versions: The latest version of the voice agent. Required. + :vartype versions: ~azure.ai.voiceagents.models.VoiceAgentObjectVersions + """ + + object: Literal[AgentObjectType.AGENT] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The object type, which is always 'agent'. Required. AGENT.""" + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique identifier of the agent. Required.""" + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of the agent. Required.""" + state: Union[str, "_models.AgentState"] = rest_field(visibility=["read"]) + """The operational state of the agent. Controls whether the agent endpoint accepts or rejects + requests. Required. Known values are: \"enabled\" and \"disabled\".""" + state_source: Optional[Union[str, "_models.AgentStateSource"]] = rest_field(visibility=["read"]) + """The source of the agent's operational state. When the agent is disabled, indicates where the + disabled state originates from. Empty when not derived from a specific source. Known values + are: \"agent_instance_identity\" and \"agent_blueprint\".""" + agent_endpoint: Optional["_models.AgentEndpointConfig"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The endpoint configuration for the agent.""" + instance_identity: Optional["_models.AgentIdentity"] = rest_field(visibility=["read"]) + """The instance identity of the agent.""" + blueprint: Optional["_models.AgentIdentity"] = rest_field(visibility=["read"]) + """The blueprint for the agent.""" + blueprint_reference: Optional["_models.AgentBlueprintReference"] = rest_field(visibility=["read"]) + """The blueprint for the agent.""" + agent_card: Optional["_models.AgentCard"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + versions: "_models.VoiceAgentObjectVersions" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The latest version of the voice agent. Required.""" + + @overload + def __init__( + self, + *, + object: Literal[AgentObjectType.AGENT], + id: str, # pylint: disable=redefined-builtin + name: str, + versions: "_models.VoiceAgentObjectVersions", + agent_endpoint: Optional["_models.AgentEndpointConfig"] = None, + agent_card: Optional["_models.AgentCard"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentObjectVersions(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """VoiceAgentObjectVersions. + + :ivar latest: Required. + :vartype latest: ~azure.ai.voiceagents.models.VoiceAgentVersionObject + """ + + latest: "_models.VoiceAgentVersionObject" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + + @overload + def __init__( + self, + *, + latest: "_models.VoiceAgentVersionObject", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentRealtimeResponse(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """A realtime response returned by the voice-agent service. + + :ivar object: The object type. Always ``realtime.response``. Required. Default value is + "realtime.response". + :vartype object: str + :ivar id: The response identifier. Required. + :vartype id: str + :ivar status: The response lifecycle status. Required. Known values are: "in_progress", + "completed", "cancelled", "incomplete", and "failed". + :vartype status: str or ~azure.ai.voiceagents.models.VoiceAgentResponseStatus + :ivar status_details: Additional details for a terminal response status. Required. + :vartype status_details: ~azure.ai.voiceagents.models.RealtimeResponseStatusDetails + :ivar output: The items produced by the response. Required. + :vartype output: list[~azure.ai.voiceagents.models.RealtimeConversationItemMessageSystem or + ~azure.ai.voiceagents.models.RealtimeConversationItemMessageUser or + ~azure.ai.voiceagents.models.RealtimeConversationItemMessageAssistant or + ~azure.ai.voiceagents.models.VoiceFunctionCallItem or + ~azure.ai.voiceagents.models.VoiceFunctionCallOutputItem or + ~azure.ai.voiceagents.models.VoiceMcpListToolsItem or + ~azure.ai.voiceagents.models.VoiceMcpCallItem or + ~azure.ai.voiceagents.models.VoiceMcpApprovalRequestItem or + ~azure.ai.voiceagents.models.VoiceMcpApprovalResponseItem or + ~azure.ai.voiceagents.models.VoiceAgentWorkflowActionItem or + ~azure.ai.voiceagents.models.VoiceAgentWebSearchCallItem or + ~azure.ai.voiceagents.models.VoiceAgentFileSearchCallItem] + :ivar usage: Token usage for the response. Required. + :vartype usage: ~azure.ai.voiceagents.models.RealtimeResponseUsage + :ivar estimated_cost: The best-effort response cost estimate. Returned only when cost output is + enabled. + :vartype estimated_cost: ~azure.ai.voiceagents.models.VoiceAgentEstimatedCost + :ivar conversation_id: The conversation identifier, or null for an out-of-band response. + :vartype conversation_id: str + :ivar modalities: The modalities used by the response. + :vartype modalities: list[str or ~azure.ai.voiceagents.models.VoiceOutputModality] + :ivar voice: The voice used by the response. Is one of the following types: OpenAIVoice, + AzureVoice, AzureRealtimeNativeVoice + :vartype voice: ~azure.ai.voiceagents.models.OpenAIVoice or + ~azure.ai.voiceagents.models.AzureVoice or + ~azure.ai.voiceagents.models.AzureRealtimeNativeVoice + :ivar output_audio_format: The output-audio format used by the response. Known values are: + "pcm16", "pcm16_8000hz", "pcm16_16000hz", "pcm16_22050hz", "pcm16_24000hz", "pcm16_44100hz", + "pcm16_48000hz", "g711_ulaw", "g711_alaw", "mp3", "mp3_24khz_48kbps", "mp3_24khz_96kbps", and + "mp3_24khz_160kbps". + :vartype output_audio_format: str or ~azure.ai.voiceagents.models.VoiceAgentResponseAudioFormat + :ivar temperature: The sampling temperature used by the response. + :vartype temperature: float + :ivar max_output_tokens: The maximum output-token count used by the response. Is either a int + type or a Literal["inf"] type. + :vartype max_output_tokens: int or str + :ivar metadata: String key-value metadata attached to the response. + :vartype metadata: dict[str, str] + """ + + object: Literal["realtime.response"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The object type. Always ``realtime.response``. Required. Default value is + \"realtime.response\".""" + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The response identifier. Required.""" + status: Union[str, "_models.VoiceAgentResponseStatus"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The response lifecycle status. Required. Known values are: \"in_progress\", \"completed\", + \"cancelled\", \"incomplete\", and \"failed\".""" + status_details: "_models.RealtimeResponseStatusDetails" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Additional details for a terminal response status. Required.""" + output: list["_unions.VoiceAgentResponseItem"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The items produced by the response. Required.""" + usage: "_models.RealtimeResponseUsage" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Token usage for the response. Required.""" + estimated_cost: Optional["_models.VoiceAgentEstimatedCost"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The best-effort response cost estimate. Returned only when cost output is enabled.""" + conversation_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The conversation identifier, or null for an out-of-band response.""" + modalities: Optional[list[Union[str, "_models.VoiceOutputModality"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The modalities used by the response.""" + voice: Optional["_unions.VoiceAgentVoice"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The voice used by the response. Is one of the following types: OpenAIVoice, AzureVoice, + AzureRealtimeNativeVoice""" + output_audio_format: Optional[Union[str, "_models.VoiceAgentResponseAudioFormat"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The output-audio format used by the response. Known values are: \"pcm16\", \"pcm16_8000hz\", + \"pcm16_16000hz\", \"pcm16_22050hz\", \"pcm16_24000hz\", \"pcm16_44100hz\", \"pcm16_48000hz\", + \"g711_ulaw\", \"g711_alaw\", \"mp3\", \"mp3_24khz_48kbps\", \"mp3_24khz_96kbps\", and + \"mp3_24khz_160kbps\".""" + temperature: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The sampling temperature used by the response.""" + max_output_tokens: Optional["_unions.VoiceAgentMaxOutputTokens"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The maximum output-token count used by the response. Is either a int type or a Literal[\"inf\"] + type.""" + metadata: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """String key-value metadata attached to the response.""" + + @overload + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + status: Union[str, "_models.VoiceAgentResponseStatus"], + status_details: "_models.RealtimeResponseStatusDetails", + output: list["_unions.VoiceAgentResponseItem"], + usage: "_models.RealtimeResponseUsage", + estimated_cost: Optional["_models.VoiceAgentEstimatedCost"] = None, + conversation_id: Optional[str] = None, + modalities: Optional[list[Union[str, "_models.VoiceOutputModality"]]] = None, + voice: Optional["_unions.VoiceAgentVoice"] = None, + output_audio_format: Optional[Union[str, "_models.VoiceAgentResponseAudioFormat"]] = None, + temperature: Optional[float] = None, + max_output_tokens: Optional["_unions.VoiceAgentMaxOutputTokens"] = None, + metadata: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.object: Literal["realtime.response"] = "realtime.response" + + +class VoiceAgentResponseCreateAudio(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Output-audio settings applied to one ``response.create`` request. + + :ivar output: The response-specific output-audio settings. + :vartype output: ~azure.ai.voiceagents.models.VoiceAgentSessionUpdateAudioOutput + """ + + output: Optional["_models.VoiceAgentSessionUpdateAudioOutput"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The response-specific output-audio settings.""" + + @overload + def __init__( + self, + *, + output: Optional["_models.VoiceAgentSessionUpdateAudioOutput"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentResponseCreateParams(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Parameters accepted by a voice-agent ``response.create`` event. + + :ivar instructions: The default system instructions (i.e. system message) prepended to model + calls. This field allows the client to guide the model on desired responses. The model can be + instructed on response content and format, (e.g. "be extremely succinct", "act friendly", "here + are examples of good responses") and on audio behavior (e.g. "talk quickly", "inject emotion + into your voice", "laugh frequently"). The instructions are not guaranteed to be followed by + the model, but they provide guidance to the model on the desired behavior. Note that the server + sets default instructions which will be used if this field is not set and are visible in the + ``session.created`` event at the start of the session. + :vartype instructions: str + :ivar tools: Tools available to the model. + :vartype tools: list[~azure.ai.voiceagents.models.RealtimeFunctionTool or + ~azure.ai.voiceagents.models.MCPTool] + :ivar tool_choice: How the model chooses tools. Provide one of the string modes or force a + specific function/MCP tool. Is one of the following types: Union[str, + "_models.ToolChoiceOptions"], ToolChoiceFunction, ToolChoiceMCP + :vartype tool_choice: str or ~azure.ai.voiceagents.models.ToolChoiceOptions or + ~azure.ai.voiceagents.models.ToolChoiceFunction or ~azure.ai.voiceagents.models.ToolChoiceMCP + :ivar parallel_tool_calls: Whether the model may call multiple tools in parallel. Only + supported by reasoning Realtime models such as ``gpt-realtime-2``. + :vartype parallel_tool_calls: bool + :ivar reasoning: + :vartype reasoning: ~azure.ai.voiceagents.models.RealtimeReasoning + :ivar max_output_tokens: Maximum number of output tokens for a single assistant response, + inclusive of tool calls. Provide an integer between 1 and 4096 to limit output tokens, or + ``inf`` for the maximum available tokens for a given model. Defaults to ``inf``. Is either a + int type or a Literal["inf"] type. + :vartype max_output_tokens: int or str + :ivar conversation: Controls which conversation the response is added to. Currently supports + ``auto`` and ``none``, with ``auto`` as the default value. The ``auto`` value means that the + contents of the response will be added to the default conversation. Set this to ``none`` to + create an out-of-band response which will not add items to default conversation. Is one of the + following types: Literal["auto"], Literal["none"], str + :vartype conversation: str or str or str + :ivar metadata: + :vartype metadata: ~azure.ai.voiceagents.models.Metadata + :ivar input: Input items to include in the prompt for the model. Using this field creates a new + context for this Response instead of using the default conversation. An empty array ``[]`` will + clear the context for this Response. Note that this can include references to items that + previously appeared in the session using their id. + :vartype input: list[~azure.ai.voiceagents.models.RealtimeConversationItem] + :ivar output_modalities: Modalities that the response may return. + :vartype output_modalities: list[str or ~azure.ai.voiceagents.models.VoiceOutputModality] + :ivar audio: Response-specific audio settings. + :vartype audio: ~azure.ai.voiceagents.models.VoiceAgentResponseCreateAudio + :ivar pre_generated_assistant_message: A pre-generated assistant message used to begin the + response. + :vartype pre_generated_assistant_message: + ~azure.ai.voiceagents.models.RealtimeConversationItemMessageAssistant + :ivar interim_response: Interim-response settings for this response. Is either a + VoiceAgentStaticInterimResponseConfig type or a VoiceAgentLlmInterimResponseConfig type. + :vartype interim_response: ~azure.ai.voiceagents.models.VoiceAgentStaticInterimResponseConfig + or ~azure.ai.voiceagents.models.VoiceAgentLlmInterimResponseConfig + """ + + instructions: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The default system instructions (i.e. system message) prepended to model calls. This field + allows the client to guide the model on desired responses. The model can be instructed on + response content and format, (e.g. \"be extremely succinct\", \"act friendly\", \"here are + examples of good responses\") and on audio behavior (e.g. \"talk quickly\", \"inject emotion + into your voice\", \"laugh frequently\"). The instructions are not guaranteed to be followed by + the model, but they provide guidance to the model on the desired behavior. Note that the server + sets default instructions which will be used if this field is not set and are visible in the + ``session.created`` event at the start of the session.""" + tools: Optional[list[Union["_models.RealtimeFunctionTool", "_models.MCPTool"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Tools available to the model.""" + tool_choice: Optional[ + Union[str, "_models.ToolChoiceOptions", "_models.ToolChoiceFunction", "_models.ToolChoiceMCP"] + ] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """How the model chooses tools. Provide one of the string modes or force a specific function/MCP + tool. Is one of the following types: Union[str, \"_models.ToolChoiceOptions\"], + ToolChoiceFunction, ToolChoiceMCP""" + parallel_tool_calls: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Whether the model may call multiple tools in parallel. Only supported by reasoning Realtime + models such as ``gpt-realtime-2``.""" + reasoning: Optional["_models.RealtimeReasoning"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + max_output_tokens: Optional[Union[int, Literal["inf"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Maximum number of output tokens for a single assistant response, inclusive of tool calls. + Provide an integer between 1 and 4096 to limit output tokens, or ``inf`` for the maximum + available tokens for a given model. Defaults to ``inf``. Is either a int type or a + Literal[\"inf\"] type.""" + conversation: Optional[Union[Literal["auto"], Literal["none"], str]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Controls which conversation the response is added to. Currently supports ``auto`` and ``none``, + with ``auto`` as the default value. The ``auto`` value means that the contents of the response + will be added to the default conversation. Set this to ``none`` to create an out-of-band + response which will not add items to default conversation. Is one of the following types: + Literal[\"auto\"], Literal[\"none\"], str""" + metadata: Optional["_models.Metadata"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + input: Optional[list["_models.RealtimeConversationItem"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Input items to include in the prompt for the model. Using this field creates a new context for + this Response instead of using the default conversation. An empty array ``[]`` will clear the + context for this Response. Note that this can include references to items that previously + appeared in the session using their id.""" + output_modalities: Optional[list[Union[str, "_models.VoiceOutputModality"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Modalities that the response may return.""" + audio: Optional["_models.VoiceAgentResponseCreateAudio"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Response-specific audio settings.""" + pre_generated_assistant_message: Optional["_models.RealtimeConversationItemMessageAssistant"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """A pre-generated assistant message used to begin the response.""" + interim_response: Optional["_unions.VoiceAgentInterimResponse"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Interim-response settings for this response. Is either a VoiceAgentStaticInterimResponseConfig + type or a VoiceAgentLlmInterimResponseConfig type.""" + + @overload + def __init__( + self, + *, + instructions: Optional[str] = None, + tools: Optional[list[Union["_models.RealtimeFunctionTool", "_models.MCPTool"]]] = None, + tool_choice: Optional[ + Union[str, "_models.ToolChoiceOptions", "_models.ToolChoiceFunction", "_models.ToolChoiceMCP"] + ] = None, + parallel_tool_calls: Optional[bool] = None, + reasoning: Optional["_models.RealtimeReasoning"] = None, + max_output_tokens: Optional[Union[int, Literal["inf"]]] = None, + conversation: Optional[Union[Literal["auto"], Literal["none"], str]] = None, + metadata: Optional["_models.Metadata"] = None, + input: Optional[list["_models.RealtimeConversationItem"]] = None, + output_modalities: Optional[list[Union[str, "_models.VoiceOutputModality"]]] = None, + audio: Optional["_models.VoiceAgentResponseCreateAudio"] = None, + pre_generated_assistant_message: Optional["_models.RealtimeConversationItemMessageAssistant"] = None, + interim_response: Optional["_unions.VoiceAgentInterimResponse"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentResponseEventAudioContentPart(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """An audio part in a ``response.content_part.*`` server event. + + :ivar type: Required. Default value is "audio". + :vartype type: str + :ivar transcript: Required. + :vartype transcript: str + :ivar annotations: + :vartype annotations: any + :ivar audio: + :vartype audio: str + :ivar format: + :vartype format: ~azure.ai.voiceagents.models.VoiceAudioFormat + """ + + type: Literal["audio"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required. Default value is \"audio\".""" + transcript: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + annotations: Optional[Any] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + audio: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + format: Optional["_models.VoiceAudioFormat"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + transcript: str, + annotations: Optional[Any] = None, + audio: Optional[str] = None, + format: Optional["_models.VoiceAudioFormat"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["audio"] = "audio" + + +class VoiceAgentResponseEventTextContentPart(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """A text part in a ``response.content_part.*`` server event. + + :ivar type: Required. Default value is "text". + :vartype type: str + :ivar text: Required. + :vartype text: str + """ + + type: Literal["text"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required. Default value is \"text\".""" + text: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + + @overload + def __init__( + self, + *, + text: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["text"] = "text" + + +class VoiceAgentSemanticVadTurnDetection(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """OpenAI semantic VAD turn-detection settings. + + :ivar eagerness: Is one of the following types: Literal["low"], Literal["medium"], + Literal["high"], Literal["auto"] + :vartype eagerness: str or str or str or str + :ivar create_response: + :vartype create_response: bool + :ivar interrupt_response: + :vartype interrupt_response: bool + :ivar type: Required. Semantic voice activity detection. + :vartype type: str or ~azure.ai.voiceagents.models.SEMANTIC_VAD + :ivar auto_truncate: + :vartype auto_truncate: bool + """ + + eagerness: Optional[Literal["low", "medium", "high", "auto"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Is one of the following types: Literal[\"low\"], Literal[\"medium\"], Literal[\"high\"], + Literal[\"auto\"]""" + create_response: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + interrupt_response: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + type: Literal[VoiceTurnDetectionType.SEMANTIC_VAD] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Required. Semantic voice activity detection.""" + auto_truncate: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + type: Literal[VoiceTurnDetectionType.SEMANTIC_VAD], + eagerness: Optional[Literal["low", "medium", "high", "auto"]] = None, + create_response: Optional[bool] = None, + interrupt_response: Optional[bool] = None, + auto_truncate: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventConversationCreated(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """The ``conversation.created`` server event emitted when a voice-agent connection starts. + + :ivar type: Required. Default value is "conversation.created". + :vartype type: str + :ivar conversation_id: The identifier of the created conversation. Required. + :vartype conversation_id: str + """ + + type: Literal["conversation.created"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required. Default value is \"conversation.created\".""" + conversation_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The identifier of the created conversation. Required.""" + + @overload + def __init__( + self, + *, + conversation_id: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["conversation.created"] = "conversation.created" + + +class VoiceAgentServerEventConversationItemAdded( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``conversation.item.added`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``conversation.item.added``. Required. + CONVERSATION_ITEM_ADDED. + :vartype type: str or ~azure.ai.voiceagents.models.CONVERSATION_ITEM_ADDED + :ivar previous_item_id: + :vartype previous_item_id: str + :ivar item: The item added to the conversation. Required. Is one of the following types: + "_unions.VoiceAgentResponseMessageItem", VoiceFunctionCallItem, VoiceFunctionCallOutputItem, + VoiceMcpListToolsItem, VoiceMcpCallItem, VoiceMcpApprovalRequestItem, + VoiceMcpApprovalResponseItem, VoiceAgentWorkflowActionItem, VoiceAgentWebSearchCallItem, + VoiceAgentFileSearchCallItem + :vartype item: ~azure.ai.voiceagents.models.RealtimeConversationItemMessageSystem or + ~azure.ai.voiceagents.models.RealtimeConversationItemMessageUser or + ~azure.ai.voiceagents.models.RealtimeConversationItemMessageAssistant or + ~azure.ai.voiceagents.models.VoiceFunctionCallItem or + ~azure.ai.voiceagents.models.VoiceFunctionCallOutputItem or + ~azure.ai.voiceagents.models.VoiceMcpListToolsItem or + ~azure.ai.voiceagents.models.VoiceMcpCallItem or + ~azure.ai.voiceagents.models.VoiceMcpApprovalRequestItem or + ~azure.ai.voiceagents.models.VoiceMcpApprovalResponseItem or + ~azure.ai.voiceagents.models.VoiceAgentWorkflowActionItem or + ~azure.ai.voiceagents.models.VoiceAgentWebSearchCallItem or + ~azure.ai.voiceagents.models.VoiceAgentFileSearchCallItem + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the server event. Required.""" + type: Literal[RealtimeServerEventType.CONVERSATION_ITEM_ADDED] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``conversation.item.added``. Required. CONVERSATION_ITEM_ADDED.""" + previous_item_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + item: "_unions.VoiceAgentResponseItem" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The item added to the conversation. Required. Is one of the following types: + \"_unions.VoiceAgentResponseMessageItem\", VoiceFunctionCallItem, VoiceFunctionCallOutputItem, + VoiceMcpListToolsItem, VoiceMcpCallItem, VoiceMcpApprovalRequestItem, + VoiceMcpApprovalResponseItem, VoiceAgentWorkflowActionItem, VoiceAgentWebSearchCallItem, + VoiceAgentFileSearchCallItem""" + + @overload + def __init__( + self, + *, + event_id: str, + type: Literal[RealtimeServerEventType.CONVERSATION_ITEM_ADDED], + item: "_unions.VoiceAgentResponseItem", + previous_item_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventConversationItemCreated( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``conversation.item.created`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``conversation.item.created``. Required. + CONVERSATION_ITEM_CREATED. + :vartype type: str or ~azure.ai.voiceagents.models.CONVERSATION_ITEM_CREATED + :ivar previous_item_id: + :vartype previous_item_id: str + :ivar item: The created conversation item. Required. Is one of the following types: + "_unions.VoiceAgentResponseMessageItem", VoiceFunctionCallItem, VoiceFunctionCallOutputItem, + VoiceMcpListToolsItem, VoiceMcpCallItem, VoiceMcpApprovalRequestItem, + VoiceMcpApprovalResponseItem, VoiceAgentWorkflowActionItem, VoiceAgentWebSearchCallItem, + VoiceAgentFileSearchCallItem + :vartype item: ~azure.ai.voiceagents.models.RealtimeConversationItemMessageSystem or + ~azure.ai.voiceagents.models.RealtimeConversationItemMessageUser or + ~azure.ai.voiceagents.models.RealtimeConversationItemMessageAssistant or + ~azure.ai.voiceagents.models.VoiceFunctionCallItem or + ~azure.ai.voiceagents.models.VoiceFunctionCallOutputItem or + ~azure.ai.voiceagents.models.VoiceMcpListToolsItem or + ~azure.ai.voiceagents.models.VoiceMcpCallItem or + ~azure.ai.voiceagents.models.VoiceMcpApprovalRequestItem or + ~azure.ai.voiceagents.models.VoiceMcpApprovalResponseItem or + ~azure.ai.voiceagents.models.VoiceAgentWorkflowActionItem or + ~azure.ai.voiceagents.models.VoiceAgentWebSearchCallItem or + ~azure.ai.voiceagents.models.VoiceAgentFileSearchCallItem + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the server event. Required.""" + type: Literal[RealtimeServerEventType.CONVERSATION_ITEM_CREATED] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``conversation.item.created``. Required. CONVERSATION_ITEM_CREATED.""" + previous_item_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + item: "_unions.VoiceAgentResponseItem" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The created conversation item. Required. Is one of the following types: + \"_unions.VoiceAgentResponseMessageItem\", VoiceFunctionCallItem, VoiceFunctionCallOutputItem, + VoiceMcpListToolsItem, VoiceMcpCallItem, VoiceMcpApprovalRequestItem, + VoiceMcpApprovalResponseItem, VoiceAgentWorkflowActionItem, VoiceAgentWebSearchCallItem, + VoiceAgentFileSearchCallItem""" + + @overload + def __init__( + self, + *, + event_id: str, + type: Literal[RealtimeServerEventType.CONVERSATION_ITEM_CREATED], + item: "_unions.VoiceAgentResponseItem", + previous_item_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventConversationItemDeleted( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``conversation.item.deleted`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``conversation.item.deleted``. Required. + CONVERSATION_ITEM_DELETED. + :vartype type: str or ~azure.ai.voiceagents.models.CONVERSATION_ITEM_DELETED + :ivar item_id: The ID of the item that was deleted. Required. + :vartype item_id: str + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the server event. Required.""" + type: Literal[RealtimeServerEventType.CONVERSATION_ITEM_DELETED] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``conversation.item.deleted``. Required. CONVERSATION_ITEM_DELETED.""" + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the item that was deleted. Required.""" + + @overload + def __init__( + self, + *, + event_id: str, + type: Literal[RealtimeServerEventType.CONVERSATION_ITEM_DELETED], + item_id: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventConversationItemDone( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``conversation.item.done`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``conversation.item.done``. Required. + CONVERSATION_ITEM_DONE. + :vartype type: str or ~azure.ai.voiceagents.models.CONVERSATION_ITEM_DONE + :ivar previous_item_id: + :vartype previous_item_id: str + :ivar item: The completed conversation item. Required. Is one of the following types: + "_unions.VoiceAgentResponseMessageItem", VoiceFunctionCallItem, VoiceFunctionCallOutputItem, + VoiceMcpListToolsItem, VoiceMcpCallItem, VoiceMcpApprovalRequestItem, + VoiceMcpApprovalResponseItem, VoiceAgentWorkflowActionItem, VoiceAgentWebSearchCallItem, + VoiceAgentFileSearchCallItem + :vartype item: ~azure.ai.voiceagents.models.RealtimeConversationItemMessageSystem or + ~azure.ai.voiceagents.models.RealtimeConversationItemMessageUser or + ~azure.ai.voiceagents.models.RealtimeConversationItemMessageAssistant or + ~azure.ai.voiceagents.models.VoiceFunctionCallItem or + ~azure.ai.voiceagents.models.VoiceFunctionCallOutputItem or + ~azure.ai.voiceagents.models.VoiceMcpListToolsItem or + ~azure.ai.voiceagents.models.VoiceMcpCallItem or + ~azure.ai.voiceagents.models.VoiceMcpApprovalRequestItem or + ~azure.ai.voiceagents.models.VoiceMcpApprovalResponseItem or + ~azure.ai.voiceagents.models.VoiceAgentWorkflowActionItem or + ~azure.ai.voiceagents.models.VoiceAgentWebSearchCallItem or + ~azure.ai.voiceagents.models.VoiceAgentFileSearchCallItem + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the server event. Required.""" + type: Literal[RealtimeServerEventType.CONVERSATION_ITEM_DONE] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``conversation.item.done``. Required. CONVERSATION_ITEM_DONE.""" + previous_item_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + item: "_unions.VoiceAgentResponseItem" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The completed conversation item. Required. Is one of the following types: + \"_unions.VoiceAgentResponseMessageItem\", VoiceFunctionCallItem, VoiceFunctionCallOutputItem, + VoiceMcpListToolsItem, VoiceMcpCallItem, VoiceMcpApprovalRequestItem, + VoiceMcpApprovalResponseItem, VoiceAgentWorkflowActionItem, VoiceAgentWebSearchCallItem, + VoiceAgentFileSearchCallItem""" + + @overload + def __init__( + self, + *, + event_id: str, + type: Literal[RealtimeServerEventType.CONVERSATION_ITEM_DONE], + item: "_unions.VoiceAgentResponseItem", + previous_item_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventConversationItemInputAudioTranscriptionCompleted( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``conversation.item.input_audio_transcription.completed`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``conversation.item.input_audio_transcription.completed``. + Required. CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_COMPLETED. + :vartype type: str or + ~azure.ai.voiceagents.models.CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_COMPLETED + :ivar item_id: The ID of the item containing the audio that is being transcribed. Required. + :vartype item_id: str + :ivar content_index: The index of the content part containing the audio. Required. + :vartype content_index: int + :ivar transcript: The transcribed text. Required. + :vartype transcript: str + :ivar logprobs: + :vartype logprobs: list[~azure.ai.voiceagents.models.LogProbProperties] + :ivar usage: Usage statistics for the transcription, this is billed according to the ASR + model's pricing rather than the realtime model's pricing. Required. Is either a + TranscriptTextUsageTokens type or a TranscriptTextUsageDuration type. + :vartype usage: ~azure.ai.voiceagents.models.TranscriptTextUsageTokens or + ~azure.ai.voiceagents.models.TranscriptTextUsageDuration + :ivar phrases: Phrase-level transcription timing and confidence details. + :vartype phrases: list[~azure.ai.voiceagents.models.VoiceAgentTranscriptionPhrase] + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the server event. Required.""" + type: Literal[RealtimeServerEventType.CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_COMPLETED] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``conversation.item.input_audio_transcription.completed``. Required. + CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_COMPLETED.""" + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the item containing the audio that is being transcribed. Required.""" + content_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The index of the content part containing the audio. Required.""" + transcript: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The transcribed text. Required.""" + logprobs: Optional[list["_models.LogProbProperties"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + usage: Union["_models.TranscriptTextUsageTokens", "_models.TranscriptTextUsageDuration"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Usage statistics for the transcription, this is billed according to the ASR model's pricing + rather than the realtime model's pricing. Required. Is either a TranscriptTextUsageTokens type + or a TranscriptTextUsageDuration type.""" + phrases: Optional[list["_models.VoiceAgentTranscriptionPhrase"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Phrase-level transcription timing and confidence details.""" + + @overload + def __init__( + self, + *, + event_id: str, + type: Literal[RealtimeServerEventType.CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_COMPLETED], + item_id: str, + content_index: int, + transcript: str, + usage: Union["_models.TranscriptTextUsageTokens", "_models.TranscriptTextUsageDuration"], + logprobs: Optional[list["_models.LogProbProperties"]] = None, + phrases: Optional[list["_models.VoiceAgentTranscriptionPhrase"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventConversationItemInputAudioTranscriptionDelta( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``conversation.item.input_audio_transcription.delta`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``conversation.item.input_audio_transcription.delta``. + Required. CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_DELTA. + :vartype type: str or + ~azure.ai.voiceagents.models.CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_DELTA + :ivar item_id: The ID of the item containing the audio that is being transcribed. Required. + :vartype item_id: str + :ivar content_index: The index of the content part in the item's content array. + :vartype content_index: int + :ivar delta: The text delta. + :vartype delta: str + :ivar logprobs: + :vartype logprobs: list[~azure.ai.voiceagents.models.LogProbProperties] + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the server event. Required.""" + type: Literal[RealtimeServerEventType.CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_DELTA] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``conversation.item.input_audio_transcription.delta``. Required. + CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_DELTA.""" + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the item containing the audio that is being transcribed. Required.""" + content_index: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The index of the content part in the item's content array.""" + delta: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The text delta.""" + logprobs: Optional[list["_models.LogProbProperties"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + event_id: str, + type: Literal[RealtimeServerEventType.CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_DELTA], + item_id: str, + content_index: Optional[int] = None, + delta: Optional[str] = None, + logprobs: Optional[list["_models.LogProbProperties"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventConversationItemInputAudioTranscriptionFailed( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``conversation.item.input_audio_transcription.failed`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``conversation.item.input_audio_transcription.failed``. + Required. CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_FAILED. + :vartype type: str or + ~azure.ai.voiceagents.models.CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_FAILED + :ivar item_id: The ID of the user message item. Required. + :vartype item_id: str + :ivar content_index: The index of the content part containing the audio. Required. + :vartype content_index: int + :ivar error: Details of the transcription error. Required. + :vartype error: + ~azure.ai.voiceagents.models.RealtimeServerEventConversationItemInputAudioTranscriptionFailedError + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the server event. Required.""" + type: Literal[RealtimeServerEventType.CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_FAILED] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``conversation.item.input_audio_transcription.failed``. Required. + CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_FAILED.""" + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the user message item. Required.""" + content_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The index of the content part containing the audio. Required.""" + error: "_models.RealtimeServerEventConversationItemInputAudioTranscriptionFailedError" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Details of the transcription error. Required.""" + + @overload + def __init__( + self, + *, + event_id: str, + type: Literal[RealtimeServerEventType.CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_FAILED], + item_id: str, + content_index: int, + error: "_models.RealtimeServerEventConversationItemInputAudioTranscriptionFailedError", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventConversationItemInputAudioTranscriptionSegment( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``conversation.item.input_audio_transcription.segment`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``conversation.item.input_audio_transcription.segment``. + Required. CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_SEGMENT. + :vartype type: str or + ~azure.ai.voiceagents.models.CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_SEGMENT + :ivar item_id: The ID of the item containing the input audio content. Required. + :vartype item_id: str + :ivar content_index: The index of the input audio content part within the item. Required. + :vartype content_index: int + :ivar text: The text for this segment. Required. + :vartype text: str + :ivar id: The segment identifier. Required. + :vartype id: str + :ivar speaker: The detected speaker label for this segment. Required. + :vartype speaker: str + :ivar start: Start time of the segment in seconds. Required. + :vartype start: float + :ivar end: End time of the segment in seconds. Required. + :vartype end: float + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the server event. Required.""" + type: Literal[RealtimeServerEventType.CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_SEGMENT] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``conversation.item.input_audio_transcription.segment``. Required. + CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_SEGMENT.""" + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the item containing the input audio content. Required.""" + content_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The index of the input audio content part within the item. Required.""" + text: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The text for this segment. Required.""" + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The segment identifier. Required.""" + speaker: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The detected speaker label for this segment. Required.""" + start: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Start time of the segment in seconds. Required.""" + end: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """End time of the segment in seconds. Required.""" + + @overload + def __init__( + self, + *, + event_id: str, + type: Literal[RealtimeServerEventType.CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_SEGMENT], + item_id: str, + content_index: int, + text: str, + id: str, # pylint: disable=redefined-builtin + speaker: str, + start: float, + end: float, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventConversationItemRetrieved( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``conversation.item.retrieved`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``conversation.item.retrieved``. Required. + CONVERSATION_ITEM_RETRIEVED. + :vartype type: str or ~azure.ai.voiceagents.models.CONVERSATION_ITEM_RETRIEVED + :ivar item: The retrieved conversation item. Required. Is one of the following types: + "_unions.VoiceAgentResponseMessageItem", VoiceFunctionCallItem, VoiceFunctionCallOutputItem, + VoiceMcpListToolsItem, VoiceMcpCallItem, VoiceMcpApprovalRequestItem, + VoiceMcpApprovalResponseItem, VoiceAgentWorkflowActionItem, VoiceAgentWebSearchCallItem, + VoiceAgentFileSearchCallItem + :vartype item: ~azure.ai.voiceagents.models.RealtimeConversationItemMessageSystem or + ~azure.ai.voiceagents.models.RealtimeConversationItemMessageUser or + ~azure.ai.voiceagents.models.RealtimeConversationItemMessageAssistant or + ~azure.ai.voiceagents.models.VoiceFunctionCallItem or + ~azure.ai.voiceagents.models.VoiceFunctionCallOutputItem or + ~azure.ai.voiceagents.models.VoiceMcpListToolsItem or + ~azure.ai.voiceagents.models.VoiceMcpCallItem or + ~azure.ai.voiceagents.models.VoiceMcpApprovalRequestItem or + ~azure.ai.voiceagents.models.VoiceMcpApprovalResponseItem or + ~azure.ai.voiceagents.models.VoiceAgentWorkflowActionItem or + ~azure.ai.voiceagents.models.VoiceAgentWebSearchCallItem or + ~azure.ai.voiceagents.models.VoiceAgentFileSearchCallItem + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the server event. Required.""" + type: Literal[RealtimeServerEventType.CONVERSATION_ITEM_RETRIEVED] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``conversation.item.retrieved``. Required. CONVERSATION_ITEM_RETRIEVED.""" + item: "_unions.VoiceAgentResponseItem" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The retrieved conversation item. Required. Is one of the following types: + \"_unions.VoiceAgentResponseMessageItem\", VoiceFunctionCallItem, VoiceFunctionCallOutputItem, + VoiceMcpListToolsItem, VoiceMcpCallItem, VoiceMcpApprovalRequestItem, + VoiceMcpApprovalResponseItem, VoiceAgentWorkflowActionItem, VoiceAgentWebSearchCallItem, + VoiceAgentFileSearchCallItem""" + + @overload + def __init__( + self, + *, + event_id: str, + type: Literal[RealtimeServerEventType.CONVERSATION_ITEM_RETRIEVED], + item: "_unions.VoiceAgentResponseItem", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventConversationItemTruncated( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``conversation.item.truncated`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``conversation.item.truncated``. Required. + CONVERSATION_ITEM_TRUNCATED. + :vartype type: str or ~azure.ai.voiceagents.models.CONVERSATION_ITEM_TRUNCATED + :ivar item_id: The ID of the assistant message item that was truncated. Required. + :vartype item_id: str + :ivar content_index: The index of the content part that was truncated. Required. + :vartype content_index: int + :ivar audio_end_ms: The duration up to which the audio was truncated, in milliseconds. + Required. + :vartype audio_end_ms: int + :ivar item: The assistant message after truncation, when the service returns the updated item. + :vartype item: ~azure.ai.voiceagents.models.RealtimeConversationItemMessageAssistant + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the server event. Required.""" + type: Literal[RealtimeServerEventType.CONVERSATION_ITEM_TRUNCATED] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``conversation.item.truncated``. Required. CONVERSATION_ITEM_TRUNCATED.""" + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the assistant message item that was truncated. Required.""" + content_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The index of the content part that was truncated. Required.""" + audio_end_ms: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The duration up to which the audio was truncated, in milliseconds. Required.""" + item: Optional["_models.RealtimeConversationItemMessageAssistant"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The assistant message after truncation, when the service returns the updated item.""" + + @overload + def __init__( + self, + *, + event_id: str, + type: Literal[RealtimeServerEventType.CONVERSATION_ITEM_TRUNCATED], + item_id: str, + content_index: int, + audio_end_ms: int, + item: Optional["_models.RealtimeConversationItemMessageAssistant"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventError(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """The ``error`` server event. + + :ivar event_id: The unique identifier of the event. Required. + :vartype event_id: str + :ivar type: Required. Default value is "error". + :vartype type: str + :ivar error: Details of the error. Required. + :vartype error: ~azure.ai.voiceagents.models.VoiceAgentServerEventErrorDetails + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique identifier of the event. Required.""" + type: Literal["error"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required. Default value is \"error\".""" + error: "_models.VoiceAgentServerEventErrorDetails" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Details of the error. Required.""" + + @overload + def __init__( + self, + *, + event_id: str, + error: "_models.VoiceAgentServerEventErrorDetails", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["error"] = "error" + + +class VoiceAgentServerEventErrorDetails(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Details of a voice-agent WebSocket error. + + :ivar type: Required. + :vartype type: str + :ivar code: + :vartype code: str + :ivar message: Required. + :vartype message: str + :ivar param: + :vartype param: str + :ivar event_id: + :vartype event_id: str + :ivar tool_label: The configured label of a tool that could not be resolved. + :vartype tool_label: str + :ivar tool_type: The configured type of a tool that could not be resolved. + :vartype tool_type: str + """ + + type: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + code: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + message: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + param: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + event_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + tool_label: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The configured label of a tool that could not be resolved.""" + tool_type: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The configured type of a tool that could not be resolved.""" + + @overload + def __init__( + self, + *, + type: str, + message: str, + code: Optional[str] = None, + param: Optional[str] = None, + event_id: Optional[str] = None, + tool_label: Optional[str] = None, + tool_type: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventFileSearchCallCompleted( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``response.file_search_call.completed`` server event. + + :ivar type: Required. Default value is "response.file_search_call.completed". + :vartype type: str + :ivar event_id: + :vartype event_id: str + :ivar response_id: + :vartype response_id: str + :ivar item_id: Required. + :vartype item_id: str + :ivar output_index: Required. + :vartype output_index: int + :ivar sequence_number: Required. + :vartype sequence_number: int + """ + + type: Literal["response.file_search_call.completed"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Required. Default value is \"response.file_search_call.completed\".""" + event_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + response_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + output_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + sequence_number: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + + @overload + def __init__( + self, + *, + item_id: str, + output_index: int, + sequence_number: int, + event_id: Optional[str] = None, + response_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["response.file_search_call.completed"] = "response.file_search_call.completed" + + +class VoiceAgentServerEventFileSearchCallInProgress( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``response.file_search_call.in_progress`` server event. + + :ivar type: Required. Default value is "response.file_search_call.in_progress". + :vartype type: str + :ivar event_id: + :vartype event_id: str + :ivar response_id: + :vartype response_id: str + :ivar item_id: Required. + :vartype item_id: str + :ivar output_index: Required. + :vartype output_index: int + :ivar sequence_number: Required. + :vartype sequence_number: int + """ + + type: Literal["response.file_search_call.in_progress"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Required. Default value is \"response.file_search_call.in_progress\".""" + event_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + response_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + output_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + sequence_number: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + + @overload + def __init__( + self, + *, + item_id: str, + output_index: int, + sequence_number: int, + event_id: Optional[str] = None, + response_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["response.file_search_call.in_progress"] = "response.file_search_call.in_progress" + + +class VoiceAgentServerEventFileSearchCallSearching( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``response.file_search_call.searching`` server event. + + :ivar type: Required. Default value is "response.file_search_call.searching". + :vartype type: str + :ivar event_id: + :vartype event_id: str + :ivar response_id: + :vartype response_id: str + :ivar item_id: Required. + :vartype item_id: str + :ivar output_index: Required. + :vartype output_index: int + :ivar sequence_number: Required. + :vartype sequence_number: int + """ + + type: Literal["response.file_search_call.searching"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Required. Default value is \"response.file_search_call.searching\".""" + event_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + response_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + output_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + sequence_number: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + + @overload + def __init__( + self, + *, + item_id: str, + output_index: int, + sequence_number: int, + event_id: Optional[str] = None, + response_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["response.file_search_call.searching"] = "response.file_search_call.searching" + + +class VoiceAgentServerEventInputAudioBufferCleared( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``input_audio_buffer.cleared`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``input_audio_buffer.cleared``. Required. + INPUT_AUDIO_BUFFER_CLEARED. + :vartype type: str or ~azure.ai.voiceagents.models.INPUT_AUDIO_BUFFER_CLEARED + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the server event. Required.""" + type: Literal[RealtimeServerEventType.INPUT_AUDIO_BUFFER_CLEARED] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``input_audio_buffer.cleared``. Required. INPUT_AUDIO_BUFFER_CLEARED.""" + + @overload + def __init__( + self, + *, + event_id: str, + type: Literal[RealtimeServerEventType.INPUT_AUDIO_BUFFER_CLEARED], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventInputAudioBufferCommitted( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``input_audio_buffer.committed`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``input_audio_buffer.committed``. Required. + INPUT_AUDIO_BUFFER_COMMITTED. + :vartype type: str or ~azure.ai.voiceagents.models.INPUT_AUDIO_BUFFER_COMMITTED + :ivar previous_item_id: + :vartype previous_item_id: str + :ivar item_id: The ID of the user message item that will be created. Required. + :vartype item_id: str + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the server event. Required.""" + type: Literal[RealtimeServerEventType.INPUT_AUDIO_BUFFER_COMMITTED] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``input_audio_buffer.committed``. Required. + INPUT_AUDIO_BUFFER_COMMITTED.""" + previous_item_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the user message item that will be created. Required.""" + + @overload + def __init__( + self, + *, + event_id: str, + type: Literal[RealtimeServerEventType.INPUT_AUDIO_BUFFER_COMMITTED], + item_id: str, + previous_item_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventInputAudioBufferSpeechStarted( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``input_audio_buffer.speech_started`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``input_audio_buffer.speech_started``. Required. + INPUT_AUDIO_BUFFER_SPEECH_STARTED. + :vartype type: str or ~azure.ai.voiceagents.models.INPUT_AUDIO_BUFFER_SPEECH_STARTED + :ivar audio_start_ms: Milliseconds from the start of all audio written to the buffer during the + session when speech was first detected. This will correspond to the beginning of audio sent to + the model, and thus includes the ``prefix_padding_ms`` configured in the Session. Required. + :vartype audio_start_ms: int + :ivar item_id: The ID of the user message item that will be created when speech stops. + Required. + :vartype item_id: str + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the server event. Required.""" + type: Literal[RealtimeServerEventType.INPUT_AUDIO_BUFFER_SPEECH_STARTED] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``input_audio_buffer.speech_started``. Required. + INPUT_AUDIO_BUFFER_SPEECH_STARTED.""" + audio_start_ms: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Milliseconds from the start of all audio written to the buffer during the session when speech + was first detected. This will correspond to the beginning of audio sent to the model, and thus + includes the ``prefix_padding_ms`` configured in the Session. Required.""" + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the user message item that will be created when speech stops. Required.""" + + @overload + def __init__( + self, + *, + event_id: str, + type: Literal[RealtimeServerEventType.INPUT_AUDIO_BUFFER_SPEECH_STARTED], + audio_start_ms: int, + item_id: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventInputAudioBufferSpeechStopped( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``input_audio_buffer.speech_stopped`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``input_audio_buffer.speech_stopped``. Required. + INPUT_AUDIO_BUFFER_SPEECH_STOPPED. + :vartype type: str or ~azure.ai.voiceagents.models.INPUT_AUDIO_BUFFER_SPEECH_STOPPED + :ivar audio_end_ms: Milliseconds since the session started when speech stopped. This will + correspond to the end of audio sent to the model, and thus includes the + ``min_silence_duration_ms`` configured in the Session. Required. + :vartype audio_end_ms: int + :ivar item_id: The ID of the user message item that will be created. Required. + :vartype item_id: str + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the server event. Required.""" + type: Literal[RealtimeServerEventType.INPUT_AUDIO_BUFFER_SPEECH_STOPPED] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``input_audio_buffer.speech_stopped``. Required. + INPUT_AUDIO_BUFFER_SPEECH_STOPPED.""" + audio_end_ms: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Milliseconds since the session started when speech stopped. This will correspond to the end of + audio sent to the model, and thus includes the ``min_silence_duration_ms`` configured in the + Session. Required.""" + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the user message item that will be created. Required.""" + + @overload + def __init__( + self, + *, + event_id: str, + type: Literal[RealtimeServerEventType.INPUT_AUDIO_BUFFER_SPEECH_STOPPED], + audio_end_ms: int, + item_id: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventInputAudioBufferTimeoutTriggered( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``input_audio_buffer.timeout_triggered`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``input_audio_buffer.timeout_triggered``. Required. + INPUT_AUDIO_BUFFER_TIMEOUT_TRIGGERED. + :vartype type: str or ~azure.ai.voiceagents.models.INPUT_AUDIO_BUFFER_TIMEOUT_TRIGGERED + :ivar audio_start_ms: Millisecond offset of audio written to the input audio buffer that was + after the playback time of the last model response. Required. + :vartype audio_start_ms: int + :ivar audio_end_ms: Millisecond offset of audio written to the input audio buffer at the time + the timeout was triggered. Required. + :vartype audio_end_ms: int + :ivar item_id: The ID of the item associated with this segment. Required. + :vartype item_id: str + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the server event. Required.""" + type: Literal[RealtimeServerEventType.INPUT_AUDIO_BUFFER_TIMEOUT_TRIGGERED] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``input_audio_buffer.timeout_triggered``. Required. + INPUT_AUDIO_BUFFER_TIMEOUT_TRIGGERED.""" + audio_start_ms: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Millisecond offset of audio written to the input audio buffer that was after the playback time + of the last model response. Required.""" + audio_end_ms: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Millisecond offset of audio written to the input audio buffer at the time the timeout was + triggered. Required.""" + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the item associated with this segment. Required.""" + + @overload + def __init__( + self, + *, + event_id: str, + type: Literal[RealtimeServerEventType.INPUT_AUDIO_BUFFER_TIMEOUT_TRIGGERED], + audio_start_ms: int, + audio_end_ms: int, + item_id: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventMcpListToolsCompleted( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``mcp_list_tools.completed`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``mcp_list_tools.completed``. Required. + MCP_LIST_TOOLS_COMPLETED. + :vartype type: str or ~azure.ai.voiceagents.models.MCP_LIST_TOOLS_COMPLETED + :ivar item_id: The ID of the MCP list tools item. Required. + :vartype item_id: str + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the server event. Required.""" + type: Literal[RealtimeServerEventType.MCP_LIST_TOOLS_COMPLETED] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``mcp_list_tools.completed``. Required. MCP_LIST_TOOLS_COMPLETED.""" + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the MCP list tools item. Required.""" + + @overload + def __init__( + self, + *, + event_id: str, + type: Literal[RealtimeServerEventType.MCP_LIST_TOOLS_COMPLETED], + item_id: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventMcpListToolsFailed(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """The ``mcp_list_tools.failed`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``mcp_list_tools.failed``. Required. MCP_LIST_TOOLS_FAILED. + :vartype type: str or ~azure.ai.voiceagents.models.MCP_LIST_TOOLS_FAILED + :ivar item_id: The ID of the MCP list tools item. Required. + :vartype item_id: str + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the server event. Required.""" + type: Literal[RealtimeServerEventType.MCP_LIST_TOOLS_FAILED] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``mcp_list_tools.failed``. Required. MCP_LIST_TOOLS_FAILED.""" + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the MCP list tools item. Required.""" + + @overload + def __init__( + self, + *, + event_id: str, + type: Literal[RealtimeServerEventType.MCP_LIST_TOOLS_FAILED], + item_id: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventMcpListToolsInProgress( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``mcp_list_tools.in_progress`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``mcp_list_tools.in_progress``. Required. + MCP_LIST_TOOLS_IN_PROGRESS. + :vartype type: str or ~azure.ai.voiceagents.models.MCP_LIST_TOOLS_IN_PROGRESS + :ivar item_id: The ID of the MCP list tools item. Required. + :vartype item_id: str + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the server event. Required.""" + type: Literal[RealtimeServerEventType.MCP_LIST_TOOLS_IN_PROGRESS] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``mcp_list_tools.in_progress``. Required. MCP_LIST_TOOLS_IN_PROGRESS.""" + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the MCP list tools item. Required.""" + + @overload + def __init__( + self, + *, + event_id: str, + type: Literal[RealtimeServerEventType.MCP_LIST_TOOLS_IN_PROGRESS], + item_id: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventOutputAudioBufferCleared( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``output_audio_buffer.cleared`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``output_audio_buffer.cleared``. Required. + OUTPUT_AUDIO_BUFFER_CLEARED. + :vartype type: str or ~azure.ai.voiceagents.models.OUTPUT_AUDIO_BUFFER_CLEARED + :ivar response_id: The unique ID of the response that produced the audio. Required. + :vartype response_id: str + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the server event. Required.""" + type: Literal[RealtimeServerEventType.OUTPUT_AUDIO_BUFFER_CLEARED] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``output_audio_buffer.cleared``. Required. OUTPUT_AUDIO_BUFFER_CLEARED.""" + response_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the response that produced the audio. Required.""" + + @overload + def __init__( + self, + *, + event_id: str, + type: Literal[RealtimeServerEventType.OUTPUT_AUDIO_BUFFER_CLEARED], + response_id: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventRateLimitsUpdated(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """The ``rate_limits.updated`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``rate_limits.updated``. Required. RATE_LIMITS_UPDATED. + :vartype type: str or ~azure.ai.voiceagents.models.RATE_LIMITS_UPDATED + :ivar rate_limits: List of rate limit information. Required. + :vartype rate_limits: + list[~azure.ai.voiceagents.models.RealtimeServerEventRateLimitsUpdatedRateLimits] + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the server event. Required.""" + type: Literal[RealtimeServerEventType.RATE_LIMITS_UPDATED] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``rate_limits.updated``. Required. RATE_LIMITS_UPDATED.""" + rate_limits: list["_models.RealtimeServerEventRateLimitsUpdatedRateLimits"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """List of rate limit information. Required.""" + + @overload + def __init__( + self, + *, + event_id: str, + type: Literal[RealtimeServerEventType.RATE_LIMITS_UPDATED], + rate_limits: list["_models.RealtimeServerEventRateLimitsUpdatedRateLimits"], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventResponseAnimationBlendshapesDelta( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``response.animation_blendshapes.delta`` server event. + + :ivar type: Required. Default value is "response.animation_blendshapes.delta". + :vartype type: str + :ivar event_id: Required. + :vartype event_id: str + :ivar response_id: Required. + :vartype response_id: str + :ivar item_id: Required. + :vartype item_id: str + :ivar output_index: Required. + :vartype output_index: int + :ivar content_index: Required. + :vartype content_index: int + :ivar frames: Animation frames as numeric blendshape weights or a compact encoded string. + Required. Is either a [[float]] type or a str type. + :vartype frames: list[list[float]] or str + :ivar frame_index: The index of the first frame in this delta. Required. + :vartype frame_index: int + """ + + type: Literal["response.animation_blendshapes.delta"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Required. Default value is \"response.animation_blendshapes.delta\".""" + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + response_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + output_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + content_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + frames: Union[list[list[float]], str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Animation frames as numeric blendshape weights or a compact encoded string. Required. Is either + a [[float]] type or a str type.""" + frame_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The index of the first frame in this delta. Required.""" + + @overload + def __init__( + self, + *, + event_id: str, + response_id: str, + item_id: str, + output_index: int, + content_index: int, + frames: Union[list[list[float]], str], + frame_index: int, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["response.animation_blendshapes.delta"] = "response.animation_blendshapes.delta" + + +class VoiceAgentServerEventResponseAnimationBlendshapesDone( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``response.animation_blendshapes.done`` server event. + + :ivar type: Required. Default value is "response.animation_blendshapes.done". + :vartype type: str + :ivar event_id: Required. + :vartype event_id: str + :ivar response_id: Required. + :vartype response_id: str + :ivar item_id: Required. + :vartype item_id: str + :ivar output_index: Required. + :vartype output_index: int + """ + + type: Literal["response.animation_blendshapes.done"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Required. Default value is \"response.animation_blendshapes.done\".""" + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + response_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + output_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + + @overload + def __init__( + self, + *, + event_id: str, + response_id: str, + item_id: str, + output_index: int, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["response.animation_blendshapes.done"] = "response.animation_blendshapes.done" + + +class VoiceAgentServerEventResponseAnimationVisemeDelta( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``response.animation_viseme.delta`` server event. + + :ivar type: Required. Default value is "response.animation_viseme.delta". + :vartype type: str + :ivar event_id: Required. + :vartype event_id: str + :ivar response_id: Required. + :vartype response_id: str + :ivar item_id: Required. + :vartype item_id: str + :ivar output_index: Required. + :vartype output_index: int + :ivar content_index: Required. + :vartype content_index: int + :ivar audio_offset_ms: Required. + :vartype audio_offset_ms: int + :ivar viseme_id: Required. + :vartype viseme_id: int + """ + + type: Literal["response.animation_viseme.delta"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Required. Default value is \"response.animation_viseme.delta\".""" + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + response_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + output_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + content_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + audio_offset_ms: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + viseme_id: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + + @overload + def __init__( + self, + *, + event_id: str, + response_id: str, + item_id: str, + output_index: int, + content_index: int, + audio_offset_ms: int, + viseme_id: int, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["response.animation_viseme.delta"] = "response.animation_viseme.delta" + + +class VoiceAgentServerEventResponseAnimationVisemeDone( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``response.animation_viseme.done`` server event. + + :ivar type: Required. Default value is "response.animation_viseme.done". + :vartype type: str + :ivar event_id: Required. + :vartype event_id: str + :ivar response_id: Required. + :vartype response_id: str + :ivar item_id: Required. + :vartype item_id: str + :ivar output_index: Required. + :vartype output_index: int + :ivar content_index: Required. + :vartype content_index: int + """ + + type: Literal["response.animation_viseme.done"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Required. Default value is \"response.animation_viseme.done\".""" + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + response_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + output_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + content_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + + @overload + def __init__( + self, + *, + event_id: str, + response_id: str, + item_id: str, + output_index: int, + content_index: int, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["response.animation_viseme.done"] = "response.animation_viseme.done" + + +class VoiceAgentServerEventResponseAudioDelta(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """The ``response.output_audio.delta`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``response.output_audio.delta``. Required. + RESPONSE_OUTPUT_AUDIO_DELTA. + :vartype type: str or ~azure.ai.voiceagents.models.RESPONSE_OUTPUT_AUDIO_DELTA + :ivar response_id: The ID of the response. Required. + :vartype response_id: str + :ivar item_id: The ID of the item. Required. + :vartype item_id: str + :ivar output_index: The index of the output item in the response. Required. + :vartype output_index: int + :ivar content_index: The index of the content part in the item's content array. Required. + :vartype content_index: int + :ivar delta: Base64-encoded audio data delta. Required. + :vartype delta: bytes + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the server event. Required.""" + type: Literal[RealtimeServerEventType.RESPONSE_OUTPUT_AUDIO_DELTA] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``response.output_audio.delta``. Required. RESPONSE_OUTPUT_AUDIO_DELTA.""" + response_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the response. Required.""" + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the item. Required.""" + output_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The index of the output item in the response. Required.""" + content_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The index of the content part in the item's content array. Required.""" + delta: bytes = rest_field(visibility=["read", "create", "update", "delete", "query"], format="base64") + """Base64-encoded audio data delta. Required.""" + + @overload + def __init__( + self, + *, + event_id: str, + type: Literal[RealtimeServerEventType.RESPONSE_OUTPUT_AUDIO_DELTA], + response_id: str, + item_id: str, + output_index: int, + content_index: int, + delta: bytes, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventResponseAudioDone(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """The ``response.output_audio.done`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``response.output_audio.done``. Required. + RESPONSE_OUTPUT_AUDIO_DONE. + :vartype type: str or ~azure.ai.voiceagents.models.RESPONSE_OUTPUT_AUDIO_DONE + :ivar response_id: The ID of the response. Required. + :vartype response_id: str + :ivar item_id: The ID of the item. Required. + :vartype item_id: str + :ivar output_index: The index of the output item in the response. Required. + :vartype output_index: int + :ivar content_index: The index of the content part in the item's content array. Required. + :vartype content_index: int + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the server event. Required.""" + type: Literal[RealtimeServerEventType.RESPONSE_OUTPUT_AUDIO_DONE] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``response.output_audio.done``. Required. RESPONSE_OUTPUT_AUDIO_DONE.""" + response_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the response. Required.""" + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the item. Required.""" + output_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The index of the output item in the response. Required.""" + content_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The index of the content part in the item's content array. Required.""" + + @overload + def __init__( + self, + *, + event_id: str, + type: Literal[RealtimeServerEventType.RESPONSE_OUTPUT_AUDIO_DONE], + response_id: str, + item_id: str, + output_index: int, + content_index: int, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventResponseAudioTimestampDelta( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``response.audio_timestamp.delta`` server event. + + :ivar type: Required. Default value is "response.audio_timestamp.delta". + :vartype type: str + :ivar event_id: Required. + :vartype event_id: str + :ivar response_id: Required. + :vartype response_id: str + :ivar item_id: Required. + :vartype item_id: str + :ivar output_index: Required. + :vartype output_index: int + :ivar content_index: Required. + :vartype content_index: int + :ivar audio_offset_ms: Required. + :vartype audio_offset_ms: int + :ivar audio_duration_ms: Required. + :vartype audio_duration_ms: int + :ivar text: Required. + :vartype text: str + :ivar timestamp_type: Required. Default value is "word". + :vartype timestamp_type: str + """ + + type: Literal["response.audio_timestamp.delta"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Required. Default value is \"response.audio_timestamp.delta\".""" + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + response_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + output_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + content_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + audio_offset_ms: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + audio_duration_ms: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + text: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + timestamp_type: Literal["word"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required. Default value is \"word\".""" + + @overload + def __init__( + self, + *, + event_id: str, + response_id: str, + item_id: str, + output_index: int, + content_index: int, + audio_offset_ms: int, + audio_duration_ms: int, + text: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["response.audio_timestamp.delta"] = "response.audio_timestamp.delta" + self.timestamp_type: Literal["word"] = "word" + + +class VoiceAgentServerEventResponseAudioTimestampDone( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``response.audio_timestamp.done`` server event. + + :ivar type: Required. Default value is "response.audio_timestamp.done". + :vartype type: str + :ivar event_id: Required. + :vartype event_id: str + :ivar response_id: Required. + :vartype response_id: str + :ivar item_id: Required. + :vartype item_id: str + :ivar output_index: Required. + :vartype output_index: int + :ivar content_index: Required. + :vartype content_index: int + """ + + type: Literal["response.audio_timestamp.done"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Required. Default value is \"response.audio_timestamp.done\".""" + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + response_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + output_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + content_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + + @overload + def __init__( + self, + *, + event_id: str, + response_id: str, + item_id: str, + output_index: int, + content_index: int, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["response.audio_timestamp.done"] = "response.audio_timestamp.done" + + +class VoiceAgentServerEventResponseAudioTranscriptDelta( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``response.output_audio_transcript.delta`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``response.output_audio_transcript.delta``. Required. + RESPONSE_OUTPUT_AUDIO_TRANSCRIPT_DELTA. + :vartype type: str or ~azure.ai.voiceagents.models.RESPONSE_OUTPUT_AUDIO_TRANSCRIPT_DELTA + :ivar response_id: The ID of the response. Required. + :vartype response_id: str + :ivar item_id: The ID of the item. Required. + :vartype item_id: str + :ivar output_index: The index of the output item in the response. Required. + :vartype output_index: int + :ivar content_index: The index of the content part in the item's content array. Required. + :vartype content_index: int + :ivar delta: The transcript delta. Required. + :vartype delta: str + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the server event. Required.""" + type: Literal[RealtimeServerEventType.RESPONSE_OUTPUT_AUDIO_TRANSCRIPT_DELTA] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``response.output_audio_transcript.delta``. Required. + RESPONSE_OUTPUT_AUDIO_TRANSCRIPT_DELTA.""" + response_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the response. Required.""" + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the item. Required.""" + output_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The index of the output item in the response. Required.""" + content_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The index of the content part in the item's content array. Required.""" + delta: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The transcript delta. Required.""" + + @overload + def __init__( + self, + *, + event_id: str, + type: Literal[RealtimeServerEventType.RESPONSE_OUTPUT_AUDIO_TRANSCRIPT_DELTA], + response_id: str, + item_id: str, + output_index: int, + content_index: int, + delta: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventResponseAudioTranscriptDone( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``response.output_audio_transcript.done`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``response.output_audio_transcript.done``. Required. + RESPONSE_OUTPUT_AUDIO_TRANSCRIPT_DONE. + :vartype type: str or ~azure.ai.voiceagents.models.RESPONSE_OUTPUT_AUDIO_TRANSCRIPT_DONE + :ivar response_id: The ID of the response. Required. + :vartype response_id: str + :ivar item_id: The ID of the item. Required. + :vartype item_id: str + :ivar output_index: The index of the output item in the response. Required. + :vartype output_index: int + :ivar content_index: The index of the content part in the item's content array. Required. + :vartype content_index: int + :ivar transcript: The final transcript of the audio. Required. + :vartype transcript: str + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the server event. Required.""" + type: Literal[RealtimeServerEventType.RESPONSE_OUTPUT_AUDIO_TRANSCRIPT_DONE] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``response.output_audio_transcript.done``. Required. + RESPONSE_OUTPUT_AUDIO_TRANSCRIPT_DONE.""" + response_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the response. Required.""" + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the item. Required.""" + output_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The index of the output item in the response. Required.""" + content_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The index of the content part in the item's content array. Required.""" + transcript: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The final transcript of the audio. Required.""" + + @overload + def __init__( + self, + *, + event_id: str, + type: Literal[RealtimeServerEventType.RESPONSE_OUTPUT_AUDIO_TRANSCRIPT_DONE], + response_id: str, + item_id: str, + output_index: int, + content_index: int, + transcript: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventResponseContentPartDone( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``response.content_part.done`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``response.content_part.done``. Required. + RESPONSE_CONTENT_PART_DONE. + :vartype type: str or ~azure.ai.voiceagents.models.RESPONSE_CONTENT_PART_DONE + :ivar response_id: The ID of the response. Required. + :vartype response_id: str + :ivar item_id: The ID of the item. Required. + :vartype item_id: str + :ivar output_index: The index of the output item in the response. Required. + :vartype output_index: int + :ivar content_index: The index of the content part in the item's content array. Required. + :vartype content_index: int + :ivar part: The content part that finished streaming. Required. Is either a + VoiceAgentResponseEventTextContentPart type or a VoiceAgentResponseEventAudioContentPart type. + :vartype part: ~azure.ai.voiceagents.models.VoiceAgentResponseEventTextContentPart or + ~azure.ai.voiceagents.models.VoiceAgentResponseEventAudioContentPart + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the server event. Required.""" + type: Literal[RealtimeServerEventType.RESPONSE_CONTENT_PART_DONE] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``response.content_part.done``. Required. RESPONSE_CONTENT_PART_DONE.""" + response_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the response. Required.""" + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the item. Required.""" + output_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The index of the output item in the response. Required.""" + content_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The index of the content part in the item's content array. Required.""" + part: "_unions.VoiceAgentResponseEventContentPart" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The content part that finished streaming. Required. Is either a + VoiceAgentResponseEventTextContentPart type or a VoiceAgentResponseEventAudioContentPart type.""" + + @overload + def __init__( + self, + *, + event_id: str, + type: Literal[RealtimeServerEventType.RESPONSE_CONTENT_PART_DONE], + response_id: str, + item_id: str, + output_index: int, + content_index: int, + part: "_unions.VoiceAgentResponseEventContentPart", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventResponseCreated(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """The ``response.created`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``response.created``. Required. RESPONSE_CREATED. + :vartype type: str or ~azure.ai.voiceagents.models.RESPONSE_CREATED + :ivar response: The created voice-agent response. Required. + :vartype response: ~azure.ai.voiceagents.models.VoiceAgentRealtimeResponse + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the server event. Required.""" + type: Literal[RealtimeServerEventType.RESPONSE_CREATED] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``response.created``. Required. RESPONSE_CREATED.""" + response: "_models.VoiceAgentRealtimeResponse" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The created voice-agent response. Required.""" + + @overload + def __init__( + self, + *, + event_id: str, + type: Literal[RealtimeServerEventType.RESPONSE_CREATED], + response: "_models.VoiceAgentRealtimeResponse", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventResponseDone(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """The ``response.done`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``response.done``. Required. RESPONSE_DONE. + :vartype type: str or ~azure.ai.voiceagents.models.RESPONSE_DONE + :ivar response: The completed voice-agent response. Required. + :vartype response: ~azure.ai.voiceagents.models.VoiceAgentRealtimeResponse + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the server event. Required.""" + type: Literal[RealtimeServerEventType.RESPONSE_DONE] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``response.done``. Required. RESPONSE_DONE.""" + response: "_models.VoiceAgentRealtimeResponse" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The completed voice-agent response. Required.""" + + @overload + def __init__( + self, + *, + event_id: str, + type: Literal[RealtimeServerEventType.RESPONSE_DONE], + response: "_models.VoiceAgentRealtimeResponse", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventResponseFunctionCallArgumentsDelta( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``response.function_call_arguments.delta`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``response.function_call_arguments.delta``. Required. + RESPONSE_FUNCTION_CALL_ARGUMENTS_DELTA. + :vartype type: str or ~azure.ai.voiceagents.models.RESPONSE_FUNCTION_CALL_ARGUMENTS_DELTA + :ivar response_id: The ID of the response. Required. + :vartype response_id: str + :ivar item_id: The ID of the function call item. Required. + :vartype item_id: str + :ivar output_index: The index of the output item in the response. Required. + :vartype output_index: int + :ivar call_id: The ID of the function call. Required. + :vartype call_id: str + :ivar delta: The arguments delta as a JSON string. Required. + :vartype delta: str + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the server event. Required.""" + type: Literal[RealtimeServerEventType.RESPONSE_FUNCTION_CALL_ARGUMENTS_DELTA] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``response.function_call_arguments.delta``. Required. + RESPONSE_FUNCTION_CALL_ARGUMENTS_DELTA.""" + response_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the response. Required.""" + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the function call item. Required.""" + output_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The index of the output item in the response. Required.""" + call_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the function call. Required.""" + delta: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The arguments delta as a JSON string. Required.""" + + @overload + def __init__( + self, + *, + event_id: str, + type: Literal[RealtimeServerEventType.RESPONSE_FUNCTION_CALL_ARGUMENTS_DELTA], + response_id: str, + item_id: str, + output_index: int, + call_id: str, + delta: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventResponseFunctionCallArgumentsDone( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``response.function_call_arguments.done`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``response.function_call_arguments.done``. Required. + RESPONSE_FUNCTION_CALL_ARGUMENTS_DONE. + :vartype type: str or ~azure.ai.voiceagents.models.RESPONSE_FUNCTION_CALL_ARGUMENTS_DONE + :ivar response_id: The ID of the response. Required. + :vartype response_id: str + :ivar item_id: The ID of the function call item. Required. + :vartype item_id: str + :ivar output_index: The index of the output item in the response. Required. + :vartype output_index: int + :ivar call_id: The ID of the function call. Required. + :vartype call_id: str + :ivar name: The name of the function that was called. Required. + :vartype name: str + :ivar arguments: The final arguments as a JSON string. Required. + :vartype arguments: str + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the server event. Required.""" + type: Literal[RealtimeServerEventType.RESPONSE_FUNCTION_CALL_ARGUMENTS_DONE] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``response.function_call_arguments.done``. Required. + RESPONSE_FUNCTION_CALL_ARGUMENTS_DONE.""" + response_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the response. Required.""" + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the function call item. Required.""" + output_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The index of the output item in the response. Required.""" + call_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the function call. Required.""" + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of the function that was called. Required.""" + arguments: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The final arguments as a JSON string. Required.""" + + @overload + def __init__( + self, + *, + event_id: str, + type: Literal[RealtimeServerEventType.RESPONSE_FUNCTION_CALL_ARGUMENTS_DONE], + response_id: str, + item_id: str, + output_index: int, + call_id: str, + name: str, + arguments: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventResponseMcpCallArgumentsDelta( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``response.mcp_call_arguments.delta`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``response.mcp_call_arguments.delta``. Required. + RESPONSE_MCP_CALL_ARGUMENTS_DELTA. + :vartype type: str or ~azure.ai.voiceagents.models.RESPONSE_MCP_CALL_ARGUMENTS_DELTA + :ivar response_id: The ID of the response. Required. + :vartype response_id: str + :ivar item_id: The ID of the MCP tool call item. Required. + :vartype item_id: str + :ivar output_index: The index of the output item in the response. Required. + :vartype output_index: int + :ivar delta: The JSON-encoded arguments delta. Required. + :vartype delta: str + :ivar obfuscation: + :vartype obfuscation: str + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the server event. Required.""" + type: Literal[RealtimeServerEventType.RESPONSE_MCP_CALL_ARGUMENTS_DELTA] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``response.mcp_call_arguments.delta``. Required. + RESPONSE_MCP_CALL_ARGUMENTS_DELTA.""" + response_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the response. Required.""" + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the MCP tool call item. Required.""" + output_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The index of the output item in the response. Required.""" + delta: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The JSON-encoded arguments delta. Required.""" + obfuscation: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + event_id: str, + type: Literal[RealtimeServerEventType.RESPONSE_MCP_CALL_ARGUMENTS_DELTA], + response_id: str, + item_id: str, + output_index: int, + delta: str, + obfuscation: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventResponseMcpCallArgumentsDone( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``response.mcp_call_arguments.done`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``response.mcp_call_arguments.done``. Required. + RESPONSE_MCP_CALL_ARGUMENTS_DONE. + :vartype type: str or ~azure.ai.voiceagents.models.RESPONSE_MCP_CALL_ARGUMENTS_DONE + :ivar response_id: The ID of the response. Required. + :vartype response_id: str + :ivar item_id: The ID of the MCP tool call item. Required. + :vartype item_id: str + :ivar output_index: The index of the output item in the response. Required. + :vartype output_index: int + :ivar arguments: The final JSON-encoded arguments string. Required. + :vartype arguments: str + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the server event. Required.""" + type: Literal[RealtimeServerEventType.RESPONSE_MCP_CALL_ARGUMENTS_DONE] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``response.mcp_call_arguments.done``. Required. + RESPONSE_MCP_CALL_ARGUMENTS_DONE.""" + response_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the response. Required.""" + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the MCP tool call item. Required.""" + output_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The index of the output item in the response. Required.""" + arguments: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The final JSON-encoded arguments string. Required.""" + + @overload + def __init__( + self, + *, + event_id: str, + type: Literal[RealtimeServerEventType.RESPONSE_MCP_CALL_ARGUMENTS_DONE], + response_id: str, + item_id: str, + output_index: int, + arguments: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventResponseMcpCallCompleted( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``response.mcp_call.completed`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``response.mcp_call.completed``. Required. + RESPONSE_MCP_CALL_COMPLETED. + :vartype type: str or ~azure.ai.voiceagents.models.RESPONSE_MCP_CALL_COMPLETED + :ivar output_index: The index of the output item in the response. Required. + :vartype output_index: int + :ivar item_id: The ID of the MCP tool call item. Required. + :vartype item_id: str + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the server event. Required.""" + type: Literal[RealtimeServerEventType.RESPONSE_MCP_CALL_COMPLETED] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``response.mcp_call.completed``. Required. RESPONSE_MCP_CALL_COMPLETED.""" + output_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The index of the output item in the response. Required.""" + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the MCP tool call item. Required.""" + + @overload + def __init__( + self, + *, + event_id: str, + type: Literal[RealtimeServerEventType.RESPONSE_MCP_CALL_COMPLETED], + output_index: int, + item_id: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventResponseMcpCallFailed( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``response.mcp_call.failed`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``response.mcp_call.failed``. Required. + RESPONSE_MCP_CALL_FAILED. + :vartype type: str or ~azure.ai.voiceagents.models.RESPONSE_MCP_CALL_FAILED + :ivar output_index: The index of the output item in the response. Required. + :vartype output_index: int + :ivar item_id: The ID of the MCP tool call item. Required. + :vartype item_id: str + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the server event. Required.""" + type: Literal[RealtimeServerEventType.RESPONSE_MCP_CALL_FAILED] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``response.mcp_call.failed``. Required. RESPONSE_MCP_CALL_FAILED.""" + output_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The index of the output item in the response. Required.""" + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the MCP tool call item. Required.""" + + @overload + def __init__( + self, + *, + event_id: str, + type: Literal[RealtimeServerEventType.RESPONSE_MCP_CALL_FAILED], + output_index: int, + item_id: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventResponseMcpCallInProgress( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``response.mcp_call.in_progress`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``response.mcp_call.in_progress``. Required. + RESPONSE_MCP_CALL_IN_PROGRESS. + :vartype type: str or ~azure.ai.voiceagents.models.RESPONSE_MCP_CALL_IN_PROGRESS + :ivar output_index: The index of the output item in the response. Required. + :vartype output_index: int + :ivar item_id: The ID of the MCP tool call item. Required. + :vartype item_id: str + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the server event. Required.""" + type: Literal[RealtimeServerEventType.RESPONSE_MCP_CALL_IN_PROGRESS] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``response.mcp_call.in_progress``. Required. + RESPONSE_MCP_CALL_IN_PROGRESS.""" + output_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The index of the output item in the response. Required.""" + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the MCP tool call item. Required.""" + + @overload + def __init__( + self, + *, + event_id: str, + type: Literal[RealtimeServerEventType.RESPONSE_MCP_CALL_IN_PROGRESS], + output_index: int, + item_id: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventResponseOutputItemAdded( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``response.output_item.added`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``response.output_item.added``. Required. + RESPONSE_OUTPUT_ITEM_ADDED. + :vartype type: str or ~azure.ai.voiceagents.models.RESPONSE_OUTPUT_ITEM_ADDED + :ivar response_id: The ID of the Response to which the item belongs. Required. + :vartype response_id: str + :ivar output_index: The index of the output item in the Response. Required. + :vartype output_index: int + :ivar item: The output item that was added. Required. Is one of the following types: + "_unions.VoiceAgentResponseMessageItem", VoiceFunctionCallItem, VoiceFunctionCallOutputItem, + VoiceMcpListToolsItem, VoiceMcpCallItem, VoiceMcpApprovalRequestItem, + VoiceMcpApprovalResponseItem, VoiceAgentWorkflowActionItem, VoiceAgentWebSearchCallItem, + VoiceAgentFileSearchCallItem + :vartype item: ~azure.ai.voiceagents.models.RealtimeConversationItemMessageSystem or + ~azure.ai.voiceagents.models.RealtimeConversationItemMessageUser or + ~azure.ai.voiceagents.models.RealtimeConversationItemMessageAssistant or + ~azure.ai.voiceagents.models.VoiceFunctionCallItem or + ~azure.ai.voiceagents.models.VoiceFunctionCallOutputItem or + ~azure.ai.voiceagents.models.VoiceMcpListToolsItem or + ~azure.ai.voiceagents.models.VoiceMcpCallItem or + ~azure.ai.voiceagents.models.VoiceMcpApprovalRequestItem or + ~azure.ai.voiceagents.models.VoiceMcpApprovalResponseItem or + ~azure.ai.voiceagents.models.VoiceAgentWorkflowActionItem or + ~azure.ai.voiceagents.models.VoiceAgentWebSearchCallItem or + ~azure.ai.voiceagents.models.VoiceAgentFileSearchCallItem + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the server event. Required.""" + type: Literal[RealtimeServerEventType.RESPONSE_OUTPUT_ITEM_ADDED] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``response.output_item.added``. Required. RESPONSE_OUTPUT_ITEM_ADDED.""" + response_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the Response to which the item belongs. Required.""" + output_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The index of the output item in the Response. Required.""" + item: "_unions.VoiceAgentResponseItem" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The output item that was added. Required. Is one of the following types: + \"_unions.VoiceAgentResponseMessageItem\", VoiceFunctionCallItem, VoiceFunctionCallOutputItem, + VoiceMcpListToolsItem, VoiceMcpCallItem, VoiceMcpApprovalRequestItem, + VoiceMcpApprovalResponseItem, VoiceAgentWorkflowActionItem, VoiceAgentWebSearchCallItem, + VoiceAgentFileSearchCallItem""" + + @overload + def __init__( + self, + *, + event_id: str, + type: Literal[RealtimeServerEventType.RESPONSE_OUTPUT_ITEM_ADDED], + response_id: str, + output_index: int, + item: "_unions.VoiceAgentResponseItem", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventResponseOutputItemDone( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``response.output_item.done`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``response.output_item.done``. Required. + RESPONSE_OUTPUT_ITEM_DONE. + :vartype type: str or ~azure.ai.voiceagents.models.RESPONSE_OUTPUT_ITEM_DONE + :ivar response_id: The ID of the Response to which the item belongs. Required. + :vartype response_id: str + :ivar output_index: The index of the output item in the Response. Required. + :vartype output_index: int + :ivar item: The output item that finished streaming. Required. Is one of the following types: + "_unions.VoiceAgentResponseMessageItem", VoiceFunctionCallItem, VoiceFunctionCallOutputItem, + VoiceMcpListToolsItem, VoiceMcpCallItem, VoiceMcpApprovalRequestItem, + VoiceMcpApprovalResponseItem, VoiceAgentWorkflowActionItem, VoiceAgentWebSearchCallItem, + VoiceAgentFileSearchCallItem + :vartype item: ~azure.ai.voiceagents.models.RealtimeConversationItemMessageSystem or + ~azure.ai.voiceagents.models.RealtimeConversationItemMessageUser or + ~azure.ai.voiceagents.models.RealtimeConversationItemMessageAssistant or + ~azure.ai.voiceagents.models.VoiceFunctionCallItem or + ~azure.ai.voiceagents.models.VoiceFunctionCallOutputItem or + ~azure.ai.voiceagents.models.VoiceMcpListToolsItem or + ~azure.ai.voiceagents.models.VoiceMcpCallItem or + ~azure.ai.voiceagents.models.VoiceMcpApprovalRequestItem or + ~azure.ai.voiceagents.models.VoiceMcpApprovalResponseItem or + ~azure.ai.voiceagents.models.VoiceAgentWorkflowActionItem or + ~azure.ai.voiceagents.models.VoiceAgentWebSearchCallItem or + ~azure.ai.voiceagents.models.VoiceAgentFileSearchCallItem + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the server event. Required.""" + type: Literal[RealtimeServerEventType.RESPONSE_OUTPUT_ITEM_DONE] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``response.output_item.done``. Required. RESPONSE_OUTPUT_ITEM_DONE.""" + response_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the Response to which the item belongs. Required.""" + output_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The index of the output item in the Response. Required.""" + item: "_unions.VoiceAgentResponseItem" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The output item that finished streaming. Required. Is one of the following types: + \"_unions.VoiceAgentResponseMessageItem\", VoiceFunctionCallItem, VoiceFunctionCallOutputItem, + VoiceMcpListToolsItem, VoiceMcpCallItem, VoiceMcpApprovalRequestItem, + VoiceMcpApprovalResponseItem, VoiceAgentWorkflowActionItem, VoiceAgentWebSearchCallItem, + VoiceAgentFileSearchCallItem""" + + @overload + def __init__( + self, + *, + event_id: str, + type: Literal[RealtimeServerEventType.RESPONSE_OUTPUT_ITEM_DONE], + response_id: str, + output_index: int, + item: "_unions.VoiceAgentResponseItem", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventResponseTextDelta(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """The ``response.output_text.delta`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``response.output_text.delta``. Required. + RESPONSE_OUTPUT_TEXT_DELTA. + :vartype type: str or ~azure.ai.voiceagents.models.RESPONSE_OUTPUT_TEXT_DELTA + :ivar response_id: The ID of the response. Required. + :vartype response_id: str + :ivar item_id: The ID of the item. Required. + :vartype item_id: str + :ivar output_index: The index of the output item in the response. Required. + :vartype output_index: int + :ivar content_index: The index of the content part in the item's content array. Required. + :vartype content_index: int + :ivar delta: The text delta. Required. + :vartype delta: str + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the server event. Required.""" + type: Literal[RealtimeServerEventType.RESPONSE_OUTPUT_TEXT_DELTA] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``response.output_text.delta``. Required. RESPONSE_OUTPUT_TEXT_DELTA.""" + response_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the response. Required.""" + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the item. Required.""" + output_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The index of the output item in the response. Required.""" + content_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The index of the content part in the item's content array. Required.""" + delta: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The text delta. Required.""" + + @overload + def __init__( + self, + *, + event_id: str, + type: Literal[RealtimeServerEventType.RESPONSE_OUTPUT_TEXT_DELTA], + response_id: str, + item_id: str, + output_index: int, + content_index: int, + delta: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventResponseTextDone(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """The ``response.output_text.done`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``response.output_text.done``. Required. + RESPONSE_OUTPUT_TEXT_DONE. + :vartype type: str or ~azure.ai.voiceagents.models.RESPONSE_OUTPUT_TEXT_DONE + :ivar response_id: The ID of the response. Required. + :vartype response_id: str + :ivar item_id: The ID of the item. Required. + :vartype item_id: str + :ivar output_index: The index of the output item in the response. Required. + :vartype output_index: int + :ivar content_index: The index of the content part in the item's content array. Required. + :vartype content_index: int + :ivar text: The final text content. Required. + :vartype text: str + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the server event. Required.""" + type: Literal[RealtimeServerEventType.RESPONSE_OUTPUT_TEXT_DONE] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``response.output_text.done``. Required. RESPONSE_OUTPUT_TEXT_DONE.""" + response_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the response. Required.""" + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the item. Required.""" + output_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The index of the output item in the response. Required.""" + content_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The index of the content part in the item's content array. Required.""" + text: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The final text content. Required.""" + + @overload + def __init__( + self, + *, + event_id: str, + type: Literal[RealtimeServerEventType.RESPONSE_OUTPUT_TEXT_DONE], + response_id: str, + item_id: str, + output_index: int, + content_index: int, + text: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventResponseVideoDelta(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """The ``response.video.delta`` server event. + + :ivar type: Required. Default value is "response.video.delta". + :vartype type: str + :ivar event_id: Required. + :vartype event_id: str + :ivar output_index: Required. + :vartype output_index: int + :ivar codec: Required. + :vartype codec: str + :ivar delta: The base64-encoded video frame data. Required. + :vartype delta: str + """ + + type: Literal["response.video.delta"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required. Default value is \"response.video.delta\".""" + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + output_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + codec: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + delta: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The base64-encoded video frame data. Required.""" + + @overload + def __init__( + self, + *, + event_id: str, + output_index: int, + codec: str, + delta: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["response.video.delta"] = "response.video.delta" + + +class VoiceAgentServerEventSessionAvatarConnecting( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``session.avatar.connecting`` server event. + + :ivar type: Required. Default value is "session.avatar.connecting". + :vartype type: str + :ivar event_id: Required. + :vartype event_id: str + :ivar server_sdp: The server's SDP answer for avatar media negotiation. Required. + :vartype server_sdp: str + """ + + type: Literal["session.avatar.connecting"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required. Default value is \"session.avatar.connecting\".""" + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + server_sdp: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The server's SDP answer for avatar media negotiation. Required.""" + + @overload + def __init__( + self, + *, + event_id: str, + server_sdp: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["session.avatar.connecting"] = "session.avatar.connecting" + + +class VoiceAgentServerEventSessionAvatarSwitchToIdle( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``session.avatar.switch_to_idle`` server event. + + :ivar type: Required. Default value is "session.avatar.switch_to_idle". + :vartype type: str + :ivar event_id: Required. + :vartype event_id: str + :ivar turn_id: + :vartype turn_id: str + """ + + type: Literal["session.avatar.switch_to_idle"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Required. Default value is \"session.avatar.switch_to_idle\".""" + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + turn_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + event_id: str, + turn_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["session.avatar.switch_to_idle"] = "session.avatar.switch_to_idle" + + +class VoiceAgentServerEventSessionAvatarSwitchToSpeaking( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``session.avatar.switch_to_speaking`` server event. + + :ivar type: Required. Default value is "session.avatar.switch_to_speaking". + :vartype type: str + :ivar event_id: Required. + :vartype event_id: str + :ivar turn_id: + :vartype turn_id: str + """ + + type: Literal["session.avatar.switch_to_speaking"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Required. Default value is \"session.avatar.switch_to_speaking\".""" + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + turn_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + event_id: str, + turn_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["session.avatar.switch_to_speaking"] = "session.avatar.switch_to_speaking" + + +class VoiceAgentServerEventSessionCreated(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """The ``session.created`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``session.created``. Required. SESSION_CREATED. + :vartype type: str or ~azure.ai.voiceagents.models.SESSION_CREATED + :ivar session: The initial effective voice-agent session configuration. Required. + :vartype session: ~azure.ai.voiceagents.models.VoiceAgentSessionResponseConfig + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the server event. Required.""" + type: Literal[RealtimeServerEventType.SESSION_CREATED] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``session.created``. Required. SESSION_CREATED.""" + session: "_models.VoiceAgentSessionResponseConfig" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The initial effective voice-agent session configuration. Required.""" + + @overload + def __init__( + self, + *, + event_id: str, + type: Literal[RealtimeServerEventType.SESSION_CREATED], + session: "_models.VoiceAgentSessionResponseConfig", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventSessionHandoffAborted( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``session.handoff.aborted`` server event. + + :ivar type: Required. Default value is "session.handoff.aborted". + :vartype type: str + :ivar event_id: Required. + :vartype event_id: str + :ivar handoff_id: Required. + :vartype handoff_id: str + :ivar edge_id: Required. + :vartype edge_id: str + :ivar from_node_id: Required. + :vartype from_node_id: str + :ivar to_node_id: Required. + :vartype to_node_id: str + :ivar from_model: Required. + :vartype from_model: str + :ivar to_model: Required. + :vartype to_model: str + :ivar tool_call_id: Required. + :vartype tool_call_id: str + :ivar node_generation: Required. + :vartype node_generation: int + :ivar reason: The reason the handoff was aborted. Required. Known values are: + "user_interruption" and "error". + :vartype reason: str or ~azure.ai.voiceagents.models.VoiceAgentHandoffAbortReason + :ivar error: The error that aborted the handoff, when ``reason`` is ``error``. + :vartype error: ~azure.ai.voiceagents.models.VoiceAgentServerEventErrorDetails + """ + + type: Literal["session.handoff.aborted"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required. Default value is \"session.handoff.aborted\".""" + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + handoff_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + edge_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + from_node_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + to_node_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + from_model: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + to_model: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + tool_call_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + node_generation: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + reason: Union[str, "_models.VoiceAgentHandoffAbortReason"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The reason the handoff was aborted. Required. Known values are: \"user_interruption\" and + \"error\".""" + error: Optional["_models.VoiceAgentServerEventErrorDetails"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The error that aborted the handoff, when ``reason`` is ``error``.""" + + @overload + def __init__( + self, + *, + event_id: str, + handoff_id: str, + edge_id: str, + from_node_id: str, + to_node_id: str, + from_model: str, + to_model: str, + tool_call_id: str, + node_generation: int, + reason: Union[str, "_models.VoiceAgentHandoffAbortReason"], + error: Optional["_models.VoiceAgentServerEventErrorDetails"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["session.handoff.aborted"] = "session.handoff.aborted" + + +class VoiceAgentServerEventSessionHandoffCompleted( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``session.handoff.completed`` server event. + + :ivar type: Required. Default value is "session.handoff.completed". + :vartype type: str + :ivar event_id: Required. + :vartype event_id: str + :ivar handoff_id: Required. + :vartype handoff_id: str + :ivar edge_id: Required. + :vartype edge_id: str + :ivar from_node_id: Required. + :vartype from_node_id: str + :ivar to_node_id: Required. + :vartype to_node_id: str + :ivar from_model: Required. + :vartype from_model: str + :ivar to_model: Required. + :vartype to_model: str + :ivar tool_call_id: Required. + :vartype tool_call_id: str + :ivar node_generation: Required. + :vartype node_generation: int + :ivar prepare_duration_ms: The time spent preparing the target behavior, in milliseconds. + Required. + :vartype prepare_duration_ms: int + :ivar duration_ms: The total duration of the handoff, in milliseconds. Required. + :vartype duration_ms: int + """ + + type: Literal["session.handoff.completed"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required. Default value is \"session.handoff.completed\".""" + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + handoff_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + edge_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + from_node_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + to_node_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + from_model: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + to_model: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + tool_call_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + node_generation: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + prepare_duration_ms: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The time spent preparing the target behavior, in milliseconds. Required.""" + duration_ms: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The total duration of the handoff, in milliseconds. Required.""" + + @overload + def __init__( + self, + *, + event_id: str, + handoff_id: str, + edge_id: str, + from_node_id: str, + to_node_id: str, + from_model: str, + to_model: str, + tool_call_id: str, + node_generation: int, + prepare_duration_ms: int, + duration_ms: int, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["session.handoff.completed"] = "session.handoff.completed" + + +class VoiceAgentServerEventSessionHandoffStarted( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``session.handoff.started`` server event. + + :ivar type: Required. Default value is "session.handoff.started". + :vartype type: str + :ivar event_id: Required. + :vartype event_id: str + :ivar handoff_id: Required. + :vartype handoff_id: str + :ivar edge_id: Required. + :vartype edge_id: str + :ivar from_node_id: Required. + :vartype from_node_id: str + :ivar to_node_id: Required. + :vartype to_node_id: str + :ivar from_model: Required. + :vartype from_model: str + :ivar to_model: Required. + :vartype to_model: str + :ivar tool_call_id: Required. + :vartype tool_call_id: str + :ivar node_generation: Required. + :vartype node_generation: int + """ + + type: Literal["session.handoff.started"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required. Default value is \"session.handoff.started\".""" + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + handoff_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + edge_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + from_node_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + to_node_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + from_model: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + to_model: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + tool_call_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + node_generation: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + + @overload + def __init__( + self, + *, + event_id: str, + handoff_id: str, + edge_id: str, + from_node_id: str, + to_node_id: str, + from_model: str, + to_model: str, + tool_call_id: str, + node_generation: int, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["session.handoff.started"] = "session.handoff.started" + + +class VoiceAgentServerEventSessionUpdated(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """The ``session.updated`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``session.updated``. Required. SESSION_UPDATED. + :vartype type: str or ~azure.ai.voiceagents.models.SESSION_UPDATED + :ivar session: The effective voice-agent session configuration after the update. Required. + :vartype session: ~azure.ai.voiceagents.models.VoiceAgentSessionResponseConfig + """ + + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the server event. Required.""" + type: Literal[RealtimeServerEventType.SESSION_UPDATED] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The event type, must be ``session.updated``. Required. SESSION_UPDATED.""" + session: "_models.VoiceAgentSessionResponseConfig" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The effective voice-agent session configuration after the update. Required.""" + + @overload + def __init__( + self, + *, + event_id: str, + type: Literal[RealtimeServerEventType.SESSION_UPDATED], + session: "_models.VoiceAgentSessionResponseConfig", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventWarning(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """The ``warning`` server event. + + :ivar type: Required. Default value is "warning". + :vartype type: str + :ivar event_id: Required. + :vartype event_id: str + :ivar warning: Required. + :vartype warning: ~azure.ai.voiceagents.models.VoiceAgentServerEventWarningDetails + """ + + type: Literal["warning"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required. Default value is \"warning\".""" + event_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + warning: "_models.VoiceAgentServerEventWarningDetails" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Required.""" + + @overload + def __init__( + self, + *, + event_id: str, + warning: "_models.VoiceAgentServerEventWarningDetails", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["warning"] = "warning" + + +class VoiceAgentServerEventWarningDetails(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Details of a non-fatal warning. + + :ivar message: Required. + :vartype message: str + :ivar code: + :vartype code: str + :ivar param: + :vartype param: str + """ + + message: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + code: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + param: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + message: str, + code: Optional[str] = None, + param: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentServerEventWebSearchCallCompleted( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``response.web_search_call.completed`` server event. + + :ivar type: Required. Default value is "response.web_search_call.completed". + :vartype type: str + :ivar event_id: + :vartype event_id: str + :ivar response_id: + :vartype response_id: str + :ivar item_id: Required. + :vartype item_id: str + :ivar output_index: Required. + :vartype output_index: int + :ivar sequence_number: Required. + :vartype sequence_number: int + """ + + type: Literal["response.web_search_call.completed"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Required. Default value is \"response.web_search_call.completed\".""" + event_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + response_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + output_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + sequence_number: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + + @overload + def __init__( + self, + *, + item_id: str, + output_index: int, + sequence_number: int, + event_id: Optional[str] = None, + response_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["response.web_search_call.completed"] = "response.web_search_call.completed" + + +class VoiceAgentServerEventWebSearchCallInProgress( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``response.web_search_call.in_progress`` server event. + + :ivar type: Required. Default value is "response.web_search_call.in_progress". + :vartype type: str + :ivar event_id: + :vartype event_id: str + :ivar response_id: + :vartype response_id: str + :ivar item_id: Required. + :vartype item_id: str + :ivar output_index: Required. + :vartype output_index: int + :ivar sequence_number: Required. + :vartype sequence_number: int + """ + + type: Literal["response.web_search_call.in_progress"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Required. Default value is \"response.web_search_call.in_progress\".""" + event_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + response_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + output_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + sequence_number: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + + @overload + def __init__( + self, + *, + item_id: str, + output_index: int, + sequence_number: int, + event_id: Optional[str] = None, + response_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["response.web_search_call.in_progress"] = "response.web_search_call.in_progress" + + +class VoiceAgentServerEventWebSearchCallSearching( + _Model +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """The ``response.web_search_call.searching`` server event. + + :ivar type: Required. Default value is "response.web_search_call.searching". + :vartype type: str + :ivar event_id: + :vartype event_id: str + :ivar response_id: + :vartype response_id: str + :ivar item_id: Required. + :vartype item_id: str + :ivar output_index: Required. + :vartype output_index: int + :ivar sequence_number: Required. + :vartype sequence_number: int + """ + + type: Literal["response.web_search_call.searching"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Required. Default value is \"response.web_search_call.searching\".""" + event_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + response_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + output_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + sequence_number: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + + @overload + def __init__( + self, + *, + item_id: str, + output_index: int, + sequence_number: int, + event_id: Optional[str] = None, + response_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["response.web_search_call.searching"] = "response.web_search_call.searching" + + +class VoiceAgentServerVadTurnDetection(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Server VAD turn-detection settings. + + :ivar create_response: + :vartype create_response: bool + :ivar interrupt_response: + :vartype interrupt_response: bool + :ivar idle_timeout_ms: + :vartype idle_timeout_ms: int + :ivar type: Required. Server-side voice activity detection. + :vartype type: str or ~azure.ai.voiceagents.models.SERVER_VAD + :ivar threshold: + :vartype threshold: float + :ivar prefix_padding_ms: + :vartype prefix_padding_ms: int + :ivar silence_duration_ms: + :vartype silence_duration_ms: int + :ivar speech_duration_ms: + :vartype speech_duration_ms: int + :ivar end_of_utterance_detection: + :vartype end_of_utterance_detection: + ~azure.ai.voiceagents.models.VoiceAgentEndOfUtteranceDetection + :ivar auto_truncate: + :vartype auto_truncate: bool + """ + + create_response: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + interrupt_response: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + idle_timeout_ms: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + type: Literal[VoiceTurnDetectionType.SERVER_VAD] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Required. Server-side voice activity detection.""" + threshold: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + prefix_padding_ms: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + silence_duration_ms: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + speech_duration_ms: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + end_of_utterance_detection: Optional["_models.VoiceAgentEndOfUtteranceDetection"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + auto_truncate: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + type: Literal[VoiceTurnDetectionType.SERVER_VAD], + create_response: Optional[bool] = None, + interrupt_response: Optional[bool] = None, + idle_timeout_ms: Optional[int] = None, + threshold: Optional[float] = None, + prefix_padding_ms: Optional[int] = None, + silence_duration_ms: Optional[int] = None, + speech_duration_ms: Optional[int] = None, + end_of_utterance_detection: Optional["_models.VoiceAgentEndOfUtteranceDetection"] = None, + auto_truncate: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentSessionAvatarConfig(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Avatar settings accepted by the stable voice-agent WebSocket contract. + + :ivar type: Known values are: "video_avatar" and "photo_avatar". + :vartype type: str or ~azure.ai.voiceagents.models.VoiceAgentAvatarType + :ivar ice_servers: + :vartype ice_servers: list[~azure.ai.voiceagents.models.VoiceAgentAvatarIceServer] + :ivar character: Required. + :vartype character: str + :ivar style: + :vartype style: str + :ivar customized: + :vartype customized: bool + :ivar model: + :vartype model: str + :ivar video: + :vartype video: ~azure.ai.voiceagents.models.VoiceAgentAvatarVideoParams + :ivar scene: + :vartype scene: ~azure.ai.voiceagents.models.VoiceAgentAvatarScene + :ivar output_protocol: Known values are: "websocket", "websocket-binary", and "webrtc". + :vartype output_protocol: str or ~azure.ai.voiceagents.models.VoiceAgentAvatarOutputProtocol + :ivar output_audit_audio: + :vartype output_audit_audio: bool + """ + + type: Optional[Union[str, "_models.VoiceAgentAvatarType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Known values are: \"video_avatar\" and \"photo_avatar\".""" + ice_servers: Optional[list["_models.VoiceAgentAvatarIceServer"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + character: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + style: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + customized: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + model: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + video: Optional["_models.VoiceAgentAvatarVideoParams"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + scene: Optional["_models.VoiceAgentAvatarScene"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + output_protocol: Optional[Union[str, "_models.VoiceAgentAvatarOutputProtocol"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Known values are: \"websocket\", \"websocket-binary\", and \"webrtc\".""" + output_audit_audio: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + character: str, + type: Optional[Union[str, "_models.VoiceAgentAvatarType"]] = None, + ice_servers: Optional[list["_models.VoiceAgentAvatarIceServer"]] = None, + style: Optional[str] = None, + customized: Optional[bool] = None, + model: Optional[str] = None, + video: Optional["_models.VoiceAgentAvatarVideoParams"] = None, + scene: Optional["_models.VoiceAgentAvatarScene"] = None, + output_protocol: Optional[Union[str, "_models.VoiceAgentAvatarOutputProtocol"]] = None, + output_audit_audio: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentSessionMcpTool(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """A remote MCP server available to a voice-agent session. + + :ivar type: Required. Default value is "mcp". + :vartype type: str + :ivar server_label: A label for this MCP server, used to identify it in tool calls. Required. + :vartype server_label: str + :ivar server_url: Required. + :vartype server_url: str + :ivar authorization: Is either a str type or a VoiceAgentMcpAssignedManagedIdentity type. + :vartype authorization: str or + ~azure.ai.voiceagents.models.VoiceAgentMcpAssignedManagedIdentity + :ivar headers: + :vartype headers: dict[str, str] + :ivar allowed_tools: + :vartype allowed_tools: list[str] + :ivar require_approval: Is either a Union[str, "_models.VoiceAgentMcpApprovalMode"] type or a + {str: [str]} type. + :vartype require_approval: str or ~azure.ai.voiceagents.models.VoiceAgentMcpApprovalMode or + dict[str, list[str]] + :ivar response_scheduling: Known values are: "silent", "when_idle", "interrupt", and + "skip_if_busy". + :vartype response_scheduling: str or + ~azure.ai.voiceagents.models.VoiceAgentMcpResponseScheduling + """ + + type: Literal["mcp"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required. Default value is \"mcp\".""" + server_label: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """A label for this MCP server, used to identify it in tool calls. Required.""" + server_url: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + authorization: Optional[Union[str, "_models.VoiceAgentMcpAssignedManagedIdentity"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Is either a str type or a VoiceAgentMcpAssignedManagedIdentity type.""" + headers: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + allowed_tools: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + require_approval: Optional["_unions.VoiceAgentMcpApprovalPolicy"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Is either a Union[str, \"_models.VoiceAgentMcpApprovalMode\"] type or a {str: [str]} type.""" + response_scheduling: Optional[Union[str, "_models.VoiceAgentMcpResponseScheduling"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Known values are: \"silent\", \"when_idle\", \"interrupt\", and \"skip_if_busy\".""" + + @overload + def __init__( + self, + *, + server_label: str, + server_url: str, + authorization: Optional[Union[str, "_models.VoiceAgentMcpAssignedManagedIdentity"]] = None, + headers: Optional[dict[str, str]] = None, + allowed_tools: Optional[list[str]] = None, + require_approval: Optional["_unions.VoiceAgentMcpApprovalPolicy"] = None, + response_scheduling: Optional[Union[str, "_models.VoiceAgentMcpResponseScheduling"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["mcp"] = "mcp" + + +class VoiceAgentSessionResponseAudio(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Input- and output-audio settings returned in a stable voice-agent session event. + + :ivar input: The effective input-audio settings. + :vartype input: ~azure.ai.voiceagents.models.VoiceAgentSessionResponseAudioInput + :ivar output: The output-audio settings for the session. + :vartype output: ~azure.ai.voiceagents.models.VoiceAgentSessionResponseAudioOutput + """ + + input: Optional["_models.VoiceAgentSessionResponseAudioInput"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The effective input-audio settings.""" + output: Optional["_models.VoiceAgentSessionResponseAudioOutput"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The output-audio settings for the session.""" + + @overload + def __init__( + self, + *, + input: Optional["_models.VoiceAgentSessionResponseAudioInput"] = None, + output: Optional["_models.VoiceAgentSessionResponseAudioOutput"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentSessionResponseAudioInput(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Input-audio settings returned in a stable voice-agent session event. + + :ivar noise_reduction: Input noise reduction. Set to null to disable. + :vartype noise_reduction: ~azure.ai.voiceagents.models.VoiceNoiseReduction + :ivar transcription: Asynchronous input-audio transcription. Set to null to disable + transcription. + :vartype transcription: ~azure.ai.voiceagents.models.VoiceInputTranscription + :ivar format: The structured input audio format. + :vartype format: ~azure.ai.voiceagents.models.VoiceAudioFormat + :ivar turn_detection: Turn-detection settings. Set to null to disable server-side turn + detection. Is one of the following types: VoiceAgentServerVadTurnDetection, + VoiceAgentSemanticVadTurnDetection, VoiceAgentAzureSemanticVadTurnDetection, + VoiceAgentAzureMultilingualSemanticVadTurnDetection + :vartype turn_detection: ~azure.ai.voiceagents.models.VoiceAgentServerVadTurnDetection or + ~azure.ai.voiceagents.models.VoiceAgentSemanticVadTurnDetection or + ~azure.ai.voiceagents.models.VoiceAgentAzureSemanticVadTurnDetection or + ~azure.ai.voiceagents.models.VoiceAgentAzureMultilingualSemanticVadTurnDetection + :ivar echo_cancellation: Optional server-side echo cancellation settings. + :vartype echo_cancellation: ~azure.ai.voiceagents.models.VoiceAgentEchoCancellation + """ + + noise_reduction: Optional["_models.VoiceNoiseReduction"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Input noise reduction. Set to null to disable.""" + transcription: Optional["_models.VoiceInputTranscription"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Asynchronous input-audio transcription. Set to null to disable transcription.""" + format: Optional["_models.VoiceAudioFormat"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The structured input audio format.""" + turn_detection: Optional["_unions.VoiceAgentTurnDetection"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Turn-detection settings. Set to null to disable server-side turn detection. Is one of the + following types: VoiceAgentServerVadTurnDetection, VoiceAgentSemanticVadTurnDetection, + VoiceAgentAzureSemanticVadTurnDetection, VoiceAgentAzureMultilingualSemanticVadTurnDetection""" + echo_cancellation: Optional["_models.VoiceAgentEchoCancellation"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Optional server-side echo cancellation settings.""" + + @overload + def __init__( + self, + *, + noise_reduction: Optional["_models.VoiceNoiseReduction"] = None, + transcription: Optional["_models.VoiceInputTranscription"] = None, + format: Optional["_models.VoiceAudioFormat"] = None, + turn_detection: Optional["_unions.VoiceAgentTurnDetection"] = None, + echo_cancellation: Optional["_models.VoiceAgentEchoCancellation"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentSessionResponseAudioOutput(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Output-audio settings returned in a stable voice-agent session event. + + :ivar format: The output audio format. + :vartype format: ~azure.ai.voiceagents.models.VoiceAudioFormat + :ivar voice: The typed voice configuration. Is one of the following types: OpenAIVoice, + AzureVoice, AzureRealtimeNativeVoice + :vartype voice: ~azure.ai.voiceagents.models.OpenAIVoice or + ~azure.ai.voiceagents.models.AzureVoice or + ~azure.ai.voiceagents.models.AzureRealtimeNativeVoice + :ivar output_audio_timestamp_types: Timestamp kinds to include with output audio. + :vartype output_audio_timestamp_types: list[str or + ~azure.ai.voiceagents.models.VoiceAudioTimestampType] + :ivar speed: The speaking-speed multiplier. + :vartype speed: float + """ + + format: Optional["_models.VoiceAudioFormat"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The output audio format.""" + voice: Optional["_unions.VoiceAgentVoice"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The typed voice configuration. Is one of the following types: OpenAIVoice, AzureVoice, + AzureRealtimeNativeVoice""" + output_audio_timestamp_types: Optional[list[Union[str, "_models.VoiceAudioTimestampType"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Timestamp kinds to include with output audio.""" + speed: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The speaking-speed multiplier.""" + + @overload + def __init__( + self, + *, + format: Optional["_models.VoiceAudioFormat"] = None, + voice: Optional["_unions.VoiceAgentVoice"] = None, + output_audio_timestamp_types: Optional[list[Union[str, "_models.VoiceAudioTimestampType"]]] = None, + speed: Optional[float] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentSessionResponseConfig(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """The effective stable realtime session settings returned by the voice-agent service. + + :ivar type: The session type. Always ``realtime``. Required. Default value is "realtime". + :vartype type: str + :ivar instructions: Instructions applied throughout the session. + :vartype instructions: str + :ivar temperature: The sampling temperature for compatible cascaded pipelines. + :vartype temperature: float + :ivar max_output_tokens: The maximum output-token count for one response. Is either a int type + or a Literal["inf"] type. + :vartype max_output_tokens: int or str + :ivar avatar: The avatar settings for the session. + :vartype avatar: ~azure.ai.voiceagents.models.VoiceAgentSessionAvatarConfig + :ivar animation: Animation settings for the session. + :vartype animation: ~azure.ai.voiceagents.models.VoiceAgentAnimationConfig + :ivar tools: Tools available to the session. + :vartype tools: list[~azure.ai.voiceagents.models.RealtimeFunctionTool or + ~azure.ai.voiceagents.models.VoiceAgentSessionMcpTool or + ~azure.ai.voiceagents.models.VoiceToolboxTool or ~azure.ai.voiceagents.models.VoiceSystemTool] + :ivar tool_choice: Tool-selection behavior for the session. Is either a Union[str, + "_models.ToolChoiceOptions"] type or a RealtimeToolChoiceFunction type. + :vartype tool_choice: str or ~azure.ai.voiceagents.models.ToolChoiceOptions or + ~azure.ai.voiceagents.models.RealtimeToolChoiceFunction + :ivar reasoning: Reasoning settings for compatible realtime models. + :vartype reasoning: ~azure.ai.voiceagents.models.RealtimeReasoning + :ivar parallel_tool_calls: Whether the model may call multiple tools in parallel. + :vartype parallel_tool_calls: bool + :ivar voice_adaptation: Voice-optimized instruction adaptation settings. + :vartype voice_adaptation: ~azure.ai.voiceagents.models.VoiceAgentVoiceAdaptation + :ivar interim_response: Interim-response settings for latency and tool execution. Is either a + VoiceAgentStaticInterimResponseConfig type or a VoiceAgentLlmInterimResponseConfig type. + :vartype interim_response: ~azure.ai.voiceagents.models.VoiceAgentStaticInterimResponseConfig + or ~azure.ai.voiceagents.models.VoiceAgentLlmInterimResponseConfig + :ivar response_delimiter: A delimiter appended to generated responses. + :vartype response_delimiter: str + :ivar greeting: A proactive assistant greeting started after session configuration. + :vartype greeting: ~azure.ai.voiceagents.models.VoiceGreetingConfig + :ivar object: The object type. Always ``realtime.session``. Required. Default value is + "realtime.session". + :vartype object: str + :ivar id: The session identifier. Required. + :vartype id: str + :ivar model: The selected model. Required. + :vartype model: str + :ivar expires_at: The session expiration time as a Unix timestamp in seconds. + :vartype expires_at: ~datetime.datetime + :ivar output_modalities: The output modalities enabled for the session. Required. + :vartype output_modalities: list[str or ~azure.ai.voiceagents.models.VoiceOutputModality] + :ivar audio: The effective input- and output-audio settings for the session. + :vartype audio: ~azure.ai.voiceagents.models.VoiceAgentSessionResponseAudio + :ivar handoff: The effective handoff state. + :vartype handoff: ~azure.ai.voiceagents.models.VoiceAgentHandoffState + :ivar idle_timeout: The idle timeout reported by the service, in milliseconds. + :vartype idle_timeout: int + """ + + type: Literal["realtime"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The session type. Always ``realtime``. Required. Default value is \"realtime\".""" + instructions: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Instructions applied throughout the session.""" + temperature: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The sampling temperature for compatible cascaded pipelines.""" + max_output_tokens: Optional["_unions.VoiceAgentMaxOutputTokens"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The maximum output-token count for one response. Is either a int type or a Literal[\"inf\"] + type.""" + avatar: Optional["_models.VoiceAgentSessionAvatarConfig"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The avatar settings for the session.""" + animation: Optional["_models.VoiceAgentAnimationConfig"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Animation settings for the session.""" + tools: Optional[list["_unions.VoiceAgentSessionTool"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Tools available to the session.""" + tool_choice: Optional["_unions.VoiceAgentToolChoice"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Tool-selection behavior for the session. Is either a Union[str, \"_models.ToolChoiceOptions\"] + type or a RealtimeToolChoiceFunction type.""" + reasoning: Optional["_models.RealtimeReasoning"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Reasoning settings for compatible realtime models.""" + parallel_tool_calls: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Whether the model may call multiple tools in parallel.""" + voice_adaptation: Optional["_models.VoiceAgentVoiceAdaptation"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Voice-optimized instruction adaptation settings.""" + interim_response: Optional["_unions.VoiceAgentInterimResponse"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Interim-response settings for latency and tool execution. Is either a + VoiceAgentStaticInterimResponseConfig type or a VoiceAgentLlmInterimResponseConfig type.""" + response_delimiter: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """A delimiter appended to generated responses.""" + greeting: Optional["_models.VoiceGreetingConfig"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """A proactive assistant greeting started after session configuration.""" + object: Literal["realtime.session"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The object type. Always ``realtime.session``. Required. Default value is \"realtime.session\".""" + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The session identifier. Required.""" + model: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The selected model. Required.""" + expires_at: Optional[datetime.datetime] = rest_field( + visibility=["read", "create", "update", "delete", "query"], format="unix-timestamp" + ) + """The session expiration time as a Unix timestamp in seconds.""" + output_modalities: list[Union[str, "_models.VoiceOutputModality"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The output modalities enabled for the session. Required.""" + audio: Optional["_models.VoiceAgentSessionResponseAudio"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The effective input- and output-audio settings for the session.""" + handoff: Optional["_models.VoiceAgentHandoffState"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The effective handoff state.""" + idle_timeout: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The idle timeout reported by the service, in milliseconds.""" + + @overload + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + model: str, + output_modalities: list[Union[str, "_models.VoiceOutputModality"]], + instructions: Optional[str] = None, + temperature: Optional[float] = None, + max_output_tokens: Optional["_unions.VoiceAgentMaxOutputTokens"] = None, + avatar: Optional["_models.VoiceAgentSessionAvatarConfig"] = None, + animation: Optional["_models.VoiceAgentAnimationConfig"] = None, + tools: Optional[list["_unions.VoiceAgentSessionTool"]] = None, + tool_choice: Optional["_unions.VoiceAgentToolChoice"] = None, + reasoning: Optional["_models.RealtimeReasoning"] = None, + parallel_tool_calls: Optional[bool] = None, + voice_adaptation: Optional["_models.VoiceAgentVoiceAdaptation"] = None, + interim_response: Optional["_unions.VoiceAgentInterimResponse"] = None, + response_delimiter: Optional[str] = None, + greeting: Optional["_models.VoiceGreetingConfig"] = None, + expires_at: Optional[datetime.datetime] = None, + audio: Optional["_models.VoiceAgentSessionResponseAudio"] = None, + handoff: Optional["_models.VoiceAgentHandoffState"] = None, + idle_timeout: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["realtime"] = "realtime" + self.object: Literal["realtime.session"] = "realtime.session" + + +class VoiceAgentSessionUpdateAudio(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Input- and output-audio settings accepted in a ``session.update`` client event. + + :ivar input: The input-audio settings for the session. + :vartype input: ~azure.ai.voiceagents.models.VoiceAgentSessionUpdateAudioInput + :ivar output: The output-audio settings for the session. + :vartype output: ~azure.ai.voiceagents.models.VoiceAgentSessionUpdateAudioOutput + """ + + input: Optional["_models.VoiceAgentSessionUpdateAudioInput"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The input-audio settings for the session.""" + output: Optional["_models.VoiceAgentSessionUpdateAudioOutput"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The output-audio settings for the session.""" + + @overload + def __init__( + self, + *, + input: Optional["_models.VoiceAgentSessionUpdateAudioInput"] = None, + output: Optional["_models.VoiceAgentSessionUpdateAudioOutput"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentSessionUpdateAudioInput(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Input-audio settings accepted in a stable voice-agent session. + + :ivar noise_reduction: Input noise reduction. Set to null to disable. + :vartype noise_reduction: ~azure.ai.voiceagents.models.VoiceNoiseReduction + :ivar transcription: Asynchronous input-audio transcription. Set to null to disable + transcription. + :vartype transcription: ~azure.ai.voiceagents.models.VoiceInputTranscription + :ivar format: The structured input audio format. + :vartype format: ~azure.ai.voiceagents.models.VoiceAudioFormat + :ivar turn_detection: Turn-detection settings. Set to null to disable server-side turn + detection. Is one of the following types: VoiceAgentServerVadTurnDetection, + VoiceAgentSemanticVadTurnDetection, VoiceAgentAzureSemanticVadTurnDetection, + VoiceAgentAzureMultilingualSemanticVadTurnDetection + :vartype turn_detection: ~azure.ai.voiceagents.models.VoiceAgentServerVadTurnDetection or + ~azure.ai.voiceagents.models.VoiceAgentSemanticVadTurnDetection or + ~azure.ai.voiceagents.models.VoiceAgentAzureSemanticVadTurnDetection or + ~azure.ai.voiceagents.models.VoiceAgentAzureMultilingualSemanticVadTurnDetection + :ivar echo_cancellation: Optional server-side echo cancellation settings. + :vartype echo_cancellation: ~azure.ai.voiceagents.models.VoiceAgentEchoCancellation + """ + + noise_reduction: Optional["_models.VoiceNoiseReduction"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Input noise reduction. Set to null to disable.""" + transcription: Optional["_models.VoiceInputTranscription"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Asynchronous input-audio transcription. Set to null to disable transcription.""" + format: Optional["_models.VoiceAudioFormat"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The structured input audio format.""" + turn_detection: Optional["_unions.VoiceAgentTurnDetection"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Turn-detection settings. Set to null to disable server-side turn detection. Is one of the + following types: VoiceAgentServerVadTurnDetection, VoiceAgentSemanticVadTurnDetection, + VoiceAgentAzureSemanticVadTurnDetection, VoiceAgentAzureMultilingualSemanticVadTurnDetection""" + echo_cancellation: Optional["_models.VoiceAgentEchoCancellation"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Optional server-side echo cancellation settings.""" + + @overload + def __init__( + self, + *, + noise_reduction: Optional["_models.VoiceNoiseReduction"] = None, + transcription: Optional["_models.VoiceInputTranscription"] = None, + format: Optional["_models.VoiceAudioFormat"] = None, + turn_detection: Optional["_unions.VoiceAgentTurnDetection"] = None, + echo_cancellation: Optional["_models.VoiceAgentEchoCancellation"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentSessionUpdateAudioOutput(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Output-audio settings accepted in a stable voice-agent session. + + :ivar format: The output audio format. + :vartype format: ~azure.ai.voiceagents.models.VoiceAudioFormat + :ivar voice: The typed voice configuration. Is one of the following types: OpenAIVoice, + AzureVoice, AzureRealtimeNativeVoice + :vartype voice: ~azure.ai.voiceagents.models.OpenAIVoice or + ~azure.ai.voiceagents.models.AzureVoice or + ~azure.ai.voiceagents.models.AzureRealtimeNativeVoice + :ivar output_audio_timestamp_types: Timestamp kinds to include with output audio. + :vartype output_audio_timestamp_types: list[str or + ~azure.ai.voiceagents.models.VoiceAudioTimestampType] + :ivar speed: The speaking-speed multiplier. + :vartype speed: float + """ + + format: Optional["_models.VoiceAudioFormat"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The output audio format.""" + voice: Optional["_unions.VoiceAgentVoice"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The typed voice configuration. Is one of the following types: OpenAIVoice, AzureVoice, + AzureRealtimeNativeVoice""" + output_audio_timestamp_types: Optional[list[Union[str, "_models.VoiceAudioTimestampType"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Timestamp kinds to include with output audio.""" + speed: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The speaking-speed multiplier.""" + + @overload + def __init__( + self, + *, + format: Optional["_models.VoiceAudioFormat"] = None, + voice: Optional["_unions.VoiceAgentVoice"] = None, + output_audio_timestamp_types: Optional[list[Union[str, "_models.VoiceAudioTimestampType"]]] = None, + speed: Optional[float] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentSessionUpdateConfig(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """The stable realtime session settings accepted in a ``session.update`` client event. + + :ivar type: The session type. Always ``realtime``. Required. Default value is "realtime". + :vartype type: str + :ivar instructions: Instructions applied throughout the session. + :vartype instructions: str + :ivar temperature: The sampling temperature for compatible cascaded pipelines. + :vartype temperature: float + :ivar max_output_tokens: The maximum output-token count for one response. Is either a int type + or a Literal["inf"] type. + :vartype max_output_tokens: int or str + :ivar output_modalities: The output modalities enabled for the session. + :vartype output_modalities: list[str or ~azure.ai.voiceagents.models.VoiceOutputModality] + :ivar audio: The input- and output-audio settings for the session. + :vartype audio: ~azure.ai.voiceagents.models.VoiceAgentSessionUpdateAudio + :ivar avatar: The avatar settings for the session. + :vartype avatar: ~azure.ai.voiceagents.models.VoiceAgentSessionAvatarConfig + :ivar animation: Animation settings for the session. + :vartype animation: ~azure.ai.voiceagents.models.VoiceAgentAnimationConfig + :ivar tools: Tools available to the session. + :vartype tools: list[~azure.ai.voiceagents.models.RealtimeFunctionTool or + ~azure.ai.voiceagents.models.VoiceAgentSessionMcpTool or + ~azure.ai.voiceagents.models.VoiceToolboxTool or ~azure.ai.voiceagents.models.VoiceSystemTool] + :ivar tool_choice: Tool-selection behavior for the session. Is either a Union[str, + "_models.ToolChoiceOptions"] type or a RealtimeToolChoiceFunction type. + :vartype tool_choice: str or ~azure.ai.voiceagents.models.ToolChoiceOptions or + ~azure.ai.voiceagents.models.RealtimeToolChoiceFunction + :ivar reasoning: Reasoning settings for compatible realtime models. + :vartype reasoning: ~azure.ai.voiceagents.models.RealtimeReasoning + :ivar parallel_tool_calls: Whether the model may call multiple tools in parallel. + :vartype parallel_tool_calls: bool + :ivar include: Additional fields to include in service outputs. + :vartype include: list[str or ~azure.ai.voiceagents.models.VoiceAgentSessionIncludeOption] + :ivar metadata: Up to 16 string key-value pairs attached to the session. + :vartype metadata: dict[str, str] + :ivar voice_adaptation: Voice-optimized instruction adaptation settings. + :vartype voice_adaptation: ~azure.ai.voiceagents.models.VoiceAgentVoiceAdaptation + :ivar interim_response: Interim-response settings for latency and tool execution. Is either a + VoiceAgentStaticInterimResponseConfig type or a VoiceAgentLlmInterimResponseConfig type. + :vartype interim_response: ~azure.ai.voiceagents.models.VoiceAgentStaticInterimResponseConfig + or ~azure.ai.voiceagents.models.VoiceAgentLlmInterimResponseConfig + :ivar response_delimiter: A delimiter appended to generated responses. + :vartype response_delimiter: str + :ivar greeting: A proactive assistant greeting started after session configuration. + :vartype greeting: ~azure.ai.voiceagents.models.VoiceGreetingConfig + :ivar handoff: The customer-supplied handoff graph. + :vartype handoff: ~azure.ai.voiceagents.models.VoiceAgentHandoffGraphConfig + """ + + type: Literal["realtime"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The session type. Always ``realtime``. Required. Default value is \"realtime\".""" + instructions: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Instructions applied throughout the session.""" + temperature: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The sampling temperature for compatible cascaded pipelines.""" + max_output_tokens: Optional["_unions.VoiceAgentMaxOutputTokens"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The maximum output-token count for one response. Is either a int type or a Literal[\"inf\"] + type.""" + output_modalities: Optional[list[Union[str, "_models.VoiceOutputModality"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The output modalities enabled for the session.""" + audio: Optional["_models.VoiceAgentSessionUpdateAudio"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The input- and output-audio settings for the session.""" + avatar: Optional["_models.VoiceAgentSessionAvatarConfig"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The avatar settings for the session.""" + animation: Optional["_models.VoiceAgentAnimationConfig"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Animation settings for the session.""" + tools: Optional[list["_unions.VoiceAgentSessionTool"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Tools available to the session.""" + tool_choice: Optional["_unions.VoiceAgentToolChoice"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Tool-selection behavior for the session. Is either a Union[str, \"_models.ToolChoiceOptions\"] + type or a RealtimeToolChoiceFunction type.""" + reasoning: Optional["_models.RealtimeReasoning"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Reasoning settings for compatible realtime models.""" + parallel_tool_calls: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Whether the model may call multiple tools in parallel.""" + include: Optional[list[Union[str, "_models.VoiceAgentSessionIncludeOption"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Additional fields to include in service outputs.""" + metadata: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Up to 16 string key-value pairs attached to the session.""" + voice_adaptation: Optional["_models.VoiceAgentVoiceAdaptation"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Voice-optimized instruction adaptation settings.""" + interim_response: Optional["_unions.VoiceAgentInterimResponse"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Interim-response settings for latency and tool execution. Is either a + VoiceAgentStaticInterimResponseConfig type or a VoiceAgentLlmInterimResponseConfig type.""" + response_delimiter: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """A delimiter appended to generated responses.""" + greeting: Optional["_models.VoiceGreetingConfig"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """A proactive assistant greeting started after session configuration.""" + handoff: Optional["_models.VoiceAgentHandoffGraphConfig"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The customer-supplied handoff graph.""" + + @overload + def __init__( + self, + *, + instructions: Optional[str] = None, + temperature: Optional[float] = None, + max_output_tokens: Optional["_unions.VoiceAgentMaxOutputTokens"] = None, + output_modalities: Optional[list[Union[str, "_models.VoiceOutputModality"]]] = None, + audio: Optional["_models.VoiceAgentSessionUpdateAudio"] = None, + avatar: Optional["_models.VoiceAgentSessionAvatarConfig"] = None, + animation: Optional["_models.VoiceAgentAnimationConfig"] = None, + tools: Optional[list["_unions.VoiceAgentSessionTool"]] = None, + tool_choice: Optional["_unions.VoiceAgentToolChoice"] = None, + reasoning: Optional["_models.RealtimeReasoning"] = None, + parallel_tool_calls: Optional[bool] = None, + include: Optional[list[Union[str, "_models.VoiceAgentSessionIncludeOption"]]] = None, + metadata: Optional[dict[str, str]] = None, + voice_adaptation: Optional["_models.VoiceAgentVoiceAdaptation"] = None, + interim_response: Optional["_unions.VoiceAgentInterimResponse"] = None, + response_delimiter: Optional[str] = None, + greeting: Optional["_models.VoiceGreetingConfig"] = None, + handoff: Optional["_models.VoiceAgentHandoffGraphConfig"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["realtime"] = "realtime" + + +class VoiceAgentStaticInterimResponseConfig( + VoiceAgentInterimResponseConfig, discriminator="static_interim_response" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """A static interim response selected from configured text. + + :ivar triggers: Conditions that may trigger one interim response. + :vartype triggers: list[str or ~azure.ai.voiceagents.models.VoiceAgentInterimResponseTrigger] + :ivar latency_threshold_ms: The latency threshold in milliseconds. + :vartype latency_threshold_ms: int + :ivar type: Required. Default value is "static_interim_response". + :vartype type: str + :ivar texts: Candidate text values for the interim response. + :vartype texts: list[str] + """ + + type: Literal["static_interim_response"] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. Default value is \"static_interim_response\".""" + texts: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Candidate text values for the interim response.""" + + @overload + def __init__( + self, + *, + triggers: Optional[list[Union[str, "_models.VoiceAgentInterimResponseTrigger"]]] = None, + latency_threshold_ms: Optional[int] = None, + texts: Optional[list[str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = "static_interim_response" # type: ignore + + +class VoiceAgentTranscriptionPhrase(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """A transcribed phrase with timing information. + + :ivar offset_milliseconds: The phrase offset from the beginning of the audio, in milliseconds. + Required. + :vartype offset_milliseconds: int + :ivar duration_milliseconds: The phrase duration in milliseconds. Required. + :vartype duration_milliseconds: int + :ivar text: The transcribed phrase text. Required. + :vartype text: str + :ivar words: Word-level timing details, when available. + :vartype words: list[~azure.ai.voiceagents.models.VoiceAgentTranscriptionWord] + :ivar locale: The detected locale. + :vartype locale: str + :ivar confidence: The transcription confidence score. + :vartype confidence: float + """ + + offset_milliseconds: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The phrase offset from the beginning of the audio, in milliseconds. Required.""" + duration_milliseconds: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The phrase duration in milliseconds. Required.""" + text: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The transcribed phrase text. Required.""" + words: Optional[list["_models.VoiceAgentTranscriptionWord"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Word-level timing details, when available.""" + locale: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The detected locale.""" + confidence: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The transcription confidence score.""" + + @overload + def __init__( + self, + *, + offset_milliseconds: int, + duration_milliseconds: int, + text: str, + words: Optional[list["_models.VoiceAgentTranscriptionWord"]] = None, + locale: Optional[str] = None, + confidence: Optional[float] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentTranscriptionWord(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """A time-stamped word in an input-audio transcription. + + :ivar text: The transcribed word text. Required. + :vartype text: str + :ivar offset_milliseconds: The word offset from the beginning of the audio, in milliseconds. + Required. + :vartype offset_milliseconds: int + :ivar duration_milliseconds: The word duration in milliseconds. Required. + :vartype duration_milliseconds: int + """ + + text: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The transcribed word text. Required.""" + offset_milliseconds: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The word offset from the beginning of the audio, in milliseconds. Required.""" + duration_milliseconds: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The word duration in milliseconds. Required.""" + + @overload + def __init__( + self, + *, + text: str, + offset_milliseconds: int, + duration_milliseconds: int, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentVersionObject(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """A voice agent version. Mirrors ``AgentVersionObject``, but its ``definition`` is always a + ``VoiceAgentDefinition``. + + :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.voiceagents.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 draft: Whether this agent version is a draft (candidate) rather than a release. Draft + versions are recorded but excluded from default 'latest' resolution and are not auto-promoted. + Defaults to false. + :vartype draft: bool + :ivar status: The provisioning status of the agent version. Defaults to 'active' for non-hosted + agents. For hosted agents, reflects infrastructure readiness. Known values are: "creating", + "active", "failed", "deleting", and "deleted". + :vartype status: str or ~azure.ai.voiceagents.models.AgentVersionStatus + :ivar instance_identity: The instance identity of the agent. + :vartype instance_identity: ~azure.ai.voiceagents.models.AgentIdentity + :ivar blueprint: The blueprint for the agent. + :vartype blueprint: ~azure.ai.voiceagents.models.AgentIdentity + :ivar blueprint_reference: The blueprint for the agent. + :vartype blueprint_reference: ~azure.ai.voiceagents.models.AgentBlueprintReference + :ivar agent_guid: The unique GUID identifier of the agent. + :vartype agent_guid: str + :ivar definition: The voice agent definition for this version. Required. + :vartype definition: ~azure.ai.voiceagents.models.VoiceAgentDefinition + """ + + metadata: dict[str, str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """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: Literal[AgentObjectType.AGENT_VERSION] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The object type, which is always 'agent.version'. Required. AGENT_VERSION.""" + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique identifier of the agent version. Required.""" + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of the agent. Name can be used to retrieve/update/delete the agent. Required.""" + version: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The version identifier of the agent. Agents are immutable and every update creates a new + version while keeping the name same. Required.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """A human-readable description of the agent.""" + created_at: datetime.datetime = rest_field( + visibility=["read", "create", "update", "delete", "query"], format="unix-timestamp" + ) + """The Unix timestamp (seconds) when the agent was created. Required.""" + draft: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Whether this agent version is a draft (candidate) rather than a release. Draft versions are + recorded but excluded from default 'latest' resolution and are not auto-promoted. Defaults to + false.""" + status: Optional[Union[str, "_models.AgentVersionStatus"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The provisioning status of the agent version. Defaults to 'active' for non-hosted agents. For + hosted agents, reflects infrastructure readiness. Known values are: \"creating\", \"active\", + \"failed\", \"deleting\", and \"deleted\".""" + instance_identity: Optional["_models.AgentIdentity"] = rest_field(visibility=["read"]) + """The instance identity of the agent.""" + blueprint: Optional["_models.AgentIdentity"] = rest_field(visibility=["read"]) + """The blueprint for the agent.""" + blueprint_reference: Optional["_models.AgentBlueprintReference"] = rest_field(visibility=["read"]) + """The blueprint for the agent.""" + agent_guid: Optional[str] = rest_field(visibility=["read"]) + """The unique GUID identifier of the agent.""" + definition: "_models.VoiceAgentDefinition" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The voice agent definition for this version. Required.""" + + @overload + def __init__( + self, + *, + metadata: dict[str, str], + object: Literal[AgentObjectType.AGENT_VERSION], + id: str, # pylint: disable=redefined-builtin + name: str, + version: str, + created_at: datetime.datetime, + definition: "_models.VoiceAgentDefinition", + description: Optional[str] = None, + draft: Optional[bool] = None, + status: Optional[Union[str, "_models.AgentVersionStatus"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAgentVoiceAdaptation(_Model): # pylint: disable=docstring-missing-param + """Voice-optimized instruction adaptation settings. + + :ivar type: The adaptation strategy. Always ``auto``. Required. Default value is "auto". + :vartype type: str + """ + + type: Literal["auto"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The adaptation strategy. Always ``auto``. Required. Default value is \"auto\".""" + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["auto"] = "auto" + + +class VoiceAgentWebSearchActionFind(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """An action that finds text on a web page. + + :ivar type: Required. Default value is "find". + :vartype type: str + :ivar pattern: Required. + :vartype pattern: str + :ivar url: Required. + :vartype url: str + """ + + type: Literal["find"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required. Default value is \"find\".""" + pattern: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + url: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + + @overload + def __init__( + self, + *, + pattern: str, + url: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["find"] = "find" + + +class VoiceAgentWebSearchActionOpenPage(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """An action that opens a web page. + + :ivar type: Required. Default value is "open_page". + :vartype type: str + :ivar url: Required. + :vartype url: str + """ + + type: Literal["open_page"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required. Default value is \"open_page\".""" + url: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + + @overload + def __init__( + self, + *, + url: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["open_page"] = "open_page" + + +class VoiceAgentWebSearchActionSearch(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """A web search action. + + :ivar type: Required. Default value is "search". + :vartype type: str + :ivar query: Required. + :vartype query: str + :ivar sources: + :vartype sources: list[~azure.ai.voiceagents.models.VoiceAgentWebSearchSource] + """ + + type: Literal["search"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required. Default value is \"search\".""" + query: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + sources: Optional[list["_models.VoiceAgentWebSearchSource"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + query: str, + sources: Optional[list["_models.VoiceAgentWebSearchSource"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["search"] = "search" + + +class VoiceAgentWebSearchCallItem(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """A web-search output item. + + :ivar id: Required. + :vartype id: str + :ivar type: Required. Default value is "web_search_call". + :vartype type: str + :ivar status: Required. Known values are: "in_progress", "searching", "completed", and + "failed". + :vartype status: str or ~azure.ai.voiceagents.models.VoiceAgentWebSearchCallStatus + :ivar action: Is one of the following types: VoiceAgentWebSearchActionSearch, + VoiceAgentWebSearchActionOpenPage, VoiceAgentWebSearchActionFind + :vartype action: ~azure.ai.voiceagents.models.VoiceAgentWebSearchActionSearch or + ~azure.ai.voiceagents.models.VoiceAgentWebSearchActionOpenPage or + ~azure.ai.voiceagents.models.VoiceAgentWebSearchActionFind + """ + + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + type: Literal["web_search_call"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required. Default value is \"web_search_call\".""" + status: Union[str, "_models.VoiceAgentWebSearchCallStatus"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Required. Known values are: \"in_progress\", \"searching\", \"completed\", and \"failed\".""" + action: Optional["_unions.VoiceAgentWebSearchAction"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Is one of the following types: VoiceAgentWebSearchActionSearch, + VoiceAgentWebSearchActionOpenPage, VoiceAgentWebSearchActionFind""" + + @overload + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + status: Union[str, "_models.VoiceAgentWebSearchCallStatus"], + action: Optional["_unions.VoiceAgentWebSearchAction"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["web_search_call"] = "web_search_call" + + +class VoiceAgentWebSearchSource(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """A web-search source URL. + + :ivar type: Required. Default value is "url". + :vartype type: str + :ivar url: Required. + :vartype url: str + """ + + type: Literal["url"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required. Default value is \"url\".""" + url: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + + @overload + def __init__( + self, + *, + url: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["url"] = "url" + + +class VoiceAgentWorkflowActionItem(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """A workflow action output item. + + :ivar id: Required. + :vartype id: str + :ivar object: Default value is "realtime.item". + :vartype object: str + :ivar type: Required. Default value is "workflow_action". + :vartype type: str + :ivar action_id: Required. + :vartype action_id: str + :ivar status: Required. + :vartype status: str + :ivar kind: + :vartype kind: str + :ivar parent_action_id: + :vartype parent_action_id: str + :ivar previous_action_id: + :vartype previous_action_id: str + """ + + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + object: Optional[Literal["realtime.item"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Default value is \"realtime.item\".""" + type: Literal["workflow_action"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required. Default value is \"workflow_action\".""" + action_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + status: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + kind: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + parent_action_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + previous_action_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + action_id: str, + status: str, + object: Optional[Literal["realtime.item"]] = None, + kind: Optional[str] = None, + parent_action_id: Optional[str] = None, + previous_action_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["workflow_action"] = "workflow_action" + + +class VoiceConversationItem(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """A persisted item in a voice conversation. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + VoiceFunctionCallItem, VoiceFunctionCallOutputItem, VoiceMcpApprovalRequestItem, + VoiceMcpApprovalResponseItem, VoiceMcpCallItem, VoiceMcpListToolsItem, VoiceMessageItem + + :ivar type: The type of the conversation item. Required. Known values are: "message", + "function_call", "function_call_output", "mcp_list_tools", "mcp_call", "mcp_approval_request", + and "mcp_approval_response". + :vartype type: str or ~azure.ai.voiceagents.models.VoiceConversationItemType + :ivar created_at: The Unix timestamp (in seconds) for when the item was persisted. + :vartype created_at: ~datetime.datetime + :ivar response_id: The id of the response that produced this item, when applicable. + :vartype response_id: str + """ + + __mapping__: dict[str, _Model] = {} + type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) + """The type of the conversation item. Required. Known values are: \"message\", \"function_call\", + \"function_call_output\", \"mcp_list_tools\", \"mcp_call\", \"mcp_approval_request\", and + \"mcp_approval_response\".""" + created_at: Optional[datetime.datetime] = rest_field( + visibility=["read", "create", "update", "delete", "query"], format="unix-timestamp" + ) + """The Unix timestamp (in seconds) for when the item was persisted.""" + response_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The id of the response that produced this item, when applicable.""" + + @overload + def __init__( + self, + *, + type: str, + created_at: Optional[datetime.datetime] = None, + response_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceMessageItem( + VoiceConversationItem, discriminator="message" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """A persisted message item in a voice conversation. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + VoiceAssistantMessageItem, VoiceSystemMessageItem, VoiceUserMessageItem + + :ivar created_at: The Unix timestamp (in seconds) for when the item was persisted. + :vartype created_at: ~datetime.datetime + :ivar response_id: The id of the response that produced this item, when applicable. + :vartype response_id: str + :ivar type: Required. A message item. + :vartype type: str or ~azure.ai.voiceagents.models.MESSAGE + :ivar role: The role of the message sender. Required. Known values are: "system", "user", and + "assistant". + :vartype role: str or ~azure.ai.voiceagents.models.RealtimeConversationItemMessageType + """ + + __mapping__: dict[str, _Model] = {} + type: Literal[VoiceConversationItemType.MESSAGE] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. A message item.""" + role: str = rest_discriminator(name="role", visibility=["read", "create", "update", "delete", "query"]) + """The role of the message sender. Required. Known values are: \"system\", \"user\", and + \"assistant\".""" + + @overload + def __init__( + self, + *, + role: str, + created_at: Optional[datetime.datetime] = None, + response_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = VoiceConversationItemType.MESSAGE # type: ignore + + +class VoiceAssistantMessageItem( + VoiceMessageItem, discriminator="assistant" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """An assistant message item. Only ``output_text`` and ``output_audio`` content are valid for + assistant messages. + + :ivar created_at: The Unix timestamp (in seconds) for when the item was persisted. + :vartype created_at: ~datetime.datetime + :ivar response_id: The id of the response that produced this item, when applicable. + :vartype response_id: str + :ivar type: Required. A message item. + :vartype type: str or ~azure.ai.voiceagents.models.MESSAGE + :ivar id: The unique ID of the item. This may be provided by the client or generated by the + server. + :vartype id: str + :ivar object: Identifier for the API object being returned - always ``realtime.item``. Optional + when creating a new item. Default value is "realtime.item". + :vartype object: str + :ivar status: The status of the item. Has no effect on the conversation. Is one of the + following types: Literal["completed"], Literal["incomplete"], Literal["in_progress"] + :vartype status: str or str or str + :ivar content: The content of the message. Required. + :vartype content: + list[~azure.ai.voiceagents.models.RealtimeConversationItemMessageAssistantContent] + :ivar role: Required. ASSISTANT. + :vartype role: str or ~azure.ai.voiceagents.models.ASSISTANT + """ + + __mapping__: dict[str, _Model] = {} + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the item. This may be provided by the client or generated by the server.""" + object: Optional[Literal["realtime.item"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Identifier for the API object being returned - always ``realtime.item``. Optional when creating + a new item. Default value is \"realtime.item\".""" + status: Optional[Literal["completed", "incomplete", "in_progress"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The status of the item. Has no effect on the conversation. Is one of the following types: + Literal[\"completed\"], Literal[\"incomplete\"], Literal[\"in_progress\"]""" + content: list["_models.RealtimeConversationItemMessageAssistantContent"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The content of the message. Required.""" + role: Literal[RealtimeConversationItemMessageType.ASSISTANT] = rest_discriminator(name="role", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. ASSISTANT.""" + + @overload + def __init__( + self, + *, + content: list["_models.RealtimeConversationItemMessageAssistantContent"], + created_at: Optional[datetime.datetime] = None, + response_id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + object: Optional[Literal["realtime.item"]] = None, + status: Optional[Literal["completed", "incomplete", "in_progress"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.role = RealtimeConversationItemMessageType.ASSISTANT # type: ignore + + +class VoiceAudioConfig(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """The audio configuration for a voice agent. These values are session defaults and may be + overridden when connecting. + + :ivar input: Input (microphone) audio configuration. + :vartype input: ~azure.ai.voiceagents.models.VoiceAudioInputConfig + :ivar output: Output (agent speech) audio configuration. + :vartype output: ~azure.ai.voiceagents.models.VoiceAudioOutputConfig + """ + + input: Optional["_models.VoiceAudioInputConfig"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Input (microphone) audio configuration.""" + output: Optional["_models.VoiceAudioOutputConfig"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Output (agent speech) audio configuration.""" + + @overload + def __init__( + self, + *, + input: Optional["_models.VoiceAudioInputConfig"] = None, + output: Optional["_models.VoiceAudioOutputConfig"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAudioFormat(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """An audio format. Follows the OpenAI Realtime session schema; ``type`` carries the media + subtype. + + :ivar type: The audio format type, e.g. 'audio/pcm' (16-bit PCM), 'audio/pcmu' (G.711 mu-law), + or 'audio/pcma' (G.711 A-law). Required. Known values are: "audio/pcm", "audio/pcmu", and + "audio/pcma". + :vartype type: str or ~azure.ai.voiceagents.models.VoiceAudioFormatType + :ivar rate: The sample rate in Hz. Applies to 'audio/pcm' (e.g. 24000); omit for telephony + G.711 formats (8 kHz). + :vartype rate: int + """ + + type: Union[str, "_models.VoiceAudioFormatType"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The audio format type, e.g. 'audio/pcm' (16-bit PCM), 'audio/pcmu' (G.711 mu-law), or + 'audio/pcma' (G.711 A-law). Required. Known values are: \"audio/pcm\", \"audio/pcmu\", and + \"audio/pcma\".""" + rate: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The sample rate in Hz. Applies to 'audio/pcm' (e.g. 24000); omit for telephony G.711 formats (8 + kHz).""" + + @overload + def __init__( + self, + *, + type: Union[str, "_models.VoiceAudioFormatType"], + rate: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAudioInputConfig(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Input audio configuration for a voice agent. + + :ivar format: The input audio format. + :vartype format: ~azure.ai.voiceagents.models.VoiceAudioFormat + :ivar noise_reduction: Input noise reduction. Set to null to disable. + :vartype noise_reduction: ~azure.ai.voiceagents.models.VoiceNoiseReduction + :ivar turn_detection: Turn (end-of-speech) detection. Server-side turn detection is enabled by + default; set to null to disable it, in which case the client must trigger responses manually. + :vartype turn_detection: ~azure.ai.voiceagents.models.VoiceTurnDetection + :ivar transcription: Asynchronous input-audio transcription. Set to null to disable + transcription. + :vartype transcription: ~azure.ai.voiceagents.models.VoiceInputTranscription + """ + + format: Optional["_models.VoiceAudioFormat"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The input audio format.""" + noise_reduction: Optional["_models.VoiceNoiseReduction"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Input noise reduction. Set to null to disable.""" + turn_detection: Optional["_models.VoiceTurnDetection"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Turn (end-of-speech) detection. Server-side turn detection is enabled by default; set to null + to disable it, in which case the client must trigger responses manually.""" + transcription: Optional["_models.VoiceInputTranscription"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Asynchronous input-audio transcription. Set to null to disable transcription.""" + + @overload + def __init__( + self, + *, + format: Optional["_models.VoiceAudioFormat"] = None, + noise_reduction: Optional["_models.VoiceNoiseReduction"] = None, + turn_detection: Optional["_models.VoiceTurnDetection"] = None, + transcription: Optional["_models.VoiceInputTranscription"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAudioOutputConfig(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Output audio configuration for a voice agent. + + :ivar format: The output audio format. + :vartype format: ~azure.ai.voiceagents.models.VoiceAudioFormat + :ivar voice: The typed voice configuration. Is one of the following types: OpenAIVoice, + AzureVoice, AzureRealtimeNativeVoice + :vartype voice: ~azure.ai.voiceagents.models.OpenAIVoice or + ~azure.ai.voiceagents.models.AzureVoice or + ~azure.ai.voiceagents.models.AzureRealtimeNativeVoice + :ivar speed: The OpenAI-compatible speaking speed multiplier, from 0.25 to 1.5. Defaults to 1. + For Azure synthesized voices, use ``voice.rate`` instead. + :vartype speed: float + :ivar output_audio_timestamp_types: Timestamp kinds to include with output audio. + :vartype output_audio_timestamp_types: list[str or + ~azure.ai.voiceagents.models.VoiceAudioTimestampType] + """ + + format: Optional["_models.VoiceAudioFormat"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The output audio format.""" + voice: Optional["_unions.VoiceAgentVoice"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The typed voice configuration. Is one of the following types: OpenAIVoice, AzureVoice, + AzureRealtimeNativeVoice""" + speed: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The OpenAI-compatible speaking speed multiplier, from 0.25 to 1.5. Defaults to 1. For Azure + synthesized voices, use ``voice.rate`` instead.""" + output_audio_timestamp_types: Optional[list[Union[str, "_models.VoiceAudioTimestampType"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Timestamp kinds to include with output audio.""" + + @overload + def __init__( + self, + *, + format: Optional["_models.VoiceAudioFormat"] = None, + voice: Optional["_unions.VoiceAgentVoice"] = None, + speed: Optional[float] = None, + output_audio_timestamp_types: Optional[list[Union[str, "_models.VoiceAudioTimestampType"]]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAvatarConfig(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Avatar configuration for a voice agent. These values are session defaults and may be overridden + when connecting. + + :ivar type: The avatar type. Required. Known values are: "video_avatar" and "photo_avatar". + :vartype type: str or ~azure.ai.voiceagents.models.VoiceAvatarType + :ivar character: The avatar character identifier, e.g. 'lisa'. Required. + :vartype character: str + :ivar style: The avatar style, e.g. 'casual-sitting'. + :vartype style: str + :ivar customized: Whether the avatar is a customer-customized avatar. Defaults to false. + :vartype customized: bool + :ivar output_protocol: The transport used to deliver the avatar video stream. Known values are: + "webrtc" and "websocket". + :vartype output_protocol: str or ~azure.ai.voiceagents.models.VoiceAvatarOutputProtocol + """ + + type: Union[str, "_models.VoiceAvatarType"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The avatar type. Required. Known values are: \"video_avatar\" and \"photo_avatar\".""" + character: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The avatar character identifier, e.g. 'lisa'. Required.""" + style: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The avatar style, e.g. 'casual-sitting'.""" + customized: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Whether the avatar is a customer-customized avatar. Defaults to false.""" + output_protocol: Optional[Union[str, "_models.VoiceAvatarOutputProtocol"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The transport used to deliver the avatar video stream. Known values are: \"webrtc\" and + \"websocket\".""" + + @overload + def __init__( + self, + *, + type: Union[str, "_models.VoiceAvatarType"], + character: str, + style: Optional[str] = None, + customized: Optional[bool] = None, + output_protocol: Optional[Union[str, "_models.VoiceAvatarOutputProtocol"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceEndOfUtteranceDetection(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Semantic end-of-utterance detection configuration. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + VoiceAzureSemanticDetection, VoiceAzureSemanticDetectionEn, + VoiceAzureSemanticDetectionMultilingual + + :ivar model: The semantic detection model. Required. Known values are: "semantic_detection_v1", + "semantic_detection_v1_en", and "semantic_detection_v1_multilingual". + :vartype model: str or ~azure.ai.voiceagents.models.VoiceEndOfUtteranceDetectionModel + """ + + __mapping__: dict[str, _Model] = {} + model: str = rest_discriminator(name="model", visibility=["read", "create", "update", "delete", "query"]) + """The semantic detection model. Required. Known values are: \"semantic_detection_v1\", + \"semantic_detection_v1_en\", and \"semantic_detection_v1_multilingual\".""" + + @overload + def __init__( + self, + *, + model: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAzureSemanticDetection( + VoiceEndOfUtteranceDetection, discriminator="semantic_detection_v1" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """Default Azure semantic end-of-utterance detection. + + :ivar model: Required. The default semantic detection model. + :vartype model: str or ~azure.ai.voiceagents.models.SEMANTIC_DETECTION_V1 + :ivar threshold_level: The sensitivity threshold. Known values are: "low", "medium", "high", + and "default". + :vartype threshold_level: str or ~azure.ai.voiceagents.models.VoiceEndOfUtteranceThresholdLevel + :ivar timeout_ms: The detection timeout in milliseconds. + :vartype timeout_ms: int + """ + + model: Literal[VoiceEndOfUtteranceDetectionModel.SEMANTIC_DETECTION_V1] = rest_discriminator(name="model", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. The default semantic detection model.""" + threshold_level: Optional[Union[str, "_models.VoiceEndOfUtteranceThresholdLevel"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The sensitivity threshold. Known values are: \"low\", \"medium\", \"high\", and \"default\".""" + timeout_ms: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The detection timeout in milliseconds.""" + + @overload + def __init__( + self, + *, + threshold_level: Optional[Union[str, "_models.VoiceEndOfUtteranceThresholdLevel"]] = None, + timeout_ms: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.model = VoiceEndOfUtteranceDetectionModel.SEMANTIC_DETECTION_V1 # type: ignore + + +class VoiceAzureSemanticDetectionEn( + VoiceEndOfUtteranceDetection, discriminator="semantic_detection_v1_en" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """English-optimized Azure semantic end-of-utterance detection. + + :ivar model: Required. The English-optimized semantic detection model. + :vartype model: str or ~azure.ai.voiceagents.models.SEMANTIC_DETECTION_V1_EN + :ivar threshold_level: The sensitivity threshold. Known values are: "low", "medium", "high", + and "default". + :vartype threshold_level: str or ~azure.ai.voiceagents.models.VoiceEndOfUtteranceThresholdLevel + :ivar timeout_ms: The detection timeout in milliseconds. + :vartype timeout_ms: int + """ + + model: Literal[VoiceEndOfUtteranceDetectionModel.SEMANTIC_DETECTION_V1_EN] = rest_discriminator(name="model", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. The English-optimized semantic detection model.""" + threshold_level: Optional[Union[str, "_models.VoiceEndOfUtteranceThresholdLevel"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The sensitivity threshold. Known values are: \"low\", \"medium\", \"high\", and \"default\".""" + timeout_ms: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The detection timeout in milliseconds.""" + + @overload + def __init__( + self, + *, + threshold_level: Optional[Union[str, "_models.VoiceEndOfUtteranceThresholdLevel"]] = None, + timeout_ms: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.model = VoiceEndOfUtteranceDetectionModel.SEMANTIC_DETECTION_V1_EN # type: ignore + + +class VoiceAzureSemanticDetectionMultilingual( + VoiceEndOfUtteranceDetection, discriminator="semantic_detection_v1_multilingual" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """Multilingual Azure semantic end-of-utterance detection. + + :ivar model: Required. The multilingual semantic detection model. + :vartype model: str or ~azure.ai.voiceagents.models.SEMANTIC_DETECTION_V1_MULTILINGUAL + :ivar threshold_level: The sensitivity threshold. Known values are: "low", "medium", "high", + and "default". + :vartype threshold_level: str or ~azure.ai.voiceagents.models.VoiceEndOfUtteranceThresholdLevel + :ivar timeout_ms: The detection timeout in milliseconds. + :vartype timeout_ms: int + """ + + model: Literal[VoiceEndOfUtteranceDetectionModel.SEMANTIC_DETECTION_V1_MULTILINGUAL] = rest_discriminator(name="model", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. The multilingual semantic detection model.""" + threshold_level: Optional[Union[str, "_models.VoiceEndOfUtteranceThresholdLevel"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The sensitivity threshold. Known values are: \"low\", \"medium\", \"high\", and \"default\".""" + timeout_ms: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The detection timeout in milliseconds.""" + + @overload + def __init__( + self, + *, + threshold_level: Optional[Union[str, "_models.VoiceEndOfUtteranceThresholdLevel"]] = None, + timeout_ms: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.model = VoiceEndOfUtteranceDetectionModel.SEMANTIC_DETECTION_V1_MULTILINGUAL # type: ignore + + +class VoiceTurnDetection(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Turn-detection configuration for a voice agent. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + VoiceAzureSemanticVadTurnDetection, VoiceAzureSemanticVadEnTurnDetection, + VoiceAzureSemanticVadMultilingualTurnDetection, VoiceSemanticVadTurnDetection, + VoiceServerVadTurnDetection + + :ivar type: The turn-detection strategy. Required. Known values are: "server_vad", + "semantic_vad", "azure_semantic_vad", "azure_semantic_vad_en", and + "azure_semantic_vad_multilingual". + :vartype type: str or ~azure.ai.voiceagents.models.VoiceTurnDetectionType + """ + + __mapping__: dict[str, _Model] = {} + type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) + """The turn-detection strategy. Required. Known values are: \"server_vad\", \"semantic_vad\", + \"azure_semantic_vad\", \"azure_semantic_vad_en\", and \"azure_semantic_vad_multilingual\".""" + + @overload + def __init__( + self, + *, + type: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceAzureSemanticVadEnTurnDetection( + VoiceTurnDetection, discriminator="azure_semantic_vad_en" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """English-optimized Azure semantic voice activity detection. + + :ivar type: Required. English-optimized Azure semantic voice activity detection. + :vartype type: str or ~azure.ai.voiceagents.models.AZURE_SEMANTIC_VAD_EN + :ivar threshold: Activation threshold for voice activity detection, from 0 to 1. + :vartype threshold: float + :ivar prefix_padding_ms: Audio to include before detected speech, in milliseconds. + :vartype prefix_padding_ms: int + :ivar silence_duration_ms: Silence required to end speech detection, in milliseconds. + :vartype silence_duration_ms: int + :ivar end_of_utterance_detection: Semantic end-of-utterance detection configuration. + :vartype end_of_utterance_detection: ~azure.ai.voiceagents.models.VoiceEndOfUtteranceDetection + :ivar speech_duration_ms: Minimum speech duration required to trigger detection, in + milliseconds. + :vartype speech_duration_ms: int + :ivar remove_filler_words: Whether filler words are removed from transcription. + :vartype remove_filler_words: bool + :ivar auto_truncate: Whether the input audio buffer is truncated automatically when speech + stops. + :vartype auto_truncate: bool + :ivar create_response: Whether a response is created automatically when speech stops. + :vartype create_response: bool + :ivar interrupt_response: Whether user speech may interrupt the agent's response. + :vartype interrupt_response: bool + """ + + type: Literal[VoiceTurnDetectionType.AZURE_SEMANTIC_VAD_EN] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. English-optimized Azure semantic voice activity detection.""" + threshold: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Activation threshold for voice activity detection, from 0 to 1.""" + prefix_padding_ms: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Audio to include before detected speech, in milliseconds.""" + silence_duration_ms: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Silence required to end speech detection, in milliseconds.""" + end_of_utterance_detection: Optional["_models.VoiceEndOfUtteranceDetection"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Semantic end-of-utterance detection configuration.""" + speech_duration_ms: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Minimum speech duration required to trigger detection, in milliseconds.""" + remove_filler_words: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Whether filler words are removed from transcription.""" + auto_truncate: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Whether the input audio buffer is truncated automatically when speech stops.""" + create_response: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Whether a response is created automatically when speech stops.""" + interrupt_response: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Whether user speech may interrupt the agent's response.""" + + @overload + def __init__( + self, + *, + threshold: Optional[float] = None, + prefix_padding_ms: Optional[int] = None, + silence_duration_ms: Optional[int] = None, + end_of_utterance_detection: Optional["_models.VoiceEndOfUtteranceDetection"] = None, + speech_duration_ms: Optional[int] = None, + remove_filler_words: Optional[bool] = None, + auto_truncate: Optional[bool] = None, + create_response: Optional[bool] = None, + interrupt_response: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = VoiceTurnDetectionType.AZURE_SEMANTIC_VAD_EN # type: ignore + + +class VoiceAzureSemanticVadMultilingualTurnDetection( + VoiceTurnDetection, discriminator="azure_semantic_vad_multilingual" +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """Multilingual Azure semantic voice activity detection. + + :ivar type: Required. Multilingual Azure semantic voice activity detection. + :vartype type: str or ~azure.ai.voiceagents.models.AZURE_SEMANTIC_VAD_MULTILINGUAL + :ivar threshold: Activation threshold for voice activity detection, from 0 to 1. + :vartype threshold: float + :ivar prefix_padding_ms: Audio to include before detected speech, in milliseconds. + :vartype prefix_padding_ms: int + :ivar silence_duration_ms: Silence required to end speech detection, in milliseconds. + :vartype silence_duration_ms: int + :ivar end_of_utterance_detection: Semantic end-of-utterance detection configuration. + :vartype end_of_utterance_detection: ~azure.ai.voiceagents.models.VoiceEndOfUtteranceDetection + :ivar speech_duration_ms: Minimum speech duration required to trigger detection, in + milliseconds. + :vartype speech_duration_ms: int + :ivar remove_filler_words: Whether filler words are removed from transcription. + :vartype remove_filler_words: bool + :ivar auto_truncate: Whether the input audio buffer is truncated automatically when speech + stops. + :vartype auto_truncate: bool + :ivar create_response: Whether a response is created automatically when speech stops. + :vartype create_response: bool + :ivar interrupt_response: Whether user speech may interrupt the agent's response. + :vartype interrupt_response: bool + :ivar languages: BCP-47 language codes used for speech detection. + :vartype languages: list[str] + """ + + type: Literal[VoiceTurnDetectionType.AZURE_SEMANTIC_VAD_MULTILINGUAL] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. Multilingual Azure semantic voice activity detection.""" + threshold: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Activation threshold for voice activity detection, from 0 to 1.""" + prefix_padding_ms: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Audio to include before detected speech, in milliseconds.""" + silence_duration_ms: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Silence required to end speech detection, in milliseconds.""" + end_of_utterance_detection: Optional["_models.VoiceEndOfUtteranceDetection"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Semantic end-of-utterance detection configuration.""" + speech_duration_ms: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Minimum speech duration required to trigger detection, in milliseconds.""" + remove_filler_words: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Whether filler words are removed from transcription.""" + auto_truncate: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Whether the input audio buffer is truncated automatically when speech stops.""" + create_response: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Whether a response is created automatically when speech stops.""" + interrupt_response: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Whether user speech may interrupt the agent's response.""" + languages: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """BCP-47 language codes used for speech detection.""" + + @overload + def __init__( + self, + *, + threshold: Optional[float] = None, + prefix_padding_ms: Optional[int] = None, + silence_duration_ms: Optional[int] = None, + end_of_utterance_detection: Optional["_models.VoiceEndOfUtteranceDetection"] = None, + speech_duration_ms: Optional[int] = None, + remove_filler_words: Optional[bool] = None, + auto_truncate: Optional[bool] = None, + create_response: Optional[bool] = None, + interrupt_response: Optional[bool] = None, + languages: Optional[list[str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = VoiceTurnDetectionType.AZURE_SEMANTIC_VAD_MULTILINGUAL # type: ignore + + +class VoiceAzureSemanticVadTurnDetection( + VoiceTurnDetection, discriminator="azure_semantic_vad" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """Azure semantic voice activity detection. + + :ivar type: Required. Azure semantic voice activity detection. + :vartype type: str or ~azure.ai.voiceagents.models.AZURE_SEMANTIC_VAD + :ivar threshold: Activation threshold for voice activity detection, from 0 to 1. + :vartype threshold: float + :ivar prefix_padding_ms: Audio to include before detected speech, in milliseconds. + :vartype prefix_padding_ms: int + :ivar silence_duration_ms: Silence required to end speech detection, in milliseconds. + :vartype silence_duration_ms: int + :ivar end_of_utterance_detection: Semantic end-of-utterance detection configuration. + :vartype end_of_utterance_detection: ~azure.ai.voiceagents.models.VoiceEndOfUtteranceDetection + :ivar speech_duration_ms: Minimum speech duration required to trigger detection, in + milliseconds. + :vartype speech_duration_ms: int + :ivar remove_filler_words: Whether filler words are removed from transcription. + :vartype remove_filler_words: bool + :ivar auto_truncate: Whether the input audio buffer is truncated automatically when speech + stops. + :vartype auto_truncate: bool + :ivar create_response: Whether a response is created automatically when speech stops. + :vartype create_response: bool + :ivar interrupt_response: Whether user speech may interrupt the agent's response. + :vartype interrupt_response: bool + :ivar languages: BCP-47 language codes used for speech detection. + :vartype languages: list[str] + """ + + type: Literal[VoiceTurnDetectionType.AZURE_SEMANTIC_VAD] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. Azure semantic voice activity detection.""" + threshold: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Activation threshold for voice activity detection, from 0 to 1.""" + prefix_padding_ms: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Audio to include before detected speech, in milliseconds.""" + silence_duration_ms: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Silence required to end speech detection, in milliseconds.""" + end_of_utterance_detection: Optional["_models.VoiceEndOfUtteranceDetection"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Semantic end-of-utterance detection configuration.""" + speech_duration_ms: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Minimum speech duration required to trigger detection, in milliseconds.""" + remove_filler_words: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Whether filler words are removed from transcription.""" + auto_truncate: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Whether the input audio buffer is truncated automatically when speech stops.""" + create_response: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Whether a response is created automatically when speech stops.""" + interrupt_response: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Whether user speech may interrupt the agent's response.""" + languages: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """BCP-47 language codes used for speech detection.""" + + @overload + def __init__( + self, + *, + threshold: Optional[float] = None, + prefix_padding_ms: Optional[int] = None, + silence_duration_ms: Optional[int] = None, + end_of_utterance_detection: Optional["_models.VoiceEndOfUtteranceDetection"] = None, + speech_duration_ms: Optional[int] = None, + remove_filler_words: Optional[bool] = None, + auto_truncate: Optional[bool] = None, + create_response: Optional[bool] = None, + interrupt_response: Optional[bool] = None, + languages: Optional[list[str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = VoiceTurnDetectionType.AZURE_SEMANTIC_VAD # type: ignore + + +class VoiceConversation(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """A persisted voice conversation. The Foundry envelope that owns a voice agent's stored + transcript, responses, per-turn metrics, and audio. It is the parent, retention, and delete + boundary: deleting it cascades to its responses, items, metrics, and audio. + + :ivar id: The unique id of the conversation. Required. + :vartype id: str + :ivar object: The object type. Always ``voice.conversation``. Required. Default value is + "voice.conversation". + :vartype object: str + :ivar status: The lifecycle status of the conversation. Required. Known values are: + "in_progress" and "completed". + :vartype status: str or ~azure.ai.voiceagents.models.VoiceConversationStatus + :ivar created_at: The Unix timestamp (in seconds) for when the conversation was created. + Required. + :vartype created_at: ~datetime.datetime + :ivar completed_at: The Unix timestamp (in seconds) for when the conversation's session ended. + Absent while in progress. + :vartype completed_at: ~datetime.datetime + :ivar metadata: A set of key-value pairs attached to the conversation. + :vartype metadata: dict[str, str] + :ivar usage: Aggregate token usage totals across all responses in this conversation. + :vartype usage: ~azure.ai.voiceagents.models.RealtimeResponseUsage + """ + + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique id of the conversation. Required.""" + object: Literal["voice.conversation"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The object type. Always ``voice.conversation``. Required. Default value is + \"voice.conversation\".""" + status: Union[str, "_models.VoiceConversationStatus"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The lifecycle status of the conversation. Required. Known values are: \"in_progress\" and + \"completed\".""" + created_at: datetime.datetime = rest_field( + visibility=["read", "create", "update", "delete", "query"], format="unix-timestamp" + ) + """The Unix timestamp (in seconds) for when the conversation was created. Required.""" + completed_at: Optional[datetime.datetime] = rest_field( + visibility=["read", "create", "update", "delete", "query"], format="unix-timestamp" + ) + """The Unix timestamp (in seconds) for when the conversation's session ended. Absent while in + progress.""" + metadata: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """A set of key-value pairs attached to the conversation.""" + usage: Optional["_models.RealtimeResponseUsage"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Aggregate token usage totals across all responses in this conversation.""" + + @overload + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + status: Union[str, "_models.VoiceConversationStatus"], + created_at: datetime.datetime, + completed_at: Optional[datetime.datetime] = None, + metadata: Optional[dict[str, str]] = None, + usage: Optional["_models.RealtimeResponseUsage"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.object: Literal["voice.conversation"] = "voice.conversation" + + +class VoiceFunctionCallItem( + VoiceConversationItem, discriminator="function_call" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """A function call request item. + + :ivar created_at: The Unix timestamp (in seconds) for when the item was persisted. + :vartype created_at: ~datetime.datetime + :ivar response_id: The id of the response that produced this item, when applicable. + :vartype response_id: str + :ivar id: The unique ID of the item. This may be provided by the client or generated by the + server. + :vartype id: str + :ivar object: Identifier for the API object being returned - always ``realtime.item``. Optional + when creating a new item. Default value is "realtime.item". + :vartype object: str + :ivar status: The status of the item. Has no effect on the conversation. Is one of the + following types: Literal["completed"], Literal["incomplete"], Literal["in_progress"] + :vartype status: str or str or str + :ivar call_id: The ID of the function call. + :vartype call_id: str + :ivar name: The name of the function being called. Required. + :vartype name: str + :ivar arguments: The arguments of the function call. This is a JSON-encoded string representing + the arguments passed to the function, for example ``{"arg1": "value1", "arg2": 42}``. Required. + :vartype arguments: str + :ivar type: Required. A function-call request item. + :vartype type: str or ~azure.ai.voiceagents.models.FUNCTION_CALL + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the item. This may be provided by the client or generated by the server.""" + object: Optional[Literal["realtime.item"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Identifier for the API object being returned - always ``realtime.item``. Optional when creating + a new item. Default value is \"realtime.item\".""" + status: Optional[Literal["completed", "incomplete", "in_progress"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The status of the item. Has no effect on the conversation. Is one of the following types: + Literal[\"completed\"], Literal[\"incomplete\"], Literal[\"in_progress\"]""" + call_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the function call.""" + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of the function being called. Required.""" + arguments: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The arguments of the function call. This is a JSON-encoded string representing the arguments + passed to the function, for example ``{\"arg1\": \"value1\", \"arg2\": 42}``. Required.""" + type: Literal[VoiceConversationItemType.FUNCTION_CALL] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. A function-call request item.""" + + @overload + def __init__( + self, + *, + name: str, + arguments: str, + created_at: Optional[datetime.datetime] = None, + response_id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + object: Optional[Literal["realtime.item"]] = None, + status: Optional[Literal["completed", "incomplete", "in_progress"]] = None, + call_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = VoiceConversationItemType.FUNCTION_CALL # type: ignore + + +class VoiceFunctionCallOutputItem( + VoiceConversationItem, discriminator="function_call_output" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """A function call output item. + + :ivar created_at: The Unix timestamp (in seconds) for when the item was persisted. + :vartype created_at: ~datetime.datetime + :ivar response_id: The id of the response that produced this item, when applicable. + :vartype response_id: str + :ivar id: The unique ID of the item. This may be provided by the client or generated by the + server. + :vartype id: str + :ivar object: Identifier for the API object being returned - always ``realtime.item``. Optional + when creating a new item. Default value is "realtime.item". + :vartype object: str + :ivar status: The status of the item. Has no effect on the conversation. Is one of the + following types: Literal["completed"], Literal["incomplete"], Literal["in_progress"] + :vartype status: str or str or str + :ivar call_id: The ID of the function call this output is for. Required. + :vartype call_id: str + :ivar output: The output of the function call, this is free text and can contain any + information or simply be empty. Required. + :vartype output: str + :ivar type: Required. A function-call output item. + :vartype type: str or ~azure.ai.voiceagents.models.FUNCTION_CALL_OUTPUT + :ivar name: The name of the function that was called. A Foundry extension: OpenAI's + function_call_output does not carry the function name, only ``call_id``. + :vartype name: str + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the item. This may be provided by the client or generated by the server.""" + object: Optional[Literal["realtime.item"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Identifier for the API object being returned - always ``realtime.item``. Optional when creating + a new item. Default value is \"realtime.item\".""" + status: Optional[Literal["completed", "incomplete", "in_progress"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The status of the item. Has no effect on the conversation. Is one of the following types: + Literal[\"completed\"], Literal[\"incomplete\"], Literal[\"in_progress\"]""" + call_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the function call this output is for. Required.""" + output: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The output of the function call, this is free text and can contain any information or simply be + empty. Required.""" + type: Literal[VoiceConversationItemType.FUNCTION_CALL_OUTPUT] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. A function-call output item.""" + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of the function that was called. A Foundry extension: OpenAI's function_call_output + does not carry the function name, only ``call_id``.""" + + @overload + def __init__( + self, + *, + call_id: str, + output: str, + created_at: Optional[datetime.datetime] = None, + response_id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + object: Optional[Literal["realtime.item"]] = None, + status: Optional[Literal["completed", "incomplete", "in_progress"]] = None, + name: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = VoiceConversationItemType.FUNCTION_CALL_OUTPUT # type: ignore + + +class VoiceInputTranscription(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Asynchronous input-audio transcription configuration. Extends the OpenAI Realtime transcription + options with the Azure and MAI transcription models, custom speech models, and phrase hints. + + :ivar language: The language of the input audio. Supplying the input language in `ISO-639-1 + `_ (e.g. ``en``) format will improve + accuracy and latency. + :vartype language: str + :ivar prompt: An optional text to guide the model's style or continue a previous audio segment. + For ``whisper-1``, the `prompt is a list of keywords `_. + For ``gpt-4o-transcribe`` models (excluding ``gpt-4o-transcribe-diarize``), the prompt is a + free text string, for example "expect words related to technology". Prompt is not supported + with ``gpt-realtime-whisper`` in GA Realtime sessions. + :vartype prompt: str + :ivar delay: Controls how long the model waits before emitting transcription text. Higher + values can improve transcription accuracy at the cost of latency. Only supported with + ``gpt-realtime-whisper`` in GA Realtime sessions. Is one of the following types: + Literal["minimal"], Literal["low"], Literal["medium"], Literal["high"], Literal["xhigh"] + :vartype delay: str or str or str or str or str + :ivar model: The transcription model to use. Required. Known values are: "whisper-1", + "gpt-realtime-whisper", "gpt-4o-transcribe", "gpt-4o-mini-transcribe", + "gpt-4o-transcribe-diarize", "gpt-transcribe", "gpt-live-transcribe", "mai-transcribe", and + "azure-speech". + :vartype model: str or ~azure.ai.voiceagents.models.VoiceInputTranscriptionModel + :ivar custom_speech: Optional custom speech model configuration, keyed by locale. + :vartype custom_speech: dict[str, str] + :ivar phrase_list: Optional phrase hints that bias recognition toward domain terms. + :vartype phrase_list: list[str] + """ + + language: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The language of the input audio. Supplying the input language in `ISO-639-1 + `_ (e.g. ``en``) format will improve + accuracy and latency.""" + prompt: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """An optional text to guide the model's style or continue a previous audio segment. For + ``whisper-1``, the `prompt is a list of keywords `_. For + ``gpt-4o-transcribe`` models (excluding ``gpt-4o-transcribe-diarize``), the prompt is a free + text string, for example \"expect words related to technology\". Prompt is not supported with + ``gpt-realtime-whisper`` in GA Realtime sessions.""" + delay: Optional[Literal["minimal", "low", "medium", "high", "xhigh"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Controls how long the model waits before emitting transcription text. Higher values can improve + transcription accuracy at the cost of latency. Only supported with ``gpt-realtime-whisper`` in + GA Realtime sessions. Is one of the following types: Literal[\"minimal\"], Literal[\"low\"], + Literal[\"medium\"], Literal[\"high\"], Literal[\"xhigh\"]""" + model: Union[str, "_models.VoiceInputTranscriptionModel"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The transcription model to use. Required. Known values are: \"whisper-1\", + \"gpt-realtime-whisper\", \"gpt-4o-transcribe\", \"gpt-4o-mini-transcribe\", + \"gpt-4o-transcribe-diarize\", \"gpt-transcribe\", \"gpt-live-transcribe\", \"mai-transcribe\", + and \"azure-speech\".""" + custom_speech: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Optional custom speech model configuration, keyed by locale.""" + phrase_list: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Optional phrase hints that bias recognition toward domain terms.""" + + @overload + def __init__( + self, + *, + model: Union[str, "_models.VoiceInputTranscriptionModel"], + language: Optional[str] = None, + prompt: Optional[str] = None, + delay: Optional[Literal["minimal", "low", "medium", "high", "xhigh"]] = None, + custom_speech: Optional[dict[str, str]] = None, + phrase_list: Optional[list[str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceItemAudioResponse(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Metadata for a single conversation item's audio segment. For bring-your-own-storage (BYOS), the + response includes ``blob_uri``, a direct customer-storage URI without a SAS token, that the + customer accesses with their own credentials. For Foundry-managed storage, ``blob_uri`` is + absent and the bytes are streamed through the item's ``/audio/content`` route. + + :ivar conversation_id: The id of the conversation the item belongs to. Required. + :vartype conversation_id: str + :ivar item_id: The id of the item this audio belongs to. Required. + :vartype item_id: str + :ivar role: The role the audio belongs to. Known values are: "user" and "agent". + :vartype role: str or ~azure.ai.voiceagents.models.VoiceAudioRole + :ivar format: The container format of the audio. "wav" + :vartype format: str or ~azure.ai.voiceagents.models.VoiceAudioContainerFormat + :ivar codec: The audio codec. Known values are: "pcm16", "pcmu", and "pcma". + :vartype codec: str or ~azure.ai.voiceagents.models.VoiceAudioCodec + :ivar sample_rate: The sample rate in Hz. + :vartype sample_rate: int + :ivar channels: The number of audio channels. + :vartype channels: int + :ivar start_offset_ms: The offset from the session start at which this segment begins. + :vartype start_offset_ms: ~datetime.timedelta + :ivar duration_ms: The duration of the audio segment. + :vartype duration_ms: ~datetime.timedelta + :ivar blob_uri: For bring-your-own-storage (BYOS) recordings only: the URI of the recording in + the customer's own storage, without a SAS token. The customer downloads it using their own + storage credentials. Absent for Foundry-managed storage, where the bytes are streamed via the + item's ``/audio/content`` route instead. + :vartype blob_uri: str + """ + + conversation_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The id of the conversation the item belongs to. Required.""" + item_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The id of the item this audio belongs to. Required.""" + role: Optional[Union[str, "_models.VoiceAudioRole"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The role the audio belongs to. Known values are: \"user\" and \"agent\".""" + format: Optional[Union[str, "_models.VoiceAudioContainerFormat"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The container format of the audio. \"wav\"""" + codec: Optional[Union[str, "_models.VoiceAudioCodec"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The audio codec. Known values are: \"pcm16\", \"pcmu\", and \"pcma\".""" + sample_rate: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The sample rate in Hz.""" + channels: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The number of audio channels.""" + start_offset_ms: Optional[datetime.timedelta] = rest_field( + visibility=["read", "create", "update", "delete", "query"], format="duration-milliseconds-int" + ) + """The offset from the session start at which this segment begins.""" + duration_ms: Optional[datetime.timedelta] = rest_field( + visibility=["read", "create", "update", "delete", "query"], format="duration-milliseconds-int" + ) + """The duration of the audio segment.""" + blob_uri: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """For bring-your-own-storage (BYOS) recordings only: the URI of the recording in the customer's + own storage, without a SAS token. The customer downloads it using their own storage + credentials. Absent for Foundry-managed storage, where the bytes are streamed via the item's + ``/audio/content`` route instead.""" + + @overload + def __init__( + self, + *, + conversation_id: str, + item_id: str, + role: Optional[Union[str, "_models.VoiceAudioRole"]] = None, + format: Optional[Union[str, "_models.VoiceAudioContainerFormat"]] = None, + codec: Optional[Union[str, "_models.VoiceAudioCodec"]] = None, + sample_rate: Optional[int] = None, + channels: Optional[int] = None, + start_offset_ms: Optional[datetime.timedelta] = None, + duration_ms: Optional[datetime.timedelta] = None, + blob_uri: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceMcpApprovalRequestItem( + VoiceConversationItem, discriminator="mcp_approval_request" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """An MCP approval request item. + + :ivar created_at: The Unix timestamp (in seconds) for when the item was persisted. + :vartype created_at: ~datetime.datetime + :ivar response_id: The id of the response that produced this item, when applicable. + :vartype response_id: str + :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 + :ivar type: Required. An MCP approval request item. + :vartype type: str or ~azure.ai.voiceagents.models.MCP_APPROVAL_REQUEST + """ + + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the approval request. Required.""" + server_label: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The label of the MCP server making the request. Required.""" + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of the tool to run. Required.""" + arguments: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """A JSON string of arguments for the tool. Required.""" + type: Literal[VoiceConversationItemType.MCP_APPROVAL_REQUEST] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. An MCP approval request item.""" + + @overload + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + server_label: str, + name: str, + arguments: str, + created_at: Optional[datetime.datetime] = None, + response_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = VoiceConversationItemType.MCP_APPROVAL_REQUEST # type: ignore + + +class VoiceMcpApprovalResponseItem( + VoiceConversationItem, discriminator="mcp_approval_response" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """An MCP approval response item (client-created). + + :ivar created_at: The Unix timestamp (in seconds) for when the item was persisted. + :vartype created_at: ~datetime.datetime + :ivar response_id: The id of the response that produced this item, when applicable. + :vartype response_id: str + :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 + :ivar type: Required. An MCP approval response item. + :vartype type: str or ~azure.ai.voiceagents.models.MCP_APPROVAL_RESPONSE + """ + + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the approval response. Required.""" + approval_request_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the approval request being answered. Required.""" + approve: bool = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Whether the request was approved. Required.""" + reason: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + type: Literal[VoiceConversationItemType.MCP_APPROVAL_RESPONSE] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. An MCP approval response item.""" + + @overload + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + approval_request_id: str, + approve: bool, + created_at: Optional[datetime.datetime] = None, + response_id: Optional[str] = None, + reason: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = VoiceConversationItemType.MCP_APPROVAL_RESPONSE # type: ignore + + +class VoiceMcpCallItem( + VoiceConversationItem, discriminator="mcp_call" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """An MCP call item. + + :ivar created_at: The Unix timestamp (in seconds) for when the item was persisted. + :vartype created_at: ~datetime.datetime + :ivar response_id: The id of the response that produced this item, when applicable. + :vartype response_id: str + :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 approval_request_id: + :vartype approval_request_id: str + :ivar output: + :vartype output: str + :ivar error: + :vartype error: ~azure.ai.voiceagents.models.RealtimeMCPError + :ivar type: Required. An MCP call item. + :vartype type: str or ~azure.ai.voiceagents.models.MCP_CALL + """ + + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the tool call. Required.""" + server_label: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The label of the MCP server running the tool. Required.""" + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of the tool that was run. Required.""" + arguments: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """A JSON string of the arguments passed to the tool. Required.""" + approval_request_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + output: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + error: Optional["_models.RealtimeMCPError"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + type: Literal[VoiceConversationItemType.MCP_CALL] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. An MCP call item.""" + + @overload + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + server_label: str, + name: str, + arguments: str, + created_at: Optional[datetime.datetime] = None, + response_id: Optional[str] = None, + approval_request_id: Optional[str] = None, + output: Optional[str] = None, + error: Optional["_models.RealtimeMCPError"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = VoiceConversationItemType.MCP_CALL # type: ignore + + +class VoiceMcpListToolsItem( + VoiceConversationItem, discriminator="mcp_list_tools" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """An MCP list-tools item. + + :ivar created_at: The Unix timestamp (in seconds) for when the item was persisted. + :vartype created_at: ~datetime.datetime + :ivar response_id: The id of the response that produced this item, when applicable. + :vartype response_id: str + :ivar id: The unique ID of the list. + :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.voiceagents.models.MCPListToolsTool] + :ivar type: Required. An MCP list-tools item. + :vartype type: str or ~azure.ai.voiceagents.models.MCP_LIST_TOOLS + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the list.""" + server_label: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The label of the MCP server. Required.""" + tools: list["_models.MCPListToolsTool"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The tools available on the server. Required.""" + type: Literal[VoiceConversationItemType.MCP_LIST_TOOLS] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. An MCP list-tools item.""" + + @overload + def __init__( + self, + *, + server_label: str, + tools: list["_models.MCPListToolsTool"], + created_at: Optional[datetime.datetime] = None, + response_id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = VoiceConversationItemType.MCP_LIST_TOOLS # type: ignore + + +class VoiceNoiseReduction(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Input audio noise reduction configuration. + + :ivar type: The noise reduction mode. Required. Known values are: "near_field", "far_field", + and "azure_deep_noise_suppression". + :vartype type: str or ~azure.ai.voiceagents.models.VoiceNoiseReductionType + """ + + type: Union[str, "_models.VoiceNoiseReductionType"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The noise reduction mode. Required. Known values are: \"near_field\", \"far_field\", and + \"azure_deep_noise_suppression\".""" + + @overload + def __init__( + self, + *, + type: Union[str, "_models.VoiceNoiseReductionType"], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceRecordingChannelLayout(_Model): # pylint: disable=docstring-missing-param + """The role assigned to each channel of a merged stereo voice recording. + + :ivar left: The role carried on the left channel. Always ``user``. Required. Default value is + "user". + :vartype left: str + :ivar right: The role carried on the right channel. Always ``agent``. Required. Default value + is "agent". + :vartype right: str + """ + + left: Literal["user"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The role carried on the left channel. Always ``user``. Required. Default value is \"user\".""" + right: Literal["agent"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The role carried on the right channel. Always ``agent``. Required. Default value is \"agent\".""" + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.left: Literal["user"] = "user" + self.right: Literal["agent"] = "agent" + + +class VoiceRecordingResponse(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Metadata for the merged, whole-call stereo recording of a voice conversation (user audio on the + left channel, agent audio on the right). Built once from the per-turn segments after the + session ends and durably cached. The common metadata (format, sample rate, channels, channel + layout, duration) is returned for both Foundry-managed and bring-your-own-storage (BYOS) + recordings. For BYOS the response also includes ``blob_uri``, the URI of the recording in the + customer's own storage (no SAS token), which the customer downloads using their own storage + credentials. For Foundry-managed storage ``blob_uri`` is absent and the bytes are streamed via + the ``/audio/content`` route instead. + + :ivar conversation_id: The id of the conversation this recording belongs to. Required. + :vartype conversation_id: str + :ivar format: The container format of the recording. Required. "wav" + :vartype format: str or ~azure.ai.voiceagents.models.VoiceAudioContainerFormat + :ivar sample_rate: The sample rate of the recording in Hz, e.g. 24000. Required. + :vartype sample_rate: int + :ivar channels: The number of audio channels. The merged recording is stereo (``2``). Required. + :vartype channels: int + :ivar channel_layout: The role assigned to each stereo channel. Required. + :vartype channel_layout: ~azure.ai.voiceagents.models.VoiceRecordingChannelLayout + :ivar duration_ms: The total duration of the recording. Required. + :vartype duration_ms: ~datetime.timedelta + :ivar blob_uri: For bring-your-own-storage (BYOS) recordings only: the URI of the recording in + the customer's own storage, without a SAS token. The customer downloads it using their own + storage credentials. Absent for Foundry-managed storage, where the bytes are streamed via the + ``/audio/content`` route instead. + :vartype blob_uri: str + """ + + conversation_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The id of the conversation this recording belongs to. Required.""" + format: Union[str, "_models.VoiceAudioContainerFormat"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The container format of the recording. Required. \"wav\"""" + sample_rate: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The sample rate of the recording in Hz, e.g. 24000. Required.""" + channels: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The number of audio channels. The merged recording is stereo (``2``). Required.""" + channel_layout: "_models.VoiceRecordingChannelLayout" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The role assigned to each stereo channel. Required.""" + duration_ms: datetime.timedelta = rest_field( + visibility=["read", "create", "update", "delete", "query"], format="duration-milliseconds-int" + ) + """The total duration of the recording. Required.""" + blob_uri: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """For bring-your-own-storage (BYOS) recordings only: the URI of the recording in the customer's + own storage, without a SAS token. The customer downloads it using their own storage + credentials. Absent for Foundry-managed storage, where the bytes are streamed via the + ``/audio/content`` route instead.""" + + @overload + def __init__( + self, + *, + conversation_id: str, + format: Union[str, "_models.VoiceAudioContainerFormat"], + sample_rate: int, + channels: int, + channel_layout: "_models.VoiceRecordingChannelLayout", + duration_ms: datetime.timedelta, + blob_uri: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceResponse(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """A persisted voice response representing one model inference turn within a conversation. In list + results the ``output`` projection may be omitted; retrieve the full response (``GET + .../responses/{response_id}``) or the paged response-items route (``GET + .../responses/{response_id}/items``) for its output items. ``created_at``/``completed_at`` are + Foundry durable ordering extensions. + + :ivar id: The unique id of the response. Required. + :vartype id: str + :ivar object: The object type. Always ``realtime.response``. Required. Default value is + "realtime.response". + :vartype object: str + :ivar status: The status of the response. Required. Known values are: "in_progress", + "completed", "cancelled", "incomplete", and "failed". + :vartype status: str or ~azure.ai.voiceagents.models.VoiceResponseStatus + :ivar status_details: Additional detail about a terminal status. + :vartype status_details: ~azure.ai.voiceagents.models.RealtimeResponseStatusDetails + :ivar output: The output items produced by the response. May be omitted in list results; + retrieve the full response (GET .../responses/{response_id}) or use the paged response-items + route (GET .../responses/{response_id}/items) for its output items. Each item's ``response_id`` + also links it back to this response in the conversation-level items list. + :vartype output: list[~azure.ai.voiceagents.models.VoiceConversationItem] + :ivar usage: Token usage statistics for the response. + :vartype usage: ~azure.ai.voiceagents.models.RealtimeResponseUsage + :ivar conversation_id: The id of the conversation this response belongs to. Required. + :vartype conversation_id: str + :ivar audio: The audio configuration used for the response, including the voice and audio + format used for output. + :vartype audio: ~azure.ai.voiceagents.models.VoiceResponseAudio + :ivar output_modalities: The output modalities used for the response, e.g. ``["text", + "audio"]``. Audio output always includes a text transcript. + :vartype output_modalities: list[str or str] + :ivar temperature: The sampling temperature used for the response. + :vartype temperature: float + :ivar max_output_tokens: The maximum number of output tokens allowed for the response; an + integer or the literal ``inf``. Is either a int type or a Literal["inf"] type. + :vartype max_output_tokens: int or str + :ivar created_at: The Unix timestamp (in seconds) for when the response was created. + :vartype created_at: ~datetime.datetime + :ivar completed_at: The Unix timestamp (in seconds) for when the response completed. + :vartype completed_at: ~datetime.datetime + """ + + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique id of the response. Required.""" + object: Literal["realtime.response"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The object type. Always ``realtime.response``. Required. Default value is + \"realtime.response\".""" + status: Union[str, "_models.VoiceResponseStatus"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The status of the response. Required. Known values are: \"in_progress\", \"completed\", + \"cancelled\", \"incomplete\", and \"failed\".""" + status_details: Optional["_models.RealtimeResponseStatusDetails"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Additional detail about a terminal status.""" + output: Optional[list["_models.VoiceConversationItem"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The output items produced by the response. May be omitted in list results; retrieve the full + response (GET .../responses/{response_id}) or use the paged response-items route (GET + .../responses/{response_id}/items) for its output items. Each item's ``response_id`` also links + it back to this response in the conversation-level items list.""" + usage: Optional["_models.RealtimeResponseUsage"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Token usage statistics for the response.""" + conversation_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The id of the conversation this response belongs to. Required.""" + audio: Optional["_models.VoiceResponseAudio"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The audio configuration used for the response, including the voice and audio format used for + output.""" + output_modalities: Optional[list[Literal["text", "audio"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The output modalities used for the response, e.g. ``[\"text\", \"audio\"]``. Audio output + always includes a text transcript.""" + temperature: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The sampling temperature used for the response.""" + max_output_tokens: Optional[Union[int, Literal["inf"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The maximum number of output tokens allowed for the response; an integer or the literal + ``inf``. Is either a int type or a Literal[\"inf\"] type.""" + created_at: Optional[datetime.datetime] = rest_field( + visibility=["read", "create", "update", "delete", "query"], format="unix-timestamp" + ) + """The Unix timestamp (in seconds) for when the response was created.""" + completed_at: Optional[datetime.datetime] = rest_field( + visibility=["read", "create", "update", "delete", "query"], format="unix-timestamp" + ) + """The Unix timestamp (in seconds) for when the response completed.""" + + @overload + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + status: Union[str, "_models.VoiceResponseStatus"], + conversation_id: str, + status_details: Optional["_models.RealtimeResponseStatusDetails"] = None, + output: Optional[list["_models.VoiceConversationItem"]] = None, + usage: Optional["_models.RealtimeResponseUsage"] = None, + audio: Optional["_models.VoiceResponseAudio"] = None, + output_modalities: Optional[list[Literal["text", "audio"]]] = None, + temperature: Optional[float] = None, + max_output_tokens: Optional[Union[int, Literal["inf"]]] = None, + created_at: Optional[datetime.datetime] = None, + completed_at: Optional[datetime.datetime] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.object: Literal["realtime.response"] = "realtime.response" + + +class VoiceResponseAudio(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Audio configuration for a response. Follows the OpenAI Realtime GA ``audio`` object shape. + + :ivar output: The audio output configuration used for the response. + :vartype output: ~azure.ai.voiceagents.models.VoiceResponseAudioOutput + """ + + output: Optional["_models.VoiceResponseAudioOutput"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The audio output configuration used for the response.""" + + @overload + def __init__( + self, + *, + output: Optional["_models.VoiceResponseAudioOutput"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceResponseAudioOutput(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """The output audio format used for a response. Follows the OpenAI Realtime GA audio format + discriminated union. + + :ivar voice: The voice used for the response's audio output. Is one of the following types: + OpenAIVoice, AzureVoice, AzureRealtimeNativeVoice + :vartype voice: ~azure.ai.voiceagents.models.OpenAIVoice or + ~azure.ai.voiceagents.models.AzureVoice or + ~azure.ai.voiceagents.models.AzureRealtimeNativeVoice + :ivar format: The audio format used for the response's audio output. + :vartype format: ~azure.ai.voiceagents.models.RealtimeAudioFormats + """ + + voice: Optional["_unions.VoiceResponseVoice"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The voice used for the response's audio output. Is one of the following types: OpenAIVoice, + AzureVoice, AzureRealtimeNativeVoice""" + format: Optional["_models.RealtimeAudioFormats"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The audio format used for the response's audio output.""" + + @overload + def __init__( + self, + *, + voice: Optional["_unions.VoiceResponseVoice"] = None, + format: Optional["_models.RealtimeAudioFormats"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VoiceSemanticVadTurnDetection( + VoiceTurnDetection, discriminator="semantic_vad" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """Semantic voice activity detection. + + :ivar eagerness: Is one of the following types: Literal["low"], Literal["medium"], + Literal["high"], Literal["auto"] + :vartype eagerness: str or str or str or str + :ivar create_response: + :vartype create_response: bool + :ivar interrupt_response: + :vartype interrupt_response: bool + :ivar type: Required. Semantic voice activity detection. + :vartype type: str or ~azure.ai.voiceagents.models.SEMANTIC_VAD + """ + + eagerness: Optional[Literal["low", "medium", "high", "auto"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Is one of the following types: Literal[\"low\"], Literal[\"medium\"], Literal[\"high\"], + Literal[\"auto\"]""" + create_response: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + interrupt_response: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + type: Literal[VoiceTurnDetectionType.SEMANTIC_VAD] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. Semantic voice activity detection.""" + + @overload + def __init__( + self, + *, + eagerness: Optional[Literal["low", "medium", "high", "auto"]] = None, + create_response: Optional[bool] = None, + interrupt_response: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = VoiceTurnDetectionType.SEMANTIC_VAD # type: ignore + + +class VoiceServerVadTurnDetection( + VoiceTurnDetection, discriminator="server_vad" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """Server-side voice activity detection. + + :ivar threshold: + :vartype threshold: float + :ivar prefix_padding_ms: + :vartype prefix_padding_ms: int + :ivar silence_duration_ms: + :vartype silence_duration_ms: int + :ivar create_response: + :vartype create_response: bool + :ivar interrupt_response: + :vartype interrupt_response: bool + :ivar idle_timeout_ms: + :vartype idle_timeout_ms: int + :ivar type: Required. Server-side voice activity detection. + :vartype type: str or ~azure.ai.voiceagents.models.SERVER_VAD + """ + + threshold: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + prefix_padding_ms: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + silence_duration_ms: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + create_response: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + interrupt_response: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + idle_timeout_ms: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + type: Literal[VoiceTurnDetectionType.SERVER_VAD] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. Server-side voice activity detection.""" + + @overload + def __init__( + self, + *, + threshold: Optional[float] = None, + prefix_padding_ms: Optional[int] = None, + silence_duration_ms: Optional[int] = None, + create_response: Optional[bool] = None, + interrupt_response: Optional[bool] = None, + idle_timeout_ms: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = VoiceTurnDetectionType.SERVER_VAD # type: ignore + + +class VoiceSystemMessageItem( + VoiceMessageItem, discriminator="system" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """A system message item. Only ``input_text`` content is valid for system messages. + + :ivar created_at: The Unix timestamp (in seconds) for when the item was persisted. + :vartype created_at: ~datetime.datetime + :ivar response_id: The id of the response that produced this item, when applicable. + :vartype response_id: str + :ivar type: Required. A message item. + :vartype type: str or ~azure.ai.voiceagents.models.MESSAGE + :ivar id: The unique ID of the item. This may be provided by the client or generated by the + server. + :vartype id: str + :ivar object: Identifier for the API object being returned - always ``realtime.item``. Optional + when creating a new item. Default value is "realtime.item". + :vartype object: str + :ivar status: The status of the item. Has no effect on the conversation. Is one of the + following types: Literal["completed"], Literal["incomplete"], Literal["in_progress"] + :vartype status: str or str or str + :ivar content: The content of the message. Required. + :vartype content: + list[~azure.ai.voiceagents.models.RealtimeConversationItemMessageSystemContent] + :ivar role: Required. SYSTEM. + :vartype role: str or ~azure.ai.voiceagents.models.SYSTEM + """ + + __mapping__: dict[str, _Model] = {} + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the item. This may be provided by the client or generated by the server.""" + object: Optional[Literal["realtime.item"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Identifier for the API object being returned - always ``realtime.item``. Optional when creating + a new item. Default value is \"realtime.item\".""" + status: Optional[Literal["completed", "incomplete", "in_progress"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The status of the item. Has no effect on the conversation. Is one of the following types: + Literal[\"completed\"], Literal[\"incomplete\"], Literal[\"in_progress\"]""" + content: list["_models.RealtimeConversationItemMessageSystemContent"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The content of the message. Required.""" + role: Literal[RealtimeConversationItemMessageType.SYSTEM] = rest_discriminator(name="role", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. SYSTEM.""" + + @overload + def __init__( + self, + *, + content: list["_models.RealtimeConversationItemMessageSystemContent"], + created_at: Optional[datetime.datetime] = None, + response_id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + object: Optional[Literal["realtime.item"]] = None, + status: Optional[Literal["completed", "incomplete", "in_progress"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.role = RealtimeConversationItemMessageType.SYSTEM # type: ignore + + +class VoiceSystemTool(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """A service-managed control that acts on the active voice session without customer code or + external authentication. + + :ivar type: The type of the tool. Always ``system``. Required. Default value is "system". + :vartype type: str + :ivar name: The service-managed control action. Known values are stable; additional values may + be added over time. Required. "end_conversation" + :vartype name: str or ~azure.ai.voiceagents.models.VoiceSystemToolName + :ivar description: An optional description of the system tool. + :vartype description: str + """ + + type: Literal["system"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The type of the tool. Always ``system``. Required. Default value is \"system\".""" + name: Union[str, "_models.VoiceSystemToolName"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The service-managed control action. Known values are stable; additional values may be added + over time. Required. \"end_conversation\"""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """An optional description of the system tool.""" + + @overload + def __init__( + self, + *, + name: Union[str, "_models.VoiceSystemToolName"], + description: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["system"] = "system" + + +class VoiceToolboxTool(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """A reference to a Foundry toolbox, which is a versioned bundle of tools executed through its MCP + endpoint. + + :ivar type: The type of the tool. Always ``toolbox``. Required. Default value is "toolbox". + :vartype type: str + :ivar toolbox_name: The name of the toolbox to attach. Required. + :vartype toolbox_name: str + :ivar toolbox_version: The immutable version of the toolbox to attach. Required. + :vartype toolbox_version: str + """ + + type: Literal["toolbox"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The type of the tool. Always ``toolbox``. Required. Default value is \"toolbox\".""" + toolbox_name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of the toolbox to attach. Required.""" + toolbox_version: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The immutable version of the toolbox to attach. Required.""" + + @overload + def __init__( + self, + *, + toolbox_name: str, + toolbox_version: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["toolbox"] = "toolbox" + + +class VoiceUserMessageItem( + VoiceMessageItem, discriminator="user" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """A user message item. ``input_text``, ``input_audio``, and ``input_image`` content are valid for + user messages. + + :ivar created_at: The Unix timestamp (in seconds) for when the item was persisted. + :vartype created_at: ~datetime.datetime + :ivar response_id: The id of the response that produced this item, when applicable. + :vartype response_id: str + :ivar type: Required. A message item. + :vartype type: str or ~azure.ai.voiceagents.models.MESSAGE + :ivar id: The unique ID of the item. This may be provided by the client or generated by the + server. + :vartype id: str + :ivar object: Identifier for the API object being returned - always ``realtime.item``. Optional + when creating a new item. Default value is "realtime.item". + :vartype object: str + :ivar status: The status of the item. Has no effect on the conversation. Is one of the + following types: Literal["completed"], Literal["incomplete"], Literal["in_progress"] + :vartype status: str or str or str + :ivar content: The content of the message. Required. + :vartype content: list[~azure.ai.voiceagents.models.RealtimeConversationItemMessageUserContent] + :ivar role: Required. USER. + :vartype role: str or ~azure.ai.voiceagents.models.USER + """ + + __mapping__: dict[str, _Model] = {} + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ID of the item. This may be provided by the client or generated by the server.""" + object: Optional[Literal["realtime.item"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Identifier for the API object being returned - always ``realtime.item``. Optional when creating + a new item. Default value is \"realtime.item\".""" + status: Optional[Literal["completed", "incomplete", "in_progress"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The status of the item. Has no effect on the conversation. Is one of the following types: + Literal[\"completed\"], Literal[\"incomplete\"], Literal[\"in_progress\"]""" + content: list["_models.RealtimeConversationItemMessageUserContent"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The content of the message. Required.""" + role: Literal[RealtimeConversationItemMessageType.USER] = rest_discriminator(name="role", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. USER.""" + + @overload + def __init__( + self, + *, + content: list["_models.RealtimeConversationItemMessageUserContent"], + created_at: Optional[datetime.datetime] = None, + response_id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + object: Optional[Literal["realtime.item"]] = None, + status: Optional[Literal["completed", "incomplete", "in_progress"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.role = RealtimeConversationItemMessageType.USER # type: ignore diff --git a/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/models/_patch.py b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/models/_patch.py new file mode 100644 index 000000000000..87676c65a8f0 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/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/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/operations/__init__.py b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/operations/__init__.py new file mode 100644 index 000000000000..af8ff4734a8f --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/operations/__init__.py @@ -0,0 +1,29 @@ +# 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 VoiceAgentWebSocketOperations # type: ignore +from ._operations import AgentEndpointConversationsOperations # type: ignore +from ._operations import VoiceAgentsOperations # type: ignore + +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "VoiceAgentWebSocketOperations", + "AgentEndpointConversationsOperations", + "VoiceAgentsOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/operations/_operations.py b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/operations/_operations.py new file mode 100644 index 000000000000..96fefa470126 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/operations/_operations.py @@ -0,0 +1,3612 @@ +# 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. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +import json +from typing import Any, Callable, IO, Iterator, Literal, Optional, TYPE_CHECKING, TypeVar, Union, overload +import urllib.parse + +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 models as _models, types as _types +from .._configuration import VoiceAgentsClientConfiguration +from .._utils.model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize +from .._utils.serialization import Deserializer, Serializer +from ..models._enums import AgentDefinitionOptInKeys + +if TYPE_CHECKING: + from .. import _unions +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] +JSON = MutableMapping[str, Any] +_Unset: Any = object() + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_voice_agent_web_socket_connect_voice_agent_request( # pylint: disable=name-too-long + agent_name: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + agent_session_id: Optional[str] = None, + agent_version_override: Optional[str] = None, + websocket_subprotocol: Optional[Union[str, _models.VoiceAgentWebSocketSubprotocol]] = None, + structured_inputs: 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")) + # Construct URL + _url = "/agents/{agent_name}/endpoint/protocols/voice" + path_format_arguments = { + "agent_name": _SERIALIZER.url("agent_name", agent_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if agent_session_id is not None: + _params["agent_session_id"] = _SERIALIZER.query("agent_session_id", agent_session_id, "str") + if agent_version_override is not None: + _params["x-agent-version-override"] = _SERIALIZER.query("agent_version_override", agent_version_override, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + if websocket_subprotocol is not None: + _headers["Sec-WebSocket-Protocol"] = _SERIALIZER.header("websocket_subprotocol", websocket_subprotocol, "str") + if structured_inputs is not None: + _headers["x-ms-voice-structured-inputs"] = _SERIALIZER.header("structured_inputs", structured_inputs, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_agent_endpoint_conversations_get_agent_conversation_request( # pylint: disable=name-too-long + agent_name: str, + conversation_id: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_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 = "/agents/{agent_name}/endpoint/protocols/voice/conversations/{conversation_id}" + path_format_arguments = { + "agent_name": _SERIALIZER.url("agent_name", agent_name, "str"), + "conversation_id": _SERIALIZER.url("conversation_id", conversation_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_agent_endpoint_conversations_delete_agent_conversation_request( # pylint: disable=name-too-long + agent_name: str, + conversation_id: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_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 = "/agents/{agent_name}/endpoint/protocols/voice/conversations/{conversation_id}" + path_format_arguments = { + "agent_name": _SERIALIZER.url("agent_name", agent_name, "str"), + "conversation_id": _SERIALIZER.url("conversation_id", conversation_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_agent_endpoint_conversations_list_agent_conversation_responses_request( # pylint: disable=name-too-long + agent_name: str, + conversation_id: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + limit: Optional[int] = None, + order: Optional[Union[str, _models.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 = "/agents/{agent_name}/endpoint/protocols/voice/conversations/{conversation_id}/responses" + path_format_arguments = { + "agent_name": _SERIALIZER.url("agent_name", agent_name, "str"), + "conversation_id": _SERIALIZER.url("conversation_id", conversation_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") + _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_agent_endpoint_conversations_get_agent_conversation_response_request( # pylint: disable=name-too-long + agent_name: str, + conversation_id: str, + response_id: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_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 = "/agents/{agent_name}/endpoint/protocols/voice/conversations/{conversation_id}/responses/{response_id}" + path_format_arguments = { + "agent_name": _SERIALIZER.url("agent_name", agent_name, "str"), + "conversation_id": _SERIALIZER.url("conversation_id", conversation_id, "str"), + "response_id": _SERIALIZER.url("response_id", response_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_agent_endpoint_conversations_list_agent_conversation_response_items_request( # pylint: disable=name-too-long + agent_name: str, + conversation_id: str, + response_id: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + limit: Optional[int] = None, + order: Optional[Union[str, _models.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 = "/agents/{agent_name}/endpoint/protocols/voice/conversations/{conversation_id}/responses/{response_id}/items" + path_format_arguments = { + "agent_name": _SERIALIZER.url("agent_name", agent_name, "str"), + "conversation_id": _SERIALIZER.url("conversation_id", conversation_id, "str"), + "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") + _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_agent_endpoint_conversations_list_agent_conversation_items_request( # pylint: disable=name-too-long + agent_name: str, + conversation_id: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + limit: Optional[int] = None, + order: Optional[Union[str, _models.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 = "/agents/{agent_name}/endpoint/protocols/voice/conversations/{conversation_id}/items" + path_format_arguments = { + "agent_name": _SERIALIZER.url("agent_name", agent_name, "str"), + "conversation_id": _SERIALIZER.url("conversation_id", conversation_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") + _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_agent_endpoint_conversations_get_agent_conversation_item_request( # pylint: disable=name-too-long + agent_name: str, + conversation_id: str, + item_id: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_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 = "/agents/{agent_name}/endpoint/protocols/voice/conversations/{conversation_id}/items/{item_id}" + path_format_arguments = { + "agent_name": _SERIALIZER.url("agent_name", agent_name, "str"), + "conversation_id": _SERIALIZER.url("conversation_id", conversation_id, "str"), + "item_id": _SERIALIZER.url("item_id", item_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_agent_endpoint_conversations_get_agent_conversation_item_audio_request( # pylint: disable=name-too-long + agent_name: str, + conversation_id: str, + item_id: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_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 = "/agents/{agent_name}/endpoint/protocols/voice/conversations/{conversation_id}/items/{item_id}/audio" + path_format_arguments = { + "agent_name": _SERIALIZER.url("agent_name", agent_name, "str"), + "conversation_id": _SERIALIZER.url("conversation_id", conversation_id, "str"), + "item_id": _SERIALIZER.url("item_id", item_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_agent_endpoint_conversations_get_agent_conversation_item_audio_content_request( # pylint: disable=name-too-long + agent_name: str, + conversation_id: str, + item_id: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_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", "audio/wav") + + # Construct URL + _url = "/agents/{agent_name}/endpoint/protocols/voice/conversations/{conversation_id}/items/{item_id}/audio/content" + path_format_arguments = { + "agent_name": _SERIALIZER.url("agent_name", agent_name, "str"), + "conversation_id": _SERIALIZER.url("conversation_id", conversation_id, "str"), + "item_id": _SERIALIZER.url("item_id", item_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_agent_endpoint_conversations_get_agent_conversation_audio_request( # pylint: disable=name-too-long + agent_name: str, + conversation_id: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_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 = "/agents/{agent_name}/endpoint/protocols/voice/conversations/{conversation_id}/audio" + path_format_arguments = { + "agent_name": _SERIALIZER.url("agent_name", agent_name, "str"), + "conversation_id": _SERIALIZER.url("conversation_id", conversation_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_agent_endpoint_conversations_get_agent_conversation_audio_content_request( # pylint: disable=name-too-long + agent_name: str, + conversation_id: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_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", "audio/wav") + + # Construct URL + _url = "/agents/{agent_name}/endpoint/protocols/voice/conversations/{conversation_id}/audio/content" + path_format_arguments = { + "agent_name": _SERIALIZER.url("agent_name", agent_name, "str"), + "conversation_id": _SERIALIZER.url("conversation_id", conversation_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_voice_agents_create_voice_agent_request( # pylint: disable=name-too-long + *, foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_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 = "/voice_agents" + + # 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_voice_agents_list_voice_agents_request( # pylint: disable=name-too-long + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + limit: Optional[int] = None, + order: Optional[Union[str, _models.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 = "/voice_agents" + + # 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_voice_agents_get_voice_agent_request( # pylint: disable=name-too-long + agent_name: str, *, foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_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 = "/voice_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 + _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_voice_agents_update_voice_agent_request( # pylint: disable=name-too-long + agent_name: str, *, foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_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 = "/voice_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 + _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_voice_agents_delete_voice_agent_request( # pylint: disable=name-too-long + agent_name: str, *, foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_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 = "/voice_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 + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_voice_agents_enable_voice_agent_request( # pylint: disable=name-too-long + agent_name: str, *, foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_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 = "/voice_agents/{agent_name}:enable" + 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 + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_voice_agents_disable_voice_agent_request( # pylint: disable=name-too-long + agent_name: str, *, foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_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 = "/voice_agents/{agent_name}:disable" + 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 + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_voice_agents_generate_voice_agent_request( # pylint: disable=name-too-long + *, foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_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 = "/voice_agents:generate" + + # 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_voice_agents_create_voice_agent_version_request( # pylint: disable=name-too-long + agent_name: str, *, foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_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 = "/voice_agents/{agent_name}/versions" + 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 + _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_voice_agents_list_voice_agent_versions_request( # pylint: disable=name-too-long + agent_name: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + limit: Optional[int] = None, + order: Optional[Union[str, _models.PageOrder]] = None, + after: Optional[str] = None, + before: Optional[str] = None, + include_drafts: 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 = "/voice_agents/{agent_name}/versions" + path_format_arguments = { + "agent_name": _SERIALIZER.url("agent_name", agent_name, "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") + if include_drafts is not None: + _params["include_drafts"] = _SERIALIZER.query("include_drafts", include_drafts, "bool") + _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_voice_agents_get_voice_agent_version_request( # pylint: disable=name-too-long + agent_name: str, + agent_version: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_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 = "/voice_agents/{agent_name}/versions/{agent_version}" + path_format_arguments = { + "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") + + # 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_voice_agents_delete_voice_agent_version_request( # pylint: disable=name-too-long + agent_name: str, + agent_version: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_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 = "/voice_agents/{agent_name}/versions/{agent_version}" + path_format_arguments = { + "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") + + # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class VoiceAgentWebSocketOperations: # pylint: disable=docstring-missing-param + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.voiceagents.VoiceAgentsClient`'s + :attr:`voice_agent_web_socket` 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: VoiceAgentsClientConfiguration = 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 connect_voice_agent( # pylint: disable=inconsistent-return-statements + self, + agent_name: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + agent_session_id: Optional[str] = None, + agent_version_override: Optional[str] = None, + websocket_subprotocol: Optional[Union[str, _models.VoiceAgentWebSocketSubprotocol]] = None, + structured_inputs: Optional[str] = None, + **kwargs: Any + ) -> None: + """Connect to a voice agent. + + Connects to a voice agent over WebSocket. The client must send an HTTP GET with ``Upgrade: + websocket`` headers. The optional ``realtime`` subprotocol is the only accepted subprotocol + value. + + :param agent_name: The name of the voice agent. Required. + :type agent_name: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_V1_PREVIEW + :keyword agent_session_id: An optional identifier used to correlate the voice session. Default + value is None. + :paramtype agent_session_id: str + :keyword agent_version_override: Selects a specific version of the voice agent for this + session. Default value is None. + :paramtype agent_version_override: str + :keyword websocket_subprotocol: The requested WebSocket subprotocol. Omit this header or + request exactly ``realtime``. "realtime" Default value is None. + :paramtype websocket_subprotocol: str or + ~azure.ai.voiceagents.models.VoiceAgentWebSocketSubprotocol + :keyword structured_inputs: A JSON object that maps structured-input names to their values for + this session. Default value is None. + :paramtype structured_inputs: 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_voice_agent_web_socket_connect_voice_agent_request( + agent_name=agent_name, + foundry_features=foundry_features, + agent_session_id=agent_session_id, + agent_version_override=agent_version_override, + websocket_subprotocol=websocket_subprotocol, + structured_inputs=structured_inputs, + 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 [101]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["Sec-WebSocket-Protocol"] = self._deserialize( + "str", response.headers.get("Sec-WebSocket-Protocol") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + +class AgentEndpointConversationsOperations: # pylint: disable=docstring-missing-param + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.voiceagents.VoiceAgentsClient`'s + :attr:`agent_endpoint_conversations` 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: VoiceAgentsClientConfiguration = 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_agent_conversation( + self, + agent_name: str, + conversation_id: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + **kwargs: Any + ) -> _models.VoiceConversation: + """Get a voice agent conversation. + + Retrieves a single conversation recorded for the specified voice agent endpoint by its id. + Returns ``404`` when the conversation was not persisted (``store = false``) or does not exist. + + :param agent_name: The name of the agent. Required. + :type agent_name: str + :param conversation_id: The id of the conversation to retrieve. Required. + :type conversation_id: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_V1_PREVIEW + :return: VoiceConversation. The VoiceConversation is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceConversation + :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.VoiceConversation] = kwargs.pop("cls", None) + + _request = build_agent_endpoint_conversations_get_agent_conversation_request( + agent_name=agent_name, + conversation_id=conversation_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) + + _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 = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.VoiceConversation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete_agent_conversation( # pylint: disable=inconsistent-return-statements + self, + agent_name: str, + conversation_id: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + **kwargs: Any + ) -> None: + """Delete a voice agent conversation. + + Deletes a conversation and all of its stored data — responses, items, and any audio (cascade). + This is the customer's explicit data-deletion control for voice conversations. + + :param agent_name: The name of the agent. Required. + :type agent_name: str + :param conversation_id: The id of the conversation to delete. Required. + :type conversation_id: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_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_agent_endpoint_conversations_delete_agent_conversation_request( + agent_name=agent_name, + conversation_id=conversation_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) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_agent_conversation_responses( + self, + agent_name: str, + conversation_id: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + limit: Optional[int] = None, + order: Optional[Union[str, _models.PageOrder]] = None, + before: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.VoiceResponse"]: + """List responses in a voice agent conversation. + + Returns a paged collection of the responses (model inference turns) recorded for the specified + conversation. The per-response ``output`` projection may be omitted here; use the + response-items route for the canonical paged output. Returns ``404`` when the conversation was + not persisted (``store = false``). + + :param agent_name: The name of the agent. Required. + :type agent_name: str + :param conversation_id: The id of the conversation whose responses are listed. Required. + :type conversation_id: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_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. + :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.voiceagents.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 VoiceResponse + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.voiceagents.models.VoiceResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_models.VoiceResponse]] = 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_agent_endpoint_conversations_list_agent_conversation_responses_request( + agent_name=agent_name, + conversation_id=conversation_id, + foundry_features=foundry_features, + 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.VoiceResponse], + 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 = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_agent_conversation_response( + self, + agent_name: str, + conversation_id: str, + response_id: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + **kwargs: Any + ) -> _models.VoiceResponse: + """Get a voice agent conversation response. + + Retrieves a single response from the specified conversation by its id, including its ``output`` + items, ``usage``, and status. Returns ``404`` when the conversation or response was not + persisted (``store = false``). + + :param agent_name: The name of the agent. Required. + :type agent_name: str + :param conversation_id: The id of the conversation that contains the response. Required. + :type conversation_id: str + :param response_id: The id of the response to retrieve. Required. + :type response_id: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_V1_PREVIEW + :return: VoiceResponse. The VoiceResponse is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceResponse + :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.VoiceResponse] = kwargs.pop("cls", None) + + _request = build_agent_endpoint_conversations_get_agent_conversation_response_request( + agent_name=agent_name, + conversation_id=conversation_id, + response_id=response_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) + + _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 = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.VoiceResponse, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_agent_conversation_response_items( + self, + agent_name: str, + conversation_id: str, + response_id: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + limit: Optional[int] = None, + order: Optional[Union[str, _models.PageOrder]] = None, + before: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.VoiceConversationItem"]: + """List items produced by a voice agent conversation response. + + Returns a paged collection of the output items produced by a specific response (the response's + output projection). For the complete ordered conversation history — including user input and + client-created tool outputs — use the conversation items route instead. Returns ``404`` when + the conversation or response was not persisted (``store = false``). + + :param agent_name: The name of the agent. Required. + :type agent_name: str + :param conversation_id: The id of the conversation that contains the response. Required. + :type conversation_id: str + :param response_id: The id of the response whose output items are listed. Required. + :type response_id: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_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. + :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.voiceagents.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 VoiceConversationItem + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.voiceagents.models.VoiceConversationItem] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_models.VoiceConversationItem]] = 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_agent_endpoint_conversations_list_agent_conversation_response_items_request( + agent_name=agent_name, + conversation_id=conversation_id, + response_id=response_id, + foundry_features=foundry_features, + 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.VoiceConversationItem], + 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 = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_agent_conversation_items( + self, + agent_name: str, + conversation_id: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + limit: Optional[int] = None, + order: Optional[Union[str, _models.PageOrder]] = None, + before: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.VoiceConversationItem"]: + """List items in a voice agent conversation. + + Returns a paged collection of items — the complete ordered conversation history, including user + input, assistant output, and client-created tool outputs (transcripts + tool events). Returns + ``404`` when the conversation was not persisted (``store = false``). + + :param agent_name: The name of the agent. Required. + :type agent_name: str + :param conversation_id: The id of the conversation whose items are listed. Required. + :type conversation_id: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_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. + :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.voiceagents.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 VoiceConversationItem + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.voiceagents.models.VoiceConversationItem] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_models.VoiceConversationItem]] = 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_agent_endpoint_conversations_list_agent_conversation_items_request( + agent_name=agent_name, + conversation_id=conversation_id, + foundry_features=foundry_features, + 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.VoiceConversationItem], + 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 = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_agent_conversation_item( + self, + agent_name: str, + conversation_id: str, + item_id: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + **kwargs: Any + ) -> _models.VoiceConversationItem: + """Get a voice agent conversation item. + + Retrieves a single item from the specified conversation by its id, including its transcript. An + ``input_audio``/``output_audio`` content part indicates that audio is available for the item; + the canonical per-item audio metadata is the ``/items/{item_id}/audio`` resource, and the bytes + are streamed by ``/items/{item_id}/audio/content``. Returns ``404`` when the conversation or + item was not persisted (``store = false``). + + :param agent_name: The name of the agent. Required. + :type agent_name: str + :param conversation_id: The id of the conversation that contains the item. Required. + :type conversation_id: str + :param item_id: The id of the conversation item to retrieve. Required. + :type item_id: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_V1_PREVIEW + :return: VoiceConversationItem. The VoiceConversationItem is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceConversationItem + :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.VoiceConversationItem] = kwargs.pop("cls", None) + + _request = build_agent_endpoint_conversations_get_agent_conversation_item_request( + agent_name=agent_name, + conversation_id=conversation_id, + item_id=item_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) + + _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 = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.VoiceConversationItem, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_agent_conversation_item_audio( + self, + agent_name: str, + conversation_id: str, + item_id: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + **kwargs: Any + ) -> _models.VoiceItemAudioResponse: + """Get a voice agent conversation item's audio metadata. + + Returns metadata for a single conversation item's audio segment, including the common playback + facts (role, format/codec, sample rate, channels, offset, duration) for both Foundry-managed + and bring-your-own-storage (BYOS) recordings; for BYOS the response additionally includes + ``blob_uri``, the URI of the recording in the customer's own storage (no SAS) that the customer + downloads with their own credentials. Requires the conversation to have persisted audio + (``store = true``); returns ``404`` when the conversation, item, or its audio was not + persisted. + + :param agent_name: The name of the agent. Required. + :type agent_name: str + :param conversation_id: The id of the conversation that contains the item. Required. + :type conversation_id: str + :param item_id: The id of the conversation item whose audio metadata is retrieved. Required. + :type item_id: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_V1_PREVIEW + :return: VoiceItemAudioResponse. The VoiceItemAudioResponse is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceItemAudioResponse + :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.VoiceItemAudioResponse] = kwargs.pop("cls", None) + + _request = build_agent_endpoint_conversations_get_agent_conversation_item_audio_request( + agent_name=agent_name, + conversation_id=conversation_id, + item_id=item_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) + + _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 = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.VoiceItemAudioResponse, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_agent_conversation_item_audio_content( # pylint: disable=name-too-long + self, + agent_name: str, + conversation_id: str, + item_id: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + **kwargs: Any + ) -> Iterator[bytes]: + """Stream a voice agent conversation item's audio. + + Streams a single conversation item's audio as a WAV (``audio/wav``) byte stream through the + service (no SAS URL). This route serves Foundry-managed storage only. For + bring-your-own-storage (BYOS) recordings the bytes are not proxied — the caller must download + directly from customer storage using the ``blob_uri`` returned by the item's ``/audio`` + metadata route — so this route returns ``409 Conflict`` for BYOS recordings. Returns ``404`` + when the conversation, item, or its audio was not persisted (``store = false``). + + :param agent_name: The name of the agent. Required. + :type agent_name: str + :param conversation_id: The id of the conversation that contains the item. Required. + :type conversation_id: str + :param item_id: The id of the conversation item whose audio is streamed. Required. + :type item_id: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_V1_PREVIEW + :return: Iterator[bytes] + :rtype: Iterator[bytes] + :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[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_agent_endpoint_conversations_get_agent_conversation_item_audio_content_request( + agent_name=agent_name, + conversation_id=conversation_id, + item_id=item_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) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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 + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_agent_conversation_audio( + self, + agent_name: str, + conversation_id: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + **kwargs: Any + ) -> _models.VoiceRecordingResponse: + """Get a voice agent conversation's merged recording metadata. + + Returns metadata for the whole-call merged stereo recording (user audio on the left channel, + agent audio on the right). The common metadata (format, sample rate, channels, channel layout, + duration) is returned for both Foundry-managed and bring-your-own-storage (BYOS) recordings; + for BYOS the response additionally includes ``blob_uri``, the URI of the recording in the + customer's own storage (no SAS) that the customer downloads with their own credentials. The + recording is built once from the per-turn segments after the session ends; a request against an + in-progress session returns ``409``. Requires the conversation to have persisted audio (``store + = true``); otherwise returns ``404``. + + :param agent_name: The name of the agent. Required. + :type agent_name: str + :param conversation_id: The id of the conversation whose merged recording metadata is + retrieved. Required. + :type conversation_id: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_V1_PREVIEW + :return: VoiceRecordingResponse. The VoiceRecordingResponse is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceRecordingResponse + :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.VoiceRecordingResponse] = kwargs.pop("cls", None) + + _request = build_agent_endpoint_conversations_get_agent_conversation_audio_request( + agent_name=agent_name, + conversation_id=conversation_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) + + _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 = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.VoiceRecordingResponse, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_agent_conversation_audio_content( + self, + agent_name: str, + conversation_id: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + **kwargs: Any + ) -> Iterator[bytes]: + """Stream a voice agent conversation's merged recording. + + Streams the whole-call merged stereo recording as a WAV (``audio/wav``) byte stream through the + service (no SAS URL). This route serves Foundry-managed storage only. For + bring-your-own-storage (BYOS) recordings the bytes are not proxied — the caller must download + directly from customer storage using the ``blob_uri`` returned by the metadata route — so this + route returns ``409 Conflict`` for BYOS recordings. A request against an in-progress session + also returns ``409`` (a distinct condition: session-not-ended versus BYOS-download-required). A + conversation without persisted audio (``store = false``) returns ``404``. + + :param agent_name: The name of the agent. Required. + :type agent_name: str + :param conversation_id: The id of the conversation whose merged recording is streamed. + Required. + :type conversation_id: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_V1_PREVIEW + :return: Iterator[bytes] + :rtype: Iterator[bytes] + :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[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_agent_endpoint_conversations_get_agent_conversation_audio_content_request( + agent_name=agent_name, + conversation_id=conversation_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) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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 + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + +class VoiceAgentsOperations: # pylint: disable=docstring-missing-param + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.voiceagents.VoiceAgentsClient`'s + :attr:`voice_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: VoiceAgentsClientConfiguration = 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_voice_agent( + self, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + name: str, + definition: _models.VoiceAgentDefinition, + content_type: str = "application/json", + state: Optional[Union[str, _models.AgentState]] = None, + metadata: Optional[dict[str, str]] = None, + description: Optional[str] = None, + blueprint_reference: Optional[_models.AgentBlueprintReference] = None, + draft: Optional[bool] = None, + agent_endpoint: Optional[_models.AgentEndpointConfig] = None, + agent_card: Optional[_models.AgentCard] = None, + **kwargs: Any + ) -> _models.VoiceAgentObject: + """Create a voice agent. + + Creates a new voice agent, or a new version of an existing one. + + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_V1_PREVIEW + :keyword 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. + :paramtype name: str + :keyword definition: The voice agent definition. Required. + :paramtype definition: ~azure.ai.voiceagents.models.VoiceAgentDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword state: The initial operational state of the agent. Defaults to 'enabled' if not + specified. Known values are: "enabled" and "disabled". Default value is None. + :paramtype state: str or ~azure.ai.voiceagents.models.AgentState + :keyword 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. + :paramtype metadata: dict[str, str] + :keyword description: A human-readable description of the agent. Default value is None. + :paramtype description: str + :keyword blueprint_reference: The blueprint reference for the agent. Default value is None. + :paramtype blueprint_reference: ~azure.ai.voiceagents.models.AgentBlueprintReference + :keyword draft: (Preview) Whether this agent version is a draft (candidate) rather than a + release. The service defaults to ``false`` if a value is not specified by the caller. Draft + versions are recorded but excluded from default 'latest' resolution and are not auto-promoted. + Default value is None. + :paramtype draft: bool + :keyword agent_endpoint: An optional endpoint configuration. If not specified, a default + endpoint configuration will be set for the agent. Default value is None. + :paramtype agent_endpoint: ~azure.ai.voiceagents.models.AgentEndpointConfig + :keyword agent_card: Optional agent card for the agent. Default value is None. + :paramtype agent_card: ~azure.ai.voiceagents.models.AgentCard + :return: VoiceAgentObject. The VoiceAgentObject is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceAgentObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_voice_agent( + self, + body: _types.CreateVoiceAgentRequest, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VoiceAgentObject: + """Create a voice agent. + + Creates a new voice agent, or a new version of an existing one. + + :param body: Required. + :type body: ~azure.ai.voiceagents.types.CreateVoiceAgentRequest + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_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: VoiceAgentObject. The VoiceAgentObject is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceAgentObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_voice_agent( + self, + body: IO[bytes], + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VoiceAgentObject: + """Create a voice agent. + + Creates a new voice agent, or a new version of an existing one. + + :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. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_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: VoiceAgentObject. The VoiceAgentObject is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceAgentObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_voice_agent( # pylint: disable=too-many-locals + self, + body: Union[JSON, _types.CreateVoiceAgentRequest, IO[bytes]] = _Unset, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + name: str = _Unset, + definition: _models.VoiceAgentDefinition = _Unset, + state: Optional[Union[str, _models.AgentState]] = None, + metadata: Optional[dict[str, str]] = None, + description: Optional[str] = None, + blueprint_reference: Optional[_models.AgentBlueprintReference] = None, + draft: Optional[bool] = None, + agent_endpoint: Optional[_models.AgentEndpointConfig] = None, + agent_card: Optional[_models.AgentCard] = None, + **kwargs: Any + ) -> _models.VoiceAgentObject: + """Create a voice agent. + + Creates a new voice agent, or a new version of an existing one. + + :param body: Is one of the following types: JSON, CreateVoiceAgentRequest, IO[bytes] Required. + :type body: JSON or ~azure.ai.voiceagents.types.CreateVoiceAgentRequest or IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_V1_PREVIEW + :keyword 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. + :paramtype name: str + :keyword definition: The voice agent definition. Required. + :paramtype definition: ~azure.ai.voiceagents.models.VoiceAgentDefinition + :keyword state: The initial operational state of the agent. Defaults to 'enabled' if not + specified. Known values are: "enabled" and "disabled". Default value is None. + :paramtype state: str or ~azure.ai.voiceagents.models.AgentState + :keyword 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. + :paramtype metadata: dict[str, str] + :keyword description: A human-readable description of the agent. Default value is None. + :paramtype description: str + :keyword blueprint_reference: The blueprint reference for the agent. Default value is None. + :paramtype blueprint_reference: ~azure.ai.voiceagents.models.AgentBlueprintReference + :keyword draft: (Preview) Whether this agent version is a draft (candidate) rather than a + release. The service defaults to ``false`` if a value is not specified by the caller. Draft + versions are recorded but excluded from default 'latest' resolution and are not auto-promoted. + Default value is None. + :paramtype draft: bool + :keyword agent_endpoint: An optional endpoint configuration. If not specified, a default + endpoint configuration will be set for the agent. Default value is None. + :paramtype agent_endpoint: ~azure.ai.voiceagents.models.AgentEndpointConfig + :keyword agent_card: Optional agent card for the agent. Default value is None. + :paramtype agent_card: ~azure.ai.voiceagents.models.AgentCard + :return: VoiceAgentObject. The VoiceAgentObject is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceAgentObject + :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.VoiceAgentObject] = 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 = { + "agent_card": agent_card, + "agent_endpoint": agent_endpoint, + "blueprint_reference": blueprint_reference, + "definition": definition, + "description": description, + "draft": draft, + "metadata": metadata, + "name": name, + "state": state, + } + 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_voice_agents_create_voice_agent_request( + foundry_features=foundry_features, + 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) + + _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 = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.VoiceAgentObject, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_voice_agents( + self, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + limit: Optional[int] = None, + order: Optional[Union[str, _models.PageOrder]] = None, + before: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.VoiceAgentObject"]: + """List voice agents. + + Returns a paged collection of voice agents. + + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_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. + :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.voiceagents.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 VoiceAgentObject + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.voiceagents.models.VoiceAgentObject] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_models.VoiceAgentObject]] = 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_voice_agents_list_voice_agents_request( + foundry_features=foundry_features, + 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.VoiceAgentObject], + 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 = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_voice_agent( + self, + agent_name: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + **kwargs: Any + ) -> _models.VoiceAgentObject: + """Get a voice agent. + + Retrieves a voice agent by its unique name. + + :param agent_name: The name of the voice agent to retrieve. Required. + :type agent_name: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_V1_PREVIEW + :return: VoiceAgentObject. The VoiceAgentObject is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceAgentObject + :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.VoiceAgentObject] = kwargs.pop("cls", None) + + _request = build_voice_agents_get_voice_agent_request( + agent_name=agent_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 = 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.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.VoiceAgentObject, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update_voice_agent( + self, + agent_name: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + definition: _models.VoiceAgentDefinition, + content_type: str = "application/json", + metadata: Optional[dict[str, str]] = None, + description: Optional[str] = None, + blueprint_reference: Optional[_models.AgentBlueprintReference] = None, + **kwargs: Any + ) -> _models.VoiceAgentObject: + """Update a voice agent. + + Updates a voice 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 voice agent to update. Required. + :type agent_name: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_V1_PREVIEW + :keyword definition: The voice agent definition. Required. + :paramtype definition: ~azure.ai.voiceagents.models.VoiceAgentDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword 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. + :paramtype metadata: dict[str, str] + :keyword description: A human-readable description of the agent. Default value is None. + :paramtype description: str + :keyword blueprint_reference: The blueprint reference for the agent. Default value is None. + :paramtype blueprint_reference: ~azure.ai.voiceagents.models.AgentBlueprintReference + :return: VoiceAgentObject. The VoiceAgentObject is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceAgentObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_voice_agent( + self, + agent_name: str, + body: _types.UpdateVoiceAgentRequest, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VoiceAgentObject: + """Update a voice agent. + + Updates a voice 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 voice agent to update. Required. + :type agent_name: str + :param body: Required. + :type body: ~azure.ai.voiceagents.types.UpdateVoiceAgentRequest + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_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: VoiceAgentObject. The VoiceAgentObject is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceAgentObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_voice_agent( + self, + agent_name: str, + body: IO[bytes], + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VoiceAgentObject: + """Update a voice agent. + + Updates a voice 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 voice agent to update. 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. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_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: VoiceAgentObject. The VoiceAgentObject is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceAgentObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update_voice_agent( + self, + agent_name: str, + body: Union[JSON, _types.UpdateVoiceAgentRequest, IO[bytes]] = _Unset, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + definition: _models.VoiceAgentDefinition = _Unset, + metadata: Optional[dict[str, str]] = None, + description: Optional[str] = None, + blueprint_reference: Optional[_models.AgentBlueprintReference] = None, + **kwargs: Any + ) -> _models.VoiceAgentObject: + """Update a voice agent. + + Updates a voice 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 voice agent to update. Required. + :type agent_name: str + :param body: Is one of the following types: JSON, UpdateVoiceAgentRequest, IO[bytes] Required. + :type body: JSON or ~azure.ai.voiceagents.types.UpdateVoiceAgentRequest or IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_V1_PREVIEW + :keyword definition: The voice agent definition. Required. + :paramtype definition: ~azure.ai.voiceagents.models.VoiceAgentDefinition + :keyword 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. + :paramtype metadata: dict[str, str] + :keyword description: A human-readable description of the agent. Default value is None. + :paramtype description: str + :keyword blueprint_reference: The blueprint reference for the agent. Default value is None. + :paramtype blueprint_reference: ~azure.ai.voiceagents.models.AgentBlueprintReference + :return: VoiceAgentObject. The VoiceAgentObject is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceAgentObject + :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.VoiceAgentObject] = kwargs.pop("cls", None) + + if body is _Unset: + if definition is _Unset: + raise TypeError("missing required argument: definition") + body = { + "blueprint_reference": blueprint_reference, + "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" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_voice_agents_update_voice_agent_request( + agent_name=agent_name, + foundry_features=foundry_features, + 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) + + _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 = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.VoiceAgentObject, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete_voice_agent( # pylint: disable=inconsistent-return-statements + self, + agent_name: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + **kwargs: Any + ) -> None: + """Delete a voice agent. + + Deletes a voice agent and all of its versions. + + :param agent_name: The name of the voice agent to delete. Required. + :type agent_name: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_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_voice_agents_delete_voice_agent_request( + agent_name=agent_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 = 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 = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def enable_voice_agent( # pylint: disable=inconsistent-return-statements + self, + agent_name: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + **kwargs: Any + ) -> None: + """Enable a voice agent. + + Enables the specified voice agent, allowing it to accept new requests. This operation is + idempotent — enabling an already-enabled voice agent returns success with no side effects. + + :param agent_name: The name of the voice agent to enable. Required. + :type agent_name: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_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_voice_agents_enable_voice_agent_request( + agent_name=agent_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 = 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 = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def disable_voice_agent( # pylint: disable=inconsistent-return-statements + self, + agent_name: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + **kwargs: Any + ) -> None: + """Disable a voice agent. + + Disables the specified voice agent, preventing it from accepting new requests. This operation + is idempotent — disabling an already-disabled voice agent returns success with no side effects. + + :param agent_name: The name of the voice agent to disable. Required. + :type agent_name: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_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_voice_agents_disable_voice_agent_request( + agent_name=agent_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 = 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 = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + def generate_voice_agent( + self, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + name: str, + model_type: Union[str, _models.VoiceModelType], + model: str, + agent_type: Union[str, _models.VoiceAgentType], + use_case: Union[str, _models.VoiceAgentUseCase], + goal: str, + content_type: str = "application/json", + description: Optional[str] = None, + tools: Optional[list["_unions.VoiceAgentTool"]] = None, + draft: Optional[bool] = None, + **kwargs: Any + ) -> _models.VoiceAgentObject: + """Generate a voice agent. + + Generates and creates a voice agent from high-level inputs plus a natural-language goal. The + operation expands the goal into a full, editable definition, creates the agent through the + standard voice create path, and returns the created ``VoiceAgentObject``. The caller can edit + or override the generated fields afterward through normal versioning. + + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_V1_PREVIEW + :keyword name: The unique name for the agent to create. Required. + :paramtype name: str + :keyword model_type: How the model backing the generated agent is served: ``managed`` + (service-managed) or ``self_deployed`` (the customer's own deployment). Carried through to the + generated definition, not generated. Known values are: "managed" and "self_deployed". Required. + :paramtype model_type: str or ~azure.ai.voiceagents.models.VoiceModelType + :keyword model: The model paired with ``model_type``: the service-managed model name when + ``managed``, or the customer's Foundry deployment name when ``self_deployed``. Carried through, + not generated. Required. + :paramtype model: str + :keyword agent_type: The persona/tone to steer generation. Known values are: "personal" and + "business". Required. + :paramtype agent_type: str or ~azure.ai.voiceagents.models.VoiceAgentType + :keyword use_case: The scenario-template catalog entry the generator specializes for. Known + values are: "customer_support", "reception", "sales", "travel_assistant", "outreach", + "personal_assistant", "learning", "call_center", and "in_car". Required. + :paramtype use_case: str or ~azure.ai.voiceagents.models.VoiceAgentUseCase + :keyword goal: A natural-language description of what the agent should do; the seed for the + generated ``instructions``. Required. + :paramtype goal: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword description: An optional description for the agent. Generated from ``goal`` when + omitted. Default value is None. + :paramtype description: str + :keyword tools: Optional tools carried through verbatim onto the generated agent (see + ``VoiceAgentTool``). Default value is None. + :paramtype tools: list[~azure.ai.voiceagents.models.RealtimeFunctionTool or + ~azure.ai.voiceagents.models.VoiceAgentMcpTool or ~azure.ai.voiceagents.models.VoiceSystemTool + or ~azure.ai.voiceagents.models.VoiceToolboxTool] + :keyword draft: (Preview) When ``true``, the generated voice agent is created as a draft — an + editable, unpublished version the caller can review and refine before publishing it via the + standard create/version path. The service defaults to ``false`` if a value is not specified by + the caller, in which case the agent is created and published normally. Default value is None. + :paramtype draft: bool + :return: VoiceAgentObject. The VoiceAgentObject is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceAgentObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def generate_voice_agent( + self, + body: _types.GenerateVoiceAgentRequest, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VoiceAgentObject: + """Generate a voice agent. + + Generates and creates a voice agent from high-level inputs plus a natural-language goal. The + operation expands the goal into a full, editable definition, creates the agent through the + standard voice create path, and returns the created ``VoiceAgentObject``. The caller can edit + or override the generated fields afterward through normal versioning. + + :param body: Required. + :type body: ~azure.ai.voiceagents.types.GenerateVoiceAgentRequest + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_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: VoiceAgentObject. The VoiceAgentObject is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceAgentObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def generate_voice_agent( + self, + body: IO[bytes], + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VoiceAgentObject: + """Generate a voice agent. + + Generates and creates a voice agent from high-level inputs plus a natural-language goal. The + operation expands the goal into a full, editable definition, creates the agent through the + standard voice create path, and returns the created ``VoiceAgentObject``. The caller can edit + or override the generated fields afterward through normal versioning. + + :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. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_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: VoiceAgentObject. The VoiceAgentObject is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceAgentObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def generate_voice_agent( # pylint: disable=too-many-locals + self, + body: Union[JSON, _types.GenerateVoiceAgentRequest, IO[bytes]] = _Unset, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + name: str = _Unset, + model_type: Union[str, _models.VoiceModelType] = _Unset, + model: str = _Unset, + agent_type: Union[str, _models.VoiceAgentType] = _Unset, + use_case: Union[str, _models.VoiceAgentUseCase] = _Unset, + goal: str = _Unset, + description: Optional[str] = None, + tools: Optional[list["_unions.VoiceAgentTool"]] = None, + draft: Optional[bool] = None, + **kwargs: Any + ) -> _models.VoiceAgentObject: + """Generate a voice agent. + + Generates and creates a voice agent from high-level inputs plus a natural-language goal. The + operation expands the goal into a full, editable definition, creates the agent through the + standard voice create path, and returns the created ``VoiceAgentObject``. The caller can edit + or override the generated fields afterward through normal versioning. + + :param body: Is one of the following types: JSON, GenerateVoiceAgentRequest, IO[bytes] + Required. + :type body: JSON or ~azure.ai.voiceagents.types.GenerateVoiceAgentRequest or IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_V1_PREVIEW + :keyword name: The unique name for the agent to create. Required. + :paramtype name: str + :keyword model_type: How the model backing the generated agent is served: ``managed`` + (service-managed) or ``self_deployed`` (the customer's own deployment). Carried through to the + generated definition, not generated. Known values are: "managed" and "self_deployed". Required. + :paramtype model_type: str or ~azure.ai.voiceagents.models.VoiceModelType + :keyword model: The model paired with ``model_type``: the service-managed model name when + ``managed``, or the customer's Foundry deployment name when ``self_deployed``. Carried through, + not generated. Required. + :paramtype model: str + :keyword agent_type: The persona/tone to steer generation. Known values are: "personal" and + "business". Required. + :paramtype agent_type: str or ~azure.ai.voiceagents.models.VoiceAgentType + :keyword use_case: The scenario-template catalog entry the generator specializes for. Known + values are: "customer_support", "reception", "sales", "travel_assistant", "outreach", + "personal_assistant", "learning", "call_center", and "in_car". Required. + :paramtype use_case: str or ~azure.ai.voiceagents.models.VoiceAgentUseCase + :keyword goal: A natural-language description of what the agent should do; the seed for the + generated ``instructions``. Required. + :paramtype goal: str + :keyword description: An optional description for the agent. Generated from ``goal`` when + omitted. Default value is None. + :paramtype description: str + :keyword tools: Optional tools carried through verbatim onto the generated agent (see + ``VoiceAgentTool``). Default value is None. + :paramtype tools: list[~azure.ai.voiceagents.models.RealtimeFunctionTool or + ~azure.ai.voiceagents.models.VoiceAgentMcpTool or ~azure.ai.voiceagents.models.VoiceSystemTool + or ~azure.ai.voiceagents.models.VoiceToolboxTool] + :keyword draft: (Preview) When ``true``, the generated voice agent is created as a draft — an + editable, unpublished version the caller can review and refine before publishing it via the + standard create/version path. The service defaults to ``false`` if a value is not specified by + the caller, in which case the agent is created and published normally. Default value is None. + :paramtype draft: bool + :return: VoiceAgentObject. The VoiceAgentObject is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceAgentObject + :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.VoiceAgentObject] = kwargs.pop("cls", None) + + if body is _Unset: + if name is _Unset: + raise TypeError("missing required argument: name") + if model_type is _Unset: + raise TypeError("missing required argument: model_type") + if model is _Unset: + raise TypeError("missing required argument: model") + if agent_type is _Unset: + raise TypeError("missing required argument: agent_type") + if use_case is _Unset: + raise TypeError("missing required argument: use_case") + if goal is _Unset: + raise TypeError("missing required argument: goal") + body = { + "agent_type": agent_type, + "description": description, + "draft": draft, + "goal": goal, + "model": model, + "model_type": model_type, + "name": name, + "tools": tools, + "use_case": use_case, + } + 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_voice_agents_generate_voice_agent_request( + foundry_features=foundry_features, + 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) + + _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 = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.VoiceAgentObject, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_voice_agent_version( + self, + agent_name: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + definition: _models.VoiceAgentDefinition, + content_type: str = "application/json", + metadata: Optional[dict[str, str]] = None, + description: Optional[str] = None, + blueprint_reference: Optional[_models.AgentBlueprintReference] = None, + draft: Optional[bool] = None, + **kwargs: Any + ) -> _models.VoiceAgentVersionObject: + """Create a voice agent version. + + Creates a new version for the specified voice agent and returns the created version resource. + + :param agent_name: The name of the voice agent. Required. + :type agent_name: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_V1_PREVIEW + :keyword definition: The voice agent definition. Required. + :paramtype definition: ~azure.ai.voiceagents.models.VoiceAgentDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword 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. + :paramtype metadata: dict[str, str] + :keyword description: A human-readable description of the agent. Default value is None. + :paramtype description: str + :keyword blueprint_reference: The blueprint reference for the agent. Default value is None. + :paramtype blueprint_reference: ~azure.ai.voiceagents.models.AgentBlueprintReference + :keyword draft: (Preview) Whether this agent version is a draft (candidate) rather than a + release. The service defaults to ``false`` if a value is not specified by the caller. Draft + versions are recorded but excluded from default 'latest' resolution and are not auto-promoted. + Default value is None. + :paramtype draft: bool + :return: VoiceAgentVersionObject. The VoiceAgentVersionObject is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceAgentVersionObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_voice_agent_version( + self, + agent_name: str, + body: _types.CreateVoiceAgentVersionRequest, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VoiceAgentVersionObject: + """Create a voice agent version. + + Creates a new version for the specified voice agent and returns the created version resource. + + :param agent_name: The name of the voice agent. Required. + :type agent_name: str + :param body: Required. + :type body: ~azure.ai.voiceagents.types.CreateVoiceAgentVersionRequest + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_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: VoiceAgentVersionObject. The VoiceAgentVersionObject is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceAgentVersionObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_voice_agent_version( + self, + agent_name: str, + body: IO[bytes], + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VoiceAgentVersionObject: + """Create a voice agent version. + + Creates a new version for the specified voice agent and returns the created version resource. + + :param agent_name: The name of the voice agent. 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. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_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: VoiceAgentVersionObject. The VoiceAgentVersionObject is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceAgentVersionObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_voice_agent_version( + self, + agent_name: str, + body: Union[JSON, _types.CreateVoiceAgentVersionRequest, IO[bytes]] = _Unset, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + definition: _models.VoiceAgentDefinition = _Unset, + metadata: Optional[dict[str, str]] = None, + description: Optional[str] = None, + blueprint_reference: Optional[_models.AgentBlueprintReference] = None, + draft: Optional[bool] = None, + **kwargs: Any + ) -> _models.VoiceAgentVersionObject: + """Create a voice agent version. + + Creates a new version for the specified voice agent and returns the created version resource. + + :param agent_name: The name of the voice agent. Required. + :type agent_name: str + :param body: Is one of the following types: JSON, CreateVoiceAgentVersionRequest, IO[bytes] + Required. + :type body: JSON or ~azure.ai.voiceagents.types.CreateVoiceAgentVersionRequest or IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_V1_PREVIEW + :keyword definition: The voice agent definition. Required. + :paramtype definition: ~azure.ai.voiceagents.models.VoiceAgentDefinition + :keyword 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. + :paramtype metadata: dict[str, str] + :keyword description: A human-readable description of the agent. Default value is None. + :paramtype description: str + :keyword blueprint_reference: The blueprint reference for the agent. Default value is None. + :paramtype blueprint_reference: ~azure.ai.voiceagents.models.AgentBlueprintReference + :keyword draft: (Preview) Whether this agent version is a draft (candidate) rather than a + release. The service defaults to ``false`` if a value is not specified by the caller. Draft + versions are recorded but excluded from default 'latest' resolution and are not auto-promoted. + Default value is None. + :paramtype draft: bool + :return: VoiceAgentVersionObject. The VoiceAgentVersionObject is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceAgentVersionObject + :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.VoiceAgentVersionObject] = kwargs.pop("cls", None) + + if body is _Unset: + if definition is _Unset: + raise TypeError("missing required argument: definition") + body = { + "blueprint_reference": blueprint_reference, + "definition": definition, + "description": description, + "draft": draft, + "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_voice_agents_create_voice_agent_version_request( + agent_name=agent_name, + foundry_features=foundry_features, + 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) + + _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 = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.VoiceAgentVersionObject, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_voice_agent_versions( + self, + agent_name: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + limit: Optional[int] = None, + order: Optional[Union[str, _models.PageOrder]] = None, + before: Optional[str] = None, + include_drafts: Optional[bool] = None, + **kwargs: Any + ) -> ItemPaged["_models.VoiceAgentVersionObject"]: + """List voice agent versions. + + Returns a paged collection of versions for the specified voice agent. + + :param agent_name: The name of the voice agent to retrieve versions for. Required. + :type agent_name: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_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. + :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.voiceagents.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 include_drafts: (Preview) Whether to include draft versions in the listing. The + service defaults to ``false`` if a value is not specified by the caller (only non-draft + versions are returned). Default value is None. + :paramtype include_drafts: bool + :return: An iterator like instance of VoiceAgentVersionObject + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.voiceagents.models.VoiceAgentVersionObject] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_models.VoiceAgentVersionObject]] = 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_voice_agents_list_voice_agent_versions_request( + agent_name=agent_name, + foundry_features=foundry_features, + limit=limit, + order=order, + after=_continuation_token, + before=before, + include_drafts=include_drafts, + 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.VoiceAgentVersionObject], + 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 = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_voice_agent_version( + self, + agent_name: str, + agent_version: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + **kwargs: Any + ) -> _models.VoiceAgentVersionObject: + """Get a voice agent version. + + Retrieves the specified version of a voice agent by its agent name and version identifier. + + :param agent_name: The name of the voice agent to retrieve. Required. + :type agent_name: str + :param agent_version: The version of the voice agent to retrieve. Required. + :type agent_version: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_V1_PREVIEW + :return: VoiceAgentVersionObject. The VoiceAgentVersionObject is compatible with MutableMapping + :rtype: ~azure.ai.voiceagents.models.VoiceAgentVersionObject + :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.VoiceAgentVersionObject] = kwargs.pop("cls", None) + + _request = build_voice_agents_get_voice_agent_version_request( + agent_name=agent_name, + agent_version=agent_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) + + _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 = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.VoiceAgentVersionObject, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete_voice_agent_version( # pylint: disable=inconsistent-return-statements + self, + agent_name: str, + agent_version: str, + *, + foundry_features: Literal[AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW], + **kwargs: Any + ) -> None: + """Delete a voice agent version. + + Deletes a specific version of a voice agent. + + :param agent_name: The name of the voice agent to delete. Required. + :type agent_name: str + :param agent_version: The version of the voice agent to delete. Required. + :type agent_version: str + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. VOICE_AGENTS_V1_PREVIEW. Required. + :paramtype foundry_features: str or ~azure.ai.voiceagents.models.VOICE_AGENTS_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_voice_agents_delete_voice_agent_version_request( + agent_name=agent_name, + agent_version=agent_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) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/operations/_patch.py b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/operations/_patch.py new file mode 100644 index 000000000000..87676c65a8f0 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/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/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/py.typed b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/types.py b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/types.py new file mode 100644 index 000000000000..32c498a13f7d --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/azure/ai/voiceagents/types.py @@ -0,0 +1,6717 @@ +# 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 ( + AgentBlueprintReferenceType, + AgentEndpointAuthorizationSchemeType, + AzureVoiceType, + CreateTranscriptionResponseJsonUsageType, + RealtimeClientEventType, + RealtimeConversationItemMessageType, + RealtimeConversationItemType, + RealtimeMcpErrorType, + RealtimeServerEventType, + ToolChoiceParamType, + ToolType, + VersionSelectorType, + VoiceConversationItemType, + VoiceEndOfUtteranceDetectionModel, + VoiceTurnDetectionType, +) + +if TYPE_CHECKING: + from . import _unions + from .models import ( + AgentState, + AzureRealtimeNativeVoiceName, + CallableToolAllowedCaller, + PersonalVoiceModel, + RealtimeReasoningEffort, + ToolChoiceOptions, + VoiceAgentAnimationOutputType, + VoiceAgentAvatarOutputProtocol, + VoiceAgentAvatarType, + VoiceAgentAzureSemanticVadType, + VoiceAgentEchoCancellationReferenceSource, + VoiceAgentEndOfUtteranceModel, + VoiceAgentEndOfUtteranceThresholdLevel, + VoiceAgentEstimatedCostStatus, + VoiceAgentFileSearchCallStatus, + VoiceAgentHandoffAbortReason, + VoiceAgentHandoffReasoningEffort, + VoiceAgentHandoffTargetResponse, + VoiceAgentInterimResponseTrigger, + VoiceAgentMcpResponseScheduling, + VoiceAgentPipelineFamily, + VoiceAgentResponseAudioFormat, + VoiceAgentResponseStatus, + VoiceAgentSessionIncludeOption, + VoiceAgentType, + VoiceAgentUseCase, + VoiceAgentWebSearchCallStatus, + VoiceAudioFormatType, + VoiceAudioTimestampType, + VoiceAvatarOutputProtocol, + VoiceAvatarType, + VoiceEndOfUtteranceThresholdLevel, + VoiceGreetingToolChoice, + VoiceIdsShared, + VoiceInputTranscriptionModel, + VoiceModelType, + VoiceNoiseReductionType, + VoiceOutputModality, + VoiceSystemToolName, + ) + + +class A2AProtocolConfiguration(TypedDict, total=False): + """Configuration specific to the A2A protocol.""" + + +class ActivityProtocolConfiguration(TypedDict, total=False): + """Configuration specific to the activity protocol. + + :ivar enable_m365_public_endpoint: Whether to enable the M365 public endpoint for the activity + protocol. + :vartype enable_m365_public_endpoint: bool + """ + + enable_m365_public_endpoint: bool + """Whether to enable the M365 public endpoint for the activity protocol.""" + + +class AgentCard(TypedDict, total=False): + """AgentCard. + + :ivar version: The version of the agent card. Required. + :vartype version: str + :ivar description: The description of the agent card. + :vartype description: str + :ivar skills: The set of skills that an agent can perform. Required. + :vartype skills: list["AgentCardSkill"] + """ + + version: Required[str] + """The version of the agent card. Required.""" + description: str + """The description of the agent card.""" + skills: Required[list["AgentCardSkill"]] + """The set of skills that an agent can perform. Required.""" + + +class AgentCardSkill(TypedDict, total=False): + """AgentCardSkill. + + :ivar id: a unique identifier for the skill. Required. + :vartype id: str + :ivar name: The name of the skill. Required. + :vartype name: str + :ivar description: A description of the skill. + :vartype description: str + :ivar tags: set of tagwords describing classes of capabilities for the skill. + :vartype tags: list[str] + :ivar examples: A list of example scenarios that the skill can perform. + :vartype examples: list[str] + """ + + id: Required[str] + """a unique identifier for the skill. Required.""" + name: Required[str] + """The name of the skill. Required.""" + description: str + """A description of the skill.""" + tags: list[str] + """set of tagwords describing classes of capabilities for the skill.""" + examples: list[str] + """A list of example scenarios that the skill can perform.""" + + +class AgentEndpointConfig(TypedDict, total=False): + """AgentEndpointConfig. + + :ivar version_selector: The version selector of the agent endpoint determines how traffic is + routed to different versions of the agent. + :vartype version_selector: "VersionSelector" + :ivar protocol_configuration: Per-protocol configuration for the agent endpoint. + :vartype protocol_configuration: "ProtocolConfiguration" + :ivar authorization_schemes: The authorization schemes supported by the agent endpoint. + :vartype authorization_schemes: list["AgentEndpointAuthorizationScheme"] + """ + + version_selector: "VersionSelector" + """The version selector of the agent endpoint determines how traffic is routed to different + versions of the agent.""" + protocol_configuration: "ProtocolConfiguration" + """Per-protocol configuration for the agent endpoint.""" + authorization_schemes: list["AgentEndpointAuthorizationScheme"] + """The authorization schemes supported by the agent endpoint.""" + + +class AzureAvatarVoiceSyncVoice(TypedDict, total=False): + """An Azure avatar voice-synchronization configuration. The runtime derives its voice name from + the avatar character and style. + + :ivar temperature: The synthesis temperature, from 0 to 1. + :vartype temperature: float + :ivar custom_lexicon_url: The URL of a custom pronunciation lexicon. + :vartype custom_lexicon_url: str + :ivar custom_text_normalization_url: The URL of a custom text-normalization service. + :vartype custom_text_normalization_url: str + :ivar prefer_locales: Preferred BCP-47 locales that influence language accents. + :vartype prefer_locales: list[str] + :ivar locale: The enforced BCP-47 locale. When omitted, the language is detected from the text. + :vartype locale: str + :ivar style: The speaking style, such as ``cheerful`` or ``sad``. + :vartype style: str + :ivar pitch: The SSML-compatible pitch adjustment, such as ``+5%``. + :vartype pitch: str + :ivar rate: The SSML-compatible speaking-rate adjustment, such as ``+10%``. + :vartype rate: str + :ivar volume: The SSML-compatible volume adjustment, such as ``+10`` or ``-6dB``. + :vartype volume: str + :ivar type: Required. An Azure avatar voice-synchronization voice. + :vartype type: Literal[AzureVoiceType.AVATAR_VOICE_SYNC] + :ivar model: The neural model used to synthesize the avatar voice. Required. Known values are: + "DragonLatestNeural", "DragonHDOmniLatestNeural", and "MAI-Voice". + :vartype model: Union[str, "PersonalVoiceModel"] + """ + + temperature: float + """The synthesis temperature, from 0 to 1.""" + custom_lexicon_url: str + """The URL of a custom pronunciation lexicon.""" + custom_text_normalization_url: str + """The URL of a custom text-normalization service.""" + prefer_locales: list[str] + """Preferred BCP-47 locales that influence language accents.""" + locale: str + """The enforced BCP-47 locale. When omitted, the language is detected from the text.""" + style: str + """The speaking style, such as ``cheerful`` or ``sad``.""" + pitch: str + """The SSML-compatible pitch adjustment, such as ``+5%``.""" + rate: str + """The SSML-compatible speaking-rate adjustment, such as ``+10%``.""" + volume: str + """The SSML-compatible volume adjustment, such as ``+10`` or ``-6dB``.""" + type: Required[Literal[AzureVoiceType.AVATAR_VOICE_SYNC]] + """Required. An Azure avatar voice-synchronization voice.""" + model: Required[Union[str, "PersonalVoiceModel"]] + """The neural model used to synthesize the avatar voice. Required. Known values are: + \"DragonLatestNeural\", \"DragonHDOmniLatestNeural\", and \"MAI-Voice\".""" + + +class AzureCustomVoice(TypedDict, total=False): + """An Azure custom neural voice configuration. + + :ivar temperature: The synthesis temperature, from 0 to 1. + :vartype temperature: float + :ivar custom_lexicon_url: The URL of a custom pronunciation lexicon. + :vartype custom_lexicon_url: str + :ivar custom_text_normalization_url: The URL of a custom text-normalization service. + :vartype custom_text_normalization_url: str + :ivar prefer_locales: Preferred BCP-47 locales that influence language accents. + :vartype prefer_locales: list[str] + :ivar locale: The enforced BCP-47 locale. When omitted, the language is detected from the text. + :vartype locale: str + :ivar style: The speaking style, such as ``cheerful`` or ``sad``. + :vartype style: str + :ivar pitch: The SSML-compatible pitch adjustment, such as ``+5%``. + :vartype pitch: str + :ivar rate: The SSML-compatible speaking-rate adjustment, such as ``+10%``. + :vartype rate: str + :ivar volume: The SSML-compatible volume adjustment, such as ``+10`` or ``-6dB``. + :vartype volume: str + :ivar type: Required. An Azure custom neural voice. + :vartype type: Literal[AzureVoiceType.AZURE_CUSTOM] + :ivar name: The custom voice name. Required. + :vartype name: str + :ivar endpoint_id: The Azure Speech custom voice deployment endpoint ID. Required. + :vartype endpoint_id: str + """ + + temperature: float + """The synthesis temperature, from 0 to 1.""" + custom_lexicon_url: str + """The URL of a custom pronunciation lexicon.""" + custom_text_normalization_url: str + """The URL of a custom text-normalization service.""" + prefer_locales: list[str] + """Preferred BCP-47 locales that influence language accents.""" + locale: str + """The enforced BCP-47 locale. When omitted, the language is detected from the text.""" + style: str + """The speaking style, such as ``cheerful`` or ``sad``.""" + pitch: str + """The SSML-compatible pitch adjustment, such as ``+5%``.""" + rate: str + """The SSML-compatible speaking-rate adjustment, such as ``+10%``.""" + volume: str + """The SSML-compatible volume adjustment, such as ``+10`` or ``-6dB``.""" + type: Required[Literal[AzureVoiceType.AZURE_CUSTOM]] + """Required. An Azure custom neural voice.""" + name: Required[str] + """The custom voice name. Required.""" + endpoint_id: Required[str] + """The Azure Speech custom voice deployment endpoint ID. Required.""" + + +class AzurePersonalVoice(TypedDict, total=False): + """An Azure personal voice configuration. + + :ivar temperature: The synthesis temperature, from 0 to 1. + :vartype temperature: float + :ivar custom_lexicon_url: The URL of a custom pronunciation lexicon. + :vartype custom_lexicon_url: str + :ivar custom_text_normalization_url: The URL of a custom text-normalization service. + :vartype custom_text_normalization_url: str + :ivar prefer_locales: Preferred BCP-47 locales that influence language accents. + :vartype prefer_locales: list[str] + :ivar locale: The enforced BCP-47 locale. When omitted, the language is detected from the text. + :vartype locale: str + :ivar style: The speaking style, such as ``cheerful`` or ``sad``. + :vartype style: str + :ivar pitch: The SSML-compatible pitch adjustment, such as ``+5%``. + :vartype pitch: str + :ivar rate: The SSML-compatible speaking-rate adjustment, such as ``+10%``. + :vartype rate: str + :ivar volume: The SSML-compatible volume adjustment, such as ``+10`` or ``-6dB``. + :vartype volume: str + :ivar type: Required. An Azure personal voice. + :vartype type: Literal[AzureVoiceType.AZURE_PERSONAL] + :ivar name: The personal voice name. Required. + :vartype name: str + :ivar model: The neural model used by the personal voice. Required. Known values are: + "DragonLatestNeural", "DragonHDOmniLatestNeural", and "MAI-Voice". + :vartype model: Union[str, "PersonalVoiceModel"] + """ + + temperature: float + """The synthesis temperature, from 0 to 1.""" + custom_lexicon_url: str + """The URL of a custom pronunciation lexicon.""" + custom_text_normalization_url: str + """The URL of a custom text-normalization service.""" + prefer_locales: list[str] + """Preferred BCP-47 locales that influence language accents.""" + locale: str + """The enforced BCP-47 locale. When omitted, the language is detected from the text.""" + style: str + """The speaking style, such as ``cheerful`` or ``sad``.""" + pitch: str + """The SSML-compatible pitch adjustment, such as ``+5%``.""" + rate: str + """The SSML-compatible speaking-rate adjustment, such as ``+10%``.""" + volume: str + """The SSML-compatible volume adjustment, such as ``+10`` or ``-6dB``.""" + type: Required[Literal[AzureVoiceType.AZURE_PERSONAL]] + """Required. An Azure personal voice.""" + name: Required[str] + """The personal voice name. Required.""" + model: Required[Union[str, "PersonalVoiceModel"]] + """The neural model used by the personal voice. Required. Known values are: + \"DragonLatestNeural\", \"DragonHDOmniLatestNeural\", and \"MAI-Voice\".""" + + +class AzureRealtimeNativeVoice(TypedDict, total=False): + """An Azure realtime-native voice configuration. + + :ivar type: The voice kind. Always ``azure-realtime-native``. Required. Default value is + "azure-realtime-native". + :vartype type: Literal["azure-realtime-native"] + :ivar name: The Azure realtime-native voice name. Required. Known values are: "aarti", + "alvaro", "andrew", "antonio", "ava", "clara", "dalia", "denise", "diego", "diya", "elsa", + "emma", "florian", "francisca", "hyunsu", "jorge", "keita", "liam", "meera", "nanami", + "natasha", "niwat", "premwadee", "remy", "ryan", "seraphina", "sonia", "sunhi", "sylvie", + "thierry", "william", "xiaoxiao", "ximena", and "yunxi". + :vartype name: Union[str, "AzureRealtimeNativeVoiceName"] + """ + + type: Required[Literal["azure-realtime-native"]] + """The voice kind. Always ``azure-realtime-native``. Required. Default value is + \"azure-realtime-native\".""" + name: Required[Union[str, "AzureRealtimeNativeVoiceName"]] + """The Azure realtime-native voice name. Required. Known values are: \"aarti\", \"alvaro\", + \"andrew\", \"antonio\", \"ava\", \"clara\", \"dalia\", \"denise\", \"diego\", \"diya\", + \"elsa\", \"emma\", \"florian\", \"francisca\", \"hyunsu\", \"jorge\", \"keita\", \"liam\", + \"meera\", \"nanami\", \"natasha\", \"niwat\", \"premwadee\", \"remy\", \"ryan\", + \"seraphina\", \"sonia\", \"sunhi\", \"sylvie\", \"thierry\", \"william\", \"xiaoxiao\", + \"ximena\", and \"yunxi\".""" + + +class AzureStandardVoice(TypedDict, total=False): + """An Azure standard neural voice configuration. + + :ivar temperature: The synthesis temperature, from 0 to 1. + :vartype temperature: float + :ivar custom_lexicon_url: The URL of a custom pronunciation lexicon. + :vartype custom_lexicon_url: str + :ivar custom_text_normalization_url: The URL of a custom text-normalization service. + :vartype custom_text_normalization_url: str + :ivar prefer_locales: Preferred BCP-47 locales that influence language accents. + :vartype prefer_locales: list[str] + :ivar locale: The enforced BCP-47 locale. When omitted, the language is detected from the text. + :vartype locale: str + :ivar style: The speaking style, such as ``cheerful`` or ``sad``. + :vartype style: str + :ivar pitch: The SSML-compatible pitch adjustment, such as ``+5%``. + :vartype pitch: str + :ivar rate: The SSML-compatible speaking-rate adjustment, such as ``+10%``. + :vartype rate: str + :ivar volume: The SSML-compatible volume adjustment, such as ``+10`` or ``-6dB``. + :vartype volume: str + :ivar type: Required. An Azure standard neural voice. + :vartype type: Literal[AzureVoiceType.AZURE_STANDARD] + :ivar name: The Azure neural voice name. Required. + :vartype name: str + :ivar multi_talker_speaker_name: The speaker name used by a multi-talker voice. + :vartype multi_talker_speaker_name: str + """ + + temperature: float + """The synthesis temperature, from 0 to 1.""" + custom_lexicon_url: str + """The URL of a custom pronunciation lexicon.""" + custom_text_normalization_url: str + """The URL of a custom text-normalization service.""" + prefer_locales: list[str] + """Preferred BCP-47 locales that influence language accents.""" + locale: str + """The enforced BCP-47 locale. When omitted, the language is detected from the text.""" + style: str + """The speaking style, such as ``cheerful`` or ``sad``.""" + pitch: str + """The SSML-compatible pitch adjustment, such as ``+5%``.""" + rate: str + """The SSML-compatible speaking-rate adjustment, such as ``+10%``.""" + volume: str + """The SSML-compatible volume adjustment, such as ``+10`` or ``-6dB``.""" + type: Required[Literal[AzureVoiceType.AZURE_STANDARD]] + """Required. An Azure standard neural voice.""" + name: Required[str] + """The Azure neural voice name. Required.""" + multi_talker_speaker_name: str + """The speaker name used by a multi-talker voice.""" + + +class BotServiceAuthorizationScheme(TypedDict, total=False): + """BotServiceAuthorizationScheme. + + :ivar type: Required. BOT_SERVICE. + :vartype type: Literal[AgentEndpointAuthorizationSchemeType.BOT_SERVICE] + """ + + type: Required[Literal[AgentEndpointAuthorizationSchemeType.BOT_SERVICE]] + """Required. BOT_SERVICE.""" + + +class BotServiceRbacAuthorizationScheme(TypedDict, total=False): + """BotServiceRbacAuthorizationScheme. + + :ivar type: Required. BOT_SERVICE_RBAC. + :vartype type: Literal[AgentEndpointAuthorizationSchemeType.BOT_SERVICE_RBAC] + """ + + type: Required[Literal[AgentEndpointAuthorizationSchemeType.BOT_SERVICE_RBAC]] + """Required. BOT_SERVICE_RBAC.""" + + +class BotServiceTenantAuthorizationScheme(TypedDict, total=False): + """BotServiceTenantAuthorizationScheme. + + :ivar type: Required. BOT_SERVICE_TENANT. + :vartype type: Literal[AgentEndpointAuthorizationSchemeType.BOT_SERVICE_TENANT] + """ + + type: Required[Literal[AgentEndpointAuthorizationSchemeType.BOT_SERVICE_TENANT]] + """Required. BOT_SERVICE_TENANT.""" + + +class EntraAuthorizationScheme(TypedDict, total=False): + """EntraAuthorizationScheme. + + :ivar type: Required. ENTRA. + :vartype type: Literal[AgentEndpointAuthorizationSchemeType.ENTRA] + """ + + type: Required[Literal[AgentEndpointAuthorizationSchemeType.ENTRA]] + """Required. ENTRA.""" + + +class FixedRatioVersionSelectionRule(TypedDict, total=False): + """FixedRatioVersionSelectionRule. + + :ivar agent_version: The agent version to route traffic to. Required. + :vartype agent_version: str + :ivar type: Required. FIXED_RATIO. + :vartype type: Literal[VersionSelectorType.FIXED_RATIO] + :ivar traffic_percentage: The percentage of traffic to route to the version. Must be between 0 + and 100. Required. + :vartype traffic_percentage: int + """ + + agent_version: Required[str] + """The agent version to route traffic to. Required.""" + type: Required[Literal[VersionSelectorType.FIXED_RATIO]] + """Required. FIXED_RATIO.""" + traffic_percentage: Required[int] + """The percentage of traffic to route to the version. Must be between 0 and 100. Required.""" + + +class InvocationsProtocolConfiguration(TypedDict, total=False): + """Configuration specific to the invocations protocol.""" + + +class InvocationsWsProtocolConfiguration(TypedDict, total=False): + """Configuration specific to the WebSocket-based invocations protocol.""" + + +class LlmGeneratedVoiceGreetingConfig(TypedDict, total=False): + """A greeting authored by the session model from a scoped opening-turn prompt. + + :ivar type: Required. Default value is "llm_generated". + :vartype type: Literal["llm_generated"] + :ivar prompt: The Handlebars prompt that guides the opening turn. Required. + :vartype prompt: str + :ivar fallback_text: The optional Handlebars text template synthesized when generation fails + before any greeting output. + :vartype fallback_text: str + :ivar tool_choice: The tool-selection policy for the opening response. Defaults to ``none``. + Known values are: "none", "auto", and "required". + :vartype tool_choice: Union[str, "VoiceGreetingToolChoice"] + """ + + type: Required[Literal["llm_generated"]] + """Required. Default value is \"llm_generated\".""" + prompt: Required[str] + """The Handlebars prompt that guides the opening turn. Required.""" + fallback_text: str + """The optional Handlebars text template synthesized when generation fails before any greeting + output.""" + tool_choice: Union[str, "VoiceGreetingToolChoice"] + """The tool-selection policy for the opening response. Defaults to ``none``. Known values are: + \"none\", \"auto\", and \"required\".""" + + +class LogProbProperties(TypedDict, total=False): + """A log probability object. + + :ivar token: The token that was used to generate the log probability. Required. + :vartype token: str + :ivar logprob: The log probability of the token. Required. + :vartype logprob: float + :ivar bytes: The bytes that were used to generate the log probability. Required. + :vartype bytes: list[int] + """ + + token: Required[str] + """The token that was used to generate the log probability. Required.""" + logprob: Required[float] + """The log probability of the token. Required.""" + bytes: Required[list[int]] + """The bytes that were used to generate the log probability. Required.""" + + +class ManagedAgentIdentityBlueprintReference(TypedDict, total=False): + """ManagedAgentIdentityBlueprintReference. + + :ivar type: Required. MANAGED_AGENT_IDENTITY_BLUEPRINT. + :vartype type: Literal[AgentBlueprintReferenceType.MANAGED_AGENT_IDENTITY_BLUEPRINT] + :ivar blueprint_id: The ID of the managed blueprint. Required. + :vartype blueprint_id: str + """ + + type: Required[Literal[AgentBlueprintReferenceType.MANAGED_AGENT_IDENTITY_BLUEPRINT]] + """Required. MANAGED_AGENT_IDENTITY_BLUEPRINT.""" + blueprint_id: Required[str] + """The ID of the managed blueprint. Required.""" + + +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: "MCPListToolsToolInputSchema" + :ivar annotations: + :vartype annotations: "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 McpProtocolConfiguration(TypedDict, total=False): + """Configuration specific to the MCP protocol.""" + + +class MCPTool(TypedDict, total=False): + """MCP tool. + + :ivar type: The type of the MCP tool. Always ``mcp``. Required. MCP. + :vartype type: Literal[ToolType.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``, ``connector_id``, or + ``tunnel_id`` must be provided. + :vartype server_url: str + :ivar connector_id: Identifier for service connectors, like those available in ChatGPT. One of + ``server_url``, ``connector_id``, or ``tunnel_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: Literal["connector_dropbox", "connector_gmail", + "connector_googlecalendar", "connector_googledrive", "connector_microsoftteams", + "connector_outlookcalendar", "connector_outlookemail", "connector_sharepoint"] + :ivar tunnel_id: The Secure MCP Tunnel ID to use instead of a direct server URL. One of + ``server_url``, ``connector_id``, or ``tunnel_id`` must be provided. + :vartype tunnel_id: 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: Union[list[str], "MCPToolFilter"] + :ivar allowed_callers: + :vartype allowed_callers: list[Union[str, "CallableToolAllowedCaller"]] + :ivar require_approval: Is one of the following types: MCPToolRequireApproval, + Literal["always"], Literal["never"] + :vartype require_approval: Union["MCPToolRequireApproval", Literal["always"], Literal["never"]] + :ivar defer_loading: Whether this MCP tool is deferred and discovered via tool search. + :vartype defer_loading: bool + :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 + :ivar tool_configs: Deprecated. This property is deprecated and will be removed in a future + version. + :vartype tool_configs: dict[str, "ToolConfig"] + """ + + 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``, ``connector_id``, or ``tunnel_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``, + ``connector_id``, or ``tunnel_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\"]""" + tunnel_id: str + """The Secure MCP Tunnel ID to use instead of a direct server URL. One of ``server_url``, + ``connector_id``, or ``tunnel_id`` must be provided.""" + 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.""" + allowed_callers: Optional[list[Union[str, "CallableToolAllowedCaller"]]] + require_approval: Optional[Union["MCPToolRequireApproval", Literal["always"], Literal["never"]]] + """Is one of the following types: MCPToolRequireApproval, Literal[\"always\"], Literal[\"never\"]""" + defer_loading: bool + """Whether this MCP tool is deferred and discovered via tool search.""" + 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.""" + tool_configs: dict[str, "ToolConfig"] + """Deprecated. This property is deprecated and will be removed in a future version.""" + + +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: "MCPToolFilter" + :ivar never: + :vartype never: "MCPToolFilter" + """ + + always: "MCPToolFilter" + never: "MCPToolFilter" + + +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 OpenAIVoice(TypedDict, total=False): + """An OpenAI built-in voice configuration with an explicit type discriminator. + + :ivar type: The voice kind. Always ``openai``. Required. Default value is "openai". + :vartype type: Literal["openai"] + :ivar name: The OpenAI built-in voice name. Required. Known values are: "alloy", "ash", + "ballad", "coral", "echo", "sage", "shimmer", "verse", "marin", and "cedar". + :vartype name: Union[str, "VoiceIdsShared"] + """ + + type: Required[Literal["openai"]] + """The voice kind. Always ``openai``. Required. Default value is \"openai\".""" + name: Required[Union[str, "VoiceIdsShared"]] + """The OpenAI built-in voice name. Required. Known values are: \"alloy\", \"ash\", \"ballad\", + \"coral\", \"echo\", \"sage\", \"shimmer\", \"verse\", \"marin\", and \"cedar\".""" + + +class ProtocolConfiguration(TypedDict, total=False): + """Per-protocol configuration for the agent endpoint. + + :ivar activity: Configuration for the activity protocol. + :vartype activity: "ActivityProtocolConfiguration" + :ivar responses: Configuration for the responses protocol. + :vartype responses: "ResponsesProtocolConfiguration" + :ivar a2a: Configuration for the A2A protocol. + :vartype a2a: "A2AProtocolConfiguration" + :ivar mcp: Configuration for the MCP protocol. + :vartype mcp: "McpProtocolConfiguration" + :ivar invocations: Configuration for the invocations protocol. + :vartype invocations: "InvocationsProtocolConfiguration" + :ivar invocations_ws: Configuration for the WebSocket-based invocations protocol. + :vartype invocations_ws: "InvocationsWsProtocolConfiguration" + """ + + activity: "ActivityProtocolConfiguration" + """Configuration for the activity protocol.""" + responses: "ResponsesProtocolConfiguration" + """Configuration for the responses protocol.""" + a2a: "A2AProtocolConfiguration" + """Configuration for the A2A protocol.""" + mcp: "McpProtocolConfiguration" + """Configuration for the MCP protocol.""" + invocations: "InvocationsProtocolConfiguration" + """Configuration for the invocations protocol.""" + invocations_ws: "InvocationsWsProtocolConfiguration" + """Configuration for the WebSocket-based invocations protocol.""" + + +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 RealtimeConversationItemFunctionCall(TypedDict, total=False): + """Realtime function call item. + + :ivar id: The unique ID of the item. This may be provided by the client or generated by the + server. + :vartype id: str + :ivar object: Identifier for the API object being returned - always ``realtime.item``. Optional + when creating a new item. Default value is "realtime.item". + :vartype object: Literal["realtime.item"] + :ivar type: The type of the item. Always ``function_call``. Required. FUNCTION_CALL. + :vartype type: Literal[RealtimeConversationItemType.FUNCTION_CALL] + :ivar status: The status of the item. Has no effect on the conversation. Is one of the + following types: Literal["completed"], Literal["incomplete"], Literal["in_progress"] + :vartype status: Literal["completed", "incomplete", "in_progress"] + :ivar call_id: The ID of the function call. + :vartype call_id: str + :ivar name: The name of the function being called. Required. + :vartype name: str + :ivar arguments: The arguments of the function call. This is a JSON-encoded string representing + the arguments passed to the function, for example ``{"arg1": "value1", "arg2": 42}``. Required. + :vartype arguments: str + """ + + id: str + """The unique ID of the item. This may be provided by the client or generated by the server.""" + object: Literal["realtime.item"] + """Identifier for the API object being returned - always ``realtime.item``. Optional when creating + a new item. Default value is \"realtime.item\".""" + type: Required[Literal[RealtimeConversationItemType.FUNCTION_CALL]] + """The type of the item. Always ``function_call``. Required. FUNCTION_CALL.""" + status: Literal["completed", "incomplete", "in_progress"] + """The status of the item. Has no effect on the conversation. Is one of the following types: + Literal[\"completed\"], Literal[\"incomplete\"], Literal[\"in_progress\"]""" + call_id: str + """The ID of the function call.""" + name: Required[str] + """The name of the function being called. Required.""" + arguments: Required[str] + """The arguments of the function call. This is a JSON-encoded string representing the arguments + passed to the function, for example ``{\"arg1\": \"value1\", \"arg2\": 42}``. Required.""" + + +class RealtimeConversationItemFunctionCallOutput(TypedDict, total=False): # pylint: disable=name-too-long + """Realtime function call output item. + + :ivar id: The unique ID of the item. This may be provided by the client or generated by the + server. + :vartype id: str + :ivar object: Identifier for the API object being returned - always ``realtime.item``. Optional + when creating a new item. Default value is "realtime.item". + :vartype object: Literal["realtime.item"] + :ivar type: The type of the item. Always ``function_call_output``. Required. + FUNCTION_CALL_OUTPUT. + :vartype type: Literal[RealtimeConversationItemType.FUNCTION_CALL_OUTPUT] + :ivar status: The status of the item. Has no effect on the conversation. Is one of the + following types: Literal["completed"], Literal["incomplete"], Literal["in_progress"] + :vartype status: Literal["completed", "incomplete", "in_progress"] + :ivar call_id: The ID of the function call this output is for. Required. + :vartype call_id: str + :ivar output: The output of the function call, this is free text and can contain any + information or simply be empty. Required. + :vartype output: str + """ + + id: str + """The unique ID of the item. This may be provided by the client or generated by the server.""" + object: Literal["realtime.item"] + """Identifier for the API object being returned - always ``realtime.item``. Optional when creating + a new item. Default value is \"realtime.item\".""" + type: Required[Literal[RealtimeConversationItemType.FUNCTION_CALL_OUTPUT]] + """The type of the item. Always ``function_call_output``. Required. FUNCTION_CALL_OUTPUT.""" + status: Literal["completed", "incomplete", "in_progress"] + """The status of the item. Has no effect on the conversation. Is one of the following types: + Literal[\"completed\"], Literal[\"incomplete\"], Literal[\"in_progress\"]""" + call_id: Required[str] + """The ID of the function call this output is for. Required.""" + output: Required[str] + """The output of the function call, this is free text and can contain any information or simply be + empty. Required.""" + + +class RealtimeConversationItemMessageAssistant(TypedDict, total=False): + """Realtime assistant message item. + + :ivar id: The unique ID of the item. This may be provided by the client or generated by the + server. + :vartype id: str + :ivar object: Identifier for the API object being returned - always ``realtime.item``. Optional + when creating a new item. Default value is "realtime.item". + :vartype object: Literal["realtime.item"] + :ivar type: The type of the item. Always ``message``. Required. Default value is "message". + :vartype type: Literal["message"] + :ivar status: The status of the item. Has no effect on the conversation. Is one of the + following types: Literal["completed"], Literal["incomplete"], Literal["in_progress"] + :vartype status: Literal["completed", "incomplete", "in_progress"] + :ivar role: The role of the message sender. Always ``assistant``. Required. ASSISTANT. + :vartype role: Literal[RealtimeConversationItemMessageType.ASSISTANT] + :ivar content: The content of the message. Required. + :vartype content: list["RealtimeConversationItemMessageAssistantContent"] + """ + + id: str + """The unique ID of the item. This may be provided by the client or generated by the server.""" + object: Literal["realtime.item"] + """Identifier for the API object being returned - always ``realtime.item``. Optional when creating + a new item. Default value is \"realtime.item\".""" + type: Required[Literal["message"]] + """The type of the item. Always ``message``. Required. Default value is \"message\".""" + status: Literal["completed", "incomplete", "in_progress"] + """The status of the item. Has no effect on the conversation. Is one of the following types: + Literal[\"completed\"], Literal[\"incomplete\"], Literal[\"in_progress\"]""" + role: Required[Literal[RealtimeConversationItemMessageType.ASSISTANT]] + """The role of the message sender. Always ``assistant``. Required. ASSISTANT.""" + content: Required[list["RealtimeConversationItemMessageAssistantContent"]] + """The content of the message. Required.""" + + +class RealtimeConversationItemMessageAssistantContent(TypedDict, total=False): # pylint: disable=name-too-long + """RealtimeConversationItemMessageAssistantContent. + + :ivar type: Is either a Literal["output_text"] type or a Literal["output_audio"] type. + :vartype type: Literal["output_text", "output_audio"] + :ivar text: + :vartype text: str + :ivar audio: + :vartype audio: str + :ivar transcript: + :vartype transcript: str + """ + + type: Literal["output_text", "output_audio"] + """Is either a Literal[\"output_text\"] type or a Literal[\"output_audio\"] type.""" + text: str + audio: str + transcript: str + + +class RealtimeConversationItemMessageSystem(TypedDict, total=False): + """Realtime system message item. + + :ivar id: The unique ID of the item. This may be provided by the client or generated by the + server. + :vartype id: str + :ivar object: Identifier for the API object being returned - always ``realtime.item``. Optional + when creating a new item. Default value is "realtime.item". + :vartype object: Literal["realtime.item"] + :ivar type: The type of the item. Always ``message``. Required. Default value is "message". + :vartype type: Literal["message"] + :ivar status: The status of the item. Has no effect on the conversation. Is one of the + following types: Literal["completed"], Literal["incomplete"], Literal["in_progress"] + :vartype status: Literal["completed", "incomplete", "in_progress"] + :ivar role: The role of the message sender. Always ``system``. Required. SYSTEM. + :vartype role: Literal[RealtimeConversationItemMessageType.SYSTEM] + :ivar content: The content of the message. Required. + :vartype content: list["RealtimeConversationItemMessageSystemContent"] + """ + + id: str + """The unique ID of the item. This may be provided by the client or generated by the server.""" + object: Literal["realtime.item"] + """Identifier for the API object being returned - always ``realtime.item``. Optional when creating + a new item. Default value is \"realtime.item\".""" + type: Required[Literal["message"]] + """The type of the item. Always ``message``. Required. Default value is \"message\".""" + status: Literal["completed", "incomplete", "in_progress"] + """The status of the item. Has no effect on the conversation. Is one of the following types: + Literal[\"completed\"], Literal[\"incomplete\"], Literal[\"in_progress\"]""" + role: Required[Literal[RealtimeConversationItemMessageType.SYSTEM]] + """The role of the message sender. Always ``system``. Required. SYSTEM.""" + content: Required[list["RealtimeConversationItemMessageSystemContent"]] + """The content of the message. Required.""" + + +class RealtimeConversationItemMessageSystemContent(TypedDict, total=False): # pylint: disable=name-too-long + """RealtimeConversationItemMessageSystemContent. + + :ivar type: Default value is "input_text". + :vartype type: Literal["input_text"] + :ivar text: + :vartype text: str + """ + + type: Literal["input_text"] + """Default value is \"input_text\".""" + text: str + + +class RealtimeConversationItemMessageUser(TypedDict, total=False): + """Realtime user message item. + + :ivar id: The unique ID of the item. This may be provided by the client or generated by the + server. + :vartype id: str + :ivar object: Identifier for the API object being returned - always ``realtime.item``. Optional + when creating a new item. Default value is "realtime.item". + :vartype object: Literal["realtime.item"] + :ivar type: The type of the item. Always ``message``. Required. Default value is "message". + :vartype type: Literal["message"] + :ivar status: The status of the item. Has no effect on the conversation. Is one of the + following types: Literal["completed"], Literal["incomplete"], Literal["in_progress"] + :vartype status: Literal["completed", "incomplete", "in_progress"] + :ivar role: The role of the message sender. Always ``user``. Required. USER. + :vartype role: Literal[RealtimeConversationItemMessageType.USER] + :ivar content: The content of the message. Required. + :vartype content: list["RealtimeConversationItemMessageUserContent"] + """ + + id: str + """The unique ID of the item. This may be provided by the client or generated by the server.""" + object: Literal["realtime.item"] + """Identifier for the API object being returned - always ``realtime.item``. Optional when creating + a new item. Default value is \"realtime.item\".""" + type: Required[Literal["message"]] + """The type of the item. Always ``message``. Required. Default value is \"message\".""" + status: Literal["completed", "incomplete", "in_progress"] + """The status of the item. Has no effect on the conversation. Is one of the following types: + Literal[\"completed\"], Literal[\"incomplete\"], Literal[\"in_progress\"]""" + role: Required[Literal[RealtimeConversationItemMessageType.USER]] + """The role of the message sender. Always ``user``. Required. USER.""" + content: Required[list["RealtimeConversationItemMessageUserContent"]] + """The content of the message. Required.""" + + +class RealtimeConversationItemMessageUserContent(TypedDict, total=False): # pylint: disable=name-too-long + """RealtimeConversationItemMessageUserContent. + + :ivar type: Is one of the following types: Literal["input_text"], Literal["input_audio"], + Literal["input_image"] + :vartype type: Literal["input_text", "input_audio", "input_image"] + :ivar text: + :vartype text: str + :ivar audio: + :vartype audio: str + :ivar image_url: + :vartype image_url: str + :ivar detail: Is one of the following types: Literal["auto"], Literal["low"], Literal["high"] + :vartype detail: Literal["auto", "low", "high"] + :ivar transcript: + :vartype transcript: str + """ + + type: Literal["input_text", "input_audio", "input_image"] + """Is one of the following types: Literal[\"input_text\"], Literal[\"input_audio\"], + Literal[\"input_image\"]""" + text: str + audio: str + image_url: str + detail: Literal["auto", "low", "high"] + """Is one of the following types: Literal[\"auto\"], Literal[\"low\"], Literal[\"high\"]""" + transcript: str + + +class RealtimeFunctionTool(TypedDict, total=False): + """Function tool. + + :ivar type: The type of the tool, i.e. ``function``. Default value is "function". + :vartype type: Literal["function"] + :ivar name: The name of the function. + :vartype name: str + :ivar description: The description of the function, including guidance on when and how to call + it, and guidance about what to tell the user when calling (if anything). + :vartype description: str + :ivar parameters: Parameters of the function in JSON Schema. + :vartype parameters: "RealtimeFunctionToolParameters" + """ + + type: Literal["function"] + """The type of the tool, i.e. ``function``. Default value is \"function\".""" + name: str + """The name of the function.""" + description: str + """The description of the function, including guidance on when and how to call it, and guidance + about what to tell the user when calling (if anything).""" + parameters: "RealtimeFunctionToolParameters" + """Parameters of the function in JSON Schema.""" + + +class RealtimeFunctionToolParameters(TypedDict, total=False): + """RealtimeFunctionToolParameters.""" + + +class RealtimeMCPApprovalRequest(TypedDict, total=False): + """Realtime MCP approval request. + + :ivar type: The type of the item. Always ``mcp_approval_request``. Required. + MCP_APPROVAL_REQUEST. + :vartype type: Literal[RealtimeConversationItemType.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[RealtimeConversationItemType.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 RealtimeMCPApprovalResponse(TypedDict, total=False): + """Realtime MCP approval response. + + :ivar type: The type of the item. Always ``mcp_approval_response``. Required. + MCP_APPROVAL_RESPONSE. + :vartype type: Literal[RealtimeConversationItemType.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[RealtimeConversationItemType.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 RealtimeMCPHTTPError(TypedDict, total=False): + """Realtime MCP HTTP error. + + :ivar type: Required. HTTP_ERROR. + :vartype type: Literal[RealtimeMcpErrorType.HTTP_ERROR] + :ivar code: Required. + :vartype code: int + :ivar message: Required. + :vartype message: str + """ + + type: Required[Literal[RealtimeMcpErrorType.HTTP_ERROR]] + """Required. HTTP_ERROR.""" + code: Required[int] + """Required.""" + message: Required[str] + """Required.""" + + +class RealtimeMCPListTools(TypedDict, total=False): + """Realtime MCP list tools. + + :ivar type: The type of the item. Always ``mcp_list_tools``. Required. MCP_LIST_TOOLS. + :vartype type: Literal[RealtimeConversationItemType.MCP_LIST_TOOLS] + :ivar id: The unique ID of the list. + :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["MCPListToolsTool"] + """ + + type: Required[Literal[RealtimeConversationItemType.MCP_LIST_TOOLS]] + """The type of the item. Always ``mcp_list_tools``. Required. MCP_LIST_TOOLS.""" + id: str + """The unique ID of the list.""" + server_label: Required[str] + """The label of the MCP server. Required.""" + tools: Required[list["MCPListToolsTool"]] + """The tools available on the server. Required.""" + + +class RealtimeMCPProtocolError(TypedDict, total=False): + """Realtime MCP protocol error. + + :ivar type: Required. PROTOCOL_ERROR. + :vartype type: Literal[RealtimeMcpErrorType.PROTOCOL_ERROR] + :ivar code: Required. + :vartype code: int + :ivar message: Required. + :vartype message: str + """ + + type: Required[Literal[RealtimeMcpErrorType.PROTOCOL_ERROR]] + """Required. PROTOCOL_ERROR.""" + code: Required[int] + """Required.""" + message: Required[str] + """Required.""" + + +class RealtimeMCPToolCall(TypedDict, total=False): + """Realtime MCP tool call. + + :ivar type: The type of the item. Always ``mcp_call``. Required. MCP_CALL. + :vartype type: Literal[RealtimeConversationItemType.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 approval_request_id: + :vartype approval_request_id: str + :ivar output: + :vartype output: str + :ivar error: + :vartype error: "RealtimeMCPError" + """ + + type: Required[Literal[RealtimeConversationItemType.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.""" + approval_request_id: Optional[str] + output: Optional[str] + error: "RealtimeMCPError" + + +class RealtimeMCPToolExecutionError(TypedDict, total=False): + """Realtime MCP tool execution error. + + :ivar type: Required. TOOL_EXECUTION_ERROR. + :vartype type: Literal[RealtimeMcpErrorType.TOOL_EXECUTION_ERROR] + :ivar message: Required. + :vartype message: str + """ + + type: Required[Literal[RealtimeMcpErrorType.TOOL_EXECUTION_ERROR]] + """Required. TOOL_EXECUTION_ERROR.""" + message: Required[str] + """Required.""" + + +class RealtimeReasoning(TypedDict, total=False): + """Realtime reasoning configuration. + + :ivar effort: Known values are: "minimal", "low", "medium", "high", and "xhigh". + :vartype effort: Union[str, "RealtimeReasoningEffort"] + """ + + effort: Union[str, "RealtimeReasoningEffort"] + """Known values are: \"minimal\", \"low\", \"medium\", \"high\", and \"xhigh\".""" + + +class RealtimeResponseStatusDetails(TypedDict, total=False): + """RealtimeResponseStatusDetails. + + :ivar type: Is one of the following types: Literal["completed"], Literal["cancelled"], + Literal["failed"], Literal["incomplete"] + :vartype type: Literal["completed", "cancelled", "failed", "incomplete"] + :ivar reason: Is one of the following types: Literal["turn_detected"], + Literal["client_cancelled"], Literal["max_output_tokens"], Literal["content_filter"] + :vartype reason: Literal["turn_detected", "client_cancelled", "max_output_tokens", + "content_filter"] + :ivar error: + :vartype error: "RealtimeResponseStatusDetailsError" + """ + + type: Literal["completed", "cancelled", "failed", "incomplete"] + """Is one of the following types: Literal[\"completed\"], Literal[\"cancelled\"], + Literal[\"failed\"], Literal[\"incomplete\"]""" + reason: Literal["turn_detected", "client_cancelled", "max_output_tokens", "content_filter"] + """Is one of the following types: Literal[\"turn_detected\"], Literal[\"client_cancelled\"], + Literal[\"max_output_tokens\"], Literal[\"content_filter\"]""" + error: "RealtimeResponseStatusDetailsError" + + +class RealtimeResponseStatusDetailsError(TypedDict, total=False): + """RealtimeResponseStatusDetailsError. + + :ivar type: + :vartype type: str + :ivar code: + :vartype code: str + """ + + type: str + code: str + + +class RealtimeResponseUsage(TypedDict, total=False): + """RealtimeResponseUsage. + + :ivar total_tokens: + :vartype total_tokens: int + :ivar input_tokens: + :vartype input_tokens: int + :ivar output_tokens: + :vartype output_tokens: int + :ivar input_token_details: + :vartype input_token_details: "RealtimeResponseUsageInputTokenDetails" + :ivar output_token_details: + :vartype output_token_details: "RealtimeResponseUsageOutputTokenDetails" + """ + + total_tokens: int + input_tokens: int + output_tokens: int + input_token_details: "RealtimeResponseUsageInputTokenDetails" + output_token_details: "RealtimeResponseUsageOutputTokenDetails" + + +class RealtimeResponseUsageInputTokenDetails(TypedDict, total=False): + """RealtimeResponseUsageInputTokenDetails. + + :ivar cached_tokens: + :vartype cached_tokens: int + :ivar text_tokens: + :vartype text_tokens: int + :ivar image_tokens: + :vartype image_tokens: int + :ivar audio_tokens: + :vartype audio_tokens: int + :ivar cached_tokens_details: + :vartype cached_tokens_details: "RealtimeResponseUsageInputTokenDetailsCachedTokensDetails" + """ + + cached_tokens: int + text_tokens: int + image_tokens: int + audio_tokens: int + cached_tokens_details: "RealtimeResponseUsageInputTokenDetailsCachedTokensDetails" + + +class RealtimeResponseUsageInputTokenDetailsCachedTokensDetails( + TypedDict, total=False +): # pylint: disable=name-too-long + """RealtimeResponseUsageInputTokenDetailsCachedTokensDetails. + + :ivar text_tokens: + :vartype text_tokens: int + :ivar image_tokens: + :vartype image_tokens: int + :ivar audio_tokens: + :vartype audio_tokens: int + """ + + text_tokens: int + image_tokens: int + audio_tokens: int + + +class RealtimeResponseUsageOutputTokenDetails(TypedDict, total=False): + """RealtimeResponseUsageOutputTokenDetails. + + :ivar text_tokens: + :vartype text_tokens: int + :ivar audio_tokens: + :vartype audio_tokens: int + """ + + text_tokens: int + audio_tokens: int + + +class RealtimeServerEventConversationItemInputAudioTranscriptionFailedError( + TypedDict, total=False +): # pylint: disable=name-too-long + """RealtimeServerEventConversationItemInputAudioTranscriptionFailedError. + + :ivar type: + :vartype type: str + :ivar code: + :vartype code: str + :ivar message: + :vartype message: str + :ivar param: + :vartype param: str + """ + + type: str + code: str + message: str + param: str + + +class RealtimeServerEventRateLimitsUpdatedRateLimits(TypedDict, total=False): # pylint: disable=name-too-long + """RealtimeServerEventRateLimitsUpdatedRateLimits. + + :ivar name: Is either a Literal["requests"] type or a Literal["tokens"] type. + :vartype name: Literal["requests", "tokens"] + :ivar limit: + :vartype limit: int + :ivar remaining: + :vartype remaining: int + :ivar reset_seconds: + :vartype reset_seconds: float + """ + + name: Literal["requests", "tokens"] + """Is either a Literal[\"requests\"] type or a Literal[\"tokens\"] type.""" + limit: int + remaining: int + reset_seconds: float + + +class RealtimeServerEventResponseContentPartAdded(TypedDict, total=False): # pylint: disable=name-too-long + """Returned when a new content part is added to an assistant message item during response + generation. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``response.content_part.added``. Required. + RESPONSE_CONTENT_PART_ADDED. + :vartype type: Literal[RealtimeServerEventType.RESPONSE_CONTENT_PART_ADDED] + :ivar response_id: The ID of the response. Required. + :vartype response_id: str + :ivar item_id: The ID of the item to which the content part was added. Required. + :vartype item_id: str + :ivar output_index: The index of the output item in the response. Required. + :vartype output_index: int + :ivar content_index: The index of the content part in the item's content array. Required. + :vartype content_index: int + :ivar part: The content part that was added. Required. + :vartype part: "RealtimeServerEventResponseContentPartAddedPart" + """ + + event_id: Required[str] + """The unique ID of the server event. Required.""" + type: Required[Literal[RealtimeServerEventType.RESPONSE_CONTENT_PART_ADDED]] + """The event type, must be ``response.content_part.added``. Required. RESPONSE_CONTENT_PART_ADDED.""" + response_id: Required[str] + """The ID of the response. Required.""" + item_id: Required[str] + """The ID of the item to which the content part was added. Required.""" + output_index: Required[int] + """The index of the output item in the response. Required.""" + content_index: Required[int] + """The index of the content part in the item's content array. Required.""" + part: Required["RealtimeServerEventResponseContentPartAddedPart"] + """The content part that was added. Required.""" + + +class RealtimeServerEventResponseContentPartAddedPart(TypedDict, total=False): # pylint: disable=name-too-long + """RealtimeServerEventResponseContentPartAddedPart. + + :ivar type: Is either a Literal["audio"] type or a Literal["text"] type. + :vartype type: Literal["audio", "text"] + :ivar text: + :vartype text: str + :ivar audio: + :vartype audio: str + :ivar transcript: + :vartype transcript: str + """ + + type: Literal["audio", "text"] + """Is either a Literal[\"audio\"] type or a Literal[\"text\"] type.""" + text: str + audio: str + transcript: str + + +class RealtimeToolChoiceFunction(TypedDict, total=False): + """A Realtime tool-choice object that forces the model to call a specific function. + + :ivar type: For function calling, the type is always ``function``. Required. FUNCTION. + :vartype type: Literal[ToolChoiceParamType.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 ResponsesProtocolConfiguration(TypedDict, total=False): + """Configuration specific to the responses protocol.""" + + +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. The service + defaults to ``false`` if a value is not specified by the caller. + :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. The service defaults to + ``false`` if a value is not specified by the caller.""" + + +class TemplateVoiceGreetingConfig(TypedDict, total=False): + """A deterministic greeting rendered with the voice agent's structured inputs and synthesized + without model-authored generation. + + :ivar type: Required. Default value is "template". + :vartype type: Literal["template"] + :ivar text: The Handlebars text template spoken at session start. Required. + :vartype text: str + """ + + type: Required[Literal["template"]] + """Required. Default value is \"template\".""" + text: Required[str] + """The Handlebars text template spoken at session start. Required.""" + + +class ToolChoiceFunction(TypedDict, total=False): + """Function tool. + + :ivar type: For function calling, the type is always ``function``. Required. FUNCTION. + :vartype type: Literal[ToolChoiceParamType.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 ToolChoiceMCP(TypedDict, total=False): + """MCP tool. + + :ivar type: For MCP tools, the type is always ``mcp``. Required. MCP. + :vartype type: Literal[ToolChoiceParamType.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 ToolConfig(TypedDict, total=False): + """Per-tool configuration that controls tool visibility and search behavior. + + :ivar pin: When true, the tool is always included in agent context and visible in + ``tools/list``. When false (default), the tool is hidden from ``tools/list`` and only + discoverable via ``tool_search``. + :vartype pin: bool + :ivar additional_search_text: Additional text indexed for tool_search. Supplements the native + tool description to improve discoverability. Does not alter ``tools/list`` output. + :vartype additional_search_text: str + """ + + pin: bool + """When true, the tool is always included in agent context and visible in ``tools/list``. When + false (default), the tool is hidden from ``tools/list`` and only discoverable via + ``tool_search``.""" + additional_search_text: str + """Additional text indexed for tool_search. Supplements the native tool description to improve + discoverability. Does not alter ``tools/list`` output.""" + + +class TranscriptTextUsageDuration(TypedDict, total=False): + """Duration Usage. + + :ivar type: The type of the usage object. Always ``duration`` for this variant. Required. + DURATION. + :vartype type: Literal[CreateTranscriptionResponseJsonUsageType.DURATION] + :ivar seconds: Duration of the input audio in seconds. Required. + :vartype seconds: str + """ + + type: Required[Literal[CreateTranscriptionResponseJsonUsageType.DURATION]] + """The type of the usage object. Always ``duration`` for this variant. Required. DURATION.""" + seconds: Required[str] + """Duration of the input audio in seconds. Required.""" + + +class TranscriptTextUsageTokens(TypedDict, total=False): + """Token Usage. + + :ivar type: The type of the usage object. Always ``tokens`` for this variant. Required. TOKENS. + :vartype type: Literal[CreateTranscriptionResponseJsonUsageType.TOKENS] + :ivar input_tokens: Number of input tokens billed for this request. Required. + :vartype input_tokens: int + :ivar input_token_details: Details about the input tokens billed for this request. + :vartype input_token_details: "TranscriptTextUsageTokensInputTokenDetails" + :ivar output_tokens: Number of output tokens generated. Required. + :vartype output_tokens: int + :ivar total_tokens: Total number of tokens used (input + output). Required. + :vartype total_tokens: int + """ + + type: Required[Literal[CreateTranscriptionResponseJsonUsageType.TOKENS]] + """The type of the usage object. Always ``tokens`` for this variant. Required. TOKENS.""" + input_tokens: Required[int] + """Number of input tokens billed for this request. Required.""" + input_token_details: "TranscriptTextUsageTokensInputTokenDetails" + """Details about the input tokens billed for this request.""" + output_tokens: Required[int] + """Number of output tokens generated. Required.""" + total_tokens: Required[int] + """Total number of tokens used (input + output). Required.""" + + +class TranscriptTextUsageTokensInputTokenDetails(TypedDict, total=False): # pylint: disable=name-too-long + """TranscriptTextUsageTokensInputTokenDetails. + + :ivar text_tokens: + :vartype text_tokens: int + :ivar audio_tokens: + :vartype audio_tokens: int + """ + + text_tokens: int + audio_tokens: int + + +class VersionSelector(TypedDict, total=False): + """VersionSelector. + + :ivar version_selection_rules: Required. + :vartype version_selection_rules: list["VersionSelectionRule"] + """ + + version_selection_rules: Required[list["VersionSelectionRule"]] + """Required.""" + + +class VoiceAgentAnimationConfig(TypedDict, total=False): + """Animation settings for a voice-agent session. + + :ivar model_name: The animation model name. + :vartype model_name: str + :ivar outputs: The requested animation output kinds. + :vartype outputs: list[Union[str, "VoiceAgentAnimationOutputType"]] + """ + + model_name: str + """The animation model name.""" + outputs: list[Union[str, "VoiceAgentAnimationOutputType"]] + """The requested animation output kinds.""" + + +class VoiceAgentAvatarIceServer(TypedDict, total=False): + """An ICE server used for avatar WebRTC negotiation. + + :ivar urls: Required. + :vartype urls: list[str] + :ivar username: + :vartype username: str + :ivar credential: + :vartype credential: str + """ + + urls: Required[list[str]] + """Required.""" + username: Optional[str] + credential: Optional[str] + + +class VoiceAgentAvatarScene(TypedDict, total=False): + """Avatar placement and motion settings. + + :ivar zoom: + :vartype zoom: float + :ivar position_x: + :vartype position_x: float + :ivar position_y: + :vartype position_y: float + :ivar rotation_x: + :vartype rotation_x: float + :ivar rotation_y: + :vartype rotation_y: float + :ivar rotation_z: + :vartype rotation_z: float + :ivar amplitude: + :vartype amplitude: float + """ + + zoom: float + position_x: float + position_y: float + rotation_x: float + rotation_y: float + rotation_z: float + amplitude: float + + +class VoiceAgentAvatarVideoBackground(TypedDict, total=False): + """The avatar video background. + + :ivar image_url: + :vartype image_url: str + :ivar color: + :vartype color: str + """ + + image_url: Optional[str] + color: Optional[str] + + +class VoiceAgentAvatarVideoCrop(TypedDict, total=False): + """The rectangular crop applied to avatar video. + + :ivar bottom_right: Required. + :vartype bottom_right: list[int] + :ivar top_left: Required. + :vartype top_left: list[int] + """ + + bottom_right: Required[list[int]] + """Required.""" + top_left: Required[list[int]] + """Required.""" + + +class VoiceAgentAvatarVideoParams(TypedDict, total=False): + """Avatar video encoder and presentation settings. + + :ivar bitrate: + :vartype bitrate: int + :ivar codec: Default value is "h264". + :vartype codec: Literal["h264"] + :ivar crop: + :vartype crop: "VoiceAgentAvatarVideoCrop" + :ivar resolution: + :vartype resolution: "VoiceAgentAvatarVideoResolution" + :ivar background: + :vartype background: "VoiceAgentAvatarVideoBackground" + :ivar gop_size: + :vartype gop_size: int + """ + + bitrate: int + codec: Literal["h264"] + """Default value is \"h264\".""" + crop: Optional["VoiceAgentAvatarVideoCrop"] + resolution: Optional["VoiceAgentAvatarVideoResolution"] + background: Optional["VoiceAgentAvatarVideoBackground"] + gop_size: int + + +class VoiceAgentAvatarVideoResolution(TypedDict, total=False): + """The avatar video resolution. + + :ivar width: Required. + :vartype width: int + :ivar height: Required. + :vartype height: int + """ + + width: Required[int] + """Required.""" + height: Required[int] + """Required.""" + + +class VoiceAgentAzureMultilingualSemanticVadTurnDetection(TypedDict, total=False): # pylint: disable=name-too-long + """Azure multilingual semantic VAD turn-detection settings. + + :ivar remove_filler_words: Whether filler words are removed from transcription. + :vartype remove_filler_words: bool + :ivar auto_truncate: Whether the input audio buffer is truncated automatically when speech + stops. + :vartype auto_truncate: bool + :ivar create_response: Whether a response is created automatically when speech stops. + :vartype create_response: bool + :ivar interrupt_response: Whether user speech may interrupt the agent's response. + :vartype interrupt_response: bool + :ivar type: Required. Multilingual Azure semantic voice activity detection. + :vartype type: Literal[VoiceTurnDetectionType.AZURE_SEMANTIC_VAD_MULTILINGUAL] + :ivar threshold: + :vartype threshold: float + :ivar prefix_padding_ms: + :vartype prefix_padding_ms: int + :ivar silence_duration_ms: + :vartype silence_duration_ms: int + :ivar idle_timeout_ms: + :vartype idle_timeout_ms: int + :ivar speech_duration_ms: + :vartype speech_duration_ms: int + :ivar end_of_utterance_detection: + :vartype end_of_utterance_detection: "VoiceAgentEndOfUtteranceDetection" + :ivar languages: + :vartype languages: list[str] + """ + + remove_filler_words: bool + """Whether filler words are removed from transcription.""" + auto_truncate: bool + """Whether the input audio buffer is truncated automatically when speech stops.""" + create_response: bool + """Whether a response is created automatically when speech stops.""" + interrupt_response: bool + """Whether user speech may interrupt the agent's response.""" + type: Required[Literal[VoiceTurnDetectionType.AZURE_SEMANTIC_VAD_MULTILINGUAL]] + """Required. Multilingual Azure semantic voice activity detection.""" + threshold: Optional[float] + prefix_padding_ms: Optional[int] + silence_duration_ms: Optional[int] + idle_timeout_ms: Optional[int] + speech_duration_ms: Optional[int] + end_of_utterance_detection: Optional["VoiceAgentEndOfUtteranceDetection"] + languages: Optional[list[str]] + + +class VoiceAgentAzureSemanticVadTurnDetection(TypedDict, total=False): + """Azure semantic VAD turn-detection settings. + + :ivar create_response: Whether a response is created automatically when speech stops. + :vartype create_response: bool + :ivar interrupt_response: Whether user speech may interrupt the agent's response. + :vartype interrupt_response: bool + :ivar type: Required. Known values are: "azure_semantic_vad" and "azure_semantic_vad_en". + :vartype type: Union[str, "VoiceAgentAzureSemanticVadType"] + :ivar threshold: + :vartype threshold: float + :ivar prefix_padding_ms: + :vartype prefix_padding_ms: int + :ivar silence_duration_ms: + :vartype silence_duration_ms: int + :ivar idle_timeout_ms: + :vartype idle_timeout_ms: int + :ivar speech_duration_ms: + :vartype speech_duration_ms: int + :ivar end_of_utterance_detection: + :vartype end_of_utterance_detection: "VoiceAgentEndOfUtteranceDetection" + :ivar remove_filler_words: + :vartype remove_filler_words: bool + :ivar languages: + :vartype languages: list[str] + :ivar auto_truncate: + :vartype auto_truncate: bool + """ + + create_response: bool + """Whether a response is created automatically when speech stops.""" + interrupt_response: bool + """Whether user speech may interrupt the agent's response.""" + type: Required[Union[str, "VoiceAgentAzureSemanticVadType"]] + """Required. Known values are: \"azure_semantic_vad\" and \"azure_semantic_vad_en\".""" + threshold: Optional[float] + prefix_padding_ms: Optional[int] + silence_duration_ms: Optional[int] + idle_timeout_ms: Optional[int] + speech_duration_ms: Optional[int] + end_of_utterance_detection: Optional["VoiceAgentEndOfUtteranceDetection"] + remove_filler_words: bool + languages: Optional[list[str]] + auto_truncate: bool + + +class VoiceAgentClientEventConversationItemCreate(TypedDict, total=False): # pylint: disable=name-too-long + """The ``conversation.item.create`` client event. + + :ivar event_id: Optional client-generated ID used to identify this event. + :vartype event_id: str + :ivar type: The event type, must be ``conversation.item.create``. Required. + CONVERSATION_ITEM_CREATE. + :vartype type: Literal[RealtimeClientEventType.CONVERSATION_ITEM_CREATE] + :ivar previous_item_id: The ID of the preceding item after which the new item will be inserted. + If not set, the new item will be appended to the end of the conversation. If set to ``root``, + the new item will be added to the beginning of the conversation. If set to an existing ID, it + allows an item to be inserted mid-conversation. If the ID cannot be found, an error will be + returned and the item will not be added. + :vartype previous_item_id: str + :ivar item: The conversation item to create. Required. Is either a + "_unions.VoiceAgentRequestConversationItem" type or a RealtimeMCPApprovalResponse type. + :vartype item: "_unions.VoiceAgentCreateConversationItem" + """ + + event_id: str + """Optional client-generated ID used to identify this event.""" + type: Required[Literal[RealtimeClientEventType.CONVERSATION_ITEM_CREATE]] + """The event type, must be ``conversation.item.create``. Required. CONVERSATION_ITEM_CREATE.""" + previous_item_id: str + """The ID of the preceding item after which the new item will be inserted. If not set, the new + item will be appended to the end of the conversation. If set to ``root``, the new item will be + added to the beginning of the conversation. If set to an existing ID, it allows an item to be + inserted mid-conversation. If the ID cannot be found, an error will be returned and the item + will not be added.""" + item: Required["_unions.VoiceAgentCreateConversationItem"] + """The conversation item to create. Required. Is either a + \"_unions.VoiceAgentRequestConversationItem\" type or a RealtimeMCPApprovalResponse type.""" + + +class VoiceAgentClientEventConversationItemDelete(TypedDict, total=False): # pylint: disable=name-too-long + """The ``conversation.item.delete`` client event. + + :ivar event_id: Optional client-generated ID used to identify this event. + :vartype event_id: str + :ivar type: The event type, must be ``conversation.item.delete``. Required. + CONVERSATION_ITEM_DELETE. + :vartype type: Literal[RealtimeClientEventType.CONVERSATION_ITEM_DELETE] + :ivar item_id: The ID of the item to delete. Required. + :vartype item_id: str + """ + + event_id: str + """Optional client-generated ID used to identify this event.""" + type: Required[Literal[RealtimeClientEventType.CONVERSATION_ITEM_DELETE]] + """The event type, must be ``conversation.item.delete``. Required. CONVERSATION_ITEM_DELETE.""" + item_id: Required[str] + """The ID of the item to delete. Required.""" + + +class VoiceAgentClientEventConversationItemRetrieve(TypedDict, total=False): # pylint: disable=name-too-long + """The ``conversation.item.retrieve`` client event. + + :ivar event_id: Optional client-generated ID used to identify this event. + :vartype event_id: str + :ivar type: The event type, must be ``conversation.item.retrieve``. Required. + CONVERSATION_ITEM_RETRIEVE. + :vartype type: Literal[RealtimeClientEventType.CONVERSATION_ITEM_RETRIEVE] + :ivar item_id: The ID of the item to retrieve. Required. + :vartype item_id: str + """ + + event_id: str + """Optional client-generated ID used to identify this event.""" + type: Required[Literal[RealtimeClientEventType.CONVERSATION_ITEM_RETRIEVE]] + """The event type, must be ``conversation.item.retrieve``. Required. CONVERSATION_ITEM_RETRIEVE.""" + item_id: Required[str] + """The ID of the item to retrieve. Required.""" + + +class VoiceAgentClientEventConversationItemTruncate(TypedDict, total=False): # pylint: disable=name-too-long + """The ``conversation.item.truncate`` client event. + + :ivar event_id: Optional client-generated ID used to identify this event. + :vartype event_id: str + :ivar type: The event type, must be ``conversation.item.truncate``. Required. + CONVERSATION_ITEM_TRUNCATE. + :vartype type: Literal[RealtimeClientEventType.CONVERSATION_ITEM_TRUNCATE] + :ivar item_id: The ID of the assistant message item to truncate. Only assistant message items + can be truncated. Required. + :vartype item_id: str + :ivar content_index: The index of the content part to truncate. Set this to ``0``. Required. + :vartype content_index: int + :ivar audio_end_ms: Inclusive duration up to which audio is truncated, in milliseconds. If the + audio_end_ms is greater than the actual audio duration, the server will respond with an error. + Required. + :vartype audio_end_ms: int + """ + + event_id: str + """Optional client-generated ID used to identify this event.""" + type: Required[Literal[RealtimeClientEventType.CONVERSATION_ITEM_TRUNCATE]] + """The event type, must be ``conversation.item.truncate``. Required. CONVERSATION_ITEM_TRUNCATE.""" + item_id: Required[str] + """The ID of the assistant message item to truncate. Only assistant message items can be + truncated. Required.""" + content_index: Required[int] + """The index of the content part to truncate. Set this to ``0``. Required.""" + audio_end_ms: Required[int] + """Inclusive duration up to which audio is truncated, in milliseconds. If the audio_end_ms is + greater than the actual audio duration, the server will respond with an error. Required.""" + + +class VoiceAgentClientEventInputAudioBufferAppend(TypedDict, total=False): # pylint: disable=name-too-long + """The ``input_audio_buffer.append`` client event. + + :ivar event_id: Optional client-generated ID used to identify this event. + :vartype event_id: str + :ivar type: The event type, must be ``input_audio_buffer.append``. Required. + INPUT_AUDIO_BUFFER_APPEND. + :vartype type: Literal[RealtimeClientEventType.INPUT_AUDIO_BUFFER_APPEND] + :ivar audio: Base64-encoded audio bytes. This must be in the format specified by the + ``input_audio_format`` field in the session configuration. Required. + :vartype audio: str + """ + + event_id: str + """Optional client-generated ID used to identify this event.""" + type: Required[Literal[RealtimeClientEventType.INPUT_AUDIO_BUFFER_APPEND]] + """The event type, must be ``input_audio_buffer.append``. Required. INPUT_AUDIO_BUFFER_APPEND.""" + audio: Required[str] + """Base64-encoded audio bytes. This must be in the format specified by the ``input_audio_format`` + field in the session configuration. Required.""" + + +class VoiceAgentClientEventInputAudioBufferClear(TypedDict, total=False): # pylint: disable=name-too-long + """The ``input_audio_buffer.clear`` client event. + + :ivar event_id: Optional client-generated ID used to identify this event. + :vartype event_id: str + :ivar type: The event type, must be ``input_audio_buffer.clear``. Required. + INPUT_AUDIO_BUFFER_CLEAR. + :vartype type: Literal[RealtimeClientEventType.INPUT_AUDIO_BUFFER_CLEAR] + """ + + event_id: str + """Optional client-generated ID used to identify this event.""" + type: Required[Literal[RealtimeClientEventType.INPUT_AUDIO_BUFFER_CLEAR]] + """The event type, must be ``input_audio_buffer.clear``. Required. INPUT_AUDIO_BUFFER_CLEAR.""" + + +class VoiceAgentClientEventInputAudioBufferCommit(TypedDict, total=False): # pylint: disable=name-too-long + """The ``input_audio_buffer.commit`` client event. + + :ivar event_id: Optional client-generated ID used to identify this event. + :vartype event_id: str + :ivar type: The event type, must be ``input_audio_buffer.commit``. Required. + INPUT_AUDIO_BUFFER_COMMIT. + :vartype type: Literal[RealtimeClientEventType.INPUT_AUDIO_BUFFER_COMMIT] + """ + + event_id: str + """Optional client-generated ID used to identify this event.""" + type: Required[Literal[RealtimeClientEventType.INPUT_AUDIO_BUFFER_COMMIT]] + """The event type, must be ``input_audio_buffer.commit``. Required. INPUT_AUDIO_BUFFER_COMMIT.""" + + +class VoiceAgentClientEventOutputAudioBufferClear(TypedDict, total=False): # pylint: disable=name-too-long + """The ``output_audio_buffer.clear`` client event. + + :ivar event_id: The unique ID of the client event used for error handling. + :vartype event_id: str + :ivar type: The event type, must be ``output_audio_buffer.clear``. Required. + OUTPUT_AUDIO_BUFFER_CLEAR. + :vartype type: Literal[RealtimeClientEventType.OUTPUT_AUDIO_BUFFER_CLEAR] + """ + + event_id: str + """The unique ID of the client event used for error handling.""" + type: Required[Literal[RealtimeClientEventType.OUTPUT_AUDIO_BUFFER_CLEAR]] + """The event type, must be ``output_audio_buffer.clear``. Required. OUTPUT_AUDIO_BUFFER_CLEAR.""" + + +class VoiceAgentClientEventResponseCancel(TypedDict, total=False): + """The ``response.cancel`` client event. + + :ivar event_id: Optional client-generated ID used to identify this event. + :vartype event_id: str + :ivar type: The event type, must be ``response.cancel``. Required. RESPONSE_CANCEL. + :vartype type: Literal[RealtimeClientEventType.RESPONSE_CANCEL] + :ivar response_id: A specific response ID to cancel - if not provided, will cancel an + in-progress response in the default conversation. + :vartype response_id: str + """ + + event_id: str + """Optional client-generated ID used to identify this event.""" + type: Required[Literal[RealtimeClientEventType.RESPONSE_CANCEL]] + """The event type, must be ``response.cancel``. Required. RESPONSE_CANCEL.""" + response_id: str + """A specific response ID to cancel - if not provided, will cancel an in-progress response in the + default conversation.""" + + +class VoiceAgentClientEventResponseCreate(TypedDict, total=False): + """The ``response.create`` client event. + + :ivar event_id: Optional client-generated ID used to identify this event. + :vartype event_id: str + :ivar type: The event type, must be ``response.create``. Required. RESPONSE_CREATE. + :vartype type: Literal[RealtimeClientEventType.RESPONSE_CREATE] + :ivar response: Parameters for the new response. + :vartype response: "VoiceAgentResponseCreateParams" + """ + + event_id: str + """Optional client-generated ID used to identify this event.""" + type: Required[Literal[RealtimeClientEventType.RESPONSE_CREATE]] + """The event type, must be ``response.create``. Required. RESPONSE_CREATE.""" + response: "VoiceAgentResponseCreateParams" + """Parameters for the new response.""" + + +class VoiceAgentClientEventSessionAvatarConnect(TypedDict, total=False): # pylint: disable=name-too-long + """The ``session.avatar.connect`` client event. + + :ivar type: The event type. Always ``session.avatar.connect``. Required. Default value is + "session.avatar.connect". + :vartype type: Literal["session.avatar.connect"] + :ivar event_id: An optional client-generated event identifier. + :vartype event_id: str + :ivar client_sdp: The client's SDP offer for avatar media negotiation. Required. + :vartype client_sdp: str + """ + + type: Required[Literal["session.avatar.connect"]] + """The event type. Always ``session.avatar.connect``. Required. Default value is + \"session.avatar.connect\".""" + event_id: str + """An optional client-generated event identifier.""" + client_sdp: Required[str] + """The client's SDP offer for avatar media negotiation. Required.""" + + +class VoiceAgentClientEventSessionUpdate(TypedDict, total=False): + """The ``session.update`` client event. + + :ivar event_id: Optional client-generated ID used to identify this event. This is an arbitrary + string that a client may assign. It will be passed back if there is an error with the event, + but the corresponding ``session.updated`` event will not include it. + :vartype event_id: str + :ivar type: The event type, must be ``session.update``. Required. SESSION_UPDATE. + :vartype type: Literal[RealtimeClientEventType.SESSION_UPDATE] + :ivar session: The stable realtime session fields to update. Required. + :vartype session: "VoiceAgentSessionUpdateConfig" + """ + + event_id: str + """Optional client-generated ID used to identify this event. This is an arbitrary string that a + client may assign. It will be passed back if there is an error with the event, but the + corresponding ``session.updated`` event will not include it.""" + type: Required[Literal[RealtimeClientEventType.SESSION_UPDATE]] + """The event type, must be ``session.update``. Required. SESSION_UPDATE.""" + session: Required["VoiceAgentSessionUpdateConfig"] + """The stable realtime session fields to update. Required.""" + + +class VoiceAgentDefinition(TypedDict, total=False): + """The voice agent definition. Its configuration (model, instructions, audio, tools, and optional + avatar) drives a managed speech-to-speech experience. The realtime voice session is established + through a separate connect operation that is not defined in this specification. Every create or + update produces a new immutable version. + + :ivar kind: The kind discriminator for a voice agent definition. Always ``voice``. Required. + Default value is "voice". + :vartype kind: Literal["voice"] + :ivar rai_config: Configuration for Responsible AI (RAI) content filtering and safety features. + :vartype rai_config: "RaiConfig" + :ivar model_type: How the model backing this agent is served. Together with ``model``, this + selects the model up front. ``managed`` uses a service-managed model; ``self_deployed`` uses + the customer's own Foundry deployment. This is independent of the architecture (realtime or + cascaded), which the service derives from the selected model. Required. Known values are: + "managed" and "self_deployed". + :vartype model_type: Union[str, "VoiceModelType"] + :ivar model: The model to use for this agent, paired with ``model_type``: the service-managed + model name when ``model_type`` is ``managed``, or the customer's Foundry deployment name when + ``model_type`` is ``self_deployed``. The model must support realtime or cascaded voice. The + service derives the architecture from the selected model. Required. + :vartype model: str + :ivar instructions: A system (or developer) message inserted into the model's context. Supports + template substitution via ``structured_inputs``, rendered per session before the live session + starts. + :vartype instructions: str + :ivar greeting: Optional session-start greeting. Template mode speaks exact rendered text; + LLM-generated mode asks the session model to author the opening response and may use configured + tools. + :vartype greeting: "VoiceGreetingConfig" + :ivar audio: The audio configuration, including input and output formats, voice, turn + detection, noise reduction, and transcription. These values are session defaults; a client may + override supported fields when connecting. + :vartype audio: "VoiceAudioConfig" + :ivar output_modalities: The output modalities the agent produces. Defaults to ``["audio"]``. + ``animation`` and ``avatar`` are available when an avatar is configured. + :vartype output_modalities: list[Union[str, "VoiceOutputModality"]] + :ivar avatar: Optional avatar configuration. These values are session defaults and may be + overridden when connecting. + :vartype avatar: "VoiceAvatarConfig" + :ivar tools: The tools the voice agent may use. Supported tool kinds are ``function`` (executed + by the client), ``mcp``, ``system`` (service-managed session controls), and ``toolbox``. + Server-side tools such as ``web_search``, ``azure_ai_search``, and ``openapi`` are provided + through a toolbox rather than declared directly. + :vartype tools: list["_unions.VoiceAgentTool"] + :ivar structured_inputs: Set of structured inputs that participate in prompt template + substitution, rendered per session before the live session starts. + :vartype structured_inputs: dict[str, "StructuredInputDefinition"] + :ivar store: Whether conversations with this agent are persisted. A single, all-or-nothing + persistence switch that defaults to ``false`` (privacy-safe: off by default). When ``true``, + Foundry persists the full conversation — the transcript/event timeline and raw audio. When + ``false``, nothing is persisted and no conversation is surfaced. There is no separate + audio-logging control; audio is persisted only as part of this switch. Latency/performance + telemetry (e.g. time-to-first-audio, inter-token latency, interruption) is observability-only + (customer trace / App Insights) and is not part of the persisted conversation content. + :vartype store: bool + """ + + kind: Required[Literal["voice"]] + """The kind discriminator for a voice agent definition. Always ``voice``. Required. Default value + is \"voice\".""" + rai_config: "RaiConfig" + """Configuration for Responsible AI (RAI) content filtering and safety features.""" + model_type: Required[Union[str, "VoiceModelType"]] + """How the model backing this agent is served. Together with ``model``, this selects the model up + front. ``managed`` uses a service-managed model; ``self_deployed`` uses the customer's own + Foundry deployment. This is independent of the architecture (realtime or cascaded), which the + service derives from the selected model. Required. Known values are: \"managed\" and + \"self_deployed\".""" + model: Required[str] + """The model to use for this agent, paired with ``model_type``: the service-managed model name + when ``model_type`` is ``managed``, or the customer's Foundry deployment name when + ``model_type`` is ``self_deployed``. The model must support realtime or cascaded voice. The + service derives the architecture from the selected model. Required.""" + instructions: str + """A system (or developer) message inserted into the model's context. Supports template + substitution via ``structured_inputs``, rendered per session before the live session starts.""" + greeting: "VoiceGreetingConfig" + """Optional session-start greeting. Template mode speaks exact rendered text; LLM-generated mode + asks the session model to author the opening response and may use configured tools.""" + audio: "VoiceAudioConfig" + """The audio configuration, including input and output formats, voice, turn detection, noise + reduction, and transcription. These values are session defaults; a client may override + supported fields when connecting.""" + output_modalities: list[Union[str, "VoiceOutputModality"]] + """The output modalities the agent produces. Defaults to ``[\"audio\"]``. ``animation`` and + ``avatar`` are available when an avatar is configured.""" + avatar: "VoiceAvatarConfig" + """Optional avatar configuration. These values are session defaults and may be overridden when + connecting.""" + tools: list["_unions.VoiceAgentTool"] + """The tools the voice agent may use. Supported tool kinds are ``function`` (executed by the + client), ``mcp``, ``system`` (service-managed session controls), and ``toolbox``. Server-side + tools such as ``web_search``, ``azure_ai_search``, and ``openapi`` are provided through a + toolbox rather than declared directly.""" + structured_inputs: dict[str, "StructuredInputDefinition"] + """Set of structured inputs that participate in prompt template substitution, rendered per session + before the live session starts.""" + store: bool + """Whether conversations with this agent are persisted. A single, all-or-nothing persistence + switch that defaults to ``false`` (privacy-safe: off by default). When ``true``, Foundry + persists the full conversation — the transcript/event timeline and raw audio. When ``false``, + nothing is persisted and no conversation is surfaced. There is no separate audio-logging + control; audio is persisted only as part of this switch. Latency/performance telemetry (e.g. + time-to-first-audio, inter-token latency, interruption) is observability-only (customer trace / + App Insights) and is not part of the persisted conversation content.""" + + +class VoiceAgentEchoCancellation(TypedDict, total=False): + """Server-side echo cancellation settings for input audio. + + :ivar type: The echo cancellation implementation. Always ``server_echo_cancellation``. + Required. Default value is "server_echo_cancellation". + :vartype type: Literal["server_echo_cancellation"] + :ivar reference_source: Whether reference audio comes from server playback or a client-provided + channel. Known values are: "server" and "client". + :vartype reference_source: Union[str, "VoiceAgentEchoCancellationReferenceSource"] + :ivar channels: The number of input channels. Use two interleaved channels when + ``reference_source`` is ``client``. + :vartype channels: int + """ + + type: Required[Literal["server_echo_cancellation"]] + """The echo cancellation implementation. Always ``server_echo_cancellation``. Required. Default + value is \"server_echo_cancellation\".""" + reference_source: Union[str, "VoiceAgentEchoCancellationReferenceSource"] + """Whether reference audio comes from server playback or a client-provided channel. Known values + are: \"server\" and \"client\".""" + channels: int + """The number of input channels. Use two interleaved channels when ``reference_source`` is + ``client``.""" + + +class VoiceAgentEndOfUtteranceDetection(TypedDict, total=False): + """End-of-utterance detection settings. + + :ivar model: Required. Known values are: "semantic_detection_v1", "semantic_detection_v1_en", + "semantic_detection_v1_multilingual", and "smart_end_of_turn_detection". + :vartype model: Union[str, "VoiceAgentEndOfUtteranceModel"] + :ivar threshold: + :vartype threshold: float + :ivar threshold_level: Known values are: "low", "medium", "high", and "default". + :vartype threshold_level: Union[str, "VoiceAgentEndOfUtteranceThresholdLevel"] + :ivar timeout: + :vartype timeout: float + :ivar timeout_ms: + :vartype timeout_ms: int + """ + + model: Required[Union[str, "VoiceAgentEndOfUtteranceModel"]] + """Required. Known values are: \"semantic_detection_v1\", \"semantic_detection_v1_en\", + \"semantic_detection_v1_multilingual\", and \"smart_end_of_turn_detection\".""" + threshold: Optional[float] + threshold_level: Optional[Union[str, "VoiceAgentEndOfUtteranceThresholdLevel"]] + """Known values are: \"low\", \"medium\", \"high\", and \"default\".""" + timeout: Optional[float] + timeout_ms: Optional[int] + + +class VoiceAgentEstimatedCost(TypedDict, total=False): + """A best-effort public-retail cost estimate for a response. + + :ivar amount: The total estimated amount, when available. Required. + :vartype amount: float + :ivar input_cost: The estimated input cost. + :vartype input_cost: float + :ivar output_cost: The estimated output cost. + :vartype output_cost: float + :ivar currency: The estimate currency. Always ``USD``. Default value is "USD". + :vartype currency: Literal["USD"] + :ivar voice_live_amount: The portion attributed to Voice Live processing. Required. + :vartype voice_live_amount: float + :ivar byom_model_amount: The portion attributed to a customer-provided model. + :vartype byom_model_amount: float + :ivar status: Whether the estimate is complete, partial, or unavailable. Required. Known values + are: "complete", "partial", and "unavailable". + :vartype status: Union[str, "VoiceAgentEstimatedCostStatus"] + :ivar price_version: The Voice Live price version used for the estimate. Required. + :vartype price_version: str + :ivar byom_model_price_version: The customer-provided model price version used for the + estimate. + :vartype byom_model_price_version: str + :ivar unpriced_components: Components for which no price was available. + :vartype unpriced_components: list[str] + """ + + amount: Required[Optional[float]] + """The total estimated amount, when available. Required.""" + input_cost: Optional[float] + """The estimated input cost.""" + output_cost: Optional[float] + """The estimated output cost.""" + currency: Literal["USD"] + """The estimate currency. Always ``USD``. Default value is \"USD\".""" + voice_live_amount: Required[float] + """The portion attributed to Voice Live processing. Required.""" + byom_model_amount: Optional[float] + """The portion attributed to a customer-provided model.""" + status: Required[Union[str, "VoiceAgentEstimatedCostStatus"]] + """Whether the estimate is complete, partial, or unavailable. Required. Known values are: + \"complete\", \"partial\", and \"unavailable\".""" + price_version: Required[str] + """The Voice Live price version used for the estimate. Required.""" + byom_model_price_version: Optional[str] + """The customer-provided model price version used for the estimate.""" + unpriced_components: list[str] + """Components for which no price was available.""" + + +class VoiceAgentFileSearchCallItem(TypedDict, total=False): + """A file-search output item. + + :ivar id: Required. + :vartype id: str + :ivar type: Required. Default value is "file_search_call". + :vartype type: Literal["file_search_call"] + :ivar status: Required. Known values are: "in_progress", "searching", "completed", + "incomplete", and "failed". + :vartype status: Union[str, "VoiceAgentFileSearchCallStatus"] + :ivar queries: + :vartype queries: list[str] + :ivar results: + :vartype results: list["VoiceAgentFileSearchResult"] + """ + + id: Required[str] + """Required.""" + type: Required[Literal["file_search_call"]] + """Required. Default value is \"file_search_call\".""" + status: Required[Union[str, "VoiceAgentFileSearchCallStatus"]] + """Required. Known values are: \"in_progress\", \"searching\", \"completed\", \"incomplete\", and + \"failed\".""" + queries: Optional[list[str]] + results: Optional[list["VoiceAgentFileSearchResult"]] + + +class VoiceAgentFileSearchResult(TypedDict, total=False): + """One result returned by a file-search call. + + :ivar attributes: + :vartype attributes: dict[str, "_unions.VoiceAgentFileSearchAttributeValue"] + :ivar file_id: + :vartype file_id: str + :ivar filename: + :vartype filename: str + :ivar score: + :vartype score: float + :ivar text: + :vartype text: str + """ + + attributes: Optional[dict[str, "_unions.VoiceAgentFileSearchAttributeValue"]] + file_id: Optional[str] + filename: Optional[str] + score: Optional[float] + text: Optional[str] + + +class VoiceAgentHandoffEdgeConfig(TypedDict, total=False): + """A directed transition between handoff nodes. + + :ivar id: The edge identifier. Required. + :vartype id: str + :ivar source: The source node identifier. Required. + :vartype source: str + :ivar target: The target node identifier. Required. + :vartype target: str + :ivar description: A non-empty description used by the model to select this transition. + Required. + :vartype description: str + :ivar cancel_on_interruption: Whether user interruption cancels the transition. + :vartype cancel_on_interruption: bool + :ivar delay_ms: The delay before the target behavior is committed, in milliseconds. + :vartype delay_ms: int + :ivar transfer_message: Optional text synthesized while transferring. + :vartype transfer_message: str + :ivar target_response: Whether the target automatically creates a response after transfer. + Known values are: "auto" and "none". + :vartype target_response: Union[str, "VoiceAgentHandoffTargetResponse"] + """ + + id: Required[str] + """The edge identifier. Required.""" + source: Required[str] + """The source node identifier. Required.""" + target: Required[str] + """The target node identifier. Required.""" + description: Required[str] + """A non-empty description used by the model to select this transition. Required.""" + cancel_on_interruption: bool + """Whether user interruption cancels the transition.""" + delay_ms: int + """The delay before the target behavior is committed, in milliseconds.""" + transfer_message: Optional[str] + """Optional text synthesized while transferring.""" + target_response: Union[str, "VoiceAgentHandoffTargetResponse"] + """Whether the target automatically creates a response after transfer. Known values are: \"auto\" + and \"none\".""" + + +class VoiceAgentHandoffEdgeState(TypedDict, total=False): + """Non-sensitive metadata for an effective handoff edge. + + :ivar id: The edge identifier. Required. + :vartype id: str + :ivar source: The source node identifier. Required. + :vartype source: str + :ivar target: The target node identifier. Required. + :vartype target: str + :ivar cancel_on_interruption: Whether user interruption cancels the transition. + :vartype cancel_on_interruption: bool + :ivar delay_ms: The delay before the target behavior is committed, in milliseconds. + :vartype delay_ms: int + :ivar transfer_message: Optional text synthesized while transferring. + :vartype transfer_message: str + :ivar target_response: Whether the target automatically creates a response after transfer. + Known values are: "auto" and "none". + :vartype target_response: Union[str, "VoiceAgentHandoffTargetResponse"] + """ + + id: Required[str] + """The edge identifier. Required.""" + source: Required[str] + """The source node identifier. Required.""" + target: Required[str] + """The target node identifier. Required.""" + cancel_on_interruption: bool + """Whether user interruption cancels the transition.""" + delay_ms: int + """The delay before the target behavior is committed, in milliseconds.""" + transfer_message: Optional[str] + """Optional text synthesized while transferring.""" + target_response: Union[str, "VoiceAgentHandoffTargetResponse"] + """Whether the target automatically creates a response after transfer. Known values are: \"auto\" + and \"none\".""" + + +class VoiceAgentHandoffGraphConfig(TypedDict, total=False): + """A customer-supplied handoff graph. + + :ivar max_transfers: The maximum number of successful transfers in the session. + :vartype max_transfers: int + :ivar max_attempts: The maximum number of transfer attempts in the session. + :vartype max_attempts: int + :ivar nodes: The explicitly configured handoff targets. Required. + :vartype nodes: list["VoiceAgentHandoffNodeConfig"] + :ivar edges: The directed transitions between handoff nodes. Required. + :vartype edges: list["VoiceAgentHandoffEdgeConfig"] + """ + + max_transfers: int + """The maximum number of successful transfers in the session.""" + max_attempts: Optional[int] + """The maximum number of transfer attempts in the session.""" + nodes: Required[list["VoiceAgentHandoffNodeConfig"]] + """The explicitly configured handoff targets. Required.""" + edges: Required[list["VoiceAgentHandoffEdgeConfig"]] + """The directed transitions between handoff nodes. Required.""" + + +class VoiceAgentHandoffNodeConfig(TypedDict, total=False): + """A configured handoff target and its node-scoped behavior. + + :ivar id: The node identifier. Required. + :vartype id: str + :ivar description: A non-empty description used to select this target. Required. + :vartype description: str + :ivar config: Session behavior applied after transferring to this node. Required. + :vartype config: "VoiceAgentHandoffNodeSessionConfig" + """ + + id: Required[str] + """The node identifier. Required.""" + description: Required[str] + """A non-empty description used to select this target. Required.""" + config: Required["VoiceAgentHandoffNodeSessionConfig"] + """Session behavior applied after transferring to this node. Required.""" + + +class VoiceAgentHandoffNodeSessionConfig(TypedDict, total=False): + """Session behavior applied at a handoff target. + + :ivar model: The target model, when different from the current node. + :vartype model: str + :ivar instructions: Instructions applied at the target node. + :vartype instructions: str + :ivar tools: Tools available at the target node. + :vartype tools: list["_unions.VoiceAgentSessionTool"] + :ivar tool_choice: Tool-selection behavior at the target node. Is either a Union[str, + "_models.ToolChoiceOptions"] type or a RealtimeToolChoiceFunction type. + :vartype tool_choice: "_unions.VoiceAgentToolChoice" + :ivar voice: The target node's voice. Is one of the following types: OpenAIVoice, AzureVoice, + AzureRealtimeNativeVoice + :vartype voice: "_unions.VoiceAgentVoice" + :ivar temperature: The target node's sampling temperature. + :vartype temperature: float + :ivar max_response_output_tokens: The target node's maximum output-token count. Is either a int + type or a Literal["inf"] type. + :vartype max_response_output_tokens: "_unions.VoiceAgentMaxOutputTokens" + :ivar reasoning_effort: The reasoning effort used at the target node. Known values are: "none", + "minimal", "low", "medium", "high", and "xhigh". + :vartype reasoning_effort: Union[str, "VoiceAgentHandoffReasoningEffort"] + :ivar voice_adaptation: Voice adaptation applied at the target node. + :vartype voice_adaptation: "VoiceAgentVoiceAdaptation" + :ivar interim_response: Interim-response settings applied at the target node. Is either a + VoiceAgentStaticInterimResponseConfig type or a VoiceAgentLlmInterimResponseConfig type. + :vartype interim_response: "_unions.VoiceAgentInterimResponse" + :ivar parallel_tool_calls: Whether the target model may call multiple tools in parallel. + :vartype parallel_tool_calls: bool + """ + + model: Optional[str] + """The target model, when different from the current node.""" + instructions: Optional[str] + """Instructions applied at the target node.""" + tools: Optional[list["_unions.VoiceAgentSessionTool"]] + """Tools available at the target node.""" + tool_choice: Optional["_unions.VoiceAgentToolChoice"] + """Tool-selection behavior at the target node. Is either a Union[str, + \"_models.ToolChoiceOptions\"] type or a RealtimeToolChoiceFunction type.""" + voice: Optional["_unions.VoiceAgentVoice"] + """The target node's voice. Is one of the following types: OpenAIVoice, AzureVoice, + AzureRealtimeNativeVoice""" + temperature: Optional[float] + """The target node's sampling temperature.""" + max_response_output_tokens: Optional["_unions.VoiceAgentMaxOutputTokens"] + """The target node's maximum output-token count. Is either a int type or a Literal[\"inf\"] type.""" + reasoning_effort: Optional[Union[str, "VoiceAgentHandoffReasoningEffort"]] + """The reasoning effort used at the target node. Known values are: \"none\", \"minimal\", \"low\", + \"medium\", \"high\", and \"xhigh\".""" + voice_adaptation: Optional["VoiceAgentVoiceAdaptation"] + """Voice adaptation applied at the target node.""" + interim_response: Optional["_unions.VoiceAgentInterimResponse"] + """Interim-response settings applied at the target node. Is either a + VoiceAgentStaticInterimResponseConfig type or a VoiceAgentLlmInterimResponseConfig type.""" + parallel_tool_calls: bool + """Whether the target model may call multiple tools in parallel.""" + + +class VoiceAgentHandoffNodeState(TypedDict, total=False): + """Non-sensitive metadata for an effective handoff node. + + :ivar id: The node identifier. Required. + :vartype id: str + :ivar description: The node description. Required. + :vartype description: str + :ivar implicit: Whether the service implicitly created this node. + :vartype implicit: bool + """ + + id: Required[str] + """The node identifier. Required.""" + description: Required[str] + """The node description. Required.""" + implicit: bool + """Whether the service implicitly created this node.""" + + +class VoiceAgentHandoffState(TypedDict, total=False): + """The effective handoff state returned by the service. + + :ivar pipeline_family: The runtime pipeline family. Required. Known values are: "cascaded" and + "realtime". + :vartype pipeline_family: Union[str, "VoiceAgentPipelineFamily"] + :ivar active_node_id: The active node identifier. Required. + :vartype active_node_id: str + :ivar node_generation: The active node generation. Required. + :vartype node_generation: int + :ivar transfer_count: The number of completed transfers. Required. + :vartype transfer_count: int + :ivar attempt_count: The number of transfer attempts. Required. + :vartype attempt_count: int + :ivar available_edge_ids: The edge identifiers currently available to the model. Required. + :vartype available_edge_ids: list[str] + :ivar transfer_tool: The function tool exposed to initiate transfers. Required. + :vartype transfer_tool: "RealtimeFunctionTool" + :ivar nodes: The compiled handoff nodes. Required. + :vartype nodes: list["VoiceAgentHandoffNodeState"] + :ivar edges: The compiled handoff edges. Required. + :vartype edges: list["VoiceAgentHandoffEdgeState"] + """ + + pipeline_family: Required[Union[str, "VoiceAgentPipelineFamily"]] + """The runtime pipeline family. Required. Known values are: \"cascaded\" and \"realtime\".""" + active_node_id: Required[str] + """The active node identifier. Required.""" + node_generation: Required[int] + """The active node generation. Required.""" + transfer_count: Required[int] + """The number of completed transfers. Required.""" + attempt_count: Required[int] + """The number of transfer attempts. Required.""" + available_edge_ids: Required[list[str]] + """The edge identifiers currently available to the model. Required.""" + transfer_tool: Required[Optional["RealtimeFunctionTool"]] + """The function tool exposed to initiate transfers. Required.""" + nodes: Required[list["VoiceAgentHandoffNodeState"]] + """The compiled handoff nodes. Required.""" + edges: Required[list["VoiceAgentHandoffEdgeState"]] + """The compiled handoff edges. Required.""" + + +class VoiceAgentLlmInterimResponseConfig(TypedDict, total=False): + """An interim response generated by a language model. + + :ivar triggers: Conditions that may trigger one interim response. + :vartype triggers: list[Union[str, "VoiceAgentInterimResponseTrigger"]] + :ivar latency_threshold_ms: The latency threshold in milliseconds. + :vartype latency_threshold_ms: int + :ivar type: Required. Default value is "llm_interim_response". + :vartype type: Literal["llm_interim_response"] + :ivar model: The model used to generate interim responses. + :vartype model: str + :ivar instructions: Optional instructions for generating interim responses. + :vartype instructions: str + :ivar max_completion_tokens: The maximum completion-token count for an interim response. + :vartype max_completion_tokens: int + """ + + triggers: list[Union[str, "VoiceAgentInterimResponseTrigger"]] + """Conditions that may trigger one interim response.""" + latency_threshold_ms: int + """The latency threshold in milliseconds.""" + type: Required[Literal["llm_interim_response"]] + """Required. Default value is \"llm_interim_response\".""" + model: str + """The model used to generate interim responses.""" + instructions: str + """Optional instructions for generating interim responses.""" + max_completion_tokens: int + """The maximum completion-token count for an interim response.""" + + +class VoiceAgentMcpAssignedManagedIdentity(TypedDict, total=False): + """A managed identity used to authorize a voice-agent MCP connection. + + :ivar type: Required. Default value is "assigned_managed_identity". + :vartype type: Literal["assigned_managed_identity"] + :ivar audience: Required. + :vartype audience: str + :ivar client_id: + :vartype client_id: str + """ + + type: Required[Literal["assigned_managed_identity"]] + """Required. Default value is \"assigned_managed_identity\".""" + audience: Required[str] + """Required.""" + client_id: str + + +class VoiceAgentMcpTool(TypedDict, total=False): + """An MCP tool available to a voice agent. + + :ivar type: The type of the MCP tool. Always ``mcp``. Required. MCP. + :vartype type: Literal[ToolType.MCP] + :ivar server_label: A label for this MCP server, used to identify it in tool calls. Required. + :vartype server_label: 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: Union[list[str], "MCPToolFilter"] + :ivar allowed_callers: + :vartype allowed_callers: list[Union[str, "CallableToolAllowedCaller"]] + :ivar require_approval: Is one of the following types: MCPToolRequireApproval, + Literal["always"], Literal["never"] + :vartype require_approval: Union["MCPToolRequireApproval", Literal["always"], Literal["never"]] + :ivar defer_loading: Whether this MCP tool is deferred and discovered via tool search. + :vartype defer_loading: bool + :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 + :ivar tool_configs: Deprecated. This property is deprecated and will be removed in a future + version. + :vartype tool_configs: dict[str, "ToolConfig"] + :ivar server_url: The URL for the MCP server. + :vartype server_url: str + :ivar response_scheduling: When the MCP invocation creates a follow-up response. Defaults to + ``when_idle`` so the agent continues after the tool call completes. Known values are: "silent", + "when_idle", "interrupt", and "skip_if_busy". + :vartype response_scheduling: Union[str, "VoiceAgentMcpResponseScheduling"] + """ + + 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_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.""" + allowed_callers: Optional[list[Union[str, "CallableToolAllowedCaller"]]] + require_approval: Optional[Union["MCPToolRequireApproval", Literal["always"], Literal["never"]]] + """Is one of the following types: MCPToolRequireApproval, Literal[\"always\"], Literal[\"never\"]""" + defer_loading: bool + """Whether this MCP tool is deferred and discovered via tool search.""" + 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.""" + tool_configs: dict[str, "ToolConfig"] + """Deprecated. This property is deprecated and will be removed in a future version.""" + server_url: str + """The URL for the MCP server.""" + response_scheduling: Union[str, "VoiceAgentMcpResponseScheduling"] + """When the MCP invocation creates a follow-up response. Defaults to ``when_idle`` so the agent + continues after the tool call completes. Known values are: \"silent\", \"when_idle\", + \"interrupt\", and \"skip_if_busy\".""" + + +class VoiceAgentRealtimeResponse(TypedDict, total=False): + """A realtime response returned by the voice-agent service. + + :ivar object: The object type. Always ``realtime.response``. Required. Default value is + "realtime.response". + :vartype object: Literal["realtime.response"] + :ivar id: The response identifier. Required. + :vartype id: str + :ivar status: The response lifecycle status. Required. Known values are: "in_progress", + "completed", "cancelled", "incomplete", and "failed". + :vartype status: Union[str, "VoiceAgentResponseStatus"] + :ivar status_details: Additional details for a terminal response status. Required. + :vartype status_details: "RealtimeResponseStatusDetails" + :ivar output: The items produced by the response. Required. + :vartype output: list["_unions.VoiceAgentResponseItem"] + :ivar usage: Token usage for the response. Required. + :vartype usage: "RealtimeResponseUsage" + :ivar estimated_cost: The best-effort response cost estimate. Returned only when cost output is + enabled. + :vartype estimated_cost: "VoiceAgentEstimatedCost" + :ivar conversation_id: The conversation identifier, or null for an out-of-band response. + :vartype conversation_id: str + :ivar modalities: The modalities used by the response. + :vartype modalities: list[Union[str, "VoiceOutputModality"]] + :ivar voice: The voice used by the response. Is one of the following types: OpenAIVoice, + AzureVoice, AzureRealtimeNativeVoice + :vartype voice: "_unions.VoiceAgentVoice" + :ivar output_audio_format: The output-audio format used by the response. Known values are: + "pcm16", "pcm16_8000hz", "pcm16_16000hz", "pcm16_22050hz", "pcm16_24000hz", "pcm16_44100hz", + "pcm16_48000hz", "g711_ulaw", "g711_alaw", "mp3", "mp3_24khz_48kbps", "mp3_24khz_96kbps", and + "mp3_24khz_160kbps". + :vartype output_audio_format: Union[str, "VoiceAgentResponseAudioFormat"] + :ivar temperature: The sampling temperature used by the response. + :vartype temperature: float + :ivar max_output_tokens: The maximum output-token count used by the response. Is either a int + type or a Literal["inf"] type. + :vartype max_output_tokens: "_unions.VoiceAgentMaxOutputTokens" + :ivar metadata: String key-value metadata attached to the response. + :vartype metadata: dict[str, str] + """ + + object: Required[Literal["realtime.response"]] + """The object type. Always ``realtime.response``. Required. Default value is + \"realtime.response\".""" + id: Required[str] + """The response identifier. Required.""" + status: Required[Union[str, "VoiceAgentResponseStatus"]] + """The response lifecycle status. Required. Known values are: \"in_progress\", \"completed\", + \"cancelled\", \"incomplete\", and \"failed\".""" + status_details: Required[Optional["RealtimeResponseStatusDetails"]] + """Additional details for a terminal response status. Required.""" + output: Required[list["_unions.VoiceAgentResponseItem"]] + """The items produced by the response. Required.""" + usage: Required[Optional["RealtimeResponseUsage"]] + """Token usage for the response. Required.""" + estimated_cost: "VoiceAgentEstimatedCost" + """The best-effort response cost estimate. Returned only when cost output is enabled.""" + conversation_id: Optional[str] + """The conversation identifier, or null for an out-of-band response.""" + modalities: Optional[list[Union[str, "VoiceOutputModality"]]] + """The modalities used by the response.""" + voice: Optional["_unions.VoiceAgentVoice"] + """The voice used by the response. Is one of the following types: OpenAIVoice, AzureVoice, + AzureRealtimeNativeVoice""" + output_audio_format: Optional[Union[str, "VoiceAgentResponseAudioFormat"]] + """The output-audio format used by the response. Known values are: \"pcm16\", \"pcm16_8000hz\", + \"pcm16_16000hz\", \"pcm16_22050hz\", \"pcm16_24000hz\", \"pcm16_44100hz\", \"pcm16_48000hz\", + \"g711_ulaw\", \"g711_alaw\", \"mp3\", \"mp3_24khz_48kbps\", \"mp3_24khz_96kbps\", and + \"mp3_24khz_160kbps\".""" + temperature: Optional[float] + """The sampling temperature used by the response.""" + max_output_tokens: Optional["_unions.VoiceAgentMaxOutputTokens"] + """The maximum output-token count used by the response. Is either a int type or a Literal[\"inf\"] + type.""" + metadata: Optional[dict[str, str]] + """String key-value metadata attached to the response.""" + + +class VoiceAgentResponseCreateAudio(TypedDict, total=False): + """Output-audio settings applied to one ``response.create`` request. + + :ivar output: The response-specific output-audio settings. + :vartype output: "VoiceAgentSessionUpdateAudioOutput" + """ + + output: Optional["VoiceAgentSessionUpdateAudioOutput"] + """The response-specific output-audio settings.""" + + +class VoiceAgentResponseCreateParams(TypedDict, total=False): + """Parameters accepted by a voice-agent ``response.create`` event. + + :ivar instructions: The default system instructions (i.e. system message) prepended to model + calls. This field allows the client to guide the model on desired responses. The model can be + instructed on response content and format, (e.g. "be extremely succinct", "act friendly", "here + are examples of good responses") and on audio behavior (e.g. "talk quickly", "inject emotion + into your voice", "laugh frequently"). The instructions are not guaranteed to be followed by + the model, but they provide guidance to the model on the desired behavior. Note that the server + sets default instructions which will be used if this field is not set and are visible in the + ``session.created`` event at the start of the session. + :vartype instructions: str + :ivar tools: Tools available to the model. + :vartype tools: list[Union["RealtimeFunctionTool", "MCPTool"]] + :ivar tool_choice: How the model chooses tools. Provide one of the string modes or force a + specific function/MCP tool. Is one of the following types: Union[str, + "_models.ToolChoiceOptions"], ToolChoiceFunction, ToolChoiceMCP + :vartype tool_choice: Union[str, "ToolChoiceOptions", "ToolChoiceFunction", "ToolChoiceMCP"] + :ivar parallel_tool_calls: Whether the model may call multiple tools in parallel. Only + supported by reasoning Realtime models such as ``gpt-realtime-2``. + :vartype parallel_tool_calls: bool + :ivar reasoning: + :vartype reasoning: "RealtimeReasoning" + :ivar max_output_tokens: Maximum number of output tokens for a single assistant response, + inclusive of tool calls. Provide an integer between 1 and 4096 to limit output tokens, or + ``inf`` for the maximum available tokens for a given model. Defaults to ``inf``. Is either a + int type or a Literal["inf"] type. + :vartype max_output_tokens: Union[int, Literal["inf"]] + :ivar conversation: Controls which conversation the response is added to. Currently supports + ``auto`` and ``none``, with ``auto`` as the default value. The ``auto`` value means that the + contents of the response will be added to the default conversation. Set this to ``none`` to + create an out-of-band response which will not add items to default conversation. Is one of the + following types: Literal["auto"], Literal["none"], str + :vartype conversation: Union[Literal["auto"], Literal["none"], str] + :ivar metadata: + :vartype metadata: "Metadata" + :ivar input: Input items to include in the prompt for the model. Using this field creates a new + context for this Response instead of using the default conversation. An empty array ``[]`` will + clear the context for this Response. Note that this can include references to items that + previously appeared in the session using their id. + :vartype input: list["RealtimeConversationItem"] + :ivar output_modalities: Modalities that the response may return. + :vartype output_modalities: list[Union[str, "VoiceOutputModality"]] + :ivar audio: Response-specific audio settings. + :vartype audio: "VoiceAgentResponseCreateAudio" + :ivar pre_generated_assistant_message: A pre-generated assistant message used to begin the + response. + :vartype pre_generated_assistant_message: "RealtimeConversationItemMessageAssistant" + :ivar interim_response: Interim-response settings for this response. Is either a + VoiceAgentStaticInterimResponseConfig type or a VoiceAgentLlmInterimResponseConfig type. + :vartype interim_response: "_unions.VoiceAgentInterimResponse" + """ + + instructions: str + """The default system instructions (i.e. system message) prepended to model calls. This field + allows the client to guide the model on desired responses. The model can be instructed on + response content and format, (e.g. \"be extremely succinct\", \"act friendly\", \"here are + examples of good responses\") and on audio behavior (e.g. \"talk quickly\", \"inject emotion + into your voice\", \"laugh frequently\"). The instructions are not guaranteed to be followed by + the model, but they provide guidance to the model on the desired behavior. Note that the server + sets default instructions which will be used if this field is not set and are visible in the + ``session.created`` event at the start of the session.""" + tools: list[Union["RealtimeFunctionTool", "MCPTool"]] + """Tools available to the model.""" + tool_choice: Union[str, "ToolChoiceOptions", "ToolChoiceFunction", "ToolChoiceMCP"] + """How the model chooses tools. Provide one of the string modes or force a specific function/MCP + tool. Is one of the following types: Union[str, \"_models.ToolChoiceOptions\"], + ToolChoiceFunction, ToolChoiceMCP""" + parallel_tool_calls: bool + """Whether the model may call multiple tools in parallel. Only supported by reasoning Realtime + models such as ``gpt-realtime-2``.""" + reasoning: "RealtimeReasoning" + max_output_tokens: Union[int, Literal["inf"]] + """Maximum number of output tokens for a single assistant response, inclusive of tool calls. + Provide an integer between 1 and 4096 to limit output tokens, or ``inf`` for the maximum + available tokens for a given model. Defaults to ``inf``. Is either a int type or a + Literal[\"inf\"] type.""" + conversation: Union[Literal["auto"], Literal["none"], str] + """Controls which conversation the response is added to. Currently supports ``auto`` and ``none``, + with ``auto`` as the default value. The ``auto`` value means that the contents of the response + will be added to the default conversation. Set this to ``none`` to create an out-of-band + response which will not add items to default conversation. Is one of the following types: + Literal[\"auto\"], Literal[\"none\"], str""" + metadata: Optional["Metadata"] + input: list["RealtimeConversationItem"] + """Input items to include in the prompt for the model. Using this field creates a new context for + this Response instead of using the default conversation. An empty array ``[]`` will clear the + context for this Response. Note that this can include references to items that previously + appeared in the session using their id.""" + output_modalities: list[Union[str, "VoiceOutputModality"]] + """Modalities that the response may return.""" + audio: "VoiceAgentResponseCreateAudio" + """Response-specific audio settings.""" + pre_generated_assistant_message: Optional["RealtimeConversationItemMessageAssistant"] + """A pre-generated assistant message used to begin the response.""" + interim_response: Optional["_unions.VoiceAgentInterimResponse"] + """Interim-response settings for this response. Is either a VoiceAgentStaticInterimResponseConfig + type or a VoiceAgentLlmInterimResponseConfig type.""" + + +class VoiceAgentResponseEventAudioContentPart(TypedDict, total=False): + """An audio part in a ``response.content_part.*`` server event. + + :ivar type: Required. Default value is "audio". + :vartype type: Literal["audio"] + :ivar transcript: Required. + :vartype transcript: str + :ivar annotations: + :vartype annotations: Any + :ivar audio: + :vartype audio: str + :ivar format: + :vartype format: "VoiceAudioFormat" + """ + + type: Required[Literal["audio"]] + """Required. Default value is \"audio\".""" + transcript: Required[Optional[str]] + """Required.""" + annotations: Any + audio: str + format: "VoiceAudioFormat" + + +class VoiceAgentResponseEventTextContentPart(TypedDict, total=False): + """A text part in a ``response.content_part.*`` server event. + + :ivar type: Required. Default value is "text". + :vartype type: Literal["text"] + :ivar text: Required. + :vartype text: str + """ + + type: Required[Literal["text"]] + """Required. Default value is \"text\".""" + text: Required[str] + """Required.""" + + +class VoiceAgentSemanticVadTurnDetection(TypedDict, total=False): + """OpenAI semantic VAD turn-detection settings. + + :ivar eagerness: Is one of the following types: Literal["low"], Literal["medium"], + Literal["high"], Literal["auto"] + :vartype eagerness: Literal["low", "medium", "high", "auto"] + :ivar create_response: + :vartype create_response: bool + :ivar interrupt_response: + :vartype interrupt_response: bool + :ivar type: Required. Semantic voice activity detection. + :vartype type: Literal[VoiceTurnDetectionType.SEMANTIC_VAD] + :ivar auto_truncate: + :vartype auto_truncate: bool + """ + + eagerness: Literal["low", "medium", "high", "auto"] + """Is one of the following types: Literal[\"low\"], Literal[\"medium\"], Literal[\"high\"], + Literal[\"auto\"]""" + create_response: bool + interrupt_response: bool + type: Required[Literal[VoiceTurnDetectionType.SEMANTIC_VAD]] + """Required. Semantic voice activity detection.""" + auto_truncate: bool + + +class VoiceAgentServerEventConversationCreated(TypedDict, total=False): + """The ``conversation.created`` server event emitted when a voice-agent connection starts. + + :ivar type: Required. Default value is "conversation.created". + :vartype type: Literal["conversation.created"] + :ivar conversation_id: The identifier of the created conversation. Required. + :vartype conversation_id: str + """ + + type: Required[Literal["conversation.created"]] + """Required. Default value is \"conversation.created\".""" + conversation_id: Required[str] + """The identifier of the created conversation. Required.""" + + +class VoiceAgentServerEventConversationItemAdded(TypedDict, total=False): # pylint: disable=name-too-long + """The ``conversation.item.added`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``conversation.item.added``. Required. + CONVERSATION_ITEM_ADDED. + :vartype type: Literal[RealtimeServerEventType.CONVERSATION_ITEM_ADDED] + :ivar previous_item_id: + :vartype previous_item_id: str + :ivar item: The item added to the conversation. Required. Is one of the following types: + "_unions.VoiceAgentResponseMessageItem", VoiceFunctionCallItem, VoiceFunctionCallOutputItem, + VoiceMcpListToolsItem, VoiceMcpCallItem, VoiceMcpApprovalRequestItem, + VoiceMcpApprovalResponseItem, VoiceAgentWorkflowActionItem, VoiceAgentWebSearchCallItem, + VoiceAgentFileSearchCallItem + :vartype item: "_unions.VoiceAgentResponseItem" + """ + + event_id: Required[str] + """The unique ID of the server event. Required.""" + type: Required[Literal[RealtimeServerEventType.CONVERSATION_ITEM_ADDED]] + """The event type, must be ``conversation.item.added``. Required. CONVERSATION_ITEM_ADDED.""" + previous_item_id: Optional[str] + item: Required["_unions.VoiceAgentResponseItem"] + """The item added to the conversation. Required. Is one of the following types: + \"_unions.VoiceAgentResponseMessageItem\", VoiceFunctionCallItem, VoiceFunctionCallOutputItem, + VoiceMcpListToolsItem, VoiceMcpCallItem, VoiceMcpApprovalRequestItem, + VoiceMcpApprovalResponseItem, VoiceAgentWorkflowActionItem, VoiceAgentWebSearchCallItem, + VoiceAgentFileSearchCallItem""" + + +class VoiceAgentServerEventConversationItemCreated(TypedDict, total=False): # pylint: disable=name-too-long + """The ``conversation.item.created`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``conversation.item.created``. Required. + CONVERSATION_ITEM_CREATED. + :vartype type: Literal[RealtimeServerEventType.CONVERSATION_ITEM_CREATED] + :ivar previous_item_id: + :vartype previous_item_id: str + :ivar item: The created conversation item. Required. Is one of the following types: + "_unions.VoiceAgentResponseMessageItem", VoiceFunctionCallItem, VoiceFunctionCallOutputItem, + VoiceMcpListToolsItem, VoiceMcpCallItem, VoiceMcpApprovalRequestItem, + VoiceMcpApprovalResponseItem, VoiceAgentWorkflowActionItem, VoiceAgentWebSearchCallItem, + VoiceAgentFileSearchCallItem + :vartype item: "_unions.VoiceAgentResponseItem" + """ + + event_id: Required[str] + """The unique ID of the server event. Required.""" + type: Required[Literal[RealtimeServerEventType.CONVERSATION_ITEM_CREATED]] + """The event type, must be ``conversation.item.created``. Required. CONVERSATION_ITEM_CREATED.""" + previous_item_id: Optional[str] + item: Required["_unions.VoiceAgentResponseItem"] + """The created conversation item. Required. Is one of the following types: + \"_unions.VoiceAgentResponseMessageItem\", VoiceFunctionCallItem, VoiceFunctionCallOutputItem, + VoiceMcpListToolsItem, VoiceMcpCallItem, VoiceMcpApprovalRequestItem, + VoiceMcpApprovalResponseItem, VoiceAgentWorkflowActionItem, VoiceAgentWebSearchCallItem, + VoiceAgentFileSearchCallItem""" + + +class VoiceAgentServerEventConversationItemDeleted(TypedDict, total=False): # pylint: disable=name-too-long + """The ``conversation.item.deleted`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``conversation.item.deleted``. Required. + CONVERSATION_ITEM_DELETED. + :vartype type: Literal[RealtimeServerEventType.CONVERSATION_ITEM_DELETED] + :ivar item_id: The ID of the item that was deleted. Required. + :vartype item_id: str + """ + + event_id: Required[str] + """The unique ID of the server event. Required.""" + type: Required[Literal[RealtimeServerEventType.CONVERSATION_ITEM_DELETED]] + """The event type, must be ``conversation.item.deleted``. Required. CONVERSATION_ITEM_DELETED.""" + item_id: Required[str] + """The ID of the item that was deleted. Required.""" + + +class VoiceAgentServerEventConversationItemDone(TypedDict, total=False): # pylint: disable=name-too-long + """The ``conversation.item.done`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``conversation.item.done``. Required. + CONVERSATION_ITEM_DONE. + :vartype type: Literal[RealtimeServerEventType.CONVERSATION_ITEM_DONE] + :ivar previous_item_id: + :vartype previous_item_id: str + :ivar item: The completed conversation item. Required. Is one of the following types: + "_unions.VoiceAgentResponseMessageItem", VoiceFunctionCallItem, VoiceFunctionCallOutputItem, + VoiceMcpListToolsItem, VoiceMcpCallItem, VoiceMcpApprovalRequestItem, + VoiceMcpApprovalResponseItem, VoiceAgentWorkflowActionItem, VoiceAgentWebSearchCallItem, + VoiceAgentFileSearchCallItem + :vartype item: "_unions.VoiceAgentResponseItem" + """ + + event_id: Required[str] + """The unique ID of the server event. Required.""" + type: Required[Literal[RealtimeServerEventType.CONVERSATION_ITEM_DONE]] + """The event type, must be ``conversation.item.done``. Required. CONVERSATION_ITEM_DONE.""" + previous_item_id: Optional[str] + item: Required["_unions.VoiceAgentResponseItem"] + """The completed conversation item. Required. Is one of the following types: + \"_unions.VoiceAgentResponseMessageItem\", VoiceFunctionCallItem, VoiceFunctionCallOutputItem, + VoiceMcpListToolsItem, VoiceMcpCallItem, VoiceMcpApprovalRequestItem, + VoiceMcpApprovalResponseItem, VoiceAgentWorkflowActionItem, VoiceAgentWebSearchCallItem, + VoiceAgentFileSearchCallItem""" + + +class VoiceAgentServerEventConversationItemInputAudioTranscriptionCompleted( + TypedDict, total=False +): # pylint: disable=name-too-long + """The ``conversation.item.input_audio_transcription.completed`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``conversation.item.input_audio_transcription.completed``. + Required. CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_COMPLETED. + :vartype type: + Literal[RealtimeServerEventType.CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_COMPLETED] + :ivar item_id: The ID of the item containing the audio that is being transcribed. Required. + :vartype item_id: str + :ivar content_index: The index of the content part containing the audio. Required. + :vartype content_index: int + :ivar transcript: The transcribed text. Required. + :vartype transcript: str + :ivar logprobs: + :vartype logprobs: list["LogProbProperties"] + :ivar usage: Usage statistics for the transcription, this is billed according to the ASR + model's pricing rather than the realtime model's pricing. Required. Is either a + TranscriptTextUsageTokens type or a TranscriptTextUsageDuration type. + :vartype usage: Union["TranscriptTextUsageTokens", "TranscriptTextUsageDuration"] + :ivar phrases: Phrase-level transcription timing and confidence details. + :vartype phrases: list["VoiceAgentTranscriptionPhrase"] + """ + + event_id: Required[str] + """The unique ID of the server event. Required.""" + type: Required[Literal[RealtimeServerEventType.CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_COMPLETED]] + """The event type, must be ``conversation.item.input_audio_transcription.completed``. Required. + CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_COMPLETED.""" + item_id: Required[str] + """The ID of the item containing the audio that is being transcribed. Required.""" + content_index: Required[int] + """The index of the content part containing the audio. Required.""" + transcript: Required[str] + """The transcribed text. Required.""" + logprobs: Optional[list["LogProbProperties"]] + usage: Required[Union["TranscriptTextUsageTokens", "TranscriptTextUsageDuration"]] + """Usage statistics for the transcription, this is billed according to the ASR model's pricing + rather than the realtime model's pricing. Required. Is either a TranscriptTextUsageTokens type + or a TranscriptTextUsageDuration type.""" + phrases: Optional[list["VoiceAgentTranscriptionPhrase"]] + """Phrase-level transcription timing and confidence details.""" + + +class VoiceAgentServerEventConversationItemInputAudioTranscriptionDelta( + TypedDict, total=False +): # pylint: disable=name-too-long + """The ``conversation.item.input_audio_transcription.delta`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``conversation.item.input_audio_transcription.delta``. + Required. CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_DELTA. + :vartype type: + Literal[RealtimeServerEventType.CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_DELTA] + :ivar item_id: The ID of the item containing the audio that is being transcribed. Required. + :vartype item_id: str + :ivar content_index: The index of the content part in the item's content array. + :vartype content_index: int + :ivar delta: The text delta. + :vartype delta: str + :ivar logprobs: + :vartype logprobs: list["LogProbProperties"] + """ + + event_id: Required[str] + """The unique ID of the server event. Required.""" + type: Required[Literal[RealtimeServerEventType.CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_DELTA]] + """The event type, must be ``conversation.item.input_audio_transcription.delta``. Required. + CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_DELTA.""" + item_id: Required[str] + """The ID of the item containing the audio that is being transcribed. Required.""" + content_index: int + """The index of the content part in the item's content array.""" + delta: str + """The text delta.""" + logprobs: Optional[list["LogProbProperties"]] + + +class VoiceAgentServerEventConversationItemInputAudioTranscriptionFailed( + TypedDict, total=False +): # pylint: disable=name-too-long + """The ``conversation.item.input_audio_transcription.failed`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``conversation.item.input_audio_transcription.failed``. + Required. CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_FAILED. + :vartype type: + Literal[RealtimeServerEventType.CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_FAILED] + :ivar item_id: The ID of the user message item. Required. + :vartype item_id: str + :ivar content_index: The index of the content part containing the audio. Required. + :vartype content_index: int + :ivar error: Details of the transcription error. Required. + :vartype error: "RealtimeServerEventConversationItemInputAudioTranscriptionFailedError" + """ + + event_id: Required[str] + """The unique ID of the server event. Required.""" + type: Required[Literal[RealtimeServerEventType.CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_FAILED]] + """The event type, must be ``conversation.item.input_audio_transcription.failed``. Required. + CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_FAILED.""" + item_id: Required[str] + """The ID of the user message item. Required.""" + content_index: Required[int] + """The index of the content part containing the audio. Required.""" + error: Required["RealtimeServerEventConversationItemInputAudioTranscriptionFailedError"] + """Details of the transcription error. Required.""" + + +class VoiceAgentServerEventConversationItemInputAudioTranscriptionSegment( + TypedDict, total=False +): # pylint: disable=name-too-long + """The ``conversation.item.input_audio_transcription.segment`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``conversation.item.input_audio_transcription.segment``. + Required. CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_SEGMENT. + :vartype type: + Literal[RealtimeServerEventType.CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_SEGMENT] + :ivar item_id: The ID of the item containing the input audio content. Required. + :vartype item_id: str + :ivar content_index: The index of the input audio content part within the item. Required. + :vartype content_index: int + :ivar text: The text for this segment. Required. + :vartype text: str + :ivar id: The segment identifier. Required. + :vartype id: str + :ivar speaker: The detected speaker label for this segment. Required. + :vartype speaker: str + :ivar start: Start time of the segment in seconds. Required. + :vartype start: float + :ivar end: End time of the segment in seconds. Required. + :vartype end: float + """ + + event_id: Required[str] + """The unique ID of the server event. Required.""" + type: Required[Literal[RealtimeServerEventType.CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_SEGMENT]] + """The event type, must be ``conversation.item.input_audio_transcription.segment``. Required. + CONVERSATION_ITEM_INPUT_AUDIO_TRANSCRIPTION_SEGMENT.""" + item_id: Required[str] + """The ID of the item containing the input audio content. Required.""" + content_index: Required[int] + """The index of the input audio content part within the item. Required.""" + text: Required[str] + """The text for this segment. Required.""" + id: Required[str] + """The segment identifier. Required.""" + speaker: Required[str] + """The detected speaker label for this segment. Required.""" + start: Required[float] + """Start time of the segment in seconds. Required.""" + end: Required[float] + """End time of the segment in seconds. Required.""" + + +class VoiceAgentServerEventConversationItemRetrieved(TypedDict, total=False): # pylint: disable=name-too-long + """The ``conversation.item.retrieved`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``conversation.item.retrieved``. Required. + CONVERSATION_ITEM_RETRIEVED. + :vartype type: Literal[RealtimeServerEventType.CONVERSATION_ITEM_RETRIEVED] + :ivar item: The retrieved conversation item. Required. Is one of the following types: + "_unions.VoiceAgentResponseMessageItem", VoiceFunctionCallItem, VoiceFunctionCallOutputItem, + VoiceMcpListToolsItem, VoiceMcpCallItem, VoiceMcpApprovalRequestItem, + VoiceMcpApprovalResponseItem, VoiceAgentWorkflowActionItem, VoiceAgentWebSearchCallItem, + VoiceAgentFileSearchCallItem + :vartype item: "_unions.VoiceAgentResponseItem" + """ + + event_id: Required[str] + """The unique ID of the server event. Required.""" + type: Required[Literal[RealtimeServerEventType.CONVERSATION_ITEM_RETRIEVED]] + """The event type, must be ``conversation.item.retrieved``. Required. CONVERSATION_ITEM_RETRIEVED.""" + item: Required["_unions.VoiceAgentResponseItem"] + """The retrieved conversation item. Required. Is one of the following types: + \"_unions.VoiceAgentResponseMessageItem\", VoiceFunctionCallItem, VoiceFunctionCallOutputItem, + VoiceMcpListToolsItem, VoiceMcpCallItem, VoiceMcpApprovalRequestItem, + VoiceMcpApprovalResponseItem, VoiceAgentWorkflowActionItem, VoiceAgentWebSearchCallItem, + VoiceAgentFileSearchCallItem""" + + +class VoiceAgentServerEventConversationItemTruncated(TypedDict, total=False): # pylint: disable=name-too-long + """The ``conversation.item.truncated`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``conversation.item.truncated``. Required. + CONVERSATION_ITEM_TRUNCATED. + :vartype type: Literal[RealtimeServerEventType.CONVERSATION_ITEM_TRUNCATED] + :ivar item_id: The ID of the assistant message item that was truncated. Required. + :vartype item_id: str + :ivar content_index: The index of the content part that was truncated. Required. + :vartype content_index: int + :ivar audio_end_ms: The duration up to which the audio was truncated, in milliseconds. + Required. + :vartype audio_end_ms: int + :ivar item: The assistant message after truncation, when the service returns the updated item. + :vartype item: "RealtimeConversationItemMessageAssistant" + """ + + event_id: Required[str] + """The unique ID of the server event. Required.""" + type: Required[Literal[RealtimeServerEventType.CONVERSATION_ITEM_TRUNCATED]] + """The event type, must be ``conversation.item.truncated``. Required. CONVERSATION_ITEM_TRUNCATED.""" + item_id: Required[str] + """The ID of the assistant message item that was truncated. Required.""" + content_index: Required[int] + """The index of the content part that was truncated. Required.""" + audio_end_ms: Required[int] + """The duration up to which the audio was truncated, in milliseconds. Required.""" + item: "RealtimeConversationItemMessageAssistant" + """The assistant message after truncation, when the service returns the updated item.""" + + +class VoiceAgentServerEventError(TypedDict, total=False): + """The ``error`` server event. + + :ivar event_id: The unique identifier of the event. Required. + :vartype event_id: str + :ivar type: Required. Default value is "error". + :vartype type: Literal["error"] + :ivar error: Details of the error. Required. + :vartype error: "VoiceAgentServerEventErrorDetails" + """ + + event_id: Required[str] + """The unique identifier of the event. Required.""" + type: Required[Literal["error"]] + """Required. Default value is \"error\".""" + error: Required["VoiceAgentServerEventErrorDetails"] + """Details of the error. Required.""" + + +class VoiceAgentServerEventErrorDetails(TypedDict, total=False): + """Details of a voice-agent WebSocket error. + + :ivar type: Required. + :vartype type: str + :ivar code: + :vartype code: str + :ivar message: Required. + :vartype message: str + :ivar param: + :vartype param: str + :ivar event_id: + :vartype event_id: str + :ivar tool_label: The configured label of a tool that could not be resolved. + :vartype tool_label: str + :ivar tool_type: The configured type of a tool that could not be resolved. + :vartype tool_type: str + """ + + type: Required[str] + """Required.""" + code: Optional[str] + message: Required[str] + """Required.""" + param: Optional[str] + event_id: Optional[str] + tool_label: str + """The configured label of a tool that could not be resolved.""" + tool_type: str + """The configured type of a tool that could not be resolved.""" + + +class VoiceAgentServerEventFileSearchCallCompleted(TypedDict, total=False): # pylint: disable=name-too-long + """The ``response.file_search_call.completed`` server event. + + :ivar type: Required. Default value is "response.file_search_call.completed". + :vartype type: Literal["response.file_search_call.completed"] + :ivar event_id: + :vartype event_id: str + :ivar response_id: + :vartype response_id: str + :ivar item_id: Required. + :vartype item_id: str + :ivar output_index: Required. + :vartype output_index: int + :ivar sequence_number: Required. + :vartype sequence_number: int + """ + + type: Required[Literal["response.file_search_call.completed"]] + """Required. Default value is \"response.file_search_call.completed\".""" + event_id: str + response_id: str + item_id: Required[str] + """Required.""" + output_index: Required[int] + """Required.""" + sequence_number: Required[int] + """Required.""" + + +class VoiceAgentServerEventFileSearchCallInProgress(TypedDict, total=False): # pylint: disable=name-too-long + """The ``response.file_search_call.in_progress`` server event. + + :ivar type: Required. Default value is "response.file_search_call.in_progress". + :vartype type: Literal["response.file_search_call.in_progress"] + :ivar event_id: + :vartype event_id: str + :ivar response_id: + :vartype response_id: str + :ivar item_id: Required. + :vartype item_id: str + :ivar output_index: Required. + :vartype output_index: int + :ivar sequence_number: Required. + :vartype sequence_number: int + """ + + type: Required[Literal["response.file_search_call.in_progress"]] + """Required. Default value is \"response.file_search_call.in_progress\".""" + event_id: str + response_id: str + item_id: Required[str] + """Required.""" + output_index: Required[int] + """Required.""" + sequence_number: Required[int] + """Required.""" + + +class VoiceAgentServerEventFileSearchCallSearching(TypedDict, total=False): # pylint: disable=name-too-long + """The ``response.file_search_call.searching`` server event. + + :ivar type: Required. Default value is "response.file_search_call.searching". + :vartype type: Literal["response.file_search_call.searching"] + :ivar event_id: + :vartype event_id: str + :ivar response_id: + :vartype response_id: str + :ivar item_id: Required. + :vartype item_id: str + :ivar output_index: Required. + :vartype output_index: int + :ivar sequence_number: Required. + :vartype sequence_number: int + """ + + type: Required[Literal["response.file_search_call.searching"]] + """Required. Default value is \"response.file_search_call.searching\".""" + event_id: str + response_id: str + item_id: Required[str] + """Required.""" + output_index: Required[int] + """Required.""" + sequence_number: Required[int] + """Required.""" + + +class VoiceAgentServerEventInputAudioBufferCleared(TypedDict, total=False): # pylint: disable=name-too-long + """The ``input_audio_buffer.cleared`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``input_audio_buffer.cleared``. Required. + INPUT_AUDIO_BUFFER_CLEARED. + :vartype type: Literal[RealtimeServerEventType.INPUT_AUDIO_BUFFER_CLEARED] + """ + + event_id: Required[str] + """The unique ID of the server event. Required.""" + type: Required[Literal[RealtimeServerEventType.INPUT_AUDIO_BUFFER_CLEARED]] + """The event type, must be ``input_audio_buffer.cleared``. Required. INPUT_AUDIO_BUFFER_CLEARED.""" + + +class VoiceAgentServerEventInputAudioBufferCommitted(TypedDict, total=False): # pylint: disable=name-too-long + """The ``input_audio_buffer.committed`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``input_audio_buffer.committed``. Required. + INPUT_AUDIO_BUFFER_COMMITTED. + :vartype type: Literal[RealtimeServerEventType.INPUT_AUDIO_BUFFER_COMMITTED] + :ivar previous_item_id: + :vartype previous_item_id: str + :ivar item_id: The ID of the user message item that will be created. Required. + :vartype item_id: str + """ + + event_id: Required[str] + """The unique ID of the server event. Required.""" + type: Required[Literal[RealtimeServerEventType.INPUT_AUDIO_BUFFER_COMMITTED]] + """The event type, must be ``input_audio_buffer.committed``. Required. + INPUT_AUDIO_BUFFER_COMMITTED.""" + previous_item_id: Optional[str] + item_id: Required[str] + """The ID of the user message item that will be created. Required.""" + + +class VoiceAgentServerEventInputAudioBufferSpeechStarted(TypedDict, total=False): # pylint: disable=name-too-long + """The ``input_audio_buffer.speech_started`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``input_audio_buffer.speech_started``. Required. + INPUT_AUDIO_BUFFER_SPEECH_STARTED. + :vartype type: Literal[RealtimeServerEventType.INPUT_AUDIO_BUFFER_SPEECH_STARTED] + :ivar audio_start_ms: Milliseconds from the start of all audio written to the buffer during the + session when speech was first detected. This will correspond to the beginning of audio sent to + the model, and thus includes the ``prefix_padding_ms`` configured in the Session. Required. + :vartype audio_start_ms: int + :ivar item_id: The ID of the user message item that will be created when speech stops. + Required. + :vartype item_id: str + """ + + event_id: Required[str] + """The unique ID of the server event. Required.""" + type: Required[Literal[RealtimeServerEventType.INPUT_AUDIO_BUFFER_SPEECH_STARTED]] + """The event type, must be ``input_audio_buffer.speech_started``. Required. + INPUT_AUDIO_BUFFER_SPEECH_STARTED.""" + audio_start_ms: Required[int] + """Milliseconds from the start of all audio written to the buffer during the session when speech + was first detected. This will correspond to the beginning of audio sent to the model, and thus + includes the ``prefix_padding_ms`` configured in the Session. Required.""" + item_id: Required[str] + """The ID of the user message item that will be created when speech stops. Required.""" + + +class VoiceAgentServerEventInputAudioBufferSpeechStopped(TypedDict, total=False): # pylint: disable=name-too-long + """The ``input_audio_buffer.speech_stopped`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``input_audio_buffer.speech_stopped``. Required. + INPUT_AUDIO_BUFFER_SPEECH_STOPPED. + :vartype type: Literal[RealtimeServerEventType.INPUT_AUDIO_BUFFER_SPEECH_STOPPED] + :ivar audio_end_ms: Milliseconds since the session started when speech stopped. This will + correspond to the end of audio sent to the model, and thus includes the + ``min_silence_duration_ms`` configured in the Session. Required. + :vartype audio_end_ms: int + :ivar item_id: The ID of the user message item that will be created. Required. + :vartype item_id: str + """ + + event_id: Required[str] + """The unique ID of the server event. Required.""" + type: Required[Literal[RealtimeServerEventType.INPUT_AUDIO_BUFFER_SPEECH_STOPPED]] + """The event type, must be ``input_audio_buffer.speech_stopped``. Required. + INPUT_AUDIO_BUFFER_SPEECH_STOPPED.""" + audio_end_ms: Required[int] + """Milliseconds since the session started when speech stopped. This will correspond to the end of + audio sent to the model, and thus includes the ``min_silence_duration_ms`` configured in the + Session. Required.""" + item_id: Required[str] + """The ID of the user message item that will be created. Required.""" + + +class VoiceAgentServerEventInputAudioBufferTimeoutTriggered(TypedDict, total=False): # pylint: disable=name-too-long + """The ``input_audio_buffer.timeout_triggered`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``input_audio_buffer.timeout_triggered``. Required. + INPUT_AUDIO_BUFFER_TIMEOUT_TRIGGERED. + :vartype type: Literal[RealtimeServerEventType.INPUT_AUDIO_BUFFER_TIMEOUT_TRIGGERED] + :ivar audio_start_ms: Millisecond offset of audio written to the input audio buffer that was + after the playback time of the last model response. Required. + :vartype audio_start_ms: int + :ivar audio_end_ms: Millisecond offset of audio written to the input audio buffer at the time + the timeout was triggered. Required. + :vartype audio_end_ms: int + :ivar item_id: The ID of the item associated with this segment. Required. + :vartype item_id: str + """ + + event_id: Required[str] + """The unique ID of the server event. Required.""" + type: Required[Literal[RealtimeServerEventType.INPUT_AUDIO_BUFFER_TIMEOUT_TRIGGERED]] + """The event type, must be ``input_audio_buffer.timeout_triggered``. Required. + INPUT_AUDIO_BUFFER_TIMEOUT_TRIGGERED.""" + audio_start_ms: Required[int] + """Millisecond offset of audio written to the input audio buffer that was after the playback time + of the last model response. Required.""" + audio_end_ms: Required[int] + """Millisecond offset of audio written to the input audio buffer at the time the timeout was + triggered. Required.""" + item_id: Required[str] + """The ID of the item associated with this segment. Required.""" + + +class VoiceAgentServerEventMcpListToolsCompleted(TypedDict, total=False): # pylint: disable=name-too-long + """The ``mcp_list_tools.completed`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``mcp_list_tools.completed``. Required. + MCP_LIST_TOOLS_COMPLETED. + :vartype type: Literal[RealtimeServerEventType.MCP_LIST_TOOLS_COMPLETED] + :ivar item_id: The ID of the MCP list tools item. Required. + :vartype item_id: str + """ + + event_id: Required[str] + """The unique ID of the server event. Required.""" + type: Required[Literal[RealtimeServerEventType.MCP_LIST_TOOLS_COMPLETED]] + """The event type, must be ``mcp_list_tools.completed``. Required. MCP_LIST_TOOLS_COMPLETED.""" + item_id: Required[str] + """The ID of the MCP list tools item. Required.""" + + +class VoiceAgentServerEventMcpListToolsFailed(TypedDict, total=False): + """The ``mcp_list_tools.failed`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``mcp_list_tools.failed``. Required. MCP_LIST_TOOLS_FAILED. + :vartype type: Literal[RealtimeServerEventType.MCP_LIST_TOOLS_FAILED] + :ivar item_id: The ID of the MCP list tools item. Required. + :vartype item_id: str + """ + + event_id: Required[str] + """The unique ID of the server event. Required.""" + type: Required[Literal[RealtimeServerEventType.MCP_LIST_TOOLS_FAILED]] + """The event type, must be ``mcp_list_tools.failed``. Required. MCP_LIST_TOOLS_FAILED.""" + item_id: Required[str] + """The ID of the MCP list tools item. Required.""" + + +class VoiceAgentServerEventMcpListToolsInProgress(TypedDict, total=False): # pylint: disable=name-too-long + """The ``mcp_list_tools.in_progress`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``mcp_list_tools.in_progress``. Required. + MCP_LIST_TOOLS_IN_PROGRESS. + :vartype type: Literal[RealtimeServerEventType.MCP_LIST_TOOLS_IN_PROGRESS] + :ivar item_id: The ID of the MCP list tools item. Required. + :vartype item_id: str + """ + + event_id: Required[str] + """The unique ID of the server event. Required.""" + type: Required[Literal[RealtimeServerEventType.MCP_LIST_TOOLS_IN_PROGRESS]] + """The event type, must be ``mcp_list_tools.in_progress``. Required. MCP_LIST_TOOLS_IN_PROGRESS.""" + item_id: Required[str] + """The ID of the MCP list tools item. Required.""" + + +class VoiceAgentServerEventOutputAudioBufferCleared(TypedDict, total=False): # pylint: disable=name-too-long + """The ``output_audio_buffer.cleared`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``output_audio_buffer.cleared``. Required. + OUTPUT_AUDIO_BUFFER_CLEARED. + :vartype type: Literal[RealtimeServerEventType.OUTPUT_AUDIO_BUFFER_CLEARED] + :ivar response_id: The unique ID of the response that produced the audio. Required. + :vartype response_id: str + """ + + event_id: Required[str] + """The unique ID of the server event. Required.""" + type: Required[Literal[RealtimeServerEventType.OUTPUT_AUDIO_BUFFER_CLEARED]] + """The event type, must be ``output_audio_buffer.cleared``. Required. OUTPUT_AUDIO_BUFFER_CLEARED.""" + response_id: Required[str] + """The unique ID of the response that produced the audio. Required.""" + + +class VoiceAgentServerEventRateLimitsUpdated(TypedDict, total=False): + """The ``rate_limits.updated`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``rate_limits.updated``. Required. RATE_LIMITS_UPDATED. + :vartype type: Literal[RealtimeServerEventType.RATE_LIMITS_UPDATED] + :ivar rate_limits: List of rate limit information. Required. + :vartype rate_limits: list["RealtimeServerEventRateLimitsUpdatedRateLimits"] + """ + + event_id: Required[str] + """The unique ID of the server event. Required.""" + type: Required[Literal[RealtimeServerEventType.RATE_LIMITS_UPDATED]] + """The event type, must be ``rate_limits.updated``. Required. RATE_LIMITS_UPDATED.""" + rate_limits: Required[list["RealtimeServerEventRateLimitsUpdatedRateLimits"]] + """List of rate limit information. Required.""" + + +class VoiceAgentServerEventResponseAnimationBlendshapesDelta(TypedDict, total=False): # pylint: disable=name-too-long + """The ``response.animation_blendshapes.delta`` server event. + + :ivar type: Required. Default value is "response.animation_blendshapes.delta". + :vartype type: Literal["response.animation_blendshapes.delta"] + :ivar event_id: Required. + :vartype event_id: str + :ivar response_id: Required. + :vartype response_id: str + :ivar item_id: Required. + :vartype item_id: str + :ivar output_index: Required. + :vartype output_index: int + :ivar content_index: Required. + :vartype content_index: int + :ivar frames: Animation frames as numeric blendshape weights or a compact encoded string. + Required. Is either a [[float]] type or a str type. + :vartype frames: Union[list[list[float]], str] + :ivar frame_index: The index of the first frame in this delta. Required. + :vartype frame_index: int + """ + + type: Required[Literal["response.animation_blendshapes.delta"]] + """Required. Default value is \"response.animation_blendshapes.delta\".""" + event_id: Required[str] + """Required.""" + response_id: Required[str] + """Required.""" + item_id: Required[str] + """Required.""" + output_index: Required[int] + """Required.""" + content_index: Required[int] + """Required.""" + frames: Required[Union[list[list[float]], str]] + """Animation frames as numeric blendshape weights or a compact encoded string. Required. Is either + a [[float]] type or a str type.""" + frame_index: Required[int] + """The index of the first frame in this delta. Required.""" + + +class VoiceAgentServerEventResponseAnimationBlendshapesDone(TypedDict, total=False): # pylint: disable=name-too-long + """The ``response.animation_blendshapes.done`` server event. + + :ivar type: Required. Default value is "response.animation_blendshapes.done". + :vartype type: Literal["response.animation_blendshapes.done"] + :ivar event_id: Required. + :vartype event_id: str + :ivar response_id: Required. + :vartype response_id: str + :ivar item_id: Required. + :vartype item_id: str + :ivar output_index: Required. + :vartype output_index: int + """ + + type: Required[Literal["response.animation_blendshapes.done"]] + """Required. Default value is \"response.animation_blendshapes.done\".""" + event_id: Required[str] + """Required.""" + response_id: Required[str] + """Required.""" + item_id: Required[str] + """Required.""" + output_index: Required[int] + """Required.""" + + +class VoiceAgentServerEventResponseAnimationVisemeDelta(TypedDict, total=False): # pylint: disable=name-too-long + """The ``response.animation_viseme.delta`` server event. + + :ivar type: Required. Default value is "response.animation_viseme.delta". + :vartype type: Literal["response.animation_viseme.delta"] + :ivar event_id: Required. + :vartype event_id: str + :ivar response_id: Required. + :vartype response_id: str + :ivar item_id: Required. + :vartype item_id: str + :ivar output_index: Required. + :vartype output_index: int + :ivar content_index: Required. + :vartype content_index: int + :ivar audio_offset_ms: Required. + :vartype audio_offset_ms: int + :ivar viseme_id: Required. + :vartype viseme_id: int + """ + + type: Required[Literal["response.animation_viseme.delta"]] + """Required. Default value is \"response.animation_viseme.delta\".""" + event_id: Required[str] + """Required.""" + response_id: Required[str] + """Required.""" + item_id: Required[str] + """Required.""" + output_index: Required[int] + """Required.""" + content_index: Required[int] + """Required.""" + audio_offset_ms: Required[int] + """Required.""" + viseme_id: Required[int] + """Required.""" + + +class VoiceAgentServerEventResponseAnimationVisemeDone(TypedDict, total=False): # pylint: disable=name-too-long + """The ``response.animation_viseme.done`` server event. + + :ivar type: Required. Default value is "response.animation_viseme.done". + :vartype type: Literal["response.animation_viseme.done"] + :ivar event_id: Required. + :vartype event_id: str + :ivar response_id: Required. + :vartype response_id: str + :ivar item_id: Required. + :vartype item_id: str + :ivar output_index: Required. + :vartype output_index: int + :ivar content_index: Required. + :vartype content_index: int + """ + + type: Required[Literal["response.animation_viseme.done"]] + """Required. Default value is \"response.animation_viseme.done\".""" + event_id: Required[str] + """Required.""" + response_id: Required[str] + """Required.""" + item_id: Required[str] + """Required.""" + output_index: Required[int] + """Required.""" + content_index: Required[int] + """Required.""" + + +class VoiceAgentServerEventResponseAudioDelta(TypedDict, total=False): + """The ``response.output_audio.delta`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``response.output_audio.delta``. Required. + RESPONSE_OUTPUT_AUDIO_DELTA. + :vartype type: Literal[RealtimeServerEventType.RESPONSE_OUTPUT_AUDIO_DELTA] + :ivar response_id: The ID of the response. Required. + :vartype response_id: str + :ivar item_id: The ID of the item. Required. + :vartype item_id: str + :ivar output_index: The index of the output item in the response. Required. + :vartype output_index: int + :ivar content_index: The index of the content part in the item's content array. Required. + :vartype content_index: int + :ivar delta: Base64-encoded audio data delta. Required. + :vartype delta: str + """ + + event_id: Required[str] + """The unique ID of the server event. Required.""" + type: Required[Literal[RealtimeServerEventType.RESPONSE_OUTPUT_AUDIO_DELTA]] + """The event type, must be ``response.output_audio.delta``. Required. RESPONSE_OUTPUT_AUDIO_DELTA.""" + response_id: Required[str] + """The ID of the response. Required.""" + item_id: Required[str] + """The ID of the item. Required.""" + output_index: Required[int] + """The index of the output item in the response. Required.""" + content_index: Required[int] + """The index of the content part in the item's content array. Required.""" + delta: Required[str] + """Base64-encoded audio data delta. Required.""" + + +class VoiceAgentServerEventResponseAudioDone(TypedDict, total=False): + """The ``response.output_audio.done`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``response.output_audio.done``. Required. + RESPONSE_OUTPUT_AUDIO_DONE. + :vartype type: Literal[RealtimeServerEventType.RESPONSE_OUTPUT_AUDIO_DONE] + :ivar response_id: The ID of the response. Required. + :vartype response_id: str + :ivar item_id: The ID of the item. Required. + :vartype item_id: str + :ivar output_index: The index of the output item in the response. Required. + :vartype output_index: int + :ivar content_index: The index of the content part in the item's content array. Required. + :vartype content_index: int + """ + + event_id: Required[str] + """The unique ID of the server event. Required.""" + type: Required[Literal[RealtimeServerEventType.RESPONSE_OUTPUT_AUDIO_DONE]] + """The event type, must be ``response.output_audio.done``. Required. RESPONSE_OUTPUT_AUDIO_DONE.""" + response_id: Required[str] + """The ID of the response. Required.""" + item_id: Required[str] + """The ID of the item. Required.""" + output_index: Required[int] + """The index of the output item in the response. Required.""" + content_index: Required[int] + """The index of the content part in the item's content array. Required.""" + + +class VoiceAgentServerEventResponseAudioTimestampDelta(TypedDict, total=False): # pylint: disable=name-too-long + """The ``response.audio_timestamp.delta`` server event. + + :ivar type: Required. Default value is "response.audio_timestamp.delta". + :vartype type: Literal["response.audio_timestamp.delta"] + :ivar event_id: Required. + :vartype event_id: str + :ivar response_id: Required. + :vartype response_id: str + :ivar item_id: Required. + :vartype item_id: str + :ivar output_index: Required. + :vartype output_index: int + :ivar content_index: Required. + :vartype content_index: int + :ivar audio_offset_ms: Required. + :vartype audio_offset_ms: int + :ivar audio_duration_ms: Required. + :vartype audio_duration_ms: int + :ivar text: Required. + :vartype text: str + :ivar timestamp_type: Required. Default value is "word". + :vartype timestamp_type: Literal["word"] + """ + + type: Required[Literal["response.audio_timestamp.delta"]] + """Required. Default value is \"response.audio_timestamp.delta\".""" + event_id: Required[str] + """Required.""" + response_id: Required[str] + """Required.""" + item_id: Required[str] + """Required.""" + output_index: Required[int] + """Required.""" + content_index: Required[int] + """Required.""" + audio_offset_ms: Required[int] + """Required.""" + audio_duration_ms: Required[int] + """Required.""" + text: Required[str] + """Required.""" + timestamp_type: Required[Literal["word"]] + """Required. Default value is \"word\".""" + + +class VoiceAgentServerEventResponseAudioTimestampDone(TypedDict, total=False): # pylint: disable=name-too-long + """The ``response.audio_timestamp.done`` server event. + + :ivar type: Required. Default value is "response.audio_timestamp.done". + :vartype type: Literal["response.audio_timestamp.done"] + :ivar event_id: Required. + :vartype event_id: str + :ivar response_id: Required. + :vartype response_id: str + :ivar item_id: Required. + :vartype item_id: str + :ivar output_index: Required. + :vartype output_index: int + :ivar content_index: Required. + :vartype content_index: int + """ + + type: Required[Literal["response.audio_timestamp.done"]] + """Required. Default value is \"response.audio_timestamp.done\".""" + event_id: Required[str] + """Required.""" + response_id: Required[str] + """Required.""" + item_id: Required[str] + """Required.""" + output_index: Required[int] + """Required.""" + content_index: Required[int] + """Required.""" + + +class VoiceAgentServerEventResponseAudioTranscriptDelta(TypedDict, total=False): # pylint: disable=name-too-long + """The ``response.output_audio_transcript.delta`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``response.output_audio_transcript.delta``. Required. + RESPONSE_OUTPUT_AUDIO_TRANSCRIPT_DELTA. + :vartype type: Literal[RealtimeServerEventType.RESPONSE_OUTPUT_AUDIO_TRANSCRIPT_DELTA] + :ivar response_id: The ID of the response. Required. + :vartype response_id: str + :ivar item_id: The ID of the item. Required. + :vartype item_id: str + :ivar output_index: The index of the output item in the response. Required. + :vartype output_index: int + :ivar content_index: The index of the content part in the item's content array. Required. + :vartype content_index: int + :ivar delta: The transcript delta. Required. + :vartype delta: str + """ + + event_id: Required[str] + """The unique ID of the server event. Required.""" + type: Required[Literal[RealtimeServerEventType.RESPONSE_OUTPUT_AUDIO_TRANSCRIPT_DELTA]] + """The event type, must be ``response.output_audio_transcript.delta``. Required. + RESPONSE_OUTPUT_AUDIO_TRANSCRIPT_DELTA.""" + response_id: Required[str] + """The ID of the response. Required.""" + item_id: Required[str] + """The ID of the item. Required.""" + output_index: Required[int] + """The index of the output item in the response. Required.""" + content_index: Required[int] + """The index of the content part in the item's content array. Required.""" + delta: Required[str] + """The transcript delta. Required.""" + + +class VoiceAgentServerEventResponseAudioTranscriptDone(TypedDict, total=False): # pylint: disable=name-too-long + """The ``response.output_audio_transcript.done`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``response.output_audio_transcript.done``. Required. + RESPONSE_OUTPUT_AUDIO_TRANSCRIPT_DONE. + :vartype type: Literal[RealtimeServerEventType.RESPONSE_OUTPUT_AUDIO_TRANSCRIPT_DONE] + :ivar response_id: The ID of the response. Required. + :vartype response_id: str + :ivar item_id: The ID of the item. Required. + :vartype item_id: str + :ivar output_index: The index of the output item in the response. Required. + :vartype output_index: int + :ivar content_index: The index of the content part in the item's content array. Required. + :vartype content_index: int + :ivar transcript: The final transcript of the audio. Required. + :vartype transcript: str + """ + + event_id: Required[str] + """The unique ID of the server event. Required.""" + type: Required[Literal[RealtimeServerEventType.RESPONSE_OUTPUT_AUDIO_TRANSCRIPT_DONE]] + """The event type, must be ``response.output_audio_transcript.done``. Required. + RESPONSE_OUTPUT_AUDIO_TRANSCRIPT_DONE.""" + response_id: Required[str] + """The ID of the response. Required.""" + item_id: Required[str] + """The ID of the item. Required.""" + output_index: Required[int] + """The index of the output item in the response. Required.""" + content_index: Required[int] + """The index of the content part in the item's content array. Required.""" + transcript: Required[str] + """The final transcript of the audio. Required.""" + + +class VoiceAgentServerEventResponseContentPartDone(TypedDict, total=False): # pylint: disable=name-too-long + """The ``response.content_part.done`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``response.content_part.done``. Required. + RESPONSE_CONTENT_PART_DONE. + :vartype type: Literal[RealtimeServerEventType.RESPONSE_CONTENT_PART_DONE] + :ivar response_id: The ID of the response. Required. + :vartype response_id: str + :ivar item_id: The ID of the item. Required. + :vartype item_id: str + :ivar output_index: The index of the output item in the response. Required. + :vartype output_index: int + :ivar content_index: The index of the content part in the item's content array. Required. + :vartype content_index: int + :ivar part: The content part that finished streaming. Required. Is either a + VoiceAgentResponseEventTextContentPart type or a VoiceAgentResponseEventAudioContentPart type. + :vartype part: "_unions.VoiceAgentResponseEventContentPart" + """ + + event_id: Required[str] + """The unique ID of the server event. Required.""" + type: Required[Literal[RealtimeServerEventType.RESPONSE_CONTENT_PART_DONE]] + """The event type, must be ``response.content_part.done``. Required. RESPONSE_CONTENT_PART_DONE.""" + response_id: Required[str] + """The ID of the response. Required.""" + item_id: Required[str] + """The ID of the item. Required.""" + output_index: Required[int] + """The index of the output item in the response. Required.""" + content_index: Required[int] + """The index of the content part in the item's content array. Required.""" + part: Required["_unions.VoiceAgentResponseEventContentPart"] + """The content part that finished streaming. Required. Is either a + VoiceAgentResponseEventTextContentPart type or a VoiceAgentResponseEventAudioContentPart type.""" + + +class VoiceAgentServerEventResponseCreated(TypedDict, total=False): + """The ``response.created`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``response.created``. Required. RESPONSE_CREATED. + :vartype type: Literal[RealtimeServerEventType.RESPONSE_CREATED] + :ivar response: The created voice-agent response. Required. + :vartype response: "VoiceAgentRealtimeResponse" + """ + + event_id: Required[str] + """The unique ID of the server event. Required.""" + type: Required[Literal[RealtimeServerEventType.RESPONSE_CREATED]] + """The event type, must be ``response.created``. Required. RESPONSE_CREATED.""" + response: Required["VoiceAgentRealtimeResponse"] + """The created voice-agent response. Required.""" + + +class VoiceAgentServerEventResponseDone(TypedDict, total=False): + """The ``response.done`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``response.done``. Required. RESPONSE_DONE. + :vartype type: Literal[RealtimeServerEventType.RESPONSE_DONE] + :ivar response: The completed voice-agent response. Required. + :vartype response: "VoiceAgentRealtimeResponse" + """ + + event_id: Required[str] + """The unique ID of the server event. Required.""" + type: Required[Literal[RealtimeServerEventType.RESPONSE_DONE]] + """The event type, must be ``response.done``. Required. RESPONSE_DONE.""" + response: Required["VoiceAgentRealtimeResponse"] + """The completed voice-agent response. Required.""" + + +class VoiceAgentServerEventResponseFunctionCallArgumentsDelta(TypedDict, total=False): # pylint: disable=name-too-long + """The ``response.function_call_arguments.delta`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``response.function_call_arguments.delta``. Required. + RESPONSE_FUNCTION_CALL_ARGUMENTS_DELTA. + :vartype type: Literal[RealtimeServerEventType.RESPONSE_FUNCTION_CALL_ARGUMENTS_DELTA] + :ivar response_id: The ID of the response. Required. + :vartype response_id: str + :ivar item_id: The ID of the function call item. Required. + :vartype item_id: str + :ivar output_index: The index of the output item in the response. Required. + :vartype output_index: int + :ivar call_id: The ID of the function call. Required. + :vartype call_id: str + :ivar delta: The arguments delta as a JSON string. Required. + :vartype delta: str + """ + + event_id: Required[str] + """The unique ID of the server event. Required.""" + type: Required[Literal[RealtimeServerEventType.RESPONSE_FUNCTION_CALL_ARGUMENTS_DELTA]] + """The event type, must be ``response.function_call_arguments.delta``. Required. + RESPONSE_FUNCTION_CALL_ARGUMENTS_DELTA.""" + response_id: Required[str] + """The ID of the response. Required.""" + item_id: Required[str] + """The ID of the function call item. Required.""" + output_index: Required[int] + """The index of the output item in the response. Required.""" + call_id: Required[str] + """The ID of the function call. Required.""" + delta: Required[str] + """The arguments delta as a JSON string. Required.""" + + +class VoiceAgentServerEventResponseFunctionCallArgumentsDone(TypedDict, total=False): # pylint: disable=name-too-long + """The ``response.function_call_arguments.done`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``response.function_call_arguments.done``. Required. + RESPONSE_FUNCTION_CALL_ARGUMENTS_DONE. + :vartype type: Literal[RealtimeServerEventType.RESPONSE_FUNCTION_CALL_ARGUMENTS_DONE] + :ivar response_id: The ID of the response. Required. + :vartype response_id: str + :ivar item_id: The ID of the function call item. Required. + :vartype item_id: str + :ivar output_index: The index of the output item in the response. Required. + :vartype output_index: int + :ivar call_id: The ID of the function call. Required. + :vartype call_id: str + :ivar name: The name of the function that was called. Required. + :vartype name: str + :ivar arguments: The final arguments as a JSON string. Required. + :vartype arguments: str + """ + + event_id: Required[str] + """The unique ID of the server event. Required.""" + type: Required[Literal[RealtimeServerEventType.RESPONSE_FUNCTION_CALL_ARGUMENTS_DONE]] + """The event type, must be ``response.function_call_arguments.done``. Required. + RESPONSE_FUNCTION_CALL_ARGUMENTS_DONE.""" + response_id: Required[str] + """The ID of the response. Required.""" + item_id: Required[str] + """The ID of the function call item. Required.""" + output_index: Required[int] + """The index of the output item in the response. Required.""" + call_id: Required[str] + """The ID of the function call. Required.""" + name: Required[str] + """The name of the function that was called. Required.""" + arguments: Required[str] + """The final arguments as a JSON string. Required.""" + + +class VoiceAgentServerEventResponseMcpCallArgumentsDelta(TypedDict, total=False): # pylint: disable=name-too-long + """The ``response.mcp_call_arguments.delta`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``response.mcp_call_arguments.delta``. Required. + RESPONSE_MCP_CALL_ARGUMENTS_DELTA. + :vartype type: Literal[RealtimeServerEventType.RESPONSE_MCP_CALL_ARGUMENTS_DELTA] + :ivar response_id: The ID of the response. Required. + :vartype response_id: str + :ivar item_id: The ID of the MCP tool call item. Required. + :vartype item_id: str + :ivar output_index: The index of the output item in the response. Required. + :vartype output_index: int + :ivar delta: The JSON-encoded arguments delta. Required. + :vartype delta: str + :ivar obfuscation: + :vartype obfuscation: str + """ + + event_id: Required[str] + """The unique ID of the server event. Required.""" + type: Required[Literal[RealtimeServerEventType.RESPONSE_MCP_CALL_ARGUMENTS_DELTA]] + """The event type, must be ``response.mcp_call_arguments.delta``. Required. + RESPONSE_MCP_CALL_ARGUMENTS_DELTA.""" + response_id: Required[str] + """The ID of the response. Required.""" + item_id: Required[str] + """The ID of the MCP tool call item. Required.""" + output_index: Required[int] + """The index of the output item in the response. Required.""" + delta: Required[str] + """The JSON-encoded arguments delta. Required.""" + obfuscation: Optional[str] + + +class VoiceAgentServerEventResponseMcpCallArgumentsDone(TypedDict, total=False): # pylint: disable=name-too-long + """The ``response.mcp_call_arguments.done`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``response.mcp_call_arguments.done``. Required. + RESPONSE_MCP_CALL_ARGUMENTS_DONE. + :vartype type: Literal[RealtimeServerEventType.RESPONSE_MCP_CALL_ARGUMENTS_DONE] + :ivar response_id: The ID of the response. Required. + :vartype response_id: str + :ivar item_id: The ID of the MCP tool call item. Required. + :vartype item_id: str + :ivar output_index: The index of the output item in the response. Required. + :vartype output_index: int + :ivar arguments: The final JSON-encoded arguments string. Required. + :vartype arguments: str + """ + + event_id: Required[str] + """The unique ID of the server event. Required.""" + type: Required[Literal[RealtimeServerEventType.RESPONSE_MCP_CALL_ARGUMENTS_DONE]] + """The event type, must be ``response.mcp_call_arguments.done``. Required. + RESPONSE_MCP_CALL_ARGUMENTS_DONE.""" + response_id: Required[str] + """The ID of the response. Required.""" + item_id: Required[str] + """The ID of the MCP tool call item. Required.""" + output_index: Required[int] + """The index of the output item in the response. Required.""" + arguments: Required[str] + """The final JSON-encoded arguments string. Required.""" + + +class VoiceAgentServerEventResponseMcpCallCompleted(TypedDict, total=False): # pylint: disable=name-too-long + """The ``response.mcp_call.completed`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``response.mcp_call.completed``. Required. + RESPONSE_MCP_CALL_COMPLETED. + :vartype type: Literal[RealtimeServerEventType.RESPONSE_MCP_CALL_COMPLETED] + :ivar output_index: The index of the output item in the response. Required. + :vartype output_index: int + :ivar item_id: The ID of the MCP tool call item. Required. + :vartype item_id: str + """ + + event_id: Required[str] + """The unique ID of the server event. Required.""" + type: Required[Literal[RealtimeServerEventType.RESPONSE_MCP_CALL_COMPLETED]] + """The event type, must be ``response.mcp_call.completed``. Required. RESPONSE_MCP_CALL_COMPLETED.""" + output_index: Required[int] + """The index of the output item in the response. Required.""" + item_id: Required[str] + """The ID of the MCP tool call item. Required.""" + + +class VoiceAgentServerEventResponseMcpCallFailed(TypedDict, total=False): # pylint: disable=name-too-long + """The ``response.mcp_call.failed`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``response.mcp_call.failed``. Required. + RESPONSE_MCP_CALL_FAILED. + :vartype type: Literal[RealtimeServerEventType.RESPONSE_MCP_CALL_FAILED] + :ivar output_index: The index of the output item in the response. Required. + :vartype output_index: int + :ivar item_id: The ID of the MCP tool call item. Required. + :vartype item_id: str + """ + + event_id: Required[str] + """The unique ID of the server event. Required.""" + type: Required[Literal[RealtimeServerEventType.RESPONSE_MCP_CALL_FAILED]] + """The event type, must be ``response.mcp_call.failed``. Required. RESPONSE_MCP_CALL_FAILED.""" + output_index: Required[int] + """The index of the output item in the response. Required.""" + item_id: Required[str] + """The ID of the MCP tool call item. Required.""" + + +class VoiceAgentServerEventResponseMcpCallInProgress(TypedDict, total=False): # pylint: disable=name-too-long + """The ``response.mcp_call.in_progress`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``response.mcp_call.in_progress``. Required. + RESPONSE_MCP_CALL_IN_PROGRESS. + :vartype type: Literal[RealtimeServerEventType.RESPONSE_MCP_CALL_IN_PROGRESS] + :ivar output_index: The index of the output item in the response. Required. + :vartype output_index: int + :ivar item_id: The ID of the MCP tool call item. Required. + :vartype item_id: str + """ + + event_id: Required[str] + """The unique ID of the server event. Required.""" + type: Required[Literal[RealtimeServerEventType.RESPONSE_MCP_CALL_IN_PROGRESS]] + """The event type, must be ``response.mcp_call.in_progress``. Required. + RESPONSE_MCP_CALL_IN_PROGRESS.""" + output_index: Required[int] + """The index of the output item in the response. Required.""" + item_id: Required[str] + """The ID of the MCP tool call item. Required.""" + + +class VoiceAgentServerEventResponseOutputItemAdded(TypedDict, total=False): # pylint: disable=name-too-long + """The ``response.output_item.added`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``response.output_item.added``. Required. + RESPONSE_OUTPUT_ITEM_ADDED. + :vartype type: Literal[RealtimeServerEventType.RESPONSE_OUTPUT_ITEM_ADDED] + :ivar response_id: The ID of the Response to which the item belongs. Required. + :vartype response_id: str + :ivar output_index: The index of the output item in the Response. Required. + :vartype output_index: int + :ivar item: The output item that was added. Required. Is one of the following types: + "_unions.VoiceAgentResponseMessageItem", VoiceFunctionCallItem, VoiceFunctionCallOutputItem, + VoiceMcpListToolsItem, VoiceMcpCallItem, VoiceMcpApprovalRequestItem, + VoiceMcpApprovalResponseItem, VoiceAgentWorkflowActionItem, VoiceAgentWebSearchCallItem, + VoiceAgentFileSearchCallItem + :vartype item: "_unions.VoiceAgentResponseItem" + """ + + event_id: Required[str] + """The unique ID of the server event. Required.""" + type: Required[Literal[RealtimeServerEventType.RESPONSE_OUTPUT_ITEM_ADDED]] + """The event type, must be ``response.output_item.added``. Required. RESPONSE_OUTPUT_ITEM_ADDED.""" + response_id: Required[str] + """The ID of the Response to which the item belongs. Required.""" + output_index: Required[int] + """The index of the output item in the Response. Required.""" + item: Required["_unions.VoiceAgentResponseItem"] + """The output item that was added. Required. Is one of the following types: + \"_unions.VoiceAgentResponseMessageItem\", VoiceFunctionCallItem, VoiceFunctionCallOutputItem, + VoiceMcpListToolsItem, VoiceMcpCallItem, VoiceMcpApprovalRequestItem, + VoiceMcpApprovalResponseItem, VoiceAgentWorkflowActionItem, VoiceAgentWebSearchCallItem, + VoiceAgentFileSearchCallItem""" + + +class VoiceAgentServerEventResponseOutputItemDone(TypedDict, total=False): # pylint: disable=name-too-long + """The ``response.output_item.done`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``response.output_item.done``. Required. + RESPONSE_OUTPUT_ITEM_DONE. + :vartype type: Literal[RealtimeServerEventType.RESPONSE_OUTPUT_ITEM_DONE] + :ivar response_id: The ID of the Response to which the item belongs. Required. + :vartype response_id: str + :ivar output_index: The index of the output item in the Response. Required. + :vartype output_index: int + :ivar item: The output item that finished streaming. Required. Is one of the following types: + "_unions.VoiceAgentResponseMessageItem", VoiceFunctionCallItem, VoiceFunctionCallOutputItem, + VoiceMcpListToolsItem, VoiceMcpCallItem, VoiceMcpApprovalRequestItem, + VoiceMcpApprovalResponseItem, VoiceAgentWorkflowActionItem, VoiceAgentWebSearchCallItem, + VoiceAgentFileSearchCallItem + :vartype item: "_unions.VoiceAgentResponseItem" + """ + + event_id: Required[str] + """The unique ID of the server event. Required.""" + type: Required[Literal[RealtimeServerEventType.RESPONSE_OUTPUT_ITEM_DONE]] + """The event type, must be ``response.output_item.done``. Required. RESPONSE_OUTPUT_ITEM_DONE.""" + response_id: Required[str] + """The ID of the Response to which the item belongs. Required.""" + output_index: Required[int] + """The index of the output item in the Response. Required.""" + item: Required["_unions.VoiceAgentResponseItem"] + """The output item that finished streaming. Required. Is one of the following types: + \"_unions.VoiceAgentResponseMessageItem\", VoiceFunctionCallItem, VoiceFunctionCallOutputItem, + VoiceMcpListToolsItem, VoiceMcpCallItem, VoiceMcpApprovalRequestItem, + VoiceMcpApprovalResponseItem, VoiceAgentWorkflowActionItem, VoiceAgentWebSearchCallItem, + VoiceAgentFileSearchCallItem""" + + +class VoiceAgentServerEventResponseTextDelta(TypedDict, total=False): + """The ``response.output_text.delta`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``response.output_text.delta``. Required. + RESPONSE_OUTPUT_TEXT_DELTA. + :vartype type: Literal[RealtimeServerEventType.RESPONSE_OUTPUT_TEXT_DELTA] + :ivar response_id: The ID of the response. Required. + :vartype response_id: str + :ivar item_id: The ID of the item. Required. + :vartype item_id: str + :ivar output_index: The index of the output item in the response. Required. + :vartype output_index: int + :ivar content_index: The index of the content part in the item's content array. Required. + :vartype content_index: int + :ivar delta: The text delta. Required. + :vartype delta: str + """ + + event_id: Required[str] + """The unique ID of the server event. Required.""" + type: Required[Literal[RealtimeServerEventType.RESPONSE_OUTPUT_TEXT_DELTA]] + """The event type, must be ``response.output_text.delta``. Required. RESPONSE_OUTPUT_TEXT_DELTA.""" + response_id: Required[str] + """The ID of the response. Required.""" + item_id: Required[str] + """The ID of the item. Required.""" + output_index: Required[int] + """The index of the output item in the response. Required.""" + content_index: Required[int] + """The index of the content part in the item's content array. Required.""" + delta: Required[str] + """The text delta. Required.""" + + +class VoiceAgentServerEventResponseTextDone(TypedDict, total=False): + """The ``response.output_text.done`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``response.output_text.done``. Required. + RESPONSE_OUTPUT_TEXT_DONE. + :vartype type: Literal[RealtimeServerEventType.RESPONSE_OUTPUT_TEXT_DONE] + :ivar response_id: The ID of the response. Required. + :vartype response_id: str + :ivar item_id: The ID of the item. Required. + :vartype item_id: str + :ivar output_index: The index of the output item in the response. Required. + :vartype output_index: int + :ivar content_index: The index of the content part in the item's content array. Required. + :vartype content_index: int + :ivar text: The final text content. Required. + :vartype text: str + """ + + event_id: Required[str] + """The unique ID of the server event. Required.""" + type: Required[Literal[RealtimeServerEventType.RESPONSE_OUTPUT_TEXT_DONE]] + """The event type, must be ``response.output_text.done``. Required. RESPONSE_OUTPUT_TEXT_DONE.""" + response_id: Required[str] + """The ID of the response. Required.""" + item_id: Required[str] + """The ID of the item. Required.""" + output_index: Required[int] + """The index of the output item in the response. Required.""" + content_index: Required[int] + """The index of the content part in the item's content array. Required.""" + text: Required[str] + """The final text content. Required.""" + + +class VoiceAgentServerEventResponseVideoDelta(TypedDict, total=False): + """The ``response.video.delta`` server event. + + :ivar type: Required. Default value is "response.video.delta". + :vartype type: Literal["response.video.delta"] + :ivar event_id: Required. + :vartype event_id: str + :ivar output_index: Required. + :vartype output_index: int + :ivar codec: Required. + :vartype codec: str + :ivar delta: The base64-encoded video frame data. Required. + :vartype delta: str + """ + + type: Required[Literal["response.video.delta"]] + """Required. Default value is \"response.video.delta\".""" + event_id: Required[str] + """Required.""" + output_index: Required[int] + """Required.""" + codec: Required[str] + """Required.""" + delta: Required[str] + """The base64-encoded video frame data. Required.""" + + +class VoiceAgentServerEventSessionAvatarConnecting(TypedDict, total=False): # pylint: disable=name-too-long + """The ``session.avatar.connecting`` server event. + + :ivar type: Required. Default value is "session.avatar.connecting". + :vartype type: Literal["session.avatar.connecting"] + :ivar event_id: Required. + :vartype event_id: str + :ivar server_sdp: The server's SDP answer for avatar media negotiation. Required. + :vartype server_sdp: str + """ + + type: Required[Literal["session.avatar.connecting"]] + """Required. Default value is \"session.avatar.connecting\".""" + event_id: Required[str] + """Required.""" + server_sdp: Required[str] + """The server's SDP answer for avatar media negotiation. Required.""" + + +class VoiceAgentServerEventSessionAvatarSwitchToIdle(TypedDict, total=False): # pylint: disable=name-too-long + """The ``session.avatar.switch_to_idle`` server event. + + :ivar type: Required. Default value is "session.avatar.switch_to_idle". + :vartype type: Literal["session.avatar.switch_to_idle"] + :ivar event_id: Required. + :vartype event_id: str + :ivar turn_id: + :vartype turn_id: str + """ + + type: Required[Literal["session.avatar.switch_to_idle"]] + """Required. Default value is \"session.avatar.switch_to_idle\".""" + event_id: Required[str] + """Required.""" + turn_id: str + + +class VoiceAgentServerEventSessionAvatarSwitchToSpeaking(TypedDict, total=False): # pylint: disable=name-too-long + """The ``session.avatar.switch_to_speaking`` server event. + + :ivar type: Required. Default value is "session.avatar.switch_to_speaking". + :vartype type: Literal["session.avatar.switch_to_speaking"] + :ivar event_id: Required. + :vartype event_id: str + :ivar turn_id: + :vartype turn_id: str + """ + + type: Required[Literal["session.avatar.switch_to_speaking"]] + """Required. Default value is \"session.avatar.switch_to_speaking\".""" + event_id: Required[str] + """Required.""" + turn_id: str + + +class VoiceAgentServerEventSessionCreated(TypedDict, total=False): + """The ``session.created`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``session.created``. Required. SESSION_CREATED. + :vartype type: Literal[RealtimeServerEventType.SESSION_CREATED] + :ivar session: The initial effective voice-agent session configuration. Required. + :vartype session: "VoiceAgentSessionResponseConfig" + """ + + event_id: Required[str] + """The unique ID of the server event. Required.""" + type: Required[Literal[RealtimeServerEventType.SESSION_CREATED]] + """The event type, must be ``session.created``. Required. SESSION_CREATED.""" + session: Required["VoiceAgentSessionResponseConfig"] + """The initial effective voice-agent session configuration. Required.""" + + +class VoiceAgentServerEventSessionHandoffAborted(TypedDict, total=False): # pylint: disable=name-too-long + """The ``session.handoff.aborted`` server event. + + :ivar type: Required. Default value is "session.handoff.aborted". + :vartype type: Literal["session.handoff.aborted"] + :ivar event_id: Required. + :vartype event_id: str + :ivar handoff_id: Required. + :vartype handoff_id: str + :ivar edge_id: Required. + :vartype edge_id: str + :ivar from_node_id: Required. + :vartype from_node_id: str + :ivar to_node_id: Required. + :vartype to_node_id: str + :ivar from_model: Required. + :vartype from_model: str + :ivar to_model: Required. + :vartype to_model: str + :ivar tool_call_id: Required. + :vartype tool_call_id: str + :ivar node_generation: Required. + :vartype node_generation: int + :ivar reason: The reason the handoff was aborted. Required. Known values are: + "user_interruption" and "error". + :vartype reason: Union[str, "VoiceAgentHandoffAbortReason"] + :ivar error: The error that aborted the handoff, when ``reason`` is ``error``. + :vartype error: "VoiceAgentServerEventErrorDetails" + """ + + type: Required[Literal["session.handoff.aborted"]] + """Required. Default value is \"session.handoff.aborted\".""" + event_id: Required[str] + """Required.""" + handoff_id: Required[str] + """Required.""" + edge_id: Required[str] + """Required.""" + from_node_id: Required[str] + """Required.""" + to_node_id: Required[str] + """Required.""" + from_model: Required[str] + """Required.""" + to_model: Required[str] + """Required.""" + tool_call_id: Required[str] + """Required.""" + node_generation: Required[int] + """Required.""" + reason: Required[Union[str, "VoiceAgentHandoffAbortReason"]] + """The reason the handoff was aborted. Required. Known values are: \"user_interruption\" and + \"error\".""" + error: "VoiceAgentServerEventErrorDetails" + """The error that aborted the handoff, when ``reason`` is ``error``.""" + + +class VoiceAgentServerEventSessionHandoffCompleted(TypedDict, total=False): # pylint: disable=name-too-long + """The ``session.handoff.completed`` server event. + + :ivar type: Required. Default value is "session.handoff.completed". + :vartype type: Literal["session.handoff.completed"] + :ivar event_id: Required. + :vartype event_id: str + :ivar handoff_id: Required. + :vartype handoff_id: str + :ivar edge_id: Required. + :vartype edge_id: str + :ivar from_node_id: Required. + :vartype from_node_id: str + :ivar to_node_id: Required. + :vartype to_node_id: str + :ivar from_model: Required. + :vartype from_model: str + :ivar to_model: Required. + :vartype to_model: str + :ivar tool_call_id: Required. + :vartype tool_call_id: str + :ivar node_generation: Required. + :vartype node_generation: int + :ivar prepare_duration_ms: The time spent preparing the target behavior, in milliseconds. + Required. + :vartype prepare_duration_ms: int + :ivar duration_ms: The total duration of the handoff, in milliseconds. Required. + :vartype duration_ms: int + """ + + type: Required[Literal["session.handoff.completed"]] + """Required. Default value is \"session.handoff.completed\".""" + event_id: Required[str] + """Required.""" + handoff_id: Required[str] + """Required.""" + edge_id: Required[str] + """Required.""" + from_node_id: Required[str] + """Required.""" + to_node_id: Required[str] + """Required.""" + from_model: Required[str] + """Required.""" + to_model: Required[str] + """Required.""" + tool_call_id: Required[str] + """Required.""" + node_generation: Required[int] + """Required.""" + prepare_duration_ms: Required[int] + """The time spent preparing the target behavior, in milliseconds. Required.""" + duration_ms: Required[int] + """The total duration of the handoff, in milliseconds. Required.""" + + +class VoiceAgentServerEventSessionHandoffStarted(TypedDict, total=False): # pylint: disable=name-too-long + """The ``session.handoff.started`` server event. + + :ivar type: Required. Default value is "session.handoff.started". + :vartype type: Literal["session.handoff.started"] + :ivar event_id: Required. + :vartype event_id: str + :ivar handoff_id: Required. + :vartype handoff_id: str + :ivar edge_id: Required. + :vartype edge_id: str + :ivar from_node_id: Required. + :vartype from_node_id: str + :ivar to_node_id: Required. + :vartype to_node_id: str + :ivar from_model: Required. + :vartype from_model: str + :ivar to_model: Required. + :vartype to_model: str + :ivar tool_call_id: Required. + :vartype tool_call_id: str + :ivar node_generation: Required. + :vartype node_generation: int + """ + + type: Required[Literal["session.handoff.started"]] + """Required. Default value is \"session.handoff.started\".""" + event_id: Required[str] + """Required.""" + handoff_id: Required[str] + """Required.""" + edge_id: Required[str] + """Required.""" + from_node_id: Required[str] + """Required.""" + to_node_id: Required[str] + """Required.""" + from_model: Required[str] + """Required.""" + to_model: Required[str] + """Required.""" + tool_call_id: Required[str] + """Required.""" + node_generation: Required[int] + """Required.""" + + +class VoiceAgentServerEventSessionUpdated(TypedDict, total=False): + """The ``session.updated`` server event. + + :ivar event_id: The unique ID of the server event. Required. + :vartype event_id: str + :ivar type: The event type, must be ``session.updated``. Required. SESSION_UPDATED. + :vartype type: Literal[RealtimeServerEventType.SESSION_UPDATED] + :ivar session: The effective voice-agent session configuration after the update. Required. + :vartype session: "VoiceAgentSessionResponseConfig" + """ + + event_id: Required[str] + """The unique ID of the server event. Required.""" + type: Required[Literal[RealtimeServerEventType.SESSION_UPDATED]] + """The event type, must be ``session.updated``. Required. SESSION_UPDATED.""" + session: Required["VoiceAgentSessionResponseConfig"] + """The effective voice-agent session configuration after the update. Required.""" + + +class VoiceAgentServerEventWarning(TypedDict, total=False): + """The ``warning`` server event. + + :ivar type: Required. Default value is "warning". + :vartype type: Literal["warning"] + :ivar event_id: Required. + :vartype event_id: str + :ivar warning: Required. + :vartype warning: "VoiceAgentServerEventWarningDetails" + """ + + type: Required[Literal["warning"]] + """Required. Default value is \"warning\".""" + event_id: Required[str] + """Required.""" + warning: Required["VoiceAgentServerEventWarningDetails"] + """Required.""" + + +class VoiceAgentServerEventWarningDetails(TypedDict, total=False): + """Details of a non-fatal warning. + + :ivar message: Required. + :vartype message: str + :ivar code: + :vartype code: str + :ivar param: + :vartype param: str + """ + + message: Required[str] + """Required.""" + code: str + param: str + + +class VoiceAgentServerEventWebSearchCallCompleted(TypedDict, total=False): # pylint: disable=name-too-long + """The ``response.web_search_call.completed`` server event. + + :ivar type: Required. Default value is "response.web_search_call.completed". + :vartype type: Literal["response.web_search_call.completed"] + :ivar event_id: + :vartype event_id: str + :ivar response_id: + :vartype response_id: str + :ivar item_id: Required. + :vartype item_id: str + :ivar output_index: Required. + :vartype output_index: int + :ivar sequence_number: Required. + :vartype sequence_number: int + """ + + type: Required[Literal["response.web_search_call.completed"]] + """Required. Default value is \"response.web_search_call.completed\".""" + event_id: str + response_id: str + item_id: Required[str] + """Required.""" + output_index: Required[int] + """Required.""" + sequence_number: Required[int] + """Required.""" + + +class VoiceAgentServerEventWebSearchCallInProgress(TypedDict, total=False): # pylint: disable=name-too-long + """The ``response.web_search_call.in_progress`` server event. + + :ivar type: Required. Default value is "response.web_search_call.in_progress". + :vartype type: Literal["response.web_search_call.in_progress"] + :ivar event_id: + :vartype event_id: str + :ivar response_id: + :vartype response_id: str + :ivar item_id: Required. + :vartype item_id: str + :ivar output_index: Required. + :vartype output_index: int + :ivar sequence_number: Required. + :vartype sequence_number: int + """ + + type: Required[Literal["response.web_search_call.in_progress"]] + """Required. Default value is \"response.web_search_call.in_progress\".""" + event_id: str + response_id: str + item_id: Required[str] + """Required.""" + output_index: Required[int] + """Required.""" + sequence_number: Required[int] + """Required.""" + + +class VoiceAgentServerEventWebSearchCallSearching(TypedDict, total=False): # pylint: disable=name-too-long + """The ``response.web_search_call.searching`` server event. + + :ivar type: Required. Default value is "response.web_search_call.searching". + :vartype type: Literal["response.web_search_call.searching"] + :ivar event_id: + :vartype event_id: str + :ivar response_id: + :vartype response_id: str + :ivar item_id: Required. + :vartype item_id: str + :ivar output_index: Required. + :vartype output_index: int + :ivar sequence_number: Required. + :vartype sequence_number: int + """ + + type: Required[Literal["response.web_search_call.searching"]] + """Required. Default value is \"response.web_search_call.searching\".""" + event_id: str + response_id: str + item_id: Required[str] + """Required.""" + output_index: Required[int] + """Required.""" + sequence_number: Required[int] + """Required.""" + + +class VoiceAgentServerVadTurnDetection(TypedDict, total=False): + """Server VAD turn-detection settings. + + :ivar create_response: + :vartype create_response: bool + :ivar interrupt_response: + :vartype interrupt_response: bool + :ivar idle_timeout_ms: + :vartype idle_timeout_ms: int + :ivar type: Required. Server-side voice activity detection. + :vartype type: Literal[VoiceTurnDetectionType.SERVER_VAD] + :ivar threshold: + :vartype threshold: float + :ivar prefix_padding_ms: + :vartype prefix_padding_ms: int + :ivar silence_duration_ms: + :vartype silence_duration_ms: int + :ivar speech_duration_ms: + :vartype speech_duration_ms: int + :ivar end_of_utterance_detection: + :vartype end_of_utterance_detection: "VoiceAgentEndOfUtteranceDetection" + :ivar auto_truncate: + :vartype auto_truncate: bool + """ + + create_response: bool + interrupt_response: bool + idle_timeout_ms: Optional[int] + type: Required[Literal[VoiceTurnDetectionType.SERVER_VAD]] + """Required. Server-side voice activity detection.""" + threshold: Optional[float] + prefix_padding_ms: Optional[int] + silence_duration_ms: Optional[int] + speech_duration_ms: Optional[int] + end_of_utterance_detection: Optional["VoiceAgentEndOfUtteranceDetection"] + auto_truncate: bool + + +class VoiceAgentSessionAvatarConfig(TypedDict, total=False): + """Avatar settings accepted by the stable voice-agent WebSocket contract. + + :ivar type: Known values are: "video_avatar" and "photo_avatar". + :vartype type: Union[str, "VoiceAgentAvatarType"] + :ivar ice_servers: + :vartype ice_servers: list["VoiceAgentAvatarIceServer"] + :ivar character: Required. + :vartype character: str + :ivar style: + :vartype style: str + :ivar customized: + :vartype customized: bool + :ivar model: + :vartype model: str + :ivar video: + :vartype video: "VoiceAgentAvatarVideoParams" + :ivar scene: + :vartype scene: "VoiceAgentAvatarScene" + :ivar output_protocol: Known values are: "websocket", "websocket-binary", and "webrtc". + :vartype output_protocol: Union[str, "VoiceAgentAvatarOutputProtocol"] + :ivar output_audit_audio: + :vartype output_audit_audio: bool + """ + + type: Union[str, "VoiceAgentAvatarType"] + """Known values are: \"video_avatar\" and \"photo_avatar\".""" + ice_servers: Optional[list["VoiceAgentAvatarIceServer"]] + character: Required[str] + """Required.""" + style: Optional[str] + customized: bool + model: Optional[str] + video: Optional["VoiceAgentAvatarVideoParams"] + scene: Optional["VoiceAgentAvatarScene"] + output_protocol: Union[str, "VoiceAgentAvatarOutputProtocol"] + """Known values are: \"websocket\", \"websocket-binary\", and \"webrtc\".""" + output_audit_audio: bool + + +class VoiceAgentSessionMcpTool(TypedDict, total=False): + """A remote MCP server available to a voice-agent session. + + :ivar type: Required. Default value is "mcp". + :vartype type: Literal["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: Required. + :vartype server_url: str + :ivar authorization: Is either a str type or a VoiceAgentMcpAssignedManagedIdentity type. + :vartype authorization: Union[str, "VoiceAgentMcpAssignedManagedIdentity"] + :ivar headers: + :vartype headers: dict[str, str] + :ivar allowed_tools: + :vartype allowed_tools: list[str] + :ivar require_approval: Is either a Union[str, "_models.VoiceAgentMcpApprovalMode"] type or a + {str: [str]} type. + :vartype require_approval: "_unions.VoiceAgentMcpApprovalPolicy" + :ivar response_scheduling: Known values are: "silent", "when_idle", "interrupt", and + "skip_if_busy". + :vartype response_scheduling: Union[str, "VoiceAgentMcpResponseScheduling"] + """ + + type: Required[Literal["mcp"]] + """Required. Default value is \"mcp\".""" + server_label: Required[str] + """A label for this MCP server, used to identify it in tool calls. Required.""" + server_url: Required[str] + """Required.""" + authorization: Optional[Union[str, "VoiceAgentMcpAssignedManagedIdentity"]] + """Is either a str type or a VoiceAgentMcpAssignedManagedIdentity type.""" + headers: dict[str, str] + allowed_tools: list[str] + require_approval: "_unions.VoiceAgentMcpApprovalPolicy" + """Is either a Union[str, \"_models.VoiceAgentMcpApprovalMode\"] type or a {str: [str]} type.""" + response_scheduling: Union[str, "VoiceAgentMcpResponseScheduling"] + """Known values are: \"silent\", \"when_idle\", \"interrupt\", and \"skip_if_busy\".""" + + +class VoiceAgentSessionResponseAudio(TypedDict, total=False): + """Input- and output-audio settings returned in a stable voice-agent session event. + + :ivar input: The effective input-audio settings. + :vartype input: "VoiceAgentSessionResponseAudioInput" + :ivar output: The output-audio settings for the session. + :vartype output: "VoiceAgentSessionResponseAudioOutput" + """ + + input: Optional["VoiceAgentSessionResponseAudioInput"] + """The effective input-audio settings.""" + output: Optional["VoiceAgentSessionResponseAudioOutput"] + """The output-audio settings for the session.""" + + +class VoiceAgentSessionResponseAudioInput(TypedDict, total=False): + """Input-audio settings returned in a stable voice-agent session event. + + :ivar noise_reduction: Input noise reduction. Set to null to disable. + :vartype noise_reduction: "VoiceNoiseReduction" + :ivar transcription: Asynchronous input-audio transcription. Set to null to disable + transcription. + :vartype transcription: "VoiceInputTranscription" + :ivar format: The structured input audio format. + :vartype format: "VoiceAudioFormat" + :ivar turn_detection: Turn-detection settings. Set to null to disable server-side turn + detection. Is one of the following types: VoiceAgentServerVadTurnDetection, + VoiceAgentSemanticVadTurnDetection, VoiceAgentAzureSemanticVadTurnDetection, + VoiceAgentAzureMultilingualSemanticVadTurnDetection + :vartype turn_detection: "_unions.VoiceAgentTurnDetection" + :ivar echo_cancellation: Optional server-side echo cancellation settings. + :vartype echo_cancellation: "VoiceAgentEchoCancellation" + """ + + noise_reduction: Optional["VoiceNoiseReduction"] + """Input noise reduction. Set to null to disable.""" + transcription: Optional["VoiceInputTranscription"] + """Asynchronous input-audio transcription. Set to null to disable transcription.""" + format: Optional["VoiceAudioFormat"] + """The structured input audio format.""" + turn_detection: Optional["_unions.VoiceAgentTurnDetection"] + """Turn-detection settings. Set to null to disable server-side turn detection. Is one of the + following types: VoiceAgentServerVadTurnDetection, VoiceAgentSemanticVadTurnDetection, + VoiceAgentAzureSemanticVadTurnDetection, VoiceAgentAzureMultilingualSemanticVadTurnDetection""" + echo_cancellation: Optional["VoiceAgentEchoCancellation"] + """Optional server-side echo cancellation settings.""" + + +class VoiceAgentSessionResponseAudioOutput(TypedDict, total=False): + """Output-audio settings returned in a stable voice-agent session event. + + :ivar format: The output audio format. + :vartype format: "VoiceAudioFormat" + :ivar voice: The typed voice configuration. Is one of the following types: OpenAIVoice, + AzureVoice, AzureRealtimeNativeVoice + :vartype voice: "_unions.VoiceAgentVoice" + :ivar output_audio_timestamp_types: Timestamp kinds to include with output audio. + :vartype output_audio_timestamp_types: list[Union[str, "VoiceAudioTimestampType"]] + :ivar speed: The speaking-speed multiplier. + :vartype speed: float + """ + + format: "VoiceAudioFormat" + """The output audio format.""" + voice: "_unions.VoiceAgentVoice" + """The typed voice configuration. Is one of the following types: OpenAIVoice, AzureVoice, + AzureRealtimeNativeVoice""" + output_audio_timestamp_types: list[Union[str, "VoiceAudioTimestampType"]] + """Timestamp kinds to include with output audio.""" + speed: Optional[float] + """The speaking-speed multiplier.""" + + +class VoiceAgentSessionResponseConfig(TypedDict, total=False): + """The effective stable realtime session settings returned by the voice-agent service. + + :ivar type: The session type. Always ``realtime``. Required. Default value is "realtime". + :vartype type: Literal["realtime"] + :ivar instructions: Instructions applied throughout the session. + :vartype instructions: str + :ivar temperature: The sampling temperature for compatible cascaded pipelines. + :vartype temperature: float + :ivar max_output_tokens: The maximum output-token count for one response. Is either a int type + or a Literal["inf"] type. + :vartype max_output_tokens: "_unions.VoiceAgentMaxOutputTokens" + :ivar avatar: The avatar settings for the session. + :vartype avatar: "VoiceAgentSessionAvatarConfig" + :ivar animation: Animation settings for the session. + :vartype animation: "VoiceAgentAnimationConfig" + :ivar tools: Tools available to the session. + :vartype tools: list["_unions.VoiceAgentSessionTool"] + :ivar tool_choice: Tool-selection behavior for the session. Is either a Union[str, + "_models.ToolChoiceOptions"] type or a RealtimeToolChoiceFunction type. + :vartype tool_choice: "_unions.VoiceAgentToolChoice" + :ivar reasoning: Reasoning settings for compatible realtime models. + :vartype reasoning: "RealtimeReasoning" + :ivar parallel_tool_calls: Whether the model may call multiple tools in parallel. + :vartype parallel_tool_calls: bool + :ivar voice_adaptation: Voice-optimized instruction adaptation settings. + :vartype voice_adaptation: "VoiceAgentVoiceAdaptation" + :ivar interim_response: Interim-response settings for latency and tool execution. Is either a + VoiceAgentStaticInterimResponseConfig type or a VoiceAgentLlmInterimResponseConfig type. + :vartype interim_response: "_unions.VoiceAgentInterimResponse" + :ivar response_delimiter: A delimiter appended to generated responses. + :vartype response_delimiter: str + :ivar greeting: A proactive assistant greeting started after session configuration. + :vartype greeting: "VoiceGreetingConfig" + :ivar object: The object type. Always ``realtime.session``. Required. Default value is + "realtime.session". + :vartype object: Literal["realtime.session"] + :ivar id: The session identifier. Required. + :vartype id: str + :ivar model: The selected model. Required. + :vartype model: str + :ivar expires_at: The session expiration time as a Unix timestamp in seconds. + :vartype expires_at: int + :ivar output_modalities: The output modalities enabled for the session. Required. + :vartype output_modalities: list[Union[str, "VoiceOutputModality"]] + :ivar audio: The effective input- and output-audio settings for the session. + :vartype audio: "VoiceAgentSessionResponseAudio" + :ivar handoff: The effective handoff state. + :vartype handoff: "VoiceAgentHandoffState" + :ivar idle_timeout: The idle timeout reported by the service, in milliseconds. + :vartype idle_timeout: int + """ + + type: Required[Literal["realtime"]] + """The session type. Always ``realtime``. Required. Default value is \"realtime\".""" + instructions: Optional[str] + """Instructions applied throughout the session.""" + temperature: Optional[float] + """The sampling temperature for compatible cascaded pipelines.""" + max_output_tokens: Optional["_unions.VoiceAgentMaxOutputTokens"] + """The maximum output-token count for one response. Is either a int type or a Literal[\"inf\"] + type.""" + avatar: Optional["VoiceAgentSessionAvatarConfig"] + """The avatar settings for the session.""" + animation: Optional["VoiceAgentAnimationConfig"] + """Animation settings for the session.""" + tools: Optional[list["_unions.VoiceAgentSessionTool"]] + """Tools available to the session.""" + tool_choice: Optional["_unions.VoiceAgentToolChoice"] + """Tool-selection behavior for the session. Is either a Union[str, \"_models.ToolChoiceOptions\"] + type or a RealtimeToolChoiceFunction type.""" + reasoning: Optional["RealtimeReasoning"] + """Reasoning settings for compatible realtime models.""" + parallel_tool_calls: bool + """Whether the model may call multiple tools in parallel.""" + voice_adaptation: Optional["VoiceAgentVoiceAdaptation"] + """Voice-optimized instruction adaptation settings.""" + interim_response: Optional["_unions.VoiceAgentInterimResponse"] + """Interim-response settings for latency and tool execution. Is either a + VoiceAgentStaticInterimResponseConfig type or a VoiceAgentLlmInterimResponseConfig type.""" + response_delimiter: str + """A delimiter appended to generated responses.""" + greeting: Optional["VoiceGreetingConfig"] + """A proactive assistant greeting started after session configuration.""" + object: Required[Literal["realtime.session"]] + """The object type. Always ``realtime.session``. Required. Default value is \"realtime.session\".""" + id: Required[str] + """The session identifier. Required.""" + model: Required[str] + """The selected model. Required.""" + expires_at: Optional[int] + """The session expiration time as a Unix timestamp in seconds.""" + output_modalities: Required[list[Union[str, "VoiceOutputModality"]]] + """The output modalities enabled for the session. Required.""" + audio: Optional["VoiceAgentSessionResponseAudio"] + """The effective input- and output-audio settings for the session.""" + handoff: Optional["VoiceAgentHandoffState"] + """The effective handoff state.""" + idle_timeout: Optional[int] + """The idle timeout reported by the service, in milliseconds.""" + + +class VoiceAgentSessionUpdateAudio(TypedDict, total=False): + """Input- and output-audio settings accepted in a ``session.update`` client event. + + :ivar input: The input-audio settings for the session. + :vartype input: "VoiceAgentSessionUpdateAudioInput" + :ivar output: The output-audio settings for the session. + :vartype output: "VoiceAgentSessionUpdateAudioOutput" + """ + + input: Optional["VoiceAgentSessionUpdateAudioInput"] + """The input-audio settings for the session.""" + output: Optional["VoiceAgentSessionUpdateAudioOutput"] + """The output-audio settings for the session.""" + + +class VoiceAgentSessionUpdateAudioInput(TypedDict, total=False): + """Input-audio settings accepted in a stable voice-agent session. + + :ivar noise_reduction: Input noise reduction. Set to null to disable. + :vartype noise_reduction: "VoiceNoiseReduction" + :ivar transcription: Asynchronous input-audio transcription. Set to null to disable + transcription. + :vartype transcription: "VoiceInputTranscription" + :ivar format: The structured input audio format. + :vartype format: "VoiceAudioFormat" + :ivar turn_detection: Turn-detection settings. Set to null to disable server-side turn + detection. Is one of the following types: VoiceAgentServerVadTurnDetection, + VoiceAgentSemanticVadTurnDetection, VoiceAgentAzureSemanticVadTurnDetection, + VoiceAgentAzureMultilingualSemanticVadTurnDetection + :vartype turn_detection: "_unions.VoiceAgentTurnDetection" + :ivar echo_cancellation: Optional server-side echo cancellation settings. + :vartype echo_cancellation: "VoiceAgentEchoCancellation" + """ + + noise_reduction: Optional["VoiceNoiseReduction"] + """Input noise reduction. Set to null to disable.""" + transcription: Optional["VoiceInputTranscription"] + """Asynchronous input-audio transcription. Set to null to disable transcription.""" + format: Optional["VoiceAudioFormat"] + """The structured input audio format.""" + turn_detection: Optional["_unions.VoiceAgentTurnDetection"] + """Turn-detection settings. Set to null to disable server-side turn detection. Is one of the + following types: VoiceAgentServerVadTurnDetection, VoiceAgentSemanticVadTurnDetection, + VoiceAgentAzureSemanticVadTurnDetection, VoiceAgentAzureMultilingualSemanticVadTurnDetection""" + echo_cancellation: Optional["VoiceAgentEchoCancellation"] + """Optional server-side echo cancellation settings.""" + + +class VoiceAgentSessionUpdateAudioOutput(TypedDict, total=False): + """Output-audio settings accepted in a stable voice-agent session. + + :ivar format: The output audio format. + :vartype format: "VoiceAudioFormat" + :ivar voice: The typed voice configuration. Is one of the following types: OpenAIVoice, + AzureVoice, AzureRealtimeNativeVoice + :vartype voice: "_unions.VoiceAgentVoice" + :ivar output_audio_timestamp_types: Timestamp kinds to include with output audio. + :vartype output_audio_timestamp_types: list[Union[str, "VoiceAudioTimestampType"]] + :ivar speed: The speaking-speed multiplier. + :vartype speed: float + """ + + format: "VoiceAudioFormat" + """The output audio format.""" + voice: "_unions.VoiceAgentVoice" + """The typed voice configuration. Is one of the following types: OpenAIVoice, AzureVoice, + AzureRealtimeNativeVoice""" + output_audio_timestamp_types: list[Union[str, "VoiceAudioTimestampType"]] + """Timestamp kinds to include with output audio.""" + speed: Optional[float] + """The speaking-speed multiplier.""" + + +class VoiceAgentSessionUpdateConfig(TypedDict, total=False): + """The stable realtime session settings accepted in a ``session.update`` client event. + + :ivar type: The session type. Always ``realtime``. Required. Default value is "realtime". + :vartype type: Literal["realtime"] + :ivar instructions: Instructions applied throughout the session. + :vartype instructions: str + :ivar temperature: The sampling temperature for compatible cascaded pipelines. + :vartype temperature: float + :ivar max_output_tokens: The maximum output-token count for one response. Is either a int type + or a Literal["inf"] type. + :vartype max_output_tokens: "_unions.VoiceAgentMaxOutputTokens" + :ivar output_modalities: The output modalities enabled for the session. + :vartype output_modalities: list[Union[str, "VoiceOutputModality"]] + :ivar audio: The input- and output-audio settings for the session. + :vartype audio: "VoiceAgentSessionUpdateAudio" + :ivar avatar: The avatar settings for the session. + :vartype avatar: "VoiceAgentSessionAvatarConfig" + :ivar animation: Animation settings for the session. + :vartype animation: "VoiceAgentAnimationConfig" + :ivar tools: Tools available to the session. + :vartype tools: list["_unions.VoiceAgentSessionTool"] + :ivar tool_choice: Tool-selection behavior for the session. Is either a Union[str, + "_models.ToolChoiceOptions"] type or a RealtimeToolChoiceFunction type. + :vartype tool_choice: "_unions.VoiceAgentToolChoice" + :ivar reasoning: Reasoning settings for compatible realtime models. + :vartype reasoning: "RealtimeReasoning" + :ivar parallel_tool_calls: Whether the model may call multiple tools in parallel. + :vartype parallel_tool_calls: bool + :ivar include: Additional fields to include in service outputs. + :vartype include: list[Union[str, "VoiceAgentSessionIncludeOption"]] + :ivar metadata: Up to 16 string key-value pairs attached to the session. + :vartype metadata: dict[str, str] + :ivar voice_adaptation: Voice-optimized instruction adaptation settings. + :vartype voice_adaptation: "VoiceAgentVoiceAdaptation" + :ivar interim_response: Interim-response settings for latency and tool execution. Is either a + VoiceAgentStaticInterimResponseConfig type or a VoiceAgentLlmInterimResponseConfig type. + :vartype interim_response: "_unions.VoiceAgentInterimResponse" + :ivar response_delimiter: A delimiter appended to generated responses. + :vartype response_delimiter: str + :ivar greeting: A proactive assistant greeting started after session configuration. + :vartype greeting: "VoiceGreetingConfig" + :ivar handoff: The customer-supplied handoff graph. + :vartype handoff: "VoiceAgentHandoffGraphConfig" + """ + + type: Required[Literal["realtime"]] + """The session type. Always ``realtime``. Required. Default value is \"realtime\".""" + instructions: Optional[str] + """Instructions applied throughout the session.""" + temperature: Optional[float] + """The sampling temperature for compatible cascaded pipelines.""" + max_output_tokens: Optional["_unions.VoiceAgentMaxOutputTokens"] + """The maximum output-token count for one response. Is either a int type or a Literal[\"inf\"] + type.""" + output_modalities: Optional[list[Union[str, "VoiceOutputModality"]]] + """The output modalities enabled for the session.""" + audio: Optional["VoiceAgentSessionUpdateAudio"] + """The input- and output-audio settings for the session.""" + avatar: Optional["VoiceAgentSessionAvatarConfig"] + """The avatar settings for the session.""" + animation: Optional["VoiceAgentAnimationConfig"] + """Animation settings for the session.""" + tools: Optional[list["_unions.VoiceAgentSessionTool"]] + """Tools available to the session.""" + tool_choice: Optional["_unions.VoiceAgentToolChoice"] + """Tool-selection behavior for the session. Is either a Union[str, \"_models.ToolChoiceOptions\"] + type or a RealtimeToolChoiceFunction type.""" + reasoning: Optional["RealtimeReasoning"] + """Reasoning settings for compatible realtime models.""" + parallel_tool_calls: bool + """Whether the model may call multiple tools in parallel.""" + include: Optional[list[Union[str, "VoiceAgentSessionIncludeOption"]]] + """Additional fields to include in service outputs.""" + metadata: Optional[dict[str, str]] + """Up to 16 string key-value pairs attached to the session.""" + voice_adaptation: Optional["VoiceAgentVoiceAdaptation"] + """Voice-optimized instruction adaptation settings.""" + interim_response: Optional["_unions.VoiceAgentInterimResponse"] + """Interim-response settings for latency and tool execution. Is either a + VoiceAgentStaticInterimResponseConfig type or a VoiceAgentLlmInterimResponseConfig type.""" + response_delimiter: str + """A delimiter appended to generated responses.""" + greeting: Optional["VoiceGreetingConfig"] + """A proactive assistant greeting started after session configuration.""" + handoff: Optional["VoiceAgentHandoffGraphConfig"] + """The customer-supplied handoff graph.""" + + +class VoiceAgentStaticInterimResponseConfig(TypedDict, total=False): + """A static interim response selected from configured text. + + :ivar triggers: Conditions that may trigger one interim response. + :vartype triggers: list[Union[str, "VoiceAgentInterimResponseTrigger"]] + :ivar latency_threshold_ms: The latency threshold in milliseconds. + :vartype latency_threshold_ms: int + :ivar type: Required. Default value is "static_interim_response". + :vartype type: Literal["static_interim_response"] + :ivar texts: Candidate text values for the interim response. + :vartype texts: list[str] + """ + + triggers: list[Union[str, "VoiceAgentInterimResponseTrigger"]] + """Conditions that may trigger one interim response.""" + latency_threshold_ms: int + """The latency threshold in milliseconds.""" + type: Required[Literal["static_interim_response"]] + """Required. Default value is \"static_interim_response\".""" + texts: list[str] + """Candidate text values for the interim response.""" + + +class VoiceAgentTranscriptionPhrase(TypedDict, total=False): + """A transcribed phrase with timing information. + + :ivar offset_milliseconds: The phrase offset from the beginning of the audio, in milliseconds. + Required. + :vartype offset_milliseconds: int + :ivar duration_milliseconds: The phrase duration in milliseconds. Required. + :vartype duration_milliseconds: int + :ivar text: The transcribed phrase text. Required. + :vartype text: str + :ivar words: Word-level timing details, when available. + :vartype words: list["VoiceAgentTranscriptionWord"] + :ivar locale: The detected locale. + :vartype locale: str + :ivar confidence: The transcription confidence score. + :vartype confidence: float + """ + + offset_milliseconds: Required[int] + """The phrase offset from the beginning of the audio, in milliseconds. Required.""" + duration_milliseconds: Required[int] + """The phrase duration in milliseconds. Required.""" + text: Required[str] + """The transcribed phrase text. Required.""" + words: Optional[list["VoiceAgentTranscriptionWord"]] + """Word-level timing details, when available.""" + locale: Optional[str] + """The detected locale.""" + confidence: Optional[float] + """The transcription confidence score.""" + + +class VoiceAgentTranscriptionWord(TypedDict, total=False): + """A time-stamped word in an input-audio transcription. + + :ivar text: The transcribed word text. Required. + :vartype text: str + :ivar offset_milliseconds: The word offset from the beginning of the audio, in milliseconds. + Required. + :vartype offset_milliseconds: int + :ivar duration_milliseconds: The word duration in milliseconds. Required. + :vartype duration_milliseconds: int + """ + + text: Required[str] + """The transcribed word text. Required.""" + offset_milliseconds: Required[int] + """The word offset from the beginning of the audio, in milliseconds. Required.""" + duration_milliseconds: Required[int] + """The word duration in milliseconds. Required.""" + + +class VoiceAgentVoiceAdaptation(TypedDict, total=False): + """Voice-optimized instruction adaptation settings. + + :ivar type: The adaptation strategy. Always ``auto``. Required. Default value is "auto". + :vartype type: Literal["auto"] + """ + + type: Required[Literal["auto"]] + """The adaptation strategy. Always ``auto``. Required. Default value is \"auto\".""" + + +class VoiceAgentWebSearchActionFind(TypedDict, total=False): + """An action that finds text on a web page. + + :ivar type: Required. Default value is "find". + :vartype type: Literal["find"] + :ivar pattern: Required. + :vartype pattern: str + :ivar url: Required. + :vartype url: str + """ + + type: Required[Literal["find"]] + """Required. Default value is \"find\".""" + pattern: Required[str] + """Required.""" + url: Required[str] + """Required.""" + + +class VoiceAgentWebSearchActionOpenPage(TypedDict, total=False): + """An action that opens a web page. + + :ivar type: Required. Default value is "open_page". + :vartype type: Literal["open_page"] + :ivar url: Required. + :vartype url: str + """ + + type: Required[Literal["open_page"]] + """Required. Default value is \"open_page\".""" + url: Required[str] + """Required.""" + + +class VoiceAgentWebSearchActionSearch(TypedDict, total=False): + """A web search action. + + :ivar type: Required. Default value is "search". + :vartype type: Literal["search"] + :ivar query: Required. + :vartype query: str + :ivar sources: + :vartype sources: list["VoiceAgentWebSearchSource"] + """ + + type: Required[Literal["search"]] + """Required. Default value is \"search\".""" + query: Required[Optional[str]] + """Required.""" + sources: Optional[list["VoiceAgentWebSearchSource"]] + + +class VoiceAgentWebSearchCallItem(TypedDict, total=False): + """A web-search output item. + + :ivar id: Required. + :vartype id: str + :ivar type: Required. Default value is "web_search_call". + :vartype type: Literal["web_search_call"] + :ivar status: Required. Known values are: "in_progress", "searching", "completed", and + "failed". + :vartype status: Union[str, "VoiceAgentWebSearchCallStatus"] + :ivar action: Is one of the following types: VoiceAgentWebSearchActionSearch, + VoiceAgentWebSearchActionOpenPage, VoiceAgentWebSearchActionFind + :vartype action: "_unions.VoiceAgentWebSearchAction" + """ + + id: Required[str] + """Required.""" + type: Required[Literal["web_search_call"]] + """Required. Default value is \"web_search_call\".""" + status: Required[Union[str, "VoiceAgentWebSearchCallStatus"]] + """Required. Known values are: \"in_progress\", \"searching\", \"completed\", and \"failed\".""" + action: Optional["_unions.VoiceAgentWebSearchAction"] + """Is one of the following types: VoiceAgentWebSearchActionSearch, + VoiceAgentWebSearchActionOpenPage, VoiceAgentWebSearchActionFind""" + + +class VoiceAgentWebSearchSource(TypedDict, total=False): + """A web-search source URL. + + :ivar type: Required. Default value is "url". + :vartype type: Literal["url"] + :ivar url: Required. + :vartype url: str + """ + + type: Required[Literal["url"]] + """Required. Default value is \"url\".""" + url: Required[str] + """Required.""" + + +class VoiceAgentWorkflowActionItem(TypedDict, total=False): + """A workflow action output item. + + :ivar id: Required. + :vartype id: str + :ivar object: Default value is "realtime.item". + :vartype object: Literal["realtime.item"] + :ivar type: Required. Default value is "workflow_action". + :vartype type: Literal["workflow_action"] + :ivar action_id: Required. + :vartype action_id: str + :ivar status: Required. + :vartype status: str + :ivar kind: + :vartype kind: str + :ivar parent_action_id: + :vartype parent_action_id: str + :ivar previous_action_id: + :vartype previous_action_id: str + """ + + id: Required[Optional[str]] + """Required.""" + object: Literal["realtime.item"] + """Default value is \"realtime.item\".""" + type: Required[Literal["workflow_action"]] + """Required. Default value is \"workflow_action\".""" + action_id: Required[str] + """Required.""" + status: Required[str] + """Required.""" + kind: Optional[str] + parent_action_id: Optional[str] + previous_action_id: Optional[str] + + +class VoiceAssistantMessageItem(TypedDict, total=False): + """An assistant message item. Only ``output_text`` and ``output_audio`` content are valid for + assistant messages. + + :ivar created_at: The Unix timestamp (in seconds) for when the item was persisted. + :vartype created_at: int + :ivar response_id: The id of the response that produced this item, when applicable. + :vartype response_id: str + :ivar type: Required. A message item. + :vartype type: Literal[VoiceConversationItemType.MESSAGE] + :ivar id: The unique ID of the item. This may be provided by the client or generated by the + server. + :vartype id: str + :ivar object: Identifier for the API object being returned - always ``realtime.item``. Optional + when creating a new item. Default value is "realtime.item". + :vartype object: Literal["realtime.item"] + :ivar status: The status of the item. Has no effect on the conversation. Is one of the + following types: Literal["completed"], Literal["incomplete"], Literal["in_progress"] + :vartype status: Literal["completed", "incomplete", "in_progress"] + :ivar content: The content of the message. Required. + :vartype content: list["RealtimeConversationItemMessageAssistantContent"] + :ivar role: Required. ASSISTANT. + :vartype role: Literal[RealtimeConversationItemMessageType.ASSISTANT] + """ + + created_at: int + """The Unix timestamp (in seconds) for when the item was persisted.""" + response_id: str + """The id of the response that produced this item, when applicable.""" + type: Required[Literal[VoiceConversationItemType.MESSAGE]] + """Required. A message item.""" + id: str + """The unique ID of the item. This may be provided by the client or generated by the server.""" + object: Literal["realtime.item"] + """Identifier for the API object being returned - always ``realtime.item``. Optional when creating + a new item. Default value is \"realtime.item\".""" + status: Literal["completed", "incomplete", "in_progress"] + """The status of the item. Has no effect on the conversation. Is one of the following types: + Literal[\"completed\"], Literal[\"incomplete\"], Literal[\"in_progress\"]""" + content: Required[list["RealtimeConversationItemMessageAssistantContent"]] + """The content of the message. Required.""" + role: Required[Literal[RealtimeConversationItemMessageType.ASSISTANT]] + """Required. ASSISTANT.""" + + +class VoiceAudioConfig(TypedDict, total=False): + """The audio configuration for a voice agent. These values are session defaults and may be + overridden when connecting. + + :ivar input: Input (microphone) audio configuration. + :vartype input: "VoiceAudioInputConfig" + :ivar output: Output (agent speech) audio configuration. + :vartype output: "VoiceAudioOutputConfig" + """ + + input: "VoiceAudioInputConfig" + """Input (microphone) audio configuration.""" + output: "VoiceAudioOutputConfig" + """Output (agent speech) audio configuration.""" + + +class VoiceAudioFormat(TypedDict, total=False): + """An audio format. Follows the OpenAI Realtime session schema; ``type`` carries the media + subtype. + + :ivar type: The audio format type, e.g. 'audio/pcm' (16-bit PCM), 'audio/pcmu' (G.711 mu-law), + or 'audio/pcma' (G.711 A-law). Required. Known values are: "audio/pcm", "audio/pcmu", and + "audio/pcma". + :vartype type: Union[str, "VoiceAudioFormatType"] + :ivar rate: The sample rate in Hz. Applies to 'audio/pcm' (e.g. 24000); omit for telephony + G.711 formats (8 kHz). + :vartype rate: int + """ + + type: Required[Union[str, "VoiceAudioFormatType"]] + """The audio format type, e.g. 'audio/pcm' (16-bit PCM), 'audio/pcmu' (G.711 mu-law), or + 'audio/pcma' (G.711 A-law). Required. Known values are: \"audio/pcm\", \"audio/pcmu\", and + \"audio/pcma\".""" + rate: int + """The sample rate in Hz. Applies to 'audio/pcm' (e.g. 24000); omit for telephony G.711 formats (8 + kHz).""" + + +class VoiceAudioInputConfig(TypedDict, total=False): + """Input audio configuration for a voice agent. + + :ivar format: The input audio format. + :vartype format: "VoiceAudioFormat" + :ivar noise_reduction: Input noise reduction. Set to null to disable. + :vartype noise_reduction: "VoiceNoiseReduction" + :ivar turn_detection: Turn (end-of-speech) detection. Server-side turn detection is enabled by + default; set to null to disable it, in which case the client must trigger responses manually. + :vartype turn_detection: "VoiceTurnDetection" + :ivar transcription: Asynchronous input-audio transcription. Set to null to disable + transcription. + :vartype transcription: "VoiceInputTranscription" + """ + + format: "VoiceAudioFormat" + """The input audio format.""" + noise_reduction: Optional["VoiceNoiseReduction"] + """Input noise reduction. Set to null to disable.""" + turn_detection: Optional["VoiceTurnDetection"] + """Turn (end-of-speech) detection. Server-side turn detection is enabled by default; set to null + to disable it, in which case the client must trigger responses manually.""" + transcription: Optional["VoiceInputTranscription"] + """Asynchronous input-audio transcription. Set to null to disable transcription.""" + + +class VoiceAudioOutputConfig(TypedDict, total=False): + """Output audio configuration for a voice agent. + + :ivar format: The output audio format. + :vartype format: "VoiceAudioFormat" + :ivar voice: The typed voice configuration. Is one of the following types: OpenAIVoice, + AzureVoice, AzureRealtimeNativeVoice + :vartype voice: "_unions.VoiceAgentVoice" + :ivar speed: The OpenAI-compatible speaking speed multiplier, from 0.25 to 1.5. Defaults to 1. + For Azure synthesized voices, use ``voice.rate`` instead. + :vartype speed: float + :ivar output_audio_timestamp_types: Timestamp kinds to include with output audio. + :vartype output_audio_timestamp_types: list[Union[str, "VoiceAudioTimestampType"]] + """ + + format: "VoiceAudioFormat" + """The output audio format.""" + voice: "_unions.VoiceAgentVoice" + """The typed voice configuration. Is one of the following types: OpenAIVoice, AzureVoice, + AzureRealtimeNativeVoice""" + speed: float + """The OpenAI-compatible speaking speed multiplier, from 0.25 to 1.5. Defaults to 1. For Azure + synthesized voices, use ``voice.rate`` instead.""" + output_audio_timestamp_types: list[Union[str, "VoiceAudioTimestampType"]] + """Timestamp kinds to include with output audio.""" + + +class VoiceAvatarConfig(TypedDict, total=False): + """Avatar configuration for a voice agent. These values are session defaults and may be overridden + when connecting. + + :ivar type: The avatar type. Required. Known values are: "video_avatar" and "photo_avatar". + :vartype type: Union[str, "VoiceAvatarType"] + :ivar character: The avatar character identifier, e.g. 'lisa'. Required. + :vartype character: str + :ivar style: The avatar style, e.g. 'casual-sitting'. + :vartype style: str + :ivar customized: Whether the avatar is a customer-customized avatar. Defaults to false. + :vartype customized: bool + :ivar output_protocol: The transport used to deliver the avatar video stream. Known values are: + "webrtc" and "websocket". + :vartype output_protocol: Union[str, "VoiceAvatarOutputProtocol"] + """ + + type: Required[Union[str, "VoiceAvatarType"]] + """The avatar type. Required. Known values are: \"video_avatar\" and \"photo_avatar\".""" + character: Required[str] + """The avatar character identifier, e.g. 'lisa'. Required.""" + style: str + """The avatar style, e.g. 'casual-sitting'.""" + customized: bool + """Whether the avatar is a customer-customized avatar. Defaults to false.""" + output_protocol: Union[str, "VoiceAvatarOutputProtocol"] + """The transport used to deliver the avatar video stream. Known values are: \"webrtc\" and + \"websocket\".""" + + +class VoiceAzureSemanticDetection(TypedDict, total=False): + """Default Azure semantic end-of-utterance detection. + + :ivar model: Required. The default semantic detection model. + :vartype model: Literal[VoiceEndOfUtteranceDetectionModel.SEMANTIC_DETECTION_V1] + :ivar threshold_level: The sensitivity threshold. Known values are: "low", "medium", "high", + and "default". + :vartype threshold_level: Union[str, "VoiceEndOfUtteranceThresholdLevel"] + :ivar timeout_ms: The detection timeout in milliseconds. + :vartype timeout_ms: int + """ + + model: Required[Literal[VoiceEndOfUtteranceDetectionModel.SEMANTIC_DETECTION_V1]] + """Required. The default semantic detection model.""" + threshold_level: Union[str, "VoiceEndOfUtteranceThresholdLevel"] + """The sensitivity threshold. Known values are: \"low\", \"medium\", \"high\", and \"default\".""" + timeout_ms: int + """The detection timeout in milliseconds.""" + + +class VoiceAzureSemanticDetectionEn(TypedDict, total=False): + """English-optimized Azure semantic end-of-utterance detection. + + :ivar model: Required. The English-optimized semantic detection model. + :vartype model: Literal[VoiceEndOfUtteranceDetectionModel.SEMANTIC_DETECTION_V1_EN] + :ivar threshold_level: The sensitivity threshold. Known values are: "low", "medium", "high", + and "default". + :vartype threshold_level: Union[str, "VoiceEndOfUtteranceThresholdLevel"] + :ivar timeout_ms: The detection timeout in milliseconds. + :vartype timeout_ms: int + """ + + model: Required[Literal[VoiceEndOfUtteranceDetectionModel.SEMANTIC_DETECTION_V1_EN]] + """Required. The English-optimized semantic detection model.""" + threshold_level: Union[str, "VoiceEndOfUtteranceThresholdLevel"] + """The sensitivity threshold. Known values are: \"low\", \"medium\", \"high\", and \"default\".""" + timeout_ms: int + """The detection timeout in milliseconds.""" + + +class VoiceAzureSemanticDetectionMultilingual(TypedDict, total=False): + """Multilingual Azure semantic end-of-utterance detection. + + :ivar model: Required. The multilingual semantic detection model. + :vartype model: Literal[VoiceEndOfUtteranceDetectionModel.SEMANTIC_DETECTION_V1_MULTILINGUAL] + :ivar threshold_level: The sensitivity threshold. Known values are: "low", "medium", "high", + and "default". + :vartype threshold_level: Union[str, "VoiceEndOfUtteranceThresholdLevel"] + :ivar timeout_ms: The detection timeout in milliseconds. + :vartype timeout_ms: int + """ + + model: Required[Literal[VoiceEndOfUtteranceDetectionModel.SEMANTIC_DETECTION_V1_MULTILINGUAL]] + """Required. The multilingual semantic detection model.""" + threshold_level: Union[str, "VoiceEndOfUtteranceThresholdLevel"] + """The sensitivity threshold. Known values are: \"low\", \"medium\", \"high\", and \"default\".""" + timeout_ms: int + """The detection timeout in milliseconds.""" + + +class VoiceAzureSemanticVadEnTurnDetection(TypedDict, total=False): + """English-optimized Azure semantic voice activity detection. + + :ivar type: Required. English-optimized Azure semantic voice activity detection. + :vartype type: Literal[VoiceTurnDetectionType.AZURE_SEMANTIC_VAD_EN] + :ivar threshold: Activation threshold for voice activity detection, from 0 to 1. + :vartype threshold: float + :ivar prefix_padding_ms: Audio to include before detected speech, in milliseconds. + :vartype prefix_padding_ms: int + :ivar silence_duration_ms: Silence required to end speech detection, in milliseconds. + :vartype silence_duration_ms: int + :ivar end_of_utterance_detection: Semantic end-of-utterance detection configuration. + :vartype end_of_utterance_detection: "VoiceEndOfUtteranceDetection" + :ivar speech_duration_ms: Minimum speech duration required to trigger detection, in + milliseconds. + :vartype speech_duration_ms: int + :ivar remove_filler_words: Whether filler words are removed from transcription. + :vartype remove_filler_words: bool + :ivar auto_truncate: Whether the input audio buffer is truncated automatically when speech + stops. + :vartype auto_truncate: bool + :ivar create_response: Whether a response is created automatically when speech stops. + :vartype create_response: bool + :ivar interrupt_response: Whether user speech may interrupt the agent's response. + :vartype interrupt_response: bool + """ + + type: Required[Literal[VoiceTurnDetectionType.AZURE_SEMANTIC_VAD_EN]] + """Required. English-optimized Azure semantic voice activity detection.""" + threshold: float + """Activation threshold for voice activity detection, from 0 to 1.""" + prefix_padding_ms: int + """Audio to include before detected speech, in milliseconds.""" + silence_duration_ms: int + """Silence required to end speech detection, in milliseconds.""" + end_of_utterance_detection: "VoiceEndOfUtteranceDetection" + """Semantic end-of-utterance detection configuration.""" + speech_duration_ms: int + """Minimum speech duration required to trigger detection, in milliseconds.""" + remove_filler_words: bool + """Whether filler words are removed from transcription.""" + auto_truncate: bool + """Whether the input audio buffer is truncated automatically when speech stops.""" + create_response: bool + """Whether a response is created automatically when speech stops.""" + interrupt_response: bool + """Whether user speech may interrupt the agent's response.""" + + +class VoiceAzureSemanticVadMultilingualTurnDetection(TypedDict, total=False): # pylint: disable=name-too-long + """Multilingual Azure semantic voice activity detection. + + :ivar type: Required. Multilingual Azure semantic voice activity detection. + :vartype type: Literal[VoiceTurnDetectionType.AZURE_SEMANTIC_VAD_MULTILINGUAL] + :ivar threshold: Activation threshold for voice activity detection, from 0 to 1. + :vartype threshold: float + :ivar prefix_padding_ms: Audio to include before detected speech, in milliseconds. + :vartype prefix_padding_ms: int + :ivar silence_duration_ms: Silence required to end speech detection, in milliseconds. + :vartype silence_duration_ms: int + :ivar end_of_utterance_detection: Semantic end-of-utterance detection configuration. + :vartype end_of_utterance_detection: "VoiceEndOfUtteranceDetection" + :ivar speech_duration_ms: Minimum speech duration required to trigger detection, in + milliseconds. + :vartype speech_duration_ms: int + :ivar remove_filler_words: Whether filler words are removed from transcription. + :vartype remove_filler_words: bool + :ivar auto_truncate: Whether the input audio buffer is truncated automatically when speech + stops. + :vartype auto_truncate: bool + :ivar create_response: Whether a response is created automatically when speech stops. + :vartype create_response: bool + :ivar interrupt_response: Whether user speech may interrupt the agent's response. + :vartype interrupt_response: bool + :ivar languages: BCP-47 language codes used for speech detection. + :vartype languages: list[str] + """ + + type: Required[Literal[VoiceTurnDetectionType.AZURE_SEMANTIC_VAD_MULTILINGUAL]] + """Required. Multilingual Azure semantic voice activity detection.""" + threshold: float + """Activation threshold for voice activity detection, from 0 to 1.""" + prefix_padding_ms: int + """Audio to include before detected speech, in milliseconds.""" + silence_duration_ms: int + """Silence required to end speech detection, in milliseconds.""" + end_of_utterance_detection: "VoiceEndOfUtteranceDetection" + """Semantic end-of-utterance detection configuration.""" + speech_duration_ms: int + """Minimum speech duration required to trigger detection, in milliseconds.""" + remove_filler_words: bool + """Whether filler words are removed from transcription.""" + auto_truncate: bool + """Whether the input audio buffer is truncated automatically when speech stops.""" + create_response: bool + """Whether a response is created automatically when speech stops.""" + interrupt_response: bool + """Whether user speech may interrupt the agent's response.""" + languages: list[str] + """BCP-47 language codes used for speech detection.""" + + +class VoiceAzureSemanticVadTurnDetection(TypedDict, total=False): + """Azure semantic voice activity detection. + + :ivar type: Required. Azure semantic voice activity detection. + :vartype type: Literal[VoiceTurnDetectionType.AZURE_SEMANTIC_VAD] + :ivar threshold: Activation threshold for voice activity detection, from 0 to 1. + :vartype threshold: float + :ivar prefix_padding_ms: Audio to include before detected speech, in milliseconds. + :vartype prefix_padding_ms: int + :ivar silence_duration_ms: Silence required to end speech detection, in milliseconds. + :vartype silence_duration_ms: int + :ivar end_of_utterance_detection: Semantic end-of-utterance detection configuration. + :vartype end_of_utterance_detection: "VoiceEndOfUtteranceDetection" + :ivar speech_duration_ms: Minimum speech duration required to trigger detection, in + milliseconds. + :vartype speech_duration_ms: int + :ivar remove_filler_words: Whether filler words are removed from transcription. + :vartype remove_filler_words: bool + :ivar auto_truncate: Whether the input audio buffer is truncated automatically when speech + stops. + :vartype auto_truncate: bool + :ivar create_response: Whether a response is created automatically when speech stops. + :vartype create_response: bool + :ivar interrupt_response: Whether user speech may interrupt the agent's response. + :vartype interrupt_response: bool + :ivar languages: BCP-47 language codes used for speech detection. + :vartype languages: list[str] + """ + + type: Required[Literal[VoiceTurnDetectionType.AZURE_SEMANTIC_VAD]] + """Required. Azure semantic voice activity detection.""" + threshold: float + """Activation threshold for voice activity detection, from 0 to 1.""" + prefix_padding_ms: int + """Audio to include before detected speech, in milliseconds.""" + silence_duration_ms: int + """Silence required to end speech detection, in milliseconds.""" + end_of_utterance_detection: "VoiceEndOfUtteranceDetection" + """Semantic end-of-utterance detection configuration.""" + speech_duration_ms: int + """Minimum speech duration required to trigger detection, in milliseconds.""" + remove_filler_words: bool + """Whether filler words are removed from transcription.""" + auto_truncate: bool + """Whether the input audio buffer is truncated automatically when speech stops.""" + create_response: bool + """Whether a response is created automatically when speech stops.""" + interrupt_response: bool + """Whether user speech may interrupt the agent's response.""" + languages: list[str] + """BCP-47 language codes used for speech detection.""" + + +class VoiceFunctionCallItem(TypedDict, total=False): + """A function call request item. + + :ivar created_at: The Unix timestamp (in seconds) for when the item was persisted. + :vartype created_at: int + :ivar response_id: The id of the response that produced this item, when applicable. + :vartype response_id: str + :ivar id: The unique ID of the item. This may be provided by the client or generated by the + server. + :vartype id: str + :ivar object: Identifier for the API object being returned - always ``realtime.item``. Optional + when creating a new item. Default value is "realtime.item". + :vartype object: Literal["realtime.item"] + :ivar status: The status of the item. Has no effect on the conversation. Is one of the + following types: Literal["completed"], Literal["incomplete"], Literal["in_progress"] + :vartype status: Literal["completed", "incomplete", "in_progress"] + :ivar call_id: The ID of the function call. + :vartype call_id: str + :ivar name: The name of the function being called. Required. + :vartype name: str + :ivar arguments: The arguments of the function call. This is a JSON-encoded string representing + the arguments passed to the function, for example ``{"arg1": "value1", "arg2": 42}``. Required. + :vartype arguments: str + :ivar type: Required. A function-call request item. + :vartype type: Literal[VoiceConversationItemType.FUNCTION_CALL] + """ + + created_at: int + """The Unix timestamp (in seconds) for when the item was persisted.""" + response_id: str + """The id of the response that produced this item, when applicable.""" + id: str + """The unique ID of the item. This may be provided by the client or generated by the server.""" + object: Literal["realtime.item"] + """Identifier for the API object being returned - always ``realtime.item``. Optional when creating + a new item. Default value is \"realtime.item\".""" + status: Literal["completed", "incomplete", "in_progress"] + """The status of the item. Has no effect on the conversation. Is one of the following types: + Literal[\"completed\"], Literal[\"incomplete\"], Literal[\"in_progress\"]""" + call_id: str + """The ID of the function call.""" + name: Required[str] + """The name of the function being called. Required.""" + arguments: Required[str] + """The arguments of the function call. This is a JSON-encoded string representing the arguments + passed to the function, for example ``{\"arg1\": \"value1\", \"arg2\": 42}``. Required.""" + type: Required[Literal[VoiceConversationItemType.FUNCTION_CALL]] + """Required. A function-call request item.""" + + +class VoiceFunctionCallOutputItem(TypedDict, total=False): + """A function call output item. + + :ivar created_at: The Unix timestamp (in seconds) for when the item was persisted. + :vartype created_at: int + :ivar response_id: The id of the response that produced this item, when applicable. + :vartype response_id: str + :ivar id: The unique ID of the item. This may be provided by the client or generated by the + server. + :vartype id: str + :ivar object: Identifier for the API object being returned - always ``realtime.item``. Optional + when creating a new item. Default value is "realtime.item". + :vartype object: Literal["realtime.item"] + :ivar status: The status of the item. Has no effect on the conversation. Is one of the + following types: Literal["completed"], Literal["incomplete"], Literal["in_progress"] + :vartype status: Literal["completed", "incomplete", "in_progress"] + :ivar call_id: The ID of the function call this output is for. Required. + :vartype call_id: str + :ivar output: The output of the function call, this is free text and can contain any + information or simply be empty. Required. + :vartype output: str + :ivar type: Required. A function-call output item. + :vartype type: Literal[VoiceConversationItemType.FUNCTION_CALL_OUTPUT] + :ivar name: The name of the function that was called. A Foundry extension: OpenAI's + function_call_output does not carry the function name, only ``call_id``. + :vartype name: str + """ + + created_at: int + """The Unix timestamp (in seconds) for when the item was persisted.""" + response_id: str + """The id of the response that produced this item, when applicable.""" + id: str + """The unique ID of the item. This may be provided by the client or generated by the server.""" + object: Literal["realtime.item"] + """Identifier for the API object being returned - always ``realtime.item``. Optional when creating + a new item. Default value is \"realtime.item\".""" + status: Literal["completed", "incomplete", "in_progress"] + """The status of the item. Has no effect on the conversation. Is one of the following types: + Literal[\"completed\"], Literal[\"incomplete\"], Literal[\"in_progress\"]""" + call_id: Required[str] + """The ID of the function call this output is for. Required.""" + output: Required[str] + """The output of the function call, this is free text and can contain any information or simply be + empty. Required.""" + type: Required[Literal[VoiceConversationItemType.FUNCTION_CALL_OUTPUT]] + """Required. A function-call output item.""" + name: str + """The name of the function that was called. A Foundry extension: OpenAI's function_call_output + does not carry the function name, only ``call_id``.""" + + +class VoiceInputTranscription(TypedDict, total=False): + """Asynchronous input-audio transcription configuration. Extends the OpenAI Realtime transcription + options with the Azure and MAI transcription models, custom speech models, and phrase hints. + + :ivar language: The language of the input audio. Supplying the input language in `ISO-639-1 + `_ (e.g. ``en``) format will improve + accuracy and latency. + :vartype language: str + :ivar prompt: An optional text to guide the model's style or continue a previous audio segment. + For ``whisper-1``, the `prompt is a list of keywords `_. + For ``gpt-4o-transcribe`` models (excluding ``gpt-4o-transcribe-diarize``), the prompt is a + free text string, for example "expect words related to technology". Prompt is not supported + with ``gpt-realtime-whisper`` in GA Realtime sessions. + :vartype prompt: str + :ivar delay: Controls how long the model waits before emitting transcription text. Higher + values can improve transcription accuracy at the cost of latency. Only supported with + ``gpt-realtime-whisper`` in GA Realtime sessions. Is one of the following types: + Literal["minimal"], Literal["low"], Literal["medium"], Literal["high"], Literal["xhigh"] + :vartype delay: Literal["minimal", "low", "medium", "high", "xhigh"] + :ivar model: The transcription model to use. Required. Known values are: "whisper-1", + "gpt-realtime-whisper", "gpt-4o-transcribe", "gpt-4o-mini-transcribe", + "gpt-4o-transcribe-diarize", "gpt-transcribe", "gpt-live-transcribe", "mai-transcribe", and + "azure-speech". + :vartype model: Union[str, "VoiceInputTranscriptionModel"] + :ivar custom_speech: Optional custom speech model configuration, keyed by locale. + :vartype custom_speech: dict[str, str] + :ivar phrase_list: Optional phrase hints that bias recognition toward domain terms. + :vartype phrase_list: list[str] + """ + + language: str + """The language of the input audio. Supplying the input language in `ISO-639-1 + `_ (e.g. ``en``) format will improve + accuracy and latency.""" + prompt: str + """An optional text to guide the model's style or continue a previous audio segment. For + ``whisper-1``, the `prompt is a list of keywords `_. For + ``gpt-4o-transcribe`` models (excluding ``gpt-4o-transcribe-diarize``), the prompt is a free + text string, for example \"expect words related to technology\". Prompt is not supported with + ``gpt-realtime-whisper`` in GA Realtime sessions.""" + delay: Literal["minimal", "low", "medium", "high", "xhigh"] + """Controls how long the model waits before emitting transcription text. Higher values can improve + transcription accuracy at the cost of latency. Only supported with ``gpt-realtime-whisper`` in + GA Realtime sessions. Is one of the following types: Literal[\"minimal\"], Literal[\"low\"], + Literal[\"medium\"], Literal[\"high\"], Literal[\"xhigh\"]""" + model: Required[Union[str, "VoiceInputTranscriptionModel"]] + """The transcription model to use. Required. Known values are: \"whisper-1\", + \"gpt-realtime-whisper\", \"gpt-4o-transcribe\", \"gpt-4o-mini-transcribe\", + \"gpt-4o-transcribe-diarize\", \"gpt-transcribe\", \"gpt-live-transcribe\", \"mai-transcribe\", + and \"azure-speech\".""" + custom_speech: dict[str, str] + """Optional custom speech model configuration, keyed by locale.""" + phrase_list: list[str] + """Optional phrase hints that bias recognition toward domain terms.""" + + +class VoiceMcpApprovalRequestItem(TypedDict, total=False): + """An MCP approval request item. + + :ivar created_at: The Unix timestamp (in seconds) for when the item was persisted. + :vartype created_at: int + :ivar response_id: The id of the response that produced this item, when applicable. + :vartype response_id: str + :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 + :ivar type: Required. An MCP approval request item. + :vartype type: Literal[VoiceConversationItemType.MCP_APPROVAL_REQUEST] + """ + + created_at: int + """The Unix timestamp (in seconds) for when the item was persisted.""" + response_id: str + """The id of the response that produced this item, when applicable.""" + 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.""" + type: Required[Literal[VoiceConversationItemType.MCP_APPROVAL_REQUEST]] + """Required. An MCP approval request item.""" + + +class VoiceMcpApprovalResponseItem(TypedDict, total=False): + """An MCP approval response item (client-created). + + :ivar created_at: The Unix timestamp (in seconds) for when the item was persisted. + :vartype created_at: int + :ivar response_id: The id of the response that produced this item, when applicable. + :vartype response_id: str + :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 + :ivar type: Required. An MCP approval response item. + :vartype type: Literal[VoiceConversationItemType.MCP_APPROVAL_RESPONSE] + """ + + created_at: int + """The Unix timestamp (in seconds) for when the item was persisted.""" + response_id: str + """The id of the response that produced this item, when applicable.""" + 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] + type: Required[Literal[VoiceConversationItemType.MCP_APPROVAL_RESPONSE]] + """Required. An MCP approval response item.""" + + +class VoiceMcpCallItem(TypedDict, total=False): + """An MCP call item. + + :ivar created_at: The Unix timestamp (in seconds) for when the item was persisted. + :vartype created_at: int + :ivar response_id: The id of the response that produced this item, when applicable. + :vartype response_id: str + :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 approval_request_id: + :vartype approval_request_id: str + :ivar output: + :vartype output: str + :ivar error: + :vartype error: "RealtimeMCPError" + :ivar type: Required. An MCP call item. + :vartype type: Literal[VoiceConversationItemType.MCP_CALL] + """ + + created_at: int + """The Unix timestamp (in seconds) for when the item was persisted.""" + response_id: str + """The id of the response that produced this item, when applicable.""" + 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.""" + approval_request_id: Optional[str] + output: Optional[str] + error: "RealtimeMCPError" + type: Required[Literal[VoiceConversationItemType.MCP_CALL]] + """Required. An MCP call item.""" + + +class VoiceMcpListToolsItem(TypedDict, total=False): + """An MCP list-tools item. + + :ivar created_at: The Unix timestamp (in seconds) for when the item was persisted. + :vartype created_at: int + :ivar response_id: The id of the response that produced this item, when applicable. + :vartype response_id: str + :ivar id: The unique ID of the list. + :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["MCPListToolsTool"] + :ivar type: Required. An MCP list-tools item. + :vartype type: Literal[VoiceConversationItemType.MCP_LIST_TOOLS] + """ + + created_at: int + """The Unix timestamp (in seconds) for when the item was persisted.""" + response_id: str + """The id of the response that produced this item, when applicable.""" + id: str + """The unique ID of the list.""" + server_label: Required[str] + """The label of the MCP server. Required.""" + tools: Required[list["MCPListToolsTool"]] + """The tools available on the server. Required.""" + type: Required[Literal[VoiceConversationItemType.MCP_LIST_TOOLS]] + """Required. An MCP list-tools item.""" + + +class VoiceNoiseReduction(TypedDict, total=False): + """Input audio noise reduction configuration. + + :ivar type: The noise reduction mode. Required. Known values are: "near_field", "far_field", + and "azure_deep_noise_suppression". + :vartype type: Union[str, "VoiceNoiseReductionType"] + """ + + type: Required[Union[str, "VoiceNoiseReductionType"]] + """The noise reduction mode. Required. Known values are: \"near_field\", \"far_field\", and + \"azure_deep_noise_suppression\".""" + + +class VoiceSemanticVadTurnDetection(TypedDict, total=False): + """Semantic voice activity detection. + + :ivar eagerness: Is one of the following types: Literal["low"], Literal["medium"], + Literal["high"], Literal["auto"] + :vartype eagerness: Literal["low", "medium", "high", "auto"] + :ivar create_response: + :vartype create_response: bool + :ivar interrupt_response: + :vartype interrupt_response: bool + :ivar type: Required. Semantic voice activity detection. + :vartype type: Literal[VoiceTurnDetectionType.SEMANTIC_VAD] + """ + + eagerness: Literal["low", "medium", "high", "auto"] + """Is one of the following types: Literal[\"low\"], Literal[\"medium\"], Literal[\"high\"], + Literal[\"auto\"]""" + create_response: bool + interrupt_response: bool + type: Required[Literal[VoiceTurnDetectionType.SEMANTIC_VAD]] + """Required. Semantic voice activity detection.""" + + +class VoiceServerVadTurnDetection(TypedDict, total=False): + """Server-side voice activity detection. + + :ivar threshold: + :vartype threshold: float + :ivar prefix_padding_ms: + :vartype prefix_padding_ms: int + :ivar silence_duration_ms: + :vartype silence_duration_ms: int + :ivar create_response: + :vartype create_response: bool + :ivar interrupt_response: + :vartype interrupt_response: bool + :ivar idle_timeout_ms: + :vartype idle_timeout_ms: int + :ivar type: Required. Server-side voice activity detection. + :vartype type: Literal[VoiceTurnDetectionType.SERVER_VAD] + """ + + threshold: float + prefix_padding_ms: int + silence_duration_ms: int + create_response: bool + interrupt_response: bool + idle_timeout_ms: Optional[int] + type: Required[Literal[VoiceTurnDetectionType.SERVER_VAD]] + """Required. Server-side voice activity detection.""" + + +class VoiceSystemMessageItem(TypedDict, total=False): + """A system message item. Only ``input_text`` content is valid for system messages. + + :ivar created_at: The Unix timestamp (in seconds) for when the item was persisted. + :vartype created_at: int + :ivar response_id: The id of the response that produced this item, when applicable. + :vartype response_id: str + :ivar type: Required. A message item. + :vartype type: Literal[VoiceConversationItemType.MESSAGE] + :ivar id: The unique ID of the item. This may be provided by the client or generated by the + server. + :vartype id: str + :ivar object: Identifier for the API object being returned - always ``realtime.item``. Optional + when creating a new item. Default value is "realtime.item". + :vartype object: Literal["realtime.item"] + :ivar status: The status of the item. Has no effect on the conversation. Is one of the + following types: Literal["completed"], Literal["incomplete"], Literal["in_progress"] + :vartype status: Literal["completed", "incomplete", "in_progress"] + :ivar content: The content of the message. Required. + :vartype content: list["RealtimeConversationItemMessageSystemContent"] + :ivar role: Required. SYSTEM. + :vartype role: Literal[RealtimeConversationItemMessageType.SYSTEM] + """ + + created_at: int + """The Unix timestamp (in seconds) for when the item was persisted.""" + response_id: str + """The id of the response that produced this item, when applicable.""" + type: Required[Literal[VoiceConversationItemType.MESSAGE]] + """Required. A message item.""" + id: str + """The unique ID of the item. This may be provided by the client or generated by the server.""" + object: Literal["realtime.item"] + """Identifier for the API object being returned - always ``realtime.item``. Optional when creating + a new item. Default value is \"realtime.item\".""" + status: Literal["completed", "incomplete", "in_progress"] + """The status of the item. Has no effect on the conversation. Is one of the following types: + Literal[\"completed\"], Literal[\"incomplete\"], Literal[\"in_progress\"]""" + content: Required[list["RealtimeConversationItemMessageSystemContent"]] + """The content of the message. Required.""" + role: Required[Literal[RealtimeConversationItemMessageType.SYSTEM]] + """Required. SYSTEM.""" + + +class VoiceSystemTool(TypedDict, total=False): + """A service-managed control that acts on the active voice session without customer code or + external authentication. + + :ivar type: The type of the tool. Always ``system``. Required. Default value is "system". + :vartype type: Literal["system"] + :ivar name: The service-managed control action. Known values are stable; additional values may + be added over time. Required. "end_conversation" + :vartype name: Union[str, "VoiceSystemToolName"] + :ivar description: An optional description of the system tool. + :vartype description: str + """ + + type: Required[Literal["system"]] + """The type of the tool. Always ``system``. Required. Default value is \"system\".""" + name: Required[Union[str, "VoiceSystemToolName"]] + """The service-managed control action. Known values are stable; additional values may be added + over time. Required. \"end_conversation\"""" + description: str + """An optional description of the system tool.""" + + +class VoiceToolboxTool(TypedDict, total=False): + """A reference to a Foundry toolbox, which is a versioned bundle of tools executed through its MCP + endpoint. + + :ivar type: The type of the tool. Always ``toolbox``. Required. Default value is "toolbox". + :vartype type: Literal["toolbox"] + :ivar toolbox_name: The name of the toolbox to attach. Required. + :vartype toolbox_name: str + :ivar toolbox_version: The immutable version of the toolbox to attach. Required. + :vartype toolbox_version: str + """ + + type: Required[Literal["toolbox"]] + """The type of the tool. Always ``toolbox``. Required. Default value is \"toolbox\".""" + toolbox_name: Required[str] + """The name of the toolbox to attach. Required.""" + toolbox_version: Required[str] + """The immutable version of the toolbox to attach. Required.""" + + +class VoiceUserMessageItem(TypedDict, total=False): + """A user message item. ``input_text``, ``input_audio``, and ``input_image`` content are valid for + user messages. + + :ivar created_at: The Unix timestamp (in seconds) for when the item was persisted. + :vartype created_at: int + :ivar response_id: The id of the response that produced this item, when applicable. + :vartype response_id: str + :ivar type: Required. A message item. + :vartype type: Literal[VoiceConversationItemType.MESSAGE] + :ivar id: The unique ID of the item. This may be provided by the client or generated by the + server. + :vartype id: str + :ivar object: Identifier for the API object being returned - always ``realtime.item``. Optional + when creating a new item. Default value is "realtime.item". + :vartype object: Literal["realtime.item"] + :ivar status: The status of the item. Has no effect on the conversation. Is one of the + following types: Literal["completed"], Literal["incomplete"], Literal["in_progress"] + :vartype status: Literal["completed", "incomplete", "in_progress"] + :ivar content: The content of the message. Required. + :vartype content: list["RealtimeConversationItemMessageUserContent"] + :ivar role: Required. USER. + :vartype role: Literal[RealtimeConversationItemMessageType.USER] + """ + + created_at: int + """The Unix timestamp (in seconds) for when the item was persisted.""" + response_id: str + """The id of the response that produced this item, when applicable.""" + type: Required[Literal[VoiceConversationItemType.MESSAGE]] + """Required. A message item.""" + id: str + """The unique ID of the item. This may be provided by the client or generated by the server.""" + object: Literal["realtime.item"] + """Identifier for the API object being returned - always ``realtime.item``. Optional when creating + a new item. Default value is \"realtime.item\".""" + status: Literal["completed", "incomplete", "in_progress"] + """The status of the item. Has no effect on the conversation. Is one of the following types: + Literal[\"completed\"], Literal[\"incomplete\"], Literal[\"in_progress\"]""" + content: Required[list["RealtimeConversationItemMessageUserContent"]] + """The content of the message. Required.""" + role: Required[Literal[RealtimeConversationItemMessageType.USER]] + """Required. USER.""" + + +class CreateVoiceAgentRequest(TypedDict, total=False): + """CreateVoiceAgentRequest. + + :ivar 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. + :vartype name: str + :ivar state: The initial operational state of the agent. Defaults to 'enabled' if not + specified. Known values are: "enabled" and "disabled". + :vartype state: Union[str, "AgentState"] + :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. + :vartype metadata: dict[str, str] + :ivar description: A human-readable description of the agent. + :vartype description: str + :ivar blueprint_reference: The blueprint reference for the agent. + :vartype blueprint_reference: "AgentBlueprintReference" + :ivar draft: (Preview) Whether this agent version is a draft (candidate) rather than a release. + The service defaults to ``false`` if a value is not specified by the caller. Draft versions are + recorded but excluded from default 'latest' resolution and are not auto-promoted. + :vartype draft: bool + :ivar definition: The voice agent definition. Required. + :vartype definition: "VoiceAgentDefinition" + :ivar agent_endpoint: An optional endpoint configuration. If not specified, a default endpoint + configuration will be set for the agent. + :vartype agent_endpoint: "AgentEndpointConfig" + :ivar agent_card: Optional agent card for the agent. + :vartype agent_card: "AgentCard" + """ + + name: Required[str] + """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.""" + state: Union[str, "AgentState"] + """The initial operational state of the agent. Defaults to 'enabled' if not specified. Known + values are: \"enabled\" and \"disabled\".""" + metadata: 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.""" + description: str + """A human-readable description of the agent.""" + blueprint_reference: "AgentBlueprintReference" + """The blueprint reference for the agent.""" + draft: bool + """(Preview) Whether this agent version is a draft (candidate) rather than a release. The service + defaults to ``false`` if a value is not specified by the caller. Draft versions are recorded + but excluded from default 'latest' resolution and are not auto-promoted.""" + definition: Required["VoiceAgentDefinition"] + """The voice agent definition. Required.""" + agent_endpoint: "AgentEndpointConfig" + """An optional endpoint configuration. If not specified, a default endpoint configuration will be + set for the agent.""" + agent_card: "AgentCard" + """Optional agent card for the agent.""" + + +class UpdateVoiceAgentRequest(TypedDict, total=False): + """UpdateVoiceAgentRequest. + + :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. + :vartype metadata: dict[str, str] + :ivar description: A human-readable description of the agent. + :vartype description: str + :ivar blueprint_reference: The blueprint reference for the agent. + :vartype blueprint_reference: "AgentBlueprintReference" + :ivar definition: The voice agent definition. Required. + :vartype definition: "VoiceAgentDefinition" + """ + + metadata: 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.""" + description: str + """A human-readable description of the agent.""" + blueprint_reference: "AgentBlueprintReference" + """The blueprint reference for the agent.""" + definition: Required["VoiceAgentDefinition"] + """The voice agent definition. Required.""" + + +class GenerateVoiceAgentRequest(TypedDict, total=False): + """GenerateVoiceAgentRequest. + + :ivar name: The unique name for the agent to create. Required. + :vartype name: str + :ivar model_type: How the model backing the generated agent is served: ``managed`` + (service-managed) or ``self_deployed`` (the customer's own deployment). Carried through to the + generated definition, not generated. Required. Known values are: "managed" and "self_deployed". + :vartype model_type: Union[str, "VoiceModelType"] + :ivar model: The model paired with ``model_type``: the service-managed model name when + ``managed``, or the customer's Foundry deployment name when ``self_deployed``. Carried through, + not generated. Required. + :vartype model: str + :ivar agent_type: The persona/tone to steer generation. Required. Known values are: "personal" + and "business". + :vartype agent_type: Union[str, "VoiceAgentType"] + :ivar use_case: The scenario-template catalog entry the generator specializes for. Required. + Known values are: "customer_support", "reception", "sales", "travel_assistant", "outreach", + "personal_assistant", "learning", "call_center", and "in_car". + :vartype use_case: Union[str, "VoiceAgentUseCase"] + :ivar goal: A natural-language description of what the agent should do; the seed for the + generated ``instructions``. Required. + :vartype goal: str + :ivar description: An optional description for the agent. Generated from ``goal`` when omitted. + :vartype description: str + :ivar tools: Optional tools carried through verbatim onto the generated agent (see + ``VoiceAgentTool``). + :vartype tools: list["_unions.VoiceAgentTool"] + :ivar draft: (Preview) When ``true``, the generated voice agent is created as a draft — an + editable, unpublished version the caller can review and refine before publishing it via the + standard create/version path. The service defaults to ``false`` if a value is not specified by + the caller, in which case the agent is created and published normally. + :vartype draft: bool + """ + + name: Required[str] + """The unique name for the agent to create. Required.""" + model_type: Required[Union[str, "VoiceModelType"]] + """How the model backing the generated agent is served: ``managed`` (service-managed) or + ``self_deployed`` (the customer's own deployment). Carried through to the generated definition, + not generated. Required. Known values are: \"managed\" and \"self_deployed\".""" + model: Required[str] + """The model paired with ``model_type``: the service-managed model name when ``managed``, or the + customer's Foundry deployment name when ``self_deployed``. Carried through, not generated. + Required.""" + agent_type: Required[Union[str, "VoiceAgentType"]] + """The persona/tone to steer generation. Required. Known values are: \"personal\" and + \"business\".""" + use_case: Required[Union[str, "VoiceAgentUseCase"]] + """The scenario-template catalog entry the generator specializes for. Required. Known values are: + \"customer_support\", \"reception\", \"sales\", \"travel_assistant\", \"outreach\", + \"personal_assistant\", \"learning\", \"call_center\", and \"in_car\".""" + goal: Required[str] + """A natural-language description of what the agent should do; the seed for the generated + ``instructions``. Required.""" + description: str + """An optional description for the agent. Generated from ``goal`` when omitted.""" + tools: list["_unions.VoiceAgentTool"] + """Optional tools carried through verbatim onto the generated agent (see ``VoiceAgentTool``).""" + draft: bool + """(Preview) When ``true``, the generated voice agent is created as a draft — an editable, + unpublished version the caller can review and refine before publishing it via the standard + create/version path. The service defaults to ``false`` if a value is not specified by the + caller, in which case the agent is created and published normally.""" + + +class CreateVoiceAgentVersionRequest(TypedDict, total=False): + """CreateVoiceAgentVersionRequest. + + :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. + :vartype metadata: dict[str, str] + :ivar description: A human-readable description of the agent. + :vartype description: str + :ivar blueprint_reference: The blueprint reference for the agent. + :vartype blueprint_reference: "AgentBlueprintReference" + :ivar draft: (Preview) Whether this agent version is a draft (candidate) rather than a release. + The service defaults to ``false`` if a value is not specified by the caller. Draft versions are + recorded but excluded from default 'latest' resolution and are not auto-promoted. + :vartype draft: bool + :ivar definition: The voice agent definition. Required. + :vartype definition: "VoiceAgentDefinition" + """ + + metadata: 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.""" + description: str + """A human-readable description of the agent.""" + blueprint_reference: "AgentBlueprintReference" + """The blueprint reference for the agent.""" + draft: bool + """(Preview) Whether this agent version is a draft (candidate) rather than a release. The service + defaults to ``false`` if a value is not specified by the caller. Draft versions are recorded + but excluded from default 'latest' resolution and are not auto-promoted.""" + definition: Required["VoiceAgentDefinition"] + """The voice agent definition. Required.""" + + +AgentBlueprintReference = Union[ManagedAgentIdentityBlueprintReference] +AgentEndpointAuthorizationScheme = Union[ + BotServiceAuthorizationScheme, + BotServiceRbacAuthorizationScheme, + BotServiceTenantAuthorizationScheme, + EntraAuthorizationScheme, +] +AzureVoice = Union[AzureAvatarVoiceSyncVoice, AzureCustomVoice, AzurePersonalVoice, AzureStandardVoice] +CreateTranscriptionResponseJsonUsage = Union[TranscriptTextUsageDuration, TranscriptTextUsageTokens] +VersionSelectionRule = Union[FixedRatioVersionSelectionRule] +VoiceGreetingConfig = Union[LlmGeneratedVoiceGreetingConfig, TemplateVoiceGreetingConfig] +Tool = Union[MCPTool] +RealtimeConversationItem = Union[ + RealtimeConversationItemFunctionCall, + RealtimeConversationItemFunctionCallOutput, + RealtimeMCPApprovalRequest, + RealtimeMCPApprovalResponse, + RealtimeMCPToolCall, + RealtimeMCPListTools, +] +RealtimeConversationItemMessage = Union[ + RealtimeConversationItemMessageAssistant, RealtimeConversationItemMessageSystem, RealtimeConversationItemMessageUser +] +RealtimeMCPError = Union[RealtimeMCPHTTPError, RealtimeMCPProtocolError, RealtimeMCPToolExecutionError] +RealtimeServerEvent = Union[RealtimeServerEventResponseContentPartAdded] +ToolChoiceParam = Union[ToolChoiceFunction, ToolChoiceMCP] +VoiceAgentInterimResponseConfig = Union[VoiceAgentLlmInterimResponseConfig, VoiceAgentStaticInterimResponseConfig] +VoiceMessageItem = Union[VoiceAssistantMessageItem, VoiceSystemMessageItem, VoiceUserMessageItem] +VoiceConversationItem = Union[ + VoiceFunctionCallItem, + VoiceFunctionCallOutputItem, + VoiceMcpApprovalRequestItem, + VoiceMcpApprovalResponseItem, + VoiceMcpCallItem, + VoiceMcpListToolsItem, + VoiceMessageItem, +] +VoiceEndOfUtteranceDetection = Union[ + VoiceAzureSemanticDetection, VoiceAzureSemanticDetectionEn, VoiceAzureSemanticDetectionMultilingual +] +VoiceTurnDetection = Union[ + VoiceAzureSemanticVadTurnDetection, + VoiceAzureSemanticVadEnTurnDetection, + VoiceAzureSemanticVadMultilingualTurnDetection, + VoiceSemanticVadTurnDetection, + VoiceServerVadTurnDetection, +] diff --git a/sdk/voiceagents/azure-ai-voiceagents/dev_requirements.txt b/sdk/voiceagents/azure-ai-voiceagents/dev_requirements.txt new file mode 100644 index 000000000000..ad0907b03b93 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/dev_requirements.txt @@ -0,0 +1,4 @@ +-e ../../../eng/tools/azure-sdk-tools +../../core/azure-core +../../identity/azure-identity +aiohttp \ No newline at end of file diff --git a/sdk/voiceagents/azure-ai-voiceagents/pyproject.toml b/sdk/voiceagents/azure-ai-voiceagents/pyproject.toml new file mode 100644 index 000000000000..5247f5be1ec5 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/pyproject.toml @@ -0,0 +1,61 @@ +# -------------------------------------------------------------------------- +# 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-voiceagents" +authors = [ + { name = "Microsoft Corporation", email = "azpysdkhelp@microsoft.com" }, +] +description = "Microsoft Corporation Azure Ai Voiceagents 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.voiceagents._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"] diff --git a/sdk/voiceagents/azure-ai-voiceagents/pyrightconfig.json b/sdk/voiceagents/azure-ai-voiceagents/pyrightconfig.json new file mode 100644 index 000000000000..66cc40d3f494 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/pyrightconfig.json @@ -0,0 +1,13 @@ +{ + "reportTypeCommentUsage": true, + "reportMissingImports": false, + "pythonVersion": "3.10", + "exclude": [ + "**/tests/**", + "azure/ai/voiceagents/_unions.py" + ], + "extraPaths": [ + "./../../core/azure-core", + "./../../identity/azure-identity" + ] +} diff --git a/sdk/voiceagents/azure-ai-voiceagents/pytest.ini b/sdk/voiceagents/azure-ai-voiceagents/pytest.ini new file mode 100644 index 000000000000..2f4c80e30750 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +asyncio_mode = auto diff --git a/sdk/voiceagents/azure-ai-voiceagents/samples/README.md b/sdk/voiceagents/azure-ai-voiceagents/samples/README.md new file mode 100644 index 000000000000..7e65dc5fd1c2 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/samples/README.md @@ -0,0 +1,153 @@ +--- +page_type: sample +languages: + - python +products: + - azure + - azure-ai-foundry +urlFragment: voiceagents-samples +--- + +# Samples for the Azure AI Voice Agents client library for Python + +These code samples are organized **by scenario**: + +- **`quickstart/`** — the + shortest end-to-end path: generate a temporary voice agent with the management + API, hold a realtime microphone/speaker conversation with it, then delete the + agent. +- **`management/`** — + request/response scenarios with the `azure-ai-voiceagents` client: managing + voice agents, working with agent versions, and reading back persisted + conversations (transcript, items, and audio recordings). Each scenario + includes a sync sample and, where applicable, its async variant (files + suffixed `_async`). +- **`live/`** — the live voice conversation + scenario against an existing agent through the native + `client.realtime.connect(...)` API. No other SDK is required. + +> [!IMPORTANT] +> Voice agents are a **gated preview**. Every call opts in with the +> `VoiceAgents=V1Preview` feature flag (the samples pass it as `foundry_features`). +> The preview must also be **enabled for your subscription** and **served on your +> project's endpoint/region**. Until then, even a correct, authenticated request +> returns `404 NotFound` -- the route simply isn't provisioned for your project +> yet. If you hit this, confirm preview enablement and a supported region with +> your service contact rather than changing the sample code. + +## `quickstart/` -- create an agent and talk to it + +| File | Description | +| ---- | ----------- | +| [quickstart/sample_quickstart_async.py](quickstart/sample_quickstart_async.py) | Generate a temporary voice agent, stream microphone audio to it, play the spoken response through your speakers, and delete the agent when the sample exits. Requires `pyaudio`. | + +## `management/` -- manage agents and read conversations + +**Manage voice agents** -- these run standalone; you only need an endpoint. + +| File | Description | +| ---- | ----------- | +| [management/sample_create_and_manage_voice_agent.py](management/sample_create_and_manage_voice_agent.py) | Create (with a voice/audio config and conversation storage enabled), get, list, update, disable/enable, and delete a voice agent. | +| [management/sample_create_and_manage_voice_agent_async.py](management/sample_create_and_manage_voice_agent_async.py) | Async version of the create/manage lifecycle. | +| [management/sample_create_voice_agent_with_tools.py](management/sample_create_voice_agent_with_tools.py) | Create an agent with tools (`function`, `system`, `mcp`, `toolbox`), input-audio config (turn detection + transcription), and bring-your-own-model (`self_deployed`). | +| [management/sample_generate_voice_agent.py](management/sample_generate_voice_agent.py) | Guided authoring: generate and create a voice agent from a persona, use case, and a natural-language goal. | +| [management/sample_manage_voice_agent_versions.py](management/sample_manage_voice_agent_versions.py) | Create and list immutable versions of a voice agent, including draft versions. | + +**Read conversations** -- these need an existing agent and a conversation id from +a completed live session (see [Getting a conversation id](#getting-a-conversation-id)). + +| File | Description | +| ---- | ----------- | +| [management/sample_read_conversation.py](management/sample_read_conversation.py) | Read a persisted conversation, its responses (and per-response items), and its items (with single get by id). | +| [management/sample_read_conversation_audio.py](management/sample_read_conversation_audio.py) | Read the merged whole-call recording and a single turn's audio, streaming each to a WAV file. | + +## `live/` -- hold a live conversation + +| File | Description | +| ---- | ----------- | +| [live/sample_live_text_conversation_async.py](live/sample_live_text_conversation_async.py) | Converse with an **existing** agent using **typed** turns: type prompts in a loop -- each is sent via `client.realtime.connect(...)` and the spoken reply is streamed back (optionally played through your speakers). Reads the persisted conversation back at the end. Runs headless -- no microphone needed. | +| [live/sample_live_audio_conversation_async.py](live/sample_live_audio_conversation_async.py) | Converse with an **existing** agent using your **microphone**: stream live audio to the agent, let server VAD detect your turns, and talk over the agent to **barge in** (cancel its in-flight reply). Requires `pyaudio`. Runs until you press Ctrl-C. | + +## Prerequisites + +- Python 3.10 or later. +- An Azure subscription and a Foundry project endpoint. +- The following packages installed: + + ```bash + python -m pip install azure-ai-voiceagents azure-identity + # for the async samples, also install an async transport: + python -m pip install aiohttp + # optional: to hear the live samples' audio reply through your speakers, + # and to run the microphone sample: + python -m pip install pyaudio + ``` + +## Setup + +The samples read their inputs from environment variables. Every sample needs +`AZURE_VOICE_AGENTS_ENDPOINT`; the other variables depend on the scenario. + +| Variable | Required by | Description | +| -------- | ----------- | ----------- | +| `AZURE_VOICE_AGENTS_ENDPOINT` | all samples | Foundry project endpoint: `https://.services.ai.azure.com/api/projects/` | +| `AZURE_VOICE_AGENTS_MODEL` | management and quickstart samples (optional) | Realtime model deployment name. Defaults to `gpt-realtime`. | +| `AZURE_VOICE_AGENTS_MODEL_TYPE` | `sample_create_voice_agent_with_tools.py` (optional) | `managed` (default) for a service-hosted model, or `self_deployed` to bring your own Foundry deployment. | +| `AZURE_VOICE_AGENTS_AGENT_NAME` | `live/*.py`, `sample_read_conversation*.py` | Name of an existing voice agent -- create one first with a management sample using `store=True`, or use the quickstart for an automatic create-and-talk flow. | +| `AZURE_VOICE_AGENTS_CONVERSATION_ID` | `sample_read_conversation*.py` | Id of a persisted conversation (see below). | + +```bash +# bash +export AZURE_VOICE_AGENTS_ENDPOINT="https://.services.ai.azure.com/api/projects/" +``` + +```powershell +# PowerShell +$env:AZURE_VOICE_AGENTS_ENDPOINT = "https://.services.ai.azure.com/api/projects/" +``` + +The samples authenticate with +[`DefaultAzureCredential`](https://learn.microsoft.com/python/api/azure-identity/azure.identity.defaultazurecredential), +so sign in first (for example, with `az login`) or configure the appropriate +environment variables. Your identity needs access to the Foundry project. + +### Getting a conversation id + +The read samples don't create conversations -- this client can only *read* them. +A conversation is created by the **voice orchestrator during a live session**, +and it is persisted only when the agent was created with `store = true` (the +management samples turn this on). During the live session the service emits a +`conversation.created` event whose id you pass as +`AZURE_VOICE_AGENTS_CONVERSATION_ID`. Audio additionally requires the session to +have ended. + +The `live/` samples do this end to end for you against an **existing** agent +(set `AZURE_VOICE_AGENTS_AGENT_NAME`; create one first with a management sample and +`store=True`): each opens a live session with `client.realtime.connect(...)`, +captures the conversation id from that session, and reads the conversation +back -- no manual id wiring required. Use `sample_live_text_conversation_async.py` +for a headless typed turn, or `sample_live_audio_conversation_async.py` for a +hands-free microphone conversation with barge-in. + +## Running a sample + +```bash +python management/sample_create_and_manage_voice_agent.py +``` + +## Troubleshooting + +| Symptom | Likely cause and fix | +| ------- | -------------------- | +| `KeyError: 'AZURE_VOICE_AGENTS_...'` | A required environment variable is not set. See the table above. | +| `HttpResponseError` 401 / 403 | Not signed in, or your identity lacks access to the project. Run `az login` and confirm project permissions. | +| `ResourceNotFoundError` / 404 on a **management** call (create, list, generate) | The gated preview isn't enabled for your subscription, or isn't served on your project's endpoint/region yet. The request URL and auth are correct; the route just isn't provisioned. Confirm preview enablement and a supported region with your service contact. | +| `HttpResponseError` 404 on a **read** sample | The conversation was not persisted (agent ran with `store = false`) or the id is wrong. | +| `HttpResponseError` 409 on the audio sample | Either the session is still in progress, or the recording lives in your own bring-your-own-storage (BYOS) account -- its bytes aren't streamed through the service and must be downloaded directly from the `blob_uri` returned by the metadata route. Foundry-managed audio streams normally. | +| Model / deployment not found | The `gpt-realtime` default deployment doesn't exist in your project. Set `AZURE_VOICE_AGENTS_MODEL` to a valid realtime deployment name. | + +> [!NOTE] +> The management samples create and delete **real resources** in your project and +> may incur cost. Each sample deletes the agent it creates on the success path +> only; if a sample fails partway through, it may leave the agent behind, so +> check your project and delete any leftover agents manually. diff --git a/sdk/voiceagents/azure-ai-voiceagents/samples/live/sample_live_audio_conversation_async.py b/sdk/voiceagents/azure-ai-voiceagents/samples/live/sample_live_audio_conversation_async.py new file mode 100644 index 000000000000..a6db0f95eb7e --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/samples/live/sample_live_audio_conversation_async.py @@ -0,0 +1,323 @@ +# 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. +# -------------------------------------------------------------------------- + +""" +FILE: sample_live_audio_conversation_async.py + +DESCRIPTION: + End-to-end hands-free, bidirectional voice conversation against an existing + voice agent, using only azure-ai-voiceagents, through the native + ``client.realtime.connect(...)`` API. + + 1. Stream live mic audio and let the agent's server-side VAD detect your + turns: your speech is transcribed, the agent replies through the + speakers, and talking over it barges in. + 2. Read the persisted conversation back (requires the agent to have been + created with ``store=True``; see sample_create_and_manage_voice_agent.py). + + Capture and playback use non-blocking pyaudio callbacks; reply audio is + sequence-numbered so a barge-in can skip whatever is still queued. The agent + owns turn detection and noise suppression server-side. Use a headset to + avoid echo. + + Mic audio is sent as base64 PCM16; the reply arrives as typed + ``response.output_audio.*`` events, decoded to PCM16, mono, 24 kHz. Requires + ``pyaudio``. + + pip install azure-ai-voiceagents azure-identity pyaudio + +USAGE: + python sample_live_audio_conversation_async.py + + Environment variables: + 1) AZURE_VOICE_AGENTS_ENDPOINT (required) - Foundry project endpoint: + https://.services.ai.azure.com/api/projects/ + 2) AZURE_VOICE_AGENTS_AGENT_NAME (required) - name of an existing voice agent to + converse with (created with ``store=True`` to persist conversations). + + Runs until you press Ctrl-C. Authenticates with DefaultAzureCredential, so + sign in first (e.g. `az login`). +""" + +import asyncio +import os +import queue +from typing import Any, Final, Optional + +from azure.core.exceptions import HttpResponseError +from azure.identity.aio import DefaultAzureCredential + +from azure.ai.voiceagents.aio import AsyncRealtimeConnection, VoiceAgentsClient +from azure.ai.voiceagents.models import ( + AgentDefinitionOptInKeys, + VoiceAgentServerEventConversationCreated, + VoiceAgentServerEventConversationItemInputAudioTranscriptionCompleted, + VoiceAgentServerEventError, + VoiceAgentServerEventInputAudioBufferSpeechStarted, + VoiceAgentServerEventResponseAudioDelta, + VoiceAgentServerEventResponseAudioTranscriptDone, +) + +PREVIEW: Final = AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW + +# Audio is streamed both ways as PCM16, mono, 24 kHz. +_SAMPLE_RATE: Final = 24000 + +# pyaudio callback buffer size (~50 ms of PCM16 audio per callback). +_CHUNK_SAMPLES: Final = 1200 + +try: + import pyaudio # type: ignore[import-not-found] +except ImportError: # pragma: no cover - required audio dependency + pyaudio: Any = None # type: ignore[no-redef] + + +class _AudioProcessor: + """Real-time mic capture and speaker playback via non-blocking pyaudio callbacks. + + * Capture appends each raw PCM16 frame to the input buffer (the realtime + client base64-encodes it). + * Playback pulls sequence-numbered PCM16 from a queue, always returning the + exact sample count pyaudio asked for (a wrong size corrupts audio). + * ``skip_pending_audio`` bumps a base sequence number so audio queued before + a barge-in is dropped, stopping playback the instant the user speaks. + """ + + def __init__(self, connection: "AsyncRealtimeConnection") -> None: + self._conn = connection + self._loop: Optional[asyncio.AbstractEventLoop] = None + self._audio = pyaudio.PyAudio() + + # Playback with sequence numbers for interrupt handling. + self._playback_queue: "queue.Queue[tuple[int, Optional[bytes]]]" = queue.Queue() + self._playback_base = 0 + self._next_seq = 0 + self._bytes = 0 + + self._input_stream = None + self._output_stream = None + + # -- capture ----------------------------------------------------------- + + def start_capture(self) -> None: + """Start streaming microphone audio to the service via a callback.""" + if self._input_stream is not None: + return + self._loop = asyncio.get_running_loop() + + def _capture_callback(in_data, _frame_count, _time_info, _status): + # Runs on a pyaudio thread: hand the frame to the event loop to append. + assert self._loop is not None + asyncio.run_coroutine_threadsafe(self._conn.input_audio_buffer.append(audio=in_data), self._loop) + return (None, pyaudio.paContinue) + + self._input_stream = self._audio.open( + format=pyaudio.paInt16, + channels=1, + rate=_SAMPLE_RATE, + input=True, + frames_per_buffer=_CHUNK_SAMPLES, + stream_callback=_capture_callback, + ) + + # -- playback ------------------------------------------------------------ + + def start_playback(self) -> None: + """Initialize the speaker playback callback.""" + if self._output_stream is not None: + return + remaining = b"" + + def _playback_callback(_in_data, frame_count, _time_info, _status): + nonlocal remaining + wanted = frame_count * pyaudio.get_sample_size(pyaudio.paInt16) + out = remaining[:wanted] + remaining = remaining[wanted:] + + while len(out) < wanted: + try: + seq, data = self._playback_queue.get_nowait() + except queue.Empty: + out = out + bytes(wanted - len(out)) # pad with silence + continue + if not data: + break # end-of-stream marker + if seq < self._playback_base: + remaining = b"" # skipped by a barge-in + continue + take = wanted - len(out) + out = out + data[:take] + remaining = data[take:] + + return (out, pyaudio.paContinue) + + self._output_stream = self._audio.open( + format=pyaudio.paInt16, + channels=1, + rate=_SAMPLE_RATE, + output=True, + frames_per_buffer=_CHUNK_SAMPLES, + stream_callback=_playback_callback, + ) + + def _next_seq_num(self) -> int: + seq = self._next_seq + self._next_seq += 1 + return seq + + def queue_audio(self, pcm: bytes) -> None: + """Queue one decoded PCM16 chunk of the agent's reply for playback. + + :param pcm: Decoded PCM16 audio bytes. + :type pcm: bytes + """ + self._bytes += len(pcm) + self._playback_queue.put((self._next_seq_num(), pcm)) + + def skip_pending_audio(self) -> None: + """Drop audio still queued for playback (used on barge-in).""" + self._playback_base = self._next_seq_num() + + def shutdown(self) -> None: + """Stop capture and playback and release the audio device.""" + if self._input_stream is not None: + self._input_stream.stop_stream() + self._input_stream.close() + self._input_stream = None + if self._output_stream is not None: + self.skip_pending_audio() + self._playback_queue.put((self._next_seq_num(), None)) + self._output_stream.stop_stream() + self._output_stream.close() + self._output_stream = None + self._audio.terminate() + + @property + def seconds(self) -> float: + """Total reply audio received, in seconds (PCM16 = 2 bytes/sample). + + :rtype: float + """ + return self._bytes / 2 / _SAMPLE_RATE + + +async def _run_audio_conversation(client: VoiceAgentsClient, agent_name: str) -> Optional[str]: + """Hold a live, hands-free conversation with barge-in. + + :param client: The voice agents client. + :param agent_name: The existing voice agent name. + :type client: ~azure.ai.voiceagents.aio.VoiceAgentsClient + :type agent_name: str + :return: The persisted conversation id, if one is created. + :rtype: str or None + """ + if pyaudio is None: + print("This sample needs pyaudio for audio: pip install pyaudio") + return None + + conversation_id: Optional[str] = None + + # Open the realtime session on the voice agent's dedicated route. + async with client.realtime.connect(agent_name=agent_name) as conn: + # A voice agent owns its model, instructions, voice, turn detection, and + # noise suppression server-side, so this client sends no ``session.update``. + ap = _AudioProcessor(conn) + ap.start_playback() + ap.start_capture() + + print("Speak now -- the agent replies after you pause.") + print("(talk over the agent to interrupt it; press Ctrl-C to end the session)") + + try: + async for event in conn: + if isinstance(event, VoiceAgentServerEventInputAudioBufferSpeechStarted): + # Barge-in: stop the active response and drop whatever reply + # audio is still queued locally. The service only supports + # output_audio_buffer.clear in avatar mode. + await conn.response.cancel() + ap.skip_pending_audio() + print("(listening...)") + elif isinstance(event, VoiceAgentServerEventConversationItemInputAudioTranscriptionCompleted): + print(f"You: {event.transcript.strip()}") + elif isinstance(event, VoiceAgentServerEventError): + # Non-fatal errors are reported; a fatal one closes the socket. + print(f"Session error: {event.error.message}") + elif isinstance(event, VoiceAgentServerEventResponseAudioDelta): + # Each delta is a decoded PCM16 chunk; queue it. + ap.queue_audio(event.delta) + elif isinstance(event, VoiceAgentServerEventResponseAudioTranscriptDone): + print(f"Agent: {event.transcript}") + elif isinstance(event, VoiceAgentServerEventConversationCreated): + conversation_id = event.conversation_id + print(f"(conversation.created -> persisted id: {conversation_id})") + except (KeyboardInterrupt, asyncio.CancelledError): + # Ctrl-C ends the session; read back whatever was persisted so far. + print("\n(ending session...)") + finally: + print(f"(received {ap.seconds:.2f}s of reply audio this session)") + ap.shutdown() + + return conversation_id + + +async def _read_conversation(client: VoiceAgentsClient, agent_name: str, conversation_id: str) -> None: + """Read the persisted conversation back over the read-only conversation API. + + :param client: The voice agents client. + :param agent_name: The voice agent name. + :param conversation_id: The persisted conversation id. + :type client: ~azure.ai.voiceagents.aio.VoiceAgentsClient + :type agent_name: str + :type conversation_id: str + """ + conversations = client.agent_endpoint_conversations + + conversation = await conversations.get_agent_conversation(agent_name, conversation_id, foundry_features=PREVIEW) + print(f"Conversation {conversation.id}: status={conversation.status}, created_at={conversation.created_at}") + + print("Items (transcript):") + async for item in conversations.list_agent_conversation_items( + agent_name, conversation_id, foundry_features=PREVIEW + ): + role = item.get("role") or item.get("type") + # Audio turns expose ``transcript``; text turns expose ``text``. + parts = [(part.get("transcript") or part.get("text") or "").strip() for part in (item.get("content") or [])] + transcript = " ".join(p for p in parts if p) + print(f" - {role} id={item.get('id')}") + if transcript: + print(f" {transcript}") + + +async def audio_conversation() -> None: + endpoint = os.environ["AZURE_VOICE_AGENTS_ENDPOINT"] + agent_name = os.environ["AZURE_VOICE_AGENTS_AGENT_NAME"] + + async with DefaultAzureCredential() as credential, VoiceAgentsClient( + endpoint=endpoint, credential=credential + ) as client: + try: + # 1) Hold a live microphone conversation with the existing agent. + print(f"Starting realtime session with agent: {agent_name}") + conversation_id = await _run_audio_conversation(client, agent_name) + + # 2) Read the persisted conversation back. + if conversation_id: + print(f"Reading persisted conversation {conversation_id!r}...") + try: + await _read_conversation(client, agent_name, conversation_id) + except HttpResponseError as e: + print(f"Could not read conversation: {e.status_code} {e.reason}") + else: + print("No conversation id was returned; nothing to read.") + except HttpResponseError as e: + print(f"Service responded with an error: {e.status_code} {e.reason}") + + +if __name__ == "__main__": + try: + asyncio.run(audio_conversation()) + except KeyboardInterrupt: + print("\nInterrupted.") diff --git a/sdk/voiceagents/azure-ai-voiceagents/samples/live/sample_live_text_conversation_async.py b/sdk/voiceagents/azure-ai-voiceagents/samples/live/sample_live_text_conversation_async.py new file mode 100644 index 000000000000..6cdcff9d2ca7 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/samples/live/sample_live_text_conversation_async.py @@ -0,0 +1,250 @@ +# 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. +# -------------------------------------------------------------------------- + +""" +FILE: sample_live_text_conversation_async.py + +DESCRIPTION: + End-to-end typed conversation against an existing voice agent, using only + azure-ai-voiceagents, through the native ``client.realtime.connect(...)`` API. + + 1. Hold a typed, multi-turn conversation: each prompt is sent as a + ``RealtimeConversationItemMessageUser`` and the reply streams back as + typed audio and transcript events. Blank line (or ``exit`` / ``quit``) + ends it. + 2. Read the persisted conversation back (requires the agent to have been + created with ``store=True``; see sample_create_and_manage_voice_agent.py). + + Reply audio is PCM16, mono, 24 kHz and plays through the speakers when + ``pyaudio`` is installed; runs headless otherwise. For a hands-free mic + conversation with barge-in, see sample_live_audio_conversation_async.py. + + pip install azure-ai-voiceagents azure-identity pyaudio + +USAGE: + python sample_live_text_conversation_async.py + + Environment variables: + 1) AZURE_VOICE_AGENTS_ENDPOINT (required) - Foundry project endpoint: + https://.services.ai.azure.com/api/projects/ + 2) AZURE_VOICE_AGENTS_AGENT_NAME (required) - name of an existing voice agent to + converse with (created with ``store=True`` to persist conversations). + + Authenticates with DefaultAzureCredential, so sign in first (e.g. `az login`). +""" + +import asyncio +import os +from typing import Final, Optional + +from azure.core.exceptions import HttpResponseError +from azure.identity.aio import DefaultAzureCredential + +from azure.ai.voiceagents.aio import VoiceAgentsClient +from azure.ai.voiceagents.models import ( + AgentDefinitionOptInKeys, + RealtimeConversationItemMessageUser, + RealtimeConversationItemMessageUserContent, + VoiceAgentServerEventConversationCreated, + VoiceAgentServerEventError, + VoiceAgentServerEventResponseAudioDelta, + VoiceAgentServerEventResponseAudioTranscriptDone, + VoiceAgentServerEventResponseDone, +) + +PREVIEW: Final = AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW + +# Seconds to wait for the agent to finish its reply. +_RESPONSE_TIMEOUT: Final = 45 + +# Reply audio format: PCM16, mono, 24 kHz. +_SAMPLE_RATE: Final = 24000 + +try: + import pyaudio # type: ignore[import-not-found] +except ImportError: # pragma: no cover - optional playback dependency + pyaudio = None # type: ignore[assignment] + + +class _SpeakerPlayer: + """Play streamed PCM16 audio through the speakers with pyaudio. + + Optional: without pyaudio the player is a no-op and the sample still runs + headless, reporting how much audio it received. + """ + + def __init__(self) -> None: + self._audio = None + self._stream = None + self._bytes = 0 + if pyaudio is not None: + self._audio = pyaudio.PyAudio() + self._stream = self._audio.open( + format=pyaudio.paInt16, + channels=1, + rate=_SAMPLE_RATE, + output=True, + ) + + @property + def enabled(self) -> bool: + return self._stream is not None + + def play(self, pcm: bytes) -> None: + """Write one decoded PCM16 chunk to the speaker. + + :param pcm: Decoded PCM16 audio bytes. + :type pcm: bytes + """ + self._bytes += len(pcm) + if self._stream is not None: + self._stream.write(pcm) + + def close(self) -> None: + """Drain and release the audio device.""" + if self._stream is not None: + self._stream.stop_stream() + self._stream.close() + self._stream = None + if self._audio is not None: + self._audio.terminate() + self._audio = None + + @property + def seconds(self) -> float: + """Total audio received, in seconds (PCM16 = 2 bytes/sample). + + :rtype: float + """ + return self._bytes / 2 / _SAMPLE_RATE + + +async def _run_text_conversation(client: VoiceAgentsClient, agent_name: str) -> Optional[str]: + """Hold a typed, multi-turn conversation. + + :param client: The voice agents client. + :param agent_name: The existing voice agent name. + :type client: ~azure.ai.voiceagents.aio.VoiceAgentsClient + :type agent_name: str + :return: The persisted conversation id, if one is created. + :rtype: str or None + """ + conversation_id: Optional[str] = None + audio_delta_count = 0 + player = _SpeakerPlayer() + + try: + # Open the realtime session on the voice agent's dedicated route. + async with client.realtime.connect(agent_name=agent_name) as conn: + print("Type a message and press Enter. Blank line (or 'exit') ends the session.") + + async def pump() -> None: + nonlocal conversation_id, audio_delta_count + async for event in conn: + if isinstance(event, VoiceAgentServerEventResponseDone): + return + if isinstance(event, VoiceAgentServerEventError): + print(f"Session error: {event.error.message}") + return + if isinstance(event, VoiceAgentServerEventResponseAudioDelta): + # Each delta is a decoded PCM16 chunk; play it. + audio_delta_count += 1 + player.play(event.delta) + elif isinstance(event, VoiceAgentServerEventResponseAudioTranscriptDone): + print(f"Agent: {event.transcript}") + elif isinstance(event, VoiceAgentServerEventConversationCreated): + conversation_id = event.conversation_id + print(f"(conversation.created -> persisted id: {conversation_id})") + + while True: + # input() blocks, so read it off the loop in a worker thread. + prompt = (await asyncio.to_thread(input, "You: ")).strip() + if not prompt or prompt.lower() in ("exit", "quit"): + break + + # Send the turn and ask the agent to respond. + await conn.conversation.item.create( + item=RealtimeConversationItemMessageUser( + content=[RealtimeConversationItemMessageUserContent(type="input_text", text=prompt)] + ) + ) + await conn.response.create() + + try: + await asyncio.wait_for(pump(), timeout=_RESPONSE_TIMEOUT) + except asyncio.TimeoutError: + print("Timed out waiting for the agent's reply.") + except (KeyboardInterrupt, asyncio.CancelledError): + print("\n(ending session...)") + finally: + played = player.enabled + player.close() + + detail = "played" if played else "received" + print(f"(streamed {audio_delta_count} audio chunks, {detail} {player.seconds:.2f}s of audio)") + if not played: + print("(install pyaudio to hear the reply: pip install pyaudio)") + return conversation_id + + +async def _read_conversation(client: VoiceAgentsClient, agent_name: str, conversation_id: str) -> None: + """Read the persisted conversation back over the read-only conversation API. + + :param client: The voice agents client. + :param agent_name: The voice agent name. + :param conversation_id: The persisted conversation id. + :type client: ~azure.ai.voiceagents.aio.VoiceAgentsClient + :type agent_name: str + :type conversation_id: str + """ + conversations = client.agent_endpoint_conversations + + conversation = await conversations.get_agent_conversation(agent_name, conversation_id, foundry_features=PREVIEW) + print(f"Conversation {conversation.id}: status={conversation.status}, created_at={conversation.created_at}") + + print("Items (transcript):") + async for item in conversations.list_agent_conversation_items( + agent_name, conversation_id, foundry_features=PREVIEW + ): + role = item.get("role") or item.get("type") + # Audio turns expose ``transcript``; text turns expose ``text``. + parts = [(part.get("transcript") or part.get("text") or "").strip() for part in (item.get("content") or [])] + transcript = " ".join(p for p in parts if p) + print(f" - {role} id={item.get('id')}") + if transcript: + print(f" {transcript}") + + +async def text_conversation() -> None: + endpoint = os.environ["AZURE_VOICE_AGENTS_ENDPOINT"] + agent_name = os.environ["AZURE_VOICE_AGENTS_AGENT_NAME"] + + async with DefaultAzureCredential() as credential, VoiceAgentsClient( + endpoint=endpoint, credential=credential + ) as client: + try: + # 1) Hold the realtime conversation against the existing agent. + print(f"Starting realtime session with agent: {agent_name}") + conversation_id = await _run_text_conversation(client, agent_name) + + # 2) Read the persisted conversation back. + if conversation_id: + print(f"Reading persisted conversation {conversation_id}...") + try: + await _read_conversation(client, agent_name, conversation_id) + except HttpResponseError as e: + print(f"Could not read conversation: {e.status_code} {e.reason}") + else: + print("No conversation id was returned; nothing to read.") + except HttpResponseError as e: + print(f"Service responded with an error: {e.status_code} {e.reason}") + + +if __name__ == "__main__": + try: + asyncio.run(text_conversation()) + except KeyboardInterrupt: + print("\nInterrupted.") diff --git a/sdk/voiceagents/azure-ai-voiceagents/samples/management/sample_create_and_manage_voice_agent.py b/sdk/voiceagents/azure-ai-voiceagents/samples/management/sample_create_and_manage_voice_agent.py new file mode 100644 index 000000000000..980cb41b8628 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/samples/management/sample_create_and_manage_voice_agent.py @@ -0,0 +1,115 @@ +# 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. +# -------------------------------------------------------------------------- + +""" +FILE: sample_create_and_manage_voice_agent.py + +DESCRIPTION: + This sample demonstrates the voice-agent management lifecycle over the HTTP + surface: creating a voice agent (with an audio/voice configuration and + conversation storage enabled), retrieving it, listing the agents in the + project, updating it, disabling/enabling it, and deleting it. + +USAGE: + python sample_create_and_manage_voice_agent.py + + Set the environment variable before running the sample: + 1) AZURE_VOICE_AGENTS_ENDPOINT - the Foundry project endpoint, in the form + https://.services.ai.azure.com/api/projects/ + + Optional: + 2) AZURE_VOICE_AGENTS_MODEL - the realtime model deployment to use. + Defaults to "gpt-realtime". + + The sample authenticates with DefaultAzureCredential, so sign in first + (for example, with `az login`). +""" + +import os +from typing import Final + +from azure.identity import DefaultAzureCredential + +from azure.ai.voiceagents import VoiceAgentsClient +from azure.ai.voiceagents.models import ( + AgentDefinitionOptInKeys, + AzureStandardVoice, + VoiceAgentDefinition, + VoiceAudioConfig, + VoiceAudioOutputConfig, + VoiceOutputModality, +) + + +def create_and_manage_voice_agent() -> None: + endpoint = os.environ["AZURE_VOICE_AGENTS_ENDPOINT"] + model = os.environ.get("AZURE_VOICE_AGENTS_MODEL", "gpt-realtime") + agent_name = "sample-voice-agent" + + # Voice agent preview operations require this feature-flag opt-in. + preview: Final = AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW + + definition = VoiceAgentDefinition( + # `managed` uses a service-hosted model; use `self_deployed` with a Foundry + # deployment name to bring your own model. + model_type="managed", + model=model, + instructions="You are a friendly voice assistant. Keep replies short and natural.", + audio=VoiceAudioConfig( + output=VoiceAudioOutputConfig(voice=AzureStandardVoice(name="en-US-AvaNeural")), + ), + output_modalities=[VoiceOutputModality.AUDIO], + # Persist conversations so the transcript and audio can be read back later + # (see sample_read_conversation.py). Defaults to False, which stores nothing. + store=True, + ) + + with VoiceAgentsClient(endpoint=endpoint, credential=DefaultAzureCredential()) as client: + created = client.voice_agents.create_voice_agent( + name=agent_name, + definition=definition, + description="Created by the azure-ai-voiceagents sample.", + foundry_features=preview, + ) + print(f"Created voice agent: {created.name}") + + agent = client.voice_agents.get_voice_agent(agent_name, foundry_features=preview) + print(f"Retrieved voice agent: {agent.name}") + + print("Voice agents in this project:") + for item in client.voice_agents.list_voice_agents(foundry_features=preview): + print(f" - {item.name}") + + # Update the agent. Each update that changes the definition produces a new version. + # Preserve the audio and output-modality configuration from the original + # definition so the new version keeps the same voice behavior. + updated = client.voice_agents.update_voice_agent( + agent_name, + definition=VoiceAgentDefinition( + model_type="managed", + model=model, + instructions="You are a friendly voice assistant. Always greet the caller warmly.", + audio=definition.audio, + output_modalities=definition.output_modalities, + store=definition.store, + ), + description="Updated instructions.", + foundry_features=preview, + ) + print(f"Updated voice agent to version: {updated.versions.latest.version}") + + # Disable the agent so its endpoint rejects new requests, then re-enable it. + client.voice_agents.disable_voice_agent(agent_name, foundry_features=preview) + print("Disabled voice agent") + client.voice_agents.enable_voice_agent(agent_name, foundry_features=preview) + print("Enabled voice agent") + + client.voice_agents.delete_voice_agent(agent_name, foundry_features=preview) + print(f"Deleted voice agent: {agent_name}") + + +if __name__ == "__main__": + create_and_manage_voice_agent() diff --git a/sdk/voiceagents/azure-ai-voiceagents/samples/management/sample_create_and_manage_voice_agent_async.py b/sdk/voiceagents/azure-ai-voiceagents/samples/management/sample_create_and_manage_voice_agent_async.py new file mode 100644 index 000000000000..1599223f6e2f --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/samples/management/sample_create_and_manage_voice_agent_async.py @@ -0,0 +1,76 @@ +# 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. +# -------------------------------------------------------------------------- + +""" +FILE: sample_create_and_manage_voice_agent_async.py + +DESCRIPTION: + This sample demonstrates the voice-agent management lifecycle using the async + client: creating a voice agent, retrieving it, listing the agents in the + project, and deleting it. + +USAGE: + python sample_create_and_manage_voice_agent_async.py + + Set the environment variable before running the sample: + 1) AZURE_VOICE_AGENTS_ENDPOINT - the Foundry project endpoint, in the form + https://.services.ai.azure.com/api/projects/ + + Optional: + 2) AZURE_VOICE_AGENTS_MODEL - the realtime model deployment to use. + Defaults to "gpt-realtime". + + The sample authenticates with DefaultAzureCredential, so sign in first + (for example, with `az login`). An async HTTP transport such as aiohttp must + be installed (`pip install aiohttp`). +""" + +import asyncio +import os +from typing import Final + +from azure.identity.aio import DefaultAzureCredential + +from azure.ai.voiceagents.aio import VoiceAgentsClient +from azure.ai.voiceagents.models import AgentDefinitionOptInKeys, VoiceAgentDefinition + + +async def create_and_manage_voice_agent() -> None: + endpoint = os.environ["AZURE_VOICE_AGENTS_ENDPOINT"] + model = os.environ.get("AZURE_VOICE_AGENTS_MODEL", "gpt-realtime") + agent_name = "sample-voice-agent-async" + preview: Final = AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW + + async with DefaultAzureCredential() as credential, VoiceAgentsClient( + endpoint=endpoint, credential=credential + ) as client: + created = await client.voice_agents.create_voice_agent( + name=agent_name, + definition=VoiceAgentDefinition( + model_type="managed", + model=model, + instructions="You are a friendly voice assistant. Keep replies short and natural.", + # Persist conversations so they can be read back later. Defaults to False. + store=True, + ), + description="Created by the azure-ai-voiceagents async sample.", + foundry_features=preview, + ) + print(f"Created voice agent: {created.name}") + + agent = await client.voice_agents.get_voice_agent(agent_name, foundry_features=preview) + print(f"Retrieved voice agent: {agent.name}") + + print("Voice agents in this project:") + async for item in client.voice_agents.list_voice_agents(foundry_features=preview): + print(f" - {item.name}") + + await client.voice_agents.delete_voice_agent(agent_name, foundry_features=preview) + print(f"Deleted voice agent: {agent_name}") + + +if __name__ == "__main__": + asyncio.run(create_and_manage_voice_agent()) diff --git a/sdk/voiceagents/azure-ai-voiceagents/samples/management/sample_create_voice_agent_with_tools.py b/sdk/voiceagents/azure-ai-voiceagents/samples/management/sample_create_voice_agent_with_tools.py new file mode 100644 index 000000000000..946205a26c42 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/samples/management/sample_create_voice_agent_with_tools.py @@ -0,0 +1,162 @@ +# 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. +# -------------------------------------------------------------------------- + +""" +FILE: sample_create_voice_agent_with_tools.py + +DESCRIPTION: + This sample demonstrates the richer parts of a voice agent definition that the + basic create sample leaves out: + + * Input (microphone) audio configuration: audio format, server-side turn + detection (VAD), input-audio transcription, and noise reduction. + * Tools the agent may use during a live session: a client-executed `function` + tool, a service-managed `system` control tool, and (shown as constructed + objects) `mcp` and `toolbox` tools. + * Bring-your-own-model (BYOM): set `model_type="self_deployed"` to point the + agent at your own Foundry model deployment instead of a service-managed model. + + The tools and audio settings are session defaults baked into the agent; the live + realtime session that actually invokes them is reached through the + `client.realtime.connect(...)` namespace (see the live sample). + +USAGE: + python sample_create_voice_agent_with_tools.py + + Set these environment variables before running the sample: + 1) AZURE_VOICE_AGENTS_ENDPOINT - the Foundry project endpoint, in the form + https://.services.ai.azure.com/api/projects/ + 2) AZURE_VOICE_AGENTS_MODEL - optional. The realtime model (managed) or the + Foundry deployment name (BYOM). Defaults to "gpt-realtime". + 3) AZURE_VOICE_AGENTS_MODEL_TYPE - optional. "managed" (default) for a + service-hosted model, or "self_deployed" to bring your own deployment. + + The sample authenticates with DefaultAzureCredential, so sign in first + (for example, with `az login`). +""" + +import os +from typing import Any, Final, cast + +from azure.identity import DefaultAzureCredential + +from azure.ai.voiceagents import VoiceAgentsClient +from azure.ai.voiceagents.models import ( + AgentDefinitionOptInKeys, + AzureStandardVoice, + RealtimeFunctionTool, + VoiceAgentDefinition, + VoiceAgentMcpTool, + VoiceAudioConfig, + VoiceAudioFormat, + VoiceAudioInputConfig, + VoiceAudioOutputConfig, + VoiceInputTranscription, + VoiceModelType, + VoiceOutputModality, + VoiceServerVadTurnDetection, + VoiceSystemTool, + VoiceSystemToolName, + ToolType, + VoiceToolboxTool, +) + + +def create_voice_agent_with_tools() -> None: + endpoint = os.environ["AZURE_VOICE_AGENTS_ENDPOINT"] + model = os.environ.get("AZURE_VOICE_AGENTS_MODEL", "gpt-realtime") + # "managed" runs a service-hosted model; "self_deployed" (BYOM) uses your own + # Foundry deployment named by `model`. The service derives whether the model is + # realtime or cascaded; you don't set that here. + model_type = os.environ.get("AZURE_VOICE_AGENTS_MODEL_TYPE", VoiceModelType.MANAGED) + agent_name = "sample-voice-agent-with-tools" + + # Voice agent preview operations require this feature-flag opt-in. + preview: Final = AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW + + # A client-executed tool: the service forwards the function call to your app, + # and your app returns the result over the live session. + get_weather = RealtimeFunctionTool( + type="function", + name="get_weather", + description="Get the current weather for a city.", + parameters=cast(Any, { + "type": "object", + "properties": {"city": {"type": "string", "description": "City name, e.g. Seattle."}}, + "required": ["city"], + }), + ) + + # A service-managed control tool: the platform can end the call on the agent's behalf. + end_call = VoiceSystemTool(name=VoiceSystemToolName.END_CONVERSATION) + + # An MCP tool is executed by the service against a remote MCP server you own. + # It references an external server, so it is constructed here for illustration + # and not attached below. Provide one of server_url, connector_id, or tunnel_id. + _example_mcp_tool = VoiceAgentMcpTool( + type=ToolType.MCP, + server_label="my-mcp-server", + server_url="https://example.com/mcp", + require_approval="never", + ) + + # A toolbox tool references a versioned Foundry toolbox you have created. It is + # constructed here for illustration; attach it only if the toolbox exists. + _example_toolbox_tool = VoiceToolboxTool(toolbox_name="my-toolbox", toolbox_version="1") + + definition = VoiceAgentDefinition( + model_type=model_type, + model=model, + instructions="You are a helpful voice assistant. Use tools when they help answer the caller.", + audio=VoiceAudioConfig( + # Input (microphone) side: 24 kHz PCM, server-side VAD so the agent + # auto-responds when the caller stops speaking, plus input-audio + # transcription so user speech is transcribed. + input=VoiceAudioInputConfig( + format=VoiceAudioFormat(type="audio/pcm", rate=24000), + turn_detection=VoiceServerVadTurnDetection( + threshold=0.5, + prefix_padding_ms=300, + silence_duration_ms=500, + ), + transcription=VoiceInputTranscription(model="whisper-1"), + ), + # Output (agent speech) side: the voice the agent speaks with. Pass an + # AzureStandardVoice for an Azure neural voice, or a plain string such as + # "alloy" for a built-in OpenAI voice (realtime models only): + # output=VoiceAudioOutputConfig(voice="alloy"), + output=VoiceAudioOutputConfig(voice=AzureStandardVoice(name="en-US-AvaNeural")), + ), + output_modalities=[VoiceOutputModality.AUDIO], + # Attach the self-contained tools. `_example_mcp_tool` and `_example_toolbox_tool` + # reference external resources you must own, so they are left out here. + tools=[get_weather, end_call], + store=True, + ) + + with VoiceAgentsClient(endpoint=endpoint, credential=DefaultAzureCredential()) as client: + created = client.voice_agents.create_voice_agent( + name=agent_name, + definition=definition, + description="Voice agent with tools and input-audio config (azure-ai-voiceagents sample).", + foundry_features=preview, + ) + print(f"Created voice agent: {created.name} (model_type={model_type}, model={model})") + + agent = client.voice_agents.get_voice_agent(agent_name, foundry_features=preview) + tools = agent.versions.latest.definition.tools or [] + print(f"Configured {len(tools)} tool(s):") + for tool in tools: + # Tools belong to an open union, so on read they surface as mappings + # keyed by their wire fields (``type`` and, for most kinds, ``name``). + print(f" - {tool['type']}: {tool.get('name', '(unnamed)')}") + + client.voice_agents.delete_voice_agent(agent_name, foundry_features=preview) + print(f"Deleted voice agent: {agent_name}") + + +if __name__ == "__main__": + create_voice_agent_with_tools() diff --git a/sdk/voiceagents/azure-ai-voiceagents/samples/management/sample_generate_voice_agent.py b/sdk/voiceagents/azure-ai-voiceagents/samples/management/sample_generate_voice_agent.py new file mode 100644 index 000000000000..42639e720bd8 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/samples/management/sample_generate_voice_agent.py @@ -0,0 +1,64 @@ +# 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. +# -------------------------------------------------------------------------- + +""" +FILE: sample_generate_voice_agent.py + +DESCRIPTION: + This sample demonstrates guided authoring: generating and creating a voice + agent from a few high-level inputs plus a natural-language goal. The service + expands the goal into a full, editable definition, creates the agent, and + returns it. Every generated field can be refined afterward through the normal + update/version flow. + +USAGE: + python sample_generate_voice_agent.py + + Set the environment variable before running the sample: + 1) AZURE_VOICE_AGENTS_ENDPOINT - the Foundry project endpoint, in the form + https://.services.ai.azure.com/api/projects/ + + Optional: + 2) AZURE_VOICE_AGENTS_MODEL - the realtime model deployment to use. + Defaults to "gpt-realtime". + + The sample authenticates with DefaultAzureCredential, so sign in first + (for example, with `az login`). +""" + +import os +from typing import Final + +from azure.identity import DefaultAzureCredential + +from azure.ai.voiceagents import VoiceAgentsClient +from azure.ai.voiceagents.models import AgentDefinitionOptInKeys, VoiceAgentType, VoiceAgentUseCase + + +def generate_voice_agent() -> None: + endpoint = os.environ["AZURE_VOICE_AGENTS_ENDPOINT"] + model = os.environ.get("AZURE_VOICE_AGENTS_MODEL", "gpt-realtime") + preview: Final = AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW + + with VoiceAgentsClient(endpoint=endpoint, credential=DefaultAzureCredential()) as client: + agent = client.voice_agents.generate_voice_agent( + name="sample-generated-agent", + model_type="managed", + model=model, + agent_type=VoiceAgentType.BUSINESS, + use_case=VoiceAgentUseCase.CUSTOMER_SUPPORT, + goal="Help callers troubleshoot their internet connection and open a support ticket if needed.", + foundry_features=preview, + ) + print(f"Generated voice agent: {agent.name}") + print(f"Instructions:\n{agent.versions.latest.definition.instructions}") + + client.voice_agents.delete_voice_agent(agent.name, foundry_features=preview) + print(f"Deleted voice agent: {agent.name}") + + +if __name__ == "__main__": + generate_voice_agent() diff --git a/sdk/voiceagents/azure-ai-voiceagents/samples/management/sample_manage_voice_agent_versions.py b/sdk/voiceagents/azure-ai-voiceagents/samples/management/sample_manage_voice_agent_versions.py new file mode 100644 index 000000000000..fbbe7b3b8462 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/samples/management/sample_manage_voice_agent_versions.py @@ -0,0 +1,101 @@ +# 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. +# -------------------------------------------------------------------------- + +""" +FILE: sample_manage_voice_agent_versions.py + +DESCRIPTION: + This sample demonstrates working with voice-agent versions. Voice agents are + immutable: every create or update produces a new version. This sample creates + an agent, adds a new version to it, lists the versions, and reads a single + version back. + +USAGE: + python sample_manage_voice_agent_versions.py + + Set the environment variable before running the sample: + 1) AZURE_VOICE_AGENTS_ENDPOINT - the Foundry project endpoint, in the form + https://.services.ai.azure.com/api/projects/ + + Optional: + 2) AZURE_VOICE_AGENTS_MODEL - the realtime model deployment to use. + Defaults to "gpt-realtime". + + The sample authenticates with DefaultAzureCredential, so sign in first + (for example, with `az login`). +""" + +import os +from typing import Final + +from azure.identity import DefaultAzureCredential + +from azure.ai.voiceagents import VoiceAgentsClient +from azure.ai.voiceagents.models import AgentDefinitionOptInKeys, VoiceAgentDefinition + + +def manage_voice_agent_versions() -> None: + endpoint = os.environ["AZURE_VOICE_AGENTS_ENDPOINT"] + model = os.environ.get("AZURE_VOICE_AGENTS_MODEL", "gpt-realtime") + agent_name = "sample-versioned-voice-agent" + preview: Final = AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW + + def definition(instructions: str) -> VoiceAgentDefinition: + # Each version differs only by its instructions; the rest is identical. + return VoiceAgentDefinition(model_type="managed", model=model, instructions=instructions) + + with VoiceAgentsClient(endpoint=endpoint, credential=DefaultAzureCredential()) as client: + # Create the initial agent (this is version 1). + created = client.voice_agents.create_voice_agent( + name=agent_name, + definition=definition("You are a helpful voice assistant."), + foundry_features=preview, + ) + print(f"Created agent '{created.name}', latest version: {created.versions.latest.version}") + + # Create a new version with updated instructions. + new_version = client.voice_agents.create_voice_agent_version( + agent_name, + definition=definition("You are a helpful voice assistant. Always greet the caller by name."), + description="Added a personalized greeting.", + foundry_features=preview, + ) + print(f"Created new version: {new_version.version}") + + # Create a draft version. Drafts are recorded but excluded from the default + # 'latest' resolution and from version listings unless include_drafts=True. + draft_version = client.voice_agents.create_voice_agent_version( + agent_name, + definition=definition("You are a helpful voice assistant. Experimental draft persona."), + description="Candidate persona under review.", + draft=True, + foundry_features=preview, + ) + print(f"Created draft version: {draft_version.version}") + + # List released versions (drafts excluded by default). + print(f"Released versions of '{agent_name}':") + for version in client.voice_agents.list_voice_agent_versions(agent_name, foundry_features=preview): + print(f" - version {version.version} (created_at={version.created_at})") + + # List including drafts. + print(f"All versions of '{agent_name}' (including drafts):") + for version in client.voice_agents.list_voice_agent_versions( + agent_name, include_drafts=True, foundry_features=preview + ): + print(f" - version {version.version} (draft={version.draft})") + + # Read a single version back. + fetched = client.voice_agents.get_voice_agent_version(agent_name, new_version.version, foundry_features=preview) + print(f"Fetched version {fetched.version}: {fetched.definition.instructions}") + + # Clean up. + client.voice_agents.delete_voice_agent(agent_name, foundry_features=preview) + print(f"Deleted agent: {agent_name}") + + +if __name__ == "__main__": + manage_voice_agent_versions() diff --git a/sdk/voiceagents/azure-ai-voiceagents/samples/management/sample_read_conversation.py b/sdk/voiceagents/azure-ai-voiceagents/samples/management/sample_read_conversation.py new file mode 100644 index 000000000000..e86b3521aae9 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/samples/management/sample_read_conversation.py @@ -0,0 +1,103 @@ +# 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. +# -------------------------------------------------------------------------- + +""" +FILE: sample_read_conversation.py + +DESCRIPTION: + This sample demonstrates reading a persisted voice conversation back over the + read-only conversation API: the conversation envelope, its responses (model + inference turns), and its ordered items (the transcript). Conversations are + created and written by the voice orchestrator during a live session; this + client can only read them, and only when the agent was configured with + `store = true`. + +USAGE: + python sample_read_conversation.py + + Set these environment variables before running the sample: + 1) AZURE_VOICE_AGENTS_ENDPOINT - the Foundry project endpoint, in the form + https://.services.ai.azure.com/api/projects/ + 2) AZURE_VOICE_AGENTS_AGENT_NAME - the name of the voice agent. + 3) AZURE_VOICE_AGENTS_CONVERSATION_ID - the id of a persisted conversation + (captured from the `conversation.created` event during a live session). + + The sample authenticates with DefaultAzureCredential, so sign in first + (for example, with `az login`). +""" + +import os +from typing import Final + +from azure.core.exceptions import HttpResponseError +from azure.identity import DefaultAzureCredential + +from azure.ai.voiceagents import VoiceAgentsClient +from azure.ai.voiceagents.models import AgentDefinitionOptInKeys + + +def read_conversation() -> None: + endpoint = os.environ["AZURE_VOICE_AGENTS_ENDPOINT"] + agent_name = os.environ["AZURE_VOICE_AGENTS_AGENT_NAME"] + conversation_id = os.environ["AZURE_VOICE_AGENTS_CONVERSATION_ID"] + preview: Final = AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW + + with VoiceAgentsClient(endpoint=endpoint, credential=DefaultAzureCredential()) as client: + conversations = client.agent_endpoint_conversations + try: + # The conversation envelope: status, timestamps, aggregate usage. + conversation = conversations.get_agent_conversation(agent_name, conversation_id, foundry_features=preview) + print(f"Conversation {conversation.id}: status={conversation.status}, created_at={conversation.created_at}") + + # The responses (model inference turns) in the conversation. + print("Responses:") + for response in conversations.list_agent_conversation_responses( + agent_name, conversation_id, foundry_features=preview + ): + print(f" - {response.id}: status={response.status}") + + # Read a single response back, with its output and token usage. + detail = conversations.get_agent_conversation_response( + agent_name, conversation_id, response.id, foundry_features=preview + ) + print(f" usage={detail.usage}") + + # The items produced by this specific response. Conversation items + # belong to an open union, so on read they surface as mappings + # keyed by their wire fields (``type``, ``id``, ...). + for response_item in conversations.list_agent_conversation_response_items( + agent_name, conversation_id, response.id, foundry_features=preview + ): + print(f" item {response_item.get('type')} id={response_item.get('id')}") + + # The ordered conversation items -- the full transcript (user + assistant + tool events). + print("Items (transcript):") + for item in conversations.list_agent_conversation_items( + agent_name, conversation_id, foundry_features=preview + ): + item_id = item.get("id") + print(f" - {item.get('type')} id={item_id}") + + # Read a single item back by id. + if item_id: + single = conversations.get_agent_conversation_item( + agent_name, conversation_id, item_id, foundry_features=preview + ) + print(f" fetched item id={single.get('id')}") + + # Deleting a conversation removes it and all of its responses, items, and audio. + # This is destructive, so it is shown but not run by default. Uncomment to enable. + # deleted = conversations.delete_agent_conversation( + # agent_name, conversation_id, foundry_features=preview + # ) + # print(f"Deleted conversation {deleted.id}: deleted={deleted.deleted}") + except HttpResponseError as e: + # 404 typically means the conversation was not persisted (agent ran with `store = false`). + print(f"Service responded with an error: {e.status_code} {e.reason}") + + +if __name__ == "__main__": + read_conversation() diff --git a/sdk/voiceagents/azure-ai-voiceagents/samples/management/sample_read_conversation_audio.py b/sdk/voiceagents/azure-ai-voiceagents/samples/management/sample_read_conversation_audio.py new file mode 100644 index 000000000000..9dc60794e78f --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/samples/management/sample_read_conversation_audio.py @@ -0,0 +1,144 @@ +# 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. +# -------------------------------------------------------------------------- + +""" +FILE: sample_read_conversation_audio.py + +DESCRIPTION: + This sample demonstrates reading the persisted audio of a voice conversation, + both the merged whole-call recording and a single turn's audio segment. For + each it reads the metadata first, then streams the WAV bytes to a local file. + The merged recording is stereo: the caller on the left channel and the agent + on the right. + + Audio is available only after the session has ended and only when the agent + was configured with `store = true`. For bring-your-own-storage (BYOS) + accounts the metadata carries a `blob_uri` instead, and the bytes are read + from your own storage rather than streamed here. + +USAGE: + python sample_read_conversation_audio.py + + Set these environment variables before running the sample: + 1) AZURE_VOICE_AGENTS_ENDPOINT - the Foundry project endpoint, in the form + https://.services.ai.azure.com/api/projects/ + 2) AZURE_VOICE_AGENTS_AGENT_NAME - the name of the voice agent. + 3) AZURE_VOICE_AGENTS_CONVERSATION_ID - the id of a persisted conversation. + + The sample authenticates with DefaultAzureCredential, so sign in first + (for example, with `az login`). +""" + +import os +from typing import Final + +from azure.core.exceptions import HttpResponseError +from azure.identity import DefaultAzureCredential + +from azure.ai.voiceagents import VoiceAgentsClient +from azure.ai.voiceagents.models import AgentDefinitionOptInKeys + + +def read_conversation_audio() -> None: + endpoint = os.environ["AZURE_VOICE_AGENTS_ENDPOINT"] + agent_name = os.environ["AZURE_VOICE_AGENTS_AGENT_NAME"] + conversation_id = os.environ["AZURE_VOICE_AGENTS_CONVERSATION_ID"] + preview: Final = AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW + + with VoiceAgentsClient(endpoint=endpoint, credential=DefaultAzureCredential()) as client: + conversations = client.agent_endpoint_conversations + try: + read_merged_recording(conversations, agent_name, conversation_id, preview) + read_first_item_audio(conversations, agent_name, conversation_id, preview) + except HttpResponseError as e: + # 404: not persisted / not ready. 409: session still in progress. + print(f"Service responded with an error: {e.status_code} {e.reason}") + + +def stream_to_wav(stream, output_path) -> None: + """Write a streamed audio-content response to a local WAV file. + + :param stream: An iterable of audio byte chunks. + :param output_path: The local output path. + :type stream: collections.abc.Iterable[bytes] + :type output_path: str + """ + with open(output_path, "wb") as f: + for chunk in stream: + f.write(chunk) + print(f"Wrote {output_path}") + + +def read_merged_recording(conversations, agent_name, conversation_id, preview) -> None: + """Read the merged whole-call stereo recording (left=user, right=agent). + + :param conversations: The conversation operations client. + :param agent_name: The voice agent name. + :param conversation_id: The persisted conversation id. + :param preview: The preview feature opt-in value. + :type conversations: azure.ai.voiceagents.operations.AgentEndpointConversationsOperations + :type agent_name: str + :type conversation_id: str + :type preview: azure.ai.voiceagents.models.AgentDefinitionOptInKeys + """ + recording = conversations.get_agent_conversation_audio(agent_name, conversation_id, foundry_features=preview) + print( + f"Recording: format={recording.format}, sample_rate={recording.sample_rate}, " + f"channels={recording.channels}, duration_ms={recording.duration_ms}" + ) + + if recording.blob_uri: + # Bring-your-own-storage: download from your own storage using the returned URI. + print(f"Recording is stored in your own storage at: {recording.blob_uri}") + return + + # Foundry-managed storage: stream the bytes and write them to a local WAV file. + stream = conversations.get_agent_conversation_audio_content(agent_name, conversation_id, foundry_features=preview) + stream_to_wav(stream, f"{conversation_id}.wav") + + +def read_first_item_audio(conversations, agent_name, conversation_id, preview) -> None: + """Read the audio segment of the first conversation item that has one. + + :param conversations: The conversation operations client. + :param agent_name: The voice agent name. + :param conversation_id: The persisted conversation id. + :param preview: The preview feature opt-in value. + :type conversations: azure.ai.voiceagents.operations.AgentEndpointConversationsOperations + :type agent_name: str + :type conversation_id: str + :type preview: azure.ai.voiceagents.models.AgentDefinitionOptInKeys + """ + for item in conversations.list_agent_conversation_items(agent_name, conversation_id, foundry_features=preview): + item_id = item.get("id") + if not item_id: + continue + try: + metadata = conversations.get_agent_conversation_item_audio( + agent_name, conversation_id, item_id, foundry_features=preview + ) + except HttpResponseError as e: + # A 404 means this item has no persisted audio (for example, a text-only turn). + if e.status_code == 404: + continue + raise + + print(f"Item {item_id}: role={metadata.role}, duration_ms={metadata.duration_ms}") + if metadata.blob_uri: + print(f"Item audio is stored in your own storage at: {metadata.blob_uri}") + return + + stream = conversations.get_agent_conversation_item_audio_content( + agent_name, conversation_id, item_id, foundry_features=preview + ) + stream_to_wav(stream, f"{conversation_id}_{item_id}.wav") + return + + print("No conversation item with audio was found.") + + +if __name__ == "__main__": + read_conversation_audio() diff --git a/sdk/voiceagents/azure-ai-voiceagents/samples/quickstart/sample_quickstart_async.py b/sdk/voiceagents/azure-ai-voiceagents/samples/quickstart/sample_quickstart_async.py new file mode 100644 index 000000000000..dfa465d81ce8 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/samples/quickstart/sample_quickstart_async.py @@ -0,0 +1,226 @@ +# 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. +# -------------------------------------------------------------------------- + +""" +FILE: sample_quickstart_async.py + +DESCRIPTION: + Generate a temporary voice agent, start a live microphone/speaker realtime + conversation with it, then delete the agent when the sample exits. + + This is the shortest end-to-end path for trying voice agents with live audio: + management API for agent setup, realtime WebSocket API for the conversation. + + Requires ``pyaudio`` for microphone capture and speaker playback. + + pip install azure-ai-voiceagents azure-identity aiohttp pyaudio + +USAGE: + python sample_quickstart_async.py + + Environment variables: + 1) AZURE_VOICE_AGENTS_ENDPOINT (required) - Foundry project endpoint: + https://.services.ai.azure.com/api/projects/ + 2) AZURE_VOICE_AGENTS_MODEL (optional) - realtime model deployment name. + Defaults to "gpt-realtime". + + Runs until you press Ctrl-C. Authenticates with DefaultAzureCredential, so + sign in first (for example, with `az login`). +""" + +import asyncio +import os +import queue +import uuid +from typing import Any, Final, Optional + +from azure.core.exceptions import HttpResponseError +from azure.identity.aio import DefaultAzureCredential + +from azure.ai.voiceagents.aio import AsyncRealtimeConnection, VoiceAgentsClient +from azure.ai.voiceagents.models import ( + AgentDefinitionOptInKeys, + VoiceAgentType, + VoiceAgentUseCase, + VoiceAgentServerEventConversationItemInputAudioTranscriptionCompleted, + VoiceAgentServerEventError, + VoiceAgentServerEventInputAudioBufferSpeechStarted, + VoiceAgentServerEventResponseAudioDelta, + VoiceAgentServerEventResponseAudioTranscriptDone, + VoiceModelType, +) + +PREVIEW: Final = AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW +_SAMPLE_RATE: Final = 24000 +_CHUNK_SAMPLES: Final = 1200 + +try: + import pyaudio # type: ignore[import-not-found] +except ImportError: # pragma: no cover - required audio dependency + pyaudio: Any = None # type: ignore[no-redef] + + +class _AudioProcessor: + def __init__(self, connection: AsyncRealtimeConnection) -> None: + self._conn = connection + self._loop: Optional[asyncio.AbstractEventLoop] = None + self._audio = pyaudio.PyAudio() + self._playback_queue: "queue.Queue[tuple[int, Optional[bytes]]]" = queue.Queue() + self._playback_base = 0 + self._next_seq = 0 + self._input_stream = None + self._output_stream = None + + def start(self) -> None: + self._loop = asyncio.get_running_loop() + + def capture_callback(in_data, _frame_count, _time_info, _status): + assert self._loop is not None + asyncio.run_coroutine_threadsafe(self._conn.input_audio_buffer.append(audio=in_data), self._loop) + return (None, pyaudio.paContinue) + + self._input_stream = self._audio.open( + format=pyaudio.paInt16, + channels=1, + rate=_SAMPLE_RATE, + input=True, + frames_per_buffer=_CHUNK_SAMPLES, + stream_callback=capture_callback, + ) + + remaining = b"" + + def playback_callback(_in_data, frame_count, _time_info, _status): + nonlocal remaining + wanted = frame_count * pyaudio.get_sample_size(pyaudio.paInt16) + out = remaining[:wanted] + remaining = remaining[wanted:] + + while len(out) < wanted: + try: + seq, data = self._playback_queue.get_nowait() + except queue.Empty: + out += bytes(wanted - len(out)) + continue + if data is None: + break + if seq < self._playback_base: + remaining = b"" + continue + take = wanted - len(out) + out += data[:take] + remaining = data[take:] + + return (out, pyaudio.paContinue) + + self._output_stream = self._audio.open( + format=pyaudio.paInt16, + channels=1, + rate=_SAMPLE_RATE, + output=True, + frames_per_buffer=_CHUNK_SAMPLES, + stream_callback=playback_callback, + ) + + def queue_audio(self, pcm: bytes) -> None: + self._playback_queue.put((self._next_seq_num(), pcm)) + + def skip_pending_audio(self) -> None: + self._playback_base = self._next_seq_num() + + def close(self) -> None: + if self._input_stream is not None: + self._input_stream.stop_stream() + self._input_stream.close() + if self._output_stream is not None: + self.skip_pending_audio() + self._playback_queue.put((self._next_seq_num(), None)) + self._output_stream.stop_stream() + self._output_stream.close() + self._audio.terminate() + + def _next_seq_num(self) -> int: + seq = self._next_seq + self._next_seq += 1 + return seq + + +async def _generate_agent(client: VoiceAgentsClient, model: str) -> str: + agent_name = f"sample-quickstart-agent-{uuid.uuid4().hex[:8]}" + agent = await client.voice_agents.generate_voice_agent( + name=agent_name, + model_type=VoiceModelType.MANAGED, + model=model, + agent_type=VoiceAgentType.BUSINESS, + use_case=VoiceAgentUseCase.CUSTOMER_SUPPORT, + goal="Answer questions in a friendly voice. Keep replies short and natural.", + description="Temporary agent generated by the azure-ai-voiceagents quickstart.", + foundry_features=PREVIEW, + ) + print(f"Generated temporary voice agent: {agent.name}") + return agent.name + + +async def _delete_agent(client: VoiceAgentsClient, agent_name: str) -> None: + try: + await client.voice_agents.delete_voice_agent(agent_name, foundry_features=PREVIEW) + except HttpResponseError as exc: + if exc.response is None or exc.response.status_code != 200: + raise + print(f"Deleted temporary voice agent: {agent_name}") + + +async def _run_audio_session(client: VoiceAgentsClient, agent_name: str) -> None: + async with client.realtime.connect(agent_name=agent_name) as conn: + audio = _AudioProcessor(conn) + audio.start() + print("Speak now. Talk over the agent to interrupt it. Press Ctrl-C to stop.") + + try: + async for event in conn: + if isinstance(event, VoiceAgentServerEventInputAudioBufferSpeechStarted): + # Cancel the in-flight response before dropping audio that is + # still queued in the local speaker buffer. The service only + # supports output_audio_buffer.clear in avatar mode. + await conn.response.cancel() + audio.skip_pending_audio() + print("(listening...)") + elif isinstance(event, VoiceAgentServerEventConversationItemInputAudioTranscriptionCompleted): + print(f"You: {event.transcript.strip()}") + elif isinstance(event, VoiceAgentServerEventResponseAudioDelta): + audio.queue_audio(event.delta) + elif isinstance(event, VoiceAgentServerEventResponseAudioTranscriptDone): + print(f"Agent: {event.transcript}") + elif isinstance(event, VoiceAgentServerEventError): + print(f"Session error: {event.error.message}") + finally: + audio.close() + + +async def main() -> None: + if pyaudio is None: + print("This quickstart needs pyaudio for microphone and speaker audio: pip install pyaudio") + return + + endpoint = os.environ["AZURE_VOICE_AGENTS_ENDPOINT"] + model = os.environ.get("AZURE_VOICE_AGENTS_MODEL", "gpt-realtime") + agent_name: Optional[str] = None + + async with DefaultAzureCredential() as credential, VoiceAgentsClient( + endpoint=endpoint, credential=credential + ) as client: + try: + agent_name = await _generate_agent(client, model) + await _run_audio_session(client, agent_name) + except (KeyboardInterrupt, asyncio.CancelledError): + print("\nStopping quickstart...") + finally: + if agent_name is not None: + await _delete_agent(client, agent_name) + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/sdk/voiceagents/azure-ai-voiceagents/test-resources.json b/sdk/voiceagents/azure-ai-voiceagents/test-resources.json new file mode 100644 index 000000000000..e3ca8f7e7422 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/test-resources.json @@ -0,0 +1,566 @@ +{ + "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "baseName": { + "type": "string", + "defaultValue": "[resourceGroup().name]", + "metadata": { + "description": "The base resource name for AI Services." + } + }, + "location": { + "type": "string", + "defaultValue": "[resourceGroup().location]", + "metadata": { + "description": "The location of the resource. By default, this is the same as the resource group." + } + }, + "tenantId": { + "type": "string", + "defaultValue": "72f988bf-86f1-41af-91ab-2d7cd011db47", + "metadata": { + "description": "The tenant ID to which the application and resources belong." + } + }, + "testApplicationOid": { + "type": "string", + "defaultValue": "b3653439-8136-4cd5-aac3-2a9460871ca6", + "metadata": { + "description": "The client OID to grant access to test resources." + } + }, + "tagValues": { + "type": "object", + "defaultValue": {} + }, + "allowProjectManagement": { + "type": "bool", + "defaultValue": true + }, + "virtualNetworkType": { + "type": "string", + "defaultValue": "None" + }, + "vnet": { + "type": "object", + "defaultValue": {} + }, + "ipRules": { + "type": "array", + "defaultValue": [] + }, + "privateEndpoints": { + "type": "array", + "defaultValue": [] + }, + "privateDnsZone": { + "type": "string", + "defaultValue": "privatelink.aiservices.azure.com" + }, + "resourceGroupName": { + "type": "string", + "defaultValue": "[resourceGroup().name]" + }, + "resourceGroupId": { + "type": "string", + "defaultValue": "[resourceGroup().id]" + }, + "uniqueId": { + "type": "string", + "defaultValue": "[newGuid()]" + }, + "defaultProjectName": { + "type": "string", + "defaultValue": "[concat(toLower(parameters('baseName')), '-ai-defaultproject')]" + }, + "identity": { + "type": "object", + "defaultValue": { + "type": "SystemAssigned" + } + }, + "userAssignedIdentityName": { + "type": "string", + "defaultValue": "" + }, + "userIdentityResourceGroupName": { + "type": "string", + "defaultValue": "" + }, + "identityType": { + "type": "string", + "defaultValue": "SystemAssigned" + }, + "encryption_status": { + "type": "string", + "defaultValue": " " + }, + "cmk_keyvault": { + "type": "string", + "defaultValue": "" + }, + "resource_cmk_uri": { + "type": "string", + "defaultValue": "" + }, + "userAssignedIdentityId": { + "type": "string", + "defaultValue": "" + }, + "keyVaultName": { + "type": "string", + "defaultValue": "" + }, + "keyVaultLocation": { + "type": "string", + "defaultValue": "" + }, + "keyVaultResourceGroupName": { + "type": "string", + "defaultValue": "" + }, + "keyVersion": { + "type": "string", + "defaultValue": "" + }, + "keyName": { + "type": "string", + "defaultValue": "" + }, + "hasRoleAssignment": { + "type": "bool", + "defaultValue": false + }, + "roleDefinitionId": { + "type": "string", + "defaultValue": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '53ca6127-db72-4b80-b1b0-d745d6d5456d')]" + }, + "enableRbac": { + "type": "bool", + "defaultValue": false + }, + "cryptoUserRoleAssignmentName": { + "type": "string", + "defaultValue": "[guid(concat(parameters('cmk_keyvault'), 'KeyVaultCryptoUser'))]" + } + }, + "variables": { + "aiServicesName": "[concat(parameters('baseName'), '-ai')]" + }, + "resources": [ + { + "type": "Microsoft.Resources/deployments", + "apiVersion": "2017-05-10", + "name": "deployVnet", + "properties": { + "mode": "Incremental", + "template": { + "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": {}, + "variables": {}, + "resources": [ + { + "type": "Microsoft.Network/virtualNetworks", + "apiVersion": "2020-04-01", + "name": "[if(equals(parameters('virtualNetworkType'), 'External'), parameters('vnet').name, variables('defaultVNetName'))]", + "location": "[parameters('location')]", + "properties": { + "addressSpace": { + "addressPrefixes": "[if(equals(parameters('virtualNetworkType'), 'External'), parameters('vnet').addressPrefixes, json(concat('[{\"', variables('defaultAddressPrefix'),'\"}]')))]" + }, + "subnets": [ + { + "name": "[if(equals(parameters('virtualNetworkType'), 'External'), parameters('vnet').subnets.subnet.name, variables('defaultSubnetName'))]", + "properties": { + "serviceEndpoints": [ + { + "service": "Microsoft.CognitiveServices", + "locations": [ + "[parameters('location')]" + ] + } + ], + "addressPrefix": "[if(equals(parameters('virtualNetworkType'), 'External'), parameters('vnet').subnets.subnet.addressPrefix, variables('defaultAddressPrefix'))]" + } + } + ] + } + } + ] + }, + "parameters": {} + }, + "condition": "[and(and(not(empty(parameters('vnet'))), equals(parameters('vnet').newOrExisting, 'new')), equals(parameters('virtualNetworkType'), 'External'))]" + }, + { + "apiVersion": "2025-04-01-preview", + "name": "[variables('aiServicesName')]", + "location": "[parameters('location')]", + "type": "Microsoft.CognitiveServices/accounts", + "kind": "AIServices", + "sku": { + "name": "S0" + }, + "identity": "[parameters('identity')]", + "tags": "[if(contains(parameters('tagValues'), 'Microsoft.CognitiveServices/accounts'), parameters('tagValues')['Microsoft.CognitiveServices/accounts'], json('{}'))]", + "properties": { + "customSubDomainName": "[toLower(variables('aiServicesName'))]", + "defaultProjectName": "[toLower(variables('aiServicesName'))]", + "publicNetworkAccess": "[if(equals(parameters('virtualNetworkType'), 'Internal'), 'Disabled', 'Enabled')]", + "networkAcls": { + "defaultAction": "[if(equals(parameters('virtualNetworkType'), 'External'), 'Deny', 'Allow')]", + "virtualNetworkRules": "[if(equals(parameters('virtualNetworkType'), 'External'), json(concat('[{\"id\": \"', concat(subscription().id, '/resourceGroups/', parameters('vnet').resourceGroup, '/providers/Microsoft.Network/virtualNetworks/', parameters('vnet').name, '/subnets/', parameters('vnet').subnets.subnet.name), '\"}]')), json('[]'))]", + "ipRules": "[if(or(empty(parameters('ipRules')), empty(parameters('ipRules')[0].value)), json('[]'), parameters('ipRules'))]" + }, + "identity": "[parameters('identity')]", + "userAssignedIdentityName": "[if(equals(parameters('identity').type, 'UserAssigned'), parameters('userAssignedIdentityName'), json('null'))]", + "userIdentityResourceGroupName": "[if(equals(parameters('identity').type, 'UserAssigned'), parameters('userIdentityResourceGroupName'), json('null'))]", + "encryption_status": "[parameters('encryption_status')]", + "keyVaultName": "[parameters('keyVaultName')]", + "keyVaultLocation": "[parameters('keyVaultLocation')]", + "keyVaultResourceGroupName": "[parameters('keyVaultResourceGroupName')]", + "cmk_keyvault": "[parameters('cmk_keyvault')]", + "resource_cmk_uri": "[parameters('resource_cmk_uri')]", + "keyVersion": "[parameters('keyVersion')]", + "allowProjectManagement": "[parameters('allowProjectManagement')]" + }, + "resources": [ + { + "type": "projects", + "apiVersion": "2025-04-01-preview", + "name": "[parameters('defaultProjectName')]", + "location": "[parameters('location')]", + "identity": { + "type": "SystemAssigned" + }, + "sku": { + "name": "S0" + }, + "properties": { + "displayName": "[parameters('defaultProjectName')]", + "description": "Default project created with the resource" + }, + "dependsOn": [ + "[resourceId('Microsoft.CognitiveServices/accounts', variables('aiServicesName'))]" + ] + } + ], + "dependsOn": [ + "[concat('Microsoft.Resources/deployments/', 'deployVnet')]" + ] + }, + { + "type": "Microsoft.Resources/deployments", + "name": "[concat('patchAccessPolicy-', parameters('keyVaultName'))]", + "apiVersion": "2021-04-01", + "condition": "[and(equals(parameters('enableRbac'), bool('false')), equals(parameters('encryption_status'), 'Enabled'))]", + "resourceGroup": "[parameters('keyVaultResourceGroupName')]", + "properties": { + "mode": "Incremental", + "template": { + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "resources": [ + { + "type": "Microsoft.KeyVault/vaults/accessPolicies", + "apiVersion": "2019-09-01", + "name": "[concat(parameters('keyVaultName'), '/add')]", + "properties": { + "accessPolicies": [ + { + "tenantId": "[subscription().tenantId]", + "objectId": "[reference(resourceId('Microsoft.CognitiveServices/accounts', variables('aiServicesName')), '2025-04-01-preview', 'Full').identity.principalId]", + "permissions": { + "keys": [ + "get", + "wrapKey", + "unwrapKey" + ] + } + } + ] + } + } + ] + } + }, + "dependsOn": [ + "[resourceId('Microsoft.CognitiveServices/accounts', variables('aiServicesName'))]" + ] + }, + { + "type": "Microsoft.Authorization/roleAssignments", + "apiVersion": "2022-04-01", + "name": "[guid(concat(parameters('cmk_keyvault'), '-', variables('aiServicesName'), 'KeyVaultCryptoUser'))]", + "scope": "[parameters('cmk_keyvault')]", + "condition": "[and(equals(parameters('hasRoleAssignment'), bool('true')), equals(parameters('enableRbac'), bool('true')))]", + "properties": { + "roleDefinitionId": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '14b46e9e-c2b7-41b4-b07b-48a6ebf60603')]", + "principalId": "[reference(resourceId('Microsoft.CognitiveServices/accounts', variables('aiServicesName')), '2025-04-01-preview', 'Full').identity.principalId]" + }, + "dependsOn": [ + "[resourceId('Microsoft.CognitiveServices/accounts', variables('aiServicesName'))]" + ] + }, + { + "type": "Microsoft.Resources/deployments", + "apiVersion": "2021-04-01", + "name": "patchCMKEncryption", + "condition": "[and(equals(parameters('enableRbac'), bool('false')), equals(parameters('encryption_status'), 'Enabled'))]", + "dependsOn": [ + "[concat('patchAccessPolicy-', parameters('keyVaultName'))]" + ], + "properties": { + "mode": "Incremental", + "template": { + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "resources": [ + { + "type": "Microsoft.CognitiveServices/accounts", + "apiVersion": "2025-04-01-preview", + "name": "[variables('aiServicesName')]", + "location": "[parameters('location')]", + "kind": "AIServices", + "sku": { + "name": "S0" + }, + "properties": { + "customSubDomainName": "[toLower(variables('aiServicesName'))]", + "publicNetworkAccess": "[if(equals(parameters('virtualNetworkType'), 'Internal'), 'Disabled', 'Enabled')]", + "networkAcls": { + "defaultAction": "[if(equals(parameters('virtualNetworkType'), 'External'), 'Deny', 'Allow')]", + "virtualNetworkRules": [], + "ipRules": [] + }, + "encryption": { + "status": "[parameters('encryption_status')]", + "keySource": "Microsoft.Keyvault", + "keyVaultProperties": { + "keyName": "[parameters('keyName')]", + "keyVersion": "[parameters('keyVersion')]", + "keyVaultUri": "[reference(parameters('cmk_keyvault'), '2021-04-01-preview').vaultUri]", + "identityClientId": "[json('null')]" + } + } + } + } + ] + } + } + }, + { + "type": "Microsoft.Resources/deployments", + "apiVersion": "2021-04-01", + "name": "patchCMKEncryptionWithRbac", + "condition": "[and(equals(parameters('enableRbac'), bool('true')), equals(parameters('encryption_status'), 'Enabled'))]", + "dependsOn": [ + "[resourceId('Microsoft.CognitiveServices/accounts', variables('aiServicesName'))]", + "[concat('Microsoft.KeyVault/vaults/', parameters('keyVaultName'), '/providers/Microsoft.Authorization/roleAssignments/', guid(concat(parameters('cmk_keyvault'), '-', variables('aiServicesName'), 'KeyVaultCryptoUser')))]" + ], + "properties": { + "mode": "Incremental", + "template": { + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "resources": [ + { + "type": "Microsoft.CognitiveServices/accounts", + "apiVersion": "2025-04-01-preview", + "name": "[variables('aiServicesName')]", + "location": "[parameters('location')]", + "kind": "AIServices", + "sku": { + "name": "S0" + }, + "properties": { + "customSubDomainName": "[toLower(variables('aiServicesName'))]", + "publicNetworkAccess": "[if(equals(parameters('virtualNetworkType'), 'Internal'), 'Disabled', 'Enabled')]", + "networkAcls": { + "defaultAction": "[if(equals(parameters('virtualNetworkType'), 'External'), 'Deny', 'Allow')]", + "virtualNetworkRules": [], + "ipRules": [] + }, + "identity": { + "type": "SystemAssigned" + }, + "encryption": { + "status": "[parameters('encryption_status')]", + "keySource": "Microsoft.Keyvault", + "keyVaultProperties": { + "keyName": "[parameters('keyName')]", + "keyVersion": "[parameters('keyVersion')]", + "keyVaultUri": "[reference(parameters('cmk_keyvault'), '2021-04-01-preview').vaultUri]", + "identityClientId": "[json('null')]" + } + } + } + } + ] + } + } + }, + { + "apiVersion": "2018-05-01", + "name": "[concat('deployPrivateEndpoint-', parameters('privateEndpoints')[copyIndex()].privateEndpointConfiguration.privateEndpoint.name)]", + "type": "Microsoft.Resources/deployments", + "resourceGroup": "[parameters('privateEndpoints')[copyIndex()].privateEndpointConfiguration.resourceGroup.value.name]", + "subscriptionId": "[parameters('privateEndpoints')[copyIndex()].privateEndpointConfiguration.subscription.subscriptionId]", + "dependsOn": [ + "[concat('Microsoft.CognitiveServices/accounts/', variables('aiServicesName'))]" + ], + "condition": "[equals(parameters('virtualNetworkType'), 'Internal')]", + "copy": { + "name": "privateendpointscopy", + "count": "[length(parameters('privateEndpoints'))]" + }, + "properties": { + "mode": "Incremental", + "template": { + "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "resources": [ + { + "location": "[parameters('privateEndpoints')[copyIndex()].privateEndpointConfiguration.privateEndpoint.location]", + "name": "[parameters('privateEndpoints')[copyIndex()].privateEndpointConfiguration.privateEndpoint.name]", + "type": "Microsoft.Network/privateEndpoints", + "apiVersion": "2021-05-01", + "properties": { + "subnet": { + "id": "[parameters('privateEndpoints')[copyIndex()].privateEndpointConfiguration.privateEndpoint.properties.subnet.id]" + }, + "privateLinkServiceConnections": [ + { + "name": "[parameters('privateEndpoints')[copyIndex()].privateEndpointConfiguration.privateEndpoint.name]", + "properties": { + "privateLinkServiceId": "[concat(parameters('resourceGroupId'), '/providers/Microsoft.CognitiveServices/accounts/', variables('aiServicesName'))]", + "groupIds": "[parameters('privateEndpoints')[copyIndex()].privateEndpointConfiguration.privateEndpoint.properties.privateLinkServiceConnections[0].properties.groupIds]" + } + } + ], + "customNetworkInterfaceName": "[concat(parameters('privateEndpoints')[copyIndex()].privateEndpointConfiguration.privateEndpoint.name, '-nic')]" + }, + "tags": {} + } + ] + } + } + }, + { + "apiVersion": "2018-05-01", + "name": "[concat('deployDnsZoneGroup-', parameters('privateEndpoints')[copyIndex()].privateEndpointConfiguration.privateEndpoint.name)]", + "type": "Microsoft.Resources/deployments", + "resourceGroup": "[parameters('privateEndpoints')[copyIndex()].privateEndpointConfiguration.resourceGroup.value.name]", + "subscriptionId": "[parameters('privateEndpoints')[copyIndex()].privateEndpointConfiguration.subscription.subscriptionId]", + "dependsOn": [ + "[concat('deployPrivateEndpoint-', parameters('privateEndpoints')[copyIndex()].privateEndpointConfiguration.privateEndpoint.name)]" + ], + "condition": "[and(equals(parameters('virtualNetworkType'), 'Internal'), parameters('privateEndpoints')[copyIndex()].privateDnsZoneConfiguration.integrateWithPrivateDnsZone)]", + "copy": { + "name": "privateendpointdnscopy", + "count": "[length(parameters('privateEndpoints'))]" + }, + "properties": { + "mode": "Incremental", + "template": { + "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "resources": [ + { + "type": "Microsoft.Network/privateDnsZones", + "apiVersion": "2018-09-01", + "name": "[parameters('privateDnsZone')]", + "location": "global", + "tags": {}, + "properties": {} + }, + { + "type": "Microsoft.Network/privateDnsZones/virtualNetworkLinks", + "apiVersion": "2018-09-01", + "name": "[concat(parameters('privateDnsZone'), '/', replace(uniqueString(parameters('privateEndpoints')[copyIndex()].privateEndpointConfiguration.privateEndpoint.properties.subnet.id), '/subnets/default', ''))]", + "location": "global", + "dependsOn": [ + "[parameters('privateDnsZone')]" + ], + "properties": { + "virtualNetwork": { + "id": "[split(parameters('privateEndpoints')[copyIndex()].privateEndpointConfiguration.privateEndpoint.properties.subnet.id, '/subnets/')[0]]" + }, + "registrationEnabled": false + } + }, + { + "apiVersion": "2017-05-10", + "name": "[concat('EndpointDnsRecords-', parameters('privateEndpoints')[copyIndex()].privateEndpointConfiguration.privateEndpoint.name)]", + "type": "Microsoft.Resources/deployments", + "dependsOn": [ + "[parameters('privateDnsZone')]" + ], + "properties": { + "mode": "Incremental", + "templatelink": { + "uri": "https://go.microsoft.com/fwlink/?linkid=2264916" + }, + "parameters": { + "privateDnsName": { + "value": "[parameters('privateDnsZone')]" + }, + "privateEndpointNicResourceId": { + "value": "[concat('/subscriptions/', parameters('privateEndpoints')[copyIndex()].privateEndpointConfiguration.subscription.subscriptionId, '/resourceGroups/', parameters('privateEndpoints')[copyIndex()].privateEndpointConfiguration.resourceGroup.value.name, '/providers/Microsoft.Network/networkInterfaces/', parameters('privateEndpoints')[copyIndex()].privateEndpointConfiguration.privateEndpoint.name, '-nic')]" + }, + "nicRecordsTemplateUri": { + "value": "https://go.microsoft.com/fwlink/?linkid=2264719" + }, + "ipConfigRecordsTemplateUri": { + "value": "https://go.microsoft.com/fwlink/?linkid=2265018" + }, + "uniqueId": { + "value": "[parameters('uniqueId')]" + }, + "existingRecords": { + "value": {} + } + } + } + }, + { + "type": "Microsoft.Network/privateEndpoints/privateDnsZoneGroups", + "apiVersion": "2020-03-01", + "name": "[concat(parameters('privateEndpoints')[copyIndex()].privateEndpointConfiguration.privateEndpoint.name, '/', 'default')]", + "location": "[parameters('location')]", + "dependsOn": [ + "[parameters('privateDnsZone')]" + ], + "properties": { + "privateDnsZoneConfigs": [ + { + "name": "privatelink-cognitiveservices", + "properties": { + "privateDnsZoneId": "[concat(parameters('resourceGroupId'), '/providers/Microsoft.Network/privateDnsZones/', parameters('privateDnsZone'))]" + } + } + ] + } + } + ] + } + } + } + ], + "outputs": { + "AI_SERVICES_NAME": { + "type": "string", + "value": "[variables('aiServicesName')]" + }, + "AI_SERVICES_ENDPOINT": { + "type": "string", + "value": "[reference(resourceId('Microsoft.CognitiveServices/accounts', variables('aiServicesName'))).endpoints['AI Foundry API']]" + }, + "AI_SERVICES_KEY": { + "type": "string", + "value": "[listKeys(resourceId('Microsoft.CognitiveServices/accounts', variables('aiServicesName')), '2025-04-01-preview').key1]" + } + } +} \ No newline at end of file diff --git a/sdk/voiceagents/azure-ai-voiceagents/tests/conftest.py b/sdk/voiceagents/azure-ai-voiceagents/tests/conftest.py new file mode 100644 index 000000000000..371671c2e8cd --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/tests/conftest.py @@ -0,0 +1,15 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +import pytest +from devtools_testutils import test_proxy # noqa: F401 pylint: disable=unused-import + + +@pytest.fixture(scope="session", autouse=True) +def start_proxy(test_proxy): # pylint: disable=redefined-outer-name + """Starts the test proxy server for the whole test session. + + See https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/tests.md + """ + return diff --git a/sdk/voiceagents/azure-ai-voiceagents/tests/live/conftest.py b/sdk/voiceagents/azure-ai-voiceagents/tests/live/conftest.py new file mode 100644 index 000000000000..ae8f36c9b21b --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/tests/live/conftest.py @@ -0,0 +1,17 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Overrides the parent (recorded-test) conftest for the live test suite. + +The live smoke test never goes through the test proxy (see test_smoke_live.py), +so it doesn't need the autouse ``start_proxy`` fixture from ../conftest.py. +This shadows that fixture so running ``pytest tests/live`` alone never tries +to download/start the proxy. +""" +import pytest + + +@pytest.fixture(scope="session", autouse=True) +def start_proxy(): + return diff --git a/sdk/voiceagents/azure-ai-voiceagents/tests/live/test_voice_agents_management.py b/sdk/voiceagents/azure-ai-voiceagents/tests/live/test_voice_agents_management.py new file mode 100644 index 000000000000..13d5e21e84ee --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/tests/live/test_voice_agents_management.py @@ -0,0 +1,101 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Live management tests for voice agents. + +These tests exercise operations whose current service status codes match the +TypeSpec-generated client. Agent deletion is cleanup only because the service +currently returns 200 while the generated client expects 204. +""" +import os +import uuid + +import pytest +from azure.core.exceptions import HttpResponseError +from azure.identity import DefaultAzureCredential + +from azure.ai.voiceagents import VoiceAgentsClient +from azure.ai.voiceagents.models import ( + AgentDefinitionOptInKeys, + AzureStandardVoice, + VoiceAgentDefinition, + VoiceAgentType, + VoiceAgentUseCase, + VoiceAudioConfig, + VoiceAudioOutputConfig, + VoiceModelType, + VoiceOutputModality, +) + +PREVIEW = AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW + +pytestmark = [ + pytest.mark.live_test_only, + pytest.mark.skipif( + os.environ.get("AZURE_TEST_RUN_LIVE", "false").lower() != "true", + reason="Live tests only run when AZURE_TEST_RUN_LIVE=true.", + ), +] + + +def _endpoint() -> str: + return os.environ.get("AZURE_VOICE_AGENTS_ENDPOINT") or os.environ["AI_SERVICES_ENDPOINT"] + + +def _definition(model: str, instructions: str) -> VoiceAgentDefinition: + return VoiceAgentDefinition( + model_type=VoiceModelType.MANAGED, + model=model, + instructions=instructions, + audio=VoiceAudioConfig(output=VoiceAudioOutputConfig(voice=AzureStandardVoice(name="en-US-AvaNeural"))), + output_modalities=[VoiceOutputModality.AUDIO], + store=False, + ) + + +def _delete_agent_for_cleanup(client: VoiceAgentsClient, agent_name: str) -> None: + try: + client.voice_agents.delete_voice_agent(agent_name, foundry_features=PREVIEW) + except HttpResponseError as exc: + if exc.response is None or exc.response.status_code not in (200, 404): + raise + + +def test_generate_get_list_update_enable_disable_voice_agent(): + """Exercise supported voice agent management operations against a live project.""" + model = os.environ.get("AZURE_VOICE_AGENTS_MODEL", "gpt-realtime") + agent_name = f"test-voice-management-{uuid.uuid4().hex[:8]}" + + with DefaultAzureCredential() as credential, VoiceAgentsClient(endpoint=_endpoint(), credential=credential) as client: + try: + generated = client.voice_agents.generate_voice_agent( + name=agent_name, + model_type=VoiceModelType.MANAGED, + model=model, + agent_type=VoiceAgentType.BUSINESS, + use_case=VoiceAgentUseCase.CUSTOMER_SUPPORT, + goal="Answer questions in a friendly voice. Keep replies short and natural.", + foundry_features=PREVIEW, + ) + assert generated["name"] == agent_name + + fetched = client.voice_agents.get_voice_agent(agent_name, foundry_features=PREVIEW) + assert fetched["state"] == "enabled" + assert any(item["name"] == agent_name for item in client.voice_agents.list_voice_agents(foundry_features=PREVIEW)) + + updated = client.voice_agents.update_voice_agent( + agent_name, + definition=_definition(model, "Greet callers warmly and keep replies concise."), + description="Updated by a live management test.", + foundry_features=PREVIEW, + ) + assert updated["name"] == agent_name + + client.voice_agents.disable_voice_agent(agent_name, foundry_features=PREVIEW) + assert client.voice_agents.get_voice_agent(agent_name, foundry_features=PREVIEW)["state"] == "disabled" + + client.voice_agents.enable_voice_agent(agent_name, foundry_features=PREVIEW) + assert client.voice_agents.get_voice_agent(agent_name, foundry_features=PREVIEW)["state"] == "enabled" + finally: + _delete_agent_for_cleanup(client, agent_name) \ No newline at end of file diff --git a/sdk/voiceagents/azure-ai-voiceagents/tests/live/test_voice_agents_realtime.py b/sdk/voiceagents/azure-ai-voiceagents/tests/live/test_voice_agents_realtime.py new file mode 100644 index 000000000000..aaf301cb2fc1 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/tests/live/test_voice_agents_realtime.py @@ -0,0 +1,83 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Live realtime WebSocket tests for voice agents.""" +import asyncio +import os +import uuid + +import pytest +from azure.core.exceptions import HttpResponseError +from azure.identity.aio import DefaultAzureCredential + +from azure.ai.voiceagents.aio import VoiceAgentsClient +from azure.ai.voiceagents.models import ( + AgentDefinitionOptInKeys, + RealtimeConversationItemMessageUser, + RealtimeConversationItemMessageUserContent, + VoiceAgentServerEventError, + VoiceAgentServerEventResponseDone, + VoiceAgentType, + VoiceAgentUseCase, + VoiceModelType, +) + +PREVIEW = AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW + +pytestmark = [ + pytest.mark.live_test_only, + pytest.mark.skipif( + os.environ.get("AZURE_TEST_RUN_LIVE", "false").lower() != "true", + reason="Live tests only run when AZURE_TEST_RUN_LIVE=true.", + ), +] + + +async def _delete_agent_for_cleanup(client: VoiceAgentsClient, agent_name: str) -> None: + try: + await client.voice_agents.delete_voice_agent(agent_name, foundry_features=PREVIEW) + except HttpResponseError as exc: + if exc.response is None or exc.response.status_code not in (200, 404): + raise + + +@pytest.mark.asyncio +async def test_realtime_typed_turn(): + """Generate an agent, stream one typed turn, and receive a completed response.""" + endpoint = os.environ.get("AZURE_VOICE_AGENTS_ENDPOINT") or os.environ["AI_SERVICES_ENDPOINT"] + model = os.environ.get("AZURE_VOICE_AGENTS_MODEL", "gpt-realtime") + agent_name = f"test-voice-stream-{uuid.uuid4().hex[:8]}" + + async with DefaultAzureCredential() as credential, VoiceAgentsClient(endpoint=endpoint, credential=credential) as client: + try: + await client.voice_agents.generate_voice_agent( + name=agent_name, + model_type=VoiceModelType.MANAGED, + model=model, + agent_type=VoiceAgentType.BUSINESS, + use_case=VoiceAgentUseCase.CUSTOMER_SUPPORT, + goal="Reply with a short, friendly greeting.", + foundry_features=PREVIEW, + ) + + async with client.realtime.connect(agent_name=agent_name) as connection: + await connection.conversation.item.create( + item=RealtimeConversationItemMessageUser( + content=[RealtimeConversationItemMessageUserContent(type="input_text", text="Hello")] + ) + ) + await connection.response.create() + + async def wait_for_response_done(): + async for event in connection: + if isinstance(event, VoiceAgentServerEventError): + raise AssertionError(f"Realtime service error: {event.error.message}") + if isinstance(event, VoiceAgentServerEventResponseDone): + return event + raise AssertionError("Realtime connection closed before the response completed.") + + response = await asyncio.wait_for(wait_for_response_done(), timeout=45) + assert response.response["status"] == "completed" + finally: + await _delete_agent_for_cleanup(client, agent_name) \ No newline at end of file diff --git a/sdk/voiceagents/azure-ai-voiceagents/tests/recording/_preparer.py b/sdk/voiceagents/azure-ai-voiceagents/tests/recording/_preparer.py new file mode 100644 index 000000000000..5a189f30208b --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/tests/recording/_preparer.py @@ -0,0 +1,26 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Shared fixtures for the recorded and live test suites in this package.""" +import functools + +from devtools_testutils import EnvironmentVariableLoader + +from azure.ai.voiceagents.models import AgentDefinitionOptInKeys + +# All voice agent operations currently require this preview feature opt-in. +PREVIEW = AgentDefinitionOptInKeys.VOICE_AGENTS_V1_PREVIEW + +# Loads the real environment variables in live mode, and sanitizes them to the +# values below when recording (so secrets/identifiers never end up in the +# checked-in cassette) and in playback (so recorded interactions can be +# matched). Kwarg names are uppercased to get the real environment variable +# name, e.g. azure_voice_agents_endpoint -> AZURE_VOICE_AGENTS_ENDPOINT. +VoiceAgentsPreparer = functools.partial( + EnvironmentVariableLoader, + "", + azure_voice_agents_endpoint="https://sanitized-account.services.ai.azure.com/api/projects/sanitized-project", + azure_voice_agents_agent_name="sanitized-agent-name", + azure_voice_agents_conversation_id="sanitized-conversation-id", +) diff --git a/sdk/voiceagents/azure-ai-voiceagents/tests/recording/conftest.py b/sdk/voiceagents/azure-ai-voiceagents/tests/recording/conftest.py new file mode 100644 index 000000000000..0aac7adf0b65 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/tests/recording/conftest.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Extra sanitization for this package's recordings. + +The test-proxy's default sanitizers redact the account-name portion of the +recorded request URI's host (e.g. "voice-live-tip-resource" -> "Sanitized"), +but they don't know about the Foundry project name embedded later in the +path ("/api/projects/{project-name}"). Without an explicit sanitizer for it, +the real project name would leak into the checked-in recording. This +sanitizer redacts that path segment regardless of what happens to the host. +""" +import pytest +from devtools_testutils import add_uri_regex_sanitizer, test_proxy # noqa: F401 pylint: disable=unused-import + + +@pytest.fixture(scope="session", autouse=True) +def add_project_name_sanitizer(test_proxy): # pylint: disable=redefined-outer-name + add_uri_regex_sanitizer(regex=r"/api/projects/[^/?]+", value="/api/projects/sanitized-project") diff --git a/sdk/voiceagents/azure-ai-voiceagents/tests/recording/test_voice_agents_client.py b/sdk/voiceagents/azure-ai-voiceagents/tests/recording/test_voice_agents_client.py new file mode 100644 index 000000000000..14b6f268ac96 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/tests/recording/test_voice_agents_client.py @@ -0,0 +1,112 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Recorded functional tests for the sync VoiceAgentsClient. + +These exercise only read-only (GET/LIST) operations against a pre-existing +voice agent and a pre-existing, persisted conversation -- both supplied via +environment variables (see ../../samples/README.md). Agent/conversation creation +and deletion are intentionally out of scope: at the time this suite was +written, the create (expects 201) and delete (expects 204) operations did not +match what the live test service actually returns (200), so recording those +calls would bake an unrelated, known service issue into the checked-in +cassette. See /memories/repo notes for details. +""" +from devtools_testutils import AzureRecordedTestCase, recorded_by_proxy + +from azure.ai.voiceagents import VoiceAgentsClient + +from _preparer import PREVIEW, VoiceAgentsPreparer + + +class TestVoiceAgentsClient(AzureRecordedTestCase): + def create_client(self, endpoint: str) -> VoiceAgentsClient: + credential = self.get_credential(VoiceAgentsClient) + return self.create_client_from_credential(VoiceAgentsClient, credential=credential, endpoint=endpoint) + + @VoiceAgentsPreparer() + @recorded_by_proxy + def test_get_voice_agent(self, azure_voice_agents_endpoint, azure_voice_agents_agent_name): + with self.create_client(azure_voice_agents_endpoint) as client: + agent = client.voice_agents.get_voice_agent(azure_voice_agents_agent_name, foundry_features=PREVIEW) + + # NOTE: don't assert agent["name"]/["id"] against azure_voice_agents_agent_name -- + # the test-proxy's built-in default sanitizers always redact "id"/"name" body + # fields to a generic value in playback, regardless of our own sanitizers. + assert agent["object"] == "agent" + assert agent["state"] in ("enabled", "disabled") + + # NOTE: list_voice_agents is intentionally not recorded here. Against a shared + # test resource, it returns every agent's full definition (including real + # subscription IDs, resource groups, connection IDs, and other agents' + # instructions), which can't be generically sanitized. See the live smoke + # test / manual testing for that operation instead. + + @VoiceAgentsPreparer() + @recorded_by_proxy + def test_get_agent_conversation( + self, azure_voice_agents_endpoint, azure_voice_agents_agent_name, azure_voice_agents_conversation_id + ): + with self.create_client(azure_voice_agents_endpoint) as client: + conversation = client.agent_endpoint_conversations.get_agent_conversation( + azure_voice_agents_agent_name, + azure_voice_agents_conversation_id, + foundry_features=PREVIEW, + headers={"Accept-Encoding": "identity"}, + ) + + # See the note in test_get_voice_agent about not asserting on "id"/"name". + assert conversation["object"] == "voice.conversation" + assert conversation["status"] is not None + + @VoiceAgentsPreparer() + @recorded_by_proxy + def test_list_agent_conversation_items( + self, azure_voice_agents_endpoint, azure_voice_agents_agent_name, azure_voice_agents_conversation_id + ): + with self.create_client(azure_voice_agents_endpoint) as client: + items = list( + client.agent_endpoint_conversations.list_agent_conversation_items( + azure_voice_agents_agent_name, + azure_voice_agents_conversation_id, + foundry_features=PREVIEW, + headers={"Accept-Encoding": "identity"}, + ) + ) + + assert items + + @VoiceAgentsPreparer() + @recorded_by_proxy + def test_list_agent_conversation_responses( + self, azure_voice_agents_endpoint, azure_voice_agents_agent_name, azure_voice_agents_conversation_id + ): + with self.create_client(azure_voice_agents_endpoint) as client: + responses = list( + client.agent_endpoint_conversations.list_agent_conversation_responses( + azure_voice_agents_agent_name, + azure_voice_agents_conversation_id, + foundry_features=PREVIEW, + headers={"Accept-Encoding": "identity"}, + ) + ) + + assert responses + assert responses[0]["object"] == "realtime.response" + + @VoiceAgentsPreparer() + @recorded_by_proxy + def test_get_agent_conversation_audio_metadata( + self, azure_voice_agents_endpoint, azure_voice_agents_agent_name, azure_voice_agents_conversation_id + ): + with self.create_client(azure_voice_agents_endpoint) as client: + recording = client.agent_endpoint_conversations.get_agent_conversation_audio( + azure_voice_agents_agent_name, + azure_voice_agents_conversation_id, + foundry_features=PREVIEW, + headers={"Accept-Encoding": "identity"}, + ) + + assert recording["format"] is not None + assert recording["sample_rate"] is not None diff --git a/sdk/voiceagents/azure-ai-voiceagents/tests/recording/test_voice_agents_client_async.py b/sdk/voiceagents/azure-ai-voiceagents/tests/recording/test_voice_agents_client_async.py new file mode 100644 index 000000000000..3bf0db40b9c1 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/tests/recording/test_voice_agents_client_async.py @@ -0,0 +1,94 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Recorded functional tests for the async VoiceAgentsClient. + +See test_voice_agents_client.py for why this suite is limited to GET/LIST +operations. +""" +from devtools_testutils import AzureRecordedTestCase +from devtools_testutils.aio import recorded_by_proxy_async + +from azure.ai.voiceagents.aio import VoiceAgentsClient + +from _preparer import PREVIEW, VoiceAgentsPreparer + + +class TestVoiceAgentsClientAsync(AzureRecordedTestCase): + def create_client(self, endpoint: str) -> VoiceAgentsClient: + credential = self.get_credential(VoiceAgentsClient, is_async=True) + return self.create_client_from_credential(VoiceAgentsClient, credential=credential, endpoint=endpoint) + + @VoiceAgentsPreparer() + @recorded_by_proxy_async + async def test_get_voice_agent(self, azure_voice_agents_endpoint, azure_voice_agents_agent_name): + async with self.create_client(azure_voice_agents_endpoint) as client: + agent = await client.voice_agents.get_voice_agent(azure_voice_agents_agent_name, foundry_features=PREVIEW) + + # NOTE: don't assert agent["name"]/["id"] against azure_voice_agents_agent_name -- + # the test-proxy's built-in default sanitizers always redact "id"/"name" body + # fields to a generic value in playback, regardless of our own sanitizers. + assert agent["object"] == "agent" + assert agent["state"] in ("enabled", "disabled") + + # NOTE: list_voice_agents is intentionally not recorded here -- see the + # comment in test_voice_agents_client.py for why. + + @VoiceAgentsPreparer() + @recorded_by_proxy_async + async def test_get_agent_conversation( + self, azure_voice_agents_endpoint, azure_voice_agents_agent_name, azure_voice_agents_conversation_id + ): + async with self.create_client(azure_voice_agents_endpoint) as client: + conversation = await client.agent_endpoint_conversations.get_agent_conversation( + azure_voice_agents_agent_name, azure_voice_agents_conversation_id, foundry_features=PREVIEW + ) + + # See the note in test_get_voice_agent about not asserting on "id"/"name". + assert conversation["object"] == "voice.conversation" + assert conversation["status"] is not None + + @VoiceAgentsPreparer() + @recorded_by_proxy_async + async def test_list_agent_conversation_items( + self, azure_voice_agents_endpoint, azure_voice_agents_agent_name, azure_voice_agents_conversation_id + ): + async with self.create_client(azure_voice_agents_endpoint) as client: + items = [ + item + async for item in client.agent_endpoint_conversations.list_agent_conversation_items( + azure_voice_agents_agent_name, azure_voice_agents_conversation_id, foundry_features=PREVIEW + ) + ] + + assert items + + @VoiceAgentsPreparer() + @recorded_by_proxy_async + async def test_list_agent_conversation_responses( + self, azure_voice_agents_endpoint, azure_voice_agents_agent_name, azure_voice_agents_conversation_id + ): + async with self.create_client(azure_voice_agents_endpoint) as client: + responses = [ + response + async for response in client.agent_endpoint_conversations.list_agent_conversation_responses( + azure_voice_agents_agent_name, azure_voice_agents_conversation_id, foundry_features=PREVIEW + ) + ] + + assert responses + assert responses[0]["object"] == "realtime.response" + + @VoiceAgentsPreparer() + @recorded_by_proxy_async + async def test_get_agent_conversation_audio_metadata( + self, azure_voice_agents_endpoint, azure_voice_agents_agent_name, azure_voice_agents_conversation_id + ): + async with self.create_client(azure_voice_agents_endpoint) as client: + recording = await client.agent_endpoint_conversations.get_agent_conversation_audio( + azure_voice_agents_agent_name, azure_voice_agents_conversation_id, foundry_features=PREVIEW + ) + + assert recording["format"] is not None + assert recording["sample_rate"] is not None diff --git a/sdk/voiceagents/azure-ai-voiceagents/tests/unit/conftest.py b/sdk/voiceagents/azure-ai-voiceagents/tests/unit/conftest.py new file mode 100644 index 000000000000..3da6c4586041 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/tests/unit/conftest.py @@ -0,0 +1,17 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Overrides the parent (recorded-test) conftest for the unit test suite. + +Unit tests don't make any network calls, so they don't need the test-proxy +server that the recorded tests in the parent ``tests/`` directory start. This +fixture shadows the autouse ``start_proxy`` fixture from ../conftest.py so +running ``pytest tests/unit`` alone never tries to download/start the proxy. +""" +import pytest + + +@pytest.fixture(scope="session", autouse=True) +def start_proxy(): + return diff --git a/sdk/voiceagents/azure-ai-voiceagents/tests/unit/test_brotli_workaround.py b/sdk/voiceagents/azure-ai-voiceagents/tests/unit/test_brotli_workaround.py new file mode 100644 index 000000000000..0b689e1772c8 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/tests/unit/test_brotli_workaround.py @@ -0,0 +1,48 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Unit tests for the Brotli/aiohttp workaround in aio/_patch.py. No network calls. + +azure-core's AioHttpTransport disables aiohttp's native response decompression +and only re-implements gzip/deflate, while aiohttp advertises "Accept-Encoding: +br" by default. The async VoiceAgentsClient works around this by injecting its +own transport (unless the caller already supplied one) that only advertises +encodings azure-core can actually decompress. + +These tests must be `async def` because constructing the injected transport +builds an aiohttp.ClientSession, which requires a running event loop. +""" +import aiohttp +from azure.core.pipeline.transport import AioHttpTransport + +from azure.ai.voiceagents.aio import VoiceAgentsClient + +ENDPOINT = "https://example.services.ai.azure.com/api/projects/p" + + +class _FakeAsyncCredential: + async def get_token(self, *scopes, **kwargs): + raise NotImplementedError + + async def close(self): + pass + + +async def test_default_transport_only_advertises_gzip_deflate(): + async with VoiceAgentsClient(endpoint=ENDPOINT, credential=_FakeAsyncCredential()) as client: + transport = client._client._pipeline._transport + assert isinstance(transport, AioHttpTransport) + assert transport.session.headers.get("Accept-Encoding") == "gzip, deflate" + + +async def test_explicit_transport_bypasses_workaround(): + custom_session = aiohttp.ClientSession() + custom_transport = AioHttpTransport(session=custom_session) + try: + async with VoiceAgentsClient( + endpoint=ENDPOINT, credential=_FakeAsyncCredential(), transport=custom_transport + ) as client: + assert client._client._pipeline._transport is custom_transport + finally: + await custom_session.close() diff --git a/sdk/voiceagents/azure-ai-voiceagents/tests/unit/test_client_construction.py b/sdk/voiceagents/azure-ai-voiceagents/tests/unit/test_client_construction.py new file mode 100644 index 000000000000..5d8c7a0f1b44 --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/tests/unit/test_client_construction.py @@ -0,0 +1,62 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Unit tests for sync/async client construction. No network calls. + +Note: constructing the async client requires a running event loop (it builds +an aiohttp.ClientSession by default -- see test_brotli_workaround.py), so the +async cases below are `async def` tests. +""" +from azure.ai.voiceagents import VoiceAgentsClient +from azure.ai.voiceagents.aio import VoiceAgentsClient as AsyncVoiceAgentsClient +from azure.ai.voiceagents.operations import ( + AgentEndpointConversationsOperations, + VoiceAgentsOperations, + VoiceAgentWebSocketOperations, +) + +ENDPOINT = "https://example.services.ai.azure.com/api/projects/p" + + +class _FakeCredential: + def get_token(self, *scopes, **kwargs): + raise NotImplementedError + + +class _FakeAsyncCredential: + async def get_token(self, *scopes, **kwargs): + raise NotImplementedError + + async def close(self): + pass + + +def test_sync_client_exposes_operation_groups(): + client = VoiceAgentsClient(endpoint=ENDPOINT, credential=_FakeCredential()) + try: + assert isinstance(client.voice_agents, VoiceAgentsOperations) + assert isinstance(client.agent_endpoint_conversations, AgentEndpointConversationsOperations) + assert isinstance(client.voice_agent_web_socket, VoiceAgentWebSocketOperations) + finally: + client.close() + + +def test_sync_client_is_a_context_manager(): + with VoiceAgentsClient(endpoint=ENDPOINT, credential=_FakeCredential()) as client: + assert client.voice_agents is not None + + +async def test_async_client_exposes_operation_groups(): + async with AsyncVoiceAgentsClient(endpoint=ENDPOINT, credential=_FakeAsyncCredential()) as client: + assert client.voice_agents is not None + assert client.agent_endpoint_conversations is not None + assert client.voice_agent_web_socket is not None + + +async def test_async_client_realtime_property_is_lazy_and_cached(): + async with AsyncVoiceAgentsClient(endpoint=ENDPOINT, credential=_FakeAsyncCredential()) as client: + assert client._realtime is None + realtime = client.realtime + assert realtime is not None + assert client.realtime is realtime # cached, not recreated on each access diff --git a/sdk/voiceagents/azure-ai-voiceagents/tests/unit/test_configuration.py b/sdk/voiceagents/azure-ai-voiceagents/tests/unit/test_configuration.py new file mode 100644 index 000000000000..56d2eb7cc2df --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/tests/unit/test_configuration.py @@ -0,0 +1,47 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Unit tests for VoiceAgentsClientConfiguration defaults. No network calls.""" +import pytest + +from azure.ai.voiceagents._configuration import VoiceAgentsClientConfiguration + +ENDPOINT = "https://example.services.ai.azure.com/api/projects/p" + + +class _FakeCredential: + def get_token(self, *scopes, **kwargs): + raise NotImplementedError + + +def test_default_api_version_is_v1(): + config = VoiceAgentsClientConfiguration(endpoint=ENDPOINT, credential=_FakeCredential()) + assert config.api_version == "v1" + + +def test_default_credential_scopes(): + config = VoiceAgentsClientConfiguration(endpoint=ENDPOINT, credential=_FakeCredential()) + assert config.credential_scopes == ["https://ai.azure.com/.default"] + + +def test_endpoint_and_credential_are_saved(): + credential = _FakeCredential() + config = VoiceAgentsClientConfiguration(endpoint=ENDPOINT, credential=credential) + assert config.endpoint == ENDPOINT + assert config.credential is credential + + +def test_endpoint_is_required(): + with pytest.raises(ValueError): + VoiceAgentsClientConfiguration(endpoint=None, credential=_FakeCredential()) + + +def test_credential_is_required(): + with pytest.raises(ValueError): + VoiceAgentsClientConfiguration(endpoint=ENDPOINT, credential=None) + + +def test_api_version_can_be_overridden(): + config = VoiceAgentsClientConfiguration(endpoint=ENDPOINT, credential=_FakeCredential(), api_version="v1") + assert config.api_version == "v1" diff --git a/sdk/voiceagents/azure-ai-voiceagents/tsp-location.yaml b/sdk/voiceagents/azure-ai-voiceagents/tsp-location.yaml new file mode 100644 index 000000000000..1ff0d06d4cdc --- /dev/null +++ b/sdk/voiceagents/azure-ai-voiceagents/tsp-location.yaml @@ -0,0 +1,13 @@ +directory: specification/ai-foundry/data-plane/Foundry/src/sdk-python-azure-ai-voice-agents +commit: 708de4f80783992b0b9bce9394a0a9212bb14d40 +repo: yulin-li/azure-rest-api-specs +additionalDirectories: +- specification/ai-foundry/data-plane/Foundry/src/agents +- specification/ai-foundry/data-plane/Foundry/src/common +- specification/ai-foundry/data-plane/Foundry/src/memory-stores +- specification/ai-foundry/data-plane/Foundry/src/openai +- specification/ai-foundry/data-plane/Foundry/src/sdk-common +- specification/ai-foundry/data-plane/Foundry/src/skills +- specification/ai-foundry/data-plane/Foundry/src/tools +- specification/ai-foundry/data-plane/Foundry/src/toolboxes +- specification/ai-foundry/data-plane/Foundry/src/voice-agents diff --git a/sdk/voiceagents/ci.yml b/sdk/voiceagents/ci.yml new file mode 100644 index 000000000000..d0a209af135c --- /dev/null +++ b/sdk/voiceagents/ci.yml @@ -0,0 +1,37 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - main + - hotfix/* + - release/* + - restapi* + paths: + include: + - sdk/voiceagents/ + - sdk/core/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + - restapi* + paths: + include: + - sdk/voiceagents/ + - sdk/core/ + +extends: + template: /eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: voiceagents + TestProxy: true + BuildDocs: true + TestTimeoutInMinutes: 60 + Artifacts: + - name: azure-ai-voiceagents + safeName: azureaivoiceagents diff --git a/sdk/voiceagents/cspell.yaml b/sdk/voiceagents/cspell.yaml new file mode 100644 index 000000000000..20807788ac46 --- /dev/null +++ b/sdk/voiceagents/cspell.yaml @@ -0,0 +1,38 @@ +# cspell configuration for this service. Words are case-insensitive and +# kept sorted alphabetically. The import of the central config is required. +import: + - ../../.vscode/cspell.json +words: + - aarti + - aiservices + - byom + - BYOS + - CSDL + - dalia + - diya + - deser + - DTMF + - hyunsu + - keita + - MCPHTTP + - meera + - niwat + - pcma + - pcmu + - premwadee + - pyaudio + - redef + - realtime + - reraises + - sess + - SSML + - sunhi + - unsanitized + - vad + - viseme + - webrtc + - xhigh + - xiaoxiao + - ximena + - yunxi + - yulin diff --git a/sdk/voiceagents/tests.yml b/sdk/voiceagents/tests.yml new file mode 100644 index 000000000000..1780a898a4e4 --- /dev/null +++ b/sdk/voiceagents/tests.yml @@ -0,0 +1,6 @@ +trigger: none + +extends: + template: /eng/pipelines/templates/stages/python-analyze-weekly-standalone.yml + parameters: + ServiceDirectory: voiceagents