SciSharp / LLamaSharp

A C#/.NET library to run LLM (🦙LLaMA/LLaVA) on your local device efficiently.
https://scisharp.github.io/LLamaSharp
MIT License
2.56k stars 334 forks source link

Semantic Kernel - Home Automation Sample #764

Closed louislewis2 closed 4 months ago

louislewis2 commented 4 months ago

Description

Good day,

I discovered an example on the Semantic Kernel repo. https://github.com/microsoft/semantic-kernel/blob/main/dotnet/samples/Demos/HomeAutomation/Program.cs

I have been trying to work out how using that example, one would implement it using LlamaSharp? I think having an example like that, would help many people.

Is this even possible? I am having issues, where the plugins are not being called, despite how I register them.

Thank you

zsogitbe commented 4 months ago

That example uses the OpenAI feature AutoInvokeKernelFunctions, which is not available in LLamaSharp. AutoInvokeKernelFunctions triggers a mechanism to call kernel plugins/functions "automatically". Where automatically means that the chat model indicates to call a function. For this you need a specialized model.

You can make all of this work without the OpenAI part "manually" as follows, you define the kernel functions and you ask the chat model to indicate the user's intention and then call the Kernel function. This is what is actually happening internally in the OpenAI implementation, so you can do the same.

But, this is all a bit outdated because there is a new way called Handlebars plan calling. You can ask a model to create a plan and then execute the plan which may contain a whole process with several plugins and functions. All of this is state of the art today and relatively complex and you will need some time to understand it...

zsogitbe commented 4 months ago

I have added an example which will make some things more clear: https://github.com/SciSharp/LLamaSharp/pull/769

SignalRT commented 4 months ago

The example is now in the master. Thank you @zsogitbe

louislewis2 commented 4 months ago

@zsogitbe I just would like to thank you for taking the time for the detailed explanation as well as the provided sample. I hope others will find this as useful as I have.