Browse Source

🔧 Update KernelMemory configuration

- Update LLamaSharpTextEmbeddingGeneration and LLamaSharpTextGeneration
- Add Microsoft.KernelMemory.Core package reference
- Update Microsoft.KernelMemory.Abstractions package reference
tags/v0.8.1
xbotter 2 years ago
parent
commit
d1e2a4750b
No known key found for this signature in database GPG Key ID: D299220A7FE5CF1E
4 changed files with 23 additions and 7 deletions
  1. +1
    -1
      LLama.Examples/Examples/KernelMemory.cs
  2. +1
    -0
      LLama.Examples/LLama.Examples.csproj
  3. +20
    -5
      LLama.KernelMemory/BuilderExtensions.cs
  4. +1
    -1
      LLama.KernelMemory/LLamaSharp.KernelMemory.csproj

+ 1
- 1
LLama.Examples/Examples/KernelMemory.cs View File

@@ -30,7 +30,7 @@ namespace LLama.Examples.Examples
MaxTokensPerLine = 100,
OverlappingTokens = 30
})
.BuildServerlessClient();
.Build();

await memory.ImportDocumentAsync(@"./Assets/sample-SK-Readme.pdf", steps: Constants.PipelineWithoutSummary);



+ 1
- 0
LLama.Examples/LLama.Examples.csproj View File

@@ -29,6 +29,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<PackageReference Include="Microsoft.KernelMemory.Core" Version="0.12.231123.1-preview" />
<PackageReference Include="Microsoft.SemanticKernel" Version="1.0.0-beta8" />
<PackageReference Include="Spectre.Console" Version="0.47.0" />
</ItemGroup>


+ 20
- 5
LLama.KernelMemory/BuilderExtensions.cs View File

@@ -7,6 +7,7 @@ using System.Threading.Tasks;
using LLama;
using LLama.Common;
using Microsoft.KernelMemory.AI;
using Microsoft.SemanticKernel.AI.Embeddings;

namespace LLamaSharp.KernelMemory
{
@@ -15,13 +16,27 @@ namespace LLamaSharp.KernelMemory
/// </summary>
public static class BuilderExtensions
{

private static IKernelMemoryBuilder WithCustomEmbeddingGeneration(this IKernelMemoryBuilder builder, ITextEmbeddingGeneration embeddingGeneration)
{
builder.AddSingleton<ITextEmbeddingGeneration>(embeddingGeneration);
builder.AddIngestionEmbeddingGenerator(embeddingGeneration);
return builder;
}

private static IKernelMemoryBuilder WithCustomTextGeneration(this IKernelMemoryBuilder builder, ITextGeneration textGeneration)
{
builder.AddSingleton<ITextGeneration>(textGeneration);
return builder;
}

/// <summary>
/// Adds LLamaSharpTextEmbeddingGeneration to the KernelMemoryBuilder.
/// </summary>
/// <param name="builder">The KernelMemoryBuilder instance.</param>
/// <param name="config">The LLamaSharpConfig instance.</param>
/// <returns>The KernelMemoryBuilder instance with LLamaSharpTextEmbeddingGeneration added.</returns>
public static KernelMemoryBuilder WithLLamaSharpTextEmbeddingGeneration(this KernelMemoryBuilder builder, LLamaSharpConfig config)
public static IKernelMemoryBuilder WithLLamaSharpTextEmbeddingGeneration(this IKernelMemoryBuilder builder, LLamaSharpConfig config)
{
builder.WithCustomEmbeddingGeneration(new LLamaSharpTextEmbeddingGeneration(config));
return builder;
@@ -33,7 +48,7 @@ namespace LLamaSharp.KernelMemory
/// <param name="builder">The KernelMemoryBuilder instance.</param>
/// <param name="textEmbeddingGeneration">The LLamaSharpTextEmbeddingGeneration instance.</param>
/// <returns>The KernelMemoryBuilder instance with LLamaSharpTextEmbeddingGeneration added.</returns>
public static KernelMemoryBuilder WithLLamaSharpTextEmbeddingGeneration(this KernelMemoryBuilder builder, LLamaSharpTextEmbeddingGeneration textEmbeddingGeneration)
public static IKernelMemoryBuilder WithLLamaSharpTextEmbeddingGeneration(this IKernelMemoryBuilder builder, LLamaSharpTextEmbeddingGeneration textEmbeddingGeneration)
{
builder.WithCustomEmbeddingGeneration(textEmbeddingGeneration);
return builder;
@@ -45,7 +60,7 @@ namespace LLamaSharp.KernelMemory
/// <param name="builder">The KernelMemoryBuilder instance.</param>
/// <param name="config">The LLamaSharpConfig instance.</param>
/// <returns>The KernelMemoryBuilder instance with LLamaSharpTextGeneration added.</returns>
public static KernelMemoryBuilder WithLLamaSharpTextGeneration(this KernelMemoryBuilder builder, LLamaSharpConfig config)
public static IKernelMemoryBuilder WithLLamaSharpTextGeneration(this IKernelMemoryBuilder builder, LLamaSharpConfig config)
{
builder.WithCustomTextGeneration(new LlamaSharpTextGeneration(config));
return builder;
@@ -57,7 +72,7 @@ namespace LLamaSharp.KernelMemory
/// <param name="builder">The KernelMemoryBuilder instance.</param>
/// <param name="textGeneration">The LlamaSharpTextGeneration instance.</param>
/// <returns>The KernelMemoryBuilder instance with LLamaSharpTextGeneration added.</returns>
public static KernelMemoryBuilder WithLLamaSharpTextGeneration(this KernelMemoryBuilder builder, LlamaSharpTextGeneration textGeneration)
public static IKernelMemoryBuilder WithLLamaSharpTextGeneration(this IKernelMemoryBuilder builder, LlamaSharpTextGeneration textGeneration)
{
builder.WithCustomTextGeneration(textGeneration);
return builder;
@@ -69,7 +84,7 @@ namespace LLamaSharp.KernelMemory
/// <param name="builder">The KernelMemoryBuilder instance.</param>
/// <param name="config">The LLamaSharpConfig instance.</param>
/// <returns>The KernelMemoryBuilder instance with LLamaSharpTextEmbeddingGeneration and LLamaSharpTextGeneration added.</returns>
public static KernelMemoryBuilder WithLLamaSharpDefaults(this KernelMemoryBuilder builder, LLamaSharpConfig config)
public static IKernelMemoryBuilder WithLLamaSharpDefaults(this IKernelMemoryBuilder builder, LLamaSharpConfig config)
{
var parameters = new ModelParams(config.ModelPath)
{


+ 1
- 1
LLama.KernelMemory/LLamaSharp.KernelMemory.csproj View File

@@ -29,7 +29,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.KernelMemory.Core" Version="0.10.231116.2-preview" />
<PackageReference Include="Microsoft.KernelMemory.Abstractions" Version="0.12.231123.1-preview" />
</ItemGroup>

<ItemGroup>


Loading…
Cancel
Save