├── README.md ├── LLM.Offline.Streaming.App ├── Resources │ ├── Fonts │ │ └── OpenSans-Regular.ttf │ ├── AppIcon │ │ ├── appicon.svg │ │ └── appiconfg.svg │ ├── Raw │ │ └── AboutAssets.txt │ ├── Splash │ │ └── splash.svg │ └── Images │ │ └── dotnet_bot.svg ├── Properties │ └── launchSettings.json ├── MainPage.xaml.cs ├── Platforms │ ├── Android │ │ ├── Resources │ │ │ └── values │ │ │ │ └── colors.xml │ │ ├── AndroidManifest.xml │ │ ├── MainApplication.cs │ │ └── MainActivity.cs │ ├── iOS │ │ ├── AppDelegate.cs │ │ ├── Program.cs │ │ ├── Info.plist │ │ └── Resources │ │ │ └── PrivacyInfo.xcprivacy │ ├── MacCatalyst │ │ ├── AppDelegate.cs │ │ ├── Program.cs │ │ ├── Entitlements.plist │ │ └── Info.plist │ ├── Windows │ │ ├── App.xaml │ │ ├── app.manifest │ │ ├── App.xaml.cs │ │ └── Package.appxmanifest │ └── Tizen │ │ ├── Main.cs │ │ └── tizen-manifest.xml ├── Components │ ├── Routes.razor │ ├── Pages │ │ ├── Counter.razor │ │ ├── Weather.razor │ │ └── Home.razor │ ├── _Imports.razor │ └── Layout │ │ ├── MainLayout.razor │ │ ├── NavMenu.razor │ │ ├── MainLayout.razor.css │ │ └── NavMenu.razor.css ├── App.xaml.cs ├── App.xaml ├── MainPage.xaml ├── MauiProgram.cs ├── wwwroot │ ├── index.html │ └── css │ │ └── app.css ├── Brokers │ └── LLMApiBroker.cs └── LLM.Offline.Streaming.App.csproj ├── LLM.Offline.Streaming.Api ├── appsettings.Development.json ├── Brokers │ ├── ILLMBroker.cs │ └── LLMBroker.cs ├── appsettings.json ├── LLM.Offline.Streaming.Api.http ├── Controllers │ └── ChatsController.cs ├── LLM.Offline.Streaming.Api.csproj ├── Properties │ └── launchSettings.json └── Program.cs ├── LLM.Offline.Streaming.Client ├── LLM.Offline.Streaming.Client.csproj └── Program.cs ├── LLM.Offline.Streaming.sln ├── .gitattributes └── .gitignore /README.md: -------------------------------------------------------------------------------- 1 | # LLM.Offline.Streaming -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/Resources/Fonts/OpenSans-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hassanhabib/LLM.Offline.API.Streaming/HEAD/LLM.Offline.Streaming.App/Resources/Fonts/OpenSans-Regular.ttf -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "Windows Machine": { 4 | "commandName": "Project", 5 | "nativeDebugging": false 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /LLM.Offline.Streaming.Api/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.Api/Brokers/ILLMBroker.cs: -------------------------------------------------------------------------------- 1 | namespace LLM.Offline.Streaming.Api.Brokers 2 | { 3 | public interface ILLMBroker 4 | { 5 | IAsyncEnumerable PromptAsync(string message); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.Api/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } 10 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.Api/LLM.Offline.Streaming.Api.http: -------------------------------------------------------------------------------- 1 | @LLM.Offline.Streaming.Api_HostAddress = http://localhost:5086 2 | 3 | GET {{LLM.Offline.Streaming.Api_HostAddress}}/weatherforecast/ 4 | Accept: application/json 5 | 6 | ### 7 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/MainPage.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace LLM.Offline.Streaming.App 2 | { 3 | public partial class MainPage : ContentPage 4 | { 5 | public MainPage() 6 | { 7 | InitializeComponent(); 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/Platforms/Android/Resources/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #512BD4 4 | #2B0B98 5 | #2B0B98 6 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/Resources/AppIcon/appicon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/Components/Routes.razor: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/Platforms/iOS/AppDelegate.cs: -------------------------------------------------------------------------------- 1 | using Foundation; 2 | 3 | namespace LLM.Offline.Streaming.App 4 | { 5 | [Register("AppDelegate")] 6 | public class AppDelegate : MauiUIApplicationDelegate 7 | { 8 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/Platforms/MacCatalyst/AppDelegate.cs: -------------------------------------------------------------------------------- 1 | using Foundation; 2 | 3 | namespace LLM.Offline.Streaming.App 4 | { 5 | [Register("AppDelegate")] 6 | public class AppDelegate : MauiUIApplicationDelegate 7 | { 8 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.Client/LLM.Offline.Streaming.Client.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net9.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/Components/Pages/Counter.razor: -------------------------------------------------------------------------------- 1 | @page "/counter" 2 | 3 |

Counter

4 | 5 |

Current count: @currentCount

6 | 7 | 8 | 9 | @code { 10 | private int currentCount = 0; 11 | 12 | private void IncrementCount() 13 | { 14 | currentCount++; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/Platforms/Windows/App.xaml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/Components/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using Microsoft.AspNetCore.Components.Web.Virtualization 7 | @using Microsoft.JSInterop 8 | @using LLM.Offline.Streaming.App 9 | @using LLM.Offline.Streaming.App.Components 10 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/App.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace LLM.Offline.Streaming.App 2 | { 3 | public partial class App : Application 4 | { 5 | public App() 6 | { 7 | InitializeComponent(); 8 | } 9 | 10 | protected override Window CreateWindow(IActivationState? activationState) 11 | { 12 | return new Window(new MainPage()) { Title = "LLM.Offline.Streaming.App" }; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/Components/Layout/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 |
4 | 7 | 8 |
9 |
10 | About 11 |
12 | 13 |
14 | @Body 15 |
16 |
17 |
18 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/Platforms/Android/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/Platforms/Tizen/Main.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Maui; 3 | using Microsoft.Maui.Hosting; 4 | 5 | namespace LLM.Offline.Streaming.App 6 | { 7 | internal class Program : MauiApplication 8 | { 9 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 10 | 11 | static void Main(string[] args) 12 | { 13 | var app = new Program(); 14 | app.Run(args); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/Platforms/Android/MainApplication.cs: -------------------------------------------------------------------------------- 1 | using Android.App; 2 | using Android.Runtime; 3 | 4 | namespace LLM.Offline.Streaming.App 5 | { 6 | [Application] 7 | public class MainApplication : MauiApplication 8 | { 9 | public MainApplication(IntPtr handle, JniHandleOwnership ownership) 10 | : base(handle, ownership) 11 | { 12 | } 13 | 14 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/Platforms/Android/MainActivity.cs: -------------------------------------------------------------------------------- 1 | using Android.App; 2 | using Android.Content.PM; 3 | using Android.OS; 4 | 5 | namespace LLM.Offline.Streaming.App 6 | { 7 | [Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)] 8 | public class MainActivity : MauiAppCompatActivity 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/Platforms/iOS/Program.cs: -------------------------------------------------------------------------------- 1 | using ObjCRuntime; 2 | using UIKit; 3 | 4 | namespace LLM.Offline.Streaming.App 5 | { 6 | public class Program 7 | { 8 | // This is the main entry point of the application. 9 | static void Main(string[] args) 10 | { 11 | // if you want to use a different Application Delegate class from "AppDelegate" 12 | // you can specify it here. 13 | UIApplication.Main(args, null, typeof(AppDelegate)); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/Platforms/MacCatalyst/Program.cs: -------------------------------------------------------------------------------- 1 | using ObjCRuntime; 2 | using UIKit; 3 | 4 | namespace LLM.Offline.Streaming.App 5 | { 6 | public class Program 7 | { 8 | // This is the main entry point of the application. 9 | static void Main(string[] args) 10 | { 11 | // if you want to use a different Application Delegate class from "AppDelegate" 12 | // you can specify it here. 13 | UIApplication.Main(args, null, typeof(AppDelegate)); 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /LLM.Offline.Streaming.Api/Controllers/ChatsController.cs: -------------------------------------------------------------------------------- 1 | using LLM.Offline.Streaming.Api.Brokers; 2 | using Microsoft.AspNetCore.Mvc; 3 | 4 | namespace LLM.Offline.Streaming.Api.Controllers 5 | { 6 | [ApiController] 7 | [Route("api/[controller]")] 8 | public class ChatsController : ControllerBase 9 | { 10 | private readonly ILLMBroker llmBroker; 11 | 12 | public ChatsController(ILLMBroker llmBroker) => 13 | this.llmBroker = llmBroker; 14 | 15 | [HttpPost] 16 | public IAsyncEnumerable PostPromptAsync([FromBody] string prompt) 17 | { 18 | return this.llmBroker.PromptAsync(prompt); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/App.xaml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/MainPage.xaml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.Api/LLM.Offline.Streaming.Api.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net9.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | Always 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.Api/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/launchsettings.json", 3 | "profiles": { 4 | "http": { 5 | "commandName": "Project", 6 | "dotnetRunMessages": true, 7 | "launchBrowser": false, 8 | "applicationUrl": "http://localhost:5086", 9 | "environmentVariables": { 10 | "ASPNETCORE_ENVIRONMENT": "Development" 11 | } 12 | }, 13 | "https": { 14 | "commandName": "Project", 15 | "dotnetRunMessages": true, 16 | "launchBrowser": false, 17 | "applicationUrl": "https://localhost:7102;http://localhost:5086", 18 | "environmentVariables": { 19 | "ASPNETCORE_ENVIRONMENT": "Development" 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/Platforms/MacCatalyst/Entitlements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.apple.security.app-sandbox 8 | 9 | 10 | com.apple.security.network.client 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/Resources/Raw/AboutAssets.txt: -------------------------------------------------------------------------------- 1 | Any raw assets you want to be deployed with your application can be placed in 2 | this directory (and child directories). Deployment of the asset to your application 3 | is automatically handled by the following `MauiAsset` Build Action within your `.csproj`. 4 | 5 | 6 | 7 | These files will be deployed with your package and will be accessible using Essentials: 8 | 9 | async Task LoadMauiAsset() 10 | { 11 | using var stream = await FileSystem.OpenAppPackageFileAsync("AboutAssets.txt"); 12 | using var reader = new StreamReader(stream); 13 | 14 | var contents = reader.ReadToEnd(); 15 | } 16 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/MauiProgram.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Logging; 2 | 3 | namespace LLM.Offline.Streaming.App 4 | { 5 | public static class MauiProgram 6 | { 7 | public static MauiApp CreateMauiApp() 8 | { 9 | var builder = MauiApp.CreateBuilder(); 10 | builder 11 | .UseMauiApp() 12 | .ConfigureFonts(fonts => 13 | { 14 | fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); 15 | }); 16 | 17 | builder.Services.AddMauiBlazorWebView(); 18 | 19 | #if DEBUG 20 | builder.Services.AddBlazorWebViewDeveloperTools(); 21 | builder.Logging.AddDebug(); 22 | #endif 23 | 24 | return builder.Build(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/Platforms/Windows/app.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 11 | true/PM 12 | PerMonitorV2, PerMonitor 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/Platforms/Tizen/tizen-manifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | maui-appicon-placeholder 7 | 8 | 9 | 10 | 11 | http://tizen.org/privilege/internet 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.Api/Program.cs: -------------------------------------------------------------------------------- 1 | 2 | using LLM.Offline.Streaming.Api.Brokers; 3 | 4 | namespace LLM.Offline.Streaming.Api 5 | { 6 | public class Program 7 | { 8 | public static void Main(string[] args) 9 | { 10 | var builder = WebApplication.CreateBuilder(args); 11 | 12 | 13 | builder.Services.AddControllers(); 14 | builder.Services.AddOpenApi(); 15 | builder.Services.AddTransient(); 16 | 17 | var app = builder.Build(); 18 | 19 | // Configure the HTTP request pipeline. 20 | if (app.Environment.IsDevelopment()) 21 | { 22 | app.MapOpenApi(); 23 | } 24 | 25 | app.UseHttpsRedirection(); 26 | 27 | app.UseAuthorization(); 28 | 29 | 30 | app.MapControllers(); 31 | 32 | app.Run(); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/Platforms/Windows/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.UI.Xaml; 2 | 3 | // To learn more about WinUI, the WinUI project structure, 4 | // and more about our project templates, see: http://aka.ms/winui-project-info. 5 | 6 | namespace LLM.Offline.Streaming.App.WinUI 7 | { 8 | /// 9 | /// Provides application-specific behavior to supplement the default Application class. 10 | /// 11 | public partial class App : MauiWinUIApplication 12 | { 13 | /// 14 | /// Initializes the singleton application object. This is the first line of authored code 15 | /// executed, and as such is the logical equivalent of main() or WinMain(). 16 | /// 17 | public App() 18 | { 19 | this.InitializeComponent(); 20 | } 21 | 22 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/wwwroot/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | LLM.Offline.Streaming.App 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 |
Loading...
19 | 20 |
21 | An unhandled error has occurred. 22 | Reload 23 | 🗙 24 |
25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/Components/Layout/NavMenu.razor: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 28 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/Brokers/LLMApiBroker.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http.Json; 2 | using System.Text.Json; 3 | 4 | namespace LLM.Offline.Streaming.App.Brokers 5 | { 6 | public class LLMApiBroker 7 | { 8 | public async IAsyncEnumerable PromptAsync(string prompt) 9 | { 10 | var httpClient = new HttpClient(); 11 | httpClient.BaseAddress = new Uri("https://localhost:7102"); 12 | 13 | var httpRequest = new HttpRequestMessage(HttpMethod.Post, "api/chats") 14 | { 15 | Content = JsonContent.Create(prompt) 16 | }; 17 | 18 | using var response = await httpClient.SendAsync(httpRequest, HttpCompletionOption.ResponseHeadersRead); 19 | response.EnsureSuccessStatusCode(); 20 | 21 | await using var responseStream = await response.Content.ReadAsStreamAsync(); 22 | 23 | var jsonOptions = new JsonSerializerOptions() 24 | { 25 | PropertyNameCaseInsensitive = true 26 | }; 27 | 28 | await foreach (var token in JsonSerializer.DeserializeAsyncEnumerable(responseStream, jsonOptions)) 29 | { 30 | yield return token; 31 | } 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/Platforms/iOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | LSRequiresIPhoneOS 6 | 7 | UIDeviceFamily 8 | 9 | 1 10 | 2 11 | 12 | UIRequiredDeviceCapabilities 13 | 14 | arm64 15 | 16 | UISupportedInterfaceOrientations 17 | 18 | UIInterfaceOrientationPortrait 19 | UIInterfaceOrientationLandscapeLeft 20 | UIInterfaceOrientationLandscapeRight 21 | 22 | UISupportedInterfaceOrientations~ipad 23 | 24 | UIInterfaceOrientationPortrait 25 | UIInterfaceOrientationPortraitUpsideDown 26 | UIInterfaceOrientationLandscapeLeft 27 | UIInterfaceOrientationLandscapeRight 28 | 29 | XSAppIconAssets 30 | Assets.xcassets/appicon.appiconset 31 | 32 | 33 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.Client/Program.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http.Json; 2 | using System.Text.Json; 3 | 4 | namespace LLM.Offline.Streaming.Client 5 | { 6 | internal class Program 7 | { 8 | static async Task Main(string[] args) 9 | { 10 | var httpClient = new HttpClient(); 11 | httpClient.BaseAddress = new Uri("https://localhost:7102"); 12 | 13 | while (true) 14 | { 15 | Console.Write("User:"); 16 | string userPrompt = Console.ReadLine(); 17 | 18 | Console.WriteLine(); 19 | var httpRequest = new HttpRequestMessage(HttpMethod.Post, "api/chats") 20 | { 21 | Content = JsonContent.Create(userPrompt) 22 | }; 23 | 24 | using var response = await httpClient.SendAsync(httpRequest, HttpCompletionOption.ResponseHeadersRead); 25 | response.EnsureSuccessStatusCode(); 26 | 27 | await using var responseStream = await response.Content.ReadAsStreamAsync(); 28 | 29 | var jsonOptions = new JsonSerializerOptions() { PropertyNameCaseInsensitive = true }; 30 | Console.Write("System"); 31 | await foreach (var token in JsonSerializer.DeserializeAsyncEnumerable(responseStream, jsonOptions)) 32 | { 33 | Console.Write(token); 34 | } 35 | 36 | } 37 | Console.ReadLine(); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/Resources/Splash/splash.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/Resources/AppIcon/appiconfg.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/Components/Layout/MainLayout.razor.css: -------------------------------------------------------------------------------- 1 | .page { 2 | position: relative; 3 | display: flex; 4 | flex-direction: column; 5 | } 6 | 7 | main { 8 | flex: 1; 9 | } 10 | 11 | .sidebar { 12 | background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); 13 | } 14 | 15 | .top-row { 16 | background-color: #f7f7f7; 17 | border-bottom: 1px solid #d6d5d5; 18 | justify-content: flex-end; 19 | height: 3.5rem; 20 | display: flex; 21 | align-items: center; 22 | } 23 | 24 | .top-row ::deep a, .top-row ::deep .btn-link { 25 | white-space: nowrap; 26 | margin-left: 1.5rem; 27 | text-decoration: none; 28 | } 29 | 30 | .top-row ::deep a:hover, .top-row ::deep .btn-link:hover { 31 | text-decoration: underline; 32 | } 33 | 34 | .top-row ::deep a:first-child { 35 | overflow: hidden; 36 | text-overflow: ellipsis; 37 | } 38 | 39 | @media (max-width: 640.98px) { 40 | .top-row { 41 | justify-content: space-between; 42 | } 43 | 44 | .top-row ::deep a, .top-row ::deep .btn-link { 45 | margin-left: 0; 46 | } 47 | } 48 | 49 | @media (min-width: 641px) { 50 | .page { 51 | flex-direction: row; 52 | } 53 | 54 | .sidebar { 55 | width: 250px; 56 | height: 100vh; 57 | position: sticky; 58 | top: 0; 59 | } 60 | 61 | .top-row { 62 | position: sticky; 63 | top: 0; 64 | z-index: 1; 65 | } 66 | 67 | .top-row.auth ::deep a:first-child { 68 | flex: 1; 69 | text-align: right; 70 | width: 0; 71 | } 72 | 73 | .top-row, article { 74 | padding-left: 2rem !important; 75 | padding-right: 1.5rem !important; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/Platforms/MacCatalyst/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | UIDeviceFamily 15 | 16 | 2 17 | 18 | UIRequiredDeviceCapabilities 19 | 20 | arm64 21 | 22 | UISupportedInterfaceOrientations 23 | 24 | UIInterfaceOrientationPortrait 25 | UIInterfaceOrientationLandscapeLeft 26 | UIInterfaceOrientationLandscapeRight 27 | 28 | UISupportedInterfaceOrientations~ipad 29 | 30 | UIInterfaceOrientationPortrait 31 | UIInterfaceOrientationPortraitUpsideDown 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | XSAppIconAssets 36 | Assets.xcassets/appicon.appiconset 37 | 38 | 39 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/Components/Pages/Weather.razor: -------------------------------------------------------------------------------- 1 | @page "/weather" 2 | 3 |

Weather

4 | 5 |

This component demonstrates showing data.

6 | 7 | @if (forecasts == null) 8 | { 9 |

Loading...

10 | } 11 | else 12 | { 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | @foreach (var forecast in forecasts) 24 | { 25 | 26 | 27 | 28 | 29 | 30 | 31 | } 32 | 33 |
DateTemp. (C)Temp. (F)Summary
@forecast.Date.ToShortDateString()@forecast.TemperatureC@forecast.TemperatureF@forecast.Summary
34 | } 35 | 36 | @code { 37 | private WeatherForecast[]? forecasts; 38 | 39 | protected override async Task OnInitializedAsync() 40 | { 41 | // Simulate asynchronous loading to demonstrate a loading indicator 42 | await Task.Delay(500); 43 | 44 | var startDate = DateOnly.FromDateTime(DateTime.Now); 45 | var summaries = new[] { "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" }; 46 | forecasts = Enumerable.Range(1, 5).Select(index => new WeatherForecast 47 | { 48 | Date = startDate.AddDays(index), 49 | TemperatureC = Random.Shared.Next(-20, 55), 50 | Summary = summaries[Random.Shared.Next(summaries.Length)] 51 | }).ToArray(); 52 | } 53 | 54 | private class WeatherForecast 55 | { 56 | public DateOnly Date { get; set; } 57 | public int TemperatureC { get; set; } 58 | public string? Summary { get; set; } 59 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/Platforms/Windows/Package.appxmanifest: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | $placeholder$ 15 | User Name 16 | $placeholder$.png 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/Platforms/iOS/Resources/PrivacyInfo.xcprivacy: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 13 | NSPrivacyAccessedAPITypes 14 | 15 | 16 | NSPrivacyAccessedAPIType 17 | NSPrivacyAccessedAPICategoryFileTimestamp 18 | NSPrivacyAccessedAPITypeReasons 19 | 20 | C617.1 21 | 22 | 23 | 24 | NSPrivacyAccessedAPIType 25 | NSPrivacyAccessedAPICategorySystemBootTime 26 | NSPrivacyAccessedAPITypeReasons 27 | 28 | 35F9.1 29 | 30 | 31 | 32 | NSPrivacyAccessedAPIType 33 | NSPrivacyAccessedAPICategoryDiskSpace 34 | NSPrivacyAccessedAPITypeReasons 35 | 36 | E174.1 37 | 38 | 39 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/Components/Pages/Home.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | @using LLM.Offline.Streaming.App.Brokers 3 | 4 | 41 | 42 |
43 | @foreach (string chat in Chats) 44 | { 45 |
46 | @chat 47 |
48 | } 49 | 50 | 51 | 52 | 53 |
54 | 55 | @code 56 | { 57 | List Chats = new List(); 58 | public string Message { get; set; } 59 | public LLMApiBroker lLMApiBroker { get; set; } 60 | 61 | protected override void OnInitialized() => 62 | this.lLMApiBroker = new LLMApiBroker(); 63 | 64 | public async Task SendMessageAsync() 65 | { 66 | string prompt = this.Message; 67 | this.Chats.Add(this.Message); 68 | this.Message = String.Empty; 69 | this.Chats.Add(string.Empty); 70 | 71 | await foreach (string word in this.lLMApiBroker.PromptAsync(prompt)) 72 | { 73 | this.Chats[^1] += word; 74 | StateHasChanged(); 75 | } 76 | } 77 | } -------------------------------------------------------------------------------- /LLM.Offline.Streaming.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.12.35728.132 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LLM.Offline.Streaming.Api", "LLM.Offline.Streaming.Api\LLM.Offline.Streaming.Api.csproj", "{53E5823E-4125-467C-A520-ECF2874B7512}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LLM.Offline.Streaming.Client", "LLM.Offline.Streaming.Client\LLM.Offline.Streaming.Client.csproj", "{8348DD83-BB32-4505-92AA-91705274A21F}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LLM.Offline.Streaming.App", "LLM.Offline.Streaming.App\LLM.Offline.Streaming.App.csproj", "{DD0EEB5C-9DD0-4AA3-B1BE-9AD20EE9A112}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Release|Any CPU = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {53E5823E-4125-467C-A520-ECF2874B7512}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {53E5823E-4125-467C-A520-ECF2874B7512}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {53E5823E-4125-467C-A520-ECF2874B7512}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {53E5823E-4125-467C-A520-ECF2874B7512}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {8348DD83-BB32-4505-92AA-91705274A21F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {8348DD83-BB32-4505-92AA-91705274A21F}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {8348DD83-BB32-4505-92AA-91705274A21F}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {8348DD83-BB32-4505-92AA-91705274A21F}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {DD0EEB5C-9DD0-4AA3-B1BE-9AD20EE9A112}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {DD0EEB5C-9DD0-4AA3-B1BE-9AD20EE9A112}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {DD0EEB5C-9DD0-4AA3-B1BE-9AD20EE9A112}.Debug|Any CPU.Deploy.0 = Debug|Any CPU 29 | {DD0EEB5C-9DD0-4AA3-B1BE-9AD20EE9A112}.Release|Any CPU.ActiveCfg = Release|Any CPU 30 | {DD0EEB5C-9DD0-4AA3-B1BE-9AD20EE9A112}.Release|Any CPU.Build.0 = Release|Any CPU 31 | EndGlobalSection 32 | GlobalSection(SolutionProperties) = preSolution 33 | HideSolutionNode = FALSE 34 | EndGlobalSection 35 | EndGlobal 36 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.Api/Brokers/LLMBroker.cs: -------------------------------------------------------------------------------- 1 | using LLama.Common; 2 | using LLama.Sampling; 3 | using LLama; 4 | 5 | namespace LLM.Offline.Streaming.Api.Brokers 6 | { 7 | public class LLMBroker : ILLMBroker 8 | { 9 | // hold onto everything so we can dispose properly 10 | private readonly LLamaWeights modelWeights; 11 | private readonly LLamaContext llamaContext; 12 | private readonly InteractiveExecutor executor; 13 | private readonly InferenceParams inferenceParams; 14 | private readonly ChatSession session; 15 | private readonly ChatHistory history; 16 | 17 | public LLMBroker() 18 | { 19 | string modelPath = "mistral-7b-instruct-v0.1.Q8_0.gguf"; 20 | uint? ctxSize = 2048; 21 | int gpuLayers = 128; 22 | 23 | var mp = new ModelParams(modelPath) 24 | { 25 | ContextSize = ctxSize, 26 | GpuLayerCount = gpuLayers 27 | }; 28 | 29 | modelWeights = LLamaWeights.LoadFromFile(mp); 30 | llamaContext = modelWeights.CreateContext(mp); 31 | executor = new InteractiveExecutor(llamaContext); 32 | history = new ChatHistory(); 33 | 34 | history.AddMessage( 35 | authorRole: AuthorRole.System, 36 | content: @"You are a helpful assistant."); 37 | 38 | 39 | session = new ChatSession(executor, history); 40 | 41 | inferenceParams = new InferenceParams 42 | { 43 | MaxTokens = 256, 44 | 45 | SamplingPipeline = new DefaultSamplingPipeline 46 | { 47 | Temperature = 0.6f, 48 | TopK = 40 49 | }, 50 | 51 | AntiPrompts = new List { "()" }, // Cut off early 52 | }; 53 | } 54 | 55 | public void Dispose() 56 | { 57 | llamaContext.Dispose(); 58 | modelWeights.Dispose(); 59 | } 60 | 61 | public IAsyncEnumerable PromptAsync(string userMessage) 62 | { 63 | var message = new ChatHistory 64 | .Message(AuthorRole.User, userMessage); 65 | 66 | return session.ChatAsync(message, inferenceParams); 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/wwwroot/css/app.css: -------------------------------------------------------------------------------- 1 | /*#if (SampleContent)*/ 2 | html, body { 3 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 4 | } 5 | 6 | a, .btn-link { 7 | color: #006bb7; 8 | } 9 | 10 | .btn-primary { 11 | color: #fff; 12 | background-color: #1b6ec2; 13 | border-color: #1861ac; 14 | } 15 | 16 | .btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus { 17 | box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb; 18 | } 19 | 20 | .content { 21 | padding-top: 1.1rem; 22 | } 23 | 24 | /*#endif*/ 25 | h1:focus { 26 | outline: none; 27 | } 28 | 29 | .valid.modified:not([type=checkbox]) { 30 | outline: 1px solid #26b050; 31 | } 32 | 33 | .invalid { 34 | outline: 1px solid #e50000; 35 | } 36 | 37 | .validation-message { 38 | color: #e50000; 39 | } 40 | 41 | #blazor-error-ui { 42 | background: lightyellow; 43 | bottom: 0; 44 | box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); 45 | display: none; 46 | left: 0; 47 | padding: 0.6rem 1.25rem 0.7rem 1.25rem; 48 | position: fixed; 49 | width: 100%; 50 | z-index: 1000; 51 | } 52 | 53 | #blazor-error-ui .dismiss { 54 | cursor: pointer; 55 | position: absolute; 56 | right: 0.75rem; 57 | top: 0.5rem; 58 | } 59 | 60 | .blazor-error-boundary { 61 | background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121; 62 | padding: 1rem 1rem 1rem 3.7rem; 63 | color: white; 64 | } 65 | 66 | .blazor-error-boundary::after { 67 | content: "An error has occurred." 68 | } 69 | 70 | .status-bar-safe-area { 71 | display: none; 72 | } 73 | 74 | @supports (-webkit-touch-callout: none) { 75 | .status-bar-safe-area { 76 | display: flex; 77 | position: sticky; 78 | top: 0; 79 | height: env(safe-area-inset-top); 80 | background-color: #f7f7f7; 81 | width: 100%; 82 | z-index: 1; 83 | } 84 | 85 | .flex-column, .navbar-brand { 86 | padding-left: env(safe-area-inset-left); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/Components/Layout/NavMenu.razor.css: -------------------------------------------------------------------------------- 1 | .navbar-toggler { 2 | appearance: none; 3 | cursor: pointer; 4 | width: 3.5rem; 5 | height: 2.5rem; 6 | color: white; 7 | position: absolute; 8 | top: 0.5rem; 9 | right: 1rem; 10 | border: 1px solid rgba(255, 255, 255, 0.1); 11 | background: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.55%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") no-repeat center/1.75rem rgba(255, 255, 255, 0.1); 12 | } 13 | 14 | .navbar-toggler:checked { 15 | background-color: rgba(255, 255, 255, 0.5); 16 | } 17 | 18 | .top-row { 19 | height: 3.5rem; 20 | background-color: rgba(0,0,0,0.4); 21 | } 22 | 23 | .navbar-brand { 24 | font-size: 1.1rem; 25 | } 26 | 27 | .bi { 28 | display: inline-block; 29 | position: relative; 30 | width: 1.25rem; 31 | height: 1.25rem; 32 | margin-right: 0.75rem; 33 | top: -1px; 34 | background-size: cover; 35 | } 36 | 37 | .bi-house-door-fill-nav-menu { 38 | background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-house-door-fill' viewBox='0 0 16 16'%3E%3Cpath d='M6.5 14.5v-3.505c0-.245.25-.495.5-.495h2c.25 0 .5.25.5.5v3.5a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5v-7a.5.5 0 0 0-.146-.354L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293L8.354 1.146a.5.5 0 0 0-.708 0l-6 6A.5.5 0 0 0 1.5 7.5v7a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5Z'/%3E%3C/svg%3E"); 39 | } 40 | 41 | .bi-plus-square-fill-nav-menu { 42 | background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-plus-square-fill' viewBox='0 0 16 16'%3E%3Cpath d='M2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2zm6.5 4.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3a.5.5 0 0 1 1 0z'/%3E%3C/svg%3E"); 43 | } 44 | 45 | .bi-list-nested-nav-menu { 46 | background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-list-nested' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M4.5 11.5A.5.5 0 0 1 5 11h10a.5.5 0 0 1 0 1H5a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 3 7h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 1 3h10a.5.5 0 0 1 0 1H1a.5.5 0 0 1-.5-.5z'/%3E%3C/svg%3E"); 47 | } 48 | 49 | .nav-item { 50 | font-size: 0.9rem; 51 | padding-bottom: 0.5rem; 52 | } 53 | 54 | .nav-item:first-of-type { 55 | padding-top: 1rem; 56 | } 57 | 58 | .nav-item:last-of-type { 59 | padding-bottom: 1rem; 60 | } 61 | 62 | .nav-item ::deep a { 63 | color: #d7d7d7; 64 | border-radius: 4px; 65 | height: 3rem; 66 | display: flex; 67 | align-items: center; 68 | line-height: 3rem; 69 | } 70 | 71 | .nav-item ::deep a.active { 72 | background-color: rgba(255,255,255,0.37); 73 | color: white; 74 | } 75 | 76 | .nav-item ::deep a:hover { 77 | background-color: rgba(255,255,255,0.1); 78 | color: white; 79 | } 80 | 81 | .nav-scrollable { 82 | display: none; 83 | } 84 | 85 | .navbar-toggler:checked ~ .nav-scrollable { 86 | display: block; 87 | } 88 | 89 | @media (min-width: 641px) { 90 | .navbar-toggler { 91 | display: none; 92 | } 93 | 94 | .nav-scrollable { 95 | /* Never collapse the sidebar for wide screens */ 96 | display: block; 97 | /* Allow sidebar to scroll for tall menus */ 98 | height: calc(100vh - 3.5rem); 99 | overflow-y: auto; 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/LLM.Offline.Streaming.App.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net9.0-android;net9.0-ios;net9.0-maccatalyst 5 | $(TargetFrameworks);net9.0-windows10.0.19041.0 6 | 7 | 8 | 9 | 14 | 15 | 16 | Exe 17 | LLM.Offline.Streaming.App 18 | true 19 | true 20 | enable 21 | false 22 | enable 23 | 24 | 25 | LLM.Offline.Streaming.App 26 | 27 | 28 | com.companyname.llm.offline.streaming.app 29 | 30 | 31 | 1.0 32 | 1 33 | 34 | 35 | None 36 | 37 | 15.0 38 | 15.0 39 | 24.0 40 | 10.0.17763.0 41 | 10.0.17763.0 42 | 6.5 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Oo]ut/ 33 | [Ll]og/ 34 | [Ll]ogs/ 35 | 36 | # Visual Studio 2015/2017 cache/options directory 37 | .vs/ 38 | # Uncomment if you have tasks that create the project's static files in wwwroot 39 | #wwwroot/ 40 | 41 | # Visual Studio 2017 auto generated files 42 | Generated\ Files/ 43 | 44 | # MSTest test Results 45 | [Tt]est[Rr]esult*/ 46 | [Bb]uild[Ll]og.* 47 | 48 | # NUnit 49 | *.VisualState.xml 50 | TestResult.xml 51 | nunit-*.xml 52 | 53 | # Build Results of an ATL Project 54 | [Dd]ebugPS/ 55 | [Rr]eleasePS/ 56 | dlldata.c 57 | 58 | # Benchmark Results 59 | BenchmarkDotNet.Artifacts/ 60 | 61 | # .NET Core 62 | project.lock.json 63 | project.fragment.lock.json 64 | artifacts/ 65 | 66 | # ASP.NET Scaffolding 67 | ScaffoldingReadMe.txt 68 | 69 | # StyleCop 70 | StyleCopReport.xml 71 | 72 | # Files built by Visual Studio 73 | *_i.c 74 | *_p.c 75 | *_h.h 76 | *.ilk 77 | *.meta 78 | *.obj 79 | *.iobj 80 | *.pch 81 | *.pdb 82 | *.ipdb 83 | *.pgc 84 | *.pgd 85 | *.rsp 86 | *.sbr 87 | *.tlb 88 | *.tli 89 | *.tlh 90 | *.tmp 91 | *.tmp_proj 92 | *_wpftmp.csproj 93 | *.log 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio LightSwitch build output 298 | **/*.HTMLClient/GeneratedArtifacts 299 | **/*.DesktopClient/GeneratedArtifacts 300 | **/*.DesktopClient/ModelManifest.xml 301 | **/*.Server/GeneratedArtifacts 302 | **/*.Server/ModelManifest.xml 303 | _Pvt_Extensions 304 | 305 | # Paket dependency manager 306 | .paket/paket.exe 307 | paket-files/ 308 | 309 | # FAKE - F# Make 310 | .fake/ 311 | 312 | # CodeRush personal settings 313 | .cr/personal 314 | 315 | # Python Tools for Visual Studio (PTVS) 316 | __pycache__/ 317 | *.pyc 318 | 319 | # Cake - Uncomment if you are using it 320 | # tools/** 321 | # !tools/packages.config 322 | 323 | # Tabs Studio 324 | *.tss 325 | 326 | # Telerik's JustMock configuration file 327 | *.jmconfig 328 | 329 | # BizTalk build output 330 | *.btp.cs 331 | *.btm.cs 332 | *.odx.cs 333 | *.xsd.cs 334 | 335 | # OpenCover UI analysis results 336 | OpenCover/ 337 | 338 | # Azure Stream Analytics local run output 339 | ASALocalRun/ 340 | 341 | # MSBuild Binary and Structured Log 342 | *.binlog 343 | 344 | # NVidia Nsight GPU debugger configuration file 345 | *.nvuser 346 | 347 | # MFractors (Xamarin productivity tool) working folder 348 | .mfractor/ 349 | 350 | # Local History for Visual Studio 351 | .localhistory/ 352 | 353 | # BeatPulse healthcheck temp database 354 | healthchecksdb 355 | 356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 357 | MigrationBackup/ 358 | 359 | # Ionide (cross platform F# VS Code tools) working folder 360 | .ionide/ 361 | 362 | # Fody - auto-generated XML schema 363 | FodyWeavers.xsd 364 | /LLM.Offline.Streaming.Api/mistral-7b-instruct-v0.1.Q8_0.gguf 365 | -------------------------------------------------------------------------------- /LLM.Offline.Streaming.App/Resources/Images/dotnet_bot.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | --------------------------------------------------------------------------------