Skip to content

A programming framework for agentic AI

[.Net] fix #3203 (#3204)

Xiaoyun Zhang155da1573464
diff --git a/dotnet/Directory.Build.props b/dotnet/Directory.Build.props
index 29e40fff3..b5663fe4c 100644
--- a/dotnet/Directory.Build.props
+++ b/dotnet/Directory.Build.props
@@ -4,7 +4,8 @@
<Import Project="./eng/MetaInfo.props" />
<Import Project="./eng/Sign.props" />
<PropertyGroup>
- <TestTargetFramework>net8.0</TestTargetFramework>
+ <PackageTargetFrameworks>netstandard2.0;net6.0;net8.0</PackageTargetFrameworks>
+ <TestTargetFrameworks>net8.0</TestTargetFrameworks>
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
<SignAssembly>True</SignAssembly>
diff --git a/dotnet/sample/AutoGen.Anthropic.Samples/AutoGen.Anthropic.Samples.csproj b/dotnet/sample/AutoGen.Anthropic.Samples/AutoGen.Anthropic.Samples.csproj
index 2948c9bf2..fe7553b93 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 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
- <TargetFramework>$(TestTargetFramework)</TargetFramework>
+ <TargetFrameworks>$(TestTargetFrameworks)</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
diff --git a/dotnet/sample/AutoGen.BasicSamples/AutoGen.BasicSample.csproj b/dotnet/sample/AutoGen.BasicSamples/AutoGen.BasicSample.csproj
index 6f55a0459..d4323ee4c 100644
--- a/dotnet/sample/AutoGen.BasicSamples/AutoGen.BasicSample.csproj
+++ b/dotnet/sample/AutoGen.BasicSamples/AutoGen.BasicSample.csproj
@@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
- <TargetFramework>$(TestTargetFramework)</TargetFramework>
+ <TargetFrameworks>$(TestTargetFrameworks)</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<NoWarn>$(NoWarn);CS8981;CS8600;CS8602;CS8604;CS8618;CS0219;SKEXP0054;SKEXP0050;SKEXP0110</NoWarn>
diff --git a/dotnet/sample/AutoGen.Gemini.Sample/AutoGen.Gemini.Sample.csproj b/dotnet/sample/AutoGen.Gemini.Sample/AutoGen.Gemini.Sample.csproj
index b1779b56c..d1df8a8ed 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 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
- <TargetFramework>net8.0</TargetFramework>
+ <TargetFrameworks>$(TestTargetFrameworks)</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IncludeResourceFolder>true</IncludeResourceFolder>
diff --git a/dotnet/sample/AutoGen.Ollama.Sample/AutoGen.Ollama.Sample.csproj b/dotnet/sample/AutoGen.Ollama.Sample/AutoGen.Ollama.Sample.csproj
index 5277408d5..62c9d6163 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 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
- <TargetFramework>$(TestTargetFramework)</TargetFramework>
+ <TargetFrameworks>$(TestTargetFrameworks)</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<NoWarn>$(NoWarn);CS8981;CS8600;CS8602;CS8604;CS8618;CS0219;SKEXP0054;SKEXP0050;SKEXP0110</NoWarn>
diff --git a/dotnet/sample/AutoGen.OpenAI.Sample/AutoGen.OpenAI.Sample.csproj b/dotnet/sample/AutoGen.OpenAI.Sample/AutoGen.OpenAI.Sample.csproj
index ffe18f8a6..49c0e21c9 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 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
- <TargetFramework>net8.0</TargetFramework>
+ <TargetFrameworks>$(TestTargetFrameworks)</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
diff --git a/dotnet/sample/AutoGen.SemanticKernel.Sample/AutoGen.SemanticKernel.Sample.csproj b/dotnet/sample/AutoGen.SemanticKernel.Sample/AutoGen.SemanticKernel.Sample.csproj
index 6c2266512..df1064e18 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 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
- <TargetFramework>$(TestTargetFramework)</TargetFramework>
+ <TargetFrameworks>$(TestTargetFrameworks)</TargetFrameworks>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<NoWarn>$(NoWarn);CS8981;CS8600;CS8602;CS8604;CS8618;CS0219;SKEXP0054;SKEXP0050;SKEXP0110</NoWarn>
<ImplicitUsings>enable</ImplicitUsings>
diff --git a/dotnet/sample/AutoGen.WebAPI.Sample/AutoGen.WebAPI.Sample.csproj b/dotnet/sample/AutoGen.WebAPI.Sample/AutoGen.WebAPI.Sample.csproj
index 41f3b7d1d..76675ba12 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 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
- <TargetFramework>net8.0</TargetFramework>
+ <TargetFrameworks>$(TestTargetFrameworks)</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
diff --git a/dotnet/src/AutoGen.Anthropic/AutoGen.Anthropic.csproj b/dotnet/src/AutoGen.Anthropic/AutoGen.Anthropic.csproj
index fefc439e0..a4fd32e7e 100644
--- a/dotnet/src/AutoGen.Anthropic/AutoGen.Anthropic.csproj
+++ b/dotnet/src/AutoGen.Anthropic/AutoGen.Anthropic.csproj
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>netstandard2.0</TargetFramework>
- <RootNamespace>AutoGen.Anthropic</RootNamespace>
+ <TargetFrameworks>$(PackageTargetFrameworks)</TargetFrameworks>
+ <RootNamespace>AutoGen.Anthropic</RootNamespace>
</PropertyGroup>
<Import Project="$(RepoRoot)/nuget/nuget-package.props" />
diff --git a/dotnet/src/AutoGen.Anthropic/Converters/JsonPropertyNameEnumCoverter.cs b/dotnet/src/AutoGen.Anthropic/Converters/JsonPropertyNameEnumCoverter.cs
index cd95d837c..68b3c14bd 100644
--- a/dotnet/src/AutoGen.Anthropic/Converters/JsonPropertyNameEnumCoverter.cs
+++ b/dotnet/src/AutoGen.Anthropic/Converters/JsonPropertyNameEnumCoverter.cs
@@ -29,7 +29,7 @@ internal class JsonPropertyNameEnumConverter<T> : JsonConverter<T> where T : str
public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
{
var field = value.GetType().GetField(value.ToString());
- var attribute = field.GetCustomAttribute<JsonPropertyNameAttribute>();
+ var attribute = field?.GetCustomAttribute<JsonPropertyNameAttribute>();
if (attribute != null)
{
diff --git a/dotnet/src/AutoGen.Core/AutoGen.Core.csproj b/dotnet/src/AutoGen.Core/AutoGen.Core.csproj
index 60aeb3ae3..8cf9e9183 100644
--- a/dotnet/src/AutoGen.Core/AutoGen.Core.csproj
+++ b/dotnet/src/AutoGen.Core/AutoGen.Core.csproj
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>netstandard2.0</TargetFramework>
+ <TargetFrameworks>$(PackageTargetFrameworks)</TargetFrameworks>
<RootNamespace>AutoGen.Core</RootNamespace>
</PropertyGroup>
@@ -17,7 +17,10 @@
<ItemGroup>
<PackageReference Include="JsonSchema.Net.Generation" Version="$(JsonSchemaVersion)" />
<PackageReference Include="System.Memory.Data" Version="8.0.0" />
- <PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
</ItemGroup>
+
+ <ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
+ <PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
+ </ItemGroup>
</Project>
diff --git a/dotnet/src/AutoGen.DotnetInteractive/AutoGen.DotnetInteractive.csproj b/dotnet/src/AutoGen.DotnetInteractive/AutoGen.DotnetInteractive.csproj
index 72c67fe78..96b331f2d 100644
--- a/dotnet/src/AutoGen.DotnetInteractive/AutoGen.DotnetInteractive.csproj
+++ b/dotnet/src/AutoGen.DotnetInteractive/AutoGen.DotnetInteractive.csproj
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>netstandard2.0</TargetFramework>
+ <TargetFrameworks>$(PackageTargetFrameworks)</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>AutoGen.DotnetInteractive</RootNamespace>
diff --git a/dotnet/src/AutoGen.DotnetInteractive/InteractiveService.cs b/dotnet/src/AutoGen.DotnetInteractive/InteractiveService.cs
index 1ca19fcbc..3797dfcff 100644
--- a/dotnet/src/AutoGen.DotnetInteractive/InteractiveService.cs
+++ b/dotnet/src/AutoGen.DotnetInteractive/InteractiveService.cs
@@ -104,6 +104,11 @@ public class InteractiveService : IDisposable
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 29c4d1bb9..9a6059650 100644
--- a/dotnet/src/AutoGen.Gemini/AutoGen.Gemini.csproj
+++ b/dotnet/src/AutoGen.Gemini/AutoGen.Gemini.csproj
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>netstandard2.0</TargetFramework>
+ <TargetFrameworks>$(PackageTargetFrameworks)</TargetFrameworks>
</PropertyGroup>
<Import Project="$(RepoRoot)/nuget/nuget-package.props" />
diff --git a/dotnet/src/AutoGen.LMStudio/AutoGen.LMStudio.csproj b/dotnet/src/AutoGen.LMStudio/AutoGen.LMStudio.csproj
index f45a2f7eb..8725d564d 100644
--- a/dotnet/src/AutoGen.LMStudio/AutoGen.LMStudio.csproj
+++ b/dotnet/src/AutoGen.LMStudio/AutoGen.LMStudio.csproj
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>netstandard2.0</TargetFramework>
+ <TargetFrameworks>$(PackageTargetFrameworks)</TargetFrameworks>
<RootNamespace>AutoGen.LMStudio</RootNamespace>
</PropertyGroup>
diff --git a/dotnet/src/AutoGen.LMStudio/LMStudioAgent.cs b/dotnet/src/AutoGen.LMStudio/LMStudioAgent.cs
index 9d0daa535..c3930abc0 100644
--- a/dotnet/src/AutoGen.LMStudio/LMStudioAgent.cs
+++ b/dotnet/src/AutoGen.LMStudio/LMStudioAgent.cs
@@ -80,7 +80,7 @@ public class LMStudioAgent : IAgent
{
// 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 25cc05fec..ee905d117 100644
--- a/dotnet/src/AutoGen.Mistral/AutoGen.Mistral.csproj
+++ b/dotnet/src/AutoGen.Mistral/AutoGen.Mistral.csproj
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>netstandard2.0</TargetFramework>
+ <TargetFrameworks>$(PackageTargetFrameworks)</TargetFrameworks>
<RootNamespace>AutoGen.Mistral</RootNamespace>
</PropertyGroup>
diff --git a/dotnet/src/AutoGen.Mistral/Converters/JsonPropertyNameEnumConverter.cs b/dotnet/src/AutoGen.Mistral/Converters/JsonPropertyNameEnumConverter.cs
index 5a4f9f9cb..9ecf11428 100644
--- a/dotnet/src/AutoGen.Mistral/Converters/JsonPropertyNameEnumConverter.cs
+++ b/dotnet/src/AutoGen.Mistral/Converters/JsonPropertyNameEnumConverter.cs
@@ -29,7 +29,7 @@ internal class JsonPropertyNameEnumConverter<T> : JsonConverter<T> where T : str
public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
{
var field = value.GetType().GetField(value.ToString());
- var attribute = field.GetCustomAttribute<JsonPropertyNameAttribute>();
+ var attribute = field?.GetCustomAttribute<JsonPropertyNameAttribute>();
if (attribute != null)
{
diff --git a/dotnet/src/AutoGen.Mistral/MistralClient.cs b/dotnet/src/AutoGen.Mistral/MistralClient.cs
index 5fc3d1109..8c6802f30 100644
--- a/dotnet/src/AutoGen.Mistral/MistralClient.cs
+++ b/dotnet/src/AutoGen.Mistral/MistralClient.cs
@@ -49,7 +49,7 @@ public class MistralClient : IDisposable
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 class MistralClient : IDisposable
else if (currentEvent.EventType == null)
{
var res = await JsonSerializer.DeserializeAsync<ChatCompletionResponse>(
- 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<ErrorResponse>(
- 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 a939f138c..512fe92f3 100644
--- a/dotnet/src/AutoGen.Ollama/AutoGen.Ollama.csproj
+++ b/dotnet/src/AutoGen.Ollama/AutoGen.Ollama.csproj
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>netstandard2.0</TargetFramework>
+ <TargetFrameworks>$(PackageTargetFrameworks)</TargetFrameworks>
<RootNamespace>AutoGen.Ollama</RootNamespace>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>
diff --git a/dotnet/src/AutoGen.Ollama/Middlewares/OllamaMessageConnector.cs b/dotnet/src/AutoGen.Ollama/Middlewares/OllamaMessageConnector.cs
index 3919b238d..9e85ca12f 100644
--- a/dotnet/src/AutoGen.Ollama/Middlewares/OllamaMessageConnector.cs
+++ b/dotnet/src/AutoGen.Ollama/Middlewares/OllamaMessageConnector.cs
@@ -101,7 +101,7 @@ public class OllamaMessageConnector : IStreamingMiddleware
// collect all the images
var images = imageMessages.SelectMany(m => ProcessImageMessage((ImageMessage)m, agent)
- .SelectMany(m => (m as IMessage<Message>)?.Content.Images));
+ .SelectMany(m => (m as IMessage<Message>)?.Content.Images ?? []));
var message = new Message()
{
diff --git a/dotnet/src/AutoGen.OpenAI/Agent/OpenAIChatAgent.cs b/dotnet/src/AutoGen.OpenAI/Agent/OpenAIChatAgent.cs
index 4608a416f..c957801f0 100644
--- a/dotnet/src/AutoGen.OpenAI/Agent/OpenAIChatAgent.cs
+++ b/dotnet/src/AutoGen.OpenAI/Agent/OpenAIChatAgent.cs
@@ -147,6 +147,16 @@ public class OpenAIChatAgent : IStreamingAgent
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 })
{
diff --git a/dotnet/src/AutoGen.OpenAI/AutoGen.OpenAI.csproj b/dotnet/src/AutoGen.OpenAI/AutoGen.OpenAI.csproj
index 7220cfe5c..e3a2f41c8 100644
--- a/dotnet/src/AutoGen.OpenAI/AutoGen.OpenAI.csproj
+++ b/dotnet/src/AutoGen.OpenAI/AutoGen.OpenAI.csproj
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>netstandard2.0</TargetFramework>
+ <TargetFrameworks>$(PackageTargetFrameworks)</TargetFrameworks>
<RootNamespace>AutoGen.OpenAI</RootNamespace>
</PropertyGroup>
diff --git a/dotnet/src/AutoGen.SemanticKernel/AutoGen.SemanticKernel.csproj b/dotnet/src/AutoGen.SemanticKernel/AutoGen.SemanticKernel.csproj
index 3bd96f93b..1cc4d8e12 100644
--- a/dotnet/src/AutoGen.SemanticKernel/AutoGen.SemanticKernel.csproj
+++ b/dotnet/src/AutoGen.SemanticKernel/AutoGen.SemanticKernel.csproj
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>netstandard2.0</TargetFramework>
+ <TargetFrameworks>$(PackageTargetFrameworks)</TargetFrameworks>
<RootNamespace>AutoGen.SemanticKernel</RootNamespace>
<NoWarn>$(NoWarn);SKEXP0110</NoWarn>
</PropertyGroup>
diff --git a/dotnet/src/AutoGen/AutoGen.csproj b/dotnet/src/AutoGen/AutoGen.csproj
index ddc34a071..3cb5a23da 100644
--- a/dotnet/src/AutoGen/AutoGen.csproj
+++ b/dotnet/src/AutoGen/AutoGen.csproj
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>netstandard2.0</TargetFramework>
+ <TargetFrameworks>$(PackageTargetFrameworks)</TargetFrameworks>
<RootNamespace>AutoGen</RootNamespace>
</PropertyGroup>
diff --git a/dotnet/src/AutoGen/Middleware/HumanInputMiddleware.cs b/dotnet/src/AutoGen/Middleware/HumanInputMiddleware.cs
index 1a742b11c..eda3c001a 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<IEnumerable<IMessage>, CancellationToken, Task<bool>> isTermination;
- private Func<string> getInput = Console.ReadLine;
+ private Func<string?> getInput = Console.ReadLine;
private Action<string> writeLine = Console.WriteLine;
public string? Name => nameof(HumanInputMiddleware);
@@ -27,7 +27,7 @@ public class HumanInputMiddleware : IMiddleware
string exitKeyword = "exit",
HumanInputMode mode = HumanInputMode.AUTO,
Func<IEnumerable<IMessage>, CancellationToken, Task<bool>>? isTermination = null,
- Func<string>? getInput = null,
+ Func<string?>? getInput = null,
Action<string>? writeLine = null)
{
this.prompt = prompt;
@@ -56,6 +56,8 @@ public class HumanInputMiddleware : IMiddleware
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 class HumanInputMiddleware : IMiddleware
return new TextMessage(Role.Assistant, GroupChatExtension.TERMINATE, agent.Name);
}
+ input ??= string.Empty;
+
return new TextMessage(Role.Assistant, input, agent.Name);
}
@@ -85,7 +89,7 @@ public class HumanInputMiddleware : IMiddleware
return messages?.Last().IsGroupChatTerminateMessage() is true;
}
- private string GetInput()
+ private string? GetInput()
{
return Console.ReadLine();
}
diff --git a/dotnet/test/AutoGen.Anthropic.Tests/AutoGen.Anthropic.Tests.csproj b/dotnet/test/AutoGen.Anthropic.Tests/AutoGen.Anthropic.Tests.csproj
index ac479ed2e..ac9617c1a 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 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>$(TestTargetFramework)</TargetFramework>
+ <TargetFrameworks>$(TestTargetFrameworks)</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
diff --git a/dotnet/test/AutoGen.DotnetInteractive.Tests/AutoGen.DotnetInteractive.Tests.csproj b/dotnet/test/AutoGen.DotnetInteractive.Tests/AutoGen.DotnetInteractive.Tests.csproj
index 0f77db2c1..7f7001a87 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 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>$(TestTargetFramework)</TargetFramework>
+ <TargetFrameworks>$(TestTargetFrameworks)</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
<IsTestProject>True</IsTestProject>
diff --git a/dotnet/test/AutoGen.Gemini.Tests/AutoGen.Gemini.Tests.csproj b/dotnet/test/AutoGen.Gemini.Tests/AutoGen.Gemini.Tests.csproj
index f4fb55825..0b9b7e2a2 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 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
- <TargetFramework>$(TestTargetFramework)</TargetFramework>
+ <TargetFrameworks>$(TestTargetFrameworks)</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
diff --git a/dotnet/test/AutoGen.Mistral.Tests/AutoGen.Mistral.Tests.csproj b/dotnet/test/AutoGen.Mistral.Tests/AutoGen.Mistral.Tests.csproj
index d734119db..aa20a835e 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 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>$(TestTargetFramework)</TargetFramework>
+ <TargetFrameworks>$(TestTargetFrameworks)</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
<IsTestProject>True</IsTestProject>
diff --git a/dotnet/test/AutoGen.Ollama.Tests/AutoGen.Ollama.Tests.csproj b/dotnet/test/AutoGen.Ollama.Tests/AutoGen.Ollama.Tests.csproj
index 1e26b38d8..c5ca19556 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 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>$(TestTargetFramework)</TargetFramework>
+ <TargetFrameworks>$(TestTargetFrameworks)</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
<IsTestProject>True</IsTestProject>
diff --git a/dotnet/test/AutoGen.OpenAI.Tests/AutoGen.OpenAI.Tests.csproj b/dotnet/test/AutoGen.OpenAI.Tests/AutoGen.OpenAI.Tests.csproj
index 04800a631..b176bc3e6 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 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>$(TestTargetFramework)</TargetFramework>
+ <TargetFrameworks>$(TestTargetFrameworks)</TargetFrameworks>
<IsPackable>false</IsPackable>
<IsTestProject>True</IsTestProject>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
diff --git a/dotnet/test/AutoGen.SemanticKernel.Tests/AutoGen.SemanticKernel.Tests.csproj b/dotnet/test/AutoGen.SemanticKernel.Tests/AutoGen.SemanticKernel.Tests.csproj
index 8be4b55b1..7f42b67da 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 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>$(TestTargetFramework)</TargetFramework>
+ <TargetFrameworks>$(TestTargetFrameworks)</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
<NoWarn>$(NoWarn);SKEXP0110</NoWarn>
diff --git a/dotnet/test/AutoGen.SourceGenerator.Tests/AutoGen.SourceGenerator.Tests.csproj b/dotnet/test/AutoGen.SourceGenerator.Tests/AutoGen.SourceGenerator.Tests.csproj
index 2e0ead045..f7d814a6c 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 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>$(TestTargetFramework)</TargetFramework>
+ <TargetFrameworks>$(TestTargetFrameworks)</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
<IsTestProject>True</IsTestProject>
diff --git a/dotnet/test/AutoGen.Tests/AutoGen.Tests.csproj b/dotnet/test/AutoGen.Tests/AutoGen.Tests.csproj
index 3dc669b5e..ce968b91f 100644
--- a/dotnet/test/AutoGen.Tests/AutoGen.Tests.csproj
+++ b/dotnet/test/AutoGen.Tests/AutoGen.Tests.csproj
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>$(TestTargetFramework)</TargetFramework>
+ <TargetFrameworks>$(TestTargetFrameworks)</TargetFrameworks>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<IsTestProject>True</IsTestProject>
<NoWarn>$(NoWarn);xUnit1013;SKEXP0110</NoWarn>
diff --git a/dotnet/test/AutoGen.WebAPI.Tests/AutoGen.WebAPI.Tests.csproj b/dotnet/test/AutoGen.WebAPI.Tests/AutoGen.WebAPI.Tests.csproj
index 3a9caf38f..7ec6c408c 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 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>$(TestTargetFramework)</TargetFramework>
+ <TargetFrameworks>$(TestTargetFrameworks)</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>