Skip to content

Commit

Permalink
Upgrade dependencies and fix code style (#748)
Browse files Browse the repository at this point in the history
  • Loading branch information
dluc authored Aug 21, 2024
1 parent 9b63662 commit f349132
Show file tree
Hide file tree
Showing 31 changed files with 76 additions and 52 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project>
<PropertyGroup>
<!-- Central version prefix - applies to all nuget packages. -->
<Version>0.70.0</Version>
<Version>0.71.0</Version>

<!-- C# lang version, https://learn.microsoft.com/dotnet/csharp/whats-new -->
<LangVersion>12</LangVersion>
Expand Down
42 changes: 21 additions & 21 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Aspire.Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.2" />
<PackageVersion Include="AWSSDK.S3" Version="3.7.310.4" />
<PackageVersion Include="Aspire.Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.1.0" />
<PackageVersion Include="AWSSDK.S3" Version="3.7.402" />
<PackageVersion Include="Azure.AI.FormRecognizer" Version="4.1.0" />
<PackageVersion Include="Azure.Extensions.AspNetCore.Configuration.Secrets" Version="1.3.1" />
<PackageVersion Include="Azure.Extensions.AspNetCore.Configuration.Secrets" Version="1.3.2" />
<PackageVersion Include="Azure.Identity" Version="1.12.0" />
<PackageVersion Include="Azure.Search.Documents" Version="11.5.1" />
<PackageVersion Include="Azure.Storage.Blobs" Version="12.20.0" />
<PackageVersion Include="Azure.Storage.Queues" Version="12.18.0" />
<PackageVersion Include="Azure.Search.Documents" Version="11.6.0" />
<PackageVersion Include="Azure.Storage.Blobs" Version="12.21.2" />
<PackageVersion Include="Azure.Storage.Queues" Version="12.19.1" />
<PackageVersion Include="Elastic.Clients.Elasticsearch" Version="8.11.0" />
<PackageVersion Include="Discord.Net" Version="3.15.2" />
<PackageVersion Include="HtmlAgilityPack" Version="1.11.61" />
<PackageVersion Include="LLamaSharp" Version="0.13.0" />
<PackageVersion Include="LLamaSharp.Backend.Cpu" Version="0.13.0" />
<PackageVersion Include="Discord.Net" Version="3.15.3" />
<PackageVersion Include="HtmlAgilityPack" Version="1.11.64" />
<PackageVersion Include="LLamaSharp" Version="0.15.0" />
<PackageVersion Include="LLamaSharp.Backend.Cpu" Version="0.15.0" />
<PackageVersion Include="LLamaSharp.Backend.Cuda11" Version="0.12.0" />
<PackageVersion Include="LLamaSharp.Backend.Cuda12" Version="0.12.0" />
<PackageVersion Include="LLamaSharp.Backend.OpenCL" Version="0.12.0" />
<PackageVersion Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.22.0" />
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
<PackageVersion Include="Microsoft.Data.SqlClient" Version="5.2.1" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.AzureAppConfiguration" Version="7.2.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.AzureAppConfiguration" Version="7.3.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" />
Expand All @@ -34,9 +34,9 @@
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.Logging.TraceSource" Version="8.0.0" />
<PackageVersion Include="Microsoft.ML.Tokenizers" Version="0.22.0-preview.24271.1" />
<PackageVersion Include="Microsoft.KernelMemory.Core" Version="0.66.240709.1" />
<PackageVersion Include="Microsoft.KernelMemory.Service.AspNetCore" Version="0.66.240709.1" />
<PackageVersion Include="MongoDB.Driver.GridFS" Version="2.27.0" />
<PackageVersion Include="Microsoft.KernelMemory.Core" Version="0.70.240803.1" />
<PackageVersion Include="Microsoft.KernelMemory.Service.AspNetCore" Version="0.70.240803.1" />
<PackageVersion Include="MongoDB.Driver.GridFS" Version="2.28.0" />
<PackageVersion Include="Moq" Version="4.20.70" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="PdfPig" Version="0.1.8" />
Expand All @@ -45,7 +45,7 @@
<PackageVersion Include="RabbitMQ.Client" Version="6.8.1" />
<PackageVersion Include="NRedisStack" Version="0.12.0" />
<PackageVersion Include="ReadLine" Version="2.0.1" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.6.2" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.7.1" />
<PackageVersion Include="System.Linq.Async" Version="6.0.1" />
<PackageVersion Include="System.Memory.Data" Version="8.0.0" />
<PackageVersion Include="System.Numerics.Tensors" Version="8.0.0" />
Expand All @@ -60,9 +60,9 @@
</ItemGroup>
<!-- Semantic Kernel -->
<ItemGroup>
<PackageVersion Include="Microsoft.SemanticKernel" Version="1.15.1" />
<PackageVersion Include="Microsoft.SemanticKernel.Abstractions" Version="1.15.1" />
<PackageVersion Include="Microsoft.SemanticKernel.Connectors.OpenAI" Version="1.15.1" />
<PackageVersion Include="Microsoft.SemanticKernel" Version="1.17.1" />
<PackageVersion Include="Microsoft.SemanticKernel.Abstractions" Version="1.17.1" />
<PackageVersion Include="Microsoft.SemanticKernel.Connectors.OpenAI" Version="1.17.1" />
</ItemGroup>
<!-- Documentation -->
<ItemGroup>
Expand All @@ -71,12 +71,12 @@
<!-- Code Analysis -->
<ItemGroup>
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="4.10.0">
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="4.11.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageVersion>
<PackageVersion Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0" />
<PackageVersion Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.10.48">
<PackageVersion Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.11.20">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageVersion>
Expand All @@ -95,7 +95,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageVersion>
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
<PackageVersion Include="xunit" Version="2.9.0" />
<PackageVersion Include="xunit.abstractions" Version="2.0.3" />
<PackageVersion Include="xunit.extensibility.core" Version="2.7.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Connectors.OpenAI;

#pragma warning disable IDE0130 // reduce number of "using" statements
// ReSharper disable CheckNamespace
namespace Microsoft.KernelMemory.Evaluators.AnswerCorrectness;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

using System.Collections.Generic;

#pragma warning disable IDE0130 // reduce number of "using" statements
// ReSharper disable InconsistentNaming
// ReSharper disable CheckNamespace
namespace Microsoft.KernelMemory.Evaluators.AnswerCorrectness;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.

#pragma warning disable IDE0130 // reduce number of "using" statements
// ReSharper disable CheckNamespace

namespace Microsoft.KernelMemory.Evaluators.AnswerCorrectness;

#pragma warning disable CA1812 // 'StatementEvaluation' is an internal class that is apparently never instantiated. If so, remove the code from the assembly. If this class is intended to contain only static members, make it 'static' (Module in Visual Basic). (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1812)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Embeddings;

#pragma warning disable IDE0130 // reduce number of "using" statements
// ReSharper disable CheckNamespace
namespace Microsoft.KernelMemory.Evaluators.AnswerSimilarity;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Connectors.OpenAI;

#pragma warning disable IDE0130 // reduce number of "using" statements
// ReSharper disable CheckNamespace
namespace Microsoft.KernelMemory.Evaluators.ContextRecall;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.

#pragma warning disable IDE0130 // reduce number of "using" statements
// ReSharper disable CheckNamespace

namespace Microsoft.KernelMemory.Evaluators.ContextRecall;

#pragma warning disable CA1812 // 'GroundTruthClassification' is an internal class that is apparently never instantiated. If so, remove the code from the assembly. If this class is intended to contain only static members, make it 'static' (Module in Visual Basic). (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1812)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.

#pragma warning disable IDE0130 // reduce number of "using" statements
// ReSharper disable CheckNamespace

namespace Microsoft.KernelMemory.Evaluators.ContextRelevancy;

#pragma warning disable CA1812 // 'ContextRelevancy' is an internal class that is apparently never instantiated. If so, remove the code from the assembly. If this class is intended to contain only static members, make it 'static' (Module in Visual Basic). (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1812)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Connectors.OpenAI;

#pragma warning disable IDE0130 // reduce number of "using" statements
// ReSharper disable CheckNamespace
namespace Microsoft.KernelMemory.Evaluators.ContextRelevancy;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Connectors.OpenAI;

#pragma warning disable IDE0130 // reduce number of "using" statements
// ReSharper disable CheckNamespace
namespace Microsoft.KernelMemory.Evaluators.Faithfulness;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.

#pragma warning disable IDE0130 // reduce number of "using" statements
// ReSharper disable CheckNamespace

namespace Microsoft.KernelMemory.Evaluators.Faithfulness;

#pragma warning disable CA1812 // 'StatementEvaluation' is an internal class that is apparently never instantiated. If so, remove the code from the assembly. If this class is intended to contain only static members, make it 'static' (Module in Visual Basic). (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1812)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.

#pragma warning disable IDE0130 // reduce number of "using" statements
// ReSharper disable CheckNamespace

namespace Microsoft.KernelMemory.Evaluators.Relevance;

#pragma warning disable CA1812 // 'RelevanceEvaluation' is an internal class that is apparently never instantiated. If so, remove the code from the assembly. If this class is intended to contain only static members, make it 'static' (Module in Visual Basic). (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1812)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Microsoft.SemanticKernel.Connectors.OpenAI;
using Microsoft.SemanticKernel.Embeddings;

#pragma warning disable IDE0130 // reduce number of "using" statements
// ReSharper disable CheckNamespace
namespace Microsoft.KernelMemory.Evaluators.Relevance;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public DataStorageTests(
}

[Fact]
[Trait("Category", "Elasticsearch")]
public async Task CanUpsertOneTextDocumentAndDeleteAsync()
{
// We upsert the file
Expand Down Expand Up @@ -54,6 +55,7 @@ await this.MemoryDb.DeleteAsync(nameof(this.CanUpsertOneTextDocumentAndDeleteAsy
}

[Fact]
[Trait("Category", "Elasticsearch")]
public async Task CanUpsertTwoTextFilesAndGetSimilarListAsync()
{
await UpsertTextFilesAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public IndexManagementTests(
}

[Fact]
[Trait("Category", "Elasticsearch")]
public async Task CanCreateAndDeleteIndexAsync()
{
var indexName = nameof(this.CanCreateAndDeleteIndexAsync);
Expand Down Expand Up @@ -44,6 +45,7 @@ await this.MemoryDb.DeleteIndexAsync(indexName)
}

[Fact]
[Trait("Category", "Elasticsearch")]
public async Task CanGetIndicesAsync()
{
var indexNames = new[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public IndexNameTests(IConfiguration cfg, ITestOutputHelper output)
}

[Theory]
[Trait("Category", "Elasticsearch")]
[InlineData("")] // default index
[InlineData("nondefault")]
[InlineData("WithUppercase")]
Expand All @@ -33,6 +34,7 @@ public void GoodIndexNamesAreAccepted(string indexName)
}

[Theory]
[Trait("Category", "Elasticsearch")]
// An index name cannot start with a hyphen (-) or underscore (_).
//[InlineData("-test", 1)]
//[InlineData("test_", 1)]
Expand Down Expand Up @@ -75,6 +77,7 @@ public void BadIndexNamesAreRejected(string indexName, int errorCount)
}

[Fact]
[Trait("Category", "Elasticsearch")]
public void IndexNameCannotBeLongerThan255Bytes()
{
var indexName = new string('a', 256);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public KernelMemoryTests(IConfiguration cfg, ITestOutputHelper output)
public IKernelMemory KernelMemory { get; }

[Fact]
[Trait("Category", "Elasticsearch")]
[SuppressMessage("Reliability", "CA2007:Consider calling ConfigureAwait on the awaited task", Justification = "<Pending>")]
public async Task ItSupportsMultipleFiltersAsync()
{
Expand Down Expand Up @@ -105,6 +106,7 @@ await this.KernelMemory.ImportDocumentAsync(
}

[Fact]
[Trait("Category", "Elasticsearch")]
public async Task ItSupportsTagsAsync()
{
// This is an adaptation of the same test in Elasticsearch.FunctionalTests
Expand Down Expand Up @@ -172,6 +174,7 @@ await this.KernelMemory.ImportDocumentAsync(
}

[Fact]
[Trait("Category", "Elasticsearch")]
public async Task ItSupportsASingleFilterAsync()
{
// This is an adaptation of the same test in Elasticsearch.FunctionalTests
Expand Down Expand Up @@ -238,6 +241,7 @@ await this.KernelMemory.ImportDocumentAsync(
}

[Fact]
[Trait("Category", "Elasticsearch")]
public async Task CanImportOneDocumentAndAskAsync()
{
var indexName = nameof(this.CanImportOneDocumentAndAskAsync);
Expand Down Expand Up @@ -267,6 +271,7 @@ public async Task CanImportOneDocumentAndAskAsync()
}

[Fact]
[Trait("Category", "Elasticsearch")]
public async Task CanImportTwoDocumentsAndAskAsync()
{
var indexName = nameof(this.CanImportTwoDocumentsAndAskAsync);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public async Task CanGetListWithTagsAsync()
}

[Fact]
[Trait("Category", "Elasticsearch")]
public async Task CanGetListWithEmptyFiltersAsync()
{
await foreach (var result in this.MemoryDb.GetListAsync(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.

#pragma warning disable IDE0130 // reduce number of "using" statements
// ReSharper disable once CheckNamespace - reduce number of "using" statements

namespace Microsoft.KernelMemory.MemoryDb.Elasticsearch;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.

#pragma warning disable IDE0130 // reduce number of "using" statements
// ReSharper disable once CheckNamespace - reduce number of "using" statements

namespace Microsoft.KernelMemory.MemoryDb.Elasticsearch;

/// <summary>
Expand Down
39 changes: 16 additions & 23 deletions extensions/LlamaSharp/LlamaSharp/LlamaSharpTextGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using LLama;
using LLama.Abstractions;
using LLama.Common;
using LLama.Sampling;
using Microsoft.Extensions.Logging;
using Microsoft.KernelMemory.AI.OpenAI;
using Microsoft.KernelMemory.Diagnostics;
Expand Down Expand Up @@ -102,37 +103,29 @@ public IAsyncEnumerable<string> GenerateTextAsync(
CancellationToken cancellationToken = default)
{
var executor = new InteractiveExecutor(this._context);
IInferenceParams settings = new InferenceParams
{
TokensKeep = this.MaxTokenTotal,
MaxTokens = options.MaxTokens ?? -1,
Temperature = (float)options.Temperature,
TopP = (float)options.NucleusSampling,
PresencePenalty = (float)options.PresencePenalty,
FrequencyPenalty = (float)options.FrequencyPenalty,
AntiPrompts = options.StopSequences?.ToList() ?? new(),
LogitBias = new(),
// RepeatLastTokensCount = 0, // [int] last n tokens to penalize (0 = disable penalty, -1 = context size)
// TopK = 0, // [int] The number of highest probability vocabulary tokens to keep for top-k-filtering.
// MinP = 0, // [float]
// TfsZ = 0, // [float]
// TypicalP = 0, // [float]
// RepeatPenalty = 0, // [float]
// MirostatTau = 0, // [float]
// MirostatEta = 0, // [float]
// PenalizeNL = false, // consider newlines as a repeatable token
// Mirostat = MirostatType.Disable, // see https://github.com/basusourya/mirostat
// Grammar = null // SafeLLamaGrammarHandle
};

var samplingPipeline = new DefaultSamplingPipeline();
samplingPipeline.Temperature = (float)options.Temperature;
samplingPipeline.TopP = (float)options.NucleusSampling;
samplingPipeline.AlphaPresence = (float)options.PresencePenalty;
samplingPipeline.AlphaFrequency = (float)options.FrequencyPenalty;

if (options.TokenSelectionBiases is { Count: > 0 })
{
foreach (var (token, bias) in options.TokenSelectionBiases)
{
settings.LogitBias!.Add(token, bias);
samplingPipeline.LogitBias!.Add(token, bias);
}
}

IInferenceParams settings = new InferenceParams
{
TokensKeep = this.MaxTokenTotal,
MaxTokens = options.MaxTokens ?? -1,
AntiPrompts = options.StopSequences?.ToList() ?? new(),
SamplingPipeline = samplingPipeline
};

return executor.InferAsync(prompt, settings, cancellationToken);
}

Expand Down
1 change: 1 addition & 0 deletions extensions/OpenAI/OpenAI/Tokenizers/DefaultGPTTokenizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Collections.Generic;
using Microsoft.ML.Tokenizers;

#pragma warning disable IDE0130 // reduce number of "using" statements
// ReSharper disable once CheckNamespace
namespace Microsoft.KernelMemory.AI.OpenAI;

Expand Down
Loading

0 comments on commit f349132

Please sign in to comment.