Skip to content

Commit ab77e26

Browse files
committed
fix(ai): Add 'includeSafetyAttributes' to Predict request payloads
1 parent 2058432 commit ab77e26

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

.changeset/good-cooks-deliver.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@firebase/ai': patch
3+
---
4+
5+
Add 'includeSafetyAttributes' field to Predict request payloads.

packages/ai/src/requests/request-helpers.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ describe('request formatting methods', () => {
214214
expect(body.instances[0].prompt).to.equal(prompt);
215215
expect(body.parameters.sampleCount).to.equal(1);
216216
expect(body.parameters.includeRaiReason).to.be.true;
217+
expect(body.parameters.includeSafetyAttributes).to.be.true;
217218

218219
// Parameters without default values should be undefined
219220
expect(body.parameters.storageUri).to.be.undefined;
@@ -258,6 +259,7 @@ describe('request formatting methods', () => {
258259
personGeneration: safetySettings.personFilterLevel,
259260
aspectRatio,
260261
includeRaiReason: true,
262+
includeSafetyAttributes: true,
261263
storageUri: undefined
262264
});
263265
});

packages/ai/src/requests/request-helpers.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ export function createPredictRequestBody(
156156
addWatermark,
157157
safetyFilterLevel,
158158
personGeneration: personFilterLevel,
159-
includeRaiReason: true
159+
includeRaiReason: true,
160+
includeSafetyAttributes: true
160161
}
161162
};
162163
return body;

packages/ai/src/types/imagen/internal.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export interface ImagenResponseInternal {
8484
* "personGeneration": "allow_all",
8585
* "sampleCount": 2,
8686
* "includeRaiReason": true,
87+
* "includeSafetyAttributes": true,
8788
* "aspectRatio": "9:16"
8889
* }
8990
* }
@@ -111,6 +112,7 @@ export interface PredictRequestBody {
111112
safetyFilterLevel?: string;
112113
personGeneration?: string; // Maps to personFilterLevel
113114
includeRaiReason: boolean;
115+
includeSafetyAttributes: boolean;
114116
};
115117
}
116118

0 commit comments

Comments
 (0)