Skip to content

Commit e5eb617

Browse files
committed
errors
1 parent b645388 commit e5eb617

File tree

6 files changed

+31
-0
lines changed

6 files changed

+31
-0
lines changed

genkit-tools/common/src/types/model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export const OperationSchema = z.object({
5757
id: z.string(),
5858
done: z.boolean().optional(),
5959
output: z.any().optional(),
60+
error: z.object({message: z.string()}).passthrough().optional(),
6061
metadata: z.record(z.string(), z.any()).optional(),
6162
});
6263

genkit-tools/genkit-schema.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,6 +1075,18 @@
10751075
"type": "boolean"
10761076
},
10771077
"output": {},
1078+
"error": {
1079+
"type": "object",
1080+
"properties": {
1081+
"message": {
1082+
"type": "string"
1083+
}
1084+
},
1085+
"required": [
1086+
"message"
1087+
],
1088+
"additionalProperties": true
1089+
},
10781090
"metadata": {
10791091
"type": "object",
10801092
"additionalProperties": {}

js/core/src/background-action.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export const OperationSchema = z.object({
3030
id: z.string(),
3131
done: z.boolean().optional(),
3232
output: z.any().optional(),
33+
error: z.object({ message: z.string() }).passthrough().optional(),
3334
metadata: z.record(z.string(), z.any()).optional(),
3435
});
3536

@@ -41,6 +42,7 @@ export interface Operation<O = any> {
4142
id: string;
4243
done?: boolean;
4344
output?: O;
45+
error?: { message: string; [key: string]: unknown };
4446
metadata?: Record<string, any>;
4547
}
4648

js/plugins/googleai/src/predict.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ export type PredictMethod = 'predict' | 'predictLongRunning';
2121
export interface Operation {
2222
name: string;
2323
done?: boolean;
24+
error?: {
25+
message: string;
26+
},
2427
response?: {
2528
generateVideoResponse: {
2629
generatedSamples: { video: { uri: string } }[];

js/plugins/googleai/src/veo.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,11 @@ function toGenkitOp(apiOp: ApiOperation): Operation<GenerateResponseData> {
178178
if (apiOp.done !== undefined) {
179179
res.done = apiOp.done;
180180
}
181+
182+
if (apiOp.error) {
183+
res.error = { message: apiOp.error.message };
184+
}
185+
181186
if (
182187
apiOp.response &&
183188
apiOp.response.generateVideoResponse &&

py/packages/genkit/src/genkit/core/typing.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,13 @@ class ModelInfo(BaseModel):
288288
stage: Stage | None = None
289289

290290

291+
class Error(BaseModel):
292+
"""Model for error data."""
293+
294+
model_config = ConfigDict(extra='forbid', populate_by_name=True)
295+
message: str
296+
297+
291298
class Operation(BaseModel):
292299
"""Model for operation data."""
293300

@@ -296,6 +303,7 @@ class Operation(BaseModel):
296303
id: str
297304
done: bool | None = None
298305
output: Any | None = None
306+
error: Error | None = None
299307
metadata: dict[str, Any] | None = None
300308

301309

0 commit comments

Comments
 (0)