mirror of https://github.com/microsoft/autogen.git
[.Net] Add AOT compatible check for AutoGen.Core (#2858)
* add AutoGen.AotCompatibility test * add aot test * fix build error * update ps1 path
This commit is contained in:
parent
5f29d6b97d
commit
84c7c2430c
|
@ -67,6 +67,31 @@ jobs:
|
|||
dotnet build --no-restore --configuration Release -bl /p:SignAssembly=true
|
||||
- name: Unit Test
|
||||
run: dotnet test --no-build -bl --configuration Release
|
||||
aot-test: # this make sure the AutoGen.Core is aot compatible
|
||||
strategy:
|
||||
fail-fast: false # ensures the entire test matrix is run, even if one permutation fails
|
||||
matrix:
|
||||
os: [ ubuntu-latest ]
|
||||
version: [ net8.0 ]
|
||||
needs: build
|
||||
defaults:
|
||||
run:
|
||||
working-directory: dotnet
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0 # fetching all
|
||||
|
||||
- name: Setup dotnet
|
||||
uses: actions/setup-dotnet@v4
|
||||
with:
|
||||
global-json-file: dotnet/global.json
|
||||
|
||||
- name: publish AOT testApp, assert static analysis warning count, and run the app
|
||||
shell: pwsh
|
||||
run: ./.tools/test-aot-compatibility.ps1 ${{ matrix.version }}
|
||||
openai-test:
|
||||
name: Run openai test
|
||||
runs-on: ubuntu-latest
|
||||
|
@ -75,7 +100,7 @@ jobs:
|
|||
run:
|
||||
working-directory: dotnet
|
||||
if: success() && (github.ref == 'refs/heads/main')
|
||||
needs: build
|
||||
needs: aot-test
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
param([string]$targetNetFramework)
|
||||
|
||||
$rootDirectory = Split-Path $PSScriptRoot -Parent
|
||||
$publishOutput = dotnet publish $rootDirectory/test/AutoGen.AotCompatibility.Tests -nodeReuse:false /p:UseSharedCompilation=false /p:ExposeExperimentalFeatures=true
|
||||
|
||||
$actualWarningCount = 0
|
||||
|
||||
foreach ($line in $($publishOutput -split "`r`n"))
|
||||
{
|
||||
if ($line -like "*analysis warning IL*")
|
||||
{
|
||||
Write-Host $line
|
||||
|
||||
$actualWarningCount += 1
|
||||
}
|
||||
}
|
||||
|
||||
pushd $rootDirectory/test/AutoGen.AotCompatibility.Tests/bin/Release/$targetNetFramework/linux-x64
|
||||
|
||||
Write-Host "Executing test App..."
|
||||
./AutoGen.AotCompatibility.Tests
|
||||
Write-Host "Finished executing test App"
|
||||
|
||||
if ($LastExitCode -ne 0)
|
||||
{
|
||||
Write-Host "There was an error while executing AotCompatibility Test App. LastExitCode is:", $LastExitCode
|
||||
}
|
||||
|
||||
popd
|
||||
|
||||
Write-Host "Actual warning count is:", $actualWarningCount
|
||||
$expectedWarningCount = 0
|
||||
|
||||
$testPassed = 0
|
||||
if ($actualWarningCount -ne $expectedWarningCount)
|
||||
{
|
||||
$testPassed = 1
|
||||
Write-Host "Actual warning count:", actualWarningCount, "is not as expected. Expected warning count is:", $expectedWarningCount
|
||||
}
|
||||
|
||||
Exit $testPassed
|
|
@ -43,15 +43,17 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoGen.Ollama", "src\AutoG
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoGen.Ollama.Tests", "test\AutoGen.Ollama.Tests\AutoGen.Ollama.Tests.csproj", "{03E31CAA-3728-48D3-B936-9F11CF6C18FE}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoGen.Ollama.Sample", "sample\AutoGen.Ollama.Sample\AutoGen.Ollama.Sample.csproj", "{93AA4D0D-6EE4-44D5-AD77-7F73A3934544}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoGen.Ollama.Sample", "sample\AutoGen.Ollama.Sample\AutoGen.Ollama.Sample.csproj", "{93AA4D0D-6EE4-44D5-AD77-7F73A3934544}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoGen.SemanticKernel.Sample", "sample\AutoGen.SemanticKernel.Sample\AutoGen.SemanticKernel.Sample.csproj", "{52958A60-3FF7-4243-9058-34A6E4F55C31}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoGen.SemanticKernel.Sample", "sample\AutoGen.SemanticKernel.Sample\AutoGen.SemanticKernel.Sample.csproj", "{52958A60-3FF7-4243-9058-34A6E4F55C31}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoGen.Anthropic", "src\AutoGen.Anthropic\AutoGen.Anthropic.csproj", "{6A95E113-B824-4524-8F13-CD0C3E1C8804}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoGen.Anthropic", "src\AutoGen.Anthropic\AutoGen.Anthropic.csproj", "{6A95E113-B824-4524-8F13-CD0C3E1C8804}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoGen.Anthropic.Tests", "test\AutoGen.Anthropic.Tests\AutoGen.Anthropic.Tests.csproj", "{815E937E-86D6-4476-9EC6-B7FBCBBB5DB6}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoGen.Anthropic.Tests", "test\AutoGen.Anthropic.Tests\AutoGen.Anthropic.Tests.csproj", "{815E937E-86D6-4476-9EC6-B7FBCBBB5DB6}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoGen.Anthropic.Samples", "sample\AutoGen.Anthropic.Samples\AutoGen.Anthropic.Samples.csproj", "{834B4E85-64E5-4382-8465-548F332E5298}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoGen.Anthropic.Samples", "sample\AutoGen.Anthropic.Samples\AutoGen.Anthropic.Samples.csproj", "{834B4E85-64E5-4382-8465-548F332E5298}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoGen.AotCompatibility.Tests", "test\AutoGen.AotCompatibility.Tests\AutoGen.AotCompatibility.Tests.csproj", "{6B82F26D-5040-4453-B21B-C8D1F913CE4C}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
@ -147,6 +149,10 @@ Global
|
|||
{834B4E85-64E5-4382-8465-548F332E5298}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{834B4E85-64E5-4382-8465-548F332E5298}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{834B4E85-64E5-4382-8465-548F332E5298}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6B82F26D-5040-4453-B21B-C8D1F913CE4C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6B82F26D-5040-4453-B21B-C8D1F913CE4C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6B82F26D-5040-4453-B21B-C8D1F913CE4C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6B82F26D-5040-4453-B21B-C8D1F913CE4C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -167,13 +173,14 @@ Global
|
|||
{1DFABC4A-8458-4875-8DCB-59F3802DAC65} = {F823671B-3ECA-4AE6-86DA-25E920D3FE64}
|
||||
{D36A85F9-C172-487D-8192-6BFE5D05B4A7} = {F823671B-3ECA-4AE6-86DA-25E920D3FE64}
|
||||
{B61388CA-DC73-4B7F-A7B2-7B9A86C9229E} = {F823671B-3ECA-4AE6-86DA-25E920D3FE64}
|
||||
{6A95E113-B824-4524-8F13-CD0C3E1C8804} = {18BF8DD7-0585-48BF-8F97-AD333080CE06}
|
||||
{815E937E-86D6-4476-9EC6-B7FBCBBB5DB6} = {F823671B-3ECA-4AE6-86DA-25E920D3FE64}
|
||||
{834B4E85-64E5-4382-8465-548F332E5298} = {FBFEAD1F-29EB-4D99-A672-0CD8473E10B9}
|
||||
{9F9E6DED-3D92-4970-909A-70FC11F1A665} = {18BF8DD7-0585-48BF-8F97-AD333080CE06}
|
||||
{03E31CAA-3728-48D3-B936-9F11CF6C18FE} = {F823671B-3ECA-4AE6-86DA-25E920D3FE64}
|
||||
{93AA4D0D-6EE4-44D5-AD77-7F73A3934544} = {FBFEAD1F-29EB-4D99-A672-0CD8473E10B9}
|
||||
{52958A60-3FF7-4243-9058-34A6E4F55C31} = {FBFEAD1F-29EB-4D99-A672-0CD8473E10B9}
|
||||
{6A95E113-B824-4524-8F13-CD0C3E1C8804} = {18BF8DD7-0585-48BF-8F97-AD333080CE06}
|
||||
{815E937E-86D6-4476-9EC6-B7FBCBBB5DB6} = {F823671B-3ECA-4AE6-86DA-25E920D3FE64}
|
||||
{834B4E85-64E5-4382-8465-548F332E5298} = {FBFEAD1F-29EB-4D99-A672-0CD8473E10B9}
|
||||
{6B82F26D-5040-4453-B21B-C8D1F913CE4C} = {F823671B-3ECA-4AE6-86DA-25E920D3FE64}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {93384647-528D-46C8-922C-8DB36A382F0B}
|
||||
|
|
|
@ -12,6 +12,6 @@
|
|||
<MicrosoftNETTestSdkVersion>17.7.0</MicrosoftNETTestSdkVersion>
|
||||
<MicrosoftDotnetInteractive>1.0.0-beta.24229.4</MicrosoftDotnetInteractive>
|
||||
<MicrosoftSourceLinkGitHubVersion>8.0.0</MicrosoftSourceLinkGitHubVersion>
|
||||
<JsonSchemaVersion>4.0.0</JsonSchemaVersion>
|
||||
<JsonSchemaVersion>4.3.0.2</JsonSchemaVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
|
@ -1,13 +1,13 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// ContentConverter.cs
|
||||
|
||||
using AutoGen.Anthropic.DTO;
|
||||
|
||||
namespace AutoGen.Anthropic.Converters;
|
||||
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
namespace AutoGen.Anthropic.Converters;
|
||||
|
||||
public sealed class ContentBaseConverter : JsonConverter<ContentBase>
|
||||
{
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
<ItemGroup>
|
||||
<PackageReference Include="JsonSchema.Net.Generation" Version="$(JsonSchemaVersion)" />
|
||||
<PackageReference Include="System.Memory.Data" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -25,7 +25,7 @@ public static class MessageExtension
|
|||
ToolCallResultMessage toolCallResultMessage => toolCallResultMessage.FormatMessage(),
|
||||
AggregateMessage<ToolCallMessage, ToolCallResultMessage> aggregateMessage => aggregateMessage.FormatMessage(),
|
||||
_ => message.ToString(),
|
||||
};
|
||||
} ?? string.Empty;
|
||||
}
|
||||
|
||||
public static string FormatMessage(this TextMessage message)
|
||||
|
|
|
@ -95,7 +95,7 @@ public class GroupChat : IGroupChat
|
|||
|
||||
if (agentNames.Count() == 1)
|
||||
{
|
||||
return this.agents.FirstOrDefault(x => x.Name == agentNames.First());
|
||||
return this.agents.First(x => x.Name == agentNames.First());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,10 +15,6 @@
|
|||
</Description>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.Memory.Data" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AutoGen.Core\AutoGen.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -314,9 +314,9 @@ public class OpenAIChatRequestMessageConnector : IMiddleware, IStreamingMiddlewa
|
|||
|
||||
private ChatMessageImageContentItem CreateChatMessageImageContentItemFromImageMessage(ImageMessage message)
|
||||
{
|
||||
return message.Data is null
|
||||
return message.Data is null && message.Url is not null
|
||||
? new ChatMessageImageContentItem(new Uri(message.Url))
|
||||
: new ChatMessageImageContentItem(message.Data, message.Data.MediaType);
|
||||
: new ChatMessageImageContentItem(message.Data, message.Data?.MediaType);
|
||||
}
|
||||
|
||||
private IEnumerable<ChatRequestMessage> ProcessToolCallMessage(IAgent agent, ToolCallMessage message)
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="JsonSchema.Net.Generation" Version="$(JsonSchemaVersion)" />
|
||||
<ProjectReference Include="..\AutoGen.LMStudio\AutoGen.LMStudio.csproj" />
|
||||
<ProjectReference Include="..\AutoGen.Mistral\AutoGen.Mistral.csproj" />
|
||||
<ProjectReference Include="..\AutoGen.SemanticKernel\AutoGen.SemanticKernel.csproj" />
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<PublishAot>true</PublishAot>
|
||||
<InvariantGlobalization>true</InvariantGlobalization>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
<SelfContained>true</SelfContained>
|
||||
<IsAotCompatible>true</IsAotCompatible>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<TrimmerRootAssembly Include="AutoGen.Core" />
|
||||
<TrimmerRootAssembly Update="@(TrimmerRootAssembly)" Path="$(RepoRoot)\src\%(Identity)\%(Identity).csproj" />
|
||||
<ProjectReference Include="@(TrimmerRootAssembly->'%(Path)')" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,4 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Program.cs
|
||||
|
||||
Console.WriteLine("Hello, World!");
|
Loading…
Reference in New Issue