microsoft / semantic-kernel

Integrate cutting-edge LLM technology quickly and easily into your apps
https://aka.ms/semantic-kernel
MIT License
21.31k stars 3.13k forks source link

Error: Invalid request: The request is not valid, HTTP status: 404 for all ".InvokeAsync" #1539

Closed Ofer-Gal closed 1 year ago

Ofer-Gal commented 1 year ago

Describe the bug In any C# notebook if step has ".InvokeAsync" It errors with "Error: Invalid request: The request is not valid, HTTP status: 404"

Desktop (please complete the following information):

Thank you

teresaqhoang commented 1 year ago

Hey @Ofer-Gal, a 404 typically indicates that you haven't configured your AI settings right.

Can you verify that you have a settings.json file under the /samples/notebooks/dotnet/config directory?

It should look like this but populated with your correct values. { "type": "", "model": "", "endpoint": "", "apikey": "", "org": "" }

Also, the Jupyter notebooks still use TextCompletion models (as opposed to ChatCompletion models), so make sure you're using a supported model, typically this is text-davinci-003.

teresaqhoang commented 1 year ago

You can also verify that everything is populated correctly by looking at the Notebook variables:

Just click on the Variables button at the top of the Notebook in VSCode Image

And it should open a tab in terminal. Your variables should be populated as follows after you run the InvokeAsync function (this is from Notebook 02-running-prompts-from-file) Image

Ofer-Gal commented 1 year ago

text-davinci-003

I changed the model in settings.json to text-davinci-003 and the results came back. Thank you. But the next section #!set --value @csharp:result --name result caused the error you see bellow. What does this statement do?

Error: System.NotSupportedException: Serialization and deserialization of 'System.IntPtr' instances are not supported. Path: $.CancellationToken.WaitHandle.Handle.
---> System.NotSupportedException: Serialization and deserialization of 'System.IntPtr' instances are not supported.
at System.Text.Json.Serialization.Converters.UnsupportedTypeConverter`1.Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
at System.Text.Json.Serialization.JsonConverter`1.TryWrite(Utf8JsonWriter writer, T& value, JsonSerializerOptions options, WriteStack& state)
at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.GetMemberAndWriteJson(Object obj, WriteStack& state, Utf8JsonWriter writer)
at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryWrite(Utf8JsonWriter writer, T value, JsonSerializerOptions options, WriteStack& state)
at System.Text.Json.Serialization.JsonConverter`1.TryWrite(Utf8JsonWriter writer, T& value, JsonSerializerOptions options, WriteStack& state)
at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.GetMemberAndWriteJson(Object obj, WriteStack& state, Utf8JsonWriter writer)
at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryWrite(Utf8JsonWriter writer, T value, JsonSerializerOptions options, WriteStack& state)
at System.Text.Json.Serialization.JsonConverter`1.TryWrite(Utf8JsonWriter writer, T& value, JsonSerializerOptions options, WriteStack& state)
at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.GetMemberAndWriteJson(Object obj, WriteStack& state, Utf8JsonWriter writer)
at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryWrite(Utf8JsonWriter writer, T value, JsonSerializerOptions options, WriteStack& state)
at System.Text.Json.Serialization.JsonConverter`1.TryWrite(Utf8JsonWriter writer, T& value, JsonSerializerOptions options, WriteStack& state)
at System.Text.Json.Serialization.JsonConverter`1.WriteCore(Utf8JsonWriter writer, T& value, JsonSerializerOptions options, WriteStack& state)
--- End of inner exception stack trace ---
at System.Text.Json.ThrowHelper.ThrowNotSupportedException(WriteStack& state, NotSupportedException ex)
at System.Text.Json.Serialization.JsonConverter`1.WriteCore(Utf8JsonWriter writer, T& value, JsonSerializerOptions options, WriteStack& state)
at System.Text.Json.Serialization.JsonConverter`1.WriteCoreAsObject(Utf8JsonWriter writer, Object value, JsonSerializerOptions options, WriteStack& state)
at System.Text.Json.JsonSerializer.WriteCore[TValue](Utf8JsonWriter writer, TValue& value, JsonTypeInfo`1 jsonTypeInfo)
at System.Text.Json.JsonSerializer.WriteString[TValue](TValue& value, JsonTypeInfo`1 jsonTypeInfo)
at System.Text.Json.JsonSerializer.Serialize[TValue](TValue value, JsonSerializerOptions options)
at Microsoft.DotNet.Interactive.Formatting.JsonFormatter`1.<.ctor>g__FormatInstance|2_0(T instance, FormatContext context) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive.Formatting\JsonFormatter{T}.cs:line 24
at Microsoft.DotNet.Interactive.Formatting.JsonFormatter`1.Format(T instance, FormatContext context) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive.Formatting\JsonFormatter{T}.cs:line 15
at Microsoft.DotNet.Interactive.Formatting.Formatter.Format(ITypeFormatter formatter, Object instance, TextWriter writer) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive.Formatting\Formatter.cs:line 292
at Microsoft.DotNet.Interactive.KernelInvocationContextExtensions.PublishValueProduced(KernelInvocationContext context, RequestValue requestValue, Object value) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive\KernelInvocationContextExtensions.cs:line 115
at Microsoft.DotNet.Interactive.CSharp.CSharpKernel.Microsoft.DotNet.Interactive.IKernelCommandHandler<Microsoft.DotNet.Interactive.Commands.RequestValue>.HandleAsync(RequestValue command, KernelInvocationContext context) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive.CSharp\CSharpKernel.cs:line 145
at Microsoft.DotNet.Interactive.Kernel.<>c__DisplayClass82_0`1.<SetHandler>b__0(KernelCommand _, KernelInvocationContext context) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive\Kernel.cs:line 876
at Microsoft.DotNet.Interactive.Kernel.HandleAsync(KernelCommand command, KernelInvocationContext context) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive\Kernel.cs:line 328
at Microsoft.DotNet.Interactive.KernelCommandPipeline.<BuildPipeline>b__6_0(KernelCommand command, KernelInvocationContext context, KernelPipelineContinuation _) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive\KernelCommandPipeline.cs:line 60
at Microsoft.DotNet.Interactive.KernelCommandPipeline.SendAsync(KernelCommand command, KernelInvocationContext context) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive\KernelCommandPipeline.cs:line 51
teresaqhoang commented 1 year ago

@Ofer-Gal What notebook are you in? Can you share a screenshot of the current failing steps, its output, as well as the state of the step before it?

Also, what kernel are you using to run the notebooks, .NET Interactive?

Ofer-Gal commented 1 year ago

00-getting started The state before was successful using .NET Interactive yes

image

teresaqhoang commented 1 year ago

@Ofer-Gal I think you may have added that section accidentally, as we don't have that in our samples: https://github.com/microsoft/semantic-kernel/blob/main/samples/notebooks/dotnet/00-getting-started.ipynb

You can either delete that section altogether, or if you don't have any other changes, you can reset the repo state by:

  1. git checkout main
  2. git restore . Then you should have a fresh slate to run the notebooks!
Ofer-Gal commented 1 year ago

Thanks