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.
Why does it do this instead of using the UseOpenTelemetry helper method?
There was a problem hiding this comment.
Didn't know it existed. I copied that from the OpenAI integration
There was a problem hiding this comment.
Me as the author of the OpenAI integration: 😅
| /// <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.
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.
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.
Missed that in my refactor, will fix.
Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
| /// 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.
| /// 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.
This comment is a bit misleading, since setting ConnectionString will populate Endpoint in ParseConnectionString below.
There was a problem hiding this comment.
I think the comment was lifted from here: https://github.com/dotnet/aspire/blob/38591121f7667cc5c6b9d7e17cd086d4909c1d6c/src/Components/Aspire.Azure.Data.Tables/AzureDataTablesSettings.cs#L18
|
@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.
configureClient => configureSettings
| /// <summary> | ||
| /// The ID of the deployment in Azure AI Foundry. | ||
| /// </summary> | ||
| public string? DeploymentId { get; } = deploymentId; |
| /// <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.
serviceKey shouldn't be nullable if you are calling AddKeyedChatClient.
There was a problem hiding this comment.
The builder has a service key:
serviceKey = serviceKey ?? builder.ServiceKey;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
Azureto the name, even though the type being registered is aChatCompletionsClientand 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?