Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 #904

Closed
Julian-Chou opened this issue May 10, 2023 · 10 comments
Assignees

Comments

@Julian-Chou
Copy link

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
@firelake
Copy link

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

@LeonCai1
Copy link

same issure here

@minzhang
Copy link

minzhang commented May 12, 2023

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

@minzhang
Copy link

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.

@sunhongyu0831
Copy link

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

@ychyjj
Copy link

ychyjj commented May 16, 2023

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

@ychyjj
Copy link

ychyjj commented May 16, 2023

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

@hathind-ms
Copy link
Contributor

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>"
  },

@firelake
Copy link

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.

@horans
Copy link

horans commented Jun 28, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

11 participants