Skip to content

Commit a2a47dd

Browse files
authored
Merge branch 'master' into update_apr_2025
2 parents f38b007 + 272027f commit a2a47dd

File tree

16 files changed

+201
-81
lines changed

16 files changed

+201
-81
lines changed

.github/workflows/stale_issues.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Close stale issues
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * *'
6+
7+
jobs:
8+
stale:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/stale@v9
12+
with:
13+
repo-token: ${{ secrets.GITHUB_TOKEN }}
14+
stale-issue-message: 'This issue has been automatically marked as stale due to inactivity. If no further activity occurs, it will be closed in 7 days.'
15+
stale-pr-message: 'This pull request has been automatically marked as stale due to inactivity. If no further activity occurs, it will be closed in 7 days.'
16+
days-before-stale: 60
17+
days-before-close: 7
18+
stale-issue-label: 'stale'
19+
exempt-issue-labels: 'do not close'
20+
operations-per-run: 30

LLama.Examples/Examples/KernelMemory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ and answer questions about them in an interactive chat prompt.
4646

4747
// Ask a predefined question
4848
Console.ForegroundColor = ConsoleColor.Green;
49-
string question1 = "What formats does KM support";
49+
string question1 = "What is Kernel Memory";
5050
Console.WriteLine($"Question: {question1}");
5151
await AnswerQuestion(memory, question1);
5252

LLama.Examples/Examples/KernelMemorySaveAndLoad.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Press ENTER to proceed...
5454
await IngestDocuments(memory);
5555
}
5656

57-
await AskSingleQuestion(memory, "What formats does KM support?");
57+
await AskSingleQuestion(memory, "What is Kernel Memory");
5858
await StartUserChatSession(memory);
5959
}
6060

LLama.Examples/LLama.Examples.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515

1616
<ItemGroup>
1717
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="9.0.3" />
18-
<PackageReference Include="Microsoft.KernelMemory.Core" Version="0.97.250211.1" />
18+
<PackageReference Include="Microsoft.KernelMemory.Core" Version="0.98.250323.1" />
1919
<PackageReference Include="Microsoft.SemanticKernel" Version="1.44.0" />
20-
<PackageReference Include="Microsoft.SemanticKernel.Plugins.Memory" Version="1.6.2-alpha" />
20+
<PackageReference Include="Microsoft.SemanticKernel.Plugins.Memory" Version="1.44.0-alpha" />
2121
<PackageReference Include="NAudio" Version="2.2.1" />
2222
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.7" />
23-
<PackageReference Include="Spectre.Console" Version="0.49.1" />
24-
<PackageReference Include="Spectre.Console.ImageSharp" Version="0.49.1" />
25-
<PackageReference Include="Whisper.net" Version="1.7.4" />
26-
<PackageReference Include="Whisper.net.Runtime" Version="1.7.4" />
23+
<PackageReference Include="Spectre.Console" Version="0.50.0" />
24+
<PackageReference Include="Spectre.Console.ImageSharp" Version="0.50.0" />
25+
<PackageReference Include="Whisper.net" Version="1.8.1" />
26+
<PackageReference Include="Whisper.net.Runtime" Version="1.8.1" />
2727
<PackageReference Include="Whisper.net.Runtime.Clblast" Version="1.5.0" />
2828
<PackageReference Include="Whisper.net.Runtime.CoreML" Version="1.7.4" />
2929
<PackageReference Include="Whisper.net.Runtime.Cublas" Version="1.5.0" />

LLama.KernelMemory/LLamaSharpTextEmbeddingGenerator.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@ public LLamaSharpTextEmbeddingGenerator(LLamaSharpConfig config)
3131

3232
var @params = new ModelParams(config.ModelPath)
3333
{
34-
ContextSize = config.ContextSize,
35-
GpuLayerCount = config.GpuLayerCount ?? 20,
36-
34+
ContextSize = config?.ContextSize ?? 2048,
35+
GpuLayerCount = config?.GpuLayerCount ?? 20,
36+
//Embeddings = true,
37+
MainGpu = config?.MainGpu ?? 0,
38+
SplitMode = config?.SplitMode ?? LLama.Native.GPUSplitMode.None,
3739
PoolingType = LLamaPoolingType.Mean,
3840
};
3941

@@ -54,11 +56,11 @@ public LLamaSharpTextEmbeddingGenerator(LLamaSharpConfig config, LLamaWeights we
5456

5557
var @params = new ModelParams(config.ModelPath)
5658
{
57-
ContextSize = config.ContextSize ?? 2048,
58-
GpuLayerCount = config.GpuLayerCount ?? 20,
59-
Embeddings = true,
60-
MainGpu = config.MainGpu,
61-
SplitMode = config.SplitMode,
59+
ContextSize = config?.ContextSize ?? 2048,
60+
GpuLayerCount = config?.GpuLayerCount ?? 20,
61+
//Embeddings = true,
62+
MainGpu = config?.MainGpu ?? 0,
63+
SplitMode = config?.SplitMode ?? LLama.Native.GPUSplitMode.None,
6264
PoolingType = LLamaPoolingType.Mean,
6365
};
6466
_weights = weights;

LLama.KernelMemory/LlamaSharpTextGenerator.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ public LlamaSharpTextGenerator(LLamaSharpConfig config)
3232
{
3333
var parameters = new ModelParams(config.ModelPath)
3434
{
35-
ContextSize = config.ContextSize ?? 2048,
36-
GpuLayerCount = config.GpuLayerCount ?? 20,
35+
ContextSize = config?.ContextSize ?? 2048,
36+
GpuLayerCount = config?.GpuLayerCount ?? 20,
37+
MainGpu = config?.MainGpu ?? 0,
38+
SplitMode = config?.SplitMode ?? LLama.Native.GPUSplitMode.None,
3739
};
3840
_weights = LLamaWeights.LoadFromFile(parameters);
3941
_context = _weights.CreateContext(parameters);

LLama.SemanticKernel/LLamaSharp.SemanticKernel.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
</PropertyGroup>
3535

3636
<ItemGroup>
37-
<PackageReference Include="Microsoft.SemanticKernel.Abstractions" Version="1.44.0" />
37+
<PackageReference Include="Microsoft.SemanticKernel.Abstractions" Version="1.48.0" />
3838
</ItemGroup>
3939

4040
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">

LLama.Unittest/Constants.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ public static int CIGpuLayerCount
2020
{
2121
get
2222
{
23-
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
23+
//if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
2424
{
2525
#if DEBUG
2626
return 20;
2727
#else
2828
return 0;
2929
#endif
3030
}
31-
else return 20;
31+
//else return 20;
3232
}
3333
}
3434
}

LLama.Unittest/KernelMemory/ITextTokenizerTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public ITextTokenizerTests(ITestOutputHelper testOutputHelper)
2222
_testOutputHelper = testOutputHelper;
2323

2424
_infParams = new() { AntiPrompts = ["\n\n"] };
25-
_lsConfig = new(Constants.GenerativeModelPath) { DefaultInferenceParams = _infParams, ContextSize = 512 };
25+
_lsConfig = new(Constants.GenerativeModelPath) { DefaultInferenceParams = _infParams, ContextSize = 512, SplitMode = LLama.Native.GPUSplitMode.Layer };
2626

2727
testOutputHelper.WriteLine($"Using model {Path.GetFileName(_lsConfig.ModelPath)}");
2828
}

LLama.Unittest/LLama.Unittest.csproj

Lines changed: 91 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<Import Project="..\LLama\LLamaSharp.Runtime.targets" />
33
<PropertyGroup>
44
<TargetFramework>net8.0</TargetFramework>
@@ -25,32 +25,99 @@
2525
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2626
<PrivateAssets>all</PrivateAssets>
2727
</PackageReference>
28+
<PackageReference Include="Xunit.SkippableFact" Version="1.5.23" />
2829
</ItemGroup>
2930

30-
<Target Name="DownloadContentFilesInner">
31-
32-
<DownloadFile SourceUrl="https://huggingface.co/bartowski/Llama-3.2-1B-Instruct-GGUF/resolve/main/Llama-3.2-1B-Instruct-Q4_0.gguf" DestinationFolder="Models" DestinationFileName="Llama-3.2-1B-Instruct-Q4_0.gguf" SkipUnchangedFiles="true">
33-
</DownloadFile>
34-
35-
<DownloadFile SourceUrl="https://huggingface.co/HuggingFaceTB/smollm-360M-instruct-v0.2-Q8_0-GGUF/resolve/main/smollm-360m-instruct-add-basics-q8_0.gguf" DestinationFolder="Models" DestinationFileName="smollm-360m-instruct-add-basics-q8_0.gguf" SkipUnchangedFiles="true">
36-
</DownloadFile>
37-
38-
<DownloadFile SourceUrl="https://huggingface.co/cjpais/llava-1.6-mistral-7b-gguf/resolve/main/llava-v1.6-mistral-7b.Q3_K_XS.gguf" DestinationFolder="Models" DestinationFileName="llava-v1.6-mistral-7b.Q3_K_XS.gguf" SkipUnchangedFiles="true">
39-
</DownloadFile>
40-
41-
<DownloadFile SourceUrl="https://huggingface.co/cjpais/llava-1.6-mistral-7b-gguf/resolve/main/mmproj-model-f16.gguf" DestinationFolder="Models" DestinationFileName="mmproj-model-f16.gguf" SkipUnchangedFiles="true">
42-
</DownloadFile>
43-
44-
<DownloadFile SourceUrl="https://huggingface.co/leliuga/all-MiniLM-L12-v2-GGUF/resolve/main/all-MiniLM-L12-v2.Q8_0.gguf" DestinationFolder="Models" DestinationFileName="all-MiniLM-L12-v2.Q8_0.gguf" SkipUnchangedFiles="true">
45-
</DownloadFile>
46-
47-
</Target>
48-
49-
<Target Name="DownloadContentFiles" BeforeTargets="DispatchToInnerBuilds;BeforeBuild">
50-
<MSBuild Projects="$(MSBuildProjectFile)" Targets="DownloadContentFilesInner" Properties="TargetFramework=once" />
51-
</Target>
31+
<!-- Define each file to download.
32+
The Include value is just an identifier.
33+
SourceUrl is the remote URL.
34+
DestinationFolder is where you want it saved.
35+
LocalFileName is the desired file name. -->
36+
<ItemGroup>
37+
<DownloadFileItem Include="Llama-3.2-1B-Instruct-Q4_0">
38+
<SourceUrl>https://huggingface.co/bartowski/Llama-3.2-1B-Instruct-GGUF/resolve/main/Llama-3.2-1B-Instruct-Q4_0.gguf</SourceUrl>
39+
<DestinationFolder>Models</DestinationFolder>
40+
<LocalFileName>Llama-3.2-1B-Instruct-Q4_0.gguf</LocalFileName>
41+
</DownloadFileItem>
5242

53-
<ItemGroup>
43+
<DownloadFileItem Include="smollm-360m-instruct-add-basics-q8_0">
44+
<SourceUrl>https://huggingface.co/HuggingFaceTB/smollm-360M-instruct-v0.2-Q8_0-GGUF/resolve/main/smollm-360m-instruct-add-basics-q8_0.gguf</SourceUrl>
45+
<DestinationFolder>Models</DestinationFolder>
46+
<LocalFileName>smollm-360m-instruct-add-basics-q8_0.gguf</LocalFileName>
47+
</DownloadFileItem>
48+
49+
<DownloadFileItem Include="llava-v1.6-mistral-7b">
50+
<SourceUrl>https://huggingface.co/cjpais/llava-1.6-mistral-7b-gguf/resolve/main/llava-v1.6-mistral-7b.Q3_K_XS.gguf</SourceUrl>
51+
<DestinationFolder>Models</DestinationFolder>
52+
<LocalFileName>llava-v1.6-mistral-7b.Q3_K_XS.gguf</LocalFileName>
53+
</DownloadFileItem>
54+
55+
<DownloadFileItem Include="mmproj-model-f16">
56+
<SourceUrl>https://huggingface.co/cjpais/llava-1.6-mistral-7b-gguf/resolve/main/mmproj-model-f16.gguf</SourceUrl>
57+
<DestinationFolder>Models</DestinationFolder>
58+
<LocalFileName>mmproj-model-f16.gguf</LocalFileName>
59+
</DownloadFileItem>
60+
61+
<DownloadFileItem Include="all-MiniLM-L12-v2">
62+
<SourceUrl>https://huggingface.co/leliuga/all-MiniLM-L12-v2-GGUF/resolve/main/all-MiniLM-L12-v2.Q8_0.gguf</SourceUrl>
63+
<DestinationFolder>Models</DestinationFolder>
64+
<LocalFileName>all-MiniLM-L12-v2.Q8_0.gguf</LocalFileName>
65+
</DownloadFileItem>
66+
</ItemGroup>
67+
68+
<!-- Ensure the destination folder exists -->
69+
<Target Name="EnsureFolders">
70+
<MakeDir Directories="Models" Condition="!Exists('Models')" />
71+
</Target>
72+
73+
<!-- Download a single file:
74+
- Computes the full target file name (DesiredFile).
75+
- If DesiredFile already exists, the download is skipped.
76+
- Otherwise, creates a temporary folder (TempDownload),
77+
downloads the file there using DownloadFile, and then moves it
78+
to DesiredFile. Finally, cleans up the temporary folder. -->
79+
<Target Name="DownloadSingleFile" DependsOnTargets="EnsureFolders">
80+
<!-- (These properties come in via the MSBuild call.) -->
81+
<PropertyGroup>
82+
<DesiredFile>$([System.IO.Path]::Combine($(DestinationFolder), $(LocalFileName)))</DesiredFile>
83+
</PropertyGroup>
84+
85+
<Message Text="Processing file: $(DesiredFile)" Importance="high" />
86+
87+
<!-- Define a flag based on whether the file already exists -->
88+
<PropertyGroup>
89+
<DownloadNeeded Condition="!Exists('$(DesiredFile)')">true</DownloadNeeded>
90+
<DownloadNeeded Condition="Exists('$(DesiredFile)')">false</DownloadNeeded>
91+
</PropertyGroup>
92+
<Message Text="Download needed: $(DownloadNeeded)" Importance="high" />
93+
94+
<!-- If the file is already present, skip the download (by simply exiting this target) -->
95+
<Message Text="File $(DesiredFile) already exists; skipping download." Importance="high" Condition=" '$(DownloadNeeded)'=='false' " />
96+
97+
<!-- Only download if required -->
98+
<DownloadFile SourceUrl="$(SourceUrl)" DestinationFolder="TempDownload" SkipUnchangedFiles="true" Condition=" '$(DownloadNeeded)'=='true' " />
99+
100+
<!-- If a file was downloaded, move it to the desired name.
101+
We assume TempDownload now contains the downloaded file.
102+
(You might want to refine this if TempDownload could ever contain multiple files.) -->
103+
<ItemGroup Condition=" '$(DownloadNeeded)'=='true' ">
104+
<TempFile Include="TempDownload/*.*" />
105+
</ItemGroup>
106+
<Message Text="Downloaded file (temp): @(TempFile)" Importance="high" Condition=" '$(DownloadNeeded)'=='true' " />
107+
<Move SourceFiles="@(TempFile)" DestinationFiles="$(DesiredFile)" Condition=" '$(DownloadNeeded)'=='true' and @(TempFile) != '' " />
108+
<Message Text="Renamed downloaded file to $(DesiredFile)" Importance="high" Condition=" '$(DownloadNeeded)'=='true' and @(TempFile) != '' " />
109+
110+
<!-- Remove the temporary download folder -->
111+
<RemoveDir Directories="TempDownload" Condition="Exists('TempDownload')" />
112+
</Target>
113+
114+
<!-- Main target to process each file by calling the DownloadSingleFile target for each item.
115+
The MSBuild task will batch over the DownloadFileItem items, passing in each file’s metadata. -->
116+
<Target Name="DownloadAllFiles" BeforeTargets="DispatchToInnerBuilds;BeforeBuild">
117+
<MSBuild Projects="$(MSBuildProjectFile)" Targets="DownloadSingleFile" Properties="SourceUrl=%(DownloadFileItem.SourceUrl);DestinationFolder=%(DownloadFileItem.DestinationFolder);LocalFileName=%(DownloadFileItem.LocalFileName);TargetFramework=once" />
118+
</Target>
119+
120+
<ItemGroup>
54121
<ProjectReference Include="..\LLama.KernelMemory\LLamaSharp.KernelMemory.csproj" />
55122
<ProjectReference Include="..\LLama.SemanticKernel\LLamaSharp.SemanticKernel.csproj" />
56123
<ProjectReference Include="..\LLama\LLamaSharp.csproj" />

0 commit comments

Comments
 (0)