Skip to content

Commit af7710a

Browse files
authored
feat(vertexai): Add HarmBlockThreshold.OFF (#17325)
* Add HarmBlockThreshold.OFF. Add unit test for api. Fix the schema output json. * fix a nit
1 parent b81fc0e commit af7710a

File tree

2 files changed

+760
-2
lines changed

2 files changed

+760
-2
lines changed

packages/firebase_vertexai/firebase_vertexai/lib/src/api.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,12 @@ enum HarmBlockThreshold {
591591
high('BLOCK_ONLY_HIGH'),
592592

593593
/// Always show regardless of probability of unsafe content.
594-
none('BLOCK_NONE');
594+
none('BLOCK_NONE'),
595+
596+
/// All content is allowed regardless of harm.
597+
///
598+
/// metadata will not be included in the response.
599+
off('OFF');
595600

596601
const HarmBlockThreshold(this._jsonString);
597602

@@ -602,6 +607,7 @@ enum HarmBlockThreshold {
602607
'BLOCK_MEDIUM_AND_ABOVE' => HarmBlockThreshold.medium,
603608
'BLOCK_ONLY_HIGH' => HarmBlockThreshold.high,
604609
'BLOCK_NONE' => HarmBlockThreshold.none,
610+
'OFF' => HarmBlockThreshold.off,
605611
_ => throw FormatException(
606612
'Unhandled HarmBlockThreshold format', jsonObject),
607613
};
@@ -797,7 +803,7 @@ final class GenerationConfig extends BaseGenerationConfig {
797803
if (responseMimeType case final responseMimeType?)
798804
'responseMimeType': responseMimeType,
799805
if (responseSchema case final responseSchema?)
800-
'responseSchema': responseSchema,
806+
'responseSchema': responseSchema.toJson(),
801807
};
802808
}
803809

0 commit comments

Comments
 (0)