@@ -19,14 +19,40 @@ pub enum Role {
19
19
Tool ,
20
20
}
21
21
22
+ #[ derive( Serialize , Deserialize , Debug , Clone ) ]
23
+ #[ serde( rename_all_fields( serialize = "lowercase" ) ) ]
24
+ pub enum RegexMode {
25
+ Search ,
26
+ Match ,
27
+ Fullmatch ,
28
+ Split ,
29
+ Findall ,
30
+ }
31
+
32
+ /// A regular expression parser
33
+ #[ derive( Serialize , Deserialize , Debug , Clone ) ]
34
+ pub struct RegexParser {
35
+ /// Regular expression to parse the value
36
+ pub regex : String ,
37
+
38
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
39
+ pub mode : Option < RegexMode > ,
40
+
41
+ /// Expected type of the parsed value
42
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
43
+ pub spec : Option < Value > ,
44
+ }
45
+
22
46
#[ derive( Serialize , Deserialize , Debug , Clone ) ]
23
47
pub enum PdlParser {
24
48
#[ serde( rename = "json" ) ]
25
49
Json ,
26
- /* #[serde(rename = "jsonl")]
27
- Jsonl,*/
50
+ #[ serde( rename = "jsonl" ) ]
51
+ Jsonl ,
28
52
#[ serde( rename = "yaml" ) ]
29
53
Yaml ,
54
+ #[ serde( untagged) ]
55
+ Regex ( RegexParser ) ,
30
56
}
31
57
32
58
#[ derive( Serialize , Deserialize , Debug , Clone ) ]
@@ -89,15 +115,26 @@ impl Timing {
89
115
#[ serde( default ) ]
90
116
#[ builder( setter( into, strip_option) , default ) ]
91
117
pub struct Metadata {
118
+ /// Documentation associated to the block
92
119
#[ serde( skip_serializing_if = "Option::is_none" ) ]
93
120
pub description : Option < String > ,
94
121
122
+ /// Set of definitions executed before the execution of the block
95
123
#[ serde( skip_serializing_if = "Option::is_none" ) ]
96
124
pub defs : Option < IndexMap < String , PdlBlock > > ,
97
125
126
+ /// Name of the variable used to store the result of the execution of the block
98
127
#[ serde( skip_serializing_if = "Option::is_none" ) ]
99
128
pub def : Option < String > ,
100
129
130
+ /// Indicate if the block contributes to the result and background context
131
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
132
+ pub contribute : Option < Vec < String > > , // TODO
133
+
134
+ /// Type specification of the result of the block
135
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
136
+ pub spec : Option < Value > ,
137
+
101
138
#[ serde( rename = "pdl__id" , skip_serializing_if = "Option::is_none" ) ]
102
139
pub pdl_id : Option < String > ,
103
140
@@ -284,11 +321,9 @@ pub struct ModelBlock {
284
321
pub input : Option < Box < PdlBlock > > ,
285
322
#[ serde( skip_serializing_if = "Option::is_none" ) ]
286
323
pub platform : Option < String > ,
287
- #[ serde( skip_serializing_if = "Option::is_none" ) ]
288
- #[ serde( rename = "modelResponse" ) ]
324
+ #[ serde( rename = "modelResponse" , skip_serializing_if = "Option::is_none" ) ]
289
325
pub model_response : Option < String > ,
290
- #[ serde( rename = "pdl__usage" ) ]
291
- #[ serde( skip_serializing_if = "Option::is_none" ) ]
326
+ #[ serde( rename = "pdl__usage" , skip_serializing_if = "Option::is_none" ) ]
292
327
pub pdl_usage : Option < PdlUsage > ,
293
328
294
329
/// The result of evaluating the `input` field (if given)
@@ -307,6 +342,37 @@ pub enum ListOrString {
307
342
List ( Vec < Value > ) ,
308
343
}
309
344
345
+ #[ derive( Serialize , Deserialize , Debug , Clone ) ]
346
+ pub enum IterationType {
347
+ #[ serde( rename = "lastOf" ) ]
348
+ LastOf ,
349
+ #[ serde( rename = "array" ) ]
350
+ Array ,
351
+ #[ serde( rename = "object" ) ]
352
+ Object ,
353
+ #[ serde( rename = "text" ) ]
354
+ Text ,
355
+ }
356
+
357
+ #[ derive( Serialize , Deserialize , Debug , Clone ) ]
358
+ pub struct JoinAs {
359
+ #[ serde( rename = "as" ) ]
360
+ as_ : IterationType ,
361
+ }
362
+ #[ derive( Serialize , Deserialize , Debug , Clone ) ]
363
+ pub struct JoinAsWith {
364
+ #[ serde( rename = "as" ) ]
365
+ as_ : IterationType ,
366
+ with : String ,
367
+ }
368
+
369
+ #[ derive( Serialize , Deserialize , Debug , Clone ) ]
370
+ #[ serde( untagged) ]
371
+ pub enum JoinType {
372
+ AsWith ( JoinAsWith ) ,
373
+ As ( JoinAs ) ,
374
+ }
375
+
310
376
/// Repeat the execution of a block.
311
377
///
312
378
/// For loop example:
@@ -326,6 +392,10 @@ pub struct RepeatBlock {
326
392
327
393
/// Body of the loop
328
394
pub repeat : Box < PdlBlock > ,
395
+
396
+ /// Define how to combine the result of each iteration
397
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
398
+ pub join : Option < JoinType > ,
329
399
}
330
400
331
401
/// Create a message
0 commit comments