You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Notebooks that reference the Microsoft.SemanticKernel.Core and Microsoft.SemanticKernel.Connectors.Ollama nuget packages output errors when they run.
To Reproduce
Create a Polyglot Notebook with these two code blocks:
usingMicrosoft.SemanticKernel;usingKernel=Microsoft.SemanticKernel.Kernel;varbuilder=Kernel.CreateBuilder();
#pragma warning disable SKEXP0070// Ollama support is experimentalbuilder.AddOllamaChatCompletion("llama3.1:8b-instruct-q2_K",newUri("http://localhost:11434"));
#pragma warning restore SKEXP0070// Ollama support is experimentalvarkernel=builder.Build();Console.WriteLine("It worked!");Console.WriteLine(kernel);
Run the code blocks. It produces this output:
Error: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=9.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=9.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
at Microsoft.SemanticKernel.OllamaKernelBuilderExtensions.AddOllamaChatCompletion(IKernelBuilder builder, String modelId, Uri endpoint, String serviceId)
at Submission#1.<<Initialize>>d__0.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.RunSubmissionsAsync[TResult](ImmutableArray`1 precedingExecutors, Func`2 currentExecutor, StrongBox`1 exceptionHolderOpt, Func`2 catchExceptionOpt, CancellationToken cancellationToken)
Expected behavior
I expected it to output:
It worked!
Microsoft.SemanticKernel.Kernel
... which is what happens if you create a .NET 8 Console App with the same two nuget packages and that C# code.
Platform
Language: [C#]
Source: [NuGet package version 1.34.0]
AI model: [llama3.1:8b-instruct-q2_K]
IDE: [VS Code with Polyglot Notebooks extension]
OS: [Windows 11]
Additional context
I have cross posted this issue with the Polyglot Notebooks team. dotnet/interactive#3823
The text was updated successfully, but these errors were encountered:
github-actionsbot
changed the title
Bug: Error in Polyglot Notebook using Ollama Connector
.Net: Bug: Error in Polyglot Notebook using Ollama Connector
Jan 27, 2025
Ensure you add the 9.0.0 dependency injection first. Ollama Connector depends on Microsoft.Extensions.AI which has a hard dependency on Microsoft.Extensions.DependencyInjection 9.0.0.
To fix, you need to restart your kernel and add the 9.0.0 explicitly as the first package.
#r "nuget: Microsoft.Extensions.DependencyInjection, 9.0.0"
#r "nuget:Microsoft.SemanticKernel.Core,1.35.0"
#r "nuget: Microsoft.SemanticKernel.Connectors.Ollama, 1.35.0-alpha"usingMicrosoft.SemanticKernel;usingKernel=Microsoft.SemanticKernel.Kernel;varbuilder=Kernel.CreateBuilder();
#pragma warning disable SKEXP0070// Ollama support is experimentalbuilder.AddOllamaChatCompletion("llama3.1:8b-instruct-q2_K",newUri("http://localhost:11434"));
#pragma warning restore SKEXP0070// Ollama support is experimentalvarkernel=builder.Build();Console.WriteLine("It worked!");Console.WriteLine(kernel);
Thanks! After installing the .NET 9 SDK and upgrading to the latest version of the Polyglot Notebooks extension, it is now working. Upgrading the extension was weird. I upgraded, but #!about still said I had the old version, and the Ollama connector still wouldn't work - same ...DependencyInjection.Abstractions, Version=9.0.0.0 error as before. I had to uninstall the extension and reinstall it, and then after that everything was happy.
Describe the bug
Notebooks that reference the
Microsoft.SemanticKernel.Core
andMicrosoft.SemanticKernel.Connectors.Ollama
nuget packages output errors when they run.To Reproduce
Create a Polyglot Notebook with these two code blocks:
Run the code blocks. It produces this output:
Expected behavior
I expected it to output:
... which is what happens if you create a .NET 8 Console App with the same two nuget packages and that C# code.
Platform
Additional context
I have cross posted this issue with the Polyglot Notebooks team. dotnet/interactive#3823
The text was updated successfully, but these errors were encountered: