diff --git a/src/AIChatApp.AppHost/AIChatApp.AppHost.csproj b/src/AIChatApp.AppHost/AIChatApp.AppHost.csproj index bb4fe63..2aea3c1 100644 --- a/src/AIChatApp.AppHost/AIChatApp.AppHost.csproj +++ b/src/AIChatApp.AppHost/AIChatApp.AppHost.csproj @@ -11,7 +11,7 @@ - + diff --git a/src/AIChatApp.AppHost/AIChatApp.AppHost.sln b/src/AIChatApp.AppHost/AIChatApp.AppHost.sln new file mode 100644 index 0000000..ec69c74 --- /dev/null +++ b/src/AIChatApp.AppHost/AIChatApp.AppHost.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.002.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AIChatApp.AppHost", "AIChatApp.AppHost.csproj", "{4D6E0B13-F222-4E81-80FD-34524B2177B5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4D6E0B13-F222-4E81-80FD-34524B2177B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4D6E0B13-F222-4E81-80FD-34524B2177B5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4D6E0B13-F222-4E81-80FD-34524B2177B5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4D6E0B13-F222-4E81-80FD-34524B2177B5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {2CCDBEAC-A29C-4A0B-A9AB-43434E8BA146} + EndGlobalSection +EndGlobal diff --git a/src/AIChatApp.AppHost/Program.cs b/src/AIChatApp.AppHost/Program.cs index ec231e0..59d7fba 100644 --- a/src/AIChatApp.AppHost/Program.cs +++ b/src/AIChatApp.AppHost/Program.cs @@ -4,15 +4,13 @@ var builder = DistributedApplication.CreateBuilder(args); -// Add support for a local configuration file, which doesn't get committed to source control -builder.Configuration.Sources.Insert(0, new JsonConfigurationSource { Path = "appsettings.Local.json", Optional = true }); - var chatDeploymentName = "chat"; var connectionString = builder.Configuration.GetConnectionString("openai"); + var openai = String.IsNullOrEmpty(connectionString) ? builder.AddAzureOpenAI("openai") .AddDeployment(new AzureOpenAIDeployment(chatDeploymentName, "gpt-4o", "2024-05-13", "GlobalStandard", 10)) - : builder.AddConnectionString("openai", "OPENAI_CONNECTION_STRING"); + : builder.AddConnectionString("openai"); builder.AddProject("aichatapp-web") .WithReference(openai) diff --git a/src/AIChatApp.Web/AIChatApp.Web.csproj b/src/AIChatApp.Web/AIChatApp.Web.csproj index 36a3b80..a2928ec 100644 --- a/src/AIChatApp.Web/AIChatApp.Web.csproj +++ b/src/AIChatApp.Web/AIChatApp.Web.csproj @@ -9,10 +9,9 @@ - + - diff --git a/src/AIChatApp.Web/Components/App.razor b/src/AIChatApp.Web/Components/App.razor index ca15925..2782ec8 100644 --- a/src/AIChatApp.Web/Components/App.razor +++ b/src/AIChatApp.Web/Components/App.razor @@ -7,7 +7,7 @@ - + diff --git a/src/AIChatApp.Web/Components/Chat/Chat.razor b/src/AIChatApp.Web/Components/Chat/Chat.razor index e10946b..5c5034c 100644 --- a/src/AIChatApp.Web/Components/Chat/Chat.razor +++ b/src/AIChatApp.Web/Components/Chat/Chat.razor @@ -2,7 +2,6 @@ @inject IConfiguration Configuration @inject IJSRuntime JS @using AIChatApp.Model -@attribute [StreamRendering(true)] Chat @@ -10,7 +9,7 @@
+ State="@(new Message(){IsAssistant = true, Content = "Hi, let's write a limerick! What's a topic we should use?"})" /> @foreach (var message in messages) { diff --git a/src/AIChatApp.Web/Dockerfile b/src/AIChatApp.Web/Dockerfile new file mode 100644 index 0000000..4499911 --- /dev/null +++ b/src/AIChatApp.Web/Dockerfile @@ -0,0 +1,15 @@ +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env +WORKDIR /App + +# Copy everything +COPY . ./ +# Restore as distinct layers +RUN dotnet restore +# Build and publish a release +RUN dotnet publish -c Release -o out + +# Build runtime image +FROM mcr.microsoft.com/dotnet/aspnet:8.0 +WORKDIR /App +COPY --from=build-env /App/out . +ENTRYPOINT ["dotnet", "AIChatApp.dll"] \ No newline at end of file diff --git a/src/AIChatApp.Web/Program.cs b/src/AIChatApp.Web/Program.cs index 26ca44f..e9eed18 100644 --- a/src/AIChatApp.Web/Program.cs +++ b/src/AIChatApp.Web/Program.cs @@ -28,6 +28,7 @@ if (!app.Environment.IsDevelopment()) { app.UseExceptionHandler("/Error", createScopeForErrors: true); + // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); }