{e}
")); 46 | } 47 | onMessageAdded(); 48 | } 49 | } -------------------------------------------------------------------------------- /src/AspireAIBlazorChatBot.Web/Components/Chatbot/Chatbot.razor: -------------------------------------------------------------------------------- 1 | @rendermode @(new InteractiveServerRenderMode(prerender: false)) 2 | @using Microsoft.AspNetCore.Components.Authorization 3 | @using AspireApp.WebApp.Chatbot 4 | @using Microsoft.Extensions.AI 5 | @inject IJSRuntime JS 6 | @inject NavigationManager Nav 7 | 8 | @inject AuthenticationStateProvider AuthenticationStateProvider 9 | @inject ILogger Logger 10 | @inject IConfiguration Configuration 11 | @inject IServiceProvider ServiceProvider 12 | 13 |[@Configuration["Aspire:OllamaSharp:ollama:Models:0"]] is Thinking...
35 | } 36 | 37 |Current count: @currentCount
9 | 10 | 11 | 12 | @code { 13 | private int currentCount = 0; 14 | 15 | private void IncrementCount() 16 | { 17 | currentCount++; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/AspireAIBlazorChatBot.Web/Components/Pages/Error.razor: -------------------------------------------------------------------------------- 1 | @page "/Error" 2 | @using System.Diagnostics 3 | 4 |
12 | Request ID: @requestId
13 |
18 | Swapping to Development environment will display more detailed information about the error that occurred. 19 |
20 |21 | The Development environment shouldn't be enabled for deployed applications. 22 | It can result in displaying sensitive information from exceptions to end users. 23 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 24 | and restarting the app. 25 |
26 | 27 | @code{ 28 | [CascadingParameter] 29 | public HttpContext? HttpContext { get; set; } 30 | 31 | private string? requestId; 32 | private bool ShowRequestId => !string.IsNullOrEmpty(requestId); 33 | 34 | protected override void OnInitialized() 35 | { 36 | requestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/AspireAIBlazorChatBot.Web/Components/Pages/Home.razor: -------------------------------------------------------------------------------- 1 | @rendermode InteractiveServer 2 | @page "/" 3 | @using AspireApp.WebApp.Chatbot 4 | 5 | @inject IConfiguration Configuration 6 | 7 |@MessageProcessor.ProcessMessageToHTML(modelStatus)
33 |This component demonstrates showing data loaded from a backend API service.
12 | 13 | @if (forecasts == null) 14 | { 15 |Loading...
16 | } 17 | else 18 | { 19 |Date | 23 |Temp. (C) | 24 |Temp. (F) | 25 |Summary | 26 |
---|---|---|---|
@forecast.Date.ToShortDateString() | 33 |@forecast.TemperatureC | 34 |@forecast.TemperatureF | 35 |@forecast.Summary | 36 |
{responseArray[i]}
"; 32 | } 33 | 34 | 35 | return responseHtml; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/AspireAIBlazorChatBot.Web/Program.cs: -------------------------------------------------------------------------------- 1 | using AspireAIBlazorChatBot.Web; 2 | using AspireAIBlazorChatBot.Web.Components; 3 | using Microsoft.Extensions.AI; 4 | 5 | var builder = WebApplication.CreateBuilder(args); 6 | 7 | // Add service defaults & Aspire components. 8 | builder.AddServiceDefaults(); 9 | builder.AddRedisOutputCache("cache"); 10 | 11 | // Add services to the container. 12 | builder.Services.AddRazorComponents() 13 | .AddInteractiveServerComponents(); 14 | 15 | builder.Services.AddHttpClient