google-gemini / generative-ai-dart

The official Dart library for the Google Gemini API
https://ai.google.dev/gemini-api/docs/get-started/tutorial?lang=dart
Apache License 2.0
543 stars 111 forks source link

Chinese will be garbled in function calling #186

Open andyli0123 opened 2 months ago

andyli0123 commented 2 months ago

Description of the bug:

  1. If the result contains Chinese, Gemini reads it as garbled. (always)

    response = await chat.sendMessage(Content.functionResponse(functionCall.name, result));
  2. Properties will also be garbled. (sometimes)

traditional-chinese

Actual vs expected behavior:

\350\230\213\346\236\234 should be 蘋果 \351\200\231\345\200\213\346\274\217\346\264\236\345\245\275\345\232\264\351\207\215 should be 這個漏洞好嚴重

Any other information you'd like to share?

Simulates a garbled situation in Python:

encoded_string = "\350\230\213\346\236\234"
decoded_string = encoded_string.encode('latin1').decode('utf-8')
print(decoded_string)
andyli0123 commented 1 month ago

Café will also become Caf\303\251.