Open
Description
Description of the Issue:
When using the methods streamChat
, streamGenerateContent
, and promptStream
, the output is missing spaces between words, causing words to be concatenated incorrectly.
Example:
- Expected output:
"Hello World"
- Actual output:
"HelloWorld"
Location of the Issue:
File: gemini_implement.dart
Current code:
res = res.trim();
if (index == 0 && res.startsWith("[")) {
res = res.replaceFirst('[', '');
}
if (res.startsWith(',')) {
res = res.replaceFirst(',', '');
}
if (res.endsWith(']')) {
res = res.substring(0, res.length - 1);
}
res = res.trim();
Proposed Fix:
Use a separate variable (trimmedRes) to check conditions before modifying res, preventing unintended modifications that could cause words to be concatenated incorrectly:
String trimmedRes = res.trim();
if (index == 0 && trimmedRes.startsWith("[")) {
res = res.replaceFirst('[', '');
}
if (trimmedRes.startsWith(',')) {
res = res.replaceFirst(',', '');
}
if (trimmedRes.endsWith(']')) {
res = res.substring(0, res.length - 1);
}
Metadata
Metadata
Assignees
Labels
No labels