Skip to content

Commit 7b699f2

Browse files
LittleLittleCloudDavidLuong98
authored andcommitted
[.Net] Set up Name field in OpenAIMessageConnector (#2662)
* 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]>
1 parent 9ad0d07 commit 7b699f2

File tree

9 files changed

+817
-601
lines changed

9 files changed

+817
-601
lines changed

dotnet/AutoGen.sln

+6
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoGen.Mistral.Tests", "te
3535
EndProject
3636
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoGen.SemanticKernel.Tests", "test\AutoGen.SemanticKernel.Tests\AutoGen.SemanticKernel.Tests.csproj", "{1DFABC4A-8458-4875-8DCB-59F3802DAC65}"
3737
EndProject
38+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoGen.OpenAI.Tests", "test\AutoGen.OpenAI.Tests\AutoGen.OpenAI.Tests.csproj", "{D36A85F9-C172-487D-8192-6BFE5D05B4A7}"
3839
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoGen.DotnetInteractive.Tests", "test\AutoGen.DotnetInteractive.Tests\AutoGen.DotnetInteractive.Tests.csproj", "{B61388CA-DC73-4B7F-A7B2-7B9A86C9229E}"
3940
EndProject
4041
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Autogen.Ollama", "src\Autogen.Ollama\Autogen.Ollama.csproj", "{A4EFA175-44CC-44A9-B93E-1C7B6FAC38F1}"
@@ -107,6 +108,10 @@ Global
107108
{1DFABC4A-8458-4875-8DCB-59F3802DAC65}.Debug|Any CPU.Build.0 = Debug|Any CPU
108109
{1DFABC4A-8458-4875-8DCB-59F3802DAC65}.Release|Any CPU.ActiveCfg = Release|Any CPU
109110
{1DFABC4A-8458-4875-8DCB-59F3802DAC65}.Release|Any CPU.Build.0 = Release|Any CPU
111+
{D36A85F9-C172-487D-8192-6BFE5D05B4A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
112+
{D36A85F9-C172-487D-8192-6BFE5D05B4A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
113+
{D36A85F9-C172-487D-8192-6BFE5D05B4A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
114+
{D36A85F9-C172-487D-8192-6BFE5D05B4A7}.Release|Any CPU.Build.0 = Release|Any CPU
110115
{B61388CA-DC73-4B7F-A7B2-7B9A86C9229E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
111116
{B61388CA-DC73-4B7F-A7B2-7B9A86C9229E}.Debug|Any CPU.Build.0 = Debug|Any CPU
112117
{B61388CA-DC73-4B7F-A7B2-7B9A86C9229E}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -131,6 +136,7 @@ Global
131136
{A4EFA175-44CC-44A9-B93E-1C7B6FAC38F1} = {18BF8DD7-0585-48BF-8F97-AD333080CE06}
132137
{C24FDE63-952D-4F8E-A807-AF31D43AD675} = {F823671B-3ECA-4AE6-86DA-25E920D3FE64}
133138
{1DFABC4A-8458-4875-8DCB-59F3802DAC65} = {F823671B-3ECA-4AE6-86DA-25E920D3FE64}
139+
{D36A85F9-C172-487D-8192-6BFE5D05B4A7} = {F823671B-3ECA-4AE6-86DA-25E920D3FE64}
134140
{B61388CA-DC73-4B7F-A7B2-7B9A86C9229E} = {F823671B-3ECA-4AE6-86DA-25E920D3FE64}
135141
EndGlobalSection
136142
GlobalSection(ExtensibilityGlobals) = postSolution

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

+139-218
Large diffs are not rendered by default.

dotnet/test/AutoGen.Tests/ApprovalTests/OpenAIMessageTests.BasicMessageTest.approved.txt renamed to dotnet/test/AutoGen.OpenAI.Tests/ApprovalTests/OpenAIMessageTests.BasicMessageTest.approved.txt

+13
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"OriginalMessage": "TextMessage(system, You are a helpful AI assistant, )",
44
"ConvertedMessages": [
55
{
6+
"Name": null,
67
"Role": "system",
78
"Content": "You are a helpful AI assistant"
89
}
@@ -14,6 +15,7 @@
1415
{
1516
"Role": "user",
1617
"Content": "Hello",
18+
"Name": "user",
1719
"MultiModaItem": null
1820
}
1921
]
@@ -24,6 +26,7 @@
2426
{
2527
"Role": "assistant",
2628
"Content": "How can I help you?",
29+
"Name": "assistant",
2730
"TooCall": [],
2831
"FunctionCallName": null,
2932
"FunctionCallArguments": null
@@ -34,6 +37,7 @@
3437
"OriginalMessage": "Message(system, You are a helpful AI assistant, , , )",
3538
"ConvertedMessages": [
3639
{
40+
"Name": null,
3741
"Role": "system",
3842
"Content": "You are a helpful AI assistant"
3943
}
@@ -45,6 +49,7 @@
4549
{
4650
"Role": "user",
4751
"Content": "Hello",
52+
"Name": "user",
4853
"MultiModaItem": null
4954
}
5055
]
@@ -55,6 +60,7 @@
5560
{
5661
"Role": "assistant",
5762
"Content": "How can I help you?",
63+
"Name": null,
5864
"TooCall": [],
5965
"FunctionCallName": null,
6066
"FunctionCallArguments": null
@@ -67,6 +73,7 @@
6773
{
6874
"Role": "user",
6975
"Content": "result",
76+
"Name": "user",
7077
"MultiModaItem": null
7178
}
7279
]
@@ -77,6 +84,7 @@
7784
{
7885
"Role": "assistant",
7986
"Content": null,
87+
"Name": null,
8088
"TooCall": [],
8189
"FunctionCallName": "functionName",
8290
"FunctionCallArguments": "functionArguments"
@@ -89,6 +97,7 @@
8997
{
9098
"Role": "user",
9199
"Content": null,
100+
"Name": "user",
92101
"MultiModaItem": [
93102
{
94103
"Type": "Image",
@@ -107,6 +116,7 @@
107116
{
108117
"Role": "user",
109118
"Content": null,
119+
"Name": "user",
110120
"MultiModaItem": [
111121
{
112122
"Type": "Text",
@@ -129,6 +139,7 @@
129139
{
130140
"Role": "assistant",
131141
"Content": "",
142+
"Name": "assistant",
132143
"TooCall": [
133144
{
134145
"Type": "Function",
@@ -173,6 +184,7 @@
173184
{
174185
"Role": "assistant",
175186
"Content": "",
187+
"Name": "assistant",
176188
"TooCall": [
177189
{
178190
"Type": "Function",
@@ -198,6 +210,7 @@
198210
{
199211
"Role": "assistant",
200212
"Content": "",
213+
"Name": "assistant",
201214
"TooCall": [
202215
{
203216
"Type": "Function",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>$(TestTargetFramework)</TargetFramework>
5+
<IsPackable>false</IsPackable>
6+
<GenerateDocumentationFile>True</GenerateDocumentationFile>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="ApprovalTests" Version="$(ApprovalTestVersion)" />
11+
<PackageReference Include="FluentAssertions" Version="$(FluentAssertionVersion)" />
12+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkVersion)" />
13+
<PackageReference Include="xunit" Version="$(XUnitVersion)" />
14+
<PackageReference Include="xunit.runner.console" Version="$(XUnitVersion)" />
15+
<PackageReference Include="xunit.runner.visualstudio" Version="$(XUnitVersion)" />
16+
</ItemGroup>
17+
18+
<ItemGroup>
19+
<ProjectReference Include="..\..\src\AutoGen.SourceGenerator\AutoGen.SourceGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
20+
<ProjectReference Include="..\..\src\AutoGen\AutoGen.csproj" />
21+
<ProjectReference Include="..\AutoGen.Tests\AutoGen.Tests.csproj" />
22+
</ItemGroup>
23+
24+
<ItemGroup>
25+
<None Update="ApprovalTests\OpenAIMessageTests.BasicMessageTest.approved.txt">
26+
<ParentFile>$([System.String]::Copy('%(FileName)').Split('.')[0])</ParentFile>
27+
<ParentExtension>$(ProjectExt.Replace('proj', ''))</ParentExtension>
28+
<DependentUpon>%(ParentFile)%(ParentExtension)</DependentUpon>
29+
</None>
30+
</ItemGroup>
31+
32+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// GlobalUsing.cs
3+
4+
global using AutoGen.Core;

0 commit comments

Comments
 (0)