From 47c8e01afe5863b4af34b9e87935b8303234af6a Mon Sep 17 00:00:00 2001 From: Piotr Stachaczynski Date: Thu, 4 Jul 2024 21:19:55 +0200 Subject: [PATCH 01/14] init backend for demo --- MaIN.sln | 6 ++ src/MaIN.RAG.Demo/MaIN.RAG.Demo.csproj | 23 +++++++ src/MaIN.RAG.Demo/MaIN.RAG.Demo.http | 6 ++ src/MaIN.RAG.Demo/Program.cs | 54 ++++++++++++++++ .../Properties/launchSettings.json | 41 ++++++++++++ .../appsettings.Development.json | 8 +++ src/MaIN.RAG.Demo/appsettings.json | 9 +++ src/MaIN.RAG.Demo/json/laptops.json | 62 +++++++++++++++++++ src/MaIN.RAG.Demo/json/pcs.json | 62 +++++++++++++++++++ 9 files changed, 271 insertions(+) create mode 100644 src/MaIN.RAG.Demo/MaIN.RAG.Demo.csproj create mode 100644 src/MaIN.RAG.Demo/MaIN.RAG.Demo.http create mode 100644 src/MaIN.RAG.Demo/Program.cs create mode 100644 src/MaIN.RAG.Demo/Properties/launchSettings.json create mode 100644 src/MaIN.RAG.Demo/appsettings.Development.json create mode 100644 src/MaIN.RAG.Demo/appsettings.json create mode 100644 src/MaIN.RAG.Demo/json/laptops.json create mode 100644 src/MaIN.RAG.Demo/json/pcs.json diff --git a/MaIN.sln b/MaIN.sln index dc7c237b..fd019bab 100644 --- a/MaIN.sln +++ b/MaIN.sln @@ -8,6 +8,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MaIN.Services", "src\MaIN.S EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MaIN.Domain", "src\MaIN.Domain\MaIN.Domain.csproj", "{4DEF4AA6-DFD8-4626-B8BE-2F773B12FE0C}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MaIN.RAG.Demo", "src\MaIN.RAG.Demo\MaIN.RAG.Demo.csproj", "{2351B015-EA33-42F3-A844-CECABF140E9A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -30,5 +32,9 @@ Global {4DEF4AA6-DFD8-4626-B8BE-2F773B12FE0C}.Debug|Any CPU.Build.0 = Debug|Any CPU {4DEF4AA6-DFD8-4626-B8BE-2F773B12FE0C}.Release|Any CPU.ActiveCfg = Release|Any CPU {4DEF4AA6-DFD8-4626-B8BE-2F773B12FE0C}.Release|Any CPU.Build.0 = Release|Any CPU + {2351B015-EA33-42F3-A844-CECABF140E9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2351B015-EA33-42F3-A844-CECABF140E9A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2351B015-EA33-42F3-A844-CECABF140E9A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2351B015-EA33-42F3-A844-CECABF140E9A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/src/MaIN.RAG.Demo/MaIN.RAG.Demo.csproj b/src/MaIN.RAG.Demo/MaIN.RAG.Demo.csproj new file mode 100644 index 00000000..de914577 --- /dev/null +++ b/src/MaIN.RAG.Demo/MaIN.RAG.Demo.csproj @@ -0,0 +1,23 @@ + + + + net8.0 + enable + enable + + + + + + + + + + Always + + + Always + + + + diff --git a/src/MaIN.RAG.Demo/MaIN.RAG.Demo.http b/src/MaIN.RAG.Demo/MaIN.RAG.Demo.http new file mode 100644 index 00000000..fdce86c5 --- /dev/null +++ b/src/MaIN.RAG.Demo/MaIN.RAG.Demo.http @@ -0,0 +1,6 @@ +@MaIN.RAG.Demo_HostAddress = http://localhost:5098 + +GET {{MaIN.RAG.Demo_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/src/MaIN.RAG.Demo/Program.cs b/src/MaIN.RAG.Demo/Program.cs new file mode 100644 index 00000000..280d40b0 --- /dev/null +++ b/src/MaIN.RAG.Demo/Program.cs @@ -0,0 +1,54 @@ +using System.Text.Json; + +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. +// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle +builder.Services.AddEndpointsApiExplorer(); +builder.Services.AddSwaggerGen(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.UseSwagger(); + app.UseSwaggerUI(); +} + +app.UseHttpsRedirection(); + +var serializeOptions = new JsonSerializerOptions +{ + PropertyNamingPolicy = JsonNamingPolicy.CamelCase, + WriteIndented = true +}; + +app.MapGet("/laptops/", () => Results.Ok( + JsonSerializer.Deserialize>( + File.ReadAllText("json/laptops.json"), serializeOptions))) + .WithName("GetLaptops") + .WithOpenApi(); + +app.MapGet("/pcs/", () => Results.Ok( + JsonSerializer.Deserialize>( + File.ReadAllText("json/pcs.json"), serializeOptions))) + .WithName("GetPCs") + .WithOpenApi(); + +app.Run(); + + +public class Hardware +{ + public int Id { get; set; } + public string Name { get; set; } + public string Brand { get; set; } + public string Processor { get; set; } + public string Ram { get; set; } + public string Storage { get; set; } + public string Gpu { get; set; } + public double Price { get; set; } + public string Availability { get; set; } + public string Description { get; set; } +} \ No newline at end of file diff --git a/src/MaIN.RAG.Demo/Properties/launchSettings.json b/src/MaIN.RAG.Demo/Properties/launchSettings.json new file mode 100644 index 00000000..75df4c08 --- /dev/null +++ b/src/MaIN.RAG.Demo/Properties/launchSettings.json @@ -0,0 +1,41 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:54552", + "sslPort": 44303 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:5098", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7205;http://localhost:5098", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/src/MaIN.RAG.Demo/appsettings.Development.json b/src/MaIN.RAG.Demo/appsettings.Development.json new file mode 100644 index 00000000..0c208ae9 --- /dev/null +++ b/src/MaIN.RAG.Demo/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/src/MaIN.RAG.Demo/appsettings.json b/src/MaIN.RAG.Demo/appsettings.json new file mode 100644 index 00000000..10f68b8c --- /dev/null +++ b/src/MaIN.RAG.Demo/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/src/MaIN.RAG.Demo/json/laptops.json b/src/MaIN.RAG.Demo/json/laptops.json new file mode 100644 index 00000000..7873ae11 --- /dev/null +++ b/src/MaIN.RAG.Demo/json/laptops.json @@ -0,0 +1,62 @@ +[ + { + "id": 1, + "name": "UltraBook Pro", + "brand": "PowerTech", + "processor": "Intel Core i7-1165G7", + "ram": "16GB LPDDR4x", + "storage": "512GB SSD", + "gpu": "Intel Iris Xe Graphics", + "price": 1299.99, + "availability": "In Stock", + "description": "The UltraBook Pro by PowerTech offers a sleek design with powerful performance, featuring an Intel Core i7 processor and Intel Iris Xe Graphics. With 16GB of RAM and a 512GB SSD, this laptop is perfect for professionals on the go." + }, + { + "id": 2, + "name": "Gaming Laptop X", + "brand": "TechMaster", + "processor": "AMD Ryzen 7 5800H", + "ram": "32GB DDR4", + "storage": "1TB SSD", + "gpu": "NVIDIA GeForce RTX 3070", + "price": 1999.99, + "availability": "In Stock", + "description": "TechMaster's Gaming Laptop X is designed for gamers who need high performance on the go. Featuring an AMD Ryzen 7 CPU and NVIDIA RTX 3070 GPU, this laptop delivers smooth gaming experiences and fast load times." + }, + { + "id": 3, + "name": "Budget Laptop", + "brand": "EconoPC", + "processor": "Intel Core i3-1115G4", + "ram": "8GB DDR4", + "storage": "256GB SSD", + "gpu": "Integrated Graphics", + "price": 499.99, + "availability": "Out of Stock", + "description": "The Budget Laptop by EconoPC offers essential features at an affordable price. With an Intel Core i3 processor and 8GB of RAM, it's suitable for students and casual users who need reliable performance for everyday tasks." + }, + { + "id": 4, + "name": "All-Purpose Laptop", + "brand": "ValueComp", + "processor": "AMD Ryzen 5 4500U", + "ram": "16GB DDR4", + "storage": "512GB SSD", + "gpu": "AMD Radeon Graphics", + "price": 899.99, + "availability": "In Stock", + "description": "ValueComp's All-Purpose Laptop is versatile and powerful, equipped with an AMD Ryzen 5 processor and Radeon Graphics. It's ideal for a variety of tasks, including work, entertainment, and light gaming." + }, + { + "id": 5, + "name": "Compact Office Laptop", + "brand": "OfficeMate", + "processor": "Intel Core i5-1135G7", + "ram": "8GB LPDDR4x", + "storage": "512GB SSD", + "gpu": "Intel Iris Xe Graphics", + "price": 799.99, + "availability": "In Stock", + "description": "The Compact Office Laptop by OfficeMate is perfect for professionals who need a portable and efficient device. With an Intel Core i5 processor and 8GB of RAM, it offers solid performance for office applications and multitasking." + } +] \ No newline at end of file diff --git a/src/MaIN.RAG.Demo/json/pcs.json b/src/MaIN.RAG.Demo/json/pcs.json new file mode 100644 index 00000000..838f4358 --- /dev/null +++ b/src/MaIN.RAG.Demo/json/pcs.json @@ -0,0 +1,62 @@ +[ + { + "id": 1, + "name": "Gaming PC Ultra", + "brand": "PowerTech", + "processor": "Intel Core i9-11900K", + "ram": "32GB DDR4", + "storage": "1TB SSD + 2TB HDD", + "gpu": "NVIDIA GeForce RTX 3090", + "price": 2999.99, + "availability": "In Stock", + "description": "The Gaming PC Ultra from PowerTech features an Intel Core i9 processor and NVIDIA RTX 3090, making it perfect for high-end gaming and demanding applications. With 32GB of RAM and ample storage, this PC can handle any task with ease." + }, + { + "id": 2, + "name": "Workstation Pro", + "brand": "TechMaster", + "processor": "AMD Ryzen 9 5950X", + "ram": "64GB DDR4", + "storage": "2TB SSD", + "gpu": "NVIDIA Quadro RTX 5000", + "price": 3499.99, + "availability": "In Stock", + "description": "TechMaster's Workstation Pro is designed for professionals who require top-tier performance. With an AMD Ryzen 9 CPU, 64GB RAM, and NVIDIA Quadro RTX GPU, this workstation excels in 3D rendering, video editing, and other intensive tasks." + }, + { + "id": 3, + "name": "Budget Gamer", + "brand": "EconoPC", + "processor": "Intel Core i5-10400F", + "ram": "16GB DDR4", + "storage": "512GB SSD", + "gpu": "NVIDIA GeForce GTX 1660 Super", + "price": 799.99, + "availability": "Out of Stock", + "description": "The Budget Gamer by EconoPC provides excellent value for entry-level gaming. Featuring an Intel Core i5 processor and NVIDIA GTX 1660 Super GPU, this PC delivers smooth performance for popular games at an affordable price." + }, + { + "id": 4, + "name": "All-Purpose PC", + "brand": "ValueComp", + "processor": "AMD Ryzen 5 3600", + "ram": "16GB DDR4", + "storage": "1TB HDD", + "gpu": "AMD Radeon RX 5700", + "price": 999.99, + "availability": "In Stock", + "description": "ValueComp's All-Purpose PC is a versatile system suitable for gaming, work, and everyday use. It features an AMD Ryzen 5 processor, 16GB RAM, and a Radeon RX 5700 GPU, ensuring balanced performance for a variety of tasks." + }, + { + "id": 5, + "name": "Compact Office PC", + "brand": "OfficeMate", + "processor": "Intel Core i3-10100", + "ram": "8GB DDR4", + "storage": "256GB SSD", + "gpu": "Integrated Graphics", + "price": 499.99, + "availability": "In Stock", + "description": "The Compact Office PC by OfficeMate is ideal for small spaces and routine office tasks. Equipped with an Intel Core i3 processor and 8GB of RAM, it offers reliable performance for word processing, spreadsheets, and internet browsing." + } +] \ No newline at end of file From 16e344ad39dfd77bab5bbd005dd29add3947ffeb Mon Sep 17 00:00:00 2001 From: Piotr Stachaczynski Date: Sat, 6 Jul 2024 21:05:26 +0200 Subject: [PATCH 02/14] rad feat continuation --- .../inspectionProfiles/Project_Default.xml | 21 +++ .../MainFE/Components/Layout/NavMenu.razor | 32 +--- .../Components/Models/HardwareItemDto.cs | 18 ++ Frontend/MainFE/Components/Pages/Chat.razor | 66 +++---- Frontend/MainFE/Components/Pages/Home.razor | 27 ++- .../MainFE/Components/Pages/Rag/RAG.razor | 144 +++++++++++++++ .../MainFE/Components/Pages/Rag/RAG.razor.css | 0 Frontend/MainFE/ExtensionMethods.cs | 5 + .../MainFE/Properties/launchSettings.json | 1 + Frontend/MainFE/wwwroot/app.css | 32 +++- Frontend/MainFE/wwwroot/css/home.css | 47 +++++ .../MainFE/wwwroot/images/demo/laptop1.jpg | Bin 0 -> 30519 bytes .../MainFE/wwwroot/images/demo/laptop2.jpg | Bin 0 -> 80608 bytes .../MainFE/wwwroot/images/demo/laptop3.jpg | Bin 0 -> 60436 bytes .../MainFE/wwwroot/images/demo/laptop4.jpg | Bin 0 -> 27903 bytes .../MainFE/wwwroot/images/demo/laptop5.jpg | Bin 0 -> 28551 bytes .../MainFE/wwwroot/images/demo/laptop6.jpg | Bin 0 -> 5737 bytes Frontend/MainFE/wwwroot/images/demo/pc1.jpg | Bin 0 -> 269371 bytes Frontend/MainFE/wwwroot/images/demo/pc2.png | Bin 0 -> 202362 bytes Frontend/MainFE/wwwroot/images/demo/pc3.jpg | Bin 0 -> 2492 bytes Frontend/MainFE/wwwroot/images/demo/pc4.jpg | Bin 0 -> 42952 bytes Frontend/MainFE/wwwroot/images/demo/pc5.jpg | Bin 0 -> 3991 bytes Frontend/MainFE/wwwroot/images/demo/pc6.jpg | Bin 0 -> 81803 bytes src/MaIN.RAG.Demo/MaIN.RAG.Demo.csproj | 5 +- src/MaIN.RAG.Demo/Program.cs | 13 +- src/MaIN.RAG.Demo/json/items.json | 170 ++++++++++++++++++ src/MaIN.RAG.Demo/json/laptops.json | 62 ------- src/MaIN.RAG.Demo/json/pcs.json | 62 ------- 28 files changed, 491 insertions(+), 214 deletions(-) create mode 100644 Frontend/MainFE/.idea/.idea.MainFE/.idea/inspectionProfiles/Project_Default.xml create mode 100644 Frontend/MainFE/Components/Models/HardwareItemDto.cs create mode 100644 Frontend/MainFE/Components/Pages/Rag/RAG.razor create mode 100644 Frontend/MainFE/Components/Pages/Rag/RAG.razor.css create mode 100644 Frontend/MainFE/wwwroot/images/demo/laptop1.jpg create mode 100644 Frontend/MainFE/wwwroot/images/demo/laptop2.jpg create mode 100644 Frontend/MainFE/wwwroot/images/demo/laptop3.jpg create mode 100644 Frontend/MainFE/wwwroot/images/demo/laptop4.jpg create mode 100644 Frontend/MainFE/wwwroot/images/demo/laptop5.jpg create mode 100644 Frontend/MainFE/wwwroot/images/demo/laptop6.jpg create mode 100644 Frontend/MainFE/wwwroot/images/demo/pc1.jpg create mode 100644 Frontend/MainFE/wwwroot/images/demo/pc2.png create mode 100644 Frontend/MainFE/wwwroot/images/demo/pc3.jpg create mode 100644 Frontend/MainFE/wwwroot/images/demo/pc4.jpg create mode 100644 Frontend/MainFE/wwwroot/images/demo/pc5.jpg create mode 100644 Frontend/MainFE/wwwroot/images/demo/pc6.jpg create mode 100644 src/MaIN.RAG.Demo/json/items.json delete mode 100644 src/MaIN.RAG.Demo/json/laptops.json delete mode 100644 src/MaIN.RAG.Demo/json/pcs.json diff --git a/Frontend/MainFE/.idea/.idea.MainFE/.idea/inspectionProfiles/Project_Default.xml b/Frontend/MainFE/.idea/.idea.MainFE/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 00000000..39b37c89 --- /dev/null +++ b/Frontend/MainFE/.idea/.idea.MainFE/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,21 @@ + + + + \ No newline at end of file diff --git a/Frontend/MainFE/Components/Layout/NavMenu.razor b/Frontend/MainFE/Components/Layout/NavMenu.razor index c4941d10..20c18302 100644 --- a/Frontend/MainFE/Components/Layout/NavMenu.razor +++ b/Frontend/MainFE/Components/Layout/NavMenu.razor @@ -4,31 +4,6 @@ box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5); background-color: #1e1e1e !important; } - - .select-label { - color: #fff; - margin-right: 10px; - } - - .select-element { - background-color: #2e2e2e; - color: #fff; - border: 1px solid #333; - border-radius: 4px; - padding: 6px 12px; - font-size: 16px; - appearance: none; - } - - .select-element:hover { - background-color: #4a4a4a; - } - - .select-element:focus { - outline: none; - border-color: #0078D4; - box-shadow: 0 0 0 3px rgba(0, 120, 212, 0.3); - } @code { diff --git a/Frontend/MainFE/Components/Models/AgentContextDto.cs b/Frontend/MainFE/Components/Models/AgentContextDto.cs index c016f416..d056fded 100644 --- a/Frontend/MainFE/Components/Models/AgentContextDto.cs +++ b/Frontend/MainFE/Components/Models/AgentContextDto.cs @@ -3,6 +3,7 @@ namespace MaIN.Models.Rag; public class AgentContextDto { public string Instruction { get; set; } + public object? Source { get; set; } public List Steps { get; set; } public List? Relations { get; set; } diff --git a/Frontend/MainFE/Components/Models/ChatDto.cs b/Frontend/MainFE/Components/Models/ChatDto.cs index d24ac62a..d0841fb2 100644 --- a/Frontend/MainFE/Components/Models/ChatDto.cs +++ b/Frontend/MainFE/Components/Models/ChatDto.cs @@ -10,5 +10,7 @@ public class ChatDto [JsonPropertyName("model")] public string Model { get; set; } [JsonPropertyName("messages")] public List Messages { get; set; } [JsonPropertyName("stream")] public bool Stream { get; set; } = false; + [JsonPropertyName("properties")] + public Dictionary Properties { get; set; } [JsonIgnore] public bool IsSelected { get; set; } } \ No newline at end of file diff --git a/Frontend/MainFE/Components/Pages/Agents.razor b/Frontend/MainFE/Components/Pages/Agents.razor index ead40015..737f3be3 100644 --- a/Frontend/MainFE/Components/Pages/Agents.razor +++ b/Frontend/MainFE/Components/Pages/Agents.razor @@ -4,6 +4,7 @@ @using Microsoft.FluentUI.AspNetCore.Components @using MainFE.Components.Elements @inject HttpClient Http +@inject NavigationManager Nav @rendermode InteractiveServer 👥 Agents @@ -19,26 +20,43 @@

Predefined Agents

+ + + @foreach (var agent in agents.Where(x => _predefinedAgents.Contains(x.Id))) { - -
-
@agent.Model
- @if (agent.Id == "b29211e9-9ee8-45f4-bdbb-054cb835d0d6") - { + @if (agent.Id == "b29211e9-9ee8-45f4-bdbb-054cb835d0d6") + { + +
+
@agent.Model
👑 - } - @if (agent.Id == "c39211w9-9ee8-4xf4-edbb-b54cb835d2d6") - { +

@agent.Description

+
+
+ } + @if (agent.Id == "c39211w9-9ee8-4xf4-edbb-b54cb835d2d6") + { + +
+
@agent.Model
🎮 - } - @if (agent.Id == "vd9d11w9-9ee8-4xf4-edbb-b54cb335d25b") - { +

@agent.Description

+
+
+ } + @if (agent.Id == "vd9d11w9-9ee8-4xf4-edbb-b54cb335d25b") + { + +
+
@agent.Model
👨‍⚕️ - } -

@agent.Description

-
-
+

@agent.Description

+
+
+ } } @if (agents.Any(x => !_predefinedAgents.Contains(x.Id))) { @@ -159,7 +177,7 @@ @code { - private List _predefinedAgents = ["b29211e9-9ee8-45f4-bdbb-054cb835d0d6", "c39211w9-9ee8-4xf4-edbb-b54cb835d2d6", "vd9d11w9-9ee8-4xf4-edbb-b54cb335d25b"]; + private List _predefinedAgents = ["d2f191c7-f08b-4285-b0d6-bb99a045ebde","f29211e9-9xe8-45f4-bdbb-054cb835d0d6","b29211e9-9ee8-45f4-bdbb-054cb835d0d6", "c39211w9-9ee8-4xf4-edbb-b54cb835d2d6", "vd9d11w9-9ee8-4xf4-edbb-b54cb335d25b"]; // Models AgentDto newAgent; @@ -245,5 +263,10 @@ _mode = AgentsPageMode.Create; } + private void NavigateToDemo() + { + Nav.NavigateTo("/rag"); + } + } diff --git a/Frontend/MainFE/Components/Pages/Chat.razor b/Frontend/MainFE/Components/Pages/Chat.razor index 296d4caf..d11fd3ba 100644 --- a/Frontend/MainFE/Components/Pages/Chat.razor +++ b/Frontend/MainFE/Components/Pages/Chat.razor @@ -6,11 +6,10 @@ @using Message = MainFE.Components.Models.Message @using MainFE.Components.Elements @inject HttpClient Http -@rendermode InteractiveServer +@rendermode @(new InteractiveServerRenderMode(prerender: false)) 💬 Chat - - +

Select a Model

- + + +
+

Multilingual

+
+ Improve translations + + +
+
@code { + // Models - List models = []; - string selectedModel = string.Empty; + bool _translate = false; + List _models = []; + string _selectedModel = string.Empty; + bool _loading = false; // Data List _chats = new(); + ChatDto _selectedChat = new() { Messages = [] }; - bool _loading = false; private void OnModelSelected(string model) { - selectedModel = model; + _selectedModel = model; } - + protected override async Task OnInitializedAsync() { await LoadChatsAsync(); @@ -79,8 +90,8 @@ var response = await Http.GetAsync($"{ExtensionMethods.GetApiUrl()}/api/chats/models"); if (response.IsSuccessStatusCode) { - models = await response.Content.ReadFromJsonAsync>() ?? []; - selectedModel = models!.First(); + _models = await response.Content.ReadFromJsonAsync>() ?? []; + _selectedModel = _models!.First(); } } @@ -111,7 +122,7 @@ { var newChatRequest = new ChatRequest { - Model = selectedModel, + Model = _selectedModel, Messages = new List(), Name = $"{AssetName.NewName()} | {DateTime.Now.ToShortDateString()}", Stream = false, diff --git a/Frontend/MainFE/Components/Pages/Rag/RAG.razor b/Frontend/MainFE/Components/Pages/Rag/RAG.razor index 1257bc29..fdf67e37 100644 --- a/Frontend/MainFE/Components/Pages/Rag/RAG.razor +++ b/Frontend/MainFE/Components/Pages/Rag/RAG.razor @@ -1,147 +1,164 @@ @page "/RAG" +@using System.Text.Json +@using MaIN.Models.Rag @using MainFE.Components.Models @using Markdig @using Microsoft.FluentUI.AspNetCore.Components @using Message = MainFE.Components.Models.Message -@rendermode @(new InteractiveServerRenderMode(prerender:false)) +@using MainFE.Components.Elements +@rendermode @(new InteractiveServerRenderMode(prerender: false)) @inject HttpClient Http + -
-
- +@if (_globalLoading) +{ + +} +else +{ +
+
+ +
+ + +
+
+ @foreach (var item in _items) + { + +
+ @item.Name +

@item.Name

+

+ Brand: @item.Brand +

+

+ Type: @item.Type +

+ +
+
+ }
- -
-
- @foreach (var item in _items) - { - -
- @item.Name -

@item.Name

-

- Brand: @item.Brand -

-

- Type: @item.Type -

- -
-
- } -
-