Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introducing Genny MAUI #870

Draft
wants to merge 35 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
e62c66c
Init
skyline75489 Aug 28, 2024
55dc232
Update
skyline75489 Aug 29, 2024
2e8a54a
Update
skyline75489 Aug 29, 2024
de6c1f2
entitlement
skyline75489 Aug 29, 2024
2662c86
exception
skyline75489 Aug 29, 2024
64fac8a
toast
skyline75489 Aug 29, 2024
7190568
Revert "toast"
skyline75489 Aug 29, 2024
d17dd6c
download HF model
skyline75489 Aug 29, 2024
0196314
Improve
skyline75489 Aug 29, 2024
d3c1114
Improve
skyline75489 Aug 29, 2024
b28dd71
Include
skyline75489 Aug 29, 2024
aedb874
Update
skyline75489 Aug 29, 2024
f6ecdc0
Improve
skyline75489 Aug 29, 2024
9cd3fac
Fix
skyline75489 Aug 30, 2024
ffecdd4
Subpath
skyline75489 Aug 30, 2024
d3dec33
refine
skyline75489 Aug 30, 2024
e0a0d88
longPathAware
skyline75489 Aug 30, 2024
b8636d1
Rename
skyline75489 Aug 30, 2024
73d092d
tokenize
skyline75489 Aug 30, 2024
e4cf894
model download error
skyline75489 Aug 30, 2024
762d59f
refine
skyline75489 Aug 30, 2024
4604cd9
layout
skyline75489 Aug 30, 2024
f4ebf38
border
skyline75489 Aug 30, 2024
bcdeebd
layout
skyline75489 Aug 30, 2024
88dcab5
Show ORT info
skyline75489 Aug 30, 2024
deef0a8
Update
skyline75489 Sep 2, 2024
2df6568
Rm
skyline75489 Sep 2, 2024
5b9184c
csproj
skyline75489 Sep 2, 2024
3f0c5fe
Merge branch 'main' into jialli/genny-maui
skyline75489 Sep 2, 2024
63a474b
Merge branch 'main' into jialli/genny-maui
skyline75489 Sep 24, 2024
1fd10b8
typo
skyline75489 Sep 24, 2024
4ae72cf
Fix on android
skyline75489 Sep 24, 2024
9e561e0
[skip] Fix
skyline75489 Nov 14, 2024
d374090
Merge branch 'main' into jialli/genny-maui
skyline75489 Nov 14, 2024
133297e
Merge branch 'main' into jialli/genny-maui
skyline75489 Dec 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions examples/csharp/GennyMaui/GennyMaui.sln
Original file line number Diff line number Diff line change
@@ -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("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "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
19 changes: 19 additions & 0 deletions examples/csharp/GennyMaui/GennyMaui/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version = "1.0" encoding = "UTF-8" ?>
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:GennyMaui"
x:Class="GennyMaui.App">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
<ResourceDictionary xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
<x:String x:Key="ImageAvatarUser">user.png</x:String>
<x:String x:Key="ImageAvatarRobot">robot.png</x:String>
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
19 changes: 19 additions & 0 deletions examples/csharp/GennyMaui/GennyMaui/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
}
14 changes: 14 additions & 0 deletions examples/csharp/GennyMaui/GennyMaui/AppShell.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Shell
x:Class="GennyMaui.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:pages="clr-namespace:GennyMaui.Pages"
Shell.FlyoutBehavior="Disabled"
Title="GennyMaui">

<ShellContent
Title="Genny"
ContentTemplate="{DataTemplate pages:AppMainPage}"
Route="AppMainPage" />
</Shell>
10 changes: 10 additions & 0 deletions examples/csharp/GennyMaui/GennyMaui/AppShell.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace GennyMaui
{
public partial class AppShell : Shell
{
public AppShell()
{
InitializeComponent();
}
}
}
23 changes: 23 additions & 0 deletions examples/csharp/GennyMaui/GennyMaui/AppShellMobile.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Shell
x:Class="GennyMaui.AppShellMobile"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:pages="clr-namespace:GennyMaui.Pages"
Title="GennyMaui">

<ShellContent
Title="Model Config"
ContentTemplate="{DataTemplate pages:AppMainPageMobile}"
Route="main" />

<ShellContent
Title="Chat"
ContentTemplate="{DataTemplate pages:ChatPageMobile}"
Route="chat" />

<ShellContent
Title="Tokenize"
ContentTemplate="{DataTemplate pages:TokenizePageMobile}"
Route="tokenize" />
</Shell>
10 changes: 10 additions & 0 deletions examples/csharp/GennyMaui/GennyMaui/AppShellMobile.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace GennyMaui
{
public partial class AppShellMobile : Shell
{
public AppShellMobile()
{
InitializeComponent();
}
}
}
116 changes: 116 additions & 0 deletions examples/csharp/GennyMaui/GennyMaui/GennyMaui.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0-ios;net8.0-maccatalyst;net8.0-android34.0</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net8.0-tizen</TargetFrameworks> -->

<!-- Note for MacCatalyst:
The default runtime is maccatalyst-x64, except in Release config, in which case the default is maccatalyst-x64;maccatalyst-arm64.
When specifying both architectures, use the plural <RuntimeIdentifiers> instead of the singular <RuntimeIdentifier>.
The Mac App Store will NOT accept apps with ONLY maccatalyst-arm64 indicated;
either BOTH runtimes must be indicated or ONLY macatalyst-x64. -->
<!-- For example: <RuntimeIdentifiers>maccatalyst-x64;maccatalyst-arm64</RuntimeIdentifiers> -->

<OutputType>Exe</OutputType>
<RootNamespace>GennyMaui</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<!-- Display name -->
<ApplicationTitle>GennyMaui</ApplicationTitle>

<!-- App Identifier -->
<ApplicationId>com.microsoft.onnxruntimegenai.gennymaui</ApplicationId>

<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>

<WindowsSdkPackageVersion>10.0.19041.39</WindowsSdkPackageVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">29.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
</PropertyGroup>

<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />

<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />

<!-- Images -->
<MauiImage Include="Resources\Images\*" />
<MauiImage Update="Resources\Images\dotnet_bot.png" Resize="True" BaseSize="300,185" />

<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*" />

<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>

<ItemGroup>
<MauiXaml Remove="Resources\Images\Images.xaml" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.Maui" Version="9.0.3" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.3.0" />
<PackageReference Include="HuggingfaceHub" Version="0.1.3" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.80" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.80" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
<PackageReference Include="Microsoft.ML.OnnxRuntimeGenAI" Version="0.4.0" />
<PackageReference Include="Microsoft.ML.OnnxRuntime.Extensions" Version="0.12.0" />
</ItemGroup>

<ItemGroup>
<Compile Update="AppShellMobile.xaml.cs">
<DependentUpon>AppShellMobile.xaml</DependentUpon>
</Compile>
<Compile Update="Pages\Views\ChatView.xaml.cs">
<DependentUpon>ChatView.xaml</DependentUpon>
</Compile>
</ItemGroup>

<ItemGroup>
<MauiXaml Update="AppShellMobile.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Pages\AppMainPage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Pages\AppMainPageMobile.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Pages\ChatPageMobile.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Pages\TokenizePageMobile.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Pages\Views\ModelConfigView.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Pages\Views\SearchOptionView.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Pages\Views\ChatView.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Pages\Views\TokenizeLandscapeView.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Pages\Views\TokenizeView.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
</ItemGroup>

</Project>
39 changes: 39 additions & 0 deletions examples/csharp/GennyMaui/GennyMaui/MauiProgram.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Microsoft.Extensions.Logging;
using CommunityToolkit.Maui;
using GennyMaui.Services;
using GennyMaui.ViewModels;

namespace GennyMaui
{
public static class MauiProgram
{
static IServiceProvider _serviceProvider;

public static TService GetService<TService>()
=> _serviceProvider.GetService<TService>();

public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UseMauiCommunityToolkit()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});

#if DEBUG
builder.Logging.AddDebug();
#endif

builder.Services.AddSingleton<IModelProvider>(new LoadableModel());

var app = builder.Build();
_serviceProvider = app.Services;

return app;
}
}
}
14 changes: 14 additions & 0 deletions examples/csharp/GennyMaui/GennyMaui/Models/ConfigurationModel.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
}
49 changes: 49 additions & 0 deletions examples/csharp/GennyMaui/GennyMaui/Models/HuggingFaceModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;

namespace GennyMaui.Models
{
[ObservableObject]
public partial class HuggingFaceModel
{
[ObservableProperty]
private bool isChecked = false;

[ObservableProperty]
private string statusString = string.Empty;

[ObservableProperty]
private bool _isDownloading = false;

public string RepoId { get; set; }

public string Subpath { get; set; }

public string Include => $"{Subpath}/*";

public string DownloadPath
{
get {
var mainDir = FileSystem.Current.AppDataDirectory;
return Path.GetFullPath(Path.Combine(mainDir, RepoId));
}
}

public string ModelPath {
get
{
var mainDir = FileSystem.Current.AppDataDirectory;
if (string.IsNullOrWhiteSpace(Subpath))
{
return Path.GetFullPath(Path.Combine(mainDir, RepoId));
}
else
{
return Path.GetFullPath(Path.Combine(mainDir, RepoId, Subpath));
}
}
}

public bool Exists => Path.Exists(ModelPath);
}
}
14 changes: 14 additions & 0 deletions examples/csharp/GennyMaui/GennyMaui/Models/ModelOptionsModel.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
}
5 changes: 5 additions & 0 deletions examples/csharp/GennyMaui/GennyMaui/Models/TokenModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

namespace GennyMaui.Models
{
public record TokenModel(int Id, string Content);
}
22 changes: 22 additions & 0 deletions examples/csharp/GennyMaui/GennyMaui/Pages/AppMainPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="GennyMaui.Pages.AppMainPage"
xmlns:views="clr-namespace:GennyMaui.Pages.Views"
Title="OnnxRuntime GenAI">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="2*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<views:ModelConfigView Grid.Column="0"></views:ModelConfigView>
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="2*" />
</Grid.RowDefinitions>
<views:TokenizeLandscapeView Grid.Row="0" />
<views:ChatView Grid.Row="1" />
</Grid>
</Grid>
</ContentPage>
Loading
Loading