diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
index 4e469df1730d..d2219e6c7ed2 100644
--- a/.github/workflows/docs.yml
+++ b/.github/workflows/docs.yml
@@ -35,7 +35,6 @@ jobs:
{ ref: "v0.4.0.dev0", dest-dir: "0.4.0.dev0" },
{ ref: "v0.4.0.dev1", dest-dir: "0.4.0.dev1" },
{ ref: "v0.4.0.dev2", dest-dir: "0.4.0.dev2" },
- { ref: "v0.4.0.dev3", dest-dir: "0.4.0.dev3" },
]
steps:
- name: Checkout
diff --git a/README.md b/README.md
index 049612da46be..43bdd263d310 100644
--- a/README.md
+++ b/README.md
@@ -101,7 +101,7 @@ We look forward to your contributions!
First install the packages:
```bash
-pip install 'autogen-agentchat==0.4.0.dev3' 'autogen-ext[docker]==0.4.0.dev3'
+pip install autogen-agentchat==0.4.0.dev2 autogen-ext==0.4.0.dev2
```
The following code uses code execution, you need to have [Docker installed](https://docs.docker.com/engine/install/)
@@ -109,11 +109,17 @@ and running on your machine.
```python
import asyncio
+import logging
+from autogen_agentchat import EVENT_LOGGER_NAME
+from autogen_agentchat.agents import CodeExecutorAgent, CodingAssistantAgent
+from autogen_agentchat.logging import ConsoleLogHandler
+from autogen_agentchat.teams import RoundRobinGroupChat, StopMessageTermination
from autogen_ext.code_executor.docker_executor import DockerCommandLineCodeExecutor
from autogen_ext.models import OpenAIChatCompletionClient
-from autogen_agentchat.agents import CodeExecutorAgent, CodingAssistantAgent
-from autogen_agentchat.teams import RoundRobinGroupChat
-from autogen_agentchat.task import TextMentionTermination
+
+logger = logging.getLogger(EVENT_LOGGER_NAME)
+logger.addHandler(ConsoleLogHandler())
+logger.setLevel(logging.INFO)
async def main() -> None:
async with DockerCommandLineCodeExecutor(work_dir="coding") as code_executor:
@@ -121,13 +127,11 @@ async def main() -> None:
coding_assistant_agent = CodingAssistantAgent(
"coding_assistant", model_client=OpenAIChatCompletionClient(model="gpt-4o", api_key="YOUR_API_KEY")
)
- termination = TextMentionTermination("TERMINATE")
- group_chat = RoundRobinGroupChat([coding_assistant_agent, code_executor_agent], termination_condition=termination)
- stream = group_chat.run_stream(
- "Create a plot of NVDIA and TSLA stock returns YTD from 2024-01-01 and save it to 'nvidia_tesla_2024_ytd.png'."
+ group_chat = RoundRobinGroupChat([coding_assistant_agent, code_executor_agent])
+ result = await group_chat.run(
+ task="Create a plot of NVDIA and TSLA stock returns YTD from 2024-01-01 and save it to 'nvidia_tesla_2024_ytd.png'.",
+ termination_condition=StopMessageTermination(),
)
- async for message in stream:
- print(message)
asyncio.run(main())
```
diff --git a/docs/switcher.json b/docs/switcher.json
index 8bde73629168..364394a4f3f7 100644
--- a/docs/switcher.json
+++ b/docs/switcher.json
@@ -21,12 +21,7 @@
{
"name": "0.4.0.dev2",
"version": "0.4.0.dev2",
- "url": "/autogen/0.4.0.dev2/"
- },
- {
- "name": "0.4.0.dev3",
- "version": "0.4.0.dev3",
- "url": "/autogen/0.4.0.dev3/",
+ "url": "/autogen/0.4.0.dev2/",
"preferred": true
}
]
diff --git a/dotnet/.gitignore b/dotnet/.gitignore
index 2fc32d9ac7e4..25f613c7945f 100644
--- a/dotnet/.gitignore
+++ b/dotnet/.gitignore
@@ -37,6 +37,9 @@ bld/
# vs code cache
.vscode/
+# Properties
+Properties/
+
artifacts/
output/
@@ -53,6 +56,8 @@ bld/
[Ll]og/
[Ll]ogs/
+appsettings.json
+
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
diff --git a/dotnet/AutoGen.sln b/dotnet/AutoGen.sln
index 4f82713b5adb..291cb484649d 100644
--- a/dotnet/AutoGen.sln
+++ b/dotnet/AutoGen.sln
@@ -68,13 +68,6 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{243E768F-EA7D-4AF1-B625-0398440BB1AB}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
- .gitattributes = .gitattributes
- .gitignore = .gitignore
- Directory.Build.props = Directory.Build.props
- Directory.Build.targets = Directory.Build.targets
- Directory.Packages.props = Directory.Packages.props
- global.json = global.json
- NuGet.config = NuGet.config
spelling.dic = spelling.dic
EndProjectSection
EndProject
@@ -130,7 +123,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HelloAgent", "samples\Hello
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AIModelClientHostingExtensions", "src\Microsoft.AutoGen\Extensions\AIModelClientHostingExtensions\AIModelClientHostingExtensions.csproj", "{97550E87-48C6-4EBF-85E1-413ABAE9DBFD}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AutoGen.Agents.Tests", "Microsoft.AutoGen.Agents.Tests\Microsoft.AutoGen.Agents.Tests.csproj", "{CF4C92BD-28AE-4B8F-B173-601004AEC9BF}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AutoGen.Agents.Tests", "Microsoft.AutoGen.Agents.Tests\Microsoft.AutoGen.Agents.Tests.csproj", "{CF4C92BD-28AE-4B8F-B173-601004AEC9BF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sample", "sample", "{686480D7-8FEC-4ED3-9C5D-CEBE1057A7ED}"
EndProject
diff --git a/dotnet/Directory.Build.props b/dotnet/Directory.Build.props
index 1e84f78232ad..bb78c84d14f4 100644
--- a/dotnet/Directory.Build.props
+++ b/dotnet/Directory.Build.props
@@ -13,7 +13,6 @@
CS1998;CS1591;CS8002;
SKEXP0001;SKEXP0010;SKEXP0020
$(NoWarn);$(CSNoWarn);$(SKEXPNoWarn);NU5104
-
true
true
false
@@ -33,6 +32,10 @@
$(NoWarn);CA1829
+
+
+
+
diff --git a/dotnet/Directory.Packages.props b/dotnet/Directory.Packages.props
index 75580bba007a..dd9df7161047 100644
--- a/dotnet/Directory.Packages.props
+++ b/dotnet/Directory.Packages.props
@@ -3,7 +3,7 @@
true
1.22.0
1.22.0-alpha
- 9.0.0-preview.9.24525.1
+ 9.0.0-preview.9.24507.7
@@ -111,5 +111,6 @@
+
-
+
\ No newline at end of file
diff --git a/dotnet/samples/AutoGen.BasicSamples/AutoGen.BasicSample.csproj b/dotnet/samples/AutoGen.BasicSamples/AutoGen.BasicSample.csproj
index 9e510ffa2f1a..460c95f3743a 100644
--- a/dotnet/samples/AutoGen.BasicSamples/AutoGen.BasicSample.csproj
+++ b/dotnet/samples/AutoGen.BasicSamples/AutoGen.BasicSample.csproj
@@ -15,6 +15,5 @@
-
diff --git a/dotnet/samples/AutoGen.BasicSamples/Example03_Agent_FunctionCall.cs b/dotnet/samples/AutoGen.BasicSamples/Example03_Agent_FunctionCall.cs
index c1087080350d..ca05a42ca367 100644
--- a/dotnet/samples/AutoGen.BasicSamples/Example03_Agent_FunctionCall.cs
+++ b/dotnet/samples/AutoGen.BasicSamples/Example03_Agent_FunctionCall.cs
@@ -6,7 +6,6 @@
using AutoGen.OpenAI;
using AutoGen.OpenAI.Extension;
using FluentAssertions;
-using Microsoft.Extensions.AI;
///
/// This example shows how to add type-safe function call to an agent.
@@ -38,20 +37,13 @@ public async Task ConcatString(string[] strings)
///
/// price, should be an integer
/// tax rate, should be in range (0, 1)
- [Function]
+ [FunctionAttribute]
public async Task CalculateTax(int price, float taxRate)
{
return $"tax is {price * taxRate}";
}
- ///
- /// This example shows how to add type-safe function call using AutoGen.SourceGenerator.
- /// The SourceGenerator will automatically generate FunctionDefinition and FunctionCallWrapper during compiling time.
- ///
- /// For adding type-safe function call from M.E.A.I tools, please refer to .
- ///
- ///
- public static async Task ToolCallWithSourceGenerator()
+ public static async Task RunAsync()
{
var instance = new Example03_Agent_FunctionCall();
var gpt4o = LLMConfiguration.GetOpenAIGPT4o_mini();
@@ -109,60 +101,4 @@ public static async Task ToolCallWithSourceGenerator()
// send aggregate message back to llm to get the final result
var finalResult = await agent.SendAsync(calculateTaxes);
}
-
- ///
- /// This example shows how to add type-safe function call from M.E.A.I tools.
- ///
- /// For adding type-safe function call from source generator, please refer to .
- ///
- public static async Task ToolCallWithMEAITools()
- {
- var gpt4o = LLMConfiguration.GetOpenAIGPT4o_mini();
- var instance = new Example03_Agent_FunctionCall();
-
- AIFunction[] tools = [
- AIFunctionFactory.Create(instance.UpperCase),
- AIFunctionFactory.Create(instance.ConcatString),
- AIFunctionFactory.Create(instance.CalculateTax),
- ];
-
- var toolCallMiddleware = new FunctionCallMiddleware(tools);
-
- var agent = new OpenAIChatAgent(
- chatClient: gpt4o,
- name: "agent",
- systemMessage: "You are a helpful AI assistant")
- .RegisterMessageConnector()
- .RegisterStreamingMiddleware(toolCallMiddleware)
- .RegisterPrintMessage();
-
- // talk to the assistant agent
- var upperCase = await agent.SendAsync("convert to upper case: hello world");
- upperCase.GetContent()?.Should().Be("HELLO WORLD");
- upperCase.Should().BeOfType();
- upperCase.GetToolCalls().Should().HaveCount(1);
- upperCase.GetToolCalls().First().FunctionName.Should().Be(nameof(UpperCase));
-
- var concatString = await agent.SendAsync("concatenate strings: a, b, c, d, e");
- concatString.GetContent()?.Should().Be("a b c d e");
- concatString.Should().BeOfType();
- concatString.GetToolCalls().Should().HaveCount(1);
- concatString.GetToolCalls().First().FunctionName.Should().Be(nameof(ConcatString));
-
- var calculateTax = await agent.SendAsync("calculate tax: 100, 0.1");
- calculateTax.GetContent().Should().Be("tax is 10");
- calculateTax.Should().BeOfType();
- calculateTax.GetToolCalls().Should().HaveCount(1);
- calculateTax.GetToolCalls().First().FunctionName.Should().Be(nameof(CalculateTax));
-
- // parallel function calls
- var calculateTaxes = await agent.SendAsync("calculate tax: 100, 0.1; calculate tax: 200, 0.2");
- calculateTaxes.GetContent().Should().Be("tax is 10\ntax is 40"); // "tax is 10\n tax is 40
- calculateTaxes.Should().BeOfType();
- calculateTaxes.GetToolCalls().Should().HaveCount(2);
- calculateTaxes.GetToolCalls().First().FunctionName.Should().Be(nameof(CalculateTax));
-
- // send aggregate message back to llm to get the final result
- var finalResult = await agent.SendAsync(calculateTaxes);
- }
}
diff --git a/dotnet/samples/AutoGen.BasicSamples/Program.cs b/dotnet/samples/AutoGen.BasicSamples/Program.cs
index 16a79e75cffe..3a2edbb585f4 100644
--- a/dotnet/samples/AutoGen.BasicSamples/Program.cs
+++ b/dotnet/samples/AutoGen.BasicSamples/Program.cs
@@ -11,8 +11,7 @@
// When a new sample is created please add them to the allSamples collection
("Assistant Agent", Example01_AssistantAgent.RunAsync),
("Two-agent Math Chat", Example02_TwoAgent_MathChat.RunAsync),
- ("Agent Function Call With Source Generator", Example03_Agent_FunctionCall.ToolCallWithSourceGenerator),
- ("Agent Function Call With M.E.A.I AI Functions", Example03_Agent_FunctionCall.ToolCallWithMEAITools),
+ ("Agent Function Call", Example03_Agent_FunctionCall.RunAsync),
("Dynamic Group Chat Coding Task", Example04_Dynamic_GroupChat_Coding_Task.RunAsync),
("DALL-E and GPT4v", Example05_Dalle_And_GPT4V.RunAsync),
("User Proxy Agent", Example06_UserProxyAgent.RunAsync),
diff --git a/dotnet/samples/AutoGen.WebAPI.Sample/Properties/launchSettings.json b/dotnet/samples/AutoGen.WebAPI.Sample/Properties/launchSettings.json
deleted file mode 100644
index b9cc7582305f..000000000000
--- a/dotnet/samples/AutoGen.WebAPI.Sample/Properties/launchSettings.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "profiles": {
- "AutoGen.WebAPI.Sample": {
- "commandName": "Project",
- "launchBrowser": true,
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- },
- "applicationUrl": "https://localhost:50675;http://localhost:50676"
- }
- }
-}
\ No newline at end of file
diff --git a/dotnet/samples/Hello/Backend/Backend.csproj b/dotnet/samples/Hello/Backend/Backend.csproj
index 2f5a02ee5117..60097b5d379d 100644
--- a/dotnet/samples/Hello/Backend/Backend.csproj
+++ b/dotnet/samples/Hello/Backend/Backend.csproj
@@ -1,16 +1,14 @@
-
-
- Exe
- net8.0
- enable
- enable
-
-
+
-
+
+ Exe
+ net8.0
+ enable
+ enable
+
diff --git a/dotnet/samples/Hello/Backend/Program.cs b/dotnet/samples/Hello/Backend/Program.cs
index 7abdb205a85c..9f55daf69fc9 100644
--- a/dotnet/samples/Hello/Backend/Program.cs
+++ b/dotnet/samples/Hello/Backend/Program.cs
@@ -1,5 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Program.cs
+using Microsoft.Extensions.Hosting;
+
var app = await Microsoft.AutoGen.Runtime.Host.StartAsync(local: true);
await app.WaitForShutdownAsync();
diff --git a/dotnet/samples/Hello/Backend/Properties/launchSettings.json b/dotnet/samples/Hello/Backend/Properties/launchSettings.json
deleted file mode 100644
index db9c6bf2c316..000000000000
--- a/dotnet/samples/Hello/Backend/Properties/launchSettings.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "profiles": {
- "Backend": {
- "commandName": "Project",
- "launchBrowser": true,
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- },
- "applicationUrl": "https://localhost:53071;http://localhost:53072"
- }
- }
-}
\ No newline at end of file
diff --git a/dotnet/samples/Hello/Hello.AppHost/Hello.AppHost.csproj b/dotnet/samples/Hello/Hello.AppHost/Hello.AppHost.csproj
index 88d23268c44d..3ecd30dee13a 100644
--- a/dotnet/samples/Hello/Hello.AppHost/Hello.AppHost.csproj
+++ b/dotnet/samples/Hello/Hello.AppHost/Hello.AppHost.csproj
@@ -1,4 +1,5 @@
+
Exe
net8.0
@@ -9,12 +10,12 @@
-
-
+
+
-
+
diff --git a/dotnet/samples/Hello/Hello.AppHost/Properties/launchSettings.json b/dotnet/samples/Hello/Hello.AppHost/Properties/launchSettings.json
deleted file mode 100644
index ea78f2933fdb..000000000000
--- a/dotnet/samples/Hello/Hello.AppHost/Properties/launchSettings.json
+++ /dev/null
@@ -1,43 +0,0 @@
-{
- "profiles": {
- "https": {
- "commandName": "Project",
- "launchBrowser": true,
- "dotnetRunMessages": true,
- "applicationUrl": "https://localhost:15887;http://localhost:15888",
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development",
- "DOTNET_ENVIRONMENT": "Development",
- //"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:16037",
- "DOTNET_DASHBOARD_OTLP_HTTP_ENDPOINT_URL": "https://localhost:16038",
- "DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:17037",
- "DOTNET_ASPIRE_SHOW_DASHBOARD_RESOURCES": "true"
- }
- },
- "http": {
- "commandName": "Project",
- "launchBrowser": true,
- "dotnetRunMessages": true,
- "applicationUrl": "http://localhost:15888",
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development",
- "DOTNET_ENVIRONMENT": "Development",
- //"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:16031",
- "DOTNET_DASHBOARD_OTLP_HTTP_ENDPOINT_URL": "http://localhost:16032",
- "DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:17031",
- "DOTNET_ASPIRE_SHOW_DASHBOARD_RESOURCES": "true",
- "ASPIRE_ALLOW_UNSECURED_TRANSPORT": "true"
- }
- },
- "generate-manifest": {
- "commandName": "Project",
- "dotnetRunMessages": true,
- "commandLineArgs": "--publisher manifest --output-path aspire-manifest.json",
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development",
- "DOTNET_ENVIRONMENT": "Development"
- }
- }
- },
- "$schema": "https://json.schemastore.org/launchsettings.json"
-}
diff --git a/dotnet/samples/Hello/HelloAIAgents/HelloAIAgent.cs b/dotnet/samples/Hello/HelloAIAgents/HelloAIAgent.cs
index f7939da7d68e..ebde6d6d2f51 100644
--- a/dotnet/samples/Hello/HelloAIAgents/HelloAIAgent.cs
+++ b/dotnet/samples/Hello/HelloAIAgents/HelloAIAgent.cs
@@ -4,6 +4,7 @@
using Microsoft.AutoGen.Abstractions;
using Microsoft.AutoGen.Agents;
using Microsoft.Extensions.AI;
+using Microsoft.Extensions.DependencyInjection;
namespace Hello;
[TopicSubscription("HelloAgents")]
diff --git a/dotnet/samples/Hello/HelloAIAgents/HelloAIAgents.csproj b/dotnet/samples/Hello/HelloAIAgents/HelloAIAgents.csproj
index 86bccb13b371..73f1891b3f22 100644
--- a/dotnet/samples/Hello/HelloAIAgents/HelloAIAgents.csproj
+++ b/dotnet/samples/Hello/HelloAIAgents/HelloAIAgents.csproj
@@ -1,14 +1,4 @@
-
-
- Exe
- net8.0
- enable
- enable
-
-
-
-
-
+
@@ -16,4 +6,16 @@
+
+
+
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
diff --git a/dotnet/samples/Hello/HelloAIAgents/Program.cs b/dotnet/samples/Hello/HelloAIAgents/Program.cs
index ebede82bb4fb..9d1964bfd1e1 100644
--- a/dotnet/samples/Hello/HelloAIAgents/Program.cs
+++ b/dotnet/samples/Hello/HelloAIAgents/Program.cs
@@ -2,8 +2,11 @@
// Program.cs
using Hello;
+using Microsoft.AspNetCore.Builder;
using Microsoft.AutoGen.Abstractions;
using Microsoft.AutoGen.Agents;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
// send a message to the agent
var builder = WebApplication.CreateBuilder();
diff --git a/dotnet/samples/Hello/HelloAIAgents/Properties/launchSettings.json b/dotnet/samples/Hello/HelloAIAgents/Properties/launchSettings.json
deleted file mode 100644
index a5d241b0b325..000000000000
--- a/dotnet/samples/Hello/HelloAIAgents/Properties/launchSettings.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "profiles": {
- "HelloAIAgents": {
- "commandName": "Project",
- "launchBrowser": true,
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- },
- "applicationUrl": "https://localhost:53139;http://localhost:53140"
- }
- }
-}
\ No newline at end of file
diff --git a/dotnet/samples/Hello/HelloAgent/HelloAgent.csproj b/dotnet/samples/Hello/HelloAgent/HelloAgent.csproj
index 8799eb7275d1..eb2ba96d6644 100644
--- a/dotnet/samples/Hello/HelloAgent/HelloAgent.csproj
+++ b/dotnet/samples/Hello/HelloAgent/HelloAgent.csproj
@@ -1,4 +1,16 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
Exe
net8.0
@@ -6,14 +18,4 @@
enable
-
-
-
-
-
-
-
-
-
-
diff --git a/dotnet/samples/Hello/HelloAgent/Program.cs b/dotnet/samples/Hello/HelloAgent/Program.cs
index 02ad838dea0d..fbe5d2f6dff9 100644
--- a/dotnet/samples/Hello/HelloAgent/Program.cs
+++ b/dotnet/samples/Hello/HelloAgent/Program.cs
@@ -3,6 +3,8 @@
using Microsoft.AutoGen.Abstractions;
using Microsoft.AutoGen.Agents;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
// step 1: create in-memory agent runtime
@@ -25,8 +27,7 @@ namespace Hello
[TopicSubscription("HelloAgents")]
public class HelloAgent(
IAgentContext context,
- [FromKeyedServices("EventTypes")] EventTypes typeRegistry,
- IHostApplicationLifetime hostApplicationLifetime) : AgentBase(
+ [FromKeyedServices("EventTypes")] EventTypes typeRegistry) : AgentBase(
context,
typeRegistry),
ISayHello,
@@ -57,11 +58,11 @@ public async Task Handle(ConversationClosed item)
Message = goodbye
}.ToCloudEvent(this.AgentId.Key);
await PublishEvent(evt).ConfigureAwait(false);
+ //sleep
+ await Task.Delay(10000).ConfigureAwait(false);
+ await AgentsApp.ShutdownAsync().ConfigureAwait(false);
- // Signal shutdown.
- hostApplicationLifetime.StopApplication();
}
-
public async Task SayHello(string ask)
{
var response = $"\n\n\n\n***************Hello {ask}**********************\n\n\n\n";
diff --git a/dotnet/samples/Hello/HelloAgent/Properties/launchSettings.json b/dotnet/samples/Hello/HelloAgent/Properties/launchSettings.json
deleted file mode 100644
index 04cd1b228704..000000000000
--- a/dotnet/samples/Hello/HelloAgent/Properties/launchSettings.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "profiles": {
- "HelloAgent": {
- "commandName": "Project",
- "launchBrowser": true,
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- },
- "applicationUrl": "https://localhost:53113;http://localhost:53114"
- }
- }
-}
\ No newline at end of file
diff --git a/dotnet/samples/Hello/HelloAgentState/HelloAgentState.csproj b/dotnet/samples/Hello/HelloAgentState/HelloAgentState.csproj
index 8799eb7275d1..eb2ba96d6644 100644
--- a/dotnet/samples/Hello/HelloAgentState/HelloAgentState.csproj
+++ b/dotnet/samples/Hello/HelloAgentState/HelloAgentState.csproj
@@ -1,4 +1,16 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
Exe
net8.0
@@ -6,14 +18,4 @@
enable
-
-
-
-
-
-
-
-
-
-
diff --git a/dotnet/samples/Hello/HelloAgentState/Program.cs b/dotnet/samples/Hello/HelloAgentState/Program.cs
index c1e00e4d6322..66b888d6c46e 100644
--- a/dotnet/samples/Hello/HelloAgentState/Program.cs
+++ b/dotnet/samples/Hello/HelloAgentState/Program.cs
@@ -3,6 +3,8 @@
using Microsoft.AutoGen.Abstractions;
using Microsoft.AutoGen.Agents;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
// send a message to the agent
var app = await AgentsApp.PublishMessageAsync("HelloAgents", new NewMessageReceived
diff --git a/dotnet/samples/Hello/HelloAgentState/Properties/launchSettings.json b/dotnet/samples/Hello/HelloAgentState/Properties/launchSettings.json
deleted file mode 100644
index 067d2fb83551..000000000000
--- a/dotnet/samples/Hello/HelloAgentState/Properties/launchSettings.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "profiles": {
- "HelloAgentState": {
- "commandName": "Project",
- "launchBrowser": true,
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- },
- "applicationUrl": "https://localhost:53136;http://localhost:53137"
- }
- }
-}
\ No newline at end of file
diff --git a/dotnet/samples/dev-team/DevTeam.AgentHost/Properties/launchSettings.json b/dotnet/samples/dev-team/DevTeam.AgentHost/Properties/launchSettings.json
deleted file mode 100644
index c43e7586ac17..000000000000
--- a/dotnet/samples/dev-team/DevTeam.AgentHost/Properties/launchSettings.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "profiles": {
- "DevTeam.AgentHost": {
- "commandName": "Project",
- "launchBrowser": true,
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- },
- "applicationUrl": "https://localhost:50670;http://localhost:50673"
- }
- }
-}
\ No newline at end of file
diff --git a/dotnet/samples/dev-team/DevTeam.Agents/DevTeam.Agents.csproj b/dotnet/samples/dev-team/DevTeam.Agents/DevTeam.Agents.csproj
index 03176d2cfd25..d7dbd1688599 100644
--- a/dotnet/samples/dev-team/DevTeam.Agents/DevTeam.Agents.csproj
+++ b/dotnet/samples/dev-team/DevTeam.Agents/DevTeam.Agents.csproj
@@ -7,9 +7,9 @@
-
+
-
+
diff --git a/dotnet/samples/dev-team/DevTeam.Agents/Properties/launchSettings.json b/dotnet/samples/dev-team/DevTeam.Agents/Properties/launchSettings.json
deleted file mode 100644
index 8edfece6ad8d..000000000000
--- a/dotnet/samples/dev-team/DevTeam.Agents/Properties/launchSettings.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "profiles": {
- "DevTeam.Agents": {
- "commandName": "Project",
- "launchBrowser": true,
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- },
- "applicationUrl": "https://localhost:50669;http://localhost:50671"
- }
- }
-}
\ No newline at end of file
diff --git a/dotnet/samples/dev-team/DevTeam.Backend/Properties/launchSettings.json b/dotnet/samples/dev-team/DevTeam.Backend/Properties/launchSettings.json
deleted file mode 100644
index f63e521d5545..000000000000
--- a/dotnet/samples/dev-team/DevTeam.Backend/Properties/launchSettings.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "profiles": {
- "DevTeam.Backend": {
- "commandName": "Project",
- "launchBrowser": true,
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- },
- "applicationUrl": "https://localhost:50672;http://localhost:50674"
- }
- }
-}
\ No newline at end of file
diff --git a/dotnet/src/AutoGen.Core/AutoGen.Core.csproj b/dotnet/src/AutoGen.Core/AutoGen.Core.csproj
index f46d48dc844f..c34c03af2b51 100644
--- a/dotnet/src/AutoGen.Core/AutoGen.Core.csproj
+++ b/dotnet/src/AutoGen.Core/AutoGen.Core.csproj
@@ -17,7 +17,6 @@
-
diff --git a/dotnet/src/AutoGen.Core/Function/FunctionAttribute.cs b/dotnet/src/AutoGen.Core/Function/FunctionAttribute.cs
index 9418dc7fd6ae..bb37f1cb25de 100644
--- a/dotnet/src/AutoGen.Core/Function/FunctionAttribute.cs
+++ b/dotnet/src/AutoGen.Core/Function/FunctionAttribute.cs
@@ -3,9 +3,6 @@
using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Text.Json.Serialization;
-using Microsoft.Extensions.AI;
namespace AutoGen.Core;
@@ -25,10 +22,6 @@ public FunctionAttribute(string? functionName = null, string? description = null
public class FunctionContract
{
- private const string NamespaceKey = nameof(Namespace);
-
- private const string ClassNameKey = nameof(ClassName);
-
///
/// The namespace of the function.
///
@@ -59,7 +52,6 @@ public class FunctionContract
///
/// The return type of the function.
///
- [JsonIgnore]
public Type? ReturnType { get; set; }
///
@@ -68,39 +60,6 @@ public class FunctionContract
/// Otherwise, the description will be null.
///
public string? ReturnDescription { get; set; }
-
- public static implicit operator FunctionContract(AIFunctionMetadata metadata)
- {
- return new FunctionContract
- {
- Namespace = metadata.AdditionalProperties.ContainsKey(NamespaceKey) ? metadata.AdditionalProperties[NamespaceKey] as string : null,
- ClassName = metadata.AdditionalProperties.ContainsKey(ClassNameKey) ? metadata.AdditionalProperties[ClassNameKey] as string : null,
- Name = metadata.Name,
- Description = metadata.Description,
- Parameters = metadata.Parameters?.Select(p => (FunctionParameterContract)p).ToList(),
- ReturnType = metadata.ReturnParameter.ParameterType,
- ReturnDescription = metadata.ReturnParameter.Description,
- };
- }
-
- public static implicit operator AIFunctionMetadata(FunctionContract contract)
- {
- return new AIFunctionMetadata(contract.Name)
- {
- Description = contract.Description,
- ReturnParameter = new AIFunctionReturnParameterMetadata()
- {
- Description = contract.ReturnDescription,
- ParameterType = contract.ReturnType,
- },
- AdditionalProperties = new Dictionary
- {
- [NamespaceKey] = contract.Namespace,
- [ClassNameKey] = contract.ClassName,
- },
- Parameters = [.. contract.Parameters?.Select(p => (AIFunctionParameterMetadata)p)],
- };
- }
}
public class FunctionParameterContract
@@ -120,7 +79,6 @@ public class FunctionParameterContract
///
/// The type of the parameter.
///
- [JsonIgnore]
public Type? ParameterType { get; set; }
///
@@ -132,29 +90,4 @@ public class FunctionParameterContract
/// The default value of the parameter.
///
public object? DefaultValue { get; set; }
-
- // convert to/from FunctionParameterMetadata
- public static implicit operator FunctionParameterContract(AIFunctionParameterMetadata metadata)
- {
- return new FunctionParameterContract
- {
- Name = metadata.Name,
- Description = metadata.Description,
- ParameterType = metadata.ParameterType,
- IsRequired = metadata.IsRequired,
- DefaultValue = metadata.DefaultValue,
- };
- }
-
- public static implicit operator AIFunctionParameterMetadata(FunctionParameterContract contract)
- {
- return new AIFunctionParameterMetadata(contract.Name!)
- {
- DefaultValue = contract.DefaultValue,
- Description = contract.Description,
- IsRequired = contract.IsRequired,
- ParameterType = contract.ParameterType,
- HasDefaultValue = contract.DefaultValue != null,
- };
- }
}
diff --git a/dotnet/src/AutoGen.Core/Middleware/FunctionCallMiddleware.cs b/dotnet/src/AutoGen.Core/Middleware/FunctionCallMiddleware.cs
index 266155316c81..21461834dc83 100644
--- a/dotnet/src/AutoGen.Core/Middleware/FunctionCallMiddleware.cs
+++ b/dotnet/src/AutoGen.Core/Middleware/FunctionCallMiddleware.cs
@@ -5,10 +5,8 @@
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
-using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.Extensions.AI;
namespace AutoGen.Core;
@@ -45,19 +43,6 @@ public FunctionCallMiddleware(
this.functionMap = functionMap;
}
- ///
- /// Create a new instance of with a list of .
- ///
- /// function list
- /// optional middleware name. If not provided, the class name will be used.
- public FunctionCallMiddleware(IEnumerable functions, string? name = null)
- {
- this.Name = name ?? nameof(FunctionCallMiddleware);
- this.functions = functions.Select(f => (FunctionContract)f.Metadata).ToArray();
-
- this.functionMap = functions.Select(f => (f.Metadata.Name, this.AIToolInvokeWrapper(f.InvokeAsync))).ToDictionary(f => f.Name, f => f.Item2);
- }
-
public string? Name { get; }
public async Task InvokeAsync(MiddlewareContext context, IAgent agent, CancellationToken cancellationToken = default)
@@ -188,20 +173,4 @@ private async Task InvokeToolCallMessagesAfterInvokingAgentAsync(ToolC
return toolCallMsg;
}
}
-
- private Func> AIToolInvokeWrapper(Func>?, CancellationToken, Task
diff --git a/dotnet/src/Microsoft.AutoGen/Extensions/SemanticKernel/Microsoft.AutoGen.Extensions.SemanticKernel.csproj b/dotnet/src/Microsoft.AutoGen/Extensions/SemanticKernel/Microsoft.AutoGen.Extensions.SemanticKernel.csproj
index fb47750fd44d..a976c007715c 100644
--- a/dotnet/src/Microsoft.AutoGen/Extensions/SemanticKernel/Microsoft.AutoGen.Extensions.SemanticKernel.csproj
+++ b/dotnet/src/Microsoft.AutoGen/Extensions/SemanticKernel/Microsoft.AutoGen.Extensions.SemanticKernel.csproj
@@ -14,7 +14,7 @@
-
+
diff --git a/dotnet/test/AutoGen.Tests/AutoGen.Tests.csproj b/dotnet/test/AutoGen.Tests/AutoGen.Tests.csproj
index 248a9e29b00d..12c31e1a473c 100644
--- a/dotnet/test/AutoGen.Tests/AutoGen.Tests.csproj
+++ b/dotnet/test/AutoGen.Tests/AutoGen.Tests.csproj
@@ -13,8 +13,6 @@
-
-
diff --git a/dotnet/test/AutoGen.Tests/BasicSampleTest.cs b/dotnet/test/AutoGen.Tests/BasicSampleTest.cs
index 5cf4704037fc..df02bb3dcd0f 100644
--- a/dotnet/test/AutoGen.Tests/BasicSampleTest.cs
+++ b/dotnet/test/AutoGen.Tests/BasicSampleTest.cs
@@ -34,8 +34,7 @@ public async Task TwoAgentMathClassTestAsync()
[ApiKeyFact("OPENAI_API_KEY")]
public async Task AgentFunctionCallTestAsync()
{
- await Example03_Agent_FunctionCall.ToolCallWithSourceGenerator();
- await Example03_Agent_FunctionCall.ToolCallWithMEAITools();
+ await Example03_Agent_FunctionCall.RunAsync();
}
[ApiKeyFact("MISTRAL_API_KEY")]
diff --git a/dotnet/test/AutoGen.Tests/Function/ApprovalTests/FunctionTests.CreateGetWeatherFunctionFromAIFunctionFactoryAsync.approved.txt b/dotnet/test/AutoGen.Tests/Function/ApprovalTests/FunctionTests.CreateGetWeatherFunctionFromAIFunctionFactoryAsync.approved.txt
deleted file mode 100644
index f57e0203e353..000000000000
--- a/dotnet/test/AutoGen.Tests/Function/ApprovalTests/FunctionTests.CreateGetWeatherFunctionFromAIFunctionFactoryAsync.approved.txt
+++ /dev/null
@@ -1,76 +0,0 @@
-[
- {
- "Kind": 0,
- "FunctionName": "GetWeather",
- "FunctionDescription": "get weather",
- "FunctionParameters": {
- "type": "object",
- "properties": {
- "city": {
- "type": "string"
- },
- "date": {
- "type": "string"
- }
- },
- "required": [
- "city"
- ]
- }
- },
- {
- "Kind": 0,
- "FunctionName": "GetWeatherStatic",
- "FunctionDescription": "get weather from static method",
- "FunctionParameters": {
- "type": "object",
- "properties": {
- "city": {
- "type": "string"
- },
- "date": {
- "type": "array",
- "items": {
- "type": "string"
- }
- }
- },
- "required": [
- "city",
- "date"
- ]
- }
- },
- {
- "Kind": 0,
- "FunctionName": "GetWeather",
- "FunctionDescription": "get weather from async method",
- "FunctionParameters": {
- "type": "object",
- "properties": {
- "city": {
- "type": "string"
- }
- },
- "required": [
- "city"
- ]
- }
- },
- {
- "Kind": 0,
- "FunctionName": "GetWeatherAsyncStatic",
- "FunctionDescription": "get weather from async static method",
- "FunctionParameters": {
- "type": "object",
- "properties": {
- "city": {
- "type": "string"
- }
- },
- "required": [
- "city"
- ]
- }
- }
-]
\ No newline at end of file
diff --git a/dotnet/test/AutoGen.Tests/Function/FunctionTests.cs b/dotnet/test/AutoGen.Tests/Function/FunctionTests.cs
deleted file mode 100644
index 64abb293bb16..000000000000
--- a/dotnet/test/AutoGen.Tests/Function/FunctionTests.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// FunctionTests.cs
-
-using System;
-using System.ComponentModel;
-using System.Linq;
-using System.Text.Json;
-using System.Text.Json.Serialization;
-using System.Threading.Tasks;
-using ApprovalTests;
-using ApprovalTests.Namers;
-using ApprovalTests.Reporters;
-using AutoGen.OpenAI.Extension;
-using FluentAssertions;
-using Microsoft.Extensions.AI;
-using Xunit;
-
-namespace AutoGen.Tests.Function;
-public class FunctionTests
-{
- private readonly JsonSerializerOptions _jsonSerializerOptions = new() { WriteIndented = true, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull };
- [Description("get weather")]
- public string GetWeather(string city, string date = "today")
- {
- return $"The weather in {city} is sunny.";
- }
-
- [Description("get weather from static method")]
- [return: Description("weather information")]
- public static string GetWeatherStatic(string city, string[] date)
- {
- return $"The weather in {city} is sunny.";
- }
-
- [Description("get weather from async method")]
- public async Task GetWeatherAsync(string city)
- {
- await Task.Delay(100);
- return $"The weather in {city} is sunny.";
- }
-
- [Description("get weather from async static method")]
- public static async Task GetWeatherAsyncStatic(string city)
- {
- await Task.Delay(100);
- return $"The weather in {city} is sunny.";
- }
-
- [Fact]
- [UseReporter(typeof(DiffReporter))]
- [UseApprovalSubdirectory("ApprovalTests")]
- public async Task CreateGetWeatherFunctionFromAIFunctionFactoryAsync()
- {
- Delegate[] availableDelegates = [
- GetWeather,
- GetWeatherStatic,
- GetWeatherAsync,
- GetWeatherAsyncStatic,
- ];
-
- var functionContracts = availableDelegates.Select(function => (FunctionContract)AIFunctionFactory.Create(function).Metadata).ToList();
-
- // Verify the function contracts
- functionContracts.Should().HaveCount(4);
-
- var openAIToolContracts = functionContracts.Select(f =>
- {
- var tool = f.ToChatTool();
-
- return new
- {
- tool.Kind,
- tool.FunctionName,
- tool.FunctionDescription,
- FunctionParameters = tool.FunctionParameters.ToObjectFromJson