Skip to content

Commit

Permalink
stashing an attempt to aspirify things. might roll this back
Browse files Browse the repository at this point in the history
  • Loading branch information
rysweet committed Oct 22, 2024
1 parent 6717b17 commit 50b457b
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 15 deletions.
21 changes: 14 additions & 7 deletions dotnet/AutoGen.sln
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
spelling.dic = spelling.dic
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hello", "samples\Hello\Hello.csproj", "{6C9135E6-9D15-4D86-B3F4-9666DB87060A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AutoGen.Agents", "src\Microsoft.AutoGen\Agents\Microsoft.AutoGen.Agents.csproj", "{FD87BD33-4616-460B-AC85-A412BA08BB78}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AutoGen.Abstractions", "src\Microsoft.AutoGen\Abstractions\Microsoft.AutoGen.Abstractions.csproj", "{E0C991D9-0DB8-471C-ADC9-5FB16E2A0106}"
Expand All @@ -119,6 +117,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloAIAgents", "samples\He
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Backend", "samples\Backend\Backend.csproj", "{0E76DD82-8115-496C-A992-FBD905EE190A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloAgent", "samples\HelloAgent\HelloAgent.csproj", "{C51DE7C2-D222-4721-8289-50BC042F47E0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hello", "samples\HelloAspireHost\Hello.csproj", "{14858C42-BDD8-4C1B-89DD-03622A0038B8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -285,10 +287,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
{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
{6C9135E6-9D15-4D86-B3F4-9666DB87060A}.Release|Any CPU.Build.0 = Release|Any CPU
{FD87BD33-4616-460B-AC85-A412BA08BB78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FD87BD33-4616-460B-AC85-A412BA08BB78}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FD87BD33-4616-460B-AC85-A412BA08BB78}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -321,6 +319,14 @@ Global
{0E76DD82-8115-496C-A992-FBD905EE190A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0E76DD82-8115-496C-A992-FBD905EE190A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0E76DD82-8115-496C-A992-FBD905EE190A}.Release|Any CPU.Build.0 = Release|Any CPU
{C51DE7C2-D222-4721-8289-50BC042F47E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C51DE7C2-D222-4721-8289-50BC042F47E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C51DE7C2-D222-4721-8289-50BC042F47E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C51DE7C2-D222-4721-8289-50BC042F47E0}.Release|Any CPU.Build.0 = Release|Any CPU
{14858C42-BDD8-4C1B-89DD-03622A0038B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{14858C42-BDD8-4C1B-89DD-03622A0038B8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{14858C42-BDD8-4C1B-89DD-03622A0038B8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{14858C42-BDD8-4C1B-89DD-03622A0038B8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -369,7 +375,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}
{6C9135E6-9D15-4D86-B3F4-9666DB87060A} = {FBFEAD1F-29EB-4D99-A672-0CD8473E10B9}
{FD87BD33-4616-460B-AC85-A412BA08BB78} = {18BF8DD7-0585-48BF-8F97-AD333080CE06}
{E0C991D9-0DB8-471C-ADC9-5FB16E2A0106} = {18BF8DD7-0585-48BF-8F97-AD333080CE06}
{952827D4-8D4C-4327-AE4D-E8D25811EF35} = {18BF8DD7-0585-48BF-8F97-AD333080CE06}
Expand All @@ -378,6 +383,8 @@ Global
{D7E9D90B-5595-4E72-A90A-6DE20D9AB7AE} = {18BF8DD7-0585-48BF-8F97-AD333080CE06}
{EB245C0B-9350-484D-85DE-36C8C02139D3} = {FBFEAD1F-29EB-4D99-A672-0CD8473E10B9}
{0E76DD82-8115-496C-A992-FBD905EE190A} = {FBFEAD1F-29EB-4D99-A672-0CD8473E10B9}
{C51DE7C2-D222-4721-8289-50BC042F47E0} = {FBFEAD1F-29EB-4D99-A672-0CD8473E10B9}
{14858C42-BDD8-4C1B-89DD-03622A0038B8} = {FBFEAD1F-29EB-4D99-A672-0CD8473E10B9}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {93384647-528D-46C8-922C-8DB36A382F0B}
Expand Down
12 changes: 12 additions & 0 deletions dotnet/samples/Backend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Backend Example

This example demonstrates how to create a simple backend service for the agent runtime using ASP.NET Core.

To Run it, simply run the following command in the terminal:

```bash
dotnet run
```

Or you can run it using Visual Studio Code by pressing `F5`.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" />
<PackageReference Include="Aspire.Hosting.AppHost" />
</ItemGroup>

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.

using Microsoft.AutoGen.Abstractions;
using Microsoft.AutoGen.Agents;
using Microsoft.Extensions.DependencyInjection;
Expand All @@ -7,7 +9,7 @@
var app = await AgentsApp.PublishMessageAsync("HelloAgents", new NewMessageReceived
{
Message = "World"
}, local: true);
}, local: false);

await app.WaitForShutdownAsync();

Expand Down
File renamed without changes.
21 changes: 21 additions & 0 deletions dotnet/samples/HelloAspireHost/Hello.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<ProjectReference Include="..\Backend\Backend.csproj" />
<ProjectReference Include="..\HelloAgent\HelloAgent.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" />
<PackageReference Include="Aspire.Hosting.AppHost" />
</ItemGroup>

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsAspireHost>true</IsAspireHost>
</PropertyGroup>

</Project>
6 changes: 6 additions & 0 deletions dotnet/samples/HelloAspireHost/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.

var builder = DistributedApplication.CreateBuilder(args);
builder.AddProject<Projects.Backend>("backend");
builder.AddProject<Projects.HelloAgent>("client");
builder.Build().Run();
16 changes: 9 additions & 7 deletions dotnet/src/Microsoft.AutoGen/Agents/App.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Diagnostics.CodeAnalysis;
using Google.Protobuf;
using Microsoft.AspNetCore.Builder;
//using Microsoft.AutoGen.Runtime;
using Microsoft.AutoGen.Runtime;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

Expand All @@ -12,32 +12,34 @@ public static class AgentsApp
// need a variable to store the runtime instance
public static WebApplication? Host { get; private set; }
public static WebApplicationBuilder ClientBuilder { get; } = WebApplication.CreateBuilder();
public static WebApplicationBuilder CreateBuilder(AgentTypes? agentTypes = null, bool local = false)
public static WebApplicationBuilder CreateBuilder(bool local = false)
{
ClientBuilder.AddServiceDefaults();
if (agentTypes!=null) { ClientBuilder.AddAgentWorker().AddAgents(agentTypes);}
return ClientBuilder;
}
[MemberNotNull(nameof(Host))]
public static async ValueTask<WebApplication> StartAsync(WebApplicationBuilder? builder = null, AgentTypes? agentTypes = null, bool local = false)
{
// start the server runtime
if (builder == null)
if (builder == null)
{
builder = AgentsApp.CreateBuilder();
}
/* if (local)
if (local)
{
builder.AddLocalAgentService();
}
else
{
builder.AddAgentService();
} */
}
builder.AddAgentWorker()
.AddAgents(agentTypes);
var app = builder.Build();
//app.MapAgentService();
if (local)
{
app.MapAgentService();
}
Host = app;
await app.StartAsync().ConfigureAwait(false);
return Host;
Expand Down

0 comments on commit 50b457b

Please sign in to comment.