File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
packages/firebase_ai/firebase_ai Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -770,6 +770,9 @@ enum FinishReason {
770770 /// The candidate content was flagged for malformed function call reasons.
771771 malformedFunctionCall ('MALFORMED_FUNCTION_CALL' ),
772772
773+ /// The model produced an unexpected tool call.
774+ unexpectedToolCall ('UNEXPECTED_TOOL_CALL' ),
775+
773776 /// Unknown reason.
774777 other ('OTHER' );
775778
@@ -790,6 +793,7 @@ enum FinishReason {
790793 'RECITATION' => FinishReason .recitation,
791794 'OTHER' => FinishReason .other,
792795 'MALFORMED_FUNCTION_CALL' => FinishReason .malformedFunctionCall,
796+ 'UNEXPECTED_TOOL_CALL' => FinishReason .unexpectedToolCall,
793797 _ => throw FormatException ('Unhandled FinishReason format' , jsonObject),
794798 };
795799 }
Original file line number Diff line number Diff line change @@ -315,6 +315,7 @@ void main() {
315315 expect (FinishReason .recitation.toJson (), 'RECITATION' );
316316 expect (FinishReason .malformedFunctionCall.toJson (),
317317 'MALFORMED_FUNCTION_CALL' );
318+ expect (FinishReason .unexpectedToolCall.toJson (), 'UNEXPECTED_TOOL_CALL' );
318319 expect (FinishReason .other.toJson (), 'OTHER' );
319320 });
320321
@@ -1048,6 +1049,18 @@ void main() {
10481049 FinishReason .malformedFunctionCall);
10491050 });
10501051
1052+ test ('parses unexpectedToolCall finishReason' , () {
1053+ final jsonResponse = {
1054+ 'candidates' : [
1055+ {'finishReason' : 'UNEXPECTED_TOOL_CALL' }
1056+ ]
1057+ };
1058+ final response =
1059+ VertexSerialization ().parseGenerateContentResponse (jsonResponse);
1060+ expect (response.candidates.first.finishReason,
1061+ FinishReason .unexpectedToolCall);
1062+ });
1063+
10511064 test (
10521065 'parses groundingSupports and filters out entries without a segment' ,
10531066 () {
You can’t perform that action at this time.
0 commit comments