Skip to content
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

Remove some defunct lazy init from chat clients #5561

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -480,15 +480,15 @@ private static List<ChatMessageContentItem> GetContentParts(IList<AIContent> con
switch (content)
{
case TextContent textContent:
(parts ??= []).Add(new ChatMessageTextContentItem(textContent.Text));
parts.Add(new ChatMessageTextContentItem(textContent.Text));
break;

case ImageContent imageContent when imageContent.Data is { IsEmpty: false } data:
(parts ??= []).Add(new ChatMessageImageContentItem(BinaryData.FromBytes(data), imageContent.MediaType));
parts.Add(new ChatMessageImageContentItem(BinaryData.FromBytes(data), imageContent.MediaType));
break;

case ImageContent imageContent when imageContent.Uri is string uri:
(parts ??= []).Add(new ChatMessageImageContentItem(new Uri(uri)));
parts.Add(new ChatMessageImageContentItem(new Uri(uri)));
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -530,8 +530,6 @@ private sealed class OpenAIChatToolJson
{
AIContent? aiContent = null;

AdditionalPropertiesDictionary? additionalProperties = null;

if (contentPart.Kind == ChatMessageContentPartKind.Text)
{
aiContent = new TextContent(contentPart.Text);
Expand All @@ -546,18 +544,17 @@ private sealed class OpenAIChatToolJson

if (imageContent is not null && contentPart.ImageDetailLevel?.ToString() is string detail)
{
(additionalProperties ??= [])[nameof(contentPart.ImageDetailLevel)] = detail;
(imageContent.AdditionalProperties ??= [])[nameof(contentPart.ImageDetailLevel)] = detail;
}
}

if (aiContent is not null)
{
if (contentPart.Refusal is string refusal)
{
(additionalProperties ??= [])[nameof(contentPart.Refusal)] = refusal;
(aiContent.AdditionalProperties ??= [])[nameof(contentPart.Refusal)] = refusal;
}

aiContent.AdditionalProperties = additionalProperties;
aiContent.RawRepresentation = contentPart;
}

Expand Down Expand Up @@ -641,15 +638,15 @@ private static List<ChatMessageContentPart> GetContentParts(IList<AIContent> con
switch (content)
{
case TextContent textContent:
(parts ??= []).Add(ChatMessageContentPart.CreateTextPart(textContent.Text));
parts.Add(ChatMessageContentPart.CreateTextPart(textContent.Text));
break;

case ImageContent imageContent when imageContent.Data is { IsEmpty: false } data:
(parts ??= []).Add(ChatMessageContentPart.CreateImagePart(BinaryData.FromBytes(data), imageContent.MediaType));
parts.Add(ChatMessageContentPart.CreateImagePart(BinaryData.FromBytes(data), imageContent.MediaType));
break;

case ImageContent imageContent when imageContent.Uri is string uri:
(parts ??= []).Add(ChatMessageContentPart.CreateImagePart(new Uri(uri)));
parts.Add(ChatMessageContentPart.CreateImagePart(new Uri(uri)));
break;
}
}
Expand Down
Loading