Skip to content

Commit

Permalink
Solving the "Please ensure that function call turn comes immediately …
Browse files Browse the repository at this point in the history
…after a user turn or after a function response turn." problem #53 #56
  • Loading branch information
MrCsabaToth committed Sep 30, 2024
1 parent 58cb75d commit 6651151
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/ai/service/ai_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ class AiService with FirebaseMixin, ToolsMixin {
}

List<FunctionCall> functionCalls;
var content = Content.text('');
while ((functionCalls = response.functionCalls.toList()).isNotEmpty) {
final responses = <FunctionResponse>[];
for (final functionCall in functionCalls) {
Expand All @@ -281,11 +280,10 @@ class AiService with FirebaseMixin, ToolsMixin {
}
}

content = response.candidates.first.content;
content.parts.addAll(responses);
message.parts.addAll(responses);
// TODO(MrCsabaToth): Store in history?
try {
response = await chat.sendMessage(content);
response = await chat.sendMessage(message);
} catch (e) {
log('Exception during function iteration chat.sendMessage: $e');
return null;
Expand Down

0 comments on commit 6651151

Please sign in to comment.