Skip to content

Commit

Permalink
Some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
MackinnonBuck committed Jan 28, 2025
1 parent 7b01ed9 commit b7bb5b9
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 17 deletions.
4 changes: 0 additions & 4 deletions eng/MSBuild/Shared.props
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,4 @@
<ItemGroup Condition="'$(InjectStringSplitExtensions)' == 'true'">
<Compile Include="$(MSBuildThisFileDirectory)\..\..\src\Shared\StringSplit\*.cs" LinkBase="Shared\StringSplit" />
</ItemGroup>

<ItemGroup Condition="'$(InjectSharedAIExtensions)' == 'true'">
<Compile Include="$(MSBuildThisFileDirectory)\..\..\src\Shared\AIExtensions\*.cs" LinkBase="Shared\AIExtensions" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
<InjectSharedDiagnosticIds>true</InjectSharedDiagnosticIds>
<InjectSharedEmptyCollections>true</InjectSharedEmptyCollections>
<InjectStringHashOnLegacy>true</InjectStringHashOnLegacy>
<InjectSharedAIExtensions>true</InjectSharedAIExtensions>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<InjectSharedDiagnosticIds>true</InjectSharedDiagnosticIds>
<InjectSharedEmptyCollections>true</InjectSharedEmptyCollections>
<InjectStringHashOnLegacy>true</InjectStringHashOnLegacy>
<InjectSharedAIExtensions>true</InjectSharedAIExtensions>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
<InjectSharedServerSentEvents>true</InjectSharedServerSentEvents>
<InjectRequiredMemberOnLegacy>true</InjectRequiredMemberOnLegacy>
<InjectCompilerFeatureRequiredOnLegacy>true</InjectCompilerFeatureRequiredOnLegacy>
<InjectSharedAIExtensions>true</InjectSharedAIExtensions>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,9 @@ private static List<ChatMessageContentPart> ToOpenAIChatContent(IList<AIContent>
break;

case DataContent dataContent when dataContent.HasMediaTypePrefix("image/"):
if (dataContent.Data is { IsEmpty: false } data)
if (dataContent.ContainsData)
{
parts.Add(ChatMessageContentPart.CreateImagePart(BinaryData.FromBytes(data), dataContent.MediaType));
parts.Add(ChatMessageContentPart.CreateImagePart(BinaryData.FromBytes(dataContent.Data!.Value), dataContent.MediaType));
}
else if (dataContent.Uri is string uri)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ public void Text_GetSet_UsesFirstTextContent()
{
ChatMessage message = new(ChatRole.User,
[
new DataContent("http://localhost/audio", mediaType: "audio/mpeg"),
new DataContent("http://localhost/image", mediaType: "image/png"),
new DataContent("http://localhost/audio"),
new DataContent("http://localhost/image"),
new FunctionCallContent("callId1", "fc1"),
new TextContent("text-1"),
new TextContent("text-2"),
Expand Down Expand Up @@ -163,8 +163,8 @@ public void Text_Set_AddsTextMessageToListWithNoText()
{
ChatMessage message = new(ChatRole.User,
[
new DataContent("http://localhost/audio", mediaType: "audio/mpeg"),
new DataContent("http://localhost/image", mediaType: "image/png"),
new DataContent("http://localhost/audio"),
new DataContent("http://localhost/image"),
new FunctionCallContent("callId1", "fc1"),
]);
Assert.Equal(3, message.Contents.Count);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ public void Text_Set_AddsTextMessageToListWithNoText()
{
Contents =
[
new DataContent("http://localhost/audio", "audio/mpeg"),
new DataContent("http://localhost/image", "image/png"),
new DataContent("http://localhost/audio"),
new DataContent("http://localhost/image"),
new FunctionCallContent("callId1", "fc1"),
]
};
Expand Down Expand Up @@ -169,7 +169,7 @@ public void JsonSerialization_Roundtrips()
Contents =
[
new TextContent("text-1"),
new DataContent("http://localhost/image", "image/png"),
new DataContent("http://localhost/image"),
new FunctionCallContent("callId1", "fc1"),
new DataContent("data"u8.ToArray()),
new TextContent("text-2"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public async Task FailureUsage_NullJson()
[Fact]
public async Task FailureUsage_NoJsonInResponse()
{
var expectedCompletion = new ChatCompletion([new ChatMessage(ChatRole.Assistant, [new DataContent("https://example.com", "image/png")])]);
var expectedCompletion = new ChatCompletion([new ChatMessage(ChatRole.Assistant, [new DataContent("https://example.com")])]);
using var client = new TestChatClient
{
CompleteAsyncCallback = (messages, options, cancellationToken) => Task.FromResult(expectedCompletion),
Expand Down

0 comments on commit b7bb5b9

Please sign in to comment.