-
Notifications
You must be signed in to change notification settings - Fork 4.1k
feat(firebaseai): ImageConfig and FinishReasons #18180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 3 commits
332475f
ed5379b
63c7faa
e100011
00e35fa
669967d
cce4f9b
4c863d9
58e14e8
a6c9495
5102dc5
9186c82
174f0a8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -315,9 +315,55 @@ void main() { | |
| expect(FinishReason.recitation.toJson(), 'RECITATION'); | ||
| expect(FinishReason.malformedFunctionCall.toJson(), | ||
| 'MALFORMED_FUNCTION_CALL'); | ||
| expect(FinishReason.blocklist.toJson(), 'BLOCKLIST'); | ||
| expect(FinishReason.prohibitedContent.toJson(), 'PROHIBITED_CONTENT'); | ||
| expect(FinishReason.spii.toJson(), 'SPII'); | ||
| expect(FinishReason.imageSafety.toJson(), 'IMAGE_SAFETY'); | ||
| expect(FinishReason.imageProhibitedContent.toJson(), | ||
| 'IMAGE_PROHIBITED_CONTENT'); | ||
| expect(FinishReason.imageOther.toJson(), 'IMAGE_OTHER'); | ||
| expect(FinishReason.noImage.toJson(), 'NO_IMAGE'); | ||
| expect(FinishReason.imageRecitation.toJson(), 'IMAGE_RECITATION'); | ||
| expect(FinishReason.language.toJson(), 'LANGUAGE'); | ||
| expect(FinishReason.unexpectedToolCall.toJson(), 'UNEXPECTED_TOOL_CALL'); | ||
| expect(FinishReason.tooManyToolCalls.toJson(), 'TOO_MANY_TOOL_CALLS'); | ||
| expect(FinishReason.missingThoughtSignature.toJson(), | ||
| 'MISSING_THOUGHT_SIGNATURE'); | ||
| expect(FinishReason.malformedResponse.toJson(), 'MALFORMED_RESPONSE'); | ||
| expect(FinishReason.other.toJson(), 'OTHER'); | ||
| }); | ||
|
|
||
| test('FinishReason parseValue', () { | ||
| expect(FinishReason.parseValue('STOP'), FinishReason.stop); | ||
| expect(FinishReason.parseValue('MAX_TOKENS'), FinishReason.maxTokens); | ||
| expect(FinishReason.parseValue('SAFETY'), FinishReason.safety); | ||
| expect(FinishReason.parseValue('RECITATION'), FinishReason.recitation); | ||
| expect(FinishReason.parseValue('MALFORMED_FUNCTION_CALL'), | ||
| FinishReason.malformedFunctionCall); | ||
| expect(FinishReason.parseValue('BLOCKLIST'), FinishReason.blocklist); | ||
| expect(FinishReason.parseValue('PROHIBITED_CONTENT'), | ||
| FinishReason.prohibitedContent); | ||
| expect(FinishReason.parseValue('SPII'), FinishReason.spii); | ||
| expect(FinishReason.parseValue('IMAGE_SAFETY'), FinishReason.imageSafety); | ||
| expect(FinishReason.parseValue('IMAGE_PROHIBITED_CONTENT'), | ||
| FinishReason.imageProhibitedContent); | ||
| expect(FinishReason.parseValue('IMAGE_OTHER'), FinishReason.imageOther); | ||
| expect(FinishReason.parseValue('NO_IMAGE'), FinishReason.noImage); | ||
| expect(FinishReason.parseValue('IMAGE_RECITATION'), | ||
| FinishReason.imageRecitation); | ||
| expect(FinishReason.parseValue('LANGUAGE'), FinishReason.language); | ||
| expect(FinishReason.parseValue('UNEXPECTED_TOOL_CALL'), | ||
| FinishReason.unexpectedToolCall); | ||
| expect(FinishReason.parseValue('TOO_MANY_TOOL_CALLS'), | ||
| FinishReason.tooManyToolCalls); | ||
| expect(FinishReason.parseValue('MISSING_THOUGHT_SIGNATURE'), | ||
| FinishReason.missingThoughtSignature); | ||
| expect(FinishReason.parseValue('MALFORMED_RESPONSE'), | ||
| FinishReason.malformedResponse); | ||
| expect(FinishReason.parseValue('OTHER'), FinishReason.other); | ||
| expect(FinishReason.parseValue('UNSPECIFIED'), FinishReason.unknown); | ||
| }); | ||
|
|
||
| test('ContentModality toJson and toString', () { | ||
| expect(ContentModality.unspecified.toJson(), 'MODALITY_UNSPECIFIED'); | ||
| expect(ContentModality.text.toJson(), 'TEXT'); | ||
|
|
@@ -439,10 +485,34 @@ void main() { | |
| }); | ||
| }); | ||
|
|
||
| group('ImageConfig', () { | ||
| test('toJson with all fields', () { | ||
| final config = ImageConfig( | ||
|
paulb777 marked this conversation as resolved.
Outdated
|
||
| aspectRatio: ImageAspectRatio.portrait9x16, | ||
| imageSize: ImageSize.size2K, | ||
| ); | ||
| expect(config.toJson(), { | ||
| 'aspectRatio': '9:16', | ||
| 'imageSize': '2K', | ||
| }); | ||
| }); | ||
|
|
||
| test('toJson with some fields null', () { | ||
| final config = ImageConfig( | ||
|
paulb777 marked this conversation as resolved.
Outdated
|
||
| aspectRatio: ImageAspectRatio.landscape16x9, | ||
| ); | ||
| expect(config.toJson(), { | ||
| 'aspectRatio': '16:9', | ||
| }); | ||
| }); | ||
| }); | ||
|
Comment on lines
+489
to
+509
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The repository style guide (line 69) recommends using References
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keeping |
||
|
|
||
| group('GenerationConfig & BaseGenerationConfig', () { | ||
| test('GenerationConfig toJson with all fields', () { | ||
| final schema = Schema.object(properties: {}); | ||
| final thinkingConfig = ThinkingConfig(thinkingBudget: 100); | ||
| final imageConfig = ImageConfig( | ||
| aspectRatio: ImageAspectRatio.square1x1, imageSize: ImageSize.size1K); | ||
|
paulb777 marked this conversation as resolved.
Outdated
|
||
| final config = GenerationConfig( | ||
| candidateCount: 1, | ||
| stopSequences: ['\n', 'stop'], | ||
|
|
@@ -455,6 +525,7 @@ void main() { | |
| responseMimeType: 'application/json', | ||
| responseSchema: schema, | ||
| thinkingConfig: thinkingConfig, | ||
| imageConfig: imageConfig, | ||
| ); | ||
| expect(config.toJson(), { | ||
| 'candidateCount': 1, | ||
|
|
@@ -468,6 +539,10 @@ void main() { | |
| 'responseMimeType': 'application/json', | ||
| 'responseSchema': schema.toJson(), | ||
| 'thinkingConfig': {'thinkingBudget': 100}, | ||
| 'imageConfig': { | ||
| 'aspectRatio': '1:1', | ||
| 'imageSize': '1K', | ||
| }, | ||
| }); | ||
| }); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.