Skip to content

Commit

Permalink
[.Net] Set up Name field in OpenAIMessageConnector (#2662)
Browse files Browse the repository at this point in the history
* create OpenAI tests project

* update

* update

* add tests

* add mroe tests:

* update comment

* Update dotnet/src/AutoGen.OpenAI/Middleware/OpenAIChatRequestMessageConnector.cs

Co-authored-by: David Luong <[email protected]>

* Update AutoGen.OpenAI.Tests.csproj

* fix build

---------

Co-authored-by: David Luong <[email protected]>
  • Loading branch information
LittleLittleCloud and DavidLuong98 committed May 16, 2024
1 parent 2749e43 commit cd44932
Show file tree
Hide file tree
Showing 9 changed files with 817 additions and 601 deletions.
6 changes: 6 additions & 0 deletions dotnet/AutoGen.sln
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoGen.Mistral.Tests", "te
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoGen.SemanticKernel.Tests", "test\AutoGen.SemanticKernel.Tests\AutoGen.SemanticKernel.Tests.csproj", "{1DFABC4A-8458-4875-8DCB-59F3802DAC65}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoGen.OpenAI.Tests", "test\AutoGen.OpenAI.Tests\AutoGen.OpenAI.Tests.csproj", "{D36A85F9-C172-487D-8192-6BFE5D05B4A7}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoGen.DotnetInteractive.Tests", "test\AutoGen.DotnetInteractive.Tests\AutoGen.DotnetInteractive.Tests.csproj", "{B61388CA-DC73-4B7F-A7B2-7B9A86C9229E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Autogen.Ollama", "src\Autogen.Ollama\Autogen.Ollama.csproj", "{A4EFA175-44CC-44A9-B93E-1C7B6FAC38F1}"
Expand Down Expand Up @@ -107,6 +108,10 @@ Global
{1DFABC4A-8458-4875-8DCB-59F3802DAC65}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1DFABC4A-8458-4875-8DCB-59F3802DAC65}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1DFABC4A-8458-4875-8DCB-59F3802DAC65}.Release|Any CPU.Build.0 = Release|Any CPU
{D36A85F9-C172-487D-8192-6BFE5D05B4A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D36A85F9-C172-487D-8192-6BFE5D05B4A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D36A85F9-C172-487D-8192-6BFE5D05B4A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D36A85F9-C172-487D-8192-6BFE5D05B4A7}.Release|Any CPU.Build.0 = Release|Any CPU
{B61388CA-DC73-4B7F-A7B2-7B9A86C9229E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B61388CA-DC73-4B7F-A7B2-7B9A86C9229E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B61388CA-DC73-4B7F-A7B2-7B9A86C9229E}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -131,6 +136,7 @@ Global
{A4EFA175-44CC-44A9-B93E-1C7B6FAC38F1} = {18BF8DD7-0585-48BF-8F97-AD333080CE06}
{C24FDE63-952D-4F8E-A807-AF31D43AD675} = {F823671B-3ECA-4AE6-86DA-25E920D3FE64}
{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}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
Expand Down
357 changes: 139 additions & 218 deletions dotnet/src/AutoGen.OpenAI/Middleware/OpenAIChatRequestMessageConnector.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"OriginalMessage": "TextMessage(system, You are a helpful AI assistant, )",
"ConvertedMessages": [
{
"Name": null,
"Role": "system",
"Content": "You are a helpful AI assistant"
}
Expand All @@ -14,6 +15,7 @@
{
"Role": "user",
"Content": "Hello",
"Name": "user",
"MultiModaItem": null
}
]
Expand All @@ -24,6 +26,7 @@
{
"Role": "assistant",
"Content": "How can I help you?",
"Name": "assistant",
"TooCall": [],
"FunctionCallName": null,
"FunctionCallArguments": null
Expand All @@ -34,6 +37,7 @@
"OriginalMessage": "Message(system, You are a helpful AI assistant, , , )",
"ConvertedMessages": [
{
"Name": null,
"Role": "system",
"Content": "You are a helpful AI assistant"
}
Expand All @@ -45,6 +49,7 @@
{
"Role": "user",
"Content": "Hello",
"Name": "user",
"MultiModaItem": null
}
]
Expand All @@ -55,6 +60,7 @@
{
"Role": "assistant",
"Content": "How can I help you?",
"Name": null,
"TooCall": [],
"FunctionCallName": null,
"FunctionCallArguments": null
Expand All @@ -67,6 +73,7 @@
{
"Role": "user",
"Content": "result",
"Name": "user",
"MultiModaItem": null
}
]
Expand All @@ -77,6 +84,7 @@
{
"Role": "assistant",
"Content": null,
"Name": null,
"TooCall": [],
"FunctionCallName": "functionName",
"FunctionCallArguments": "functionArguments"
Expand All @@ -89,6 +97,7 @@
{
"Role": "user",
"Content": null,
"Name": "user",
"MultiModaItem": [
{
"Type": "Image",
Expand All @@ -107,6 +116,7 @@
{
"Role": "user",
"Content": null,
"Name": "user",
"MultiModaItem": [
{
"Type": "Text",
Expand All @@ -129,6 +139,7 @@
{
"Role": "assistant",
"Content": "",
"Name": "assistant",
"TooCall": [
{
"Type": "Function",
Expand Down Expand Up @@ -173,6 +184,7 @@
{
"Role": "assistant",
"Content": "",
"Name": "assistant",
"TooCall": [
{
"Type": "Function",
Expand All @@ -198,6 +210,7 @@
{
"Role": "assistant",
"Content": "",
"Name": "assistant",
"TooCall": [
{
"Type": "Function",
Expand Down
32 changes: 32 additions & 0 deletions dotnet/test/AutoGen.OpenAI.Tests/AutoGen.OpenAI.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>$(TestTargetFramework)</TargetFramework>
<IsPackable>false</IsPackable>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ApprovalTests" Version="$(ApprovalTestVersion)" />
<PackageReference Include="FluentAssertions" Version="$(FluentAssertionVersion)" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkVersion)" />
<PackageReference Include="xunit" Version="$(XUnitVersion)" />
<PackageReference Include="xunit.runner.console" Version="$(XUnitVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="$(XUnitVersion)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\AutoGen.SourceGenerator\AutoGen.SourceGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
<ProjectReference Include="..\..\src\AutoGen\AutoGen.csproj" />
<ProjectReference Include="..\AutoGen.Tests\AutoGen.Tests.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="ApprovalTests\OpenAIMessageTests.BasicMessageTest.approved.txt">
<ParentFile>$([System.String]::Copy('%(FileName)').Split('.')[0])</ParentFile>
<ParentExtension>$(ProjectExt.Replace('proj', ''))</ParentExtension>
<DependentUpon>%(ParentFile)%(ParentExtension)</DependentUpon>
</None>
</ItemGroup>

</Project>
4 changes: 4 additions & 0 deletions dotnet/test/AutoGen.OpenAI.Tests/GlobalUsing.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// GlobalUsing.cs

global using AutoGen.Core;

0 comments on commit cd44932

Please sign in to comment.