File tree Expand file tree Collapse file tree 3 files changed +89
-0
lines changed Expand file tree Collapse file tree 3 files changed +89
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ const EmptyPartSchema = z.object({
28
28
metadata : z . record ( z . unknown ( ) ) . optional ( ) ,
29
29
custom : z . record ( z . unknown ( ) ) . optional ( ) ,
30
30
reasoning : z . never ( ) . optional ( ) ,
31
+ resource : z . never ( ) . optional ( ) ,
31
32
} ) ;
32
33
33
34
/**
@@ -147,6 +148,20 @@ export const CustomPartSchema = EmptyPartSchema.extend({
147
148
*/
148
149
export type CustomPart = z . infer < typeof CustomPartSchema > ;
149
150
151
+ /**
152
+ * Zod schema of a resource part.
153
+ */
154
+ export const ResourcePartSchema = EmptyPartSchema . extend ( {
155
+ resource : z . object ( {
156
+ uri : z . string ( ) ,
157
+ } ) ,
158
+ } ) ;
159
+
160
+ /**
161
+ * Resource part.
162
+ */
163
+ export type ResourcePart = z . infer < typeof ResourcePartSchema > ;
164
+
150
165
// Disclaimer: genkit/js/ai/document.ts defines the following schema, type pair
151
166
// as PartSchema and Part, respectively. genkit-tools cannot retain those names
152
167
// due to it clashing with similar schema in model.ts, and genkit-tools
Original file line number Diff line number Diff line change @@ -23,12 +23,14 @@ import {
23
23
TextPartSchema ,
24
24
ToolRequestPartSchema ,
25
25
ToolResponsePartSchema ,
26
+ ResourcePartSchema ,
26
27
type CustomPart ,
27
28
type DataPart ,
28
29
type MediaPart ,
29
30
type TextPart ,
30
31
type ToolRequestPart ,
31
32
type ToolResponsePart ,
33
+ type ResourcePart ,
32
34
} from './document' ;
33
35
export {
34
36
CustomPartSchema ,
@@ -37,12 +39,14 @@ export {
37
39
TextPartSchema ,
38
40
ToolRequestPartSchema ,
39
41
ToolResponsePartSchema ,
42
+ ResourcePartSchema ,
40
43
type CustomPart ,
41
44
type DataPart ,
42
45
type MediaPart ,
43
46
type TextPart ,
44
47
type ToolRequestPart ,
45
48
type ToolResponsePart ,
49
+ type ResourcePart ,
46
50
} ;
47
51
48
52
//
@@ -77,6 +81,7 @@ export const PartSchema = z.union([
77
81
DataPartSchema ,
78
82
CustomPartSchema ,
79
83
ReasoningPartSchema ,
84
+ ResourcePartSchema
80
85
] ) ;
81
86
82
87
/**
Original file line number Diff line number Diff line change 27
27
},
28
28
"reasoning" : {
29
29
"not" : {}
30
+ },
31
+ "resource" : {
32
+ "not" : {}
30
33
}
31
34
},
32
35
"required" : [
59
62
},
60
63
"reasoning" : {
61
64
"$ref" : " #/$defs/CustomPart/properties/reasoning"
65
+ },
66
+ "resource" : {
67
+ "$ref" : " #/$defs/CustomPart/properties/resource"
62
68
}
63
69
},
64
70
"additionalProperties" : false
118
124
},
119
125
"reasoning" : {
120
126
"$ref" : " #/$defs/CustomPart/properties/reasoning"
127
+ },
128
+ "resource" : {
129
+ "$ref" : " #/$defs/CustomPart/properties/resource"
121
130
}
122
131
},
123
132
"required" : [
166
175
},
167
176
"reasoning" : {
168
177
"type" : " string"
178
+ },
179
+ "resource" : {
180
+ "$ref" : " #/$defs/CustomPart/properties/resource"
169
181
}
170
182
},
171
183
"required" : [
172
184
" reasoning"
173
185
],
174
186
"additionalProperties" : false
175
187
},
188
+ "ResourcePart" : {
189
+ "type" : " object" ,
190
+ "properties" : {
191
+ "text" : {
192
+ "$ref" : " #/$defs/CustomPart/properties/text"
193
+ },
194
+ "media" : {
195
+ "$ref" : " #/$defs/CustomPart/properties/media"
196
+ },
197
+ "toolRequest" : {
198
+ "$ref" : " #/$defs/CustomPart/properties/toolRequest"
199
+ },
200
+ "toolResponse" : {
201
+ "$ref" : " #/$defs/CustomPart/properties/toolResponse"
202
+ },
203
+ "data" : {
204
+ "$ref" : " #/$defs/CustomPart/properties/data"
205
+ },
206
+ "metadata" : {
207
+ "$ref" : " #/$defs/CustomPart/properties/metadata"
208
+ },
209
+ "custom" : {
210
+ "$ref" : " #/$defs/DataPart/properties/custom"
211
+ },
212
+ "reasoning" : {
213
+ "$ref" : " #/$defs/CustomPart/properties/reasoning"
214
+ },
215
+ "resource" : {
216
+ "type" : " object" ,
217
+ "properties" : {
218
+ "uri" : {
219
+ "type" : " string"
220
+ }
221
+ },
222
+ "required" : [
223
+ " uri"
224
+ ],
225
+ "additionalProperties" : false
226
+ }
227
+ },
228
+ "required" : [
229
+ " resource"
230
+ ],
231
+ "additionalProperties" : false
232
+ },
176
233
"TextPart" : {
177
234
"type" : " object" ,
178
235
"properties" : {
199
256
},
200
257
"reasoning" : {
201
258
"$ref" : " #/$defs/CustomPart/properties/reasoning"
259
+ },
260
+ "resource" : {
261
+ "$ref" : " #/$defs/CustomPart/properties/resource"
202
262
}
203
263
},
204
264
"required" : [
232
292
},
233
293
"reasoning" : {
234
294
"$ref" : " #/$defs/CustomPart/properties/reasoning"
295
+ },
296
+ "resource" : {
297
+ "$ref" : " #/$defs/CustomPart/properties/resource"
235
298
}
236
299
},
237
300
"required" : [
281
344
},
282
345
"reasoning" : {
283
346
"$ref" : " #/$defs/CustomPart/properties/reasoning"
347
+ },
348
+ "resource" : {
349
+ "$ref" : " #/$defs/CustomPart/properties/resource"
284
350
}
285
351
},
286
352
"required" : [
1138
1204
},
1139
1205
{
1140
1206
"$ref" : " #/$defs/ReasoningPart"
1207
+ },
1208
+ {
1209
+ "$ref" : " #/$defs/ResourcePart"
1141
1210
}
1142
1211
]
1143
1212
},
You can’t perform that action at this time.
0 commit comments