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

'<' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0 while calling CreateEmbedding api #427

Closed
shadakshari-s opened this issue Nov 17, 2023 · 5 comments

Comments

@shadakshari-s
Copy link

Hi Team,

Need your help in resolving below error.

Error: '<' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0.

Stack Trace: [Error] at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, JsonReaderException ex) at System.Text.Json.Serialization.JsonConverter 1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state) at System.Text.Json.JsonSerializer.ReadCore[TValue](JsonConverter jsonConverter, Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state) at System.Text.Json.JsonSerializer.ReadCore[TValue](JsonReaderState& readerState, Boolean isFinalBlock, ReadOnlySpan 1 buffer, JsonSerializerOptions options, ReadStack& state, JsonConverter converterBase) at System.Text.Json.JsonSerializer.ContinueDeserialize[TValue](ReadBufferState& bufferState, JsonReaderState& jsonReaderState, ReadStack& readStack, JsonConverter converter, JsonSerializerOptions options) at System.Text.Json.JsonSerializer.ReadAllAsync[TValue](Stream utf8Json, JsonTypeInfo jsonTypeInfo, CancellationToken cancellationToken) at System.Net.Http.Json.HttpContentJsonExtensions.ReadFromJsonAsyncCore[T](HttpContent content, Encoding sourceEncoding, JsonSerializerOptions options, CancellationToken cancellationToken) at OpenAI.Extensions.HttpClientExtensions.PostAndReadAsAsync[TResponse](HttpClient client, String uri, Object requestModel, CancellationToken cancellationToken) at OpenAI.Managers.OpenAIService.CreateEmbedding(EmbeddingCreateRequest createEmbeddingRequest, CancellationToken cancellationToken)

When I debug locally everything is fine.
But, when I access the code deployed as Azure Function, I am receiving above mentioned error.

Here is the code excerpt:
var result = await _gpt3.CreateEmbedding(new OpenAI.GPT3.ObjectModels.RequestModels.EmbeddingCreateRequest() { Input = text, Model = _config[SettingPropertyNames.gptEmbeddingModel] });

_gpt3 is an instance of OpenAI.GPT3.Managers.OpenAIService.

Regards
Shadakshari

@xbaha
Copy link

xbaha commented Nov 17, 2023

looks like similar to issue #408 , how many tokens was your prompt?

@shadakshari-s
Copy link
Author

looks like similar to issue #408 , how many tokens was your prompt?

It is a simple prompt: when CI/CD pipeline will begin to run?

@belaszalontai
Copy link
Contributor

Most probably the response you are receiving is html instead of actual JSON format for the endpoint you are requesting. Please check that.
An as HTML usually starts with tag, the JSON validator fails on the very first character.
You should also clear any cache, that might be interfering with the returned data. (this has helped people resolve this same issue)

Source: https://stackoverflow.com/questions/61487289/exception-is-an-invalid-start-of-a-value

@shadakshari-s
Copy link
Author

Most probably the response you are receiving is html instead of actual JSON format for the endpoint you are requesting. Please check that. An as HTML usually starts with tag, the JSON validator fails on the very first character. You should also clear any cache, that might be interfering with the returned data. (this has helped people resolve this same issue)

Source: https://stackoverflow.com/questions/61487289/exception-is-an-invalid-start-of-a-value

Thank you.
But the error is occurring in Betalgo package which I don't have control over.
Please refer to the stack trace.

@shadakshari-s
Copy link
Author

Thank you all for your support.

Found the root cause: it is something to do with application's IP origin country.
Please check this OpenAI forum discussion: https://community.openai.com/t/api-access-failed-showing-cloudflare-block-page/506015/21

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

3 participants