rosarioOriginal post
Rank 2: Process
Hello guys,
I run an execution Execution execution = await functions.getExecution( functionId: functionId, executionId: executionId); which call the Completation Chat API from OpenAI.
Since it took more than 30 seconds and I got the error Operation timed out after 30000 milliseconds
So I defined an async function:
`Execution result = await functions.createExecution(
functionId: '65fd719a000f460e4896',
body: body,
method: 'POST',
headers: headers,
xasync: true);
var executionId = result.$id;
Execution execution = await functions.getExecution(
functionId:functionId, executionId: executionId);
while (
execution.status == 'waiting' || execution.status == 'processing') {
await Future.delayed(Duration(seconds: 5));
execution = await functions.getExecution(
functionId: functionId, executionId: executionId);
}`
The function is completed but I get the following error FormatException: SyntaxError: Unexpected end of JSON input
print(result.responseBody); does not print anything but I can see in the Admin console the body printed which is a valid JSON.
Why do I have the problem?
Summary
Developers are encountering a `FormatException` with the message `SyntaxError: Unexpected end of JSON input` when trying to utilize the Completation Chat API from OpenAI. This occurs despite receiving a valid JSON response. The issue might be due to asynchronous operations.
Possible Solution:
Make sure that the API response is being fully received before attempting to parse it. Consider checking the response content length or using a delay to allow for the complete reception of JSON data before processing it.