-
Notifications
You must be signed in to change notification settings - Fork 12
Description
Hey,
While using the LangChain.dart package, which uses the openapi_spec package, I've noticed that if the OpenAI response includes characters in Hebrew or other languages with special characters - it results with "gibberish".
This is most probably due to client.dart > lines 883 and 896, where json.decode is done over r.body:
https://github.com/search?q=repo%3Atazatechnology%2Fopenapi_spec+json.decode%28r.body%29&type=code
It seems that due to this Dart issue:
dart-lang/http#789
The json.decode should be done with utf8.decode over the r.bodyBytes, in order to properly handle the UTF-8 chars:
if (s.ref != null || returnType.startsWith('Union')) {
decoder = "return $returnType.fromJson(json.decode(utf8.decode(r.bodyBytes)));";
} else {
decoder = """
final list = json.decode(utf8.decode(r.bodyBytes)) as List;
return list.map((e) => ${s.items.ref}.fromJson(e)).toList();
I've manually manipulated the generated client.dart file - and it resolved the problem.
However, unfortunately, due to lack of time I'm unable to test this properly and submit a Pull Request...
I hope the maintainers will have to take a look soon.