File tree Expand file tree Collapse file tree 6 files changed +31
-0
lines changed
py/packages/genkit/src/genkit/core Expand file tree Collapse file tree 6 files changed +31
-0
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 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" : {}
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change @@ -21,6 +21,9 @@ export type PredictMethod = 'predict' | 'predictLongRunning';
2121export interface Operation {
2222 name : string ;
2323 done ?: boolean ;
24+ error ?: {
25+ message : string ;
26+ } ,
2427 response ?: {
2528 generateVideoResponse : {
2629 generatedSamples : { video : { uri : string } } [ ] ;
Original file line number Diff line number Diff 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 &&
Original file line number Diff line number Diff 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+
291298class 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
You can’t perform that action at this time.
0 commit comments