openai
openai copied to clipboard
why createStream silently ignored the potenital json decode error ?
trafficstars
Hi,
I'm wondering why this potienital json decode be ignored:
https://github.com/anasfik/openai/blob/650ffbf93961962fec1554ba817c07d9700e2002/lib/src/core/networking/client.dart#L390-L392
I'm using a Microsoft Azure provided openai services behand a cloudflare worker. when I misspelled the model name, I got a 403 response which body is not a valid json. In this case,I am unable to get either the data or the error message.
Is it possible to change here to this:
try {
decodedData = decodeToMap(respondData);
} catch (error) {
final statusCode = respond.statusCode;
final exception = RequestFailedException(error.toString(), statusCode);
yield* Stream<T>.error(exception);
}