-
Notifications
You must be signed in to change notification settings - Fork 652
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
Integration for Azure.AI.Inference
#9103
Conversation
if (builder.DisableTracing) | ||
{ | ||
return result; | ||
} | ||
|
||
var loggerFactory = services.GetService<ILoggerFactory>(); | ||
return new OpenTelemetryChatClient(result, loggerFactory?.CreateLogger(typeof(OpenTelemetryChatClient))); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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: 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #9103 (comment)
src/Components/Aspire.Azure.AI.Inference/AspireAzureAIInferenceExtensions.cs
Show resolved
Hide resolved
src/Components/Aspire.Azure.AI.Inference/AspireChatCompletionsClientBuilder.cs
Show resolved
Hide resolved
src/Components/Aspire.Azure.AI.Inference/AspireAzureAIInferenceExtensions.cs
Outdated
Show resolved
Hide resolved
src/Components/Aspire.Azure.AI.Inference/Aspire.Azure.AI.Inference.csproj
Outdated
Show resolved
Hide resolved
/// <summary> | ||
/// Gets or sets the name of the AI model to use for chat completions. | ||
/// </summary> | ||
public string? ModelName { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this used?
There was a problem hiding this comment.
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; } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
src/Components/Aspire.Azure.AI.Inference/Aspire.Azure.AI.Inference.csproj
Show resolved
Hide resolved
/// 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// 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"/>. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the comment was lifted from here:
/// If <see cref="ConnectionString"/> is set, it overrides <see cref="ServiceUri"/> and <see cref="Credential"/>. |
src/Components/Aspire.Azure.AI.Inference/AspireAzureAIInferenceExtensions.cs
Outdated
Show resolved
Hide resolved
src/Components/Aspire.Azure.AI.Inference/AspireAzureAIInferenceExtensions.cs
Outdated
Show resolved
Hide resolved
src/Components/Aspire.Azure.AI.Inference/Aspire.Azure.AI.Inference.csproj
Show resolved
Hide resolved
@eerhardt could you please review too? |
public static AspireChatCompletionsClientBuilder AddAzureChatCompletionsClient( | ||
this IHostApplicationBuilder builder, | ||
string connectionName, | ||
Action<ChatCompletionsClientSettings>? configureClient = null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
configureClient
=> configureSettings
/// <summary> | ||
/// The ID of the deployment in Azure AI Foundry. | ||
/// </summary> | ||
public string? DeploymentId { get; } = deploymentId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does this get used?
/// <param name="builder">An <see cref="AspireChatCompletionsClientBuilder" />.</param> | ||
/// <param name="serviceKey">The service key with which the <see cref="IChatClient"/> will be registered.</param> | ||
/// <returns></returns> | ||
public static ChatClientBuilder AddKeyedChatClient(this AspireChatCompletionsClientBuilder builder, string? serviceKey) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
serviceKey
shouldn't be nullable if you are calling AddKeyedChatClient
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The builder has a service key:
serviceKey = serviceKey ?? builder.ServiceKey;
src/Components/Aspire.Azure.AI.Inference/AspireAzureAIInferenceExtensions.cs
Outdated
Show resolved
Hide resolved
src/Components/Aspire.Azure.AI.Inference/AspireAzureAIInferenceExtensions.cs
Outdated
Show resolved
Hide resolved
Use DeploymentId when calling AsIChatClient. Make serviceKey required.
I am doing the required changes, will merge after |
@joperezr we want this one even though it was just after 4pm. |
Sure, let's put up a backport PR then. The target is to have the final build by EoD today. |
Oh nvm, just realized this made the cutoff |
Description
Implementing an integration for the Azure AI Inference NuGet package.
For the method, I've added
Azure
to the name, even though the type being registered is aChatCompletionsClient
and it can be used without Azure (it's GitHub Models compatible). This aims to be consistent with the other integrations like Table.Fixes #9011
Checklist
<remarks />
and<code />
elements on your triple slash comments?