|
1 | | -using Atc.SemanticKernel.Connectors.Ollama.ChatCompletion; |
2 | | -using Atc.SemanticKernel.Connectors.Ollama.TextEmbeddingGeneration; |
3 | | -using Atc.SemanticKernel.Connectors.Ollama.TextGenerationService; |
4 | | -using NeighborlyMemory; |
| 1 | +using NeighborlyMemory; |
5 | 2 | using Microsoft.SemanticKernel; |
6 | 3 | using Microsoft.SemanticKernel.Memory; |
7 | 4 | using Microsoft.SemanticKernel.Connectors.OpenAI; |
8 | 5 | using Microsoft.SemanticKernel.Plugins.Memory; |
| 6 | +using Microsoft.SemanticKernel.Connectors.Ollama; |
| 7 | +using OllamaSharp; |
9 | 8 | using DotNet.Testcontainers.Builders; |
10 | | -using Microsoft.SemanticKernel.Embeddings; |
11 | 9 | using Microsoft.Extensions.DependencyInjection; |
12 | 10 | using Microsoft.SemanticKernel.ChatCompletion; |
13 | | -using Microsoft.SemanticKernel.TextGeneration; |
| 11 | +using Microsoft.SemanticKernel.Embeddings; |
14 | 12 | using Microsoft.Extensions.Logging; |
15 | 13 | using Neighborly; |
16 | 14 |
|
|
40 | 38 |
|
41 | 39 | Uri ollamaUri = new($"http://localhost:{ollama.GetMappedPublicPort(11434)}"); |
42 | 40 |
|
43 | | -OllamaChatCompletionService ollamaChat = new(ollamaUri, modelName); |
44 | | -OllamaTextGenerationService ollamaText = new(ollamaUri, modelName); |
45 | | -OllamaTextEmbeddingGenerationService ollamaEmbedding = new(ollamaUri, embeddingModelName); |
| 41 | +#pragma warning disable SKEXP0070 // Ollama connector is experimental |
| 42 | +using var ollamaClient = new OllamaApiClient(ollamaUri, modelName); |
| 43 | +using var ollamaEmbeddingClient = new OllamaApiClient(ollamaUri, embeddingModelName); |
| 44 | + |
| 45 | +var ollamaChat = ollamaClient.AsChatCompletionService(); |
| 46 | +var ollamaEmbedding = ollamaEmbeddingClient.AsTextEmbeddingGenerationService(); |
| 47 | +#pragma warning restore SKEXP0070 |
46 | 48 |
|
47 | 49 | #pragma warning disable SKEXP0001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed. |
48 | 50 | using var db = new VectorDatabase(loggerFactory.CreateLogger<VectorDatabase>(), null); |
|
59 | 61 | builder.Services.AddSingleton(db); |
60 | 62 | builder.Services.AddSingleton(memory); |
61 | 63 | builder.Services.AddSingleton<IChatCompletionService>(ollamaChat); |
62 | | -builder.Services.AddSingleton<ITextGenerationService>(ollamaText); |
63 | | -#pragma warning disable SKEXP0001 |
| 64 | +#pragma warning disable SKEXP0001, CS0618 |
64 | 65 | builder.Services.AddSingleton<ITextEmbeddingGenerationService>(ollamaEmbedding); |
65 | | -#pragma warning restore SKEXP0001 |
| 66 | +#pragma warning restore SKEXP0001, CS0618 |
66 | 67 |
|
67 | 68 | var kernel = builder.Build(); |
68 | 69 |
|
|
0 commit comments