From cdc18114e8808318533529a80c5244623d223d88 Mon Sep 17 00:00:00 2001 From: Roger Barreto <19890735+RogerBarreto@users.noreply.github.com> Date: Wed, 21 Aug 2024 19:21:27 +0100 Subject: [PATCH 1/2] Fix --- .../TextGeneration/Ollama_TextGeneration.cs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/dotnet/samples/Concepts/TextGeneration/Ollama_TextGeneration.cs b/dotnet/samples/Concepts/TextGeneration/Ollama_TextGeneration.cs index 12f7d42b13ae..05885c6c5da6 100644 --- a/dotnet/samples/Concepts/TextGeneration/Ollama_TextGeneration.cs +++ b/dotnet/samples/Concepts/TextGeneration/Ollama_TextGeneration.cs @@ -62,19 +62,14 @@ public async Task RunStreamingExampleAsync() Console.WriteLine($"\n======== HuggingFace {model} streaming example ========\n"); Kernel kernel = Kernel.CreateBuilder() - .AddHuggingFaceTextGeneration( - model: model, - apiKey: TestConfiguration.HuggingFace.ApiKey) + .AddOllamaTextGeneration( + endpoint: new Uri(TestConfiguration.Ollama.Endpoint), + modelId: TestConfiguration.Ollama.ModelId) .Build(); - var settings = new HuggingFacePromptExecutionSettings { UseCache = false }; - - var questionAnswerFunction = kernel.CreateFunctionFromPrompt("Question: {{$input}}; Answer:", new HuggingFacePromptExecutionSettings - { - UseCache = false - }); + var questionAnswerFunction = kernel.CreateFunctionFromPrompt("Question: {{$input}}; Answer:"); - await foreach (string text in kernel.InvokePromptStreamingAsync("Question: {{$input}}; Answer:", new(settings) { ["input"] = "What is New York?" })) + await foreach (string text in kernel.InvokePromptStreamingAsync("Question: {{$input}}; Answer:", new() { ["input"] = "What is New York?" })) { Console.Write(text); } From ccb7b6ddb4e440aaff303aaf71e8b56b8f800034 Mon Sep 17 00:00:00 2001 From: Roger Barreto <19890735+RogerBarreto@users.noreply.github.com> Date: Wed, 21 Aug 2024 20:58:29 +0100 Subject: [PATCH 2/2] Format fix --- dotnet/samples/Concepts/TextGeneration/Ollama_TextGeneration.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/dotnet/samples/Concepts/TextGeneration/Ollama_TextGeneration.cs b/dotnet/samples/Concepts/TextGeneration/Ollama_TextGeneration.cs index 05885c6c5da6..719d5eb9f951 100644 --- a/dotnet/samples/Concepts/TextGeneration/Ollama_TextGeneration.cs +++ b/dotnet/samples/Concepts/TextGeneration/Ollama_TextGeneration.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft. All rights reserved. using Microsoft.SemanticKernel; -using Microsoft.SemanticKernel.Connectors.HuggingFace; using Microsoft.SemanticKernel.TextGeneration; using xRetry;