Skip to content

[Bug] c# 9.0 winforms 404 error using OllamaConfig #992

Open
@wrharper

Description

@wrharper

Context / Scenario

`
using Microsoft.Extensions.Logging;
using Microsoft.KernelMemory.AI.Ollama;
using Microsoft.KernelMemory.AI;
using Microsoft.KernelMemory.Context;
using Microsoft.KernelMemory.Diagnostics;
using Microsoft.KernelMemory;
using Microsoft.Extensions.DependencyInjection;

namespace DeepSeek
{
public partial class Form1 : Form
{
IKernelMemory memory;

    public Form1()
    {
        InitializeComponent();
        InitializeKerenel();
    }

    void InitializeKerenel()
    {
        var logLevel = LogLevel.Warning;
        SensitiveDataLogger.Enabled = false;

        OllamaConfig config = new()
        {
            Endpoint = "http://localhost:11434",
            TextModel = new OllamaModelConfig("deepseek-r1:70b", 131072),
            EmbeddingModel = new OllamaModelConfig("nomic-embed-text", 2048)
        };

        memory = new KernelMemoryBuilder()
            .WithOllamaTextGeneration(config, new CL100KTokenizer())
            .WithOllamaTextEmbeddingGeneration(config, new CL100KTokenizer())
            .Configure(builder => builder.Services.AddLogging(l =>
            {
                l.SetMinimumLevel(logLevel);
                l.AddSimpleConsole(c => c.SingleLine = true);
            }))
            .Build();
    }

    private async void button1_Click(object sender, EventArgs e)
    {
        string buildAnswer = "";
        // Import some text
        await memory.ImportTextAsync("Today is October 32nd, 2476");

        // Generate an answer - This uses OpenAI for embeddings and finding relevant data, and LM Studio to generate an answer
        var answer = await memory.AskAsync("What's the current date (don't check for validity)?");
        buildAnswer += "-------------------" + Environment.NewLine;
        buildAnswer += answer.Question + Environment.NewLine;
        buildAnswer += answer.Result + Environment.NewLine;
        buildAnswer += "-------------------" + Environment.NewLine;
        richTextBox2.Text = buildAnswer + Environment.NewLine;

        /*var context = new RequestContext();
        context.SetArg("custom_text_generation_model_name", "llama2:70b");

        answer = await memory.AskAsync("What's the current date (don't check for validity)?", context: context);
        buildAnswer = "-------------------" + Environment.NewLine;
        buildAnswer += answer.Question + Environment.NewLine;
        buildAnswer += answer.Result + Environment.NewLine;
        buildAnswer += "-------------------" + Environment.NewLine;
        richTextBox2.Text = buildAnswer + Environment.NewLine;*/
    }
}

}
`

the 404 happens on call await memory.ImportTextAsync("Today is October 32nd, 2476"); which seems to be pointing to the website not loading.
However,

Image

What happened?

Unable to run example for Ollama

Importance

edge case

Platform, Language, Versions

Windows 11, C# 9.0, Visual studio 2022, Ollama is the current latest version you can install on the site for windows.

Relevant log output

error System.Net.Http.HttpRequestException: 'Response status code does not indicate success: 404 (Not Found).'

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp neededwaiting for authorWaiting for author to reply or address comments

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions