Skip to content

Commit 37d46e0

Browse files
LittleLittleCloudvictordibia
authored andcommitted
fix build and tests (#3134)
1 parent 5ec0308 commit 37d46e0

File tree

11 files changed

+320
-204
lines changed

11 files changed

+320
-204
lines changed

dotnet/sample/AutoGen.BasicSamples/CodeSnippet/CreateAnAgent.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public async Task CodeSnippet5()
129129
},
130130
functionMap: new Dictionary<string, Func<string, Task<string>>>
131131
{
132-
{ this.UpperCaseFunction.Name, this.UpperCaseWrapper }, // The wrapper function for the UpperCase function
132+
{ this.UpperCaseFunctionContract.Name, this.UpperCaseWrapper }, // The wrapper function for the UpperCase function
133133
});
134134

135135
var response = await assistantAgent.SendAsync("hello");

dotnet/sample/AutoGen.BasicSamples/Example07_Dynamic_GroupChat_Calculate_Fibonacci.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using AutoGen.Core;
99
using AutoGen.DotnetInteractive;
1010
using AutoGen.OpenAI;
11+
using AutoGen.OpenAI.Extension;
1112
using FluentAssertions;
1213

1314
public partial class Example07_Dynamic_GroupChat_Calculate_Fibonacci
@@ -138,7 +139,7 @@ public static async Task<IAgent> CreateReviewerAgentAsync()
138139
name: "code_reviewer",
139140
systemMessage: @"You review code block from coder",
140141
config: gpt3Config,
141-
functions: [functions.ReviewCodeBlockFunction],
142+
functions: [functions.ReviewCodeBlockFunctionContract.ToOpenAIFunctionDefinition()],
142143
functionMap: new Dictionary<string, Func<string, Task<string>>>()
143144
{
144145
{ nameof(ReviewCodeBlock), functions.ReviewCodeBlockWrapper },

dotnet/sample/AutoGen.BasicSamples/Example09_LMStudio_FunctionCall.cs

+5-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Text.Json.Serialization;
66
using AutoGen.Core;
77
using AutoGen.LMStudio;
8+
using AutoGen.OpenAI.Extension;
89
using Azure.AI.OpenAI;
910

1011
namespace AutoGen.BasicSample;
@@ -69,8 +70,8 @@ public static async Task RunAsync()
6970
// And ask agent to response in function call object format using few-shot example
7071
object[] functionList =
7172
[
72-
SerializeFunctionDefinition(instance.GetWeatherFunction),
73-
SerializeFunctionDefinition(instance.GoogleSearchFunction)
73+
SerializeFunctionDefinition(instance.GetWeatherFunctionContract.ToOpenAIFunctionDefinition()),
74+
SerializeFunctionDefinition(instance.GetWeatherFunctionContract.ToOpenAIFunctionDefinition())
7475
];
7576
var functionListString = JsonSerializer.Serialize(functionList, new JsonSerializerOptions { WriteIndented = true });
7677
var lmAgent = new LMStudioAgent(
@@ -98,12 +99,12 @@ You are a helpful AI assistant
9899
{
99100
var arguments = JsonSerializer.Serialize(functionCall.Arguments);
100101
// invoke function wrapper
101-
if (functionCall.Name == instance.GetWeatherFunction.Name)
102+
if (functionCall.Name == instance.GetWeatherFunctionContract.Name)
102103
{
103104
var result = await instance.GetWeatherWrapper(arguments);
104105
return new TextMessage(Role.Assistant, result);
105106
}
106-
else if (functionCall.Name == instance.GoogleSearchFunction.Name)
107+
else if (functionCall.Name == instance.GetWeatherFunctionContract.Name)
107108
{
108109
var result = await instance.GoogleSearchWrapper(arguments);
109110
return new TextMessage(Role.Assistant, result);

dotnet/src/AutoGen.Core/Function/FunctionAttribute.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class FunctionContract
3535
/// <summary>
3636
/// The name of the function.
3737
/// </summary>
38-
public string? Name { get; set; }
38+
public string Name { get; set; } = null!;
3939

4040
/// <summary>
4141
/// The description of the function.

0 commit comments

Comments
 (0)