Skip to content

Embeding LLamaSharp inside .NET MAUI Android App #954

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

Open
Karimiprogramer opened this issue Oct 17, 2024 · 13 comments
Open

Embeding LLamaSharp inside .NET MAUI Android App #954

Karimiprogramer opened this issue Oct 17, 2024 · 13 comments

Comments

@Karimiprogramer
Copy link

Description

I am a .NET MAUI develpoer and I am interested in embeding a LLM inside my application with LLamaSharp. After build llama.cpp with ndk , How can I embed libraries on my application??

@Karimiprogramer Karimiprogramer changed the title Embeding LLamaSharp inside .NET MAUI App Embeding LLamaSharp inside .NET MAUI Android App Oct 17, 2024
@andersonvieiragomeslopes

Description

I am a .NET MAUI develpoer and I am interested in embeding a LLM inside my application with LLamaSharp. After build llama.cpp with ndk , How can I embed libraries on my application??

I'm also interested, did you manage to use it?

@Karimiprogramer
Copy link
Author

After solving some problems with embeding model inside app , I will publish it into my github.

@Darlanio
Copy link

Looking forward to your solution to this problem. I am not sure if llamasharp would work out of the box on android/ios, but maybe it is possible to compile llama.cpp for the specified platform?

At least llama.cpp runs under Termux on Android...

I will keep an eye on your repository:
https://github.com/Karimiprogramer/Sigma

@Darlanio
Copy link

Tested on 0.19 without compiling the binaries myself and got the exception System.PlatformNotSupportedException: 'Operation is not supported on this platform.' on the ModelParams constructor.

@Darlanio
Copy link

Looking foward to Android supported nuget libraries.

@homerokzam
Copy link

Is there a solution for iOS?

@andersonvieiragomeslopes
Copy link

andersonvieiragomeslopes commented Feb 1, 2025

"Hey @AmSmart, could you join this discussion here? I saw that you had success with this Maui Android Backend Support."

@AmSmart
Copy link
Contributor

AmSmart commented Feb 1, 2025

Yeah, I have a PR that brings Android support for this library. Just that I haven't had enough time to write the tests and all. I'll open my PR this weekend and see if it's good enough to get merged. Also planning an IOS update in the future.

@amirvenus
Copy link

Yeah, I have a PR that brings Android support for this library. Just that I haven't had enough time to write the tests and all. I'll open my PR this weekend and see if it's good enough to get merged. Also planning an IOS update in the future.

Any updates on this, @AmSmart ?

This will be a really cool feature!

@Karimiprogramer
Copy link
Author

I have successfully built CPU-based versions of libllama and libgguf for Android and imported them into my .NET MAUI application. However, I am facing some challenges in utilizing these libraries effectively within my app.

I would greatly appreciate any guidance or support you can provide to help me overcome these issues. Thank you!

@martindevans
Copy link
Member

One thing to check - did you build exactly the llama.cpp version listed in the table at the bottom of the readme? Each version of LLamaSharp is only compatible with one specific version of llama.cpp!

@Darlanio
Copy link

I wish I had time to check this now, but will have to wait until I have time in April.

@AmSmart
Copy link
Contributor

AmSmart commented Mar 20, 2025

Update: The extra demand here gave me the motivation to complete my PR #1130 introducing Android support. Will still require a bit of back and forth but I hope it can get merged soon enough.

I've built this nupkgs off my PR so anyone blocked can use them to experiment temporarily. Reiterating that these are not official packages from the repo so it is definitely worth waiting for the next release with official Android support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants