Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/staging' into termination-condition
Browse files Browse the repository at this point in the history
  • Loading branch information
ekzhu committed Oct 9, 2024
2 parents a7c65ee + 333c951 commit de6eb90
Show file tree
Hide file tree
Showing 114 changed files with 349 additions and 1,286 deletions.
50 changes: 32 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,52 +139,62 @@ cd dotnet && dotnet build AutoGen.sln
dotnet add <your.csproj> reference <path to your checkout of autogen>/dotnet/src/Microsoft.AutoGen.Agents.Client/Microsoft.AutoGen.Agents.Client.csproj
```

Then, define your first agent:
Then, define and run your first agent:

```csharp
using Microsoft.AutoGen.Agents.Abstractions;
using Microsoft.AutoGen.Agents.Client;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace HelloAgents.Agents;
// send a message to the agent
var app = await App.PublishMessageAsync("HelloAgents", new NewMessageReceived
{
Message = "World"
}, local: true);

await App.RuntimeApp!.WaitForShutdownAsync();
await app.WaitForShutdownAsync();

[TopicSubscription("HelloAgents")]
public class HelloAgent(
IAgentContext context,
Kernel kernel,
ISemanticTextMemory memory,
[FromKeyedServices("EventTypes")] EventTypes typeRegistry,
ILogger<HelloAgent> logger) : AiAgent<HelloAgentState>(
[FromKeyedServices("EventTypes")] EventTypes typeRegistry) : ConsoleAgent(
context,
memory,
kernel,
typeRegistry),
ISayHello,
IHandle<NewMessageReceived>,
IHandle<ConversationClosed>
{
public async Task Handle(NewMessageReceived item)
{
var response = await SayHello(item.Message);
var evt = new ResponseGenerated
var response = await SayHello(item.Message).ConfigureAwait(false);
var evt = new Output
{
Response = response
Message = response
}.ToCloudEvent(this.AgentId.Key);
await PublishEvent(evt);
await PublishEvent(evt).ConfigureAwait(false);
var goodbye = new ConversationClosed
{
UserId = this.AgentId.Key,
UserMessage = "Goodbye"
}.ToCloudEvent(this.AgentId.Key);
await PublishEvent(goodbye).ConfigureAwait(false);
}

public async Task Handle(ConversationClosed item)
{
var goodbye = "";
var evt = new GoodBye
var goodbye = $"********************* {item.UserId} said {item.UserMessage} ************************";
var evt = new Output
{
Message = goodbye
}.ToCloudEvent(this.AgentId.Key);
await PublishEvent(evt);
await PublishEvent(evt).ConfigureAwait(false);
await Task.Delay(60000);
await App.ShutdownAsync();
}

public async Task<string> SayHello(string ask)
{
var response = $"Hello {ask}";
var response = $"\n\n\n\n***************Hello {ask}**********************\n\n\n\n";
return response;
}
}
Expand All @@ -194,6 +204,10 @@ public interface ISayHello
}
```

```bash
dotnet run
```

<p align="right" style="font-size: 14px; color: #555; margin-top: 20px;">
<a href="#readme-top" style="text-decoration: none; color: blue; font-weight: bold;">
↑ Back to Top ↑
Expand Down
38 changes: 0 additions & 38 deletions dotnet/AutoGen.sln
Original file line number Diff line number Diff line change
Expand Up @@ -104,24 +104,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevTeam.Backend", "samples\
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevTeam.Shared", "samples\dev-team\DevTeam.Shared\DevTeam.Shared.csproj", "{D9F65DFD-368B-47DB-8BB5-0C74DED7F439}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "HelloAgents", "HelloAgents", "{F7AC0FF1-8500-49C6-8CB3-97C6D52C8BEF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{243E768F-EA7D-4AF1-B625-0398440BB1AB}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
spelling.dic = spelling.dic
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HelloAgents.Agents", "samples\HelloAgents\HelloAgents.Agents\HelloAgents.Agents.csproj", "{ECCE44EE-3934-448E-A9A5-3403117EF0B5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HelloAgents.ApiService", "samples\HelloAgents\HelloAgents.ApiService\HelloAgents.ApiService.csproj", "{74ADFF5D-80AF-4A6E-9794-746BDE1A41D1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HelloAgents.AppHost", "samples\HelloAgents\HelloAgents.AppHost\HelloAgents.AppHost.csproj", "{031FED7F-97ED-4AA1-B408-88BD3B70A463}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HelloAgents.ServiceDefaults", "samples\HelloAgents\HelloAgents.ServiceDefaults\HelloAgents.ServiceDefaults.csproj", "{6B88F4B3-26AB-4034-B0AC-5BA6EEDEB8E5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HelloAgents.Web", "samples\HelloAgents\HelloAgents.Web\HelloAgents.Web.csproj", "{8B56BE22-5CF4-44BB-AFA5-732FEA2AFF0B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hello", "samples\Hello\Hello.csproj", "{6C9135E6-9D15-4D86-B3F4-9666DB87060A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AutoGen.ServiceDefaults", "src\Microsoft.AutoGen.ServiceDefaults\Microsoft.AutoGen.ServiceDefaults.csproj", "{F70C6FD7-9615-4EDD-8D55-5460FCC5A46D}"
Expand Down Expand Up @@ -312,26 +300,6 @@ Global
{D9F65DFD-368B-47DB-8BB5-0C74DED7F439}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D9F65DFD-368B-47DB-8BB5-0C74DED7F439}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D9F65DFD-368B-47DB-8BB5-0C74DED7F439}.Release|Any CPU.Build.0 = Release|Any CPU
{ECCE44EE-3934-448E-A9A5-3403117EF0B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ECCE44EE-3934-448E-A9A5-3403117EF0B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ECCE44EE-3934-448E-A9A5-3403117EF0B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ECCE44EE-3934-448E-A9A5-3403117EF0B5}.Release|Any CPU.Build.0 = Release|Any CPU
{74ADFF5D-80AF-4A6E-9794-746BDE1A41D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{74ADFF5D-80AF-4A6E-9794-746BDE1A41D1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{74ADFF5D-80AF-4A6E-9794-746BDE1A41D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{74ADFF5D-80AF-4A6E-9794-746BDE1A41D1}.Release|Any CPU.Build.0 = Release|Any CPU
{031FED7F-97ED-4AA1-B408-88BD3B70A463}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{031FED7F-97ED-4AA1-B408-88BD3B70A463}.Debug|Any CPU.Build.0 = Debug|Any CPU
{031FED7F-97ED-4AA1-B408-88BD3B70A463}.Release|Any CPU.ActiveCfg = Release|Any CPU
{031FED7F-97ED-4AA1-B408-88BD3B70A463}.Release|Any CPU.Build.0 = Release|Any CPU
{6B88F4B3-26AB-4034-B0AC-5BA6EEDEB8E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6B88F4B3-26AB-4034-B0AC-5BA6EEDEB8E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6B88F4B3-26AB-4034-B0AC-5BA6EEDEB8E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6B88F4B3-26AB-4034-B0AC-5BA6EEDEB8E5}.Release|Any CPU.Build.0 = Release|Any CPU
{8B56BE22-5CF4-44BB-AFA5-732FEA2AFF0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8B56BE22-5CF4-44BB-AFA5-732FEA2AFF0B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8B56BE22-5CF4-44BB-AFA5-732FEA2AFF0B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8B56BE22-5CF4-44BB-AFA5-732FEA2AFF0B}.Release|Any CPU.Build.0 = Release|Any CPU
{6C9135E6-9D15-4D86-B3F4-9666DB87060A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6C9135E6-9D15-4D86-B3F4-9666DB87060A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6C9135E6-9D15-4D86-B3F4-9666DB87060A}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -393,12 +361,6 @@ Global
{F2F13EAF-05C6-4E90-B2E4-3FA0290D7F6E} = {616F30DF-1F41-4047-BAA4-64BA03BF5AEA}
{D826D5E4-31F4-4AB5-AC86-F7B4AD79314B} = {616F30DF-1F41-4047-BAA4-64BA03BF5AEA}
{D9F65DFD-368B-47DB-8BB5-0C74DED7F439} = {616F30DF-1F41-4047-BAA4-64BA03BF5AEA}
{F7AC0FF1-8500-49C6-8CB3-97C6D52C8BEF} = {FBFEAD1F-29EB-4D99-A672-0CD8473E10B9}
{ECCE44EE-3934-448E-A9A5-3403117EF0B5} = {F7AC0FF1-8500-49C6-8CB3-97C6D52C8BEF}
{74ADFF5D-80AF-4A6E-9794-746BDE1A41D1} = {F7AC0FF1-8500-49C6-8CB3-97C6D52C8BEF}
{031FED7F-97ED-4AA1-B408-88BD3B70A463} = {F7AC0FF1-8500-49C6-8CB3-97C6D52C8BEF}
{6B88F4B3-26AB-4034-B0AC-5BA6EEDEB8E5} = {F7AC0FF1-8500-49C6-8CB3-97C6D52C8BEF}
{8B56BE22-5CF4-44BB-AFA5-732FEA2AFF0B} = {F7AC0FF1-8500-49C6-8CB3-97C6D52C8BEF}
{6C9135E6-9D15-4D86-B3F4-9666DB87060A} = {FBFEAD1F-29EB-4D99-A672-0CD8473E10B9}
{F70C6FD7-9615-4EDD-8D55-5460FCC5A46D} = {18BF8DD7-0585-48BF-8F97-AD333080CE06}
EndGlobalSection
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

18 changes: 0 additions & 18 deletions dotnet/samples/HelloAgents/HelloAgents.Agents/Program.cs

This file was deleted.

This file was deleted.

43 changes: 0 additions & 43 deletions dotnet/samples/HelloAgents/HelloAgents.ApiService/Program.cs

This file was deleted.

This file was deleted.

Loading

0 comments on commit de6eb90

Please sign in to comment.