Skip to content

Commit

Permalink
upgrade to Aspire 9
Browse files Browse the repository at this point in the history
  • Loading branch information
kostapetan committed Nov 15, 2024
1 parent 437db9f commit 03ad20a
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 47 deletions.
20 changes: 9 additions & 11 deletions dotnet/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,22 @@
<MicrosoftSemanticKernelVersion>1.22.0</MicrosoftSemanticKernelVersion>
<MicrosoftSemanticKernelExperimentalVersion>1.22.0-alpha</MicrosoftSemanticKernelExperimentalVersion>
<MicrosoftExtensionsAIVersion>9.0.0-preview.9.24525.1</MicrosoftExtensionsAIVersion>

<NuGetAuditMode>direct</NuGetAuditMode>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Aspire.Hosting" Version="9.0.0-rc.1.24511.1" />
<PackageVersion Include="AspNetCore.Authentication.ApiKey" Version="8.0.1" />
<PackageVersion Include="Aspire.Azure.AI.OpenAI" Version="8.0.1-preview.8.24267.1" />
<PackageVersion Include="Aspire.Hosting.AppHost" Version="8.2.1" />
<PackageVersion Include="Aspire.Hosting.Azure.ApplicationInsights" Version="8.2.1" />
<PackageVersion Include="Aspire.Hosting.Azure.CognitiveServices" Version="8.2.1" />
<PackageVersion Include="Aspire.Hosting.NodeJs" Version="8.2.0" />
<PackageVersion Include="Aspire.Hosting.Orleans" Version="8.2.1" />
<PackageVersion Include="Aspire.Hosting.Qdrant" Version="8.2.1" />
<PackageVersion Include="Aspire.Hosting.Redis" Version="8.2.0" />
<PackageVersion Include="Aspire.Azure.AI.OpenAI" Version="9.0.0-preview.5.24551.3" />
<PackageVersion Include="Aspire.Hosting.AppHost" Version="9.0.0" />
<PackageVersion Include="Aspire.Hosting.Azure.ApplicationInsights" Version="9.0.0" />
<PackageVersion Include="Aspire.Hosting.Azure.CognitiveServices" Version="9.0.0" />
<PackageVersion Include="Aspire.Hosting.NodeJs" Version="9.0.0" />
<PackageVersion Include="Aspire.Hosting.Orleans" Version="9.0.0" />
<PackageVersion Include="Aspire.Hosting.Qdrant" Version="9.0.0" />
<PackageVersion Include="Aspire.Hosting.Redis" Version="9.0.0" />
<PackageVersion Include="Azure.AI.OpenAI" Version=" 2.1.0-beta.1" />
<PackageVersion Include="Azure.AI.Inference" Version="1.0.0-beta.1" />
<PackageVersion Include="Azure.Data.Tables" Version="12.9.1" />
<PackageVersion Include="Azure.Identity" Version="1.13.0" />
<PackageVersion Include="Azure.Identity" Version="1.13.1" />
<PackageVersion Include="Azure.ResourceManager.ContainerInstance" Version="1.2.1" />
<PackageVersion Include="Azure.Storage.Files.Shares" Version="12.20.1" />
<PackageVersion Include="CloudNative.CloudEvents.SystemTextJson" Version="2.7.1" />
Expand Down
23 changes: 9 additions & 14 deletions dotnet/samples/Hello-distributed/AppHost/AppHost.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">

<Sdk Name="Aspire.AppHost.Sdk" Version="9.0.0" />
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
Expand All @@ -8,21 +8,16 @@
<IsAspireHost>true</IsAspireHost>
<UserSecretsId>e8874200-80ab-41e3-bb56-b5bb93974eea</UserSecretsId>
</PropertyGroup>

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

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

<ItemGroup>
<None Update="Properties\launchSettings.json">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>

</Project>
<ItemGroup>
<None Update="Properties\launchSettings.json">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
5 changes: 2 additions & 3 deletions dotnet/samples/Hello-distributed/AppHost/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@

var agentHost = builder.AddContainer("agent-host", "autogen-host")
.WithEnvironment("ASPNETCORE_URLS", "http://+:5001")
.WithHttpEndpoint(port:5001, targetPort: 5001);
.WithHttpEndpoint(targetPort: 5001);

var agentHostHttp = agentHost.GetEndpoint("http");
var url = agentHostHttp.Property(EndpointProperty.Url);

builder.AddProject<Projects.Backend>("backend")
.WithEnvironment("AGENT_HOST", $"{url}")
.WithEnvironment("AGENT_HOST", $"{agentHostHttp.Property(EndpointProperty.Url)}")
.WithEnvironment("OpenAI__Key", builder.Configuration["OpenAI:Key"])
.WithEnvironment("OpenAI__Endpoint", builder.Configuration["OpenAI:Endpoint"])
.WaitFor(agentHost);
Expand Down
6 changes: 3 additions & 3 deletions dotnet/samples/Hello-distributed/Backend/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
builder.Services.AddControllers();
builder.Services.AddSwaggerGen();

builder.AddAgentWorker(builder.Configuration["AGENT_HOST"]!)
.AddAgent<HelloAgent>(nameof(HelloAgent))
;
var agentHostUrl = builder.Configuration["AGENT_HOST"]!;
builder.AddAgentWorker(agentHostUrl)
.AddAgent<HelloAgent>(nameof(HelloAgent));

builder.Services.AddSingleton<AgentWorker>();

Expand Down
6 changes: 2 additions & 4 deletions dotnet/samples/Hello/Hello.AppHost/Hello.AppHost.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<Sdk Name="Aspire.AppHost.Sdk" Version="9.0.0" />
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
Expand All @@ -7,14 +8,11 @@
<IsAspireHost>true</IsAspireHost>
<UserSecretsId>ecb5cbe4-15d8-4120-8f18-d3ba4902915b</UserSecretsId>
</PropertyGroup>

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

<ItemGroup>
<ProjectReference Include="..\Backend\Backend.csproj" />
<ProjectReference Include="..\HelloAgent\HelloAgent.csproj" />
</ItemGroup>
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"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"
"DOTNET_ASPIRE_SHOW_DASHBOARD_RESOURCES": "true",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21021"
}
},
"http": {
Expand All @@ -22,7 +22,6 @@
"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",
Expand All @@ -40,4 +39,4 @@
}
},
"$schema": "https://json.schemastore.org/launchsettings.json"
}
}
2 changes: 1 addition & 1 deletion dotnet/samples/dev-team/DevTeam.Agents/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

builder.AddServiceDefaults();

builder.ConfigureSemanticKernel();
builder.ConfigureSemanticKernel(useVectorDb:true);

builder.AddAgentWorker(builder.Configuration["AGENT_HOST"]!)
.AddAgent<Dev>(nameof(Dev))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<Sdk Name="Aspire.AppHost.Sdk" Version="9.0.0" />

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
Expand Down
2 changes: 1 addition & 1 deletion dotnet/samples/dev-team/DevTeam.Backend/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
var builder = WebApplication.CreateBuilder(args);

builder.AddServiceDefaults();
builder.ConfigureSemanticKernel();
builder.ConfigureSemanticKernel(useVectorDb:true);

builder.Services.AddHttpClient();
builder.Services.AddControllers();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
namespace Microsoft.AutoGen.Extensions.SemanticKernel;
public static class SemanticKernelHostingExtensions
{
public static IHostApplicationBuilder ConfigureSemanticKernel(this IHostApplicationBuilder builder)
public static IHostApplicationBuilder ConfigureSemanticKernel(this IHostApplicationBuilder builder, bool useVectorDb=false)
{
builder.Services.Configure<AIClientOptions>(o =>
{
Expand All @@ -27,22 +27,25 @@ public static IHostApplicationBuilder ConfigureSemanticKernel(this IHostApplicat
o.ChatDeploymentOrModelId = "gpt-4o";
});

if (useVectorDb)
{
builder.Services.AddOptions<QdrantOptions>().Bind(builder.Configuration.GetSection("Qdrant"))
.ValidateDataAnnotations()
.ValidateOnStart();
builder.Services.AddTransient(CreateMemory);
}
builder.Services.Configure<AzureOpenAIClientOptions>(o =>
{
o.NetworkTimeout = TimeSpan.FromMinutes(5);
});

builder.Services.AddOptions<QdrantOptions>().Bind(builder.Configuration.GetSection("Qdrant"))
.ValidateDataAnnotations()
.ValidateOnStart();

builder.Services.Configure<JsonSerializerOptions>(options =>
{
options.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
});

builder.Services.AddTransient(CreateKernel);
builder.Services.AddTransient(CreateMemory);

return builder;
}

Expand Down

0 comments on commit 03ad20a

Please sign in to comment.