Skip to content

Commit

Permalink
fix build and tests (#3134)
Browse files Browse the repository at this point in the history
  • Loading branch information
LittleLittleCloud committed Jul 15, 2024
1 parent 178bb8d commit 7205ccc
Show file tree
Hide file tree
Showing 11 changed files with 320 additions and 204 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public async Task CodeSnippet5()
},
functionMap: new Dictionary<string, Func<string, Task<string>>>
{
{ this.UpperCaseFunction.Name, this.UpperCaseWrapper }, // The wrapper function for the UpperCase function
{ this.UpperCaseFunctionContract.Name, this.UpperCaseWrapper }, // The wrapper function for the UpperCase function
});

var response = await assistantAgent.SendAsync("hello");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using AutoGen.Core;
using AutoGen.DotnetInteractive;
using AutoGen.OpenAI;
using AutoGen.OpenAI.Extension;
using FluentAssertions;

public partial class Example07_Dynamic_GroupChat_Calculate_Fibonacci
Expand Down Expand Up @@ -138,7 +139,7 @@ public static async Task<IAgent> CreateReviewerAgentAsync()
name: "code_reviewer",
systemMessage: @"You review code block from coder",
config: gpt3Config,
functions: [functions.ReviewCodeBlockFunction],
functions: [functions.ReviewCodeBlockFunctionContract.ToOpenAIFunctionDefinition()],
functionMap: new Dictionary<string, Func<string, Task<string>>>()
{
{ nameof(ReviewCodeBlock), functions.ReviewCodeBlockWrapper },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text.Json.Serialization;
using AutoGen.Core;
using AutoGen.LMStudio;
using AutoGen.OpenAI.Extension;
using Azure.AI.OpenAI;

namespace AutoGen.BasicSample;
Expand Down Expand Up @@ -69,8 +70,8 @@ public static async Task RunAsync()
// And ask agent to response in function call object format using few-shot example
object[] functionList =
[
SerializeFunctionDefinition(instance.GetWeatherFunction),
SerializeFunctionDefinition(instance.GoogleSearchFunction)
SerializeFunctionDefinition(instance.GetWeatherFunctionContract.ToOpenAIFunctionDefinition()),
SerializeFunctionDefinition(instance.GetWeatherFunctionContract.ToOpenAIFunctionDefinition())
];
var functionListString = JsonSerializer.Serialize(functionList, new JsonSerializerOptions { WriteIndented = true });
var lmAgent = new LMStudioAgent(
Expand Down Expand Up @@ -98,12 +99,12 @@ You are a helpful AI assistant
{
var arguments = JsonSerializer.Serialize(functionCall.Arguments);
// invoke function wrapper
if (functionCall.Name == instance.GetWeatherFunction.Name)
if (functionCall.Name == instance.GetWeatherFunctionContract.Name)
{
var result = await instance.GetWeatherWrapper(arguments);
return new TextMessage(Role.Assistant, result);
}
else if (functionCall.Name == instance.GoogleSearchFunction.Name)
else if (functionCall.Name == instance.GetWeatherFunctionContract.Name)
{
var result = await instance.GoogleSearchWrapper(arguments);
return new TextMessage(Role.Assistant, result);
Expand Down
2 changes: 1 addition & 1 deletion dotnet/src/AutoGen.Core/Function/FunctionAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class FunctionContract
/// <summary>
/// The name of the function.
/// </summary>
public string? Name { get; set; }
public string Name { get; set; } = null!;

/// <summary>
/// The description of the function.
Expand Down
Loading

0 comments on commit 7205ccc

Please sign in to comment.