From e62c66cd7567cc86141500f8aa8f0df251a1a42c Mon Sep 17 00:00:00 2001 From: Chester Liu <4710575+skyline75489@users.noreply.github.com> Date: Wed, 28 Aug 2024 16:19:59 +0800 Subject: [PATCH 01/31] Init --- examples/csharp/GennyMaui/GennyMaui.sln | 27 ++ examples/csharp/GennyMaui/GennyMaui/App.xaml | 19 + .../csharp/GennyMaui/GennyMaui/App.xaml.cs | 19 + .../csharp/GennyMaui/GennyMaui/AppShell.xaml | 14 + .../GennyMaui/GennyMaui/AppShell.xaml.cs | 10 + .../GennyMaui/GennyMaui/AppShellMobile.xaml | 11 + .../GennyMaui/AppShellMobile.xaml.cs | 10 + .../GennyMaui/GennyMaui/GennyMaui.csproj | 96 ++++ .../GennyMaui/GennyMaui/GennyMaui.csproj.user | 50 ++ .../csharp/GennyMaui/GennyMaui/MauiProgram.cs | 27 ++ .../GennyMaui/Models/ConfigurationModel.cs | 14 + .../GennyMaui/Models/ModelOptionsModel.cs | 14 + .../GennyMaui/GennyMaui/Models/TokenModel.cs | 5 + .../GennyMaui/Pages/AppMainPage.xaml | 12 + .../GennyMaui/Pages/AppMainPage.xaml.cs | 9 + .../Pages/Views/ModelConfigView.xaml | 29 ++ .../Pages/Views/ModelConfigView.xaml.cs | 9 + .../Pages/Views/SearchOptionView.xaml | 91 ++++ .../Pages/Views/SearchOptionView.xaml.cs | 9 + .../GennyMaui/Pages/Views/StatefulView.xaml | 67 +++ .../Pages/Views/StatefulView.xaml.cs | 16 + .../Platforms/Android/AndroidManifest.xml | 6 + .../Platforms/Android/MainActivity.cs | 11 + .../Platforms/Android/MainApplication.cs | 16 + .../Android/Resources/values/colors.xml | 6 + .../Platforms/MacCatalyst/AppDelegate.cs | 10 + .../Platforms/MacCatalyst/Entitlements.plist | 14 + .../Platforms/MacCatalyst/Info.plist | 38 ++ .../Platforms/MacCatalyst/Program.cs | 16 + .../GennyMaui/Platforms/Tizen/Main.cs | 17 + .../Platforms/Tizen/tizen-manifest.xml | 15 + .../GennyMaui/Platforms/Windows/App.xaml | 8 + .../GennyMaui/Platforms/Windows/App.xaml.cs | 25 + .../Platforms/Windows/Package.appxmanifest | 46 ++ .../GennyMaui/Platforms/Windows/app.manifest | 15 + .../GennyMaui/Platforms/iOS/AppDelegate.cs | 10 + .../GennyMaui/Platforms/iOS/Info.plist | 32 ++ .../GennyMaui/Platforms/iOS/Program.cs | 16 + .../iOS/Resources/PrivacyInfo.xcprivacy | 51 +++ .../GennyMaui/Properties/launchSettings.json | 8 + .../GennyMaui/Resources/AppIcon/appicon.svg | 4 + .../GennyMaui/Resources/AppIcon/appiconfg.svg | 8 + .../Resources/Fonts/OpenSans-Regular.ttf | Bin 0 -> 107280 bytes .../Resources/Fonts/OpenSans-Semibold.ttf | Bin 0 -> 111168 bytes .../GennyMaui/Resources/Images/robot.png | Bin 0 -> 6385 bytes .../GennyMaui/Resources/Images/user.png | Bin 0 -> 5549 bytes .../GennyMaui/Resources/Raw/AboutAssets.txt | 15 + .../GennyMaui/Resources/Splash/splash.svg | 8 + .../GennyMaui/Resources/Styles/Colors.xaml | 45 ++ .../GennyMaui/Resources/Styles/Styles.xaml | 427 ++++++++++++++++++ .../GennyMaui/Utils/GenaiExtensions.cs | 46 ++ .../GennyMaui/ViewModels/LoadableModel.cs | 96 ++++ .../GennyMaui/ViewModels/ResultModel.cs | 15 + .../ViewModels/SearchOptionsModel.cs | 64 +++ .../ViewModels/StatefulChatViewModel.cs | 180 ++++++++ 55 files changed, 1826 insertions(+) create mode 100644 examples/csharp/GennyMaui/GennyMaui.sln create mode 100644 examples/csharp/GennyMaui/GennyMaui/App.xaml create mode 100644 examples/csharp/GennyMaui/GennyMaui/App.xaml.cs create mode 100644 examples/csharp/GennyMaui/GennyMaui/AppShell.xaml create mode 100644 examples/csharp/GennyMaui/GennyMaui/AppShell.xaml.cs create mode 100644 examples/csharp/GennyMaui/GennyMaui/AppShellMobile.xaml create mode 100644 examples/csharp/GennyMaui/GennyMaui/AppShellMobile.xaml.cs create mode 100644 examples/csharp/GennyMaui/GennyMaui/GennyMaui.csproj create mode 100644 examples/csharp/GennyMaui/GennyMaui/GennyMaui.csproj.user create mode 100644 examples/csharp/GennyMaui/GennyMaui/MauiProgram.cs create mode 100644 examples/csharp/GennyMaui/GennyMaui/Models/ConfigurationModel.cs create mode 100644 examples/csharp/GennyMaui/GennyMaui/Models/ModelOptionsModel.cs create mode 100644 examples/csharp/GennyMaui/GennyMaui/Models/TokenModel.cs create mode 100644 examples/csharp/GennyMaui/GennyMaui/Pages/AppMainPage.xaml create mode 100644 examples/csharp/GennyMaui/GennyMaui/Pages/AppMainPage.xaml.cs create mode 100644 examples/csharp/GennyMaui/GennyMaui/Pages/Views/ModelConfigView.xaml create mode 100644 examples/csharp/GennyMaui/GennyMaui/Pages/Views/ModelConfigView.xaml.cs create mode 100644 examples/csharp/GennyMaui/GennyMaui/Pages/Views/SearchOptionView.xaml create mode 100644 examples/csharp/GennyMaui/GennyMaui/Pages/Views/SearchOptionView.xaml.cs create mode 100644 examples/csharp/GennyMaui/GennyMaui/Pages/Views/StatefulView.xaml create mode 100644 examples/csharp/GennyMaui/GennyMaui/Pages/Views/StatefulView.xaml.cs create mode 100644 examples/csharp/GennyMaui/GennyMaui/Platforms/Android/AndroidManifest.xml create mode 100644 examples/csharp/GennyMaui/GennyMaui/Platforms/Android/MainActivity.cs create mode 100644 examples/csharp/GennyMaui/GennyMaui/Platforms/Android/MainApplication.cs create mode 100644 examples/csharp/GennyMaui/GennyMaui/Platforms/Android/Resources/values/colors.xml create mode 100644 examples/csharp/GennyMaui/GennyMaui/Platforms/MacCatalyst/AppDelegate.cs create mode 100644 examples/csharp/GennyMaui/GennyMaui/Platforms/MacCatalyst/Entitlements.plist create mode 100644 examples/csharp/GennyMaui/GennyMaui/Platforms/MacCatalyst/Info.plist create mode 100644 examples/csharp/GennyMaui/GennyMaui/Platforms/MacCatalyst/Program.cs create mode 100644 examples/csharp/GennyMaui/GennyMaui/Platforms/Tizen/Main.cs create mode 100644 examples/csharp/GennyMaui/GennyMaui/Platforms/Tizen/tizen-manifest.xml create mode 100644 examples/csharp/GennyMaui/GennyMaui/Platforms/Windows/App.xaml create mode 100644 examples/csharp/GennyMaui/GennyMaui/Platforms/Windows/App.xaml.cs create mode 100644 examples/csharp/GennyMaui/GennyMaui/Platforms/Windows/Package.appxmanifest create mode 100644 examples/csharp/GennyMaui/GennyMaui/Platforms/Windows/app.manifest create mode 100644 examples/csharp/GennyMaui/GennyMaui/Platforms/iOS/AppDelegate.cs create mode 100644 examples/csharp/GennyMaui/GennyMaui/Platforms/iOS/Info.plist create mode 100644 examples/csharp/GennyMaui/GennyMaui/Platforms/iOS/Program.cs create mode 100644 examples/csharp/GennyMaui/GennyMaui/Platforms/iOS/Resources/PrivacyInfo.xcprivacy create mode 100644 examples/csharp/GennyMaui/GennyMaui/Properties/launchSettings.json create mode 100644 examples/csharp/GennyMaui/GennyMaui/Resources/AppIcon/appicon.svg create mode 100644 examples/csharp/GennyMaui/GennyMaui/Resources/AppIcon/appiconfg.svg create mode 100644 examples/csharp/GennyMaui/GennyMaui/Resources/Fonts/OpenSans-Regular.ttf create mode 100644 examples/csharp/GennyMaui/GennyMaui/Resources/Fonts/OpenSans-Semibold.ttf create mode 100644 examples/csharp/GennyMaui/GennyMaui/Resources/Images/robot.png create mode 100644 examples/csharp/GennyMaui/GennyMaui/Resources/Images/user.png create mode 100644 examples/csharp/GennyMaui/GennyMaui/Resources/Raw/AboutAssets.txt create mode 100644 examples/csharp/GennyMaui/GennyMaui/Resources/Splash/splash.svg create mode 100644 examples/csharp/GennyMaui/GennyMaui/Resources/Styles/Colors.xaml create mode 100644 examples/csharp/GennyMaui/GennyMaui/Resources/Styles/Styles.xaml create mode 100644 examples/csharp/GennyMaui/GennyMaui/Utils/GenaiExtensions.cs create mode 100644 examples/csharp/GennyMaui/GennyMaui/ViewModels/LoadableModel.cs create mode 100644 examples/csharp/GennyMaui/GennyMaui/ViewModels/ResultModel.cs create mode 100644 examples/csharp/GennyMaui/GennyMaui/ViewModels/SearchOptionsModel.cs create mode 100644 examples/csharp/GennyMaui/GennyMaui/ViewModels/StatefulChatViewModel.cs diff --git a/examples/csharp/GennyMaui/GennyMaui.sln b/examples/csharp/GennyMaui/GennyMaui.sln new file mode 100644 index 000000000..2324beb06 --- /dev/null +++ b/examples/csharp/GennyMaui/GennyMaui.sln @@ -0,0 +1,27 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.11.35219.272 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GennyMaui", "GennyMaui\GennyMaui.csproj", "{6FFCAD8B-C49A-4C89-8345-66DDD01FA96E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6FFCAD8B-C49A-4C89-8345-66DDD01FA96E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6FFCAD8B-C49A-4C89-8345-66DDD01FA96E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6FFCAD8B-C49A-4C89-8345-66DDD01FA96E}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {6FFCAD8B-C49A-4C89-8345-66DDD01FA96E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6FFCAD8B-C49A-4C89-8345-66DDD01FA96E}.Release|Any CPU.Build.0 = Release|Any CPU + {6FFCAD8B-C49A-4C89-8345-66DDD01FA96E}.Release|Any CPU.Deploy.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {044E2864-E43E-48C4-9126-84F9C06A2B7B} + EndGlobalSection +EndGlobal diff --git a/examples/csharp/GennyMaui/GennyMaui/App.xaml b/examples/csharp/GennyMaui/GennyMaui/App.xaml new file mode 100644 index 000000000..0d7d56794 --- /dev/null +++ b/examples/csharp/GennyMaui/GennyMaui/App.xaml @@ -0,0 +1,19 @@ + + + + + + + + + user.png + robot.png + + + + + diff --git a/examples/csharp/GennyMaui/GennyMaui/App.xaml.cs b/examples/csharp/GennyMaui/GennyMaui/App.xaml.cs new file mode 100644 index 000000000..6aa30b46d --- /dev/null +++ b/examples/csharp/GennyMaui/GennyMaui/App.xaml.cs @@ -0,0 +1,19 @@ +namespace GennyMaui +{ + public partial class App : Application + { + public App() + { + InitializeComponent(); + + if (DeviceInfo.Idiom == DeviceIdiom.Phone) + { + MainPage = new AppShellMobile(); + } + else + { + MainPage = new AppShell(); + } + } + } +} diff --git a/examples/csharp/GennyMaui/GennyMaui/AppShell.xaml b/examples/csharp/GennyMaui/GennyMaui/AppShell.xaml new file mode 100644 index 000000000..b23253e9b --- /dev/null +++ b/examples/csharp/GennyMaui/GennyMaui/AppShell.xaml @@ -0,0 +1,14 @@ + + + + + diff --git a/examples/csharp/GennyMaui/GennyMaui/AppShell.xaml.cs b/examples/csharp/GennyMaui/GennyMaui/AppShell.xaml.cs new file mode 100644 index 000000000..03ae22458 --- /dev/null +++ b/examples/csharp/GennyMaui/GennyMaui/AppShell.xaml.cs @@ -0,0 +1,10 @@ +namespace GennyMaui +{ + public partial class AppShell : Shell + { + public AppShell() + { + InitializeComponent(); + } + } +} diff --git a/examples/csharp/GennyMaui/GennyMaui/AppShellMobile.xaml b/examples/csharp/GennyMaui/GennyMaui/AppShellMobile.xaml new file mode 100644 index 000000000..12b89dc03 --- /dev/null +++ b/examples/csharp/GennyMaui/GennyMaui/AppShellMobile.xaml @@ -0,0 +1,11 @@ + + + + + diff --git a/examples/csharp/GennyMaui/GennyMaui/AppShellMobile.xaml.cs b/examples/csharp/GennyMaui/GennyMaui/AppShellMobile.xaml.cs new file mode 100644 index 000000000..37e754562 --- /dev/null +++ b/examples/csharp/GennyMaui/GennyMaui/AppShellMobile.xaml.cs @@ -0,0 +1,10 @@ +namespace GennyMaui +{ + public partial class AppShellMobile : Shell + { + public AppShellMobile() + { + InitializeComponent(); + } + } +} diff --git a/examples/csharp/GennyMaui/GennyMaui/GennyMaui.csproj b/examples/csharp/GennyMaui/GennyMaui/GennyMaui.csproj new file mode 100644 index 000000000..74d7b8feb --- /dev/null +++ b/examples/csharp/GennyMaui/GennyMaui/GennyMaui.csproj @@ -0,0 +1,96 @@ + + + + net8.0-android;net8.0-ios;net8.0-maccatalyst + $(TargetFrameworks);net8.0-windows10.0.19041.0 + + + + + + + Exe + GennyMaui + true + true + enable + enable + + + GennyMaui + + + com.companyname.gennymaui + + + 1.0 + 1 + + 11.0 + 13.1 + 21.0 + 10.0.17763.0 + 10.0.17763.0 + 6.5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AppShellMobile.xaml + + + + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + + diff --git a/examples/csharp/GennyMaui/GennyMaui/GennyMaui.csproj.user b/examples/csharp/GennyMaui/GennyMaui/GennyMaui.csproj.user new file mode 100644 index 000000000..6fd5f18a9 --- /dev/null +++ b/examples/csharp/GennyMaui/GennyMaui/GennyMaui.csproj.user @@ -0,0 +1,50 @@ + + + + False + net8.0-windows10.0.19041.0 + Windows Machine + PhysicalDevice + Windows Subsystem for Android + + + ProjectDebugger + + + + Designer + + + Designer + + + Designer + + + Designer + + + Designer + + + + + Designer + + + Designer + + + Designer + + + Designer + + + Designer + + + Designer + + + \ No newline at end of file diff --git a/examples/csharp/GennyMaui/GennyMaui/MauiProgram.cs b/examples/csharp/GennyMaui/GennyMaui/MauiProgram.cs new file mode 100644 index 000000000..47605139e --- /dev/null +++ b/examples/csharp/GennyMaui/GennyMaui/MauiProgram.cs @@ -0,0 +1,27 @@ +using Microsoft.Extensions.Logging; +using CommunityToolkit.Maui; + +namespace GennyMaui +{ + public static class MauiProgram + { + public static MauiApp CreateMauiApp() + { + var builder = MauiApp.CreateBuilder(); + builder + .UseMauiApp() + .UseMauiCommunityToolkit() + .ConfigureFonts(fonts => + { + fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); + fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold"); + }); + +#if DEBUG + builder.Logging.AddDebug(); +#endif + + return builder.Build(); + } + } +} diff --git a/examples/csharp/GennyMaui/GennyMaui/Models/ConfigurationModel.cs b/examples/csharp/GennyMaui/GennyMaui/Models/ConfigurationModel.cs new file mode 100644 index 000000000..0c90840a7 --- /dev/null +++ b/examples/csharp/GennyMaui/GennyMaui/Models/ConfigurationModel.cs @@ -0,0 +1,14 @@ +using System.Text.Json.Serialization; +using GennyMaui.ViewModels; + +namespace GennyMaui.Models +{ + public class ConfigurationModel + { + [JsonPropertyName("model")] + public ModelOptionsModel ModelOptions { get; set; } + + [JsonPropertyName("search")] + public SearchOptionsModel SearchOptions { get; set; } + } +} diff --git a/examples/csharp/GennyMaui/GennyMaui/Models/ModelOptionsModel.cs b/examples/csharp/GennyMaui/GennyMaui/Models/ModelOptionsModel.cs new file mode 100644 index 000000000..be217e88a --- /dev/null +++ b/examples/csharp/GennyMaui/GennyMaui/Models/ModelOptionsModel.cs @@ -0,0 +1,14 @@ + +using System.Text.Json.Serialization; + +namespace GennyMaui.Models +{ + public class ModelOptionsModel + { + [JsonPropertyName("type")] + public string Type { get; set; } + + [JsonPropertyName("context_length")] + public int ContextLength { get; set; } + } +} diff --git a/examples/csharp/GennyMaui/GennyMaui/Models/TokenModel.cs b/examples/csharp/GennyMaui/GennyMaui/Models/TokenModel.cs new file mode 100644 index 000000000..f83dbe89d --- /dev/null +++ b/examples/csharp/GennyMaui/GennyMaui/Models/TokenModel.cs @@ -0,0 +1,5 @@ + +namespace GennyMaui.Models +{ + public record TokenModel(int Id, string Content); +} diff --git a/examples/csharp/GennyMaui/GennyMaui/Pages/AppMainPage.xaml b/examples/csharp/GennyMaui/GennyMaui/Pages/AppMainPage.xaml new file mode 100644 index 000000000..c519e4e56 --- /dev/null +++ b/examples/csharp/GennyMaui/GennyMaui/Pages/AppMainPage.xaml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/examples/csharp/GennyMaui/GennyMaui/Pages/AppMainPage.xaml.cs b/examples/csharp/GennyMaui/GennyMaui/Pages/AppMainPage.xaml.cs new file mode 100644 index 000000000..6f8462e0d --- /dev/null +++ b/examples/csharp/GennyMaui/GennyMaui/Pages/AppMainPage.xaml.cs @@ -0,0 +1,9 @@ +namespace GennyMaui.Pages; + +public partial class AppMainPage : ContentPage +{ + public AppMainPage() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/examples/csharp/GennyMaui/GennyMaui/Pages/Views/ModelConfigView.xaml b/examples/csharp/GennyMaui/GennyMaui/Pages/Views/ModelConfigView.xaml new file mode 100644 index 000000000..e8a1cf2f7 --- /dev/null +++ b/examples/csharp/GennyMaui/GennyMaui/Pages/Views/ModelConfigView.xaml @@ -0,0 +1,29 @@ + + + + + + + + + + +