Skip to content

.Net: Introduce support for response modalities and audio options in AzureClientCore #12523

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Cobra86
Copy link

@Cobra86 Cobra86 commented Jun 18, 2025

Motivation and Context

This change extends AzureClientCore to handle response modalities and audio options dynamically based on user-provided executionSettings.

Why this is needed:

Currently, the OpenAI connector supports audio modalities through the Modalities and Audio properties in OpenAIPromptExecutionSettings, but the Azure OpenAI connector doesn't fully implement this functionality.

The code for handling audio exists in AzureClientCore.cs but isn't included in AzureClientCore.ChatCompletion.cs.

Description

  • Introduced GetResponseModalities and GetAudioOptions helper methods. These follow the same logic as the equivalent methods in the OpenAI connector to ensure consistent behaviour and reduce duplication across both clients.

  • Updated CreateChatCompletionOptions to:

    • Parse and apply ResponseModalities if specified in executionSettings.
    • Parse and apply AudioOptions if specified in executionSettings.
    • Ensured backward compatibility: defaults remain unchanged if these options are not provided.

Contribution Checklist

Introduce methods to handle response modalities and audio options in AzureClientCore.
Add checks for executionSettings.Modalities and executionSettings.Audio to dynamically configure options based on user settings.
Implement GetResponseModalities and GetAudioOptions methods to support various input formats, improving flexibility and robustness.
@Cobra86 Cobra86 requested a review from a team as a code owner June 18, 2025 11:15
@markwallace-microsoft markwallace-microsoft added .NET Issue or Pull requests regarding .NET code kernel Issues or pull requests impacting the core kernel labels Jun 18, 2025
@github-actions github-actions bot changed the title Introduce support for response modalities and audio options in AzureClientCore .Net: Introduce support for response modalities and audio options in AzureClientCore Jun 18, 2025
@Cobra86
Copy link
Author

Cobra86 commented Jun 18, 2025

@microsoft-github-policy-service agree

@Cobra86
Copy link
Author

Cobra86 commented Jun 18, 2025

This is for this request #11720

@RogerBarreto
Copy link
Member

@Cobra86 Thank you for adding the support, to get those one in, we also need Unit Tests similar how we do have for OpenAI Connector. Please add those. Overall LGTM.

Implemented tests in `AzureOpenAIChatCompletionServiceTests` to verify the correct handling of audio content in requests and responses. This includes checks for sending audio content, processing audio responses, and handling audio metadata. Introduced new theory data members for validating response modalities and audio options.
@Cobra86
Copy link
Author

Cobra86 commented Jun 18, 2025

@RogerBarreto Thank you :). I've added the tests same as OpenAI. Please let me know if i need more tests

Copy link
Contributor

@westey-m westey-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a couple small comments about error messaging, to help users troubleshoot failures.

Enhance error handling by introducing try-catch blocks
for JSON deserialization, providing clearer exception
messages for unsupported modalities and invalid audio
options. Refactor parsing logic for string modalities
to improve code readability and maintainability.
@Cobra86
Copy link
Author

Cobra86 commented Jun 20, 2025

Looks good, just a couple small comments about error messaging, to help users troubleshoot failures.

Thanks. I've made the changes. Please review it and let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kernel Issues or pull requests impacting the core kernel .NET Issue or Pull requests regarding .NET code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants