Skip to content

Commit 41f73a9

Browse files
committed
Addressing some more feedback, and fixing the app so that it can auto-provision the OpenAI dependency.
1 parent aacbb35 commit 41f73a9

File tree

8 files changed

+47
-10
lines changed

8 files changed

+47
-10
lines changed

src/AIChatApp.AppHost/AIChatApp.AppHost.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<ItemGroup>
1313
<PackageReference Include="Aspire.Hosting.AppHost" Version="8.2.1" />
14-
<PackageReference Include="Aspire.Hosting.Azure.CognitiveServices" Version="8.2.1" />
14+
<PackageReference Include="Aspire.Hosting.Azure.CognitiveServices" Version="9.0.0-rc.1.24511.1" />
1515
</ItemGroup>
1616

1717
<ItemGroup>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.5.002.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AIChatApp.AppHost", "AIChatApp.AppHost.csproj", "{4D6E0B13-F222-4E81-80FD-34524B2177B5}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{4D6E0B13-F222-4E81-80FD-34524B2177B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{4D6E0B13-F222-4E81-80FD-34524B2177B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{4D6E0B13-F222-4E81-80FD-34524B2177B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{4D6E0B13-F222-4E81-80FD-34524B2177B5}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {2CCDBEAC-A29C-4A0B-A9AB-43434E8BA146}
24+
EndGlobalSection
25+
EndGlobal

src/AIChatApp.AppHost/Program.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44

55
var builder = DistributedApplication.CreateBuilder(args);
66

7-
// Add support for a local configuration file, which doesn't get committed to source control
8-
builder.Configuration.Sources.Insert(0, new JsonConfigurationSource { Path = "appsettings.Local.json", Optional = true });
9-
107
var chatDeploymentName = "chat";
118
var connectionString = builder.Configuration.GetConnectionString("openai");
9+
1210
var openai = String.IsNullOrEmpty(connectionString)
1311
? builder.AddAzureOpenAI("openai")
1412
.AddDeployment(new AzureOpenAIDeployment(chatDeploymentName, "gpt-4o", "2024-05-13", "GlobalStandard", 10))
15-
: builder.AddConnectionString("openai", "OPENAI_CONNECTION_STRING");
13+
: builder.AddConnectionString("openai");
1614

1715
builder.AddProject<AIChatApp_Web>("aichatapp-web")
1816
.WithReference(openai)

src/AIChatApp.Web/AIChatApp.Web.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="Aspire.Azure.AI.OpenAI" Version="8.2.1-preview.1.24473.4" />
12+
<PackageReference Include="Aspire.Azure.AI.OpenAI" Version="9.0.0-preview.4.24511.1" />
1313
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.10" />
1414
<PackageReference Include="Microsoft.SemanticKernel" Version="1.24.0" />
15-
<PackageReference Include="Microsoft.SemanticKernel.Connectors.AzureOpenAI" Version="1.24.0" />
1615
</ItemGroup>
1716

1817
<ItemGroup>

src/AIChatApp.Web/Components/App.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<base href="/" />
88
<link rel="stylesheet" href="bootstrap/bootstrap.min.css" />
99
<link rel="stylesheet" href="app.css" />
10-
<link rel="stylesheet" href="AIChatApp.styles.css" />
10+
<link rel="stylesheet" href="AIChatApp.Web.styles.css" />
1111
<link rel="icon" type="image/png" href="favicon.png" />
1212
<HeadOutlet @rendermode="@PageRenderMode" />
1313
</head>

src/AIChatApp.Web/Components/Chat/Chat.razor

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22
@inject IConfiguration Configuration
33
@inject IJSRuntime JS
44
@using AIChatApp.Model
5-
@attribute [StreamRendering(true)]
65

76
<PageTitle>Chat</PageTitle>
87

98
<div class="chat">
109
<div class="messages-scroller">
1110
<div class="messages">
1211
<ChatMessage
13-
State="@(new Message(){IsAssistant = true, Content = "Hi, I'm a helpful assistant, how may I assist you?"})" />
12+
State="@(new Message(){IsAssistant = true, Content = "Hi, let's write a limerick! What's a topic we should use?"})" />
1413
@foreach (var message in messages)
1514
{
1615
<ChatMessage @key="@message" State="@message" />

src/AIChatApp.Web/Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
2+
WORKDIR /App
3+
4+
# Copy everything
5+
COPY . ./
6+
# Restore as distinct layers
7+
RUN dotnet restore
8+
# Build and publish a release
9+
RUN dotnet publish -c Release -o out
10+
11+
# Build runtime image
12+
FROM mcr.microsoft.com/dotnet/aspnet:8.0
13+
WORKDIR /App
14+
COPY --from=build-env /App/out .
15+
ENTRYPOINT ["dotnet", "AIChatApp.dll"]

src/AIChatApp.Web/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
if (!app.Environment.IsDevelopment())
2929
{
3030
app.UseExceptionHandler("/Error", createScopeForErrors: true);
31+
3132
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
3233
app.UseHsts();
3334
}

0 commit comments

Comments
 (0)