diff --git a/.github/actions/ollama/action.yml b/.github/actions/ollama/action.yml index 9af8b4fa0..841890b13 100644 --- a/.github/actions/ollama/action.yml +++ b/.github/actions/ollama/action.yml @@ -20,6 +20,7 @@ runs: run: | ollama pull granite3.2:2b ollama pull granite3.2:8b + ollama pull granite3.3:2b ollama pull granite3.3:8b ollama pull mxbai-embed-large ollama list diff --git a/examples/aggregators/contribute_in_file.pdl b/examples/aggregators/contribute_in_file.pdl new file mode 100644 index 000000000..4cb7bbcb4 --- /dev/null +++ b/examples/aggregators/contribute_in_file.pdl @@ -0,0 +1,20 @@ +defs: + log: + aggregator: + file: /tmp/log.txt +text: +- Hello +- model: ollama_chat/granite3.3:2b + parameters: + temperature: 0 + contribute: [ result, context, log ] +- nice to meet you. +- model: ollama_chat/granite3.3:2b + parameters: + temperature: 0 + modelResponse: raw_response + contribute: + - result + - log: + value: ${raw_response} +- Bye diff --git a/examples/aggregators/contribute_in_stderr.pdl b/examples/aggregators/contribute_in_stderr.pdl new file mode 100644 index 000000000..83faf41de --- /dev/null +++ b/examples/aggregators/contribute_in_stderr.pdl @@ -0,0 +1,10 @@ +text: +- Hello +- text: Before model call + contribute: [ stderr ] +- model: ollama_chat/granite3.3:2b + parameters: + temperature: 0 +- contribute: + - stderr: + value: After model call diff --git a/examples/aggregators/contribute_in_stdout.pdl b/examples/aggregators/contribute_in_stdout.pdl new file mode 100644 index 000000000..fed5cfc47 --- /dev/null +++ b/examples/aggregators/contribute_in_stdout.pdl @@ -0,0 +1,10 @@ +text: +- Hello +- text: Before model call + contribute: [ stdout ] +- model: ollama_chat/granite3.3:2b + parameters: + temperature: 0 +- contribute: + - stdout: + value: After model call diff --git a/pdl-live-react/src/pdl_ast.d.ts b/pdl-live-react/src/pdl_ast.d.ts index f15502b41..332b3b437 100644 --- a/pdl-live-react/src/pdl_ast.d.ts +++ b/pdl-live-react/src/pdl_ast.d.ts @@ -32,6 +32,7 @@ export type Program = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -167,6 +168,11 @@ export type Description19 = string | null * */ export type Description20 = string | null +/** + * Documentation associated to the block. + * + */ +export type Description21 = string | null /** * Name of the variable used to store the result of the execution of the block. * @@ -175,16 +181,14 @@ export type Def = string | null /** * Values allowed in the `contribute` field. */ -export type ContributeTarget = "result" | "context" -export type Value = LocalizedExpression | unknown[] | string -export type Path = string[] -export type File = string +export type ContributeTarget = "result" | "context" | "stdout" | "stderr" /** * Indicate if the block contributes to the result and background context. * */ export type Contribute = ( | ContributeTarget + | string | { [k: string]: ContributeValue } @@ -197,7 +201,7 @@ export type Parser = | PdlParser | RegexParser | null -export type Description21 = string | null +export type Description22 = string | null export type Pdl = | boolean | number @@ -221,10 +225,11 @@ export type Pdl = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null -export type Description22 = string | null +export type Description23 = string | null export type Regex = string export type Mode = "search" | "match" | "fullmatch" | "split" | "findall" /** @@ -254,6 +259,7 @@ export type Fallback = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -287,6 +293,8 @@ export type PdlContext = * */ export type PdlId = string | null +export type Path = string[] +export type File = string export type StartNanos = number | null export type EndNanos = number | null export type FirstUseNanos = number | null @@ -304,6 +312,7 @@ export type Def1 = string | null */ export type Contribute1 = ( | ContributeTarget + | string | { [k: string]: ContributeValue } @@ -343,6 +352,7 @@ export type Fallback1 = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -410,6 +420,7 @@ export type Program1 = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -424,6 +435,7 @@ export type Def2 = string | null */ export type Contribute2 = ( | ContributeTarget + | string | { [k: string]: ContributeValue } @@ -463,6 +475,7 @@ export type Fallback2 = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -497,7 +510,124 @@ export type PdlContext2 = */ export type PdlId2 = string | null export type PdlIsLeaf2 = true -export type Kind2 = "import" +export type Kind2 = "aggregator" +export type Aggregator = "context" | FileAggregatorConfig +/** + * Documentation associated to the aggregator config. + * + */ +export type Description24 = string | null +/** + * Name of the file to which contribute. + */ +export type File1 = LocalizedExpression | string +/** + * File opening mode. + */ +export type Mode1 = LocalizedExpression | string +/** + * File encoding. + */ +export type Encoding = LocalizedExpression | string | null +/** + * Prefix to the contributed value. + */ +export type Prefix = LocalizedExpression | string +/** + * Suffix to the contributed value. + */ +export type Suffix = LocalizedExpression | string +/** + * Whether to forcibly flush the stream. + */ +export type Flush = LocalizedExpression | boolean | string +/** + * Name of the variable used to store the result of the execution of the block. + * + */ +export type Def3 = string | null +/** + * Indicate if the block contributes to the result and background context. + * + */ +export type Contribute3 = ( + | ContributeTarget + | string + | { + [k: string]: ContributeValue + } +)[] +/** + * Parser to use to construct a value out of a string result. + */ +export type Parser3 = + | ("json" | "jsonl" | "yaml") + | PdlParser + | RegexParser + | null +/** + * Block to execute in case of error. + * + */ +export type Fallback3 = + | boolean + | number + | string + | FunctionBlock + | CallBlock + | LitellmModelBlock + | GraniteioModelBlock + | CodeBlock + | ArgsBlock + | GetBlock + | DataBlock + | IfBlock + | MatchBlock + | RepeatBlock + | TextBlock + | LastOfBlock + | ArrayBlock + | ObjectBlock + | MessageBlock + | ReadBlock + | IncludeBlock + | ImportBlock + | AggregatorBlock + | ErrorBlock + | EmptyBlock + | null +/** + * The maximum number of times to retry when an error occurs within a block. + * + */ +export type Retry3 = number | null +/** + * Whether to add the errors while retrying to the trace. Set this to true to use retry feature for multiple LLM trials. + * + */ +export type TraceErrorOnRetry3 = boolean | string | null +/** + * Role associated to the block and sub-blocks. + * Typical roles are `system`, `user`, and `assistant`, + * but there may be other roles such as `available_tools`. + */ +export type Role3 = string | null +/** + * Current context + * + */ +export type PdlContext3 = + | { + [k: string]: unknown + }[] + | null +/** + * Unique identifier for this block + * + */ +export type PdlId3 = string | null +export type PdlIsLeaf3 = true +export type Kind3 = "import" /** * Name of the file to import. * @@ -526,6 +656,7 @@ export type PdlTrace = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -533,13 +664,14 @@ export type PdlTrace = * Name of the variable used to store the result of the execution of the block. * */ -export type Def3 = string | null +export type Def4 = string | null /** * Indicate if the block contributes to the result and background context. * */ -export type Contribute3 = ( +export type Contribute4 = ( | ContributeTarget + | string | { [k: string]: ContributeValue } @@ -547,7 +679,7 @@ export type Contribute3 = ( /** * Parser to use to construct a value out of a string result. */ -export type Parser3 = +export type Parser4 = | ("json" | "jsonl" | "yaml") | PdlParser | RegexParser @@ -556,7 +688,7 @@ export type Parser3 = * Block to execute in case of error. * */ -export type Fallback3 = +export type Fallback4 = | boolean | number | string @@ -579,6 +711,7 @@ export type Fallback3 = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -586,23 +719,23 @@ export type Fallback3 = * The maximum number of times to retry when an error occurs within a block. * */ -export type Retry3 = number | null +export type Retry4 = number | null /** * Whether to add the errors while retrying to the trace. Set this to true to use retry feature for multiple LLM trials. * */ -export type TraceErrorOnRetry3 = boolean | string | null +export type TraceErrorOnRetry4 = boolean | string | null /** * Role associated to the block and sub-blocks. * Typical roles are `system`, `user`, and `assistant`, * but there may be other roles such as `available_tools`. */ -export type Role3 = string | null +export type Role4 = string | null /** * Current context * */ -export type PdlContext3 = +export type PdlContext4 = | { [k: string]: unknown }[] @@ -611,10 +744,10 @@ export type PdlContext3 = * Unique identifier for this block * */ -export type PdlId3 = string | null -export type PdlIsLeaf3 = false +export type PdlId4 = string | null +export type PdlIsLeaf4 = false export type IndependentEnum = "independent" | "dependent" -export type Kind3 = "include" +export type Kind4 = "include" /** * Name of the file to include. * @@ -643,6 +776,7 @@ export type PdlTrace1 = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -650,13 +784,14 @@ export type PdlTrace1 = * Name of the variable used to store the result of the execution of the block. * */ -export type Def4 = string | null +export type Def5 = string | null /** * Indicate if the block contributes to the result and background context. * */ -export type Contribute4 = ( +export type Contribute5 = ( | ContributeTarget + | string | { [k: string]: ContributeValue } @@ -664,7 +799,7 @@ export type Contribute4 = ( /** * Parser to use to construct a value out of a string result. */ -export type Parser4 = +export type Parser5 = | ("json" | "jsonl" | "yaml") | PdlParser | RegexParser @@ -673,7 +808,7 @@ export type Parser4 = * Block to execute in case of error. * */ -export type Fallback4 = +export type Fallback5 = | boolean | number | string @@ -696,6 +831,7 @@ export type Fallback4 = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -703,23 +839,23 @@ export type Fallback4 = * The maximum number of times to retry when an error occurs within a block. * */ -export type Retry4 = number | null +export type Retry5 = number | null /** * Whether to add the errors while retrying to the trace. Set this to true to use retry feature for multiple LLM trials. * */ -export type TraceErrorOnRetry4 = boolean | string | null +export type TraceErrorOnRetry5 = boolean | string | null /** * Role associated to the block and sub-blocks. * Typical roles are `system`, `user`, and `assistant`, * but there may be other roles such as `available_tools`. */ -export type Role4 = string | null +export type Role5 = string | null /** * Current context * */ -export type PdlContext4 = +export type PdlContext5 = | { [k: string]: unknown }[] @@ -728,9 +864,9 @@ export type PdlContext4 = * Unique identifier for this block * */ -export type PdlId4 = string | null -export type PdlIsLeaf4 = true -export type Kind4 = "read" +export type PdlId5 = string | null +export type PdlIsLeaf5 = true +export type Kind5 = "read" /** * Name of the file to read. If `None`, read the standard input. * @@ -750,13 +886,14 @@ export type Multiline = boolean * Name of the variable used to store the result of the execution of the block. * */ -export type Def5 = string | null +export type Def6 = string | null /** * Indicate if the block contributes to the result and background context. * */ -export type Contribute5 = ( +export type Contribute6 = ( | ContributeTarget + | string | { [k: string]: ContributeValue } @@ -764,7 +901,7 @@ export type Contribute5 = ( /** * Parser to use to construct a value out of a string result. */ -export type Parser5 = +export type Parser6 = | ("json" | "jsonl" | "yaml") | PdlParser | RegexParser @@ -773,7 +910,7 @@ export type Parser5 = * Block to execute in case of error. * */ -export type Fallback5 = +export type Fallback6 = | boolean | number | string @@ -796,6 +933,7 @@ export type Fallback5 = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -803,23 +941,23 @@ export type Fallback5 = * The maximum number of times to retry when an error occurs within a block. * */ -export type Retry5 = number | null +export type Retry6 = number | null /** * Whether to add the errors while retrying to the trace. Set this to true to use retry feature for multiple LLM trials. * */ -export type TraceErrorOnRetry5 = boolean | string | null +export type TraceErrorOnRetry6 = boolean | string | null /** * Role associated to the block and sub-blocks. * Typical roles are `system`, `user`, and `assistant`, * but there may be other roles such as `available_tools`. */ -export type Role5 = string | null +export type Role6 = string | null /** * Current context * */ -export type PdlContext5 = +export type PdlContext6 = | { [k: string]: unknown }[] @@ -828,9 +966,9 @@ export type PdlContext5 = * Unique identifier for this block * */ -export type PdlId5 = string | null -export type PdlIsLeaf5 = true -export type Kind5 = "message" +export type PdlId6 = string | null +export type PdlIsLeaf6 = true +export type Kind6 = "message" /** * Content of the message. */ @@ -857,6 +995,7 @@ export type Content = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -872,13 +1011,14 @@ export type ToolCallId = LocalizedExpression | string | null * Name of the variable used to store the result of the execution of the block. * */ -export type Def6 = string | null +export type Def7 = string | null /** * Indicate if the block contributes to the result and background context. * */ -export type Contribute6 = ( +export type Contribute7 = ( | ContributeTarget + | string | { [k: string]: ContributeValue } @@ -886,7 +1026,7 @@ export type Contribute6 = ( /** * Parser to use to construct a value out of a string result. */ -export type Parser6 = +export type Parser7 = | ("json" | "jsonl" | "yaml") | PdlParser | RegexParser @@ -895,7 +1035,7 @@ export type Parser6 = * Block to execute in case of error. * */ -export type Fallback6 = +export type Fallback7 = | boolean | number | string @@ -918,6 +1058,7 @@ export type Fallback6 = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -925,23 +1066,23 @@ export type Fallback6 = * The maximum number of times to retry when an error occurs within a block. * */ -export type Retry6 = number | null +export type Retry7 = number | null /** * Whether to add the errors while retrying to the trace. Set this to true to use retry feature for multiple LLM trials. * */ -export type TraceErrorOnRetry6 = boolean | string | null +export type TraceErrorOnRetry7 = boolean | string | null /** * Role associated to the block and sub-blocks. * Typical roles are `system`, `user`, and `assistant`, * but there may be other roles such as `available_tools`. */ -export type Role6 = string | null +export type Role7 = string | null /** * Current context * */ -export type PdlContext6 = +export type PdlContext7 = | { [k: string]: unknown }[] @@ -950,10 +1091,10 @@ export type PdlContext6 = * Unique identifier for this block * */ -export type PdlId6 = string | null -export type PdlIsLeaf6 = false +export type PdlId7 = string | null +export type PdlIsLeaf7 = false export type IndependentEnum1 = "independent" | "dependent" -export type Kind6 = "object" +export type Kind7 = "object" export type Object1 = | { [k: string]: @@ -979,6 +1120,7 @@ export type Object1 = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -1006,6 +1148,7 @@ export type Object1 = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -1014,13 +1157,14 @@ export type Object1 = * Name of the variable used to store the result of the execution of the block. * */ -export type Def7 = string | null +export type Def8 = string | null /** * Indicate if the block contributes to the result and background context. * */ -export type Contribute7 = ( +export type Contribute8 = ( | ContributeTarget + | string | { [k: string]: ContributeValue } @@ -1028,7 +1172,7 @@ export type Contribute7 = ( /** * Parser to use to construct a value out of a string result. */ -export type Parser7 = +export type Parser8 = | ("json" | "jsonl" | "yaml") | PdlParser | RegexParser @@ -1037,7 +1181,7 @@ export type Parser7 = * Block to execute in case of error. * */ -export type Fallback7 = +export type Fallback8 = | boolean | number | string @@ -1060,6 +1204,7 @@ export type Fallback7 = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -1067,23 +1212,23 @@ export type Fallback7 = * The maximum number of times to retry when an error occurs within a block. * */ -export type Retry7 = number | null +export type Retry8 = number | null /** * Whether to add the errors while retrying to the trace. Set this to true to use retry feature for multiple LLM trials. * */ -export type TraceErrorOnRetry7 = boolean | string | null +export type TraceErrorOnRetry8 = boolean | string | null /** * Role associated to the block and sub-blocks. * Typical roles are `system`, `user`, and `assistant`, * but there may be other roles such as `available_tools`. */ -export type Role7 = string | null +export type Role8 = string | null /** * Current context * */ -export type PdlContext7 = +export type PdlContext8 = | { [k: string]: unknown }[] @@ -1092,10 +1237,10 @@ export type PdlContext7 = * Unique identifier for this block * */ -export type PdlId7 = string | null -export type PdlIsLeaf7 = false +export type PdlId8 = string | null +export type PdlIsLeaf8 = false export type IndependentEnum2 = "independent" | "dependent" -export type Kind7 = "array" +export type Kind8 = "array" /** * Elements of the array. */ @@ -1122,6 +1267,7 @@ export type Array = ( | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -1130,13 +1276,14 @@ export type Array = ( * Name of the variable used to store the result of the execution of the block. * */ -export type Def8 = string | null +export type Def9 = string | null /** * Indicate if the block contributes to the result and background context. * */ -export type Contribute8 = ( +export type Contribute9 = ( | ContributeTarget + | string | { [k: string]: ContributeValue } @@ -1144,7 +1291,7 @@ export type Contribute8 = ( /** * Parser to use to construct a value out of a string result. */ -export type Parser8 = +export type Parser9 = | ("json" | "jsonl" | "yaml") | PdlParser | RegexParser @@ -1153,7 +1300,7 @@ export type Parser8 = * Block to execute in case of error. * */ -export type Fallback8 = +export type Fallback9 = | boolean | number | string @@ -1176,6 +1323,7 @@ export type Fallback8 = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -1183,23 +1331,23 @@ export type Fallback8 = * The maximum number of times to retry when an error occurs within a block. * */ -export type Retry8 = number | null +export type Retry9 = number | null /** * Whether to add the errors while retrying to the trace. Set this to true to use retry feature for multiple LLM trials. * */ -export type TraceErrorOnRetry8 = boolean | string | null +export type TraceErrorOnRetry9 = boolean | string | null /** * Role associated to the block and sub-blocks. * Typical roles are `system`, `user`, and `assistant`, * but there may be other roles such as `available_tools`. */ -export type Role8 = string | null +export type Role9 = string | null /** * Current context * */ -export type PdlContext8 = +export type PdlContext9 = | { [k: string]: unknown }[] @@ -1208,10 +1356,10 @@ export type PdlContext8 = * Unique identifier for this block * */ -export type PdlId8 = string | null -export type PdlIsLeaf8 = false +export type PdlId9 = string | null +export type PdlIsLeaf9 = false export type IndependentEnum3 = "independent" | "dependent" -export type Kind8 = "lastOf" +export type Kind9 = "lastOf" /** * Sequence of blocks to execute. */ @@ -1238,6 +1386,7 @@ export type Lastof = ( | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -1246,13 +1395,14 @@ export type Lastof = ( * Name of the variable used to store the result of the execution of the block. * */ -export type Def9 = string | null +export type Def10 = string | null /** * Indicate if the block contributes to the result and background context. * */ -export type Contribute9 = ( +export type Contribute10 = ( | ContributeTarget + | string | { [k: string]: ContributeValue } @@ -1260,7 +1410,7 @@ export type Contribute9 = ( /** * Parser to use to construct a value out of a string result. */ -export type Parser9 = +export type Parser10 = | ("json" | "jsonl" | "yaml") | PdlParser | RegexParser @@ -1269,7 +1419,7 @@ export type Parser9 = * Block to execute in case of error. * */ -export type Fallback9 = +export type Fallback10 = | boolean | number | string @@ -1292,6 +1442,7 @@ export type Fallback9 = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -1299,23 +1450,23 @@ export type Fallback9 = * The maximum number of times to retry when an error occurs within a block. * */ -export type Retry9 = number | null +export type Retry10 = number | null /** * Whether to add the errors while retrying to the trace. Set this to true to use retry feature for multiple LLM trials. * */ -export type TraceErrorOnRetry9 = boolean | string | null +export type TraceErrorOnRetry10 = boolean | string | null /** * Role associated to the block and sub-blocks. * Typical roles are `system`, `user`, and `assistant`, * but there may be other roles such as `available_tools`. */ -export type Role9 = string | null +export type Role10 = string | null /** * Current context * */ -export type PdlContext9 = +export type PdlContext10 = | { [k: string]: unknown }[] @@ -1324,10 +1475,10 @@ export type PdlContext9 = * Unique identifier for this block * */ -export type PdlId9 = string | null -export type PdlIsLeaf9 = false +export type PdlId10 = string | null +export type PdlIsLeaf10 = false export type IndependentEnum4 = "independent" | "dependent" -export type Kind9 = "text" +export type Kind10 = "text" /** * Body of the text. * @@ -1355,6 +1506,7 @@ export type Text = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | ( @@ -1380,6 +1532,7 @@ export type Text = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -1389,13 +1542,14 @@ export type Text = * Name of the variable used to store the result of the execution of the block. * */ -export type Def10 = string | null +export type Def11 = string | null /** * Indicate if the block contributes to the result and background context. * */ -export type Contribute10 = ( +export type Contribute11 = ( | ContributeTarget + | string | { [k: string]: ContributeValue } @@ -1403,7 +1557,7 @@ export type Contribute10 = ( /** * Parser to use to construct a value out of a string result. */ -export type Parser10 = +export type Parser11 = | ("json" | "jsonl" | "yaml") | PdlParser | RegexParser @@ -1412,7 +1566,7 @@ export type Parser10 = * Block to execute in case of error. * */ -export type Fallback10 = +export type Fallback11 = | boolean | number | string @@ -1435,6 +1589,7 @@ export type Fallback10 = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -1442,23 +1597,23 @@ export type Fallback10 = * The maximum number of times to retry when an error occurs within a block. * */ -export type Retry10 = number | null +export type Retry11 = number | null /** * Whether to add the errors while retrying to the trace. Set this to true to use retry feature for multiple LLM trials. * */ -export type TraceErrorOnRetry10 = boolean | string | null +export type TraceErrorOnRetry11 = boolean | string | null /** * Role associated to the block and sub-blocks. * Typical roles are `system`, `user`, and `assistant`, * but there may be other roles such as `available_tools`. */ -export type Role10 = string | null +export type Role11 = string | null /** * Current context * */ -export type PdlContext10 = +export type PdlContext11 = | { [k: string]: unknown }[] @@ -1467,10 +1622,10 @@ export type PdlContext10 = * Unique identifier for this block * */ -export type PdlId10 = string | null -export type PdlIsLeaf10 = false +export type PdlId11 = string | null +export type PdlIsLeaf11 = false export type IndependentEnum5 = "independent" | "dependent" -export type Kind10 = "repeat" +export type Kind11 = "repeat" /** * Arrays to iterate over. * @@ -1515,6 +1670,7 @@ export type Repeat = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -1582,6 +1738,7 @@ export type PdlTrace2 = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -1591,13 +1748,14 @@ export type PdlTrace2 = * Name of the variable used to store the result of the execution of the block. * */ -export type Def11 = string | null +export type Def12 = string | null /** * Indicate if the block contributes to the result and background context. * */ -export type Contribute11 = ( +export type Contribute12 = ( | ContributeTarget + | string | { [k: string]: ContributeValue } @@ -1605,7 +1763,7 @@ export type Contribute11 = ( /** * Parser to use to construct a value out of a string result. */ -export type Parser11 = +export type Parser12 = | ("json" | "jsonl" | "yaml") | PdlParser | RegexParser @@ -1614,7 +1772,7 @@ export type Parser11 = * Block to execute in case of error. * */ -export type Fallback11 = +export type Fallback12 = | boolean | number | string @@ -1637,6 +1795,7 @@ export type Fallback11 = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -1644,23 +1803,23 @@ export type Fallback11 = * The maximum number of times to retry when an error occurs within a block. * */ -export type Retry11 = number | null +export type Retry12 = number | null /** * Whether to add the errors while retrying to the trace. Set this to true to use retry feature for multiple LLM trials. * */ -export type TraceErrorOnRetry11 = boolean | string | null +export type TraceErrorOnRetry12 = boolean | string | null /** * Role associated to the block and sub-blocks. * Typical roles are `system`, `user`, and `assistant`, * but there may be other roles such as `available_tools`. */ -export type Role11 = string | null +export type Role12 = string | null /** * Current context * */ -export type PdlContext11 = +export type PdlContext12 = | { [k: string]: unknown }[] @@ -1669,10 +1828,10 @@ export type PdlContext11 = * Unique identifier for this block * */ -export type PdlId11 = string | null -export type PdlIsLeaf11 = false +export type PdlId12 = string | null +export type PdlIsLeaf12 = false export type IndependentEnum6 = "independent" | "dependent" -export type Kind11 = "match" +export type Kind12 = "match" export type Case = | boolean | number @@ -1682,10 +1841,10 @@ export type Case = | ObjectPattern | AnyPattern | null -export type Def12 = string | null export type Def13 = string | null export type Def14 = string | null export type Def15 = string | null +export type Def16 = string | null export type Any = null export type Array1 = ( | boolean @@ -1731,6 +1890,7 @@ export type Then = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -1746,13 +1906,14 @@ export type With1 = MatchCase[] * Name of the variable used to store the result of the execution of the block. * */ -export type Def16 = string | null +export type Def17 = string | null /** * Indicate if the block contributes to the result and background context. * */ -export type Contribute12 = ( +export type Contribute13 = ( | ContributeTarget + | string | { [k: string]: ContributeValue } @@ -1760,7 +1921,7 @@ export type Contribute12 = ( /** * Parser to use to construct a value out of a string result. */ -export type Parser12 = +export type Parser13 = | ("json" | "jsonl" | "yaml") | PdlParser | RegexParser @@ -1769,7 +1930,7 @@ export type Parser12 = * Block to execute in case of error. * */ -export type Fallback12 = +export type Fallback13 = | boolean | number | string @@ -1792,6 +1953,7 @@ export type Fallback12 = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -1799,23 +1961,23 @@ export type Fallback12 = * The maximum number of times to retry when an error occurs within a block. * */ -export type Retry12 = number | null +export type Retry13 = number | null /** * Whether to add the errors while retrying to the trace. Set this to true to use retry feature for multiple LLM trials. * */ -export type TraceErrorOnRetry12 = boolean | string | null +export type TraceErrorOnRetry13 = boolean | string | null /** * Role associated to the block and sub-blocks. * Typical roles are `system`, `user`, and `assistant`, * but there may be other roles such as `available_tools`. */ -export type Role12 = string | null +export type Role13 = string | null /** * Current context * */ -export type PdlContext12 = +export type PdlContext13 = | { [k: string]: unknown }[] @@ -1824,10 +1986,10 @@ export type PdlContext12 = * Unique identifier for this block * */ -export type PdlId12 = string | null -export type PdlIsLeaf12 = false +export type PdlId13 = string | null +export type PdlIsLeaf13 = false export type IndependentEnum7 = "independent" | "dependent" -export type Kind12 = "if" +export type Kind13 = "if" /** * Condition. * @@ -1860,6 +2022,7 @@ export type Then1 = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -1890,6 +2053,7 @@ export type Else = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -1897,13 +2061,14 @@ export type Else = * Name of the variable used to store the result of the execution of the block. * */ -export type Def17 = string | null +export type Def18 = string | null /** * Indicate if the block contributes to the result and background context. * */ -export type Contribute13 = ( +export type Contribute14 = ( | ContributeTarget + | string | { [k: string]: ContributeValue } @@ -1911,7 +2076,7 @@ export type Contribute13 = ( /** * Parser to use to construct a value out of a string result. */ -export type Parser13 = +export type Parser14 = | ("json" | "jsonl" | "yaml") | PdlParser | RegexParser @@ -1920,7 +2085,7 @@ export type Parser13 = * Block to execute in case of error. * */ -export type Fallback13 = +export type Fallback14 = | boolean | number | string @@ -1943,6 +2108,7 @@ export type Fallback13 = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -1950,23 +2116,23 @@ export type Fallback13 = * The maximum number of times to retry when an error occurs within a block. * */ -export type Retry13 = number | null +export type Retry14 = number | null /** * Whether to add the errors while retrying to the trace. Set this to true to use retry feature for multiple LLM trials. * */ -export type TraceErrorOnRetry13 = boolean | string | null +export type TraceErrorOnRetry14 = boolean | string | null /** * Role associated to the block and sub-blocks. * Typical roles are `system`, `user`, and `assistant`, * but there may be other roles such as `available_tools`. */ -export type Role13 = string | null +export type Role14 = string | null /** * Current context * */ -export type PdlContext13 = +export type PdlContext14 = | { [k: string]: unknown }[] @@ -1975,9 +2141,9 @@ export type PdlContext13 = * Unique identifier for this block * */ -export type PdlId13 = string | null -export type PdlIsLeaf13 = true -export type Kind13 = "data" +export type PdlId14 = string | null +export type PdlIsLeaf14 = true +export type Kind14 = "data" /** * Do not evaluate expressions inside strings. */ @@ -1986,13 +2152,14 @@ export type Raw = boolean * Name of the variable used to store the result of the execution of the block. * */ -export type Def18 = string | null +export type Def19 = string | null /** * Indicate if the block contributes to the result and background context. * */ -export type Contribute14 = ( +export type Contribute15 = ( | ContributeTarget + | string | { [k: string]: ContributeValue } @@ -2000,7 +2167,7 @@ export type Contribute14 = ( /** * Parser to use to construct a value out of a string result. */ -export type Parser14 = +export type Parser15 = | ("json" | "jsonl" | "yaml") | PdlParser | RegexParser @@ -2009,7 +2176,7 @@ export type Parser14 = * Block to execute in case of error. * */ -export type Fallback14 = +export type Fallback15 = | boolean | number | string @@ -2032,6 +2199,7 @@ export type Fallback14 = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -2039,23 +2207,23 @@ export type Fallback14 = * The maximum number of times to retry when an error occurs within a block. * */ -export type Retry14 = number | null +export type Retry15 = number | null /** * Whether to add the errors while retrying to the trace. Set this to true to use retry feature for multiple LLM trials. * */ -export type TraceErrorOnRetry14 = boolean | string | null +export type TraceErrorOnRetry15 = boolean | string | null /** * Role associated to the block and sub-blocks. * Typical roles are `system`, `user`, and `assistant`, * but there may be other roles such as `available_tools`. */ -export type Role14 = string | null +export type Role15 = string | null /** * Current context * */ -export type PdlContext14 = +export type PdlContext15 = | { [k: string]: unknown }[] @@ -2064,9 +2232,9 @@ export type PdlContext14 = * Unique identifier for this block * */ -export type PdlId14 = string | null -export type PdlIsLeaf14 = true -export type Kind14 = "get" +export type PdlId15 = string | null +export type PdlIsLeaf15 = true +export type Kind15 = "get" /** * Name of the variable to access. */ @@ -2075,13 +2243,14 @@ export type Get = string * Name of the variable used to store the result of the execution of the block. * */ -export type Def19 = string | null +export type Def20 = string | null /** * Indicate if the block contributes to the result and background context. * */ -export type Contribute15 = ( +export type Contribute16 = ( | ContributeTarget + | string | { [k: string]: ContributeValue } @@ -2089,7 +2258,7 @@ export type Contribute15 = ( /** * Parser to use to construct a value out of a string result. */ -export type Parser15 = +export type Parser16 = | ("json" | "jsonl" | "yaml") | PdlParser | RegexParser @@ -2098,7 +2267,7 @@ export type Parser15 = * Block to execute in case of error. * */ -export type Fallback15 = +export type Fallback16 = | boolean | number | string @@ -2121,6 +2290,7 @@ export type Fallback15 = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -2128,23 +2298,23 @@ export type Fallback15 = * The maximum number of times to retry when an error occurs within a block. * */ -export type Retry15 = number | null +export type Retry16 = number | null /** * Whether to add the errors while retrying to the trace. Set this to true to use retry feature for multiple LLM trials. * */ -export type TraceErrorOnRetry15 = boolean | string | null +export type TraceErrorOnRetry16 = boolean | string | null /** * Role associated to the block and sub-blocks. * Typical roles are `system`, `user`, and `assistant`, * but there may be other roles such as `available_tools`. */ -export type Role15 = string | null +export type Role16 = string | null /** * Current context * */ -export type PdlContext15 = +export type PdlContext16 = | { [k: string]: unknown }[] @@ -2153,9 +2323,9 @@ export type PdlContext15 = * Unique identifier for this block * */ -export type PdlId15 = string | null -export type PdlIsLeaf15 = true -export type Kind15 = "code" +export type PdlId16 = string | null +export type PdlIsLeaf16 = true +export type Kind16 = "code" export type Lang = "command" /** * The argument vector to spawn. @@ -2166,13 +2336,14 @@ export type Args = (LocalizedExpression | string)[] * Name of the variable used to store the result of the execution of the block. * */ -export type Def20 = string | null +export type Def21 = string | null /** * Indicate if the block contributes to the result and background context. * */ -export type Contribute16 = ( +export type Contribute17 = ( | ContributeTarget + | string | { [k: string]: ContributeValue } @@ -2180,7 +2351,7 @@ export type Contribute16 = ( /** * Parser to use to construct a value out of a string result. */ -export type Parser16 = +export type Parser17 = | ("json" | "jsonl" | "yaml") | PdlParser | RegexParser @@ -2189,7 +2360,7 @@ export type Parser16 = * Block to execute in case of error. * */ -export type Fallback16 = +export type Fallback17 = | boolean | number | string @@ -2212,6 +2383,7 @@ export type Fallback16 = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -2219,23 +2391,23 @@ export type Fallback16 = * The maximum number of times to retry when an error occurs within a block. * */ -export type Retry16 = number | null +export type Retry17 = number | null /** * Whether to add the errors while retrying to the trace. Set this to true to use retry feature for multiple LLM trials. * */ -export type TraceErrorOnRetry16 = boolean | string | null +export type TraceErrorOnRetry17 = boolean | string | null /** * Role associated to the block and sub-blocks. * Typical roles are `system`, `user`, and `assistant`, * but there may be other roles such as `available_tools`. */ -export type Role16 = string | null +export type Role17 = string | null /** * Current context * */ -export type PdlContext16 = +export type PdlContext17 = | { [k: string]: unknown }[] @@ -2244,9 +2416,9 @@ export type PdlContext16 = * Unique identifier for this block * */ -export type PdlId16 = string | null -export type PdlIsLeaf16 = true -export type Kind16 = "code" +export type PdlId17 = string | null +export type PdlIsLeaf17 = true +export type Kind17 = "code" /** * Programming language of the code. * @@ -2279,6 +2451,7 @@ export type Code = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -2286,13 +2459,14 @@ export type Code = * Name of the variable used to store the result of the execution of the block. * */ -export type Def21 = string | null +export type Def22 = string | null /** * Indicate if the block contributes to the result and background context. * */ -export type Contribute17 = ( +export type Contribute18 = ( | ContributeTarget + | string | { [k: string]: ContributeValue } @@ -2300,7 +2474,7 @@ export type Contribute17 = ( /** * Parser to use to construct a value out of a string result. */ -export type Parser17 = +export type Parser18 = | ("json" | "jsonl" | "yaml") | PdlParser | RegexParser @@ -2309,7 +2483,7 @@ export type Parser17 = * Block to execute in case of error. * */ -export type Fallback17 = +export type Fallback18 = | boolean | number | string @@ -2332,6 +2506,7 @@ export type Fallback17 = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -2339,23 +2514,23 @@ export type Fallback17 = * The maximum number of times to retry when an error occurs within a block. * */ -export type Retry17 = number | null +export type Retry18 = number | null /** * Whether to add the errors while retrying to the trace. Set this to true to use retry feature for multiple LLM trials. * */ -export type TraceErrorOnRetry17 = boolean | string | null +export type TraceErrorOnRetry18 = boolean | string | null /** * Role associated to the block and sub-blocks. * Typical roles are `system`, `user`, and `assistant`, * but there may be other roles such as `available_tools`. */ -export type Role17 = string | null +export type Role18 = string | null /** * Current context * */ -export type PdlContext17 = +export type PdlContext18 = | { [k: string]: unknown }[] @@ -2364,9 +2539,9 @@ export type PdlContext17 = * Unique identifier for this block * */ -export type PdlId17 = string | null -export type PdlIsLeaf17 = true -export type Kind17 = "model" +export type PdlId18 = string | null +export type PdlIsLeaf18 = true +export type Kind18 = "model" /** * Messages to send to the model. * @@ -2394,6 +2569,7 @@ export type Input = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -2429,13 +2605,14 @@ export type Parameters = * Name of the variable used to store the result of the execution of the block. * */ -export type Def22 = string | null +export type Def23 = string | null /** * Indicate if the block contributes to the result and background context. * */ -export type Contribute18 = ( +export type Contribute19 = ( | ContributeTarget + | string | { [k: string]: ContributeValue } @@ -2443,7 +2620,7 @@ export type Contribute18 = ( /** * Parser to use to construct a value out of a string result. */ -export type Parser18 = +export type Parser19 = | ("json" | "jsonl" | "yaml") | PdlParser | RegexParser @@ -2452,7 +2629,7 @@ export type Parser18 = * Block to execute in case of error. * */ -export type Fallback18 = +export type Fallback19 = | boolean | number | string @@ -2475,6 +2652,7 @@ export type Fallback18 = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -2482,23 +2660,23 @@ export type Fallback18 = * The maximum number of times to retry when an error occurs within a block. * */ -export type Retry18 = number | null +export type Retry19 = number | null /** * Whether to add the errors while retrying to the trace. Set this to true to use retry feature for multiple LLM trials. * */ -export type TraceErrorOnRetry18 = boolean | string | null +export type TraceErrorOnRetry19 = boolean | string | null /** * Role associated to the block and sub-blocks. * Typical roles are `system`, `user`, and `assistant`, * but there may be other roles such as `available_tools`. */ -export type Role18 = string | null +export type Role19 = string | null /** * Current context * */ -export type PdlContext18 = +export type PdlContext19 = | { [k: string]: unknown }[] @@ -2507,9 +2685,9 @@ export type PdlContext18 = * Unique identifier for this block * */ -export type PdlId18 = string | null -export type PdlIsLeaf18 = true -export type Kind18 = "model" +export type PdlId19 = string | null +export type PdlIsLeaf19 = true +export type Kind19 = "model" /** * Messages to send to the model. * @@ -2537,6 +2715,7 @@ export type Input1 = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -2623,13 +2802,14 @@ export type MaxRetries = number | string | null * Name of the variable used to store the result of the execution of the block. * */ -export type Def23 = string | null +export type Def24 = string | null /** * Indicate if the block contributes to the result and background context. * */ -export type Contribute19 = ( +export type Contribute20 = ( | ContributeTarget + | string | { [k: string]: ContributeValue } @@ -2637,7 +2817,7 @@ export type Contribute19 = ( /** * Parser to use to construct a value out of a string result. */ -export type Parser19 = +export type Parser20 = | ("json" | "jsonl" | "yaml") | PdlParser | RegexParser @@ -2646,7 +2826,7 @@ export type Parser19 = * Block to execute in case of error. * */ -export type Fallback19 = +export type Fallback20 = | boolean | number | string @@ -2669,6 +2849,7 @@ export type Fallback19 = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -2676,23 +2857,23 @@ export type Fallback19 = * The maximum number of times to retry when an error occurs within a block. * */ -export type Retry19 = number | null +export type Retry20 = number | null /** * Whether to add the errors while retrying to the trace. Set this to true to use retry feature for multiple LLM trials. * */ -export type TraceErrorOnRetry19 = boolean | string | null +export type TraceErrorOnRetry20 = boolean | string | null /** * Role associated to the block and sub-blocks. * Typical roles are `system`, `user`, and `assistant`, * but there may be other roles such as `available_tools`. */ -export type Role19 = string | null +export type Role20 = string | null /** * Current context * */ -export type PdlContext19 = +export type PdlContext20 = | { [k: string]: unknown }[] @@ -2701,9 +2882,9 @@ export type PdlContext19 = * Unique identifier for this block * */ -export type PdlId19 = string | null -export type PdlIsLeaf19 = true -export type Kind19 = "call" +export type PdlId20 = string | null +export type PdlIsLeaf20 = true +export type Kind20 = "call" /** * Function to call. * @@ -2732,6 +2913,7 @@ export type PdlTrace3 = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -2739,13 +2921,14 @@ export type PdlTrace3 = * Name of the variable used to store the result of the execution of the block. * */ -export type Def24 = string | null +export type Def25 = string | null /** * Indicate if the block contributes to the result and background context. * */ -export type Contribute20 = ( +export type Contribute21 = ( | ContributeTarget + | string | { [k: string]: ContributeValue } @@ -2753,7 +2936,7 @@ export type Contribute20 = ( /** * Parser to use to construct a value out of a string result. */ -export type Parser20 = +export type Parser21 = | ("json" | "jsonl" | "yaml") | PdlParser | RegexParser @@ -2762,7 +2945,7 @@ export type Parser20 = * Block to execute in case of error. * */ -export type Fallback20 = +export type Fallback21 = | boolean | number | string @@ -2785,6 +2968,7 @@ export type Fallback20 = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -2792,23 +2976,23 @@ export type Fallback20 = * The maximum number of times to retry when an error occurs within a block. * */ -export type Retry20 = number | null +export type Retry21 = number | null /** * Whether to add the errors while retrying to the trace. Set this to true to use retry feature for multiple LLM trials. * */ -export type TraceErrorOnRetry20 = boolean | string | null +export type TraceErrorOnRetry21 = boolean | string | null /** * Role associated to the block and sub-blocks. * Typical roles are `system`, `user`, and `assistant`, * but there may be other roles such as `available_tools`. */ -export type Role20 = string | null +export type Role21 = string | null /** * Current context * */ -export type PdlContext20 = +export type PdlContext21 = | { [k: string]: unknown }[] @@ -2817,9 +3001,9 @@ export type PdlContext20 = * Unique identifier for this block * */ -export type PdlId20 = string | null -export type PdlIsLeaf20 = true -export type Kind20 = "function" +export type PdlId21 = string | null +export type PdlIsLeaf21 = true +export type Kind21 = "function" /** * Functions parameters with their types. * @@ -2854,6 +3038,7 @@ export type Return = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -2885,6 +3070,7 @@ export type PdlBlock = | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -2924,20 +3110,20 @@ export interface FunctionBlock { } | null defs?: Defs - def?: Def24 - contribute?: Contribute20 - parser?: Parser20 - fallback?: Fallback20 - retry?: Retry20 - trace_error_on_retry?: TraceErrorOnRetry20 - role?: Role20 - pdl__context?: PdlContext20 - pdl__id?: PdlId20 + def?: Def25 + contribute?: Contribute21 + parser?: Parser21 + fallback?: Fallback21 + retry?: Retry21 + trace_error_on_retry?: TraceErrorOnRetry21 + role?: Role21 + pdl__context?: PdlContext21 + pdl__id?: PdlId21 pdl__result?: unknown pdl__location?: PdlLocationType | null pdl__timing?: PdlTiming | null - pdl__is_leaf?: PdlIsLeaf20 - kind?: Kind20 + pdl__is_leaf?: PdlIsLeaf21 + kind?: Kind21 function: Function return: Return signature?: Signature @@ -2999,6 +3185,7 @@ export interface Defs { | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -3038,20 +3225,20 @@ export interface CallBlock { } | null defs?: Defs1 - def?: Def23 - contribute?: Contribute19 - parser?: Parser19 - fallback?: Fallback19 - retry?: Retry19 - trace_error_on_retry?: TraceErrorOnRetry19 - role?: Role19 - pdl__context?: PdlContext19 - pdl__id?: PdlId19 + def?: Def24 + contribute?: Contribute20 + parser?: Parser20 + fallback?: Fallback20 + retry?: Retry20 + trace_error_on_retry?: TraceErrorOnRetry20 + role?: Role20 + pdl__context?: PdlContext20 + pdl__id?: PdlId20 pdl__result?: unknown pdl__location?: PdlLocationType | null pdl__timing?: PdlTiming | null - pdl__is_leaf?: PdlIsLeaf19 - kind?: Kind19 + pdl__is_leaf?: PdlIsLeaf20 + kind?: Kind20 call: Call args?: unknown pdl__trace?: PdlTrace3 @@ -3084,6 +3271,7 @@ export interface Defs1 { | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -3130,20 +3318,20 @@ export interface LitellmModelBlock { } | null defs?: Defs2 - def?: Def22 - contribute?: Contribute18 - parser?: Parser18 - fallback?: Fallback18 - retry?: Retry18 - trace_error_on_retry?: TraceErrorOnRetry18 - role?: Role18 - pdl__context?: PdlContext18 - pdl__id?: PdlId18 + def?: Def23 + contribute?: Contribute19 + parser?: Parser19 + fallback?: Fallback19 + retry?: Retry19 + trace_error_on_retry?: TraceErrorOnRetry19 + role?: Role19 + pdl__context?: PdlContext19 + pdl__id?: PdlId19 pdl__result?: unknown pdl__location?: PdlLocationType | null pdl__timing?: PdlTiming | null - pdl__is_leaf?: PdlIsLeaf18 - kind?: Kind18 + pdl__is_leaf?: PdlIsLeaf19 + kind?: Kind19 input?: Input1 modelResponse?: Modelresponse1 /** @@ -3184,6 +3372,7 @@ export interface Defs2 { | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -3223,20 +3412,20 @@ export interface GraniteioModelBlock { } | null defs?: Defs3 - def?: Def21 - contribute?: Contribute17 - parser?: Parser17 - fallback?: Fallback17 - retry?: Retry17 - trace_error_on_retry?: TraceErrorOnRetry17 - role?: Role17 - pdl__context?: PdlContext17 - pdl__id?: PdlId17 + def?: Def22 + contribute?: Contribute18 + parser?: Parser18 + fallback?: Fallback18 + retry?: Retry18 + trace_error_on_retry?: TraceErrorOnRetry18 + role?: Role18 + pdl__context?: PdlContext18 + pdl__id?: PdlId18 pdl__result?: unknown pdl__location?: PdlLocationType | null pdl__timing?: PdlTiming | null - pdl__is_leaf?: PdlIsLeaf17 - kind?: Kind17 + pdl__is_leaf?: PdlIsLeaf18 + kind?: Kind18 input?: Input modelResponse?: Modelresponse /** @@ -3277,6 +3466,7 @@ export interface Defs3 { | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -3325,20 +3515,20 @@ export interface CodeBlock { } | null defs?: Defs4 - def?: Def20 - contribute?: Contribute16 - parser?: Parser16 - fallback?: Fallback16 - retry?: Retry16 - trace_error_on_retry?: TraceErrorOnRetry16 - role?: Role16 - pdl__context?: PdlContext16 - pdl__id?: PdlId16 + def?: Def21 + contribute?: Contribute17 + parser?: Parser17 + fallback?: Fallback17 + retry?: Retry17 + trace_error_on_retry?: TraceErrorOnRetry17 + role?: Role17 + pdl__context?: PdlContext17 + pdl__id?: PdlId17 pdl__result?: unknown pdl__location?: PdlLocationType | null pdl__timing?: PdlTiming | null - pdl__is_leaf?: PdlIsLeaf16 - kind?: Kind16 + pdl__is_leaf?: PdlIsLeaf17 + kind?: Kind17 lang: Lang1 code: Code } @@ -3370,6 +3560,7 @@ export interface Defs4 { | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -3417,20 +3608,20 @@ export interface ArgsBlock { } | null defs?: Defs5 - def?: Def19 - contribute?: Contribute15 - parser?: Parser15 - fallback?: Fallback15 - retry?: Retry15 - trace_error_on_retry?: TraceErrorOnRetry15 - role?: Role15 - pdl__context?: PdlContext15 - pdl__id?: PdlId15 + def?: Def20 + contribute?: Contribute16 + parser?: Parser16 + fallback?: Fallback16 + retry?: Retry16 + trace_error_on_retry?: TraceErrorOnRetry16 + role?: Role16 + pdl__context?: PdlContext16 + pdl__id?: PdlId16 pdl__result?: unknown pdl__location?: PdlLocationType | null pdl__timing?: PdlTiming | null - pdl__is_leaf?: PdlIsLeaf15 - kind?: Kind15 + pdl__is_leaf?: PdlIsLeaf16 + kind?: Kind16 lang?: Lang args: Args } @@ -3462,6 +3653,7 @@ export interface Defs5 { | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -3503,20 +3695,20 @@ export interface GetBlock { } | null defs?: Defs6 - def?: Def18 - contribute?: Contribute14 - parser?: Parser14 - fallback?: Fallback14 - retry?: Retry14 - trace_error_on_retry?: TraceErrorOnRetry14 - role?: Role14 - pdl__context?: PdlContext14 - pdl__id?: PdlId14 + def?: Def19 + contribute?: Contribute15 + parser?: Parser15 + fallback?: Fallback15 + retry?: Retry15 + trace_error_on_retry?: TraceErrorOnRetry15 + role?: Role15 + pdl__context?: PdlContext15 + pdl__id?: PdlId15 pdl__result?: unknown pdl__location?: PdlLocationType | null pdl__timing?: PdlTiming | null - pdl__is_leaf?: PdlIsLeaf14 - kind?: Kind14 + pdl__is_leaf?: PdlIsLeaf15 + kind?: Kind15 get: Get } /** @@ -3547,6 +3739,7 @@ export interface Defs6 { | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -3607,20 +3800,20 @@ export interface DataBlock { } | null defs?: Defs7 - def?: Def17 - contribute?: Contribute13 - parser?: Parser13 - fallback?: Fallback13 - retry?: Retry13 - trace_error_on_retry?: TraceErrorOnRetry13 - role?: Role13 - pdl__context?: PdlContext13 - pdl__id?: PdlId13 + def?: Def18 + contribute?: Contribute14 + parser?: Parser14 + fallback?: Fallback14 + retry?: Retry14 + trace_error_on_retry?: TraceErrorOnRetry14 + role?: Role14 + pdl__context?: PdlContext14 + pdl__id?: PdlId14 pdl__result?: unknown pdl__location?: PdlLocationType | null pdl__timing?: PdlTiming | null - pdl__is_leaf?: PdlIsLeaf13 - kind?: Kind13 + pdl__is_leaf?: PdlIsLeaf14 + kind?: Kind14 data: unknown raw?: Raw } @@ -3652,6 +3845,7 @@ export interface Defs7 { | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -3701,21 +3895,21 @@ export interface IfBlock { } | null defs?: Defs8 - def?: Def16 - contribute?: Contribute12 - parser?: Parser12 - fallback?: Fallback12 - retry?: Retry12 - trace_error_on_retry?: TraceErrorOnRetry12 - role?: Role12 - pdl__context?: PdlContext12 - pdl__id?: PdlId12 + def?: Def17 + contribute?: Contribute13 + parser?: Parser13 + fallback?: Fallback13 + retry?: Retry13 + trace_error_on_retry?: TraceErrorOnRetry13 + role?: Role13 + pdl__context?: PdlContext13 + pdl__id?: PdlId13 pdl__result?: unknown pdl__location?: PdlLocationType | null pdl__timing?: PdlTiming | null - pdl__is_leaf?: PdlIsLeaf12 + pdl__is_leaf?: PdlIsLeaf13 context?: IndependentEnum7 - kind?: Kind12 + kind?: Kind13 if: If1 then: Then1 else?: Else @@ -3748,6 +3942,7 @@ export interface Defs8 { | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -3804,21 +3999,21 @@ export interface MatchBlock { } | null defs?: Defs9 - def?: Def11 - contribute?: Contribute11 - parser?: Parser11 - fallback?: Fallback11 - retry?: Retry11 - trace_error_on_retry?: TraceErrorOnRetry11 - role?: Role11 - pdl__context?: PdlContext11 - pdl__id?: PdlId11 + def?: Def12 + contribute?: Contribute12 + parser?: Parser12 + fallback?: Fallback12 + retry?: Retry12 + trace_error_on_retry?: TraceErrorOnRetry12 + role?: Role12 + pdl__context?: PdlContext12 + pdl__id?: PdlId12 pdl__result?: unknown pdl__location?: PdlLocationType | null pdl__timing?: PdlTiming | null - pdl__is_leaf?: PdlIsLeaf11 + pdl__is_leaf?: PdlIsLeaf12 context?: IndependentEnum6 - kind?: Kind11 + kind?: Kind12 match: unknown with: With1 } @@ -3850,6 +4045,7 @@ export interface Defs9 { | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -3908,21 +4104,21 @@ export interface RepeatBlock { } | null defs?: Defs10 - def?: Def10 - contribute?: Contribute10 - parser?: Parser10 - fallback?: Fallback10 - retry?: Retry10 - trace_error_on_retry?: TraceErrorOnRetry10 - role?: Role10 - pdl__context?: PdlContext10 - pdl__id?: PdlId10 + def?: Def11 + contribute?: Contribute11 + parser?: Parser11 + fallback?: Fallback11 + retry?: Retry11 + trace_error_on_retry?: TraceErrorOnRetry11 + role?: Role11 + pdl__context?: PdlContext11 + pdl__id?: PdlId11 pdl__result?: unknown pdl__location?: PdlLocationType | null pdl__timing?: PdlTiming | null - pdl__is_leaf?: PdlIsLeaf10 + pdl__is_leaf?: PdlIsLeaf11 context?: IndependentEnum5 - kind?: Kind10 + kind?: Kind11 for?: For index?: Index while?: While @@ -3960,6 +4156,7 @@ export interface Defs10 { | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -3999,6 +4196,91 @@ export interface TextBlock { } | null defs?: Defs11 + def?: Def10 + contribute?: Contribute10 + parser?: Parser10 + fallback?: Fallback10 + retry?: Retry10 + trace_error_on_retry?: TraceErrorOnRetry10 + role?: Role10 + pdl__context?: PdlContext10 + pdl__id?: PdlId10 + pdl__result?: unknown + pdl__location?: PdlLocationType | null + pdl__timing?: PdlTiming | null + pdl__is_leaf?: PdlIsLeaf10 + context?: IndependentEnum4 + kind?: Kind10 + text: Text +} +/** + * Set of definitions executed before the execution of the block. + * + */ +export interface Defs11 { + [k: string]: + | boolean + | number + | string + | FunctionBlock + | CallBlock + | LitellmModelBlock + | GraniteioModelBlock + | CodeBlock + | ArgsBlock + | GetBlock + | DataBlock + | IfBlock + | MatchBlock + | RepeatBlock + | TextBlock + | LastOfBlock + | ArrayBlock + | ObjectBlock + | MessageBlock + | ReadBlock + | IncludeBlock + | ImportBlock + | AggregatorBlock + | ErrorBlock + | EmptyBlock + | null +} +/** + * Return the value of the last block if the list of blocks. + */ +export interface LastOfBlock { + description?: Description12 + /** + * Type specification of the result of the block. + * + */ + spec?: + | ( + | "null" + | "boolean" + | "string" + | "number" + | "integer" + | "array" + | "object" + | "bool" + | "str" + | "float" + | "int" + | "list" + | "obj" + ) + | EnumPdlType + | PdlTypeType[] + | OptionalPdlType + | JsonSchemaTypePdlType + | ObjectPdlType + | { + [k: string]: PdlTypeType + } + | null + defs?: Defs12 def?: Def9 contribute?: Contribute9 parser?: Parser9 @@ -4012,15 +4294,15 @@ export interface TextBlock { pdl__location?: PdlLocationType | null pdl__timing?: PdlTiming | null pdl__is_leaf?: PdlIsLeaf9 - context?: IndependentEnum4 + context?: IndependentEnum3 kind?: Kind9 - text: Text + lastOf: Lastof } /** * Set of definitions executed before the execution of the block. * */ -export interface Defs11 { +export interface Defs12 { [k: string]: | boolean | number @@ -4044,15 +4326,16 @@ export interface Defs11 { | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null } /** - * Return the value of the last block if the list of blocks. + * Return the array of values computed by each block of the list of blocks. */ -export interface LastOfBlock { - description?: Description12 +export interface ArrayBlock { + description?: Description13 /** * Type specification of the result of the block. * @@ -4082,7 +4365,7 @@ export interface LastOfBlock { [k: string]: PdlTypeType } | null - defs?: Defs12 + defs?: Defs13 def?: Def8 contribute?: Contribute8 parser?: Parser8 @@ -4096,15 +4379,15 @@ export interface LastOfBlock { pdl__location?: PdlLocationType | null pdl__timing?: PdlTiming | null pdl__is_leaf?: PdlIsLeaf8 - context?: IndependentEnum3 + context?: IndependentEnum2 kind?: Kind8 - lastOf: Lastof + array: Array } /** * Set of definitions executed before the execution of the block. * */ -export interface Defs12 { +export interface Defs13 { [k: string]: | boolean | number @@ -4128,15 +4411,16 @@ export interface Defs12 { | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null } /** - * Return the array of values computed by each block of the list of blocks. + * Return the object where the value of each field is defined by a block. If the body of the object is an array, the resulting object is the union of the objects computed by each element of the array. */ -export interface ArrayBlock { - description?: Description13 +export interface ObjectBlock { + description?: Description14 /** * Type specification of the result of the block. * @@ -4166,7 +4450,7 @@ export interface ArrayBlock { [k: string]: PdlTypeType } | null - defs?: Defs13 + defs?: Defs14 def?: Def7 contribute?: Contribute7 parser?: Parser7 @@ -4180,15 +4464,15 @@ export interface ArrayBlock { pdl__location?: PdlLocationType | null pdl__timing?: PdlTiming | null pdl__is_leaf?: PdlIsLeaf7 - context?: IndependentEnum2 + context?: IndependentEnum1 kind?: Kind7 - array: Array + object: Object1 } /** * Set of definitions executed before the execution of the block. * */ -export interface Defs13 { +export interface Defs14 { [k: string]: | boolean | number @@ -4212,15 +4496,16 @@ export interface Defs13 { | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null } /** - * Return the object where the value of each field is defined by a block. If the body of the object is an array, the resulting object is the union of the objects computed by each element of the array. + * Create a message. */ -export interface ObjectBlock { - description?: Description14 +export interface MessageBlock { + description?: Description15 /** * Type specification of the result of the block. * @@ -4250,7 +4535,7 @@ export interface ObjectBlock { [k: string]: PdlTypeType } | null - defs?: Defs14 + defs?: Defs15 def?: Def6 contribute?: Contribute6 parser?: Parser6 @@ -4264,15 +4549,16 @@ export interface ObjectBlock { pdl__location?: PdlLocationType | null pdl__timing?: PdlTiming | null pdl__is_leaf?: PdlIsLeaf6 - context?: IndependentEnum1 kind?: Kind6 - object: Object1 + content: Content + name?: Name + tool_call_id?: ToolCallId } /** * Set of definitions executed before the execution of the block. * */ -export interface Defs14 { +export interface Defs15 { [k: string]: | boolean | number @@ -4296,15 +4582,28 @@ export interface Defs14 { | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null } /** - * Create a message. + * Read from a file or standard input. + * + * Example. Read from the standard input with a prompt starting with `> `. + * ```PDL + * read: + * message: "> " + * ``` + * + * Example. Read the file `./data.yaml` in the same directory of the PDL file containing the block and parse it into YAML. + * ```PDL + * read: ./data.yaml + * parser: yaml + * ``` */ -export interface MessageBlock { - description?: Description15 +export interface ReadBlock { + description?: Description16 /** * Type specification of the result of the block. * @@ -4334,7 +4633,7 @@ export interface MessageBlock { [k: string]: PdlTypeType } | null - defs?: Defs15 + defs?: Defs16 def?: Def5 contribute?: Contribute5 parser?: Parser5 @@ -4349,15 +4648,15 @@ export interface MessageBlock { pdl__timing?: PdlTiming | null pdl__is_leaf?: PdlIsLeaf5 kind?: Kind5 - content: Content - name?: Name - tool_call_id?: ToolCallId + read: Read + message?: Message + multiline?: Multiline } /** * Set of definitions executed before the execution of the block. * */ -export interface Defs15 { +export interface Defs16 { [k: string]: | boolean | number @@ -4381,27 +4680,16 @@ export interface Defs15 { | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null } /** - * Read from a file or standard input. - * - * Example. Read from the standard input with a prompt starting with `> `. - * ```PDL - * read: - * message: "> " - * ``` - * - * Example. Read the file `./data.yaml` in the same directory of the PDL file containing the block and parse it into YAML. - * ```PDL - * read: ./data.yaml - * parser: yaml - * ``` + * Include a PDL file. */ -export interface ReadBlock { - description?: Description16 +export interface IncludeBlock { + description?: Description17 /** * Type specification of the result of the block. * @@ -4431,7 +4719,7 @@ export interface ReadBlock { [k: string]: PdlTypeType } | null - defs?: Defs16 + defs?: Defs17 def?: Def4 contribute?: Contribute4 parser?: Parser4 @@ -4445,16 +4733,16 @@ export interface ReadBlock { pdl__location?: PdlLocationType | null pdl__timing?: PdlTiming | null pdl__is_leaf?: PdlIsLeaf4 + context?: IndependentEnum kind?: Kind4 - read: Read - message?: Message - multiline?: Multiline + include: Include + pdl__trace?: PdlTrace1 } /** * Set of definitions executed before the execution of the block. * */ -export interface Defs16 { +export interface Defs17 { [k: string]: | boolean | number @@ -4478,15 +4766,16 @@ export interface Defs16 { | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null } /** - * Include a PDL file. + * Import a PDL file. */ -export interface IncludeBlock { - description?: Description17 +export interface ImportBlock { + description?: Description18 /** * Type specification of the result of the block. * @@ -4516,7 +4805,7 @@ export interface IncludeBlock { [k: string]: PdlTypeType } | null - defs?: Defs17 + defs?: Defs18 def?: Def3 contribute?: Contribute3 parser?: Parser3 @@ -4530,16 +4819,15 @@ export interface IncludeBlock { pdl__location?: PdlLocationType | null pdl__timing?: PdlTiming | null pdl__is_leaf?: PdlIsLeaf3 - context?: IndependentEnum kind?: Kind3 - include: Include - pdl__trace?: PdlTrace1 + import: Import + pdl__trace?: PdlTrace } /** * Set of definitions executed before the execution of the block. * */ -export interface Defs17 { +export interface Defs18 { [k: string]: | boolean | number @@ -4563,15 +4851,16 @@ export interface Defs17 { | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null } /** - * Import a PDL file. + * Create a new aggregator that can be use in the `contribute` field. */ -export interface ImportBlock { - description?: Description18 +export interface AggregatorBlock { + description?: Description19 /** * Type specification of the result of the block. * @@ -4601,7 +4890,7 @@ export interface ImportBlock { [k: string]: PdlTypeType } | null - defs?: Defs18 + defs?: Defs19 def?: Def2 contribute?: Contribute2 parser?: Parser2 @@ -4616,14 +4905,13 @@ export interface ImportBlock { pdl__timing?: PdlTiming | null pdl__is_leaf?: PdlIsLeaf2 kind?: Kind2 - import: Import - pdl__trace?: PdlTrace + aggregator: Aggregator } /** * Set of definitions executed before the execution of the block. * */ -export interface Defs18 { +export interface Defs19 { [k: string]: | boolean | number @@ -4647,6 +4935,7 @@ export interface Defs18 { | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -4655,7 +4944,7 @@ export interface Defs18 { * Block representing an error generated at runtime. */ export interface ErrorBlock { - description?: Description19 + description?: Description20 /** * Type specification of the result of the block. * @@ -4685,7 +4974,7 @@ export interface ErrorBlock { [k: string]: PdlTypeType } | null - defs?: Defs19 + defs?: Defs20 def?: Def1 contribute?: Contribute1 parser?: Parser1 @@ -4707,7 +4996,7 @@ export interface ErrorBlock { * Set of definitions executed before the execution of the block. * */ -export interface Defs19 { +export interface Defs20 { [k: string]: | boolean | number @@ -4731,6 +5020,7 @@ export interface Defs19 { | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -4739,7 +5029,7 @@ export interface Defs19 { * Block without an action. It can contain definitions. */ export interface EmptyBlock { - description?: Description20 + description?: Description21 /** * Type specification of the result of the block. * @@ -4769,7 +5059,7 @@ export interface EmptyBlock { [k: string]: PdlTypeType } | null - defs?: Defs20 + defs?: Defs21 def?: Def contribute?: Contribute parser?: Parser @@ -4789,7 +5079,7 @@ export interface EmptyBlock { * Set of definitions executed before the execution of the block. * */ -export interface Defs20 { +export interface Defs21 { [k: string]: | boolean | number @@ -4813,6 +5103,7 @@ export interface Defs20 { | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock | null @@ -4821,32 +5112,13 @@ export interface Defs20 { * Contribution of a specific value instead of the default one. */ export interface ContributeValue { - value: Value -} -export interface LocalizedExpression { - pdl__expr: PdlExpr - pdl__result?: unknown - pdl__location?: PdlLocationType | null -} -export interface PdlExpr { - [k: string]: unknown -} -/** - * Internal data structure to keep track of the source location information. - */ -export interface PdlLocationType { - path: Path - file: File - table: Table -} -export interface Table { - [k: string]: number + value: unknown } /** * Use a PDL program as a parser specification (experimental). */ export interface PdlParser { - description?: Description21 + description?: Description22 spec?: | ( | "null" @@ -4878,7 +5150,7 @@ export interface PdlParser { * A regular expression parser. */ export interface RegexParser { - description?: Description22 + description?: Description23 spec?: | ( | "null" @@ -4907,6 +5179,17 @@ export interface RegexParser { regex: Regex mode?: Mode } +/** + * Internal data structure to keep track of the source location information. + */ +export interface PdlLocationType { + path: Path + file: File + table: Table +} +export interface Table { + [k: string]: number +} /** * Internal data structure to record timing information in the trace. */ @@ -4916,6 +5199,23 @@ export interface PdlTiming { first_use_nanos?: FirstUseNanos timezone?: Timezone } +export interface FileAggregatorConfig { + description?: Description24 + file: File1 + mode?: Mode1 + encoding?: Encoding + prefix?: Prefix + suffix?: Suffix + flush?: Flush +} +export interface LocalizedExpression { + pdl__expr: PdlExpr + pdl__result?: unknown + pdl__location?: PdlLocationType | null +} +export interface PdlExpr { + [k: string]: unknown +} /** * Join loop iterations as a string. */ @@ -4956,21 +5256,21 @@ export interface MatchCase { * Match any of the patterns. */ export interface OrPattern { - def?: Def12 + def?: Def13 anyOf: Anyof } /** * Match an array. */ export interface ArrayPattern { - def?: Def13 + def?: Def14 array: Array1 } /** * Match an object. */ export interface ObjectPattern { - def?: Def14 + def?: Def15 object: Object2 } export interface Object2 { @@ -4988,7 +5288,7 @@ export interface Object2 { * Match any value. */ export interface AnyPattern { - def?: Def15 + def?: Def16 any: Any } /** diff --git a/pdl-live-react/src/pdl_ast_utils.ts b/pdl-live-react/src/pdl_ast_utils.ts index 7d57cd947..a0741a7ac 100644 --- a/pdl-live-react/src/pdl_ast_utils.ts +++ b/pdl-live-react/src/pdl_ast_utils.ts @@ -47,7 +47,7 @@ export function map_block_children( } // @ts-expect-error: TODO new_block = match(new_block) - // .with(P.string, s => s) + .with(P.union(P.nullish, P.boolean, P.number, P.string), (v) => v) .with({ kind: "empty" }, (block) => block) .with({ kind: "function" }, (block) => { const return_ = f_block(block.return) @@ -202,6 +202,7 @@ export function map_block_children( }) .with({ kind: "include" }, (block) => block) .with({ kind: "import" }, (block) => block) + .with({ kind: "aggregator" }, (block) => block) .with({ kind: undefined }, (block) => block) .exhaustive() match(new_block) @@ -293,6 +294,7 @@ export function iter_block_children( .with({ kind: "read" }, () => {}) .with({ kind: "include" }, () => {}) .with({ kind: "import" }, () => {}) + .with({ kind: "aggregator" }, () => {}) .with({ kind: undefined }, () => {}) .exhaustive() match(block) diff --git a/pdl-live-react/src/view/timeline/model.ts b/pdl-live-react/src/view/timeline/model.ts index c384c3e70..043e77c52 100644 --- a/pdl-live-react/src/view/timeline/model.ts +++ b/pdl-live-react/src/view/timeline/model.ts @@ -135,6 +135,7 @@ export function childrenOf(block: NonScalarPdlBlock) { .with({ kind: "read" }, (data) => [data.pdl__result]) .with({ kind: "include" }, (data) => [data.pdl__trace ?? data.pdl__result]) .with({ kind: "import" }, (data) => [data.pdl__trace ?? data.pdl__result]) + .with({ kind: "aggregator" }, () => []) .with({ kind: "function" }, () => []) .with({ kind: "call" }, (data) => [data.pdl__trace ?? data.pdl__result]) .with({ kind: "text" }, (data) => [data.text]) diff --git a/src/pdl/pdl-schema.json b/src/pdl/pdl-schema.json index 17a6c3f60..a83ceafc7 100644 --- a/src/pdl/pdl-schema.json +++ b/src/pdl/pdl-schema.json @@ -1,5 +1,404 @@ { "$defs": { + "AggregatorBlock": { + "additionalProperties": false, + "description": "Create a new aggregator that can be use in the `contribute` field.", + "properties": { + "description": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "description": "Documentation associated to the block.\n ", + "title": "Description" + }, + "spec": { + "$ref": "#/$defs/PdlTypeType", + "default": null, + "description": "Type specification of the result of the block.\n " + }, + "defs": { + "additionalProperties": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "integer" + }, + { + "type": "number" + }, + { + "type": "string" + }, + { + "$ref": "#/$defs/FunctionBlock" + }, + { + "$ref": "#/$defs/CallBlock" + }, + { + "$ref": "#/$defs/LitellmModelBlock" + }, + { + "$ref": "#/$defs/GraniteioModelBlock" + }, + { + "$ref": "#/$defs/CodeBlock" + }, + { + "$ref": "#/$defs/ArgsBlock" + }, + { + "$ref": "#/$defs/GetBlock" + }, + { + "$ref": "#/$defs/DataBlock" + }, + { + "$ref": "#/$defs/IfBlock" + }, + { + "$ref": "#/$defs/MatchBlock" + }, + { + "$ref": "#/$defs/RepeatBlock" + }, + { + "$ref": "#/$defs/TextBlock" + }, + { + "$ref": "#/$defs/LastOfBlock" + }, + { + "$ref": "#/$defs/ArrayBlock" + }, + { + "$ref": "#/$defs/ObjectBlock" + }, + { + "$ref": "#/$defs/MessageBlock" + }, + { + "$ref": "#/$defs/ReadBlock" + }, + { + "$ref": "#/$defs/IncludeBlock" + }, + { + "$ref": "#/$defs/ImportBlock" + }, + { + "$ref": "#/$defs/AggregatorBlock" + }, + { + "$ref": "#/$defs/ErrorBlock" + }, + { + "$ref": "#/$defs/EmptyBlock" + }, + { + "type": "null" + } + ] + }, + "default": {}, + "description": "Set of definitions executed before the execution of the block.\n ", + "title": "Defs", + "type": "object" + }, + "def": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "description": "Name of the variable used to store the result of the execution of the block.\n ", + "title": "Def" + }, + "contribute": { + "default": [ + "result", + "context" + ], + "description": "Indicate if the block contributes to the result and background context.\n ", + "items": { + "anyOf": [ + { + "$ref": "#/$defs/ContributeTarget" + }, + { + "type": "string" + }, + { + "additionalProperties": { + "$ref": "#/$defs/ContributeValue" + }, + "type": "object" + } + ] + }, + "title": "Contribute", + "type": "array" + }, + "parser": { + "anyOf": [ + { + "enum": [ + "json", + "jsonl", + "yaml" + ], + "type": "string" + }, + { + "$ref": "#/$defs/PdlParser" + }, + { + "$ref": "#/$defs/RegexParser" + }, + { + "type": "null" + } + ], + "default": null, + "description": "Parser to use to construct a value out of a string result.", + "title": "Parser" + }, + "fallback": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "integer" + }, + { + "type": "number" + }, + { + "type": "string" + }, + { + "$ref": "#/$defs/FunctionBlock" + }, + { + "$ref": "#/$defs/CallBlock" + }, + { + "$ref": "#/$defs/LitellmModelBlock" + }, + { + "$ref": "#/$defs/GraniteioModelBlock" + }, + { + "$ref": "#/$defs/CodeBlock" + }, + { + "$ref": "#/$defs/ArgsBlock" + }, + { + "$ref": "#/$defs/GetBlock" + }, + { + "$ref": "#/$defs/DataBlock" + }, + { + "$ref": "#/$defs/IfBlock" + }, + { + "$ref": "#/$defs/MatchBlock" + }, + { + "$ref": "#/$defs/RepeatBlock" + }, + { + "$ref": "#/$defs/TextBlock" + }, + { + "$ref": "#/$defs/LastOfBlock" + }, + { + "$ref": "#/$defs/ArrayBlock" + }, + { + "$ref": "#/$defs/ObjectBlock" + }, + { + "$ref": "#/$defs/MessageBlock" + }, + { + "$ref": "#/$defs/ReadBlock" + }, + { + "$ref": "#/$defs/IncludeBlock" + }, + { + "$ref": "#/$defs/ImportBlock" + }, + { + "$ref": "#/$defs/AggregatorBlock" + }, + { + "$ref": "#/$defs/ErrorBlock" + }, + { + "$ref": "#/$defs/EmptyBlock" + }, + { + "type": "null" + } + ], + "default": null, + "description": "Block to execute in case of error.\n ", + "title": "Fallback" + }, + "retry": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": null, + "description": "The maximum number of times to retry when an error occurs within a block.\n ", + "title": "Retry" + }, + "trace_error_on_retry": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "description": "Whether to add the errors while retrying to the trace. Set this to true to use retry feature for multiple LLM trials.\n ", + "title": "Trace Error On Retry" + }, + "role": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "description": "Role associated to the block and sub-blocks.\nTypical roles are `system`, `user`, and `assistant`,\nbut there may be other roles such as `available_tools`.", + "title": "Role" + }, + "pdl__context": { + "anyOf": [ + { + "items": { + "additionalProperties": true, + "type": "object" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": [], + "description": "Current context\n ", + "title": "Pdl Context" + }, + "pdl__id": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": "", + "description": "Unique identifier for this block\n ", + "title": "Pdl Id" + }, + "pdl__result": { + "anyOf": [ + {}, + { + "type": "null" + } + ], + "default": null, + "description": "Result of the execution of the block", + "title": "Pdl Result" + }, + "pdl__location": { + "anyOf": [ + { + "$ref": "#/$defs/PdlLocationType" + }, + { + "type": "null" + } + ], + "default": null + }, + "pdl__timing": { + "anyOf": [ + { + "$ref": "#/$defs/PdlTiming" + }, + { + "type": "null" + } + ], + "default": null + }, + "pdl__is_leaf": { + "const": true, + "default": true, + "title": "Pdl Is Leaf", + "type": "boolean" + }, + "kind": { + "const": "aggregator", + "default": "aggregator", + "title": "Kind", + "type": "string" + }, + "aggregator": { + "anyOf": [ + { + "const": "context", + "type": "string" + }, + { + "$ref": "#/$defs/FileAggregatorConfig" + } + ], + "title": "Aggregator" + } + }, + "required": [ + "aggregator" + ], + "title": "AggregatorBlock", + "type": "object" + }, "AnyPattern": { "additionalProperties": false, "description": "Match any value.", @@ -122,6 +521,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -162,6 +564,9 @@ { "$ref": "#/$defs/ContributeTarget" }, + { + "type": "string" + }, { "additionalProperties": { "$ref": "#/$defs/ContributeValue" @@ -268,6 +673,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -521,6 +929,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -561,6 +972,9 @@ { "$ref": "#/$defs/ContributeTarget" }, + { + "type": "string" + }, { "additionalProperties": { "$ref": "#/$defs/ContributeValue" @@ -667,6 +1081,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -875,6 +1292,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -1048,6 +1468,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -1088,6 +1511,9 @@ { "$ref": "#/$defs/ContributeTarget" }, + { + "type": "string" + }, { "additionalProperties": { "$ref": "#/$defs/ContributeValue" @@ -1194,6 +1620,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -1425,6 +1854,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -1539,6 +1971,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -1579,6 +2014,9 @@ { "$ref": "#/$defs/ContributeTarget" }, + { + "type": "string" + }, { "additionalProperties": { "$ref": "#/$defs/ContributeValue" @@ -1685,6 +2123,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -1899,6 +2340,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -1924,7 +2368,9 @@ "description": "Values allowed in the `contribute` field.", "enum": [ "result", - "context" + "context", + "stdout", + "stderr" ], "title": "ContributeTarget", "type": "string" @@ -1938,10 +2384,7 @@ { "$ref": "#/$defs/LocalizedExpression_TypeVar_" }, - { - "items": {}, - "type": "array" - }, + {}, { "type": "string" } @@ -2049,6 +2492,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -2089,6 +2535,9 @@ { "$ref": "#/$defs/ContributeTarget" }, + { + "type": "string" + }, { "additionalProperties": { "$ref": "#/$defs/ContributeValue" @@ -2195,6 +2644,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -2446,6 +2898,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -2486,6 +2941,9 @@ { "$ref": "#/$defs/ContributeTarget" }, + { + "type": "string" + }, { "additionalProperties": { "$ref": "#/$defs/ContributeValue" @@ -2592,6 +3050,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -2837,6 +3298,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -2877,6 +3341,9 @@ { "$ref": "#/$defs/ContributeTarget" }, + { + "type": "string" + }, { "additionalProperties": { "$ref": "#/$defs/ContributeValue" @@ -2983,6 +3450,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -3190,6 +3660,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -3211,6 +3684,112 @@ "title": "ErrorBlock", "type": "object" }, + "FileAggregatorConfig": { + "additionalProperties": false, + "properties": { + "description": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "description": "Documentation associated to the aggregator config.\n ", + "title": "Description" + }, + "file": { + "anyOf": [ + { + "$ref": "#/$defs/LocalizedExpression_TypeVar_" + }, + { + "type": "string" + } + ], + "description": "Name of the file to which contribute.", + "title": "File" + }, + "mode": { + "anyOf": [ + { + "$ref": "#/$defs/LocalizedExpression_TypeVar_" + }, + { + "type": "string" + } + ], + "default": "w", + "description": "File opening mode.", + "title": "Mode" + }, + "encoding": { + "anyOf": [ + { + "$ref": "#/$defs/LocalizedExpression_TypeVar_" + }, + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": "utf-8", + "description": "File encoding.", + "title": "Encoding" + }, + "prefix": { + "anyOf": [ + { + "$ref": "#/$defs/LocalizedExpression_TypeVar_" + }, + { + "type": "string" + } + ], + "default": "", + "description": "Prefix to the contributed value.", + "title": "Prefix" + }, + "suffix": { + "anyOf": [ + { + "$ref": "#/$defs/LocalizedExpression_TypeVar_" + }, + { + "type": "string" + } + ], + "default": "\n", + "description": "Suffix to the contributed value.", + "title": "Suffix" + }, + "flush": { + "anyOf": [ + { + "$ref": "#/$defs/LocalizedExpression_TypeVar_" + }, + { + "type": "boolean" + }, + { + "type": "string" + } + ], + "default": false, + "description": "Whether to forcibly flush the stream.", + "title": "Flush" + } + }, + "required": [ + "file" + ], + "title": "FileAggregatorConfig", + "type": "object" + }, "FunctionBlock": { "additionalProperties": false, "description": "Function declaration.", @@ -3305,6 +3884,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -3345,6 +3927,9 @@ { "$ref": "#/$defs/ContributeTarget" }, + { + "type": "string" + }, { "additionalProperties": { "$ref": "#/$defs/ContributeValue" @@ -3451,6 +4036,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -3668,6 +4256,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -3798,6 +4389,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -3838,6 +4432,9 @@ { "$ref": "#/$defs/ContributeTarget" }, + { + "type": "string" + }, { "additionalProperties": { "$ref": "#/$defs/ContributeValue" @@ -3944,6 +4541,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -4181,6 +4781,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -4221,6 +4824,9 @@ { "$ref": "#/$defs/ContributeTarget" }, + { + "type": "string" + }, { "additionalProperties": { "$ref": "#/$defs/ContributeValue" @@ -4327,6 +4933,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -4529,6 +5138,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -4783,6 +5395,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -4823,6 +5438,9 @@ { "$ref": "#/$defs/ContributeTarget" }, + { + "type": "string" + }, { "additionalProperties": { "$ref": "#/$defs/ContributeValue" @@ -4929,6 +5547,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -5150,6 +5771,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -5234,6 +5858,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -5350,6 +5977,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -5390,6 +6020,9 @@ { "$ref": "#/$defs/ContributeTarget" }, + { + "type": "string" + }, { "additionalProperties": { "$ref": "#/$defs/ContributeValue" @@ -5496,6 +6129,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -5703,6 +6339,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -5817,6 +6456,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -5857,6 +6499,9 @@ { "$ref": "#/$defs/ContributeTarget" }, + { + "type": "string" + }, { "additionalProperties": { "$ref": "#/$defs/ContributeValue" @@ -5963,6 +6608,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -6174,6 +6822,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -6393,6 +7044,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -6433,6 +7087,9 @@ { "$ref": "#/$defs/ContributeTarget" }, + { + "type": "string" + }, { "additionalProperties": { "$ref": "#/$defs/ContributeValue" @@ -6539,6 +7196,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -6747,6 +7407,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -6862,6 +7525,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -6902,6 +7568,9 @@ { "$ref": "#/$defs/ContributeTarget" }, + { + "type": "string" + }, { "additionalProperties": { "$ref": "#/$defs/ContributeValue" @@ -7008,6 +7677,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -7210,6 +7882,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -7844,6 +8519,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -7884,6 +8562,9 @@ { "$ref": "#/$defs/ContributeTarget" }, + { + "type": "string" + }, { "additionalProperties": { "$ref": "#/$defs/ContributeValue" @@ -7990,6 +8671,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -8280,6 +8964,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -8429,6 +9116,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -8469,6 +9159,9 @@ { "$ref": "#/$defs/ContributeTarget" }, + { + "type": "string" + }, { "additionalProperties": { "$ref": "#/$defs/ContributeValue" @@ -8575,6 +9268,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -8777,6 +9473,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -8923,6 +9622,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -8963,6 +9665,9 @@ { "$ref": "#/$defs/ContributeTarget" }, + { + "type": "string" + }, { "additionalProperties": { "$ref": "#/$defs/ContributeValue" @@ -9069,6 +9774,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -9278,6 +9986,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -9363,6 +10074,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -9605,6 +10319,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -9739,6 +10456,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -9965,6 +10685,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -10072,6 +10795,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -10112,6 +10838,9 @@ { "$ref": "#/$defs/ContributeTarget" }, + { + "type": "string" + }, { "additionalProperties": { "$ref": "#/$defs/ContributeValue" @@ -10218,6 +10947,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -10527,6 +11259,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -10567,6 +11302,9 @@ { "$ref": "#/$defs/ContributeTarget" }, + { + "type": "string" + }, { "additionalProperties": { "$ref": "#/$defs/ContributeValue" @@ -10673,6 +11411,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -10935,6 +11676,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -11079,6 +11823,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -11200,6 +11947,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -11240,6 +11990,9 @@ { "$ref": "#/$defs/ContributeTarget" }, + { + "type": "string" + }, { "additionalProperties": { "$ref": "#/$defs/ContributeValue" @@ -11346,6 +12099,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -11552,6 +12308,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, @@ -11630,6 +12389,9 @@ { "$ref": "#/$defs/ImportBlock" }, + { + "$ref": "#/$defs/AggregatorBlock" + }, { "$ref": "#/$defs/ErrorBlock" }, diff --git a/src/pdl/pdl_ast.py b/src/pdl/pdl_ast.py index 396fe7570..550352291 100644 --- a/src/pdl/pdl_ast.py +++ b/src/pdl/pdl_ast.py @@ -65,6 +65,7 @@ class BlockKind(StrEnum): READ = "read" INCLUDE = "include" IMPORT = "import" + AGGREGATOR = "aggregator" EMPTY = "empty" ERROR = "error" @@ -272,6 +273,8 @@ class ContributeTarget(StrEnum): RESULT = "result" CONTEXT = "context" + STDOUT = "stdout" + STDERR = "stderr" class ContributeValue(BaseModel): @@ -279,10 +282,13 @@ class ContributeValue(BaseModel): model_config = ConfigDict(extra="forbid") - value: ExpressionType[list[Any]] + value: ExpressionType[Any] """Value to contribute.""" +ContributeElement: TypeAlias = ContributeTarget | str | dict[str, ContributeValue] + + class PdlTiming(BaseModel): """Internal data structure to record timing information in the trace.""" @@ -333,7 +339,7 @@ class Block(BaseModel): def_: Optional[str] = Field(default=None, alias="def") """Name of the variable used to store the result of the execution of the block. """ - contribute: Sequence[ContributeTarget | dict[str, ContributeValue]] = [ + contribute: Sequence[ContributeElement] = [ ContributeTarget.RESULT, ContributeTarget.CONTEXT, ] @@ -944,6 +950,45 @@ class ImportBlock(LeafBlock): pdl__trace: Optional["BlockType"] = None +class AggregatorConfig(BaseModel): + """Common fields for all aggregator configurations.""" + + model_config = ConfigDict( + extra="forbid", + use_attribute_docstrings=True, + arbitrary_types_allowed=True, + ) + + description: Optional[str] = None + """Documentation associated to the aggregator config. + """ + + +class FileAggregatorConfig(AggregatorConfig): + file: ExpressionType[str] + """Name of the file to which contribute.""" + mode: ExpressionType[str] = "w" + """File opening mode.""" + encoding: ExpressionType[Optional[str]] = "utf-8" + """File encoding.""" + prefix: ExpressionType[str] = "" + """Prefix to the contributed value.""" + suffix: ExpressionType[str] = "\n" + """Suffix to the contributed value.""" + flush: ExpressionType[bool] = False + """Whether to forcibly flush the stream.""" + + +AggregatorType: TypeAlias = Literal["context"] | FileAggregatorConfig + + +class AggregatorBlock(LeafBlock): + """Create a new aggregator that can be use in the `contribute` field.""" + + kind: Literal[BlockKind.AGGREGATOR] = BlockKind.AGGREGATOR + aggregator: AggregatorType + + class ErrorBlock(LeafBlock): """Block representing an error generated at runtime.""" @@ -982,6 +1027,7 @@ class EmptyBlock(LeafBlock): | ReadBlock | IncludeBlock | ImportBlock + | AggregatorBlock | ErrorBlock | EmptyBlock ) diff --git a/src/pdl/pdl_ast_utils.py b/src/pdl/pdl_ast_utils.py index 241662680..3a775b7ca 100644 --- a/src/pdl/pdl_ast_utils.py +++ b/src/pdl/pdl_ast_utils.py @@ -1,6 +1,7 @@ from typing import Callable, Sequence from .pdl_ast import ( + AggregatorBlock, ArrayBlock, Block, BlockType, @@ -95,6 +96,8 @@ def iter_block_children(f: Callable[[BlockType], None], block: BlockType) -> Non case ImportBlock(): if block.pdl__trace is not None: f(block.pdl__trace) + case AggregatorBlock(): + pass case EmptyBlock(): pass case _: @@ -201,6 +204,8 @@ def map_block_children(f: MappedFunctions, block: BlockType) -> BlockType: case ImportBlock(): if block.pdl__trace is not None: block.pdl__trace = f.f_block(block.pdl__trace) + case AggregatorBlock(): + pass case EmptyBlock(): pass case _: diff --git a/src/pdl/pdl_compilers/to_regex.py b/src/pdl/pdl_compilers/to_regex.py index 602e81a0c..3b61b8930 100644 --- a/src/pdl/pdl_compilers/to_regex.py +++ b/src/pdl/pdl_compilers/to_regex.py @@ -4,6 +4,7 @@ from typing import Sequence, TypeAlias from ..pdl_ast import ( + AggregatorBlock, Block, BlockType, CallBlock, @@ -318,6 +319,8 @@ def compile_block( regex = ReStar(ReAnyChar()) # XXX TODO XXX case ImportBlock(): regex = ReStar(ReAnyChar()) # XXX TODO XXX + case AggregatorBlock(): + regex = ReStar(ReAnyChar()) # XXX TODO XXX case FunctionBlock(): regex = ReStar(ReAnyChar()) # XXX TODO XXX # scope = scope | {x: ReStar(ReAnyChar) for x in block.function.keys()} diff --git a/src/pdl/pdl_dumper.py b/src/pdl/pdl_dumper.py index bcd3f9379..341e22a9d 100644 --- a/src/pdl/pdl_dumper.py +++ b/src/pdl/pdl_dumper.py @@ -8,6 +8,8 @@ from . import pdl_ast from .pdl_ast import ( + AggregatorBlock, + AggregatorType, AnyPattern, ArgsBlock, ArrayBlock, @@ -15,13 +17,14 @@ Block, CallBlock, CodeBlock, + ContributeElement, ContributeTarget, - ContributeValue, DataBlock, EmptyBlock, EnumPdlType, ErrorBlock, ExpressionType, + FileAggregatorConfig, FunctionBlock, GetBlock, GraniteioModelBlock, @@ -213,6 +216,8 @@ def block_to_dict( # noqa: C901 d["import"] = block.import_ if block.pdl__trace: d["pdl__trace"] = block_to_dict(block.pdl__trace, json_compatible) + case AggregatorBlock(): + d["aggregator"] = aggregator_to_dict(block.aggregator) case IfBlock(): d["if"] = expr_to_dict(block.condition, json_compatible) d["then"] = block_to_dict(block.then, json_compatible) @@ -453,7 +458,7 @@ def location_to_dict(location: PdlLocationType) -> dict[str, Any]: def contribute_to_list( - contribute: Sequence[ContributeTarget | dict[str, ContributeValue]], + contribute: Sequence[ContributeElement], ) -> list[str | dict[str, Any]]: acc: list[str | dict[str, Any]] = [] for contrib in contribute: @@ -464,6 +469,17 @@ def contribute_to_list( return acc +def aggregator_to_dict(aggregator: AggregatorType): + match aggregator: + case "context": + result = aggregator + case FileAggregatorConfig(): + result = aggregator.model_dump() + case _: + assert False, "Unexpected aggregator" + return result + + def build_exclude(obj: Any, regex: re.Pattern[str]) -> Any: if isinstance(obj, BaseModel): exclude: dict[str, Any] = {} diff --git a/src/pdl/pdl_interpreter.py b/src/pdl/pdl_interpreter.py index 85fe87041..fc9b89ee2 100644 --- a/src/pdl/pdl_interpreter.py +++ b/src/pdl/pdl_interpreter.py @@ -10,6 +10,7 @@ # TODO: temporarily disabling warnings to mute a pydantic warning from liteLLM import warnings +from abc import ABC, abstractmethod from asyncio import AbstractEventLoop from functools import partial from os import getenv @@ -17,7 +18,7 @@ warnings.filterwarnings("ignore", "Valid config keys have changed in V2") from pathlib import Path # noqa: E402 -from typing import Any, Generator, Optional, Sequence, TypeVar # noqa: E402 +from typing import IO, Any, Generator, Optional, Sequence, TypeVar # noqa: E402 import httpx # noqa: E402 import json_repair # noqa: E402 @@ -36,6 +37,7 @@ from .pdl_ast import ( # noqa: E402 AdvancedBlockType, + AggregatorBlock, AnyPattern, ArgsBlock, ArrayBlock, @@ -45,12 +47,14 @@ BlockType, CallBlock, CodeBlock, + ContributeElement, ContributeTarget, ContributeValue, DataBlock, EmptyBlock, ErrorBlock, ExpressionType, + FileAggregatorConfig, FunctionBlock, GetBlock, GraniteioModelBlock, @@ -63,6 +67,7 @@ LastOfBlock, LazyMessage, LazyMessages, + LeafBlock, LitellmModelBlock, LitellmParameters, LocalizedExpression, @@ -121,7 +126,7 @@ from .pdl_utils import ( # noqa: E402 GeneratorWrapper, apply_defaults, - get_contribute_value, + get_contribute_context_value, replace_contribute_value, stringify, value_of_expr, @@ -304,7 +309,7 @@ def process_block( def context_in_contribute(block: AdvancedBlockType) -> bool: if ContributeTarget.CONTEXT.value in block.contribute: return True - if get_contribute_value(block.contribute) is not None: + if get_contribute_context_value(block.contribute) is not None: return True return False @@ -391,7 +396,7 @@ def process_advanced_block( init_state = state state = state.with_yield_result( state.yield_result - and ContributeTarget.RESULT in block.contribute + and ContributeTarget.RESULT.value in block.contribute and block.parser is None ) state = state.with_yield_background( @@ -417,13 +422,11 @@ def process_advanced_block( ) trace = trace.model_copy(update={"pdl__result": result}) if block.parser is not None: - # Use partial to create a function with fixed arguments parser_func = partial(parse_result, block.parser) result = lazy_apply(parser_func, result) - if init_state.yield_result and ContributeTarget.RESULT: + if init_state.yield_result: yield_result(result, block.kind) if block.spec is not None and not isinstance(block, FunctionBlock): - # Use partial to create a function with fixed arguments checker = partial( result_with_type_checking, spec=block.spec, @@ -479,14 +482,15 @@ def process_advanced_block( if block.def_ is not None: var = block.def_ new_scope = new_scope | PdlDict({var: result}) - if ContributeTarget.RESULT not in block.contribute: - result = PdlConst("") - if ContributeTarget.CONTEXT not in block.contribute: + new_scope, trace = process_contribute(trace, result, new_scope, loc) + if ContributeTarget.CONTEXT.value not in block.contribute: background = DependentContext([]) - contribute_value, trace = process_contribute(trace, new_scope, loc) - if contribute_value is not None: - background = DependentContext([contribute_value]) - + else: + contribute_value, trace = process_contribute_context(trace, new_scope, loc) + if contribute_value is not None: + background = DependentContext([contribute_value]) + if ContributeTarget.RESULT.value not in block.contribute: + result = PdlConst("") return result, background, new_scope, trace @@ -908,6 +912,11 @@ def process_block_body( case ImportBlock(): result, background, scope, trace = process_import(state, scope, block, loc) + case AggregatorBlock(): + result, background, scope, trace = process_aggregator( + state, scope, block, loc + ) + case FunctionBlock(): closure = block.model_copy() if block.def_ is not None: @@ -1182,19 +1191,17 @@ def combine_results(iteration_type: IterationType, results: list[PdlLazy[Any]]): return result -BlockTypeTVarProcessContribute = TypeVar( - "BlockTypeTVarProcessContribute", bound=AdvancedBlockType +BlockTypeTVarProcessContributeOld = TypeVar( + "BlockTypeTVarProcessContributeOld", bound=AdvancedBlockType ) -def process_contribute( - block: BlockTypeTVarProcessContribute, scope: ScopeType, loc: PdlLocationType -) -> tuple[Any, BlockTypeTVarProcessContribute]: - result: list[ContributeTarget | dict[str, ContributeValue]] - value_trace: LocalizedExpression[ - list[ContributeTarget | dict[str, ContributeValue]] - ] - value = get_contribute_value(block.contribute) +def process_contribute_context( + block: BlockTypeTVarProcessContributeOld, scope: ScopeType, loc: PdlLocationType +) -> tuple[Any, BlockTypeTVarProcessContributeOld]: + result: list[ContributeElement] + value_trace: LocalizedExpression[list[ContributeElement]] + value = get_contribute_context_value(block.contribute) if value is None: return None, block loc = append(loc, "contribute") @@ -1213,6 +1220,74 @@ def process_contribute( return result, trace +BlockTypeTVarProcessContribute = TypeVar( + "BlockTypeTVarProcessContribute", bound=AdvancedBlockType +) + + +def process_contribute( + block: BlockTypeTVarProcessContribute, + result: Any, + scope: ScopeType, + loc: PdlLocationType, +) -> tuple[ScopeType, BlockTypeTVarProcessContribute]: + loc = append(loc, "contribute") + contribute = [] + for i, elem in enumerate(block.contribute): + scope, elem = process_contribution( + block, elem, result, scope, append(loc, "[" + str(i) + "]") + ) + contribute.append(elem) + trace = block.model_copy(update={"contribute": contribute}) + return scope, trace + + +def process_contribution( + block: AdvancedBlockType, + elem: ContributeElement, + result: Any, + scope: ScopeType, + loc: PdlLocationType, +) -> tuple[ScopeType, ContributeElement]: + target: ContributeTarget | str + match elem: + case ContributeTarget.RESULT | "result" | ContributeTarget.CONTEXT | "context": + return scope, elem + case ContributeTarget() | str(): + target = elem + case dict(): + if len(elem) != 1: + msg = "Contributions are expected to be strings or dictionaries of length 1 but got {elem}" + raise PDLRuntimeError( + msg, + loc=loc, + trace=ErrorBlock(msg=msg, pdl__location=loc, program=block), + fallback=[], + ) + target, contribute_value = list(elem.items()).pop() + try: + result, value_trace = process_expr(scope, contribute_value.value, loc) + except PDLRuntimeExpressionError as exc: + raise PDLRuntimeError( + exc.message, + loc=exc.loc or loc, + trace=ErrorBlock(msg=exc.message, pdl__location=loc, program=block), + ) from exc + elem = {target: ContributeValue(value=value_trace)} + case _: + msg = "Contributions are expected to be strings or dictionaries of length 1 but got {elem}" + raise PDLRuntimeError( + msg, + loc=loc, + trace=ErrorBlock(msg=msg, pdl__location=loc, program=block), + fallback=[], + ) + aggregator = get_contribute_aggregator(block, target, scope, loc) + aggregator = aggregator.contribute(result, block.role, loc, block) + scope = scope | {target: aggregator} + return scope, elem + + BlockTypeTVarProcessExprOf = TypeVar( "BlockTypeTVarProcessExprOf", bound=AdvancedBlockType ) @@ -2038,6 +2113,163 @@ def process_import( ) from exc +class Aggregator(ABC): + @abstractmethod + def contribute( + self, + result: PdlLazy[Any], + role: Optional[RoleType] = None, + loc: Optional[PdlLocationType] = None, + block: Optional[BlockType] = None, + ) -> "Aggregator": + """Function executed at the end of each block that contain the aggregator. + + Args: + result: value computed by the block + role: role associated to the block. Defaults to None. + loc: source code location of the block. Defaults to None. + block: block contributing the value. Defaults to None. + + Returns: + Aggregator: new aggregator with the contributed value. + """ + + +class ContextAggregator(Aggregator): + def __init__(self, messages: Optional[LazyMessages] = None): + if messages is None: + self.messages: LazyMessages = DependentContext([]) + else: + self.messages = messages + + def contribute( + self, + result: PdlLazy[Any], + role: Optional[RoleType] = None, + loc: Optional[PdlLocationType] = None, + block: Optional[BlockType] = None, + ) -> "ContextAggregator": + match block: + case None | StructuredBlock(): + return self + case LeafBlock(): + block_id = ".".join(block.pdl__id or []) + msg = {"role": role, "content": result, "pdl__defsite": block_id} + case _: + msg = {"role": role, "content": result} + new_messages: LazyMessages = SingletonContext(PdlDict(msg)) + messages = DependentContext([self.messages, new_messages]) + return ContextAggregator(messages) + + +class FileAggregator(Aggregator): + def __init__( + self, fp: IO, prefix: str = "", suffix: str = "\n", flush: bool = False + ): + self.fp = fp + self.prefix = prefix + self.suffix = suffix + self.flush = flush + + def contribute( + self, + result: PdlLazy[Any], + role: Optional[RoleType] = None, + loc: Optional[PdlLocationType] = None, + block: Optional[BlockType] = None, + ) -> "FileAggregator": + print(f"{self.prefix}{result}", file=self.fp, end=self.suffix, flush=self.flush) + return self + + +def process_aggregator( + state: InterpreterState, + scope: ScopeType, + block: AggregatorBlock, + loc: PdlLocationType, +) -> tuple[PdlLazy[Aggregator], LazyMessages, ScopeType, AggregatorBlock]: + aggregator: Aggregator + match block.aggregator: + case "context": + aggregator = ContextAggregator() + case FileAggregatorConfig(): + try: + cfg = block.aggregator + file: str + file_trace: ExpressionType[str] + file, file_trace = process_expr(scope, cfg.file, loc) + mode: str + mode_trace: ExpressionType[str] + mode, mode_trace = process_expr(scope, cfg.mode, loc) + encoding: Optional[str] + encoding_trace: ExpressionType[Optional[str]] + encoding, encoding_trace = process_expr(scope, cfg.encoding, loc) + prefix: str + prefix_trace: ExpressionType[str] + prefix, prefix_trace = process_expr(scope, cfg.prefix, loc) + suffix: str + suffix_trace: ExpressionType[str] + suffix, suffix_trace = process_expr(scope, cfg.suffix, loc) + flush: bool + flush_trace: ExpressionType[bool] + flush, flush_trace = process_expr(scope, cfg.flush, loc) + cfg = block.aggregator.model_copy( + update={ + "file": file_trace, + "mode": mode_trace, + "encoding": encoding_trace, + "prefix": prefix_trace, + "suffix": suffix_trace, + "flush": flush_trace, + } + ) + trace = block.model_copy(update={"aggregator": cfg}) + except PDLRuntimeExpressionError as exc: + raise PDLRuntimeError( + exc.message, + loc=exc.loc or loc, + trace=ErrorBlock(msg=exc.message, pdl__location=loc, program=block), + ) from exc + fp = open( # pylint: disable=consider-using-with + file, mode=mode, encoding=encoding + ) + aggregator = FileAggregator(fp, prefix=prefix, suffix=suffix, flush=flush) + case _: + assert False, "Unexpected aggregator" + background: LazyMessages = DependentContext([]) + trace = block.model_copy() + return PdlConst(aggregator), background, scope, trace + + +def get_contribute_aggregator( + block: AdvancedBlockType, + target: ContributeTarget | str, + scope: ScopeType, + loc: PdlLocationType, +) -> Aggregator: + match target: + case ContributeTarget.STDOUT | "stdout": + aggregator = FileAggregator(sys.stdout, flush=True) + case ContributeTarget.STDERR | "stderr": + aggregator = FileAggregator(sys.stderr, flush=True) + case str(): + aggregator = get_var(target, scope, loc) + if isinstance(aggregator, PdlLazy): + aggregator = aggregator.result() + if not isinstance(aggregator, Aggregator): + msg = f"An aggregator was expected but got a value of type {type(aggregator)}." + raise PDLRuntimeError( + msg, + loc=loc, + trace=ErrorBlock(msg=msg, pdl__location=loc, program=block), + fallback=[], + ) + + case _: + assert False, f"Unexpected target type: {type(target)}" + return aggregator + + JSONReturnType = dict[str, Any] | list[Any] | str | float | int | bool | None diff --git a/src/pdl/pdl_scheduler.py b/src/pdl/pdl_scheduler.py index 5e126ae7f..909a54b95 100644 --- a/src/pdl/pdl_scheduler.py +++ b/src/pdl/pdl_scheduler.py @@ -57,6 +57,8 @@ def color_of(kind: BlockKind): color = None case BlockKind.IMPORT: color = None + case BlockKind.AGGREGATOR: + color = None case BlockKind.EMPTY: color = None case BlockKind.ERROR: diff --git a/src/pdl/pdl_utils.py b/src/pdl/pdl_utils.py index 59afcef39..47fd5e669 100644 --- a/src/pdl/pdl_utils.py +++ b/src/pdl/pdl_utils.py @@ -6,6 +6,7 @@ from .pdl_ast import ( BlockType, + ContributeElement, ContributeTarget, ContributeValue, ExpressionType, @@ -81,8 +82,8 @@ def value_of_expr(expr: ExpressionType[ValueOfExprT]) -> ValueOfExprT: return v # type: ignore -def replace_contribute_value( - contribute: Sequence[ContributeTarget | dict[str, ContributeValue]], +def replace_contribute_value( # TODO: remove + contribute: Sequence[ContributeElement], value: ContributeValue, ): ret = [] @@ -95,14 +96,14 @@ def replace_contribute_value( return ret -def get_contribute_value( - contribute: Sequence[ContributeTarget | dict[str, ContributeValue]] | None, +def get_contribute_context_value( + contribute: Sequence[ContributeElement] | None, ): if contribute is None: return None for item in contribute: if isinstance(item, dict) and isinstance( - item[ContributeTarget.CONTEXT], ContributeValue + item.get(ContributeTarget.CONTEXT), ContributeValue ): return item[ContributeTarget.CONTEXT].value return None diff --git a/tests/results/examples/aggregators/contribute_in_file.0.result b/tests/results/examples/aggregators/contribute_in_file.0.result new file mode 100644 index 000000000..281fc3326 --- /dev/null +++ b/tests/results/examples/aggregators/contribute_in_file.0.result @@ -0,0 +1 @@ +HelloHello! How can I assist you today?nice to meet you.It's nice to meet you too! I'm here to help answer your questions or provide information on a wide range of topics. Please go ahead and ask.Bye diff --git a/tests/results/examples/aggregators/contribute_in_stderr.0.result b/tests/results/examples/aggregators/contribute_in_stderr.0.result new file mode 100644 index 000000000..5cd085a9f --- /dev/null +++ b/tests/results/examples/aggregators/contribute_in_stderr.0.result @@ -0,0 +1 @@ +HelloHello! How can I assist you today? diff --git a/tests/results/examples/aggregators/contribute_in_stdout.0.result b/tests/results/examples/aggregators/contribute_in_stdout.0.result new file mode 100644 index 000000000..5cd085a9f --- /dev/null +++ b/tests/results/examples/aggregators/contribute_in_stdout.0.result @@ -0,0 +1 @@ +HelloHello! How can I assist you today?