LLamaSharp/LLama.SemanticKernel
xbotter 40ac944fb5
Bump sk to 1.0.1
2023-12-19 08:42:01 +08:00
..
ChatCompletion bump sk-1.0.0-rc4 2023-12-14 09:47:32 +08:00
TextCompletion bump sk-1.0.0-rc4 2023-12-14 09:47:32 +08:00
TextEmbedding bump sk-1.0.0-rc4 2023-12-14 09:47:32 +08:00
ExtensionMethods.cs bump sk-1.0.0-rc4 2023-12-14 09:47:32 +08:00
LLamaSharp.SemanticKernel.csproj Bump sk to 1.0.1 2023-12-19 08:42:01 +08:00
README.md Bump example, readme 2023-09-02 14:21:02 +09:00

README.md

LLamaSharp.SemanticKernel

LLamaSharp.SemanticKernel are connections for SemanticKernel: an SDK for intergrating various LLM interfaces into a single implementation. With this, you can add local LLaMa queries as another connection point with your existing connections.

For reference on how to implement it, view the following examples:

ITextCompletion

using var model = LLamaWeights.LoadFromFile(parameters);
// LLamaSharpTextCompletion can accept ILLamaExecutor. 
var ex = new StatelessExecutor(model, parameters);
var builder = new KernelBuilder();
builder.WithAIService<ITextCompletion>("local-llama", new LLamaSharpTextCompletion(ex), true);

IChatCompletion

using var model = LLamaWeights.LoadFromFile(parameters);
using var context = model.CreateContext(parameters);
// LLamaSharpChatCompletion requires InteractiveExecutor, as it's the best fit for the given command.
var ex = new InteractiveExecutor(context);
var chatGPT = new LLamaSharpChatCompletion(ex);

ITextEmbeddingGeneration

using var model = LLamaWeights.LoadFromFile(parameters);
var embedding = new LLamaEmbedder(model, parameters);
var kernelWithCustomDb = Kernel.Builder
    .WithLoggerFactory(ConsoleLogger.LoggerFactory)
    .WithAIService<ITextEmbeddingGeneration>("local-llama-embed", new LLamaSharpEmbeddingGeneration(embedding), true)
    .WithMemoryStorage(new VolatileMemoryStore())
    .Build();