Skip to content

Integration for Azure.AI.Inference #9103

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 8 commits into
base: main
Choose a base branch
from

Conversation

aaronpowell
Copy link
Contributor

Description

Implementing an integration for the Azure AI Inference NuGet package.

Fixes #9011

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label May 5, 2025
@github-actions github-actions bot added the area-integrations Issues pertaining to Aspire Integrations packages label May 5, 2025
Comment on lines 170 to 176
if (builder.DisableTracing)
{
return result;
}

var loggerFactory = services.GetService<ILoggerFactory>();
return new OpenTelemetryChatClient(result, loggerFactory?.CreateLogger(typeof(OpenTelemetryChatClient)));
Copy link
Member

Choose a reason for hiding this comment

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

Why does it do this instead of using the UseOpenTelemetry helper method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Didn't know it existed. I copied that from the OpenAI integration

Copy link
Member

Choose a reason for hiding this comment

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

Me as the author of the OpenAI integration: 😅

Copy link
Member

Choose a reason for hiding this comment

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

@RussKie RussKie mentioned this pull request May 5, 2025
18 tasks
/// <summary>
/// Gets or sets the name of the AI model to use for chat completions.
/// </summary>
public string? ModelName { get; set; }
Copy link
Member

Choose a reason for hiding this comment

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

Where is this used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Possibly isn't, I think it was from an older implementation

/// <summary>
/// Gets or sets the ID of the AI model to use for chat completions.
/// </summary>
public string? ModelId { get; set; }
Copy link
Member

Choose a reason for hiding this comment

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

The Azure.AI.Inference library calls this "deploymentId", right? We also use the term DeploymentId in AspireChatCompletionsClientBuilder. We should consolidate on a single term here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Missed that in my refactor, will fix.

/// Gets or sets a boolean value that indicates whether the OpenTelemetry tracing is disabled or not.
/// </summary>
/// <remarks>
/// ServiceBus ActivitySource support in Azure SDK is experimental, the shape of Activities may change in the future without notice.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// ServiceBus ActivitySource support in Azure SDK is experimental, the shape of Activities may change in the future without notice.
/// Azure AI Inference client library ActivitySource support in Azure SDK is experimental, the shape of Activities may change in the future without notice.

/// Gets or sets the connection string used to connect to the AI Foundry account.
/// </summary>
/// <remarks>
/// If <see cref="ConnectionString"/> is set, it overrides <see cref="Endpoint"/> and <see cref="Credential"/>.
Copy link
Member

Choose a reason for hiding this comment

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

This comment is a bit misleading, since setting ConnectionString will populate Endpoint in ParseConnectionString below.

/// </summary>
/// <param name="builder"></param>
/// <returns></returns>
public static ChatClientBuilder AddChatClient(this AspireChatCompletionsClientBuilder builder) =>
Copy link
Member

Choose a reason for hiding this comment

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

Are there any tests for this method?

return result;
}

return new ChatClientBuilder(result)
Copy link
Member

Choose a reason for hiding this comment

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

This should use the same pattern as we do elsewhere:

var loggerFactory = services.GetService<ILoggerFactory>();
return new OpenTelemetryChatClient(result, loggerFactory?.CreateLogger(typeof(OpenTelemetryChatClient)));

As this code currently is, the Logger won't be hooked up because you aren't passing in the services to Build().

@@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a README for the library?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-integrations Issues pertaining to Aspire Integrations packages community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Client Integration for Azure.AI.Inference
5 participants