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

Unable to generate bot response. Details: Error: 400: => Runtime error: Function `ChatSkill.ExtractUserMemories` execution failed. Microsoft.SemanticKernel.AI.AIException: Invalid request: The request is not valid, HTTP status: 400

Open Julian-Chou opened this issue 2 years ago • 8 comments

Describe the bug I can run webapi and webapp, but get the error message been shown the browser like 'Unable to generate bot response. Details: Error: 400: => Runtime error: Function ChatSkill.ExtractUserMemories execution failed. Microsoft.SemanticKernel.AI.AIException: Invalid request: The request is not valid, HTTP status: 400' as below. image

A clear and concise description of what the bug is.

To Reproduce

  1. run webapi
  2. run webapp
  3. go to http://localhost:3000/
  4. input the chat: How many planets are there in the solar system?
  5. See error: Unable to generate bot response. Details: Error: 400: => Runtime error: Function ChatSkill.ExtractUserMemories execution failed. Microsoft.SemanticKernel.AI.AIException: Invalid request: The request is not valid, HTTP status: 400

Screenshots my appsetting.json image my webapi console image

Desktop (please complete the following information):

  • OS: Windows 10 64
  • IDE: run on PowerShell

Julian-Chou avatar May 10 '23 02:05 Julian-Chou

I am seeing similar issue but with the 404 error: Unable to generate bot response. Details: Error: 400: => Runtime error: Function ChatSkill.ExtractUserMemories execution failed. Microsoft.SemanticKernel.AI.AIException: Invalid request: The request is not valid, HTTP status: 404

image

Exception call stack:

fail: SemanticKernel.Service.Program[0]
      Something went wrong when invoking function with custom input: ChatSkill.ExtractUserMemories. Error: Invalid request: The request is not valid, HTTP status: 404
      Microsoft.SemanticKernel.AI.AIException: Invalid request: The request is not valid, HTTP status: 404
         at Microsoft.SemanticKernel.Connectors.AI.OpenAI.AzureSdk.ClientBase.RunRequestAsync[T](Func`1 request) in D:\src\semantic-kernel\dotnet\src\Connectors\Connectors.AI.OpenAI\AzureSdk\ClientBase.cs:line 363
         at Microsoft.SemanticKernel.Connectors.AI.OpenAI.AzureSdk.ClientBase.InternalGenerateTextEmbeddingsAsync(IList`1 data, CancellationToken cancellationToken) in D:\src\semantic-kernel\dotnet\src\Connectors\Connectors.AI.OpenAI\AzureSdk\ClientBase.cs:line 110
         at Microsoft.SemanticKernel.AI.Embeddings.EmbeddingGenerationExtensions.GenerateEmbeddingAsync[TValue,TEmbedding](IEmbeddingGeneration`2 generator, TValue value, CancellationToken cancellationToken) in D:\src\semantic-kernel\dotnet\src\SemanticKernel.Abstractions\AI\Embeddings\IEmbeddingGeneration.cs:line 47
         at Microsoft.SemanticKernel.Memory.SemanticTextMemory.SearchAsync(String collection, String query, Int32 limit, Double minRelevanceScore, Boolean withEmbeddings, CancellationToken cancellationToken)+MoveNext() in D:\src\semantic-kernel\dotnet\src\SemanticKernel\Memory\SemanticTextMemory.cs:line 104
         at Microsoft.SemanticKernel.Memory.SemanticTextMemory.SearchAsync(String collection, String query, Int32 limit, Double minRelevanceScore, Boolean withEmbeddings, CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
         at SemanticKernel.Service.Skills.ChatSkill.ExtractUserMemoriesAsync(SKContext context) in D:\src\semantic-kernel\samples\apps\copilot-chat-app\webapi\Skills\ChatSkill.cs:line 161
         at SemanticKernel.Service.Skills.ChatSkill.ExtractUserMemoriesAsync(SKContext context) in D:\src\semantic-kernel\samples\apps\copilot-chat-app\webapi\Skills\ChatSkill.cs:line 161
         at Microsoft.SemanticKernel.SkillDefinition.SKFunction.InvokeNativeAsync(SKContext context) in D:\src\semantic-kernel\dotnet\src\SemanticKernel\SkillDefinition\SKFunction.cs:line 423
         at Microsoft.SemanticKernel.SkillDefinition.SKFunctionExtensions.InvokeWithCustomInputAsync(ISKFunction function, ContextVariables input, ISemanticTextMemory memory, IReadOnlySkillCollection skills, ILogger log, CancellationToken cancellationToken) in D:\src\semantic-kernel\dotnet\src\SemanticKernel\SkillDefinition\SKFunctionExtensions.cs:line 111
fail: SemanticKernel.Service.Program[0]
      Function `ChatSkill.ExtractUserMemories` execution failed. Microsoft.SemanticKernel.AI.AIException: Invalid request: The request is not valid, HTTP status: 404
fail: SemanticKernel.Service.Program[0]
      Something went wrong while rendering the semantic function or while executing the text completion. Function: ChatSkill.func485e46927356468eaf92dfb4ab2d955b. Error: Runtime error: Function `ChatSkill.ExtractUserMemories` execution failed. Microsoft.SemanticKernel.AI.AIException: Invalid request: The request is not valid, HTTP status: 404
      Microsoft.SemanticKernel.TemplateEngine.TemplateException: Runtime error: Function `ChatSkill.ExtractUserMemories` execution failed. Microsoft.SemanticKernel.AI.AIException: Invalid request: The request is not valid, HTTP status: 404
       ---> Microsoft.SemanticKernel.AI.AIException: Invalid request: The request is not valid, HTTP status: 404
         at Microsoft.SemanticKernel.Connectors.AI.OpenAI.AzureSdk.ClientBase.RunRequestAsync[T](Func`1 request) in D:\src\semantic-kernel\dotnet\src\Connectors\Connectors.AI.OpenAI\AzureSdk\ClientBase.cs:line 363
         at Microsoft.SemanticKernel.Connectors.AI.OpenAI.AzureSdk.ClientBase.InternalGenerateTextEmbeddingsAsync(IList`1 data, CancellationToken cancellationToken) in D:\src\semantic-kernel\dotnet\src\Connectors\Connectors.AI.OpenAI\AzureSdk\ClientBase.cs:line 110
         at Microsoft.SemanticKernel.AI.Embeddings.EmbeddingGenerationExtensions.GenerateEmbeddingAsync[TValue,TEmbedding](IEmbeddingGeneration`2 generator, TValue value, CancellationToken cancellationToken) in D:\src\semantic-kernel\dotnet\src\SemanticKernel.Abstractions\AI\Embeddings\IEmbeddingGeneration.cs:line 47
         at Microsoft.SemanticKernel.Memory.SemanticTextMemory.SearchAsync(String collection, String query, Int32 limit, Double minRelevanceScore, Boolean withEmbeddings, CancellationToken cancellationToken)+MoveNext() in D:\src\semantic-kernel\dotnet\src\SemanticKernel\Memory\SemanticTextMemory.cs:line 104
         at Microsoft.SemanticKernel.Memory.SemanticTextMemory.SearchAsync(String collection, String query, Int32 limit, Double minRelevanceScore, Boolean withEmbeddings, CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
         at SemanticKernel.Service.Skills.ChatSkill.ExtractUserMemoriesAsync(SKContext context) in D:\src\semantic-kernel\samples\apps\copilot-chat-app\webapi\Skills\ChatSkill.cs:line 161
         at SemanticKernel.Service.Skills.ChatSkill.ExtractUserMemoriesAsync(SKContext context) in D:\src\semantic-kernel\samples\apps\copilot-chat-app\webapi\Skills\ChatSkill.cs:line 161
         at Microsoft.SemanticKernel.SkillDefinition.SKFunction.InvokeNativeAsync(SKContext context) in D:\src\semantic-kernel\dotnet\src\SemanticKernel\SkillDefinition\SKFunction.cs:line 423
         at Microsoft.SemanticKernel.SkillDefinition.SKFunctionExtensions.InvokeWithCustomInputAsync(ISKFunction function, ContextVariables input, ISemanticTextMemory memory, IReadOnlySkillCollection skills, ILogger log, CancellationToken cancellationToken) in D:\src\semantic-kernel\dotnet\src\SemanticKernel\SkillDefinition\SKFunctionExtensions.cs:line 111
         --- End of inner exception stack trace ---
         at Microsoft.SemanticKernel.TemplateEngine.Blocks.CodeBlock.RenderFunctionCallAsync(FunctionIdBlock fBlock, SKContext context) in D:\src\semantic-kernel\dotnet\src\SemanticKernel\TemplateEngine\Blocks\CodeBlock.cs:line 138
         at Microsoft.SemanticKernel.TemplateEngine.Blocks.CodeBlock.RenderCodeAsync(SKContext context) in D:\src\semantic-kernel\dotnet\src\SemanticKernel\TemplateEngine\Blocks\CodeBlock.cs:line 87
         at Microsoft.SemanticKernel.TemplateEngine.PromptTemplateEngine.RenderAsync(IList`1 blocks, SKContext context) in D:\src\semantic-kernel\dotnet\src\SemanticKernel\TemplateEngine\PromptTemplateEngine.cs:line 78
         at Microsoft.SemanticKernel.TemplateEngine.PromptTemplateEngine.RenderAsync(String templateText, SKContext context) in D:\src\semantic-kernel\dotnet\src\SemanticKernel\TemplateEngine\PromptTemplateEngine.cs:line 61
         at Microsoft.SemanticKernel.SemanticFunctions.PromptTemplate.RenderAsync(SKContext executionContext) in D:\src\semantic-kernel\dotnet\src\SemanticKernel\SemanticFunctions\PromptTemplate.cs:line 110
         at Microsoft.SemanticKernel.SkillDefinition.SKFunction.<>c__DisplayClass18_0.<<FromSemanticConfig>g__LocalFunc|0>d.MoveNext() in D:\src\semantic-kernel\dotnet\src\SemanticKernel\SkillDefinition\SKFunction.cs:line 111
fail: SemanticKernel.Service.Program[0]
      Function call fail during pipeline step 0: ChatSkill.Chat. Error: Runtime error: Function `ChatSkill.ExtractUserMemories` execution failed. Microsoft.SemanticKernel.AI.AIException: Invalid request: The request is not valid, HTTP status: 404
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
      Request finished HTTP/2 POST https://localhost:40443/skills/ChatSkill/functions/Chat/invoke application/json 311 - 400 - text/plain;+charset=utf-8 4529.7223ms

firelake avatar May 10 '23 09:05 firelake

same issure here

LeonCai1 avatar May 11 '23 07:05 LeonCai1

Same here with the latest code from "main" branch.

minzhang avatar May 12 '23 09:05 minzhang

Same here with the latest code from "main" branch.

Update: after tried talk with the chatbot 5 or some more times, the issue looks gone.

minzhang avatar May 12 '23 10:05 minzhang

Same 404 issue here. Tried a lot of times, but the issue is still there.

fail: SemanticKernel.Service.Program[0]
      Runtime error: Function `ChatSkill.ExtractUserMemories` execution failed. Microsoft.SemanticKernel.AI.AIException: Invalid request: The request is not valid, HTTP status: 404: Microsoft.SemanticKernel.TemplateEngine.TemplateException: Runtime error: Function `ChatSkill.ExtractUserMemories` execution failed. Microsoft.SemanticKernel.AI.AIException: Invalid request: The request is not valid, HTTP status: 404
       ---> Microsoft.SemanticKernel.AI.AIException: Invalid request: The request is not valid, HTTP status: 404
         at Microsoft.SemanticKernel.Connectors.AI.OpenAI.AzureSdk.ClientBase.RunRequestAsync[T](Func`1 request) in C:\Users\hons\semantic-kernel-main\semantic-kernel-main\dotnet\src\Connectors\Connectors.AI.OpenAI\AzureSdk\ClientBase.cs:line 363
         at Microsoft.SemanticKernel.Connectors.AI.OpenAI.AzureSdk.ClientBase.InternalGenerateTextEmbeddingsAsync(IList`1 data, CancellationToken cancellationToken) in C:\Users\hons\semantic-kernel-main\semantic-kernel-main\dotnet\src\Connectors\Connectors.AI.OpenAI\AzureSdk\ClientBase.cs:line 110
         at Microsoft.SemanticKernel.AI.Embeddings.EmbeddingGenerationExtensions.GenerateEmbeddingAsync[TValue,TEmbedding](IEmbeddingGeneration`2 generator, TValue value, CancellationToken cancellationToken) in C:\Users\hons\semantic-kernel-main\semantic-kernel-main\dotnet\src\SemanticKernel.Abstractions\AI\Embeddings\IEmbeddingGeneration.cs:line 47
         at Microsoft.SemanticKernel.Memory.SemanticTextMemory.SearchAsync(String collection, String query, Int32 limit, Double minRelevanceScore, Boolean withEmbeddings, CancellationToken cancellationToken)+MoveNext() in C:\Users\hons\semantic-kernel-main\semantic-kernel-main\dotnet\src\SemanticKernel\Memory\SemanticTextMemory.cs:line 104
         at Microsoft.SemanticKernel.Memory.SemanticTextMemory.SearchAsync(String collection, String query, Int32 limit, Double minRelevanceScore, Boolean withEmbeddings, CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
         at SemanticKernel.Service.Skills.ChatSkill.ExtractUserMemoriesAsync(SKContext context) in C:\Users\hons\semantic-kernel-main\semantic-kernel-main\samples\apps\copilot-chat-app\webapi\Skills\ChatSkill.cs:line 167
         at SemanticKernel.Service.Skills.ChatSkill.ExtractUserMemoriesAsync(SKContext context) in C:\Users\hons\semantic-kernel-main\semantic-kernel-main\samples\apps\copilot-chat-app\webapi\Skills\ChatSkill.cs:line 167
         at Microsoft.SemanticKernel.SkillDefinition.SKFunction.InvokeNativeAsync(SKContext context) in C:\Users\hons\semantic-kernel-main\semantic-kernel-main\dotnet\src\SemanticKernel\SkillDefinition\SKFunction.cs:line 425
         at Microsoft.SemanticKernel.SkillDefinition.SKFunctionExtensions.InvokeWithCustomInputAsync(ISKFunction function, ContextVariables input, ISemanticTextMemory memory, IReadOnlySkillCollection skills, ILogger log, CancellationToken cancellationToken) in C:\Users\hons\semantic-kernel-main\semantic-kernel-main\dotnet\src\SemanticKernel\SkillDefinition\SKFunctionExtensions.cs:line 111
         --- End of inner exception stack trace ---
         at Microsoft.SemanticKernel.TemplateEngine.Blocks.CodeBlock.RenderFunctionCallAsync(FunctionIdBlock fBlock, SKContext context) in C:\Users\hons\semantic-kernel-main\semantic-kernel-main\dotnet\src\SemanticKernel\TemplateEngine\Blocks\CodeBlock.cs:line 138
         at Microsoft.SemanticKernel.TemplateEngine.Blocks.CodeBlock.RenderCodeAsync(SKContext context) in C:\Users\hons\semantic-kernel-main\semantic-kernel-main\dotnet\src\SemanticKernel\TemplateEngine\Blocks\CodeBlock.cs:line 87
         at Microsoft.SemanticKernel.TemplateEngine.PromptTemplateEngine.RenderAsync(IList`1 blocks, SKContext context) in C:\Users\hons\semantic-kernel-main\semantic-kernel-main\dotnet\src\SemanticKernel\TemplateEngine\PromptTemplateEngine.cs:line 78
         at Microsoft.SemanticKernel.TemplateEngine.PromptTemplateEngine.RenderAsync(String templateText, SKContext context) in C:\Users\hons\semantic-kernel-main\semantic-kernel-main\dotnet\src\SemanticKernel\TemplateEngine\PromptTemplateEngine.cs:line 61
         at Microsoft.SemanticKernel.SemanticFunctions.PromptTemplate.RenderAsync(SKContext executionContext) in C:\Users\hons\semantic-kernel-main\semantic-kernel-main\dotnet\src\SemanticKernel\SemanticFunctions\PromptTemplate.cs:line 110
         at Microsoft.SemanticKernel.SkillDefinition.SKFunction.<>c__DisplayClass19_0.<<FromSemanticConfig>g__LocalFunc|0>d.MoveNext() in C:\Users\hons\semantic-kernel-main\semantic-kernel-main\dotnet\src\SemanticKernel\SkillDefinition\SKFunction.cs:line 142

sunhongyu0831 avatar May 15 '23 14:05 sunhongyu0831

Same here with the latest code from "main" branch. Windows and Mac are encountering the same error.

ychyjj avatar May 16 '23 07:05 ychyjj

webapi server: fail: Microsoft.SemanticKernel.IKernel[0] Function call fail during pipeline step 0: ChatSkill.Chat. Error: Runtime error: Function ChatSkill.ExtractUserMemories execution failed. Microsoft.SemanticKernel.AI.AIException: Invalid request: The request is not valid, HTTP status: 400

ychyjj avatar May 16 '23 07:05 ychyjj

Can you please confirm if the AI endpoint and key values are set in Embeddings section in appsettings.json:

 "Embedding": {
    "Label": "Embeddings",
    "AIService": "AzureOpenAI",
    "DeploymentOrModelId": "text-embedding-ada-002",
    "Endpoint": "<value>", // ignored when AIService is "OpenAI"
    "Key": "<value>"
  },

hathind-ms avatar May 16 '23 17:05 hathind-ms

Update: for the 404 error I mentioned above, it is because the embedding deployment/model id "text-embedding-ada-002" specified in the config had not been deployed in my Azure OAI resource. After deploying the model, I am able to setup and use the chat app successfully without any errors.

firelake avatar May 18 '23 07:05 firelake

In my case, the OpenAI deployment names are different from the model names, ie. "chatgpt-35-turbo". Then you have to change them to the deployment names in your WebApi's Configuration under AIService:Models:Completion, etc.

horans avatar Jun 28 '23 07:06 horans