Skip to content

Commit 9c52287

Browse files
committed
Ignore safetyAttributes in response parsing
1 parent ab77e26 commit 9c52287

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,8 @@ export async function handlePredictResponse<
296296
mimeType: prediction.mimeType,
297297
gcsURI: prediction.gcsUri
298298
} as T);
299+
} else if (prediction.safetyAttributes) {
300+
// Ignore safetyAttributes "prediction" to avoid throwing an error below.
299301
} else {
300302
throw new AIError(
301303
AIErrorCode.RESPONSE_ERROR,

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ export interface ImagenResponseInternal {
6161
* The reason why the image was filtered.
6262
*/
6363
raiFilteredReason?: string;
64+
/**
65+
* The safety attributes.
66+
*
67+
* This type is currently unused in the SDK. It is sent back because our requests set
68+
* `includeSafetyAttributes`. This field is currently only used to avoid logging unsupported
69+
* prediction types.
70+
*/
71+
safetyAttributes?: unknown;
6472
}>;
6573
}
6674

0 commit comments

Comments
 (0)