From 1840d119def14731fbbb914de0f67d53516c45bc Mon Sep 17 00:00:00 2001 From: Luca Maccarini Date: Sun, 29 Jun 2025 18:30:30 +0200 Subject: [PATCH 1/4] add Llama.mobile code containing a basic chatbot --- .gitignore | 3 +- LLamaSharp.sln | 21 +++ Llama.Mobile/MainPage.xaml | 112 +++++++++++-- Llama.Mobile/MainPage.xaml.cs | 152 +++++++++++++++++- .../Src/ChatMessageTemplateSelector.cs | 16 ++ Llama.Mobile/Src/InverseBooleanConverter.cs | 25 +++ Llama.Mobile/Src/Message.cs | 63 ++++++++ 7 files changed, 377 insertions(+), 15 deletions(-) create mode 100644 Llama.Mobile/Src/ChatMessageTemplateSelector.cs create mode 100644 Llama.Mobile/Src/InverseBooleanConverter.cs create mode 100644 Llama.Mobile/Src/Message.cs diff --git a/.gitignore b/.gitignore index 206b0dac1..ac50b1485 100644 --- a/.gitignore +++ b/.gitignore @@ -351,4 +351,5 @@ site/ **/appsettings.Local.json /LLama/runtimes/deps /LLama/runtimes/deps.zip -/LLama/runtimes/release_id.txt \ No newline at end of file +/LLama/runtimes/release_id.txt +/Llama.Mobile/Resources/Raw/Llama-3.2-1B-Instruct-Q4_0.gguf diff --git a/LLamaSharp.sln b/LLamaSharp.sln index 7c970aa99..e18363591 100644 --- a/LLamaSharp.sln +++ b/LLamaSharp.sln @@ -21,6 +21,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LLama.Experimental", "LLama EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LLama.Benchmark", "LLama.Benchmark\LLama.Benchmark.csproj", "{90D38FEE-68EA-459E-A4EE-268B9DFA1CD5}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Llama.Mobile", "Llama.Mobile\Llama.Mobile.csproj", "{0E058BB0-83C6-4FBE-BC80-E8C5F7E29651}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -196,6 +198,25 @@ Global {90D38FEE-68EA-459E-A4EE-268B9DFA1CD5}.Release|Arm64.Build.0 = Release|Any CPU {90D38FEE-68EA-459E-A4EE-268B9DFA1CD5}.Release|x64.ActiveCfg = Release|Any CPU {90D38FEE-68EA-459E-A4EE-268B9DFA1CD5}.Release|x64.Build.0 = Release|Any CPU + {0E058BB0-83C6-4FBE-BC80-E8C5F7E29651}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0E058BB0-83C6-4FBE-BC80-E8C5F7E29651}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0E058BB0-83C6-4FBE-BC80-E8C5F7E29651}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {0E058BB0-83C6-4FBE-BC80-E8C5F7E29651}.Debug|Arm64.ActiveCfg = Debug|Any CPU + {0E058BB0-83C6-4FBE-BC80-E8C5F7E29651}.Debug|Arm64.Build.0 = Debug|Any CPU + {0E058BB0-83C6-4FBE-BC80-E8C5F7E29651}.Debug|x64.ActiveCfg = Debug|Any CPU + {0E058BB0-83C6-4FBE-BC80-E8C5F7E29651}.Debug|x64.Build.0 = Debug|Any CPU + {0E058BB0-83C6-4FBE-BC80-E8C5F7E29651}.GPU|Any CPU.ActiveCfg = Debug|Any CPU + {0E058BB0-83C6-4FBE-BC80-E8C5F7E29651}.GPU|Any CPU.Build.0 = Debug|Any CPU + {0E058BB0-83C6-4FBE-BC80-E8C5F7E29651}.GPU|Arm64.ActiveCfg = Debug|Any CPU + {0E058BB0-83C6-4FBE-BC80-E8C5F7E29651}.GPU|Arm64.Build.0 = Debug|Any CPU + {0E058BB0-83C6-4FBE-BC80-E8C5F7E29651}.GPU|x64.ActiveCfg = Debug|Any CPU + {0E058BB0-83C6-4FBE-BC80-E8C5F7E29651}.GPU|x64.Build.0 = Debug|Any CPU + {0E058BB0-83C6-4FBE-BC80-E8C5F7E29651}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0E058BB0-83C6-4FBE-BC80-E8C5F7E29651}.Release|Any CPU.Build.0 = Release|Any CPU + {0E058BB0-83C6-4FBE-BC80-E8C5F7E29651}.Release|Arm64.ActiveCfg = Release|Any CPU + {0E058BB0-83C6-4FBE-BC80-E8C5F7E29651}.Release|Arm64.Build.0 = Release|Any CPU + {0E058BB0-83C6-4FBE-BC80-E8C5F7E29651}.Release|x64.ActiveCfg = Release|Any CPU + {0E058BB0-83C6-4FBE-BC80-E8C5F7E29651}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Llama.Mobile/MainPage.xaml b/Llama.Mobile/MainPage.xaml index 5bd8e7e94..31215a8c9 100644 --- a/Llama.Mobile/MainPage.xaml +++ b/Llama.Mobile/MainPage.xaml @@ -1,14 +1,106 @@ - -