-
Notifications
You must be signed in to change notification settings - Fork 832
Description
Description
When using Microsoft.Extensions.AI.AzureAIInference IChatClient, sending DataContent
with a valid data URI fails.
Repro:
https://gist.github.com/luisquintanilla/48a3dae23ca160a505b29ac8b87d38a4
For text content, rather than checking that the media type is text, it assumes that the AIContent is TextContent.
extensions/src/Libraries/Microsoft.Extensions.AI.AzureAIInference/AzureAIInferenceChatClient.cs
Lines 489 to 491 in d325bcb
case TextContent textContent: | |
parts.Add(new ChatMessageTextContentItem(textContent.Text)); | |
break; |
I would expect the switch statement to treat everything as DataContent and for text to also use the media type.
This also raises another question. For custom media / MIME types, what is the mechanism for handling those? Would I have to implement my own DelegateChatClient?
Reproduction Steps
https://gist.github.com/luisquintanilla/48a3dae23ca160a505b29ac8b87d38a4
Expected behavior
I can get a response from the model provider.
Actual behavior
Error: System.ArgumentException: Value cannot be an empty collection. (Parameter 'content')
at Azure.AI.Inference.Argument.AssertNotNullOrEmpty[T](IEnumerable`1 value, String name)
at Azure.AI.Inference.ChatRequestUserMessage..ctor(IEnumerable`1 content)
at Microsoft.Extensions.AI.AzureAIInferenceChatClient.ToAzureAIInferenceChatMessages(IList`1 inputs)+MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Azure.AI.Inference.ChatCompletionsOptions..ctor(IEnumerable`1 messages)
at Microsoft.Extensions.AI.AzureAIInferenceChatClient.ToAzureAIOptions(IList`1 chatContents, ChatOptions options)
at Microsoft.Extensions.AI.AzureAIInferenceChatClient.GetResponseAsync(IList`1 chatMessages, ChatOptions options, CancellationToken cancellationToken)
at Submission#8.<<Initialize>>d__0.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.RunSubmissionsAsync[TResult](ImmutableArray`1 precedingExecutors, Func`2 currentExecutor, StrongBox`1 exceptionHolderOpt, Func`2 catchExceptionOpt, CancellationToken cancellationToken)
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response