BLaZeKiLL / Codeblaze.SemanticKernel

Some Cool Semantic Kernel Plugins
MIT License
46 stars 9 forks source link

Dotnet - System.Text.Json.JsonException when using Uri object #15

Open davejitsu opened 3 months ago

davejitsu commented 3 months ago

Code:

var llmEndPoint = "http://localhost:11434";
var llmUri = new Uri(llmEndPoint);

var modelId = "phi3:medium";
var embedderModelId = "nomic-embed-text";

var builder = Kernel.CreateBuilder()
    .AddOpenAIChatCompletion(modelId, llmUri, null)
    .AddOllamaTextEmbeddingGeneration(embedderModelId, llmUri);

builder.Services.AddTransient();
var kernel = builder.Build();

var embeddingGenerator = kernel.GetRequiredService>();
var embeddings = await embeddingGenerator.GenerateEmbeddingAsync("What is the capital of France?");

Error: System.Text.Json.JsonException: ''p' is invalid after a single JSON value. Expected end of data. Path: $ | LineNumber: 0 | BytePositionInLine: 4.'

Http Response: StatusCode: 404, ReasonPhrase: 'Not Found', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent

Cause: There is a trailing / when using Uri object Expected: http://localhost:11434/api/embeddings Actual: http://localhost:11434//api/embeddings