Description
Describe the bug
Microsoft.SemanticKernel version 1.20 has problems Version 1.19 is fine
Ollama uses the OpenAI architecture to report error 404
this is my code
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.ChatCompletion;
#pragma warning disable SKEXP0010
var builder = Kernel.CreateBuilder();
builder.AddOpenAIChatCompletion(modelId: "qwen2:latest", apiKey: null, endpoint: new Uri("http://127.0.0.1:11434"));
var kernel = builder.Build();
var chatCompletionService = kernel.GetRequiredService();
var history = new ChatHistory();
string? userInput;
do
{
Console.Write("User > ");
userInput = Console.ReadLine();
history.AddUserMessage(userInput);
var result = await chatCompletionService.GetChatMessageContentAsync(
history,
// executionSettings: openAIPromptExecutionSettings,
kernel: kernel);
Console.WriteLine("Assistant > " + result);
history.AddMessage(result.Role, result.Content ?? string.Empty);
} while (userInput is not null);
Console.WriteLine("Hello, World!");
To Reproduce
Steps to reproduce the behavior:
error :
Unhandled exception. Microsoft.SemanticKernel.HttpOperationException: Service request failed.
Status: 404 (Not Found)
---> System.ClientModel.ClientResultException: Service request failed.
Status: 404 (Not Found)
at OpenAI.ClientPipelineExtensions.ProcessMessageAsync(ClientPipeline pipeline, PipelineMessage message, RequestOptions options)
at OpenAI.Chat.ChatClient.CompleteChatAsync(BinaryContent content, RequestOptions options)
at OpenAI.Chat.ChatClient.CompleteChatAsync(IEnumerable1 messages, ChatCompletionOptions options, CancellationToken cancellationToken) at Microsoft.SemanticKernel.Connectors.OpenAI.ClientCore.RunRequestAsync[T](Func
1 request)
--- End of inner exception stack trace ---
at Microsoft.SemanticKernel.Connectors.OpenAI.ClientCore.RunRequestAsync[T](Func`1 request)
at Microsoft.SemanticKernel.Connectors.OpenAI.ClientCore.GetChatMessageContentsAsync(String targetModel, ChatHistory chatHistory, PromptExecutionSettings executionSettings, Kernel kernel, CancellationToken cancellationToken)
at Microsoft.SemanticKernel.ChatCompletion.ChatCompletionServiceExtensions.GetChatMessageContentAsync(IChatCompletionService chatCompletionService, ChatHistory chatHistory, PromptExecutionSettings executionSettings, Kernel kernel, CancellationToken cancellationToken)
at Program.
at Program.(String[] args)
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Platform
- OS:windows11
- IDE: vs2022
- Language: C#
- Source: [e.g. NuGet package version 1.20, pip package version 0.1.0, main branch of repository]
Additional context
Add any other context about the problem here.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status