File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
packages/firebase_ai/firebase_ai Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -751,6 +751,9 @@ enum FinishReason {
751751 /// The candidate content was flagged for recitation reasons.
752752 recitation ('RECITATION' ),
753753
754+ /// The candidate content was flagged for malformed function call reasons.
755+ malformedFunctionCall ('MALFORMED_FUNCTION_CALL' ),
756+
754757 /// Unknown reason.
755758 other ('OTHER' );
756759
@@ -770,6 +773,7 @@ enum FinishReason {
770773 'SAFETY' => FinishReason .safety,
771774 'RECITATION' => FinishReason .recitation,
772775 'OTHER' => FinishReason .other,
776+ 'MALFORMED_FUNCTION_CALL' => FinishReason .malformedFunctionCall,
773777 _ => throw FormatException ('Unhandled FinishReason format' , jsonObject),
774778 };
775779 }
Original file line number Diff line number Diff line change @@ -312,6 +312,8 @@ void main() {
312312 expect (FinishReason .maxTokens.toJson (), 'MAX_TOKENS' );
313313 expect (FinishReason .safety.toJson (), 'SAFETY' );
314314 expect (FinishReason .recitation.toJson (), 'RECITATION' );
315+ expect (FinishReason .malformedFunctionCall.toJson (),
316+ 'MALFORMED_FUNCTION_CALL' );
315317 expect (FinishReason .other.toJson (), 'OTHER' );
316318 });
317319
@@ -973,6 +975,18 @@ void main() {
973975 (e) => e.message, 'message' , contains ('WebGroundingChunk' ))));
974976 });
975977
978+ test ('parses malformedFunctionCall finishReason' , () {
979+ final jsonResponse = {
980+ 'candidates' : [
981+ {'finishReason' : 'MALFORMED_FUNCTION_CALL' }
982+ ]
983+ };
984+ final response =
985+ VertexSerialization ().parseGenerateContentResponse (jsonResponse);
986+ expect (response.candidates.first.finishReason,
987+ FinishReason .malformedFunctionCall);
988+ });
989+
976990 test (
977991 'parses groundingSupport and filters out entries without a segment' ,
978992 () {
You can’t perform that action at this time.
0 commit comments