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
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.
A clear and concise description of what the bug is.
To Reproduce
- run webapi
- run webapp
- go to http://localhost:3000/
- input the chat: How many planets are there in the solar system?
- See error: Unable to generate bot response. Details: Error: 400: => Runtime error: Function
ChatSkill.ExtractUserMemoriesexecution failed. Microsoft.SemanticKernel.AI.AIException: Invalid request: The request is not valid, HTTP status: 400
Screenshots
my appsetting.json
my webapi console
Desktop (please complete the following information):
- OS: Windows 10 64
- IDE: run on PowerShell
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
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
same issure here
Same here with the latest code from "main" branch.
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.
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
Same here with the latest code from "main" branch. Windows and Mac are encountering the same error.
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
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>"
},
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.
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.