|
1 |
| -using Microsoft.KernelMemory; |
| 1 | +using Microsoft.KernelMemory; |
2 | 2 | using System;
|
3 | 3 | using System.Collections.Generic;
|
4 | 4 | using System.Linq;
|
@@ -81,23 +81,22 @@ public static IKernelMemoryBuilder WithLLamaSharpDefaults(this IKernelMemoryBuil
|
81 | 81 | {
|
82 | 82 | var parameters = new ModelParams(config.ModelPath)
|
83 | 83 | {
|
84 |
| - ContextSize = config?.ContextSize ?? 2048, |
85 |
| - Seed = config?.Seed ?? 0, |
86 |
| - GpuLayerCount = config?.GpuLayerCount ?? 20, |
| 84 | + ContextSize = config.ContextSize ?? 2048, |
| 85 | + Seed = config.Seed ?? 0, |
| 86 | + GpuLayerCount = config.GpuLayerCount ?? 20, |
87 | 87 | Embeddings = true,
|
88 |
| - MainGpu = config?.MainGpu ?? 0, |
89 |
| - SplitMode = config?.SplitMode ?? GPUSplitMode.None, |
| 88 | + MainGpu = config.MainGpu, |
| 89 | + SplitMode = config.SplitMode |
90 | 90 | };
|
91 | 91 |
|
92 |
| - if (weights == null) |
| 92 | + if (weights == null || context == null) |
93 | 93 | {
|
94 | 94 | weights = LLamaWeights.LoadFromFile(parameters);
|
95 | 95 | context = weights.CreateContext(parameters);
|
96 | 96 | }
|
97 | 97 |
|
98 | 98 | var executor = new StatelessExecutor(weights, parameters);
|
99 |
| - var embedder = new LLamaEmbedder(weights, parameters); |
100 |
| - builder.WithLLamaSharpTextEmbeddingGeneration(new LLamaSharpTextEmbeddingGenerator(embedder)); |
| 99 | + builder.WithLLamaSharpTextEmbeddingGeneration(new LLamaSharpTextEmbeddingGenerator(config, weights)); |
101 | 100 | builder.WithLLamaSharpTextGeneration(new LlamaSharpTextGenerator(weights, context, executor, config?.DefaultInferenceParams));
|
102 | 101 | return builder;
|
103 | 102 | }
|
|
0 commit comments