magols / BlazorGPT

BlazorGPT is a Blazor Server application that uses Semantic Kernel plus OpenAI, Azure OpenAI and Ollama for inference and embeddings.
MIT License
64 stars 19 forks source link

Starting Conversation #11

Closed ScheppKrauss closed 8 months ago

ScheppKrauss commented 10 months ago

Hallo,

great Projectidea!

I try to use it with OpenAi. But starting a conversation i got:

An error occurred. Please try again/later. Value cannot be an empty string. (Parameter 'key') at Azure.Core.Argument.AssertNotNullOrEmpty(String value, String name) at Azure.AzureKeyCredential.Update(String key) at Azure.AzureKeyCredential..ctor(String key) at Microsoft.SemanticKernel.OpenAIKernelBuilderExtensions.<>cDisplayClass7_0.gFactory|0(ILoggerFactory loggerFactory, IDelegatingHandlerFactory httpHandlerFactory) at Microsoft.SemanticKernel.KernelBuilder.<>cDisplayClass22_0`1.b0() at Microsoft.SemanticKernel.Services.NamedServiceProvider1.GetService[T](String name) at Microsoft.SemanticKernel.Kernel.GetService[T](String name) at BlazorGPT.Pipeline.KernelService.ChatCompletionAsStreamAsync(IKernel kernel, ChatHistory chatHistory, Conversation conversation, AIRequestSettings requestSettings, Func2 onStreamCompletion, CancellationToken cancellationToken) in D:\DevSources\BlazorGPT\src\BlazorGPT\Pipeline\KernelService.cs:line 106 at BlazorGPT.Pipeline.KernelService.ChatCompletionAsStreamAsync(IKernel kernel, Conversation conversation, AIRequestSettings requestSettings, Func`2 OnStreamCompletion, CancellationToken cancellationToken) in D:\DevSources\BlazorGPT\src\BlazorGPT\Pipeline\KernelService.cs:line 96 at BlazorGPT.Pages.ConversationPage.Send() in D:\DevSources\BlazorGPT\src\BlazorGPT\Pages\ConversationPage.razor.cs:line 325

I think there is a configuration error ?

magols commented 10 months ago

If you are trying to use OpenAI your config file should look something like this:

  "PipelineOptions:serviceType": "OpenAI",
  "PipelineOptions:Model": "gpt-4-1106-preview",
  "PipelineOptions:ModelEmbeddings": "text-embedding-ada-002",

  "PipelineOptions:Models": [ "gpt-3.5-turbo", "gpt-4", "gpt-4-1106-preview" ],
  "PipelineOptions:apiKey": "sk-XXXXXXXXXXXXXXXXXXXXXXXXx",
ScheppKrauss commented 10 months ago

Hallo, thanks,. i build the project again. Now i get an other error blazor.web.js:1 [2023-12-21T10:30:23.580Z] Error: System.ArgumentException: The value cannot be an empty string or composed entirely of whitespace. (Parameter 'endpoint') at Microsoft.SemanticKernel.Verify.ThrowArgumentWhiteSpaceException(String paramName) at Microsoft.SemanticKernel.OpenAIServiceCollectionExtensions.AddAzureOpenAIChatCompletion(IKernelBuilder builder, String deploymentName, String endpoint, String apiKey, String serviceId, String modelId, HttpClient httpClient) at BlazorGPT.Pipeline.KernelService.CreateKernelAsync(String model) in D:\DevSources\ScheppachGPT\src\BlazorGPT\Pipeline\KernelService.cs:line 36 at BlazorGPT.Pages.ConversationPage.SendConversation() in D:\DevSources\ScheppachGPT\src\BlazorGPT\Pages\ConversationPage.razor.cs:line 267 at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task) at Microsoft.AspNetCore.Components.Forms.EditForm.HandleSubmitAsync() at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task) at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

ScheppKrauss commented 10 months ago

T think i have found the error. In the Config file you have the Node "PipelineOptions": {

but there ist no serviceType you have in the Node PipelineOptions:serviceType But you just search for ServiceType

magols commented 10 months ago

Hi,

I have reworked the service provider and model settings a bit. Hopefully the appsettings configuration is a bit more clear. https://github.com/magols/BlazorGPT/blob/a1edad4f88c0a8300f9d28ac4f8ed179f9987b22/src/BlazorGPT.Web/appsettings.json#L13

It also allows for Azure OpenAI models where the deployment name does not match the model name. (That's how we have it set up at work) You can also switch between OpenAI and Azure during runtime and the settings are stored in your browsers LocalStorage.