kernel-memory icon indicating copy to clipboard operation
kernel-memory copied to clipboard

[Bug] c# 9.0 winforms 404 error using OllamaConfig

Open wrharper opened this issue 11 months ago • 6 comments

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).'

wrharper avatar Jan 31 '25 22:01 wrharper