From 5d93931a321ec1f9a9ce4e95e70a8f330382437e Mon Sep 17 00:00:00 2001 From: XiaoYun Zhang Date: Wed, 24 Jul 2024 12:26:36 -0700 Subject: [PATCH 1/3] add net6 & net8 --- dotnet/Directory.Build.props | 1 + dotnet/src/AutoGen.Anthropic/AutoGen.Anthropic.csproj | 4 ++-- .../Converters/JsonPropertyNameEnumCoverter.cs | 2 +- dotnet/src/AutoGen.Core/AutoGen.Core.csproj | 7 +++++-- .../AutoGen.DotnetInteractive.csproj | 2 +- .../AutoGen.DotnetInteractive/InteractiveService.cs | 5 +++++ dotnet/src/AutoGen.Gemini/AutoGen.Gemini.csproj | 2 +- dotnet/src/AutoGen.LMStudio/AutoGen.LMStudio.csproj | 2 +- dotnet/src/AutoGen.LMStudio/LMStudioAgent.cs | 2 +- dotnet/src/AutoGen.Mistral/AutoGen.Mistral.csproj | 2 +- .../Converters/JsonPropertyNameEnumConverter.cs | 2 +- dotnet/src/AutoGen.Mistral/MistralClient.cs | 6 +++--- dotnet/src/AutoGen.Ollama/AutoGen.Ollama.csproj | 2 +- .../Middlewares/OllamaMessageConnector.cs | 2 +- dotnet/src/AutoGen.OpenAI/AutoGen.OpenAI.csproj | 2 +- .../AutoGen.SemanticKernel.csproj | 2 +- dotnet/src/AutoGen/AutoGen.csproj | 2 +- dotnet/src/AutoGen/Middleware/HumanInputMiddleware.cs | 10 +++++++--- 18 files changed, 35 insertions(+), 22 deletions(-) diff --git a/dotnet/Directory.Build.props b/dotnet/Directory.Build.props index 29e40fff384c..8c7cf9a4fcd7 100644 --- a/dotnet/Directory.Build.props +++ b/dotnet/Directory.Build.props @@ -4,6 +4,7 @@ + netstandard2.0;net6.0;net8.0 net8.0 preview enable diff --git a/dotnet/src/AutoGen.Anthropic/AutoGen.Anthropic.csproj b/dotnet/src/AutoGen.Anthropic/AutoGen.Anthropic.csproj index fefc439e00ba..a4fd32e7e345 100644 --- a/dotnet/src/AutoGen.Anthropic/AutoGen.Anthropic.csproj +++ b/dotnet/src/AutoGen.Anthropic/AutoGen.Anthropic.csproj @@ -1,8 +1,8 @@  - netstandard2.0 - AutoGen.Anthropic + $(PackageTargetFrameworks) + AutoGen.Anthropic diff --git a/dotnet/src/AutoGen.Anthropic/Converters/JsonPropertyNameEnumCoverter.cs b/dotnet/src/AutoGen.Anthropic/Converters/JsonPropertyNameEnumCoverter.cs index cd95d837cffd..68b3c14bdee6 100644 --- a/dotnet/src/AutoGen.Anthropic/Converters/JsonPropertyNameEnumCoverter.cs +++ b/dotnet/src/AutoGen.Anthropic/Converters/JsonPropertyNameEnumCoverter.cs @@ -29,7 +29,7 @@ public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerial public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options) { var field = value.GetType().GetField(value.ToString()); - var attribute = field.GetCustomAttribute(); + var attribute = field?.GetCustomAttribute(); if (attribute != null) { diff --git a/dotnet/src/AutoGen.Core/AutoGen.Core.csproj b/dotnet/src/AutoGen.Core/AutoGen.Core.csproj index 60aeb3ae3fca..8cf9e9183d40 100644 --- a/dotnet/src/AutoGen.Core/AutoGen.Core.csproj +++ b/dotnet/src/AutoGen.Core/AutoGen.Core.csproj @@ -1,6 +1,6 @@  - netstandard2.0 + $(PackageTargetFrameworks) AutoGen.Core @@ -17,7 +17,10 @@ - + + + + diff --git a/dotnet/src/AutoGen.DotnetInteractive/AutoGen.DotnetInteractive.csproj b/dotnet/src/AutoGen.DotnetInteractive/AutoGen.DotnetInteractive.csproj index 72c67fe78016..96b331f2df3b 100644 --- a/dotnet/src/AutoGen.DotnetInteractive/AutoGen.DotnetInteractive.csproj +++ b/dotnet/src/AutoGen.DotnetInteractive/AutoGen.DotnetInteractive.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + $(PackageTargetFrameworks) enable enable AutoGen.DotnetInteractive diff --git a/dotnet/src/AutoGen.DotnetInteractive/InteractiveService.cs b/dotnet/src/AutoGen.DotnetInteractive/InteractiveService.cs index 1ca19fcbcfff..3797dfcff649 100644 --- a/dotnet/src/AutoGen.DotnetInteractive/InteractiveService.cs +++ b/dotnet/src/AutoGen.DotnetInteractive/InteractiveService.cs @@ -104,6 +104,11 @@ public async Task StartAsync(string workingDirectory, CancellationToken ct public bool RestoreDotnetInteractive() { + if (this.installingDirectory is null) + { + throw new Exception("Installing directory is not set"); + } + this.WriteLine("Restore dotnet interactive tool"); // write RestoreInteractive.config from embedded resource to this.workingDirectory var assembly = Assembly.GetAssembly(typeof(InteractiveService))!; diff --git a/dotnet/src/AutoGen.Gemini/AutoGen.Gemini.csproj b/dotnet/src/AutoGen.Gemini/AutoGen.Gemini.csproj index 29c4d1bb9c6f..9a60596503bc 100644 --- a/dotnet/src/AutoGen.Gemini/AutoGen.Gemini.csproj +++ b/dotnet/src/AutoGen.Gemini/AutoGen.Gemini.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + $(PackageTargetFrameworks) diff --git a/dotnet/src/AutoGen.LMStudio/AutoGen.LMStudio.csproj b/dotnet/src/AutoGen.LMStudio/AutoGen.LMStudio.csproj index f45a2f7eba5f..8725d564df41 100644 --- a/dotnet/src/AutoGen.LMStudio/AutoGen.LMStudio.csproj +++ b/dotnet/src/AutoGen.LMStudio/AutoGen.LMStudio.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + $(PackageTargetFrameworks) AutoGen.LMStudio diff --git a/dotnet/src/AutoGen.LMStudio/LMStudioAgent.cs b/dotnet/src/AutoGen.LMStudio/LMStudioAgent.cs index 9d0daa535b23..c3930abc0def 100644 --- a/dotnet/src/AutoGen.LMStudio/LMStudioAgent.cs +++ b/dotnet/src/AutoGen.LMStudio/LMStudioAgent.cs @@ -80,7 +80,7 @@ protected override Task SendAsync(HttpRequestMessage reques { // request.RequestUri = new Uri($"{_modelServiceUrl}{request.RequestUri.PathAndQuery}"); var uriBuilder = new UriBuilder(_modelServiceUrl); - uriBuilder.Path = request.RequestUri.PathAndQuery; + uriBuilder.Path = request.RequestUri?.PathAndQuery ?? throw new InvalidOperationException("RequestUri is null"); request.RequestUri = uriBuilder.Uri; return base.SendAsync(request, cancellationToken); } diff --git a/dotnet/src/AutoGen.Mistral/AutoGen.Mistral.csproj b/dotnet/src/AutoGen.Mistral/AutoGen.Mistral.csproj index 25cc05fec922..ee905d117791 100644 --- a/dotnet/src/AutoGen.Mistral/AutoGen.Mistral.csproj +++ b/dotnet/src/AutoGen.Mistral/AutoGen.Mistral.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + $(PackageTargetFrameworks) AutoGen.Mistral diff --git a/dotnet/src/AutoGen.Mistral/Converters/JsonPropertyNameEnumConverter.cs b/dotnet/src/AutoGen.Mistral/Converters/JsonPropertyNameEnumConverter.cs index 5a4f9f9cb189..9ecf11428397 100644 --- a/dotnet/src/AutoGen.Mistral/Converters/JsonPropertyNameEnumConverter.cs +++ b/dotnet/src/AutoGen.Mistral/Converters/JsonPropertyNameEnumConverter.cs @@ -29,7 +29,7 @@ public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerial public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options) { var field = value.GetType().GetField(value.ToString()); - var attribute = field.GetCustomAttribute(); + var attribute = field?.GetCustomAttribute(); if (attribute != null) { diff --git a/dotnet/src/AutoGen.Mistral/MistralClient.cs b/dotnet/src/AutoGen.Mistral/MistralClient.cs index 5fc3d110985e..8c6802f30eb1 100644 --- a/dotnet/src/AutoGen.Mistral/MistralClient.cs +++ b/dotnet/src/AutoGen.Mistral/MistralClient.cs @@ -49,7 +49,7 @@ public async IAsyncEnumerable StreamingChatCompletionsAs var response = await HttpRequestRaw(HttpMethod.Post, chatCompletionRequest, streaming: true); using var stream = await response.Content.ReadAsStreamAsync(); using StreamReader reader = new StreamReader(stream); - string line; + string? line = null; SseEvent currentEvent = new SseEvent(); while ((line = await reader.ReadLineAsync()) != null) @@ -67,13 +67,13 @@ public async IAsyncEnumerable StreamingChatCompletionsAs else if (currentEvent.EventType == null) { var res = await JsonSerializer.DeserializeAsync( - new MemoryStream(Encoding.UTF8.GetBytes(currentEvent.Data))) ?? throw new Exception("Failed to deserialize response"); + new MemoryStream(Encoding.UTF8.GetBytes(currentEvent.Data ?? string.Empty))) ?? throw new Exception("Failed to deserialize response"); yield return res; } else if (currentEvent.EventType != null) { var res = await JsonSerializer.DeserializeAsync( - new MemoryStream(Encoding.UTF8.GetBytes(currentEvent.Data))); + new MemoryStream(Encoding.UTF8.GetBytes(currentEvent.Data ?? string.Empty))); throw new Exception(res?.Error.Message); } diff --git a/dotnet/src/AutoGen.Ollama/AutoGen.Ollama.csproj b/dotnet/src/AutoGen.Ollama/AutoGen.Ollama.csproj index a939f138c1c1..512fe92f3e3e 100644 --- a/dotnet/src/AutoGen.Ollama/AutoGen.Ollama.csproj +++ b/dotnet/src/AutoGen.Ollama/AutoGen.Ollama.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + $(PackageTargetFrameworks) AutoGen.Ollama True diff --git a/dotnet/src/AutoGen.Ollama/Middlewares/OllamaMessageConnector.cs b/dotnet/src/AutoGen.Ollama/Middlewares/OllamaMessageConnector.cs index 3919b238d659..9e85ca12fd9e 100644 --- a/dotnet/src/AutoGen.Ollama/Middlewares/OllamaMessageConnector.cs +++ b/dotnet/src/AutoGen.Ollama/Middlewares/OllamaMessageConnector.cs @@ -101,7 +101,7 @@ private IEnumerable ProcessMultiModalMessage(MultiModalMessage multiMo // collect all the images var images = imageMessages.SelectMany(m => ProcessImageMessage((ImageMessage)m, agent) - .SelectMany(m => (m as IMessage)?.Content.Images)); + .SelectMany(m => (m as IMessage)?.Content.Images ?? [])); var message = new Message() { diff --git a/dotnet/src/AutoGen.OpenAI/AutoGen.OpenAI.csproj b/dotnet/src/AutoGen.OpenAI/AutoGen.OpenAI.csproj index 7220cfe5c628..e3a2f41c8f7a 100644 --- a/dotnet/src/AutoGen.OpenAI/AutoGen.OpenAI.csproj +++ b/dotnet/src/AutoGen.OpenAI/AutoGen.OpenAI.csproj @@ -1,6 +1,6 @@  - netstandard2.0 + $(PackageTargetFrameworks) AutoGen.OpenAI diff --git a/dotnet/src/AutoGen.SemanticKernel/AutoGen.SemanticKernel.csproj b/dotnet/src/AutoGen.SemanticKernel/AutoGen.SemanticKernel.csproj index 3bd96f93b687..1cc4d8e127a7 100644 --- a/dotnet/src/AutoGen.SemanticKernel/AutoGen.SemanticKernel.csproj +++ b/dotnet/src/AutoGen.SemanticKernel/AutoGen.SemanticKernel.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + $(PackageTargetFrameworks) AutoGen.SemanticKernel $(NoWarn);SKEXP0110 diff --git a/dotnet/src/AutoGen/AutoGen.csproj b/dotnet/src/AutoGen/AutoGen.csproj index ddc34a071cbf..3cb5a23da14c 100644 --- a/dotnet/src/AutoGen/AutoGen.csproj +++ b/dotnet/src/AutoGen/AutoGen.csproj @@ -1,6 +1,6 @@  - netstandard2.0 + $(PackageTargetFrameworks) AutoGen diff --git a/dotnet/src/AutoGen/Middleware/HumanInputMiddleware.cs b/dotnet/src/AutoGen/Middleware/HumanInputMiddleware.cs index 1a742b11c799..eda3c001a249 100644 --- a/dotnet/src/AutoGen/Middleware/HumanInputMiddleware.cs +++ b/dotnet/src/AutoGen/Middleware/HumanInputMiddleware.cs @@ -18,7 +18,7 @@ public class HumanInputMiddleware : IMiddleware private readonly string prompt; private readonly string exitKeyword; private Func, CancellationToken, Task> isTermination; - private Func getInput = Console.ReadLine; + private Func getInput = Console.ReadLine; private Action writeLine = Console.WriteLine; public string? Name => nameof(HumanInputMiddleware); @@ -27,7 +27,7 @@ public HumanInputMiddleware( string exitKeyword = "exit", HumanInputMode mode = HumanInputMode.AUTO, Func, CancellationToken, Task>? isTermination = null, - Func? getInput = null, + Func? getInput = null, Action? writeLine = null) { this.prompt = prompt; @@ -56,6 +56,8 @@ public async Task InvokeAsync(MiddlewareContext context, IAgent agent, return new TextMessage(Role.Assistant, GroupChatExtension.TERMINATE, agent.Name); } + input ??= string.Empty; + return new TextMessage(Role.Assistant, input, agent.Name); } @@ -74,6 +76,8 @@ public async Task InvokeAsync(MiddlewareContext context, IAgent agent, return new TextMessage(Role.Assistant, GroupChatExtension.TERMINATE, agent.Name); } + input ??= string.Empty; + return new TextMessage(Role.Assistant, input, agent.Name); } @@ -85,7 +89,7 @@ private async Task DefaultIsTermination(IEnumerable messages, Ca return messages?.Last().IsGroupChatTerminateMessage() is true; } - private string GetInput() + private string? GetInput() { return Console.ReadLine(); } From abfc7a278f0eaf5192618b415d1dbc8fcb588c25 Mon Sep 17 00:00:00 2001 From: XiaoYun Zhang Date: Wed, 24 Jul 2024 12:38:48 -0700 Subject: [PATCH 2/3] update --- dotnet/Directory.Build.props | 2 +- .../AutoGen.Anthropic.Samples/AutoGen.Anthropic.Samples.csproj | 2 +- dotnet/sample/AutoGen.BasicSamples/AutoGen.BasicSample.csproj | 2 +- .../sample/AutoGen.Gemini.Sample/AutoGen.Gemini.Sample.csproj | 2 +- .../sample/AutoGen.Ollama.Sample/AutoGen.Ollama.Sample.csproj | 2 +- .../sample/AutoGen.OpenAI.Sample/AutoGen.OpenAI.Sample.csproj | 2 +- .../AutoGen.SemanticKernel.Sample.csproj | 2 +- .../sample/AutoGen.WebAPI.Sample/AutoGen.WebAPI.Sample.csproj | 2 +- .../test/AutoGen.Anthropic.Tests/AutoGen.Anthropic.Tests.csproj | 2 +- .../AutoGen.DotnetInteractive.Tests.csproj | 2 +- dotnet/test/AutoGen.Gemini.Tests/AutoGen.Gemini.Tests.csproj | 2 +- dotnet/test/AutoGen.Mistral.Tests/AutoGen.Mistral.Tests.csproj | 2 +- dotnet/test/AutoGen.Ollama.Tests/AutoGen.Ollama.Tests.csproj | 2 +- dotnet/test/AutoGen.OpenAI.Tests/AutoGen.OpenAI.Tests.csproj | 2 +- .../AutoGen.SemanticKernel.Tests.csproj | 2 +- .../AutoGen.SourceGenerator.Tests.csproj | 2 +- dotnet/test/AutoGen.Tests/AutoGen.Tests.csproj | 2 +- dotnet/test/AutoGen.WebAPI.Tests/AutoGen.WebAPI.Tests.csproj | 2 +- 18 files changed, 18 insertions(+), 18 deletions(-) diff --git a/dotnet/Directory.Build.props b/dotnet/Directory.Build.props index 8c7cf9a4fcd7..b5663fe4c578 100644 --- a/dotnet/Directory.Build.props +++ b/dotnet/Directory.Build.props @@ -5,7 +5,7 @@ netstandard2.0;net6.0;net8.0 - net8.0 + net8.0 preview enable True diff --git a/dotnet/sample/AutoGen.Anthropic.Samples/AutoGen.Anthropic.Samples.csproj b/dotnet/sample/AutoGen.Anthropic.Samples/AutoGen.Anthropic.Samples.csproj index 2948c9bf283c..fe7553b937f4 100644 --- a/dotnet/sample/AutoGen.Anthropic.Samples/AutoGen.Anthropic.Samples.csproj +++ b/dotnet/sample/AutoGen.Anthropic.Samples/AutoGen.Anthropic.Samples.csproj @@ -2,7 +2,7 @@ Exe - $(TestTargetFramework) + $(TestTargetFrameworks) enable enable True diff --git a/dotnet/sample/AutoGen.BasicSamples/AutoGen.BasicSample.csproj b/dotnet/sample/AutoGen.BasicSamples/AutoGen.BasicSample.csproj index 6f55a04592f5..d4323ee4c924 100644 --- a/dotnet/sample/AutoGen.BasicSamples/AutoGen.BasicSample.csproj +++ b/dotnet/sample/AutoGen.BasicSamples/AutoGen.BasicSample.csproj @@ -2,7 +2,7 @@ Exe - $(TestTargetFramework) + $(TestTargetFrameworks) enable True $(NoWarn);CS8981;CS8600;CS8602;CS8604;CS8618;CS0219;SKEXP0054;SKEXP0050;SKEXP0110 diff --git a/dotnet/sample/AutoGen.Gemini.Sample/AutoGen.Gemini.Sample.csproj b/dotnet/sample/AutoGen.Gemini.Sample/AutoGen.Gemini.Sample.csproj index b1779b56c390..d1df8a8ed161 100644 --- a/dotnet/sample/AutoGen.Gemini.Sample/AutoGen.Gemini.Sample.csproj +++ b/dotnet/sample/AutoGen.Gemini.Sample/AutoGen.Gemini.Sample.csproj @@ -2,7 +2,7 @@ Exe - net8.0 + $(TestTargetFrameworks) enable enable true diff --git a/dotnet/sample/AutoGen.Ollama.Sample/AutoGen.Ollama.Sample.csproj b/dotnet/sample/AutoGen.Ollama.Sample/AutoGen.Ollama.Sample.csproj index 5277408d595d..62c9d61633c9 100644 --- a/dotnet/sample/AutoGen.Ollama.Sample/AutoGen.Ollama.Sample.csproj +++ b/dotnet/sample/AutoGen.Ollama.Sample/AutoGen.Ollama.Sample.csproj @@ -1,7 +1,7 @@  Exe - $(TestTargetFramework) + $(TestTargetFrameworks) enable True $(NoWarn);CS8981;CS8600;CS8602;CS8604;CS8618;CS0219;SKEXP0054;SKEXP0050;SKEXP0110 diff --git a/dotnet/sample/AutoGen.OpenAI.Sample/AutoGen.OpenAI.Sample.csproj b/dotnet/sample/AutoGen.OpenAI.Sample/AutoGen.OpenAI.Sample.csproj index ffe18f8a616a..49c0e21c9ece 100644 --- a/dotnet/sample/AutoGen.OpenAI.Sample/AutoGen.OpenAI.Sample.csproj +++ b/dotnet/sample/AutoGen.OpenAI.Sample/AutoGen.OpenAI.Sample.csproj @@ -2,7 +2,7 @@ Exe - net8.0 + $(TestTargetFrameworks) enable enable True diff --git a/dotnet/sample/AutoGen.SemanticKernel.Sample/AutoGen.SemanticKernel.Sample.csproj b/dotnet/sample/AutoGen.SemanticKernel.Sample/AutoGen.SemanticKernel.Sample.csproj index 6c2266512929..df1064e18c44 100644 --- a/dotnet/sample/AutoGen.SemanticKernel.Sample/AutoGen.SemanticKernel.Sample.csproj +++ b/dotnet/sample/AutoGen.SemanticKernel.Sample/AutoGen.SemanticKernel.Sample.csproj @@ -2,7 +2,7 @@ Exe - $(TestTargetFramework) + $(TestTargetFrameworks) True $(NoWarn);CS8981;CS8600;CS8602;CS8604;CS8618;CS0219;SKEXP0054;SKEXP0050;SKEXP0110 enable diff --git a/dotnet/sample/AutoGen.WebAPI.Sample/AutoGen.WebAPI.Sample.csproj b/dotnet/sample/AutoGen.WebAPI.Sample/AutoGen.WebAPI.Sample.csproj index 41f3b7d1d381..76675ba12346 100644 --- a/dotnet/sample/AutoGen.WebAPI.Sample/AutoGen.WebAPI.Sample.csproj +++ b/dotnet/sample/AutoGen.WebAPI.Sample/AutoGen.WebAPI.Sample.csproj @@ -1,7 +1,7 @@  - net8.0 + $(TestTargetFrameworks) enable enable diff --git a/dotnet/test/AutoGen.Anthropic.Tests/AutoGen.Anthropic.Tests.csproj b/dotnet/test/AutoGen.Anthropic.Tests/AutoGen.Anthropic.Tests.csproj index ac479ed2e722..ac9617c1a573 100644 --- a/dotnet/test/AutoGen.Anthropic.Tests/AutoGen.Anthropic.Tests.csproj +++ b/dotnet/test/AutoGen.Anthropic.Tests/AutoGen.Anthropic.Tests.csproj @@ -1,7 +1,7 @@ - $(TestTargetFramework) + $(TestTargetFrameworks) enable false True diff --git a/dotnet/test/AutoGen.DotnetInteractive.Tests/AutoGen.DotnetInteractive.Tests.csproj b/dotnet/test/AutoGen.DotnetInteractive.Tests/AutoGen.DotnetInteractive.Tests.csproj index 0f77db2c1c36..7f7001a877d1 100644 --- a/dotnet/test/AutoGen.DotnetInteractive.Tests/AutoGen.DotnetInteractive.Tests.csproj +++ b/dotnet/test/AutoGen.DotnetInteractive.Tests/AutoGen.DotnetInteractive.Tests.csproj @@ -1,7 +1,7 @@  - $(TestTargetFramework) + $(TestTargetFrameworks) enable false True diff --git a/dotnet/test/AutoGen.Gemini.Tests/AutoGen.Gemini.Tests.csproj b/dotnet/test/AutoGen.Gemini.Tests/AutoGen.Gemini.Tests.csproj index f4fb55825e54..0b9b7e2a24b0 100644 --- a/dotnet/test/AutoGen.Gemini.Tests/AutoGen.Gemini.Tests.csproj +++ b/dotnet/test/AutoGen.Gemini.Tests/AutoGen.Gemini.Tests.csproj @@ -2,7 +2,7 @@ Exe - $(TestTargetFramework) + $(TestTargetFrameworks) enable enable True diff --git a/dotnet/test/AutoGen.Mistral.Tests/AutoGen.Mistral.Tests.csproj b/dotnet/test/AutoGen.Mistral.Tests/AutoGen.Mistral.Tests.csproj index d734119dbb09..aa20a835e9b9 100644 --- a/dotnet/test/AutoGen.Mistral.Tests/AutoGen.Mistral.Tests.csproj +++ b/dotnet/test/AutoGen.Mistral.Tests/AutoGen.Mistral.Tests.csproj @@ -1,7 +1,7 @@  - $(TestTargetFramework) + $(TestTargetFrameworks) enable false True diff --git a/dotnet/test/AutoGen.Ollama.Tests/AutoGen.Ollama.Tests.csproj b/dotnet/test/AutoGen.Ollama.Tests/AutoGen.Ollama.Tests.csproj index 1e26b38d8a4f..c5ca19556244 100644 --- a/dotnet/test/AutoGen.Ollama.Tests/AutoGen.Ollama.Tests.csproj +++ b/dotnet/test/AutoGen.Ollama.Tests/AutoGen.Ollama.Tests.csproj @@ -1,7 +1,7 @@ - $(TestTargetFramework) + $(TestTargetFrameworks) enable false True diff --git a/dotnet/test/AutoGen.OpenAI.Tests/AutoGen.OpenAI.Tests.csproj b/dotnet/test/AutoGen.OpenAI.Tests/AutoGen.OpenAI.Tests.csproj index 04800a631ee6..b176bc3e6ac2 100644 --- a/dotnet/test/AutoGen.OpenAI.Tests/AutoGen.OpenAI.Tests.csproj +++ b/dotnet/test/AutoGen.OpenAI.Tests/AutoGen.OpenAI.Tests.csproj @@ -1,7 +1,7 @@  - $(TestTargetFramework) + $(TestTargetFrameworks) false True True diff --git a/dotnet/test/AutoGen.SemanticKernel.Tests/AutoGen.SemanticKernel.Tests.csproj b/dotnet/test/AutoGen.SemanticKernel.Tests/AutoGen.SemanticKernel.Tests.csproj index 8be4b55b1722..7f42b67da715 100644 --- a/dotnet/test/AutoGen.SemanticKernel.Tests/AutoGen.SemanticKernel.Tests.csproj +++ b/dotnet/test/AutoGen.SemanticKernel.Tests/AutoGen.SemanticKernel.Tests.csproj @@ -1,7 +1,7 @@  - $(TestTargetFramework) + $(TestTargetFrameworks) enable false $(NoWarn);SKEXP0110 diff --git a/dotnet/test/AutoGen.SourceGenerator.Tests/AutoGen.SourceGenerator.Tests.csproj b/dotnet/test/AutoGen.SourceGenerator.Tests/AutoGen.SourceGenerator.Tests.csproj index 2e0ead045bef..f7d814a6cdef 100644 --- a/dotnet/test/AutoGen.SourceGenerator.Tests/AutoGen.SourceGenerator.Tests.csproj +++ b/dotnet/test/AutoGen.SourceGenerator.Tests/AutoGen.SourceGenerator.Tests.csproj @@ -1,7 +1,7 @@  - $(TestTargetFramework) + $(TestTargetFrameworks) enable false True diff --git a/dotnet/test/AutoGen.Tests/AutoGen.Tests.csproj b/dotnet/test/AutoGen.Tests/AutoGen.Tests.csproj index 3dc669b5edd8..ce968b91f556 100644 --- a/dotnet/test/AutoGen.Tests/AutoGen.Tests.csproj +++ b/dotnet/test/AutoGen.Tests/AutoGen.Tests.csproj @@ -1,7 +1,7 @@  - $(TestTargetFramework) + $(TestTargetFrameworks) True True $(NoWarn);xUnit1013;SKEXP0110 diff --git a/dotnet/test/AutoGen.WebAPI.Tests/AutoGen.WebAPI.Tests.csproj b/dotnet/test/AutoGen.WebAPI.Tests/AutoGen.WebAPI.Tests.csproj index 3a9caf38fc8e..7ec6c408cfe8 100644 --- a/dotnet/test/AutoGen.WebAPI.Tests/AutoGen.WebAPI.Tests.csproj +++ b/dotnet/test/AutoGen.WebAPI.Tests/AutoGen.WebAPI.Tests.csproj @@ -1,7 +1,7 @@  - $(TestTargetFramework) + $(TestTargetFrameworks) enable enable false From deeb73308453fa152022fdf55906de584ee6dfc8 Mon Sep 17 00:00:00 2001 From: XiaoYun Zhang Date: Wed, 24 Jul 2024 13:17:16 -0700 Subject: [PATCH 3/3] add tools and stop sequence --- dotnet/src/AutoGen.OpenAI/Agent/OpenAIChatAgent.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dotnet/src/AutoGen.OpenAI/Agent/OpenAIChatAgent.cs b/dotnet/src/AutoGen.OpenAI/Agent/OpenAIChatAgent.cs index 4608a416feda..c957801f0238 100644 --- a/dotnet/src/AutoGen.OpenAI/Agent/OpenAIChatAgent.cs +++ b/dotnet/src/AutoGen.OpenAI/Agent/OpenAIChatAgent.cs @@ -147,6 +147,16 @@ private ChatCompletionsOptions CreateChatCompletionsOptions(GenerateReplyOptions settings.Temperature = options?.Temperature ?? settings.Temperature; settings.MaxTokens = options?.MaxToken ?? settings.MaxTokens; + foreach (var functions in this.options.Tools) + { + settings.Tools.Add(functions); + } + + foreach (var stopSequence in this.options.StopSequences) + { + settings.StopSequences.Add(stopSequence); + } + var openAIFunctionDefinitions = options?.Functions?.Select(f => f.ToOpenAIFunctionDefinition()).ToList(); if (openAIFunctionDefinitions is { Count: > 0 }) {