diff --git a/contrib/prompt_library/CoT.pdl b/contrib/prompt_library/CoT.pdl index 4d559ac34..9c03d192d 100644 --- a/contrib/prompt_library/CoT.pdl +++ b/contrib/prompt_library/CoT.pdl @@ -3,9 +3,9 @@ defs: # Chain of Thought cot_block: function: - question: str - reasoning: str - answer: str + question: string + reasoning: string + answer: string return: |- Question: ${ question } Answer: Let's think step by step. ${ reasoning } @@ -13,8 +13,7 @@ defs: fewshot_cot: function: - examples: - { list: { obj: { question: str, reasoning: str, answer: str } } } + examples: [{ question: string, reasoning: string, answer: string }] return: text: - for: @@ -30,10 +29,9 @@ defs: chain_of_thought: function: - question: str - model: str - examples: - { list: { obj: { question: str, reasoning: str, answer: str } } } + question: string + model: string + examples: [{ question: string, reasoning: string, answer: string }] return: lastOf: - call: ${ fewshot_cot } diff --git a/contrib/prompt_library/ReAct.pdl b/contrib/prompt_library/ReAct.pdl index ff585b08b..f1eb5dcdd 100644 --- a/contrib/prompt_library/ReAct.pdl +++ b/contrib/prompt_library/ReAct.pdl @@ -3,7 +3,7 @@ description: ReAct pattern from Yao et al., [ICLR 2023](https://openreview.net/f defs: react_block: function: - trajectory: { list: obj } + trajectory: [ object ] return: text: - for: @@ -36,11 +36,11 @@ defs: react: function: - task: str - model: str - tool_schema: { list: obj } - tools: obj - trajectories: { list: list } + task: string + model: string + tool_schema: [ object ] + tools: object + trajectories: [ array ] return: lastOf: - role: system @@ -95,7 +95,7 @@ defs: temperature: 0 stop: ["\n", "Obs:", "<|eom_id|>"] include_stop_sequence: false - spec: { name: str, arguments: obj } + spec: { name: string, arguments: object } - if: ${ action != prev_action } then: def: observation diff --git a/contrib/prompt_library/ReWoo.pdl b/contrib/prompt_library/ReWoo.pdl index 3393aba3c..78ebf4fe6 100644 --- a/contrib/prompt_library/ReWoo.pdl +++ b/contrib/prompt_library/ReWoo.pdl @@ -5,7 +5,7 @@ description: ReWOO (Reasoning without observation) pattern from Xu et al., (http defs: rewoo_block: function: - trajectory: { list: obj } + trajectory: [ object ] return: text: - defs: @@ -47,12 +47,12 @@ defs: rewoo: function: - task: str - model: str - tool_schema: { list: obj } - tools: obj - trajectories: { list: list } - show_plans: bool + task: string + model: string + tool_schema: [object] + tools: object + trajectories: array + show_plans: boolean return: lastOf: - | diff --git a/contrib/prompt_library/tools.pdl b/contrib/prompt_library/tools.pdl index 182fff4e5..5b5aa25b6 100644 --- a/contrib/prompt_library/tools.pdl +++ b/contrib/prompt_library/tools.pdl @@ -12,8 +12,8 @@ defs: filter_tools_by_name: function: - tools: { list: obj } - tool_names: { list: str } + tools: [object] + tool_names: [string] return: data: ${ tools|selectattr('name', 'in', tool_names)|list } @@ -58,7 +58,7 @@ defs: object: calculator: function: - arguments: obj + arguments: object return: lang: python code: | @@ -81,7 +81,7 @@ defs: result = main(**arguments) search: function: - arguments: obj + arguments: object return: lastOf: - def: result diff --git a/docs/tutorial.md b/docs/tutorial.md index be2b8c968..77cb2ca9a 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -535,7 +535,7 @@ tools: object: hello: function: - arguments: obj + arguments: object return: lang: python code: | @@ -569,7 +569,7 @@ tool_schema: type: object properties: answer: - type: str + type: string description: The answer required: - answer @@ -586,7 +586,7 @@ finish_action: type: object properties: answer: - type: str + type: string description: The answer required: - answer @@ -916,12 +916,9 @@ some JSON data. --8<-- "./examples/tutorial/type_checking.pdl" ``` -Upon reading the data we use a parser to parse it into a YAML. The `spec` field indicates the expected type for the -data, which is an object with 2 fields: `questions` and `answers` that are a list of string and a list of objects, -respectively. When the interpreter is executed, it checks this type dynamically and throws errors if necessary. +Upon reading the data we use a parser to parse it into a YAML. The `spec` field indicates the expected type for the data, which is an object with 2 fields: `questions` and `answers` that are an array of string and an array of objects, respectively. When the interpreter is executed, it checks this type dynamically and throws errors if necessary. -Similarly, the output of the model call is parsed as YAML, and the `spec` indicates that we expect an object with -2 fields: `name` of type string, and `age` of type integer. +Similarly, the output of the model call is parsed as YAML, and the `spec` indicates that we expect an object with two fields: `name` of type string, and `age` of type integer. When we run this program, we obtain the output: @@ -933,26 +930,27 @@ type_checking.pdl:9 - twentyfive should be of type Notice that since we asked the age to be produced in letters, we got a string back and this causes a type error indicated above. -In general, `spec` definitions can be a subset of JSON schema, or use a shorthand notation as illustrated by -the examples below: - -- `bool`: boolean -- `str`: string -- `int`: integer -- `float`: float -- `{str: {pattern: '^[A-Za-z][A-Za-z0-9_]*$'}}`: a string satisfying the indicated pattern -- `{float: {minimum: 0, exclusiveMaximum: 1}}`: a float satisfying the indicated constraints -- `{list: int}`: a list of integers -- `[int]`: a list of integers -- `{list: {int: {minimum: 0}}}`: a list of integers satisfying the indicated constraints -- `[{int: {minimum: 0}}]`: same as above -- `{list: {minItems: 1, int: {}}}`, a list satisfying the indicated constraints -- `{obj: {latitude: float, longitude: float}}`: an object with fields `latitude` and `longitude` -- `{latitude: float, longitude: float}`: same as above -- `{obj: {question: str, answer: str, context: {optional: str}}}`: an object with an optional field -- `{question: str, answer: str, context: {optional: str}}`: same as above -- `{list: {obj: {question: str, answer: str}}}`: a list of objects -- `[{question: str, answer: str}]`: same as above +In general, `spec` definitions can be a subset of JSON schema, or use a shorthand notation as illustrated by the examples below: + +- `boolean` or `{type: boolean}`: boolean +- `string` or `{type: string}`: string +- `integer` or `{type: integer}`: integer +- `number` or `{type: number}`: floating point numbers +- `"null"` or `{type: "null"}`: type of the `null` value +- `array` or `{type: array}`: array with elements of any type +- `object` or `{type: object}`: object with any fields +- `{type: string, pattern: '^[A-Za-z][A-Za-z0-9_]*$'}`: a string satisfying the indicated pattern +- `{type: number, minimum: 0, exclusiveMaximum: 1}`: a float satisfying the indicated constraints +- `[integer]`: an array of integers +- `{type: array, items: { type: integer }}`: same as above +- `[{ type: integer, minimum: 0}]`: a list of integers satisfying the indicated constraints +- `{type: array, items: { type: integer, minimum: 0}}`: same as above +- `{type: array, minItems: 1}`, a list with at least one element +- `{latitude: number, longitude: number}`: an object with fields `latitude` and `longitude` +- `{object: {latitude: number, longitude: number}}`: same as above +- `{question: string, answer: string, context: {optional: string}}`: an object with an optional field `context` +- `{object: {question: string, answer: string, context: {optional: string}}}`: same as above +- `[{question: string, answer: string}]`: a list of objects - `{enum: [red, green, blue]}`: an enumeration Another example of type checking a list can be found [here](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/type_list.pdl). diff --git a/examples/callback/repair_prompt.pdl b/examples/callback/repair_prompt.pdl index 2bc6796b5..7c611c179 100644 --- a/examples/callback/repair_prompt.pdl +++ b/examples/callback/repair_prompt.pdl @@ -15,13 +15,13 @@ lastOf: - lang: python def: parsed_output - spec: {thought: str, code_line: str} + spec: {thought: string, code_line: string} code: | import repair_main # (In PDL, set `result` to the output you wish for your code block.) result = repair_main.parse_output(raw_output) -- spec: {before: str, after: str} +- spec: {before: string, after: string} object: before: ${code_line} after: ${parsed_output.code_line} diff --git a/examples/demo/10-sdg.pdl b/examples/demo/10-sdg.pdl index ac1ba52ea..886fe02c9 100644 --- a/examples/demo/10-sdg.pdl +++ b/examples/demo/10-sdg.pdl @@ -3,18 +3,18 @@ defs: teacher_model: ollama_chat/granite3.2:8b teacher_template: function: - sys_prompt: str - prompt: str + sys_prompt: string + prompt: string return: [INST] ${sys_prompt} ${prompt} [/INST] teacher_stop_token: question_template_freeform: function: - num_samples: int - task_description: str - icl_question: str - spec: { introduction: str, principles: str, examples: str, generation: str, max_new_tokens: int } + num_samples: integer + task_description: string + icl_question: string + spec: { introduction: string, principles: string, examples: string, generation: string, max_new_tokens: integer } return: data: introduction: | @@ -40,16 +40,16 @@ defs: gen_questions_freeform_inner: function: - num_samples: int - task_description: str - icl_question: str - icl_answer: str - spec: [{icl_question: str, icl_answer: str, question: str}] + num_samples: integer + task_description: string + icl_question: string + icl_answer: string + spec: [{icl_question: string, icl_answer: string, question: string}] return: defs: prompt_data: call: ${question_template_freeform} - spec: { introduction: str, principles: str, examples: str, generation: str, max_new_tokens: int } + spec: { introduction: string, principles: string, examples: string, generation: string, max_new_tokens: integer } args: num_samples: ${num_samples} task_description: ${task_description} @@ -85,9 +85,9 @@ defs: gen_questions_freeform: function: - task_description: str - seed_examples: [{question: str, answer: str}] - spec: [{icl_question: str, icl_answer: str, question: str}] + task_description: string + seed_examples: [{question: string, answer: string}] + spec: [{icl_question: string, icl_answer: string, question: string}] return: defs: list_of_lists: @@ -109,9 +109,9 @@ defs: filter_questions_template: function: - task_description: str - question: str - spec: {introduction: str, principles: str, generation: str, max_new_tokens: int} + task_description: string + question: string + spec: {introduction: string, principles: string, generation: string, max_new_tokens: integer} return: data: introduction: | @@ -133,14 +133,14 @@ defs: # https://github.com/instruct-lab/datagen-pipeline/blob/main/sdg/filter_questions.py filter_questions_inner: function: - task_description: str - question: str - spec: float + task_description: string + question: string + spec: number return: defs: prompt_data: call: ${filter_questions_template} - spec: {introduction: str, principles: str, generation: str, max_new_tokens: int} + spec: {introduction: string, principles: string, generation: string, max_new_tokens: integer} args: task_description: ${task_description} question: ${question} @@ -160,7 +160,7 @@ defs: max_new_tokens: ${prompt_data.max_new_tokens} temperature: 0 parser: - spec: { "rating": str } + spec: { "rating": string } # regex: "Rating.*\\[\\[(?P\\d+\\.?\\d*)\\]\\]" regex: 'Rating.*\[\[(?P\d+\.?\d*)\]\]' mode: search @@ -168,9 +168,9 @@ defs: filter_questions: function: - task_description: str - questions: [{icl_question: str, icl_answer: str, question: str}] - spec: [{icl_question: str, icl_answer: str, question: str}] + task_description: string + questions: [{icl_question: string, icl_answer: string, question: string}] + spec: [{icl_question: string, icl_answer: string, question: string}] return: defs: list_of_pairs: @@ -197,10 +197,10 @@ defs: answer_template: function: - icl_question: str - icl_response: str - question: str - spec: {introduction: str, principles: str, examples: str, generation: str, max_new_tokens: int, additional_stop_tokens: [str]} + icl_question: string + icl_response: string + question: string + spec: {introduction: string, principles: string, examples: string, generation: string, max_new_tokens: integer, additional_stop_tokens: [string]} return: data: introduction: Your task is to faithfully follow the user's prompt and generate a response. @@ -228,13 +228,13 @@ defs: gen_answers_inner: function: - question: {icl_question: str, icl_answer: str, question: str} - spec: {question: str, answer: str} + question: {icl_question: string, icl_answer: string, question: string} + spec: {question: string, answer: string} return: defs: prompt_data: call: ${answer_template} - spec: {introduction: str, principles: str, examples: str, generation: str, max_new_tokens: int, additional_stop_tokens: [str]} + spec: {introduction: string, principles: string, examples: string, generation: string, max_new_tokens: integer, additional_stop_tokens: [string]} args: icl_question: ${question.icl_question} icl_response: ${question.icl_answer} @@ -269,12 +269,12 @@ defs: gen_answers: function: - questions: [{icl_question: str, icl_answer: str, question: str}] - spec: [{question: str, answer: str}] + questions: [{icl_question: string, icl_answer: string, question: string}] + spec: [{question: string, answer: string}] return: defs: all_results: - spec: [{question: str, answer: str}] + spec: [{question: string, answer: string}] for: question: ${ questions } repeat: @@ -284,16 +284,16 @@ defs: join: as: array lang: python - spec: [{question: str, answer: str}] + spec: [{question: string, answer: string}] code: | # keep only if answer non-empty result = [r for r in ${all_results} if len(r["answer"]) > 0] filter_qa_template: function: - question: str - answer: str - spec: {introduction: str, principles: str, generation: str, max_new_tokens: int} + question: string + answer: string + spec: {introduction: string, principles: string, generation: string, max_new_tokens: integer} return: data: introduction: | @@ -316,14 +316,14 @@ defs: filter_question_answer_pair_inner: function: - question: str - answer: str - spec: float + question: string + answer: string + spec: number return: defs: prompt_data: call: ${filter_qa_template} - spec: {introduction: str, principles: str, generation: str, max_new_tokens: int} + spec: {introduction: string, principles: string, generation: string, max_new_tokens: integer} args: question: ${question} answer: ${answer} @@ -343,15 +343,15 @@ defs: max_new_tokens: ${prompt_data.max_new_tokens} temperature: 0 parser: - spec: { "rating": str } + spec: { "rating": string } regex: 'Rating.*\[\[(?P\d+\.?\d*)\]\]' mode: search data: ${ (teacher_output.rating if teacher_output.rating is not none else 0.0) | float} filter_question_answer_pair: function: - qa_pairs: [{question: str, answer: str}] - spec: [{question: str, answer: str}] + qa_pairs: [{question: string, answer: string}] + spec: [{question: string, answer: string}] return: defs: ratings: @@ -361,7 +361,7 @@ defs: defs: filter_output: call: ${filter_question_answer_pair_inner} - spec: float + spec: number args: question: ${qa_pair.question} answer: ${qa_pair.answer} @@ -372,7 +372,7 @@ defs: as: array filtered: lang: python - spec: [{question: str, answer: str}] + spec: [{question: string, answer: string}] code: | # keep only if rating is at least two result = [p["qa_pair"] for p in ${ratings} if p["rating"] >= 2] data: ${filtered} @@ -386,14 +386,14 @@ text: - "\n\n----- Generating questions -----\n\n" - def: generated_questions call: ${gen_questions_freeform} - spec: [{icl_question: str, icl_answer: str, question: str}] + spec: [{icl_question: string, icl_answer: string, question: string}] args: task_description: ${seed_examples.task_description} seed_examples: ${seed_examples.seed_examples} - "\n\n----- Filtering questions -----\n\n" - def: filtered_questions call: ${filter_questions} - spec: [{icl_question: str, icl_answer: str, question: str}] + spec: [{icl_question: string, icl_answer: string, question: string}] args: task_description: ${seed_examples.task_description} questions: ${generated_questions} diff --git a/examples/demo/4-function.pdl b/examples/demo/4-function.pdl index 553aae6f0..dac318dc9 100644 --- a/examples/demo/4-function.pdl +++ b/examples/demo/4-function.pdl @@ -2,8 +2,8 @@ description: Function def and call text: - def: translate function: - sentence: str - language: str + sentence: string + language: string return: lastOf: - "\nTranslate the sentence '${ sentence }' to ${ language }.\n" diff --git a/examples/demo/8-tools.pdl b/examples/demo/8-tools.pdl index c0b58ae16..97c8765f2 100644 --- a/examples/demo/8-tools.pdl +++ b/examples/demo/8-tools.pdl @@ -20,7 +20,7 @@ text: - def: actions model: ollama_chat/granite3.2:8b parser: json - spec: [{ name: str, arguments: { expr: str }}] + spec: [{ name: string, arguments: { expr: string }}] parameters: drop_params: true - "\n" diff --git a/examples/demos/react_fun.pdl b/examples/demos/react_fun.pdl index 6eec4124f..2ba59ae61 100644 --- a/examples/demos/react_fun.pdl +++ b/examples/demos/react_fun.pdl @@ -2,9 +2,9 @@ description: Function definition for react pattern defs: react_inner: function: - examples: [str] - question: str - model: str + examples: [string] + question: string + model: string return: text: - defs: @@ -103,8 +103,8 @@ defs: react: function: - question: str - model: str + question: string + model: string return: defs: examples: diff --git a/examples/demos/repair_prompt.pdl b/examples/demos/repair_prompt.pdl index 2bc6796b5..7c611c179 100644 --- a/examples/demos/repair_prompt.pdl +++ b/examples/demos/repair_prompt.pdl @@ -15,13 +15,13 @@ lastOf: - lang: python def: parsed_output - spec: {thought: str, code_line: str} + spec: {thought: string, code_line: string} code: | import repair_main # (In PDL, set `result` to the output you wish for your code block.) result = repair_main.parse_output(raw_output) -- spec: {before: str, after: str} +- spec: {before: string, after: string} object: before: ${code_line} after: ${parsed_output.code_line} diff --git a/examples/demos/wiki.pdl b/examples/demos/wiki.pdl index 5b234edd1..9cc9b80d1 100644 --- a/examples/demos/wiki.pdl +++ b/examples/demos/wiki.pdl @@ -25,7 +25,7 @@ text: - def: actions model: ollama_chat/granite3.3:8b parser: json - spec: [{ name: str, arguments: { topic: str }}] + spec: [{ name: string, arguments: { topic: string }}] - "\n" - if: ${ actions[0].name == "search" } then: diff --git a/examples/gsm8k/gsm8.pdl b/examples/gsm8k/gsm8.pdl index 1d28bb2b2..5f43320f3 100644 --- a/examples/gsm8k/gsm8.pdl +++ b/examples/gsm8k/gsm8.pdl @@ -84,7 +84,7 @@ text: parser: regex: "[^0-9]*(?P[0-9]+).*$" spec: - answer: str + answer: string def: EXTRACTED_SIMPLIFIED_LLM_ANSWER # (In case the simplified answer did not contain digits.) - if: ${ EXTRACTED_SIMPLIFIED_LLM_ANSWER == None } @@ -104,7 +104,7 @@ text: parser: regex: "(.|\n)*#### (?P([0-9])*)\n*" spec: - answer: str + answer: string def: EXTRACTED_GROUND_TRUTH #- lang: python # code: | diff --git a/examples/gsm8k/gsm8k-plan-few-shots.pdl b/examples/gsm8k/gsm8k-plan-few-shots.pdl index 145922537..93ad87057 100644 --- a/examples/gsm8k/gsm8k-plan-few-shots.pdl +++ b/examples/gsm8k/gsm8k-plan-few-shots.pdl @@ -8,8 +8,8 @@ defs: planning: function: - problem: str - demos: [str] + problem: string + demos: [string] return: lastOf: - | @@ -32,7 +32,7 @@ defs: solve: function: - plan: str + plan: string return: text: - ${ plan } @@ -45,7 +45,7 @@ defs: extract_final_answer: function: - solution: str + solution: string return: lastOf: - ${ solution } @@ -53,22 +53,22 @@ defs: - model: ollama/granite3.2:8b parser: json def: result - spec: { "result": float } + spec: { "result": number } fallback: data: result: 0 compare_to_ground_truth: function: - result: obj - truth: str + result: object + truth: string return: lastOf: - data: ${ truth } parser: regex: "(.|\n)*#### (?P([0-9])*)\n*" spec: - answer: str + answer: string def: ground_truth - if: ${ result.result|float == ground_truth.answer|float} then: diff --git a/examples/gsm8k/gsm8k-plan.pdl b/examples/gsm8k/gsm8k-plan.pdl index 8736e1fa4..1ea2b2098 100644 --- a/examples/gsm8k/gsm8k-plan.pdl +++ b/examples/gsm8k/gsm8k-plan.pdl @@ -8,7 +8,7 @@ defs: planning: function: - problem: str + problem: string return: text: - > @@ -23,7 +23,7 @@ defs: solve: function: - plan: str + plan: string return: text: - ${ plan } @@ -35,7 +35,7 @@ defs: extract_final_answer: function: - solution: str + solution: string return: lastOf: - ${ solution } @@ -43,22 +43,22 @@ defs: - model: ollama/granite3.2:8b parser: json def: result - spec: { "result": float } + spec: { "result": number } fallback: data: result: 0 compare_to_ground_truth: function: - result: obj - truth: str + result: object + truth: string return: lastOf: - data: ${ truth } parser: regex: "(.|\n)*#### (?P([0-9])*)\n*" spec: - answer: str + answer: string def: ground_truth - if: ${ result.result|float == ground_truth.answer|float} then: diff --git a/examples/gsm8k/gsm8k-tot-few-shot.pdl b/examples/gsm8k/gsm8k-tot-few-shot.pdl index 37a2e7f4c..d49063181 100644 --- a/examples/gsm8k/gsm8k-tot-few-shot.pdl +++ b/examples/gsm8k/gsm8k-tot-few-shot.pdl @@ -10,7 +10,7 @@ defs: majority_vote: function: - numbers: [float] + numbers: [number] return: lang: python code: | @@ -21,7 +21,7 @@ defs: majority_vote_json: function: - results: [{ "result": float }] + results: [{ "result": number }] return: lastOf: - lang: python @@ -34,8 +34,8 @@ defs: planning: function: - problem: str - demos: [str] + problem: string + demos: [string] return: text: - | @@ -61,7 +61,7 @@ defs: solve: function: - plan: str + plan: string return: text: - ${ plan } @@ -77,7 +77,7 @@ defs: extract_final_answer: function: - solution: str + solution: string return: lastOf: - ${ solution } @@ -85,22 +85,22 @@ defs: - model: ollama/granite3.2:8b parser: json def: result - spec: { "result": float } + spec: { "result": number } fallback: data: result: 0 compare_to_ground_truth: function: - result: float - truth: str + result: number + truth: string return: lastOf: - data: ${ truth } parser: regex: "(.|\n)*#### (?P([0-9])*)\n*" spec: - answer: str + answer: string def: ground_truth - if: ${ result|float == ground_truth.answer|float} then: diff --git a/examples/gsm8k/gsm8k-tot-multiplan.pdl b/examples/gsm8k/gsm8k-tot-multiplan.pdl index 321aea6d5..02fcbe8a4 100644 --- a/examples/gsm8k/gsm8k-tot-multiplan.pdl +++ b/examples/gsm8k/gsm8k-tot-multiplan.pdl @@ -10,7 +10,7 @@ defs: majority_vote: function: - results: [{ "result": float }] + results: [{ "result": number }] return: lang: python code: | @@ -21,7 +21,7 @@ defs: result = most_frequent planning: function: - problem: str + problem: string return: text: - | @@ -40,7 +40,7 @@ defs: solve: function: - plan: str + plan: string return: text: - ${ plan } @@ -56,7 +56,7 @@ defs: extract_final_answer: function: - solution: str + solution: string return: lastOf: - ${ solution } @@ -64,22 +64,22 @@ defs: - model: ollama/granite3.2:8b parser: json def: result - spec: { "result": float } + spec: { "result": number } fallback: data: result: 0 compare_to_ground_truth: function: - result: float - truth: str + result: number + truth: string return: lastOf: - data: ${ truth } parser: regex: "(.|\n)*#### (?P([0-9])*)\n*" spec: - answer: str + answer: string def: ground_truth - if: ${ result|float == ground_truth.answer|float} then: diff --git a/examples/gsm8k/gsm8k-tot.pdl b/examples/gsm8k/gsm8k-tot.pdl index d9df68868..bcfcfaf96 100644 --- a/examples/gsm8k/gsm8k-tot.pdl +++ b/examples/gsm8k/gsm8k-tot.pdl @@ -10,7 +10,7 @@ defs: majority_vote: function: - numbers: [float] + numbers: [number] return: lang: python code: | @@ -21,7 +21,7 @@ defs: majority_vote_json: function: - results: [{ "result": float }] + results: [{ "result": number }] return: lastOf: - lang: python @@ -34,7 +34,7 @@ defs: planning: function: - problem: str + problem: string return: text: - | @@ -53,7 +53,7 @@ defs: solve: function: - plan: str + plan: string return: text: - ${ plan } @@ -69,7 +69,7 @@ defs: extract_final_answer: function: - solution: str + solution: string return: lastOf: - ${ solution } @@ -77,22 +77,22 @@ defs: - model: ollama/granite3.2:8b parser: json def: result - spec: { "result": float } + spec: { "result": number } fallback: data: result: 0 compare_to_ground_truth: function: - result: float - truth: str + result: number + truth: string return: lastOf: - data: ${ truth } parser: regex: "(.|\n)*#### (?P([0-9])*)\n*" spec: - answer: str + answer: string def: ground_truth - if: ${ result|float == ground_truth.answer|float} then: diff --git a/examples/notebooks/demo.ipynb b/examples/notebooks/demo.ipynb index 251f99fb9..2bdabee40 100644 --- a/examples/notebooks/demo.ipynb +++ b/examples/notebooks/demo.ipynb @@ -405,7 +405,7 @@ " - def: action\n", " lang: python\n", " parser: json\n", - " spec: {name: str, arguments: obj}\n", + " spec: {name: string, arguments: object}\n", " contribute: [context]\n", " code:\n", " |\n", diff --git a/examples/optimizer/mbpp.pdl b/examples/optimizer/mbpp.pdl index a18936c90..5791a65b0 100644 --- a/examples/optimizer/mbpp.pdl +++ b/examples/optimizer/mbpp.pdl @@ -2,7 +2,7 @@ description: MBPP agent defs: react_code_block: function: - trajectory: { list: obj } + trajectory: [object] return: text: - for: diff --git a/examples/rag/rag_library1.pdl b/examples/rag/rag_library1.pdl index 3e81fd224..e5270a3b7 100644 --- a/examples/rag/rag_library1.pdl +++ b/examples/rag/rag_library1.pdl @@ -4,9 +4,9 @@ description: RAG library for PDL text: - def: pdf_parse function: - filename: str - chunk_size: int - chunk_overlap: int + filename: string + chunk_size: integer + chunk_overlap: integer return: lang: python code: | @@ -14,11 +14,11 @@ text: result = rag.parse(filename, chunk_size, chunk_overlap) - def: rag_index function: - inp: list # This is a list[str], but PDL doesn't allow that type - encoder_model: str - embed_dimension: int - database_name: str # optional, could also be URL? - collection_name: str + inp: [string] + encoder_model: string + embed_dimension: integer + database_name: string # optional, could also be URL? + collection_name: string return: lang: python code: | @@ -26,11 +26,11 @@ text: result = rag.rag_index(inp, encoder_model, embed_dimension, database_name, collection_name) - def: rag_retrieve function: - inp: str - encoder_model: str - limit: int - collection_name: str - database_name: str # optional, could also be URL? + inp: string + encoder_model: string + limit: integer + collection_name: string + database_name: string # optional, could also be URL? return: lang: python code: | diff --git a/examples/rag/tfidf_rag.pdl b/examples/rag/tfidf_rag.pdl index 6c2acd74b..a9d5d7323 100644 --- a/examples/rag/tfidf_rag.pdl +++ b/examples/rag/tfidf_rag.pdl @@ -21,7 +21,7 @@ text: contribute: [] - def: RETRIEVED lang: python - spec: {prompt: [str], code: [str]} + spec: {prompt: [string], code: [string]} code: | key = PDL_SESSION.embed("${ TEST_PROMPT }") nearest = PDL_SESSION.vec_db.get_nearest_examples("embeddings", key, 5) diff --git a/examples/react/react_fun.pdl b/examples/react/react_fun.pdl index 675ca6d33..8b92c362d 100644 --- a/examples/react/react_fun.pdl +++ b/examples/react/react_fun.pdl @@ -2,9 +2,9 @@ description: Function definition for react defs: react_inner: function: - examples: [str] - question: str - model: str + examples: [string] + question: string + model: string return: text: - defs: @@ -103,8 +103,8 @@ defs: react: function: - question: str - model: str + question: string + model: string return: defs: examples: diff --git a/examples/skeleton-of-thought/tips.pdl b/examples/skeleton-of-thought/tips.pdl index e3e9e367d..87d724ae6 100644 --- a/examples/skeleton-of-thought/tips.pdl +++ b/examples/skeleton-of-thought/tips.pdl @@ -7,8 +7,8 @@ defs: expand_tip: function: - topic: str - tip: str + topic: string + tip: string return: lastOf: - | @@ -37,8 +37,8 @@ defs: suggest_tips: function: - topic: str - number: int + topic: string + number: integer return: lastOf: - "Please act as a helpful assistant. Your job is to provide users with useful tips on a specific topic.\n" diff --git a/examples/teacher/teacher.pdl b/examples/teacher/teacher.pdl index ac1ba52ea..886fe02c9 100644 --- a/examples/teacher/teacher.pdl +++ b/examples/teacher/teacher.pdl @@ -3,18 +3,18 @@ defs: teacher_model: ollama_chat/granite3.2:8b teacher_template: function: - sys_prompt: str - prompt: str + sys_prompt: string + prompt: string return: [INST] ${sys_prompt} ${prompt} [/INST] teacher_stop_token: question_template_freeform: function: - num_samples: int - task_description: str - icl_question: str - spec: { introduction: str, principles: str, examples: str, generation: str, max_new_tokens: int } + num_samples: integer + task_description: string + icl_question: string + spec: { introduction: string, principles: string, examples: string, generation: string, max_new_tokens: integer } return: data: introduction: | @@ -40,16 +40,16 @@ defs: gen_questions_freeform_inner: function: - num_samples: int - task_description: str - icl_question: str - icl_answer: str - spec: [{icl_question: str, icl_answer: str, question: str}] + num_samples: integer + task_description: string + icl_question: string + icl_answer: string + spec: [{icl_question: string, icl_answer: string, question: string}] return: defs: prompt_data: call: ${question_template_freeform} - spec: { introduction: str, principles: str, examples: str, generation: str, max_new_tokens: int } + spec: { introduction: string, principles: string, examples: string, generation: string, max_new_tokens: integer } args: num_samples: ${num_samples} task_description: ${task_description} @@ -85,9 +85,9 @@ defs: gen_questions_freeform: function: - task_description: str - seed_examples: [{question: str, answer: str}] - spec: [{icl_question: str, icl_answer: str, question: str}] + task_description: string + seed_examples: [{question: string, answer: string}] + spec: [{icl_question: string, icl_answer: string, question: string}] return: defs: list_of_lists: @@ -109,9 +109,9 @@ defs: filter_questions_template: function: - task_description: str - question: str - spec: {introduction: str, principles: str, generation: str, max_new_tokens: int} + task_description: string + question: string + spec: {introduction: string, principles: string, generation: string, max_new_tokens: integer} return: data: introduction: | @@ -133,14 +133,14 @@ defs: # https://github.com/instruct-lab/datagen-pipeline/blob/main/sdg/filter_questions.py filter_questions_inner: function: - task_description: str - question: str - spec: float + task_description: string + question: string + spec: number return: defs: prompt_data: call: ${filter_questions_template} - spec: {introduction: str, principles: str, generation: str, max_new_tokens: int} + spec: {introduction: string, principles: string, generation: string, max_new_tokens: integer} args: task_description: ${task_description} question: ${question} @@ -160,7 +160,7 @@ defs: max_new_tokens: ${prompt_data.max_new_tokens} temperature: 0 parser: - spec: { "rating": str } + spec: { "rating": string } # regex: "Rating.*\\[\\[(?P\\d+\\.?\\d*)\\]\\]" regex: 'Rating.*\[\[(?P\d+\.?\d*)\]\]' mode: search @@ -168,9 +168,9 @@ defs: filter_questions: function: - task_description: str - questions: [{icl_question: str, icl_answer: str, question: str}] - spec: [{icl_question: str, icl_answer: str, question: str}] + task_description: string + questions: [{icl_question: string, icl_answer: string, question: string}] + spec: [{icl_question: string, icl_answer: string, question: string}] return: defs: list_of_pairs: @@ -197,10 +197,10 @@ defs: answer_template: function: - icl_question: str - icl_response: str - question: str - spec: {introduction: str, principles: str, examples: str, generation: str, max_new_tokens: int, additional_stop_tokens: [str]} + icl_question: string + icl_response: string + question: string + spec: {introduction: string, principles: string, examples: string, generation: string, max_new_tokens: integer, additional_stop_tokens: [string]} return: data: introduction: Your task is to faithfully follow the user's prompt and generate a response. @@ -228,13 +228,13 @@ defs: gen_answers_inner: function: - question: {icl_question: str, icl_answer: str, question: str} - spec: {question: str, answer: str} + question: {icl_question: string, icl_answer: string, question: string} + spec: {question: string, answer: string} return: defs: prompt_data: call: ${answer_template} - spec: {introduction: str, principles: str, examples: str, generation: str, max_new_tokens: int, additional_stop_tokens: [str]} + spec: {introduction: string, principles: string, examples: string, generation: string, max_new_tokens: integer, additional_stop_tokens: [string]} args: icl_question: ${question.icl_question} icl_response: ${question.icl_answer} @@ -269,12 +269,12 @@ defs: gen_answers: function: - questions: [{icl_question: str, icl_answer: str, question: str}] - spec: [{question: str, answer: str}] + questions: [{icl_question: string, icl_answer: string, question: string}] + spec: [{question: string, answer: string}] return: defs: all_results: - spec: [{question: str, answer: str}] + spec: [{question: string, answer: string}] for: question: ${ questions } repeat: @@ -284,16 +284,16 @@ defs: join: as: array lang: python - spec: [{question: str, answer: str}] + spec: [{question: string, answer: string}] code: | # keep only if answer non-empty result = [r for r in ${all_results} if len(r["answer"]) > 0] filter_qa_template: function: - question: str - answer: str - spec: {introduction: str, principles: str, generation: str, max_new_tokens: int} + question: string + answer: string + spec: {introduction: string, principles: string, generation: string, max_new_tokens: integer} return: data: introduction: | @@ -316,14 +316,14 @@ defs: filter_question_answer_pair_inner: function: - question: str - answer: str - spec: float + question: string + answer: string + spec: number return: defs: prompt_data: call: ${filter_qa_template} - spec: {introduction: str, principles: str, generation: str, max_new_tokens: int} + spec: {introduction: string, principles: string, generation: string, max_new_tokens: integer} args: question: ${question} answer: ${answer} @@ -343,15 +343,15 @@ defs: max_new_tokens: ${prompt_data.max_new_tokens} temperature: 0 parser: - spec: { "rating": str } + spec: { "rating": string } regex: 'Rating.*\[\[(?P\d+\.?\d*)\]\]' mode: search data: ${ (teacher_output.rating if teacher_output.rating is not none else 0.0) | float} filter_question_answer_pair: function: - qa_pairs: [{question: str, answer: str}] - spec: [{question: str, answer: str}] + qa_pairs: [{question: string, answer: string}] + spec: [{question: string, answer: string}] return: defs: ratings: @@ -361,7 +361,7 @@ defs: defs: filter_output: call: ${filter_question_answer_pair_inner} - spec: float + spec: number args: question: ${qa_pair.question} answer: ${qa_pair.answer} @@ -372,7 +372,7 @@ defs: as: array filtered: lang: python - spec: [{question: str, answer: str}] + spec: [{question: string, answer: string}] code: | # keep only if rating is at least two result = [p["qa_pair"] for p in ${ratings} if p["rating"] >= 2] data: ${filtered} @@ -386,14 +386,14 @@ text: - "\n\n----- Generating questions -----\n\n" - def: generated_questions call: ${gen_questions_freeform} - spec: [{icl_question: str, icl_answer: str, question: str}] + spec: [{icl_question: string, icl_answer: string, question: string}] args: task_description: ${seed_examples.task_description} seed_examples: ${seed_examples.seed_examples} - "\n\n----- Filtering questions -----\n\n" - def: filtered_questions call: ${filter_questions} - spec: [{icl_question: str, icl_answer: str, question: str}] + spec: [{icl_question: string, icl_answer: string, question: string}] args: task_description: ${seed_examples.task_description} questions: ${generated_questions} diff --git a/examples/tools/calc.pdl b/examples/tools/calc.pdl index a9bb59d52..2405f3c40 100644 --- a/examples/tools/calc.pdl +++ b/examples/tools/calc.pdl @@ -20,7 +20,7 @@ text: - def: actions model: ollama_chat/granite3.2:8b parser: json - spec: [{ name: str, arguments: { expr: str }}] + spec: [{ name: string, arguments: { expr: string }}] parameters: drop_params: true # This is needed because the model does not support structured decoding. It directs LiteLLM to ignore parameters sent for structured decoding. - "\n" diff --git a/examples/tools/search.pdl b/examples/tools/search.pdl index 3ec1e6883..7bb42fb84 100644 --- a/examples/tools/search.pdl +++ b/examples/tools/search.pdl @@ -31,7 +31,7 @@ text: - def: actions model: ollama_chat/granite3.3:8b parser: json - spec: [{ name: str, arguments: { topic: str }}] + spec: [{ name: string, arguments: { topic: string }}] - "\n" - if: ${ actions[0].name == "search" } then: diff --git a/examples/tools/wiki.pdl b/examples/tools/wiki.pdl index 5b234edd1..9cc9b80d1 100644 --- a/examples/tools/wiki.pdl +++ b/examples/tools/wiki.pdl @@ -25,7 +25,7 @@ text: - def: actions model: ollama_chat/granite3.3:8b parser: json - spec: [{ name: str, arguments: { topic: str }}] + spec: [{ name: string, arguments: { topic: string }}] - "\n" - if: ${ actions[0].name == "search" } then: diff --git a/examples/tutorial/defs-hello.pdl b/examples/tutorial/defs-hello.pdl index 1d3a2f41f..477d58822 100644 --- a/examples/tutorial/defs-hello.pdl +++ b/examples/tutorial/defs-hello.pdl @@ -2,7 +2,7 @@ description: Hello world with defs defs: hello: function: - name: str + name: string return: Hello ${ name }! bye: "Good bye" diff --git a/examples/tutorial/defs.pdl b/examples/tutorial/defs.pdl index a3cf2e9f8..e2e49afd0 100644 --- a/examples/tutorial/defs.pdl +++ b/examples/tutorial/defs.pdl @@ -2,8 +2,8 @@ description: Function def and call defs: translate: function: - sentence: str - language: str + sentence: string + language: string return: lastOf: - "\nTranslate the sentence '${ sentence }' to ${ language }.\n" diff --git a/examples/tutorial/function_alias.pdl b/examples/tutorial/function_alias.pdl index a26f45d22..23bf7c115 100644 --- a/examples/tutorial/function_alias.pdl +++ b/examples/tutorial/function_alias.pdl @@ -2,7 +2,7 @@ description: Hello function defs: hello: function: - name: str + name: string return: Hello ${ name }! alias: ${ hello } text: diff --git a/examples/tutorial/function_definition.pdl b/examples/tutorial/function_definition.pdl index 553aae6f0..dac318dc9 100644 --- a/examples/tutorial/function_definition.pdl +++ b/examples/tutorial/function_definition.pdl @@ -2,8 +2,8 @@ description: Function def and call text: - def: translate function: - sentence: str - language: str + sentence: string + language: string return: lastOf: - "\nTranslate the sentence '${ sentence }' to ${ language }.\n" diff --git a/examples/tutorial/function_empty_context.pdl b/examples/tutorial/function_empty_context.pdl index 38aee6e4a..54e3c6858 100644 --- a/examples/tutorial/function_empty_context.pdl +++ b/examples/tutorial/function_empty_context.pdl @@ -2,7 +2,7 @@ description: Hello world with function definition and call text: - def: hello function: - name: str + name: string return: text: - Hello ${ name }! diff --git a/examples/tutorial/function_optional_params.pdl b/examples/tutorial/function_optional_params.pdl index 2aec3814e..cde3af8ac 100644 --- a/examples/tutorial/function_optional_params.pdl +++ b/examples/tutorial/function_optional_params.pdl @@ -2,8 +2,8 @@ description: Hello world with function definition and call text: - def: hello function: - name: str - lastName: {optional: str} # optional parameter + name: string + lastName: {optional: string} # optional parameter return: if: ${ lastName is defined } then: Hello ${ name } ${ lastName }! diff --git a/examples/tutorial/import_lib.pdl b/examples/tutorial/import_lib.pdl index 30f15ec36..26f7cd5f9 100644 --- a/examples/tutorial/import_lib.pdl +++ b/examples/tutorial/import_lib.pdl @@ -2,13 +2,13 @@ defs: b: function: - arg: str + arg: string return: ${ arg } a: function: - arg: str + arg: string return: call: ${ b } args: diff --git a/examples/tutorial/muting_block_output.pdl b/examples/tutorial/muting_block_output.pdl index 613b84671..c75b416a0 100644 --- a/examples/tutorial/muting_block_output.pdl +++ b/examples/tutorial/muting_block_output.pdl @@ -2,8 +2,8 @@ description: Function def and call defs: translate: function: - sentence: str - language: str + sentence: string + language: string return: text: - text: "\nTranslate the sentence '${ sentence }' to ${ language }.\n" diff --git a/examples/tutorial/parser-regex.pdl b/examples/tutorial/parser-regex.pdl index cf14dcbfd..c6d38a10d 100644 --- a/examples/tutorial/parser-regex.pdl +++ b/examples/tutorial/parser-regex.pdl @@ -5,8 +5,8 @@ text: parameters: # Tell the LLM to stop after generating an exclamation point. stop: ['!'] - spec: {"name": str} + spec: {"name": string} parser: spec: - name: str + name: string regex: '\s*(?P.*)\s*' diff --git a/examples/tutorial/parser_regex_code.pdl b/examples/tutorial/parser_regex_code.pdl index 3e64598af..676df0f54 100644 --- a/examples/tutorial/parser_regex_code.pdl +++ b/examples/tutorial/parser_regex_code.pdl @@ -7,6 +7,6 @@ defs: input: Write a Python function that perform the addition of two numbers. parser: spec: - code: str + code: string regex: (.|\n)*```python\n(?P(.|\n)*)```(.|\n)* text: ${ output.code } \ No newline at end of file diff --git a/examples/tutorial/programs/tfidf_rag.pdl b/examples/tutorial/programs/tfidf_rag.pdl index 6c2acd74b..a9d5d7323 100644 --- a/examples/tutorial/programs/tfidf_rag.pdl +++ b/examples/tutorial/programs/tfidf_rag.pdl @@ -21,7 +21,7 @@ text: contribute: [] - def: RETRIEVED lang: python - spec: {prompt: [str], code: [str]} + spec: {prompt: [string], code: [string]} code: | key = PDL_SESSION.embed("${ TEST_PROMPT }") nearest = PDL_SESSION.vec_db.get_nearest_examples("embeddings", key, 5) diff --git a/examples/tutorial/structured_decoding.pdl b/examples/tutorial/structured_decoding.pdl index b98d3a627..aaedd1406 100644 --- a/examples/tutorial/structured_decoding.pdl +++ b/examples/tutorial/structured_decoding.pdl @@ -5,4 +5,4 @@ text: - "\nWhat is the color of the sky? Write it as JSON\n" - model: watsonx/ibm/granite-34b-code-instruct parser: json - spec: { color: str } \ No newline at end of file + spec: { color: string } \ No newline at end of file diff --git a/examples/tutorial/type_checking.pdl b/examples/tutorial/type_checking.pdl index c521c3028..676db9ff5 100644 --- a/examples/tutorial/type_checking.pdl +++ b/examples/tutorial/type_checking.pdl @@ -4,11 +4,11 @@ defs: data: read: type_checking_data.yaml parser: yaml - spec: { questions: [str], answers: [obj] } + spec: { questions: [string], answers: [object] } text: - model: ollama_chat/granite3.2:2b def: model_output - spec: {name: str, age: int} + spec: {name: string, age: integer} input: array: - role: user diff --git a/examples/tutorial/type_list.pdl b/examples/tutorial/type_list.pdl index 270d37af1..d5240920b 100644 --- a/examples/tutorial/type_list.pdl +++ b/examples/tutorial/type_list.pdl @@ -1,4 +1,4 @@ # Expected not to type check description: test -spec: {"list": {"minItems": 0, "maxItems": 0, "str": {}}} +spec: {type: array, minItems: 0, maxItems: 0, items: { type: string }} data: ["hello", "world"] diff --git a/pdl-live-react/demos/error.pdl b/pdl-live-react/demos/error.pdl index 0dcaa9450..34253a74c 100644 --- a/pdl-live-react/demos/error.pdl +++ b/pdl-live-react/demos/error.pdl @@ -3,11 +3,11 @@ defs: data: read: ./gen-data.yaml parser: yaml - spec: { questions: [str], answers: [obj] } + spec: { questions: [string], answers: [object] } text: - model: ollama_chat/granite3.2:2b def: model_output - spec: {name: str, age: int} + spec: {name: string, age: integer} input: text: - for: diff --git a/pdl-live-react/src-tauri/src/pdl/ast.rs b/pdl-live-react/src-tauri/src/pdl/ast.rs index 16ff29ba5..1d7cda222 100644 --- a/pdl-live-react/src-tauri/src/pdl/ast.rs +++ b/pdl-live-react/src-tauri/src/pdl/ast.rs @@ -62,11 +62,11 @@ pub enum PdlParser { #[derive(Serialize, Deserialize, Debug, Clone)] pub enum PdlBaseType { - #[serde(rename = "str")] + #[serde(rename = "string")] Str, - #[serde(rename = "bool")] + #[serde(rename = "boolean")] Bool, - #[serde(rename = "int")] + #[serde(rename = "integer")] Int, #[serde(rename = "null")] Null, diff --git a/pdl-live-react/src-tauri/src/pdl/interpreter_tests.rs b/pdl-live-react/src-tauri/src/pdl/interpreter_tests.rs index aa727933a..3a8bf6567 100644 --- a/pdl-live-react/src-tauri/src/pdl/interpreter_tests.rs +++ b/pdl-live-react/src-tauri/src/pdl/interpreter_tests.rs @@ -277,7 +277,7 @@ mod tests { "defs": { "foo": { "function": { - "x": "int" + "x": "integer" }, "return": { "description": "unary function", @@ -687,8 +687,8 @@ mod tests { "regex": "[^0-9]*(?P[0-9]+)[^0-9]*(?P[0-9]+)$", "mode": "findall", "spec": { - "answer1": "str", - "answer2": "str" + "answer1": "string", + "answer2": "string" } } }); @@ -707,8 +707,8 @@ mod tests { "parser": { "regex": "[^0-9]*(?P[0-9]+)[^0-9]*(?P[0-9]+)$", "spec": { - "answer1": "str", - "answer2": "str" + "answer1": "string", + "answer2": "string" } } }); @@ -728,7 +728,7 @@ mod tests { "parser": { "regex": "[^0-9]*(?P[0-9]+)[^0-9]*(?P[0-9]+)$", "spec": { - "answer1": "str", + "answer1": "string", } } }); diff --git a/pdl-live-react/src-tauri/tests/cli/call-with-args.pdl b/pdl-live-react/src-tauri/tests/cli/call-with-args.pdl index eecaad795..e601c18ea 100644 --- a/pdl-live-react/src-tauri/tests/cli/call-with-args.pdl +++ b/pdl-live-react/src-tauri/tests/cli/call-with-args.pdl @@ -1,7 +1,7 @@ defs: foo: function: - x: int + x: integer return: description: nullary function text: diff --git a/pdl-live-react/src-tauri/tests/cli/regex-findall.pdl b/pdl-live-react/src-tauri/tests/cli/regex-findall.pdl index 7002e92d8..57a44b999 100644 --- a/pdl-live-react/src-tauri/tests/cli/regex-findall.pdl +++ b/pdl-live-react/src-tauri/tests/cli/regex-findall.pdl @@ -3,5 +3,5 @@ parser: regex: '[^0-9]*(?P[0-9]+)[^0-9]*(?P[0-9]+)$' mode: findall spec: - answer1: str - answer2: str + answer1: string + answer2: string diff --git a/pdl-live-react/src/pdl_ast.d.ts b/pdl-live-react/src/pdl_ast.d.ts index 245a53704..cd3cbe2d2 100644 --- a/pdl-live-react/src/pdl_ast.d.ts +++ b/pdl-live-react/src/pdl_ast.d.ts @@ -41,40 +41,18 @@ export type Program = */ export type Description = string | null export type Enum = unknown[] -export type Minlength = number | null -export type Maxlength = number | null -export type Pattern = string | null -export type Multipleof = number | null -export type Minimum = number | null -export type Exclusiveminimum = number | null -export type Maximum = number | null -export type Exclusivemaximum = number | null -export type Minimum1 = number | null -export type Exclusiveminimum1 = number | null -export type Maximum1 = number | null -export type Exclusivemaximum1 = number | null -export type List = PdlTypeType | ListPdlTypeConstraints export type PdlTypeType = - | ("null" | "bool" | "str" | "float" | "int" | "list" | "obj") + | ("null" | "boolean" | "string" | "number" | "integer" | "array" | "object") | EnumPdlType - | StrPdlType - | FloatPdlType - | IntPdlType - | ListPdlType | PdlTypeType[] | OptionalPdlType | JsonSchemaTypePdlType - | ObjPdlType + | ObjectPdlType | { [k: string]: PdlTypeType } | null export type Type = string | string[] -export type Obj = { - [k: string]: PdlTypeType -} | null -export type Minitems = number | null -export type Maxitems = number | null /** * Documentation associated to the block. * @@ -959,7 +937,7 @@ export type PdlId6 = string | null export type PdlIsLeaf6 = false export type IndependentEnum1 = "independent" | "dependent" export type Kind6 = "object" -export type Object = +export type Object1 = | { [k: string]: | boolean @@ -2915,16 +2893,20 @@ export interface FunctionBlock { * */ spec?: - | ("null" | "bool" | "str" | "float" | "int" | "list" | "obj") + | ( + | "null" + | "boolean" + | "string" + | "number" + | "integer" + | "array" + | "object" + ) | EnumPdlType - | StrPdlType - | FloatPdlType - | IntPdlType - | ListPdlType | PdlTypeType[] | OptionalPdlType | JsonSchemaTypePdlType - | ObjPdlType + | ObjectPdlType | { [k: string]: PdlTypeType } @@ -2949,61 +2931,11 @@ export interface FunctionBlock { signature?: Signature } /** - * Enumerated type. + * Json Schema with an `enum` field. */ export interface EnumPdlType { enum: Enum -} -/** - * String type. - */ -export interface StrPdlType { - str: StrPdlTypeConstraints | null -} -/** - * Constraints on string type. - */ -export interface StrPdlTypeConstraints { - minLength?: Minlength - maxLength?: Maxlength - pattern?: Pattern -} -/** - * Float type. - */ -export interface FloatPdlType { - float: FloatPdlTypeConstraints | null -} -/** - * Constraints on float type. - */ -export interface FloatPdlTypeConstraints { - multipleOf?: Multipleof - minimum?: Minimum - exclusiveMinimum?: Exclusiveminimum - maximum?: Maximum - exclusiveMaximum?: Exclusivemaximum -} -/** - * Integer type. - */ -export interface IntPdlType { - int: IntPdlTypeConstraints | null -} -/** - * Constraints on integer type. - */ -export interface IntPdlTypeConstraints { - minimum?: Minimum1 - exclusiveMinimum?: Exclusiveminimum1 - maximum?: Maximum1 - exclusiveMaximum?: Exclusivemaximum1 -} -/** - * List type. - */ -export interface ListPdlType { - list: List + [k: string]: unknown } /** * Optional type. @@ -3012,7 +2944,7 @@ export interface OptionalPdlType { optional: PdlTypeType } /** - * Json Schema type + * Json Schema with a type field. */ export interface JsonSchemaTypePdlType { type: Type @@ -3021,16 +2953,11 @@ export interface JsonSchemaTypePdlType { /** * Object type. */ -export interface ObjPdlType { - obj: Obj +export interface ObjectPdlType { + object: Object } -/** - * Constraints on list type. - */ -export interface ListPdlTypeConstraints { - minItems?: Minitems - maxItems?: Maxitems - [k: string]: unknown +export interface Object { + [k: string]: PdlTypeType } /** * Set of definitions executed before the execution of the block. @@ -3074,16 +3001,20 @@ export interface CallBlock { * */ spec?: - | ("null" | "bool" | "str" | "float" | "int" | "list" | "obj") + | ( + | "null" + | "boolean" + | "string" + | "number" + | "integer" + | "array" + | "object" + ) | EnumPdlType - | StrPdlType - | FloatPdlType - | IntPdlType - | ListPdlType | PdlTypeType[] | OptionalPdlType | JsonSchemaTypePdlType - | ObjPdlType + | ObjectPdlType | { [k: string]: PdlTypeType } @@ -3156,16 +3087,20 @@ export interface LitellmModelBlock { * */ spec?: - | ("null" | "bool" | "str" | "float" | "int" | "list" | "obj") + | ( + | "null" + | "boolean" + | "string" + | "number" + | "integer" + | "array" + | "object" + ) | EnumPdlType - | StrPdlType - | FloatPdlType - | IntPdlType - | ListPdlType | PdlTypeType[] | OptionalPdlType | JsonSchemaTypePdlType - | ObjPdlType + | ObjectPdlType | { [k: string]: PdlTypeType } @@ -3239,16 +3174,20 @@ export interface GraniteioModelBlock { * */ spec?: - | ("null" | "bool" | "str" | "float" | "int" | "list" | "obj") + | ( + | "null" + | "boolean" + | "string" + | "number" + | "integer" + | "array" + | "object" + ) | EnumPdlType - | StrPdlType - | FloatPdlType - | IntPdlType - | ListPdlType | PdlTypeType[] | OptionalPdlType | JsonSchemaTypePdlType - | ObjPdlType + | ObjectPdlType | { [k: string]: PdlTypeType } @@ -3333,16 +3272,20 @@ export interface CodeBlock { * */ spec?: - | ("null" | "bool" | "str" | "float" | "int" | "list" | "obj") + | ( + | "null" + | "boolean" + | "string" + | "number" + | "integer" + | "array" + | "object" + ) | EnumPdlType - | StrPdlType - | FloatPdlType - | IntPdlType - | ListPdlType | PdlTypeType[] | OptionalPdlType | JsonSchemaTypePdlType - | ObjPdlType + | ObjectPdlType | { [k: string]: PdlTypeType } @@ -3415,16 +3358,20 @@ export interface ArgsBlock { * */ spec?: - | ("null" | "bool" | "str" | "float" | "int" | "list" | "obj") + | ( + | "null" + | "boolean" + | "string" + | "number" + | "integer" + | "array" + | "object" + ) | EnumPdlType - | StrPdlType - | FloatPdlType - | IntPdlType - | ListPdlType | PdlTypeType[] | OptionalPdlType | JsonSchemaTypePdlType - | ObjPdlType + | ObjectPdlType | { [k: string]: PdlTypeType } @@ -3491,16 +3438,20 @@ export interface GetBlock { * */ spec?: - | ("null" | "bool" | "str" | "float" | "int" | "list" | "obj") + | ( + | "null" + | "boolean" + | "string" + | "number" + | "integer" + | "array" + | "object" + ) | EnumPdlType - | StrPdlType - | FloatPdlType - | IntPdlType - | ListPdlType | PdlTypeType[] | OptionalPdlType | JsonSchemaTypePdlType - | ObjPdlType + | ObjectPdlType | { [k: string]: PdlTypeType } @@ -3574,7 +3525,7 @@ export interface Defs6 { * parser: * regex: "(.|\n)*#### (?P([0-9])*)\n*" * spec: - * answer: str + * answer: string * def: EXTRACTED_GROUND_TRUTH * ``` */ @@ -3585,16 +3536,20 @@ export interface DataBlock { * */ spec?: - | ("null" | "bool" | "str" | "float" | "int" | "list" | "obj") + | ( + | "null" + | "boolean" + | "string" + | "number" + | "integer" + | "array" + | "object" + ) | EnumPdlType - | StrPdlType - | FloatPdlType - | IntPdlType - | ListPdlType | PdlTypeType[] | OptionalPdlType | JsonSchemaTypePdlType - | ObjPdlType + | ObjectPdlType | { [k: string]: PdlTypeType } @@ -3669,16 +3624,20 @@ export interface IfBlock { * */ spec?: - | ("null" | "bool" | "str" | "float" | "int" | "list" | "obj") + | ( + | "null" + | "boolean" + | "string" + | "number" + | "integer" + | "array" + | "object" + ) | EnumPdlType - | StrPdlType - | FloatPdlType - | IntPdlType - | ListPdlType | PdlTypeType[] | OptionalPdlType | JsonSchemaTypePdlType - | ObjPdlType + | ObjectPdlType | { [k: string]: PdlTypeType } @@ -3763,16 +3722,20 @@ export interface MatchBlock { * */ spec?: - | ("null" | "bool" | "str" | "float" | "int" | "list" | "obj") + | ( + | "null" + | "boolean" + | "string" + | "number" + | "integer" + | "array" + | "object" + ) | EnumPdlType - | StrPdlType - | FloatPdlType - | IntPdlType - | ListPdlType | PdlTypeType[] | OptionalPdlType | JsonSchemaTypePdlType - | ObjPdlType + | ObjectPdlType | { [k: string]: PdlTypeType } @@ -3857,16 +3820,20 @@ export interface RepeatBlock { * */ spec?: - | ("null" | "bool" | "str" | "float" | "int" | "list" | "obj") + | ( + | "null" + | "boolean" + | "string" + | "number" + | "integer" + | "array" + | "object" + ) | EnumPdlType - | StrPdlType - | FloatPdlType - | IntPdlType - | ListPdlType | PdlTypeType[] | OptionalPdlType | JsonSchemaTypePdlType - | ObjPdlType + | ObjectPdlType | { [k: string]: PdlTypeType } @@ -3938,16 +3905,20 @@ export interface TextBlock { * */ spec?: - | ("null" | "bool" | "str" | "float" | "int" | "list" | "obj") + | ( + | "null" + | "boolean" + | "string" + | "number" + | "integer" + | "array" + | "object" + ) | EnumPdlType - | StrPdlType - | FloatPdlType - | IntPdlType - | ListPdlType | PdlTypeType[] | OptionalPdlType | JsonSchemaTypePdlType - | ObjPdlType + | ObjectPdlType | { [k: string]: PdlTypeType } @@ -4012,16 +3983,20 @@ export interface LastOfBlock { * */ spec?: - | ("null" | "bool" | "str" | "float" | "int" | "list" | "obj") + | ( + | "null" + | "boolean" + | "string" + | "number" + | "integer" + | "array" + | "object" + ) | EnumPdlType - | StrPdlType - | FloatPdlType - | IntPdlType - | ListPdlType | PdlTypeType[] | OptionalPdlType | JsonSchemaTypePdlType - | ObjPdlType + | ObjectPdlType | { [k: string]: PdlTypeType } @@ -4086,16 +4061,20 @@ export interface ArrayBlock { * */ spec?: - | ("null" | "bool" | "str" | "float" | "int" | "list" | "obj") + | ( + | "null" + | "boolean" + | "string" + | "number" + | "integer" + | "array" + | "object" + ) | EnumPdlType - | StrPdlType - | FloatPdlType - | IntPdlType - | ListPdlType | PdlTypeType[] | OptionalPdlType | JsonSchemaTypePdlType - | ObjPdlType + | ObjectPdlType | { [k: string]: PdlTypeType } @@ -4160,16 +4139,20 @@ export interface ObjectBlock { * */ spec?: - | ("null" | "bool" | "str" | "float" | "int" | "list" | "obj") + | ( + | "null" + | "boolean" + | "string" + | "number" + | "integer" + | "array" + | "object" + ) | EnumPdlType - | StrPdlType - | FloatPdlType - | IntPdlType - | ListPdlType | PdlTypeType[] | OptionalPdlType | JsonSchemaTypePdlType - | ObjPdlType + | ObjectPdlType | { [k: string]: PdlTypeType } @@ -4190,7 +4173,7 @@ export interface ObjectBlock { pdl__is_leaf?: PdlIsLeaf6 context?: IndependentEnum1 kind?: Kind6 - object: Object + object: Object1 } /** * Set of definitions executed before the execution of the block. @@ -4234,16 +4217,20 @@ export interface MessageBlock { * */ spec?: - | ("null" | "bool" | "str" | "float" | "int" | "list" | "obj") + | ( + | "null" + | "boolean" + | "string" + | "number" + | "integer" + | "array" + | "object" + ) | EnumPdlType - | StrPdlType - | FloatPdlType - | IntPdlType - | ListPdlType | PdlTypeType[] | OptionalPdlType | JsonSchemaTypePdlType - | ObjPdlType + | ObjectPdlType | { [k: string]: PdlTypeType } @@ -4321,16 +4308,20 @@ export interface ReadBlock { * */ spec?: - | ("null" | "bool" | "str" | "float" | "int" | "list" | "obj") + | ( + | "null" + | "boolean" + | "string" + | "number" + | "integer" + | "array" + | "object" + ) | EnumPdlType - | StrPdlType - | FloatPdlType - | IntPdlType - | ListPdlType | PdlTypeType[] | OptionalPdlType | JsonSchemaTypePdlType - | ObjPdlType + | ObjectPdlType | { [k: string]: PdlTypeType } @@ -4396,16 +4387,20 @@ export interface IncludeBlock { * */ spec?: - | ("null" | "bool" | "str" | "float" | "int" | "list" | "obj") + | ( + | "null" + | "boolean" + | "string" + | "number" + | "integer" + | "array" + | "object" + ) | EnumPdlType - | StrPdlType - | FloatPdlType - | IntPdlType - | ListPdlType | PdlTypeType[] | OptionalPdlType | JsonSchemaTypePdlType - | ObjPdlType + | ObjectPdlType | { [k: string]: PdlTypeType } @@ -4471,16 +4466,20 @@ export interface ImportBlock { * */ spec?: - | ("null" | "bool" | "str" | "float" | "int" | "list" | "obj") + | ( + | "null" + | "boolean" + | "string" + | "number" + | "integer" + | "array" + | "object" + ) | EnumPdlType - | StrPdlType - | FloatPdlType - | IntPdlType - | ListPdlType | PdlTypeType[] | OptionalPdlType | JsonSchemaTypePdlType - | ObjPdlType + | ObjectPdlType | { [k: string]: PdlTypeType } @@ -4545,16 +4544,20 @@ export interface ErrorBlock { * */ spec?: - | ("null" | "bool" | "str" | "float" | "int" | "list" | "obj") + | ( + | "null" + | "boolean" + | "string" + | "number" + | "integer" + | "array" + | "object" + ) | EnumPdlType - | StrPdlType - | FloatPdlType - | IntPdlType - | ListPdlType | PdlTypeType[] | OptionalPdlType | JsonSchemaTypePdlType - | ObjPdlType + | ObjectPdlType | { [k: string]: PdlTypeType } @@ -4619,16 +4622,20 @@ export interface EmptyBlock { * */ spec?: - | ("null" | "bool" | "str" | "float" | "int" | "list" | "obj") + | ( + | "null" + | "boolean" + | "string" + | "number" + | "integer" + | "array" + | "object" + ) | EnumPdlType - | StrPdlType - | FloatPdlType - | IntPdlType - | ListPdlType | PdlTypeType[] | OptionalPdlType | JsonSchemaTypePdlType - | ObjPdlType + | ObjectPdlType | { [k: string]: PdlTypeType } @@ -4706,16 +4713,20 @@ export interface Table { export interface PdlParser { description?: Description21 spec?: - | ("null" | "bool" | "str" | "float" | "int" | "list" | "obj") + | ( + | "null" + | "boolean" + | "string" + | "number" + | "integer" + | "array" + | "object" + ) | EnumPdlType - | StrPdlType - | FloatPdlType - | IntPdlType - | ListPdlType | PdlTypeType[] | OptionalPdlType | JsonSchemaTypePdlType - | ObjPdlType + | ObjectPdlType | { [k: string]: PdlTypeType } @@ -4728,16 +4739,20 @@ export interface PdlParser { export interface RegexParser { description?: Description22 spec?: - | ("null" | "bool" | "str" | "float" | "int" | "list" | "obj") + | ( + | "null" + | "boolean" + | "string" + | "number" + | "integer" + | "array" + | "object" + ) | EnumPdlType - | StrPdlType - | FloatPdlType - | IntPdlType - | ListPdlType | PdlTypeType[] | OptionalPdlType | JsonSchemaTypePdlType - | ObjPdlType + | ObjectPdlType | { [k: string]: PdlTypeType } @@ -4788,9 +4803,9 @@ export interface ArrayPattern { } export interface ObjectPattern { def?: Def14 - object: Object1 + object: Object2 } -export interface Object1 { +export interface Object2 { [k: string]: | boolean | number diff --git a/src/pdl/pdl-schema.json b/src/pdl/pdl-schema.json index 6a034fabc..41cffe823 100644 --- a/src/pdl/pdl-schema.json +++ b/src/pdl/pdl-schema.json @@ -1951,7 +1951,7 @@ }, "DataBlock": { "additionalProperties": false, - "description": "Arbitrary value, equivalent to JSON.\n\nExample. As part of a `defs` section, set `numbers` to the list `[1, 2, 3, 4]`:\n```PDL\ndefs:\n numbers:\n data: [1, 2, 3, 4]\n```\n\nExample. Evaluate `${ TEST.answer }` in\n[Jinja](https://jinja.palletsprojects.com/en/stable/), passing\nthe result to a regex parser with capture groups. Set\n`EXTRACTED_GROUND_TRUTH` to an object with attribute `answer`,\na string, containing the value of the capture group.\n```PDL\n- data: ${ TEST.answer }\n parser:\n regex: \"(.|\\n)*#### (?P([0-9])*)\\n*\"\n spec:\n answer: str\n def: EXTRACTED_GROUND_TRUTH\n```", + "description": "Arbitrary value, equivalent to JSON.\n\nExample. As part of a `defs` section, set `numbers` to the list `[1, 2, 3, 4]`:\n```PDL\ndefs:\n numbers:\n data: [1, 2, 3, 4]\n```\n\nExample. Evaluate `${ TEST.answer }` in\n[Jinja](https://jinja.palletsprojects.com/en/stable/), passing\nthe result to a regex parser with capture groups. Set\n`EXTRACTED_GROUND_TRUTH` to an object with attribute `answer`,\na string, containing the value of the capture group.\n```PDL\n- data: ${ TEST.answer }\n parser:\n regex: \"(.|\\n)*#### (?P([0-9])*)\\n*\"\n spec:\n answer: string\n def: EXTRACTED_GROUND_TRUTH\n```", "properties": { "description": { "anyOf": [ @@ -2722,8 +2722,8 @@ "type": "object" }, "EnumPdlType": { - "additionalProperties": false, - "description": "Enumerated type.", + "additionalProperties": true, + "description": "Json Schema with an `enum` field.", "properties": { "enum": { "items": {}, @@ -3205,95 +3205,6 @@ "title": "ErrorBlock", "type": "object" }, - "FloatPdlType": { - "additionalProperties": false, - "description": "Float type.", - "properties": { - "float": { - "anyOf": [ - { - "$ref": "#/$defs/FloatPdlTypeConstraints" - }, - { - "type": "null" - } - ] - } - }, - "required": [ - "float" - ], - "title": "FloatPdlType", - "type": "object" - }, - "FloatPdlTypeConstraints": { - "additionalProperties": false, - "description": "Constraints on float type.", - "properties": { - "multipleOf": { - "anyOf": [ - { - "type": "number" - }, - { - "type": "null" - } - ], - "default": null, - "title": "Multipleof" - }, - "minimum": { - "anyOf": [ - { - "type": "number" - }, - { - "type": "null" - } - ], - "default": null, - "title": "Minimum" - }, - "exclusiveMinimum": { - "anyOf": [ - { - "type": "number" - }, - { - "type": "null" - } - ], - "default": null, - "title": "Exclusiveminimum" - }, - "maximum": { - "anyOf": [ - { - "type": "number" - }, - { - "type": "null" - } - ], - "default": null, - "title": "Maximum" - }, - "exclusiveMaximum": { - "anyOf": [ - { - "type": "number" - }, - { - "type": "null" - } - ], - "default": null, - "title": "Exclusivemaximum" - } - }, - "title": "FloatPdlTypeConstraints", - "type": "object" - }, "FunctionBlock": { "additionalProperties": false, "description": "Function declaration.", @@ -6272,83 +6183,6 @@ "title": "IndependentEnum", "type": "string" }, - "IntPdlType": { - "additionalProperties": false, - "description": "Integer type.", - "properties": { - "int": { - "anyOf": [ - { - "$ref": "#/$defs/IntPdlTypeConstraints" - }, - { - "type": "null" - } - ] - } - }, - "required": [ - "int" - ], - "title": "IntPdlType", - "type": "object" - }, - "IntPdlTypeConstraints": { - "additionalProperties": false, - "description": "Constraints on integer type.", - "properties": { - "minimum": { - "anyOf": [ - { - "type": "number" - }, - { - "type": "null" - } - ], - "default": null, - "title": "Minimum" - }, - "exclusiveMinimum": { - "anyOf": [ - { - "type": "number" - }, - { - "type": "null" - } - ], - "default": null, - "title": "Exclusiveminimum" - }, - "maximum": { - "anyOf": [ - { - "type": "number" - }, - { - "type": "null" - } - ], - "default": null, - "title": "Maximum" - }, - "exclusiveMaximum": { - "anyOf": [ - { - "type": "number" - }, - { - "type": "null" - } - ], - "default": null, - "title": "Exclusivemaximum" - } - }, - "title": "IntPdlTypeConstraints", - "type": "object" - }, "JoinArray": { "additionalProperties": false, "properties": { @@ -6419,7 +6253,7 @@ }, "JsonSchemaTypePdlType": { "additionalProperties": true, - "description": "Json Schema type", + "description": "Json Schema with a type field.", "properties": { "type": { "anyOf": [ @@ -6911,60 +6745,6 @@ "title": "LastOfBlock", "type": "object" }, - "ListPdlType": { - "additionalProperties": false, - "description": "List type.", - "properties": { - "list": { - "anyOf": [ - { - "$ref": "#/$defs/PdlTypeType" - }, - { - "$ref": "#/$defs/ListPdlTypeConstraints" - } - ], - "title": "List" - } - }, - "required": [ - "list" - ], - "title": "ListPdlType", - "type": "object" - }, - "ListPdlTypeConstraints": { - "additionalProperties": true, - "description": "Constraints on list type.", - "properties": { - "minItems": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "null" - } - ], - "default": null, - "title": "Minitems" - }, - "maxItems": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "null" - } - ], - "default": null, - "title": "Maxitems" - } - }, - "title": "ListPdlTypeConstraints", - "type": "object" - }, "LitellmModelBlock": { "additionalProperties": false, "description": "Call an LLM through [the LiteLLM API](https://docs.litellm.ai/).\n\nExample:\n```PDL\n- model: ollama/granite-code:8b\n parameters:\n stop: ['!']\n```", @@ -9026,31 +8806,6 @@ "title": "MessageBlock", "type": "object" }, - "ObjPdlType": { - "additionalProperties": false, - "description": "Object type.", - "properties": { - "obj": { - "anyOf": [ - { - "additionalProperties": { - "$ref": "#/$defs/PdlTypeType" - }, - "type": "object" - }, - { - "type": "null" - } - ], - "title": "Obj" - } - }, - "required": [ - "obj" - ], - "title": "ObjPdlType", - "type": "object" - }, "ObjectBlock": { "additionalProperties": false, "description": "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.", @@ -9665,6 +9420,24 @@ "title": "ObjectPattern", "type": "object" }, + "ObjectPdlType": { + "additionalProperties": false, + "description": "Object type.", + "properties": { + "object": { + "additionalProperties": { + "$ref": "#/$defs/PdlTypeType" + }, + "title": "Object", + "type": "object" + } + }, + "required": [ + "object" + ], + "title": "ObjectPdlType", + "type": "object" + }, "OptionalPdlType": { "additionalProperties": false, "description": "Optional type.", @@ -10020,30 +9793,18 @@ { "enum": [ "null", - "bool", - "str", - "float", - "int", - "list", - "obj" + "boolean", + "string", + "number", + "integer", + "array", + "object" ], "type": "string" }, { "$ref": "#/$defs/EnumPdlType" }, - { - "$ref": "#/$defs/StrPdlType" - }, - { - "$ref": "#/$defs/FloatPdlType" - }, - { - "$ref": "#/$defs/IntPdlType" - }, - { - "$ref": "#/$defs/ListPdlType" - }, { "items": { "$ref": "#/$defs/PdlTypeType" @@ -10057,7 +9818,7 @@ "$ref": "#/$defs/JsonSchemaTypePdlType" }, { - "$ref": "#/$defs/ObjPdlType" + "$ref": "#/$defs/ObjectPdlType" }, { "additionalProperties": { @@ -11313,71 +11074,6 @@ "title": "RepeatBlock", "type": "object" }, - "StrPdlType": { - "additionalProperties": false, - "description": "String type.", - "properties": { - "str": { - "anyOf": [ - { - "$ref": "#/$defs/StrPdlTypeConstraints" - }, - { - "type": "null" - } - ] - } - }, - "required": [ - "str" - ], - "title": "StrPdlType", - "type": "object" - }, - "StrPdlTypeConstraints": { - "additionalProperties": false, - "description": "Constraints on string type.", - "properties": { - "minLength": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "null" - } - ], - "default": null, - "title": "Minlength" - }, - "maxLength": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "null" - } - ], - "default": null, - "title": "Maxlength" - }, - "pattern": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "title": "Pattern" - } - }, - "title": "StrPdlTypeConstraints", - "type": "object" - }, "TextBlock": { "additionalProperties": false, "description": "Create the concatenation of the stringify version of the result of each block of the list of blocks.", diff --git a/src/pdl/pdl_ast.py b/src/pdl/pdl_ast.py index 6a6ca38e1..a25c64a7f 100644 --- a/src/pdl/pdl_ast.py +++ b/src/pdl/pdl_ast.py @@ -143,7 +143,9 @@ class AnyPattern(Pattern): ) -BasePdlType: TypeAlias = Literal["null", "bool", "str", "float", "int", "list", "obj"] +BasePdlType: TypeAlias = Literal[ + "null", "boolean", "string", "number", "integer", "array", "object" +] class PdlType(BaseModel): @@ -152,95 +154,36 @@ class PdlType(BaseModel): model_config = ConfigDict(extra="forbid") -class EnumPdlType(PdlType): - """Enumerated type.""" - - enum: list[Any] - """List of allowed values in the type.""" - - -class StrPdlTypeConstraints(BaseModel): - """Constraints on string type.""" - - model_config = ConfigDict(extra="forbid") - minLength: Optional[int] = None - """Minimal length of the string.""" - maxLength: Optional[int] = None - """Maximal length of the string.""" - pattern: Optional[str] = None - """Regular expression that values of the type must match.""" - - -class StrPdlType(PdlType): - """String type.""" - - str: Optional[StrPdlTypeConstraints] - - -class FloatPdlTypeConstraints(BaseModel): - """Constraints on float type.""" - - model_config = ConfigDict(extra="forbid") - multipleOf: Optional[float] = None - minimum: Optional[float] = None - exclusiveMinimum: Optional[float] = None - maximum: Optional[float] = None - exclusiveMaximum: Optional[float] = None - - -class FloatPdlType(PdlType): - """Float type.""" - - float: Optional[FloatPdlTypeConstraints] - - -class IntPdlTypeConstraints(BaseModel): - """Constraints on integer type.""" - - model_config = ConfigDict(extra="forbid") - minimum: Optional[float] = None - exclusiveMinimum: Optional[float] = None - maximum: Optional[float] = None - exclusiveMaximum: Optional[float] = None - - -class IntPdlType(PdlType): - """Integer type.""" - - int: Optional[IntPdlTypeConstraints] - - -class ListPdlTypeConstraints(BaseModel): - """Constraints on list type.""" - - model_config = ConfigDict(extra="allow") - minItems: Optional[int] = None - maxItems: Optional[int] = None - - -class ListPdlType(PdlType): - """List type.""" - - list: Union["PdlTypeType", ListPdlTypeConstraints] - - class OptionalPdlType(PdlType): """Optional type.""" optional: "PdlTypeType" + """""" class JsonSchemaTypePdlType(PdlType): - """Json Schema type""" + """Json Schema with a type field.""" model_config = ConfigDict(extra="allow") + type: str | list[str] + """Data type that a schema should expect.""" + + +class EnumPdlType(PdlType): + """Json Schema with an `enum` field.""" + + model_config = ConfigDict(extra="allow") + + enum: list[Any] + """List of allowed values in the type.""" -class ObjPdlType(PdlType): +class ObjectPdlType(PdlType): """Object type.""" - obj: Optional[dict[str, "PdlTypeType"]] + object: dict[str, "PdlTypeType"] + """Fields of the objects with their types.""" PdlTypeType = TypeAliasType( @@ -249,14 +192,10 @@ class ObjPdlType(PdlType): "Union[None," # pyright: ignore " BasePdlType," " EnumPdlType," - " StrPdlType," - " FloatPdlType," - " IntPdlType," - " ListPdlType," " list['PdlTypeType']," " OptionalPdlType," " JsonSchemaTypePdlType," - " ObjPdlType," + " ObjectPdlType," " dict[str, 'PdlTypeType']]", Field(union_mode="left_to_right"), ], @@ -683,7 +622,7 @@ class DataBlock(LeafBlock): parser: regex: "(.|\\n)*#### (?P([0-9])*)\\n*" spec: - answer: str + answer: string def: EXTRACTED_GROUND_TRUTH ``` """ diff --git a/src/pdl/pdl_dumper.py b/src/pdl/pdl_dumper.py index b0ef300b5..eddea82a0 100644 --- a/src/pdl/pdl_dumper.py +++ b/src/pdl/pdl_dumper.py @@ -22,20 +22,16 @@ EnumPdlType, ErrorBlock, ExpressionType, - FloatPdlType, FunctionBlock, GetBlock, GraniteioModelBlock, IfBlock, ImportBlock, IncludeBlock, - IntPdlType, JoinText, JoinType, JsonSchemaTypePdlType, LastOfBlock, - ListPdlType, - ListPdlTypeConstraints, LitellmModelBlock, LitellmParameters, LocalizedExpression, @@ -43,7 +39,7 @@ MessageBlock, ObjectBlock, ObjectPattern, - ObjPdlType, + ObjectPdlType, OptionalPdlType, OrPattern, ParserType, @@ -57,7 +53,6 @@ ReadBlock, RegexParser, RepeatBlock, - StrPdlType, StructuredBlock, TextBlock, ) @@ -323,65 +318,10 @@ def type_to_dict(t: PdlTypeType): match t: case None: d = None - case "null" | "bool" | "str" | "float" | "int" | "list" | "obj": + case "null" | "boolean" | "string" | "number" | "integer" | "array" | "object": d = t case EnumPdlType(): - d = {"enum": t.enum} - case StrPdlType(): - if t.str is None: - d = "str" - else: - cstr: dict = {} - if t.str.minLength is not None: - cstr["minLength"] = t.str.minLength - if t.str.maxLength is not None: - cstr["maxLength"] = t.str.maxLength - if t.str.pattern is not None: - cstr["pattern"] = t.str.pattern - d = {"str": cstr} - case FloatPdlType(): - if t.float is None: - d = "float" - else: - cstr = {} - if t.float.multipleOf is not None: - cstr["multipleOf"] = t.float.multipleOf - if t.float.minimum is not None: - cstr["minimum"] = t.float.minimum - if t.float.exclusiveMinimum is not None: - cstr["exclusiveMinimum"] = t.float.exclusiveMinimum - if t.float.maximum is not None: - cstr["maximum"] = t.float.maximum - if t.float.exclusiveMaximum is not None: - cstr["exclusiveMaximum"] = t.float.exclusiveMaximum - d = {"float": cstr} - case IntPdlType(): - if t.int is None: - d = "int" - else: - cstr = {} - if t.int.minimum is not None: - cstr["minimum"] = t.int.minimum - if t.int.exclusiveMinimum is not None: - cstr["exclusiveMinimum"] = t.int.exclusiveMinimum - if t.int.maximum is not None: - cstr["maximum"] = t.int.maximum - if t.int.exclusiveMaximum is not None: - cstr["exclusiveMaximum"] = t.int.exclusiveMaximum - d = {"int": cstr} - case ListPdlType(): - if t.list is None: - d = "list" - else: - if isinstance(t.list, ListPdlTypeConstraints): - cstr = type_to_dict(t.list.__pydantic_extra__) - if t.list.minItems is not None: - cstr["minItems"] = t.list.minItems - if t.list.maxItems is not None: - cstr["maxItems"] = t.list.maxItems - d = {"list": cstr} - else: - d = {"list": type_to_dict(t.list)} + d = t.model_dump() case [elem]: d = [type_to_dict(elem)] # type:ignore case list(): @@ -390,11 +330,8 @@ def type_to_dict(t: PdlTypeType): d = {"optional": type_to_dict(t.optional)} case JsonSchemaTypePdlType(): d = t.model_dump() - case ObjPdlType(): - if t.obj is None: - d = "obj" - else: - d = {"obj": {x: type_to_dict(t_x) for x, t_x in t.obj.items()}} + case ObjectPdlType(): + d = {"object": {x: type_to_dict(t_x) for x, t_x in t.object.items()}} case dict(): d = {x: type_to_dict(t_x) for x, t_x in t.items()} case _: diff --git a/src/pdl/pdl_interpreter.py b/src/pdl/pdl_interpreter.py index 7dd55cb4c..6e1f803c1 100644 --- a/src/pdl/pdl_interpreter.py +++ b/src/pdl/pdl_interpreter.py @@ -71,7 +71,7 @@ ModelPlatform, ObjectBlock, ObjectPattern, - ObjPdlType, + ObjectPdlType, OrPattern, ParserType, Pattern, @@ -2055,7 +2055,7 @@ def parse_result(parser: ParserType, text: str) -> JSONReturnType: if m is None: return None match parser.spec: - case ObjPdlType(obj=dict() as spec) | (dict() as spec): + case ObjectPdlType(object=dict() as spec) | (dict() as spec): current_group_name = "" try: result = {} diff --git a/src/pdl/pdl_schema_utils.py b/src/pdl/pdl_schema_utils.py index f5adb6f22..b923b1965 100644 --- a/src/pdl/pdl_schema_utils.py +++ b/src/pdl/pdl_schema_utils.py @@ -3,16 +3,10 @@ from .pdl_ast import ( EnumPdlType, - FloatPdlType, - IntPdlType, JsonSchemaTypePdlType, - ListPdlType, - ListPdlTypeConstraints, - ObjPdlType, + ObjectPdlType, OptionalPdlType, PdlTypeType, - StrPdlType, - pdl_type_adapter, ) json_types_convert = { @@ -32,17 +26,6 @@ def convert_to_json_type(a_type): return None -_PDLTYPE_TO_JSONSCHEMA_NAME = { - "null": "null", - "bool": "boolean", - "str": "string", - "float": "number", - "int": "integer", - "list": "array", - "obj": "object", -} - - def pdltype_to_jsonschema( pdl_type: PdlTypeType, additional_properties: bool ) -> dict[str, Any]: @@ -50,58 +33,14 @@ def pdltype_to_jsonschema( match pdl_type: case None: schema = {} # Any type - case "null" | "bool" | "str" | "float" | "int" | "list" | "obj": - schema = {"type": _PDLTYPE_TO_JSONSCHEMA_NAME[pdl_type]} + case "null" | "boolean" | "string" | "number" | "integer" | "array" | "object": + schema = {"type": pdl_type} case EnumPdlType(enum=choices): - schema = {"enum": choices} - case StrPdlType(str=None): - schema = {"type": "string"} - case StrPdlType(str=constraints): - if constraints is None: - details = {} - else: - details = constraints.model_dump(exclude_defaults=True) - schema = {"type": "string", **details} - case FloatPdlType(float=constraints): - if constraints is None: - details = {} - else: - details = constraints.model_dump(exclude_defaults=True) - schema = {"type": "number", **details} - case IntPdlType(int=constraints): - if constraints is None: - details = {} + if pdl_type.__pydantic_extra__ is None: + extra = {} else: - details = constraints.model_dump(exclude_defaults=True) - schema = {"type": "integer", **details} - case ListPdlType(list=ListPdlTypeConstraints() as cstr): - items_type = pdl_type_adapter.validate_python(cstr.__pydantic_extra__) - details = {} - if cstr.minItems is not None: - details["minItems"] = cstr.minItems - if cstr.maxItems is not None: - details["maxItems"] = cstr.maxItems - schema = { - "type": "array", - "items": pdltype_to_jsonschema(items_type, additional_properties), - **details, - } - case ListPdlType(list=items_type): - schema = { - "type": "array", - "items": pdltype_to_jsonschema(items_type, additional_properties), - } - # case {"list": dict() as details}: - # ikws = ["enum", *_PDLTYPE_TO_JSONSCHEMA_NAME.keys()] - # items_details = {k: v for k, v in details.items() if k in ikws} - # if len(items_details) != 1: - # raise ValueError(f"invalid PDL type {pdl_type}") - # other_details = {k: v for k, v in details.items() if k not in ikws} - # return { - # "type": "array", - # "items": pdltype_to_jsonschema(items_details, additional_properties), - # **other_details, - # } + extra = pdl_type.__pydantic_extra__ + schema = {"enum": choices, **extra} case list() as type_list: if len(type_list) != 1: raise ValueError(f"invalid PDL type {pdl_type}") @@ -111,14 +50,14 @@ def pdltype_to_jsonschema( } case OptionalPdlType(optional=t): t_schema = pdltype_to_jsonschema(t, additional_properties) - schema = {"anyOf": [t_schema, "null"]} + schema = {"anyOf": [t_schema, {"type": "null"}]} case JsonSchemaTypePdlType(type=t): if pdl_type.__pydantic_extra__ is None: extra = {} else: extra = pdl_type.__pydantic_extra__ schema = {"type": t, **extra} - case ObjPdlType(obj=pdl_props): + case ObjectPdlType(object=pdl_props): if pdl_props is None: schema = {"type": "object"} else: @@ -159,7 +98,7 @@ def get_json_schema( ) -> Optional[dict[str, Any]]: try: result = pdltype_to_jsonschema( - ObjPdlType.model_validate({"obj": params}), additional_properties + ObjectPdlType.model_validate({"object": params}), additional_properties ) return result except ValueError as e: diff --git a/src/pdl/pdl_schema_validator.py b/src/pdl/pdl_schema_validator.py index c84ca5374..929bed935 100644 --- a/src/pdl/pdl_schema_validator.py +++ b/src/pdl/pdl_schema_validator.py @@ -27,7 +27,7 @@ def type_check_args( # if "pdl_context" not in params_copy: if "pdl_context" in args_copy: # params_copy["pdl_context"] = [{"role": "str?", "content": "str"}] - params_copy["pdl_context"] = ["obj"] + params_copy["pdl_context"] = ["object"] for k, v in args_copy.items(): if isinstance(v, FunctionBlock): args_copy[k] = v.model_dump() diff --git a/tests/data/call_expression_args.pdl b/tests/data/call_expression_args.pdl index 762420d82..f8901e10f 100644 --- a/tests/data/call_expression_args.pdl +++ b/tests/data/call_expression_args.pdl @@ -1,7 +1,7 @@ defs: get_current_stock: function: - product_name: str + product_name: string return: "FN::get_current_stock:: '${product_name}'\n" text: diff --git a/tests/data/function.pdl b/tests/data/function.pdl index ed7234c06..2fd3a0c44 100644 --- a/tests/data/function.pdl +++ b/tests/data/function.pdl @@ -2,9 +2,9 @@ description: Function definition defs: template: function: - preamble: str - question: str - notes: str + preamble: string + question: string + notes: string return: | ${ preamble } ### Question: ${ question } diff --git a/tests/data/line/hello10.pdl b/tests/data/line/hello10.pdl index 7e9645a25..a03d71b2a 100644 --- a/tests/data/line/hello10.pdl +++ b/tests/data/line/hello10.pdl @@ -8,4 +8,4 @@ text: contribute: [] - if: '${ QUESTION }' then: How are you? - spec: bool \ No newline at end of file + spec: boolean \ No newline at end of file diff --git a/tests/data/line/hello11.pdl b/tests/data/line/hello11.pdl index 960775c02..5f3da6386 100644 --- a/tests/data/line/hello11.pdl +++ b/tests/data/line/hello11.pdl @@ -8,4 +8,4 @@ text: contribute: [] - if: '${ QUESTION }' then: How are you? - spec: bool \ No newline at end of file + spec: boolean \ No newline at end of file diff --git a/tests/data/line/hello12.pdl b/tests/data/line/hello12.pdl index d32d0a979..8cbf1d1e8 100644 --- a/tests/data/line/hello12.pdl +++ b/tests/data/line/hello12.pdl @@ -8,4 +8,4 @@ text: contribute: [] - if: '${ QUESTION }' then: How are you? - spec: bool \ No newline at end of file + spec: boolean \ No newline at end of file diff --git a/tests/data/line/hello13.pdl b/tests/data/line/hello13.pdl index d44f84fcc..5b1b5817c 100644 --- a/tests/data/line/hello13.pdl +++ b/tests/data/line/hello13.pdl @@ -9,6 +9,6 @@ text: - def: I lang: python code: result = ${ I } + 1 - spec: str + spec: string - "\n" until: '${ I == 5 }' diff --git a/tests/data/line/hello14.pdl b/tests/data/line/hello14.pdl index a79a04634..99cc0756e 100644 --- a/tests/data/line/hello14.pdl +++ b/tests/data/line/hello14.pdl @@ -10,9 +10,9 @@ text: mock_response: " World!" - def: translate function: - sentence: str - language: str - spec: int + sentence: string + language: string + spec: integer return: lastOf: - "\nTranslate the sentence '${ sentence }' to ${ language }\n" @@ -23,7 +23,7 @@ text: include_stop_sequence: true mock_response: "Bonjour le monde!" - call: ${ translate } - spec: str + spec: string args: sentence: Hello,${ GEN } language: French \ No newline at end of file diff --git a/tests/data/line/hello16.pdl b/tests/data/line/hello16.pdl index 60ff2b2ff..9f50b954f 100644 --- a/tests/data/line/hello16.pdl +++ b/tests/data/line/hello16.pdl @@ -4,10 +4,10 @@ text: parser: json def: data contribute: [] - spec: { "questions": ["str"], "answers": ["obj"] } + spec: { questions: [string], answers: [object] } - model: watsonx_text/ibm/granite-20b-code-instruct def: model_output - spec: {"bob": int, "carol": str} + spec: {bob: integer, "carol": string} input: text: - for: diff --git a/tests/data/line/hello17.pdl b/tests/data/line/hello17.pdl index c432cea75..815687888 100644 --- a/tests/data/line/hello17.pdl +++ b/tests/data/line/hello17.pdl @@ -1,7 +1,7 @@ description: Hello world showing call out to python code text: - lang: python - spec: int + spec: integer code: | import string result = "hello" diff --git a/tests/data/line/hello19.pdl b/tests/data/line/hello19.pdl index 84801d320..0bd208f11 100644 --- a/tests/data/line/hello19.pdl +++ b/tests/data/line/hello19.pdl @@ -4,7 +4,7 @@ defs: text: - Hello, - model: ${ models } - spec: int + spec: integer parameters: decoding_method: greedy stop: diff --git a/tests/data/line/hello24.pdl b/tests/data/line/hello24.pdl index daa535cfc..facbd95ae 100644 --- a/tests/data/line/hello24.pdl +++ b/tests/data/line/hello24.pdl @@ -10,9 +10,9 @@ text: mock_response: " World!" - def: translate function: - sentence: str - language: str - spec: int + sentence: string + language: string + spec: integer return: lastOf: - "\nTranslate the sentence '${ sentence }' to ${ language }\n" @@ -20,7 +20,7 @@ text: parameters: mock_response: " World!" - call: ${ translate } - spec: str + spec: string args: sentence: Hello,${ GEN1 } language: ${ GEN2 } \ No newline at end of file diff --git a/tests/data/line/hello25.pdl b/tests/data/line/hello25.pdl index fc7e3d000..bbd29de27 100644 --- a/tests/data/line/hello25.pdl +++ b/tests/data/line/hello25.pdl @@ -9,8 +9,8 @@ text: include_stop_sequence: true - def: translate function: - sentence: str - language: str + sentence: string + language: string return: lastOf: - "\nTranslate the sentence '${ sentence1 }' to ${ language }\n" @@ -21,7 +21,7 @@ text: - "\n" include_stop_sequence: true - call: ${ translate } - spec: str + spec: string args: sentence: Hello,${ GEN } language: French \ No newline at end of file diff --git a/tests/data/line/hello26.pdl b/tests/data/line/hello26.pdl index a2d9f49a4..60b9be0fc 100644 --- a/tests/data/line/hello26.pdl +++ b/tests/data/line/hello26.pdl @@ -4,7 +4,7 @@ text: parser: json def: data contribute: [] - spec: { "questions": ["str"], "answers": ["obj"] } + spec: { questions: [string], answers: [object] } - model: watsonx_text/ibm/granite-34b-code-instruct def: model_output input: diff --git a/tests/data/line/hello27.pdl b/tests/data/line/hello27.pdl index 8124e8c5a..7c2c6f7c7 100644 --- a/tests/data/line/hello27.pdl +++ b/tests/data/line/hello27.pdl @@ -4,7 +4,7 @@ text: parser: json def: data contribute: [] - spec: { "questions": ["str"], "answers": ["obj"] } + spec: { questions: [string], answers: [object] } - model: watsonx_text/ibm/granite-34b-code-instruct def: model_output input: diff --git a/tests/data/line/hello3.pdl b/tests/data/line/hello3.pdl index 817e3f9ef..a700903f1 100644 --- a/tests/data/line/hello3.pdl +++ b/tests/data/line/hello3.pdl @@ -4,7 +4,7 @@ defs: text: - Hello, - model: ${ model } - spec: int + spec: integer parameters: temperature: 0 stop: diff --git a/tests/data/line/hello31.pdl b/tests/data/line/hello31.pdl index b84c81879..656bc55a3 100644 --- a/tests/data/line/hello31.pdl +++ b/tests/data/line/hello31.pdl @@ -3,7 +3,7 @@ defs: # ... several other defs, ~85 lines get_current_weather: function: - subject: str + subject: string return: text: hello show_result: false \ No newline at end of file diff --git a/tests/data/line/hello9.pdl b/tests/data/line/hello9.pdl index 4bce271f4..61b7f71af 100644 --- a/tests/data/line/hello9.pdl +++ b/tests/data/line/hello9.pdl @@ -1,7 +1,7 @@ description: Hello world showing call out to python code text: - lang: python - spec: int + spec: integer code: | import string result = "hello" \ No newline at end of file diff --git a/tests/data/optimizer_gsm8k.pdl b/tests/data/optimizer_gsm8k.pdl index 747d0212e..4d3a56849 100644 --- a/tests/data/optimizer_gsm8k.pdl +++ b/tests/data/optimizer_gsm8k.pdl @@ -11,10 +11,10 @@ defs: chain_of_thought: function: - question: str - model: str + question: string + model: string examples: - { list: { obj: { question: str, reasoning: str, answer: str } } } + [ { question: string, reasoning: string, answer: string } ] return: lastOf: - call: ${ cot.fewshot_cot } diff --git a/tests/results/examples/react/react_call.0.result b/tests/results/examples/react/react_call.0.result index 80b4b1789..85f6285b4 100644 --- a/tests/results/examples/react/react_call.0.result +++ b/tests/results/examples/react/react_call.0.result @@ -1,4 +1,4 @@ -{'pdl_context': [], 'react_inner': FunctionBlock(description=None, spec=None, defs={}, def_=None, contribute=[, ], parser=None, fallback=None, role=None, context=[], pdl__id='text.0.import.empty.0.function', pdl__result=None, pdl__location=PdlLocationType(path=['defs', 'react_inner'], file='examples/react/react_fun.pdl', table={"['description']": 1, "['defs']": 2, "['defs', 'react_inner']": 3, "['defs', 'react_inner', 'function']": 4, "['defs', 'react_inner', 'function', 'examples']": 5, "['defs', 'react_inner', 'function', 'question']": 6, "['defs', 'react_inner', 'function', 'model']": 7, "['defs', 'react_inner', 'return']": 8, "['defs', 'react_inner', 'return', 'text']": 9, "['defs', 'react_inner', 'return', 'text', '[0]']": 10, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs']": 10, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools']": 11, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data']": 12, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[0]']": 13, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[0]', 'name']": 13, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[0]', 'description']": 14, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[0]', 'arguments']": 15, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[0]', 'arguments', 'expr']": 16, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[0]', 'arguments', 'expr', 'type']": 17, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[0]', 'arguments', 'expr', 'description']": 18, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[1]']": 19, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[1]', 'name']": 19, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[1]', 'description']": 20, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[1]', 'arguments']": 21, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[1]', 'arguments', 'topic']": 22, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[1]', 'arguments', 'topic', 'type']": 23, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[1]', 'arguments', 'topic', 'description']": 24, "['defs', 'react_inner', 'return', 'text', '[1]']": 25, "['defs', 'react_inner', 'return', 'text', '[1]', 'for']": 25, "['defs', 'react_inner', 'return', 'text', '[1]', 'for', 'ex']": 26, "['defs', 'react_inner', 'return', 'text', '[1]', 'repeat']": 27, "['defs', 'react_inner', 'return', 'text', '[2]']": 29, "['defs', 'react_inner', 'return', 'text', '[3]']": 30, "['defs', 'react_inner', 'return', 'text', '[4]']": 31, "['defs', 'react_inner', 'return', 'text', '[5]']": 32, "['defs', 'react_inner', 'return', 'text', '[5]', 'role']": 32, "['defs', 'react_inner', 'return', 'text', '[5]', 'text']": 33, "['defs', 'react_inner', 'return', 'text', '[5]', 'contribute']": 34, "['defs', 'react_inner', 'return', 'text', '[6]']": 35, "['defs', 'react_inner', 'return', 'text', '[6]', 'role']": 35, "['defs', 'react_inner', 'return', 'text', '[6]', 'text']": 36, "['defs', 'react_inner', 'return', 'text', '[6]', 'contribute']": 37, "['defs', 'react_inner', 'return', 'text', '[7]']": 38, "['defs', 'react_inner', 'return', 'text', '[7]', 'def']": 38, "['defs', 'react_inner', 'return', 'text', '[7]', 'contribute']": 39, "['defs', 'react_inner', 'return', 'text', '[7]', 'data']": 40, "['defs', 'react_inner', 'return', 'text', '[8]']": 41, "['defs', 'react_inner', 'return', 'text', '[8]', 'def']": 41, "['defs', 'react_inner', 'return', 'text', '[8]', 'contribute']": 42, "['defs', 'react_inner', 'return', 'text', '[8]', 'data']": 43, "['defs', 'react_inner', 'return', 'text', '[9]']": 44, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat']": 44, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text']": 45, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[0]']": 46, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[0]', 'def']": 46, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[0]', 'model']": 47, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[0]', 'parameters']": 48, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[0]', 'parameters', 'temperature']": 49, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[0]', 'parameters', 'stop_sequences']": 50, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[1]']": 51, '[\'defs\', \'react_inner\', \'return\', \'text\', \'[9]\', \'repeat\', \'text\', \'[1]\', \'"Action\']': 51, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[2]']": 52, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[2]', 'def']": 52, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[2]', 'model']": 53, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[2]', 'parameters']": 54, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[2]', 'parameters', 'temperature']": 55, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[2]', 'parameters', 'stop_sequences']": 56, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[2]', 'parser']": 57, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]']": 58, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'if']": 58, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then']": 59, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'def']": 60, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'if']": 61, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'then']": 62, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'then', 'text']": 63, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'then', 'text', '[0]']": 64, '[\'defs\', \'react_inner\', \'return\', \'text\', \'[9]\', \'repeat\', \'text\', \'[3]\', \'then\', \'then\', \'text\', \'[0]\', \'"\\\\nObservation\']': 64, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'then', 'text', '[1]']": 65, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'then', 'text', '[1]', 'lang']": 65, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'then', 'text', '[1]', 'code']": 66, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'then', 'text', '[1]', 'code', 'try']": 69, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'then', 'text', '[1]', 'code', 'except wikipedia.WikipediaException as e']": 71, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'then', 'text', '[2]']": 73, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'else']": 74, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'else', 'if']": 75, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'else', 'then']": 76, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'else', 'then', 'text']": 77, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'else', 'then', 'text', '[0]']": 78, '[\'defs\', \'react_inner\', \'return\', \'text\', \'[9]\', \'repeat\', \'text\', \'[3]\', \'then\', \'else\', \'then\', \'text\', \'[0]\', \'"\\\\nObservation\']': 78, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'else', 'then', 'text', '[1]']": 79, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'else', 'then', 'text', '[1]', 'lang']": 79, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'else', 'then', 'text', '[1]', 'code']": 80, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'else', 'then', 'text', '[2]']": 81, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'else']": 82, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'else', 'def']": 83, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'else', 'contribute']": 84, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'else', 'data']": 85, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[4]']": 86, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[4]', 'def']": 86, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[4]', 'contribute']": 87, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[4]', 'data']": 88, "['defs', 'react_inner', 'return', 'text', '[9]', 'until']": 89, "['defs', 'react']": 91, "['defs', 'react', 'function']": 92, "['defs', 'react', 'function', 'question']": 93, "['defs', 'react', 'function', 'model']": 94, "['defs', 'react', 'return']": 95, "['defs', 'react', 'return', 'defs']": 96, "['defs', 'react', 'return', 'defs', 'examples']": 97, "['defs', 'react', 'return', 'defs', 'examples', 'array']": 98, "['defs', 'react', 'return', 'defs', 'examples', 'array', '[0]']": 99, "['defs', 'react', 'return', 'defs', 'examples', 'array', '[0]', 'text']": 99, "['defs', 'react', 'return', 'defs', 'examples', 'array', '[0]', 'text', 'Thought']": 110, "['defs', 'react', 'return', 'defs', 'examples', 'array', '[0]', 'text', 'Action']": 111, '[\'defs\', \'react\', \'return\', \'defs\', \'examples\', \'array\', \'[0]\', \'text\', \'[{"name"\']': 112, "['defs', 'react', 'return', 'defs', 'examples', 'array', '[0]', 'text', 'Observation']": 109, "['defs', 'Thought']": 121, "['defs', 'Action']": 122, '[\'defs\', \'[{"name"\']': 123, "['defs', 'Observation']": 119, "['defs', 'call']": 125, "['defs', 'args']": 126, "['defs', 'args', 'pdl_context']": 127, "['defs', 'args', 'examples']": 128, "['defs', 'args', 'question']": 129, "['defs', 'args', 'model']": 130}), pdl__timing=PdlTiming(start_nanos=1743268261743942000, end_nanos=1743268261744003000, first_use_nanos=0, timezone=''), pdl__is_leaf=True, kind=, function={'examples': ['str'], 'question': 'str', 'model': 'str'}, returns=TextBlock(description=None, spec=None, defs={}, def_=None, contribute=[, ], parser=None, fallback=None, role=None, context=[], pdl__id='text.1.call.call.text', pdl__result=None, pdl__location=PdlLocationType(path=['defs', 'react_inner', 'return'], file='examples/react/react_fun.pdl', table={"['description']": 1, "['text']": 2, "['text', '[0]']": 3, "['text', '[0]', 'import']": 3, "['text', '[0]', 'def']": 4, "['text', '[1]']": 5, "['text', '[1]', 'call']": 5, "['text', '[1]', 'args']": 6, "['text', '[1]', 'args', 'question']": 7, "['text', '[1]', 'args', 'model']": 8}), pdl__timing=PdlTiming(start_nanos=1743268261747530000, end_nanos=1743268269097271000, first_use_nanos=0, timezone=''), pdl__is_leaf=False, kind=, text=[EmptyBlock(description=None, spec=None, defs={'tools': DataBlock(description=None, spec=None, defs={}, def_=None, contribute=[, ], parser=None, fallback=None, role=None, context=[], pdl__id='text.1.call.call.text.0.empty.0.data', pdl__result=None, pdl__location=PdlLocationType(path=['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data'], file='examples/react/react_fun.pdl', table={"['description']": 1, "['text']": 2, "['text', '[0]']": 3, "['text', '[0]', 'import']": 3, "['text', '[0]', 'def']": 4, "['text', '[1]']": 5, "['text', '[1]', 'call']": 5, "['text', '[1]', 'args']": 6, "['text', '[1]', 'args', 'question']": 7, "['text', '[1]', 'args', 'model']": 8}), pdl__timing=PdlTiming(start_nanos=1743268261747571000, end_nanos=1743268261747890000, first_use_nanos=0, timezone=''), pdl__is_leaf=True, kind=, data=[{'name': 'Calc', 'description': 'Calculator function', 'arguments': {'expr': {'type': 'string', 'description': 'Arithmetic expression to calculate'}}}, {'name': 'Search', 'description': 'Wikipedia search', 'arguments': {'topic': {'type': 'string', 'description': 'Topic to search'}}}], raw=False)}, def_=None, contribute=[, ], parser=None, fallback=None, role=None, context=[], pdl__id='text.1.call.call.text.0.empty', pdl__result=None, pdl__location=None, pdl__timing=PdlTiming(start_nanos=1743268261747554000, end_nanos=1743268261747913000, first_use_nanos=0, timezone=''), pdl__is_leaf=True, kind=), RepeatBlock(description=None, spec=None, defs={}, def_=None, contribute=[, ], parser=None, fallback=None, role=None, context=[], pdl__id='text.1.call.call.text.1.repeat', pdl__result=None, pdl__location=PdlLocationType(path=['defs', 'react_inner', 'return', 'text', '[1]'], file='examples/react/react_fun.pdl', table={"['description']": 1, "['text']": 2, "['text', '[0]']": 3, "['text', '[0]', 'import']": 3, "['text', '[0]', 'def']": 4, "['text', '[1]']": 5, "['text', '[1]', 'call']": 5, "['text', '[1]', 'args']": 6, "['text', '[1]', 'args', 'question']": 7, "['text', '[1]', 'args', 'model']": 8}), pdl__timing=PdlTiming(start_nanos=1743268261747930000, end_nanos=1743268261748738000, first_use_nanos=0, timezone=''), pdl__is_leaf=False, kind=, for_={'ex': '${ examples }'}, while_=True, repeat='${ ex }\n', until=False, max_iterations=None, join=JoinText(as_=, with_=''), pdl__trace=None), '\n', '${ question }', '\n', TextBlock(description=None, spec=None, defs={}, def_=None, contribute=[], parser=None, fallback=None, role='system', context=[], pdl__id='text.1.call.call.text.5.text', pdl__result=None, pdl__location=PdlLocationType(path=['defs', 'react_inner', 'return', 'text', '[5]'], file='examples/react/react_fun.pdl', table={"['description']": 1, "['text']": 2, "['text', '[0]']": 3, "['text', '[0]', 'import']": 3, "['text', '[0]', 'def']": 4, "['text', '[1]']": 5, "['text', '[1]', 'call']": 5, "['text', '[1]', 'args']": 6, "['text', '[1]', 'args', 'question']": 7, "['text', '[1]', 'args', 'model']": 8}), pdl__timing=PdlTiming(start_nanos=1743268261749504000, end_nanos=1743268261749584000, first_use_nanos=0, timezone=''), pdl__is_leaf=False, kind=, text="You are Granite, developed by IBM. You are a helpful AI assistant with access to the following tools. When a tool is required to answer the user's query, respond with <|tool_call|> followed by a JSON list of tools used. If a tool does not exist in the provided list of tools, notify the user that you do not have the ability to fulfill the request."), TextBlock(description=None, spec=None, defs={}, def_=None, contribute=[], parser=None, fallback=None, role='tools', context=[], pdl__id='text.1.call.call.text.6.text', pdl__result=None, pdl__location=PdlLocationType(path=['defs', 'react_inner', 'return', 'text', '[6]'], file='examples/react/react_fun.pdl', table={"['description']": 1, "['text']": 2, "['text', '[0]']": 3, "['text', '[0]', 'import']": 3, "['text', '[0]', 'def']": 4, "['text', '[1]']": 5, "['text', '[1]', 'call']": 5, "['text', '[1]', 'args']": 6, "['text', '[1]', 'args', 'question']": 7, "['text', '[1]', 'args', 'model']": 8}), pdl__timing=PdlTiming(start_nanos=1743268261749599000, end_nanos=1743268261749888000, first_use_nanos=0, timezone=''), pdl__is_leaf=False, kind=, text='${ tools }'), DataBlock(description=None, spec=None, defs={}, def_='prev_action', contribute=[], parser=None, fallback=None, role=None, context=[], pdl__id='text.1.call.call.text.7.data', pdl__result=None, pdl__location=PdlLocationType(path=['defs', 'react_inner', 'return', 'text', '[7]', 'data'], file='examples/react/react_fun.pdl', table={"['description']": 1, "['text']": 2, "['text', '[0]']": 3, "['text', '[0]', 'import']": 3, "['text', '[0]', 'def']": 4, "['text', '[1]']": 5, "['text', '[1]', 'call']": 5, "['text', '[1]', 'args']": 6, "['text', '[1]', 'args', 'question']": 7, "['text', '[1]', 'args', 'model']": 8}), pdl__timing=PdlTiming(start_nanos=1743268261749905000, end_nanos=1743268261749978000, first_use_nanos=0, timezone=''), pdl__is_leaf=True, kind=, data='none', raw=False), DataBlock(description=None, spec=None, defs={}, def_='exit', contribute=[], parser=None, fallback=None, role=None, context=[], pdl__id='text.1.call.call.text.8.data', pdl__result=None, pdl__location=PdlLocationType(path=['defs', 'react_inner', 'return', 'text', '[8]', 'data'], file='examples/react/react_fun.pdl', table={"['description']": 1, "['text']": 2, "['text', '[0]']": 3, "['text', '[0]', 'import']": 3, "['text', '[0]', 'def']": 4, "['text', '[1]']": 5, "['text', '[1]', 'call']": 5, "['text', '[1]', 'args']": 6, "['text', '[1]', 'args', 'question']": 7, "['text', '[1]', 'args', 'model']": 8}), pdl__timing=PdlTiming(start_nanos=1743268261749992000, end_nanos=1743268261750018000, first_use_nanos=0, timezone=''), pdl__is_leaf=True, kind=, data=False, raw=False), RepeatBlock(description=None, spec=None, defs={}, def_=None, contribute=[, ], parser=None, fallback=None, role=None, context=[], pdl__id='text.1.call.call.text.9.repeat', pdl__result=None, pdl__location=PdlLocationType(path=['defs', 'react_inner', 'return', 'text', '[9]'], file='examples/react/react_fun.pdl', table={"['description']": 1, "['text']": 2, "['text', '[0]']": 3, "['text', '[0]', 'import']": 3, "['text', '[0]', 'def']": 4, "['text', '[1]']": 5, "['text', '[1]', 'call']": 5, "['text', '[1]', 'args']": 6, "['text', '[1]', 'args', 'question']": 7, "['text', '[1]', 'args', 'model']": 8}), pdl__timing=PdlTiming(start_nanos=1743268261750031000, end_nanos=1743268269097254000, first_use_nanos=0, timezone=''), pdl__is_leaf=False, kind=, for_=None, while_=True, repeat=TextBlock(description=None, spec=None, defs={}, def_=None, contribute=[, ], parser=None, fallback=None, role=None, context=[], pdl__id='text.1.call.call.text.9.repeat.0.text', pdl__result=None, pdl__location=PdlLocationType(path=['defs', 'react_inner', 'return', 'text', '[9]', 'repeat'], file='examples/react/react_fun.pdl', table={"['description']": 1, "['text']": 2, "['text', '[0]']": 3, "['text', '[0]', 'import']": 3, "['text', '[0]', 'def']": 4, "['text', '[1]']": 5, "['text', '[1]', 'call']": 5, "['text', '[1]', 'args']": 6, "['text', '[1]', 'args', 'question']": 7, "['text', '[1]', 'args', 'model']": 8}), pdl__timing=PdlTiming(start_nanos=1743268261750053000, end_nanos=1743268269096538000, first_use_nanos=0, timezone=''), pdl__is_leaf=False, kind=, text=[LitellmModelBlock(description=None, spec=None, defs={}, def_='thought', contribute=[, ], parser=None, fallback=None, role=None, context=[], pdl__id='text.1.call.call.text.9.repeat.0.text.0.model', pdl__result=None, pdl__location=PdlLocationType(path=['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[0]'], file='examples/react/react_fun.pdl', table={"['description']": 1, "['text']": 2, "['text', '[0]']": 3, "['text', '[0]', 'import']": 3, "['text', '[0]', 'def']": 4, "['text', '[1]']": 5, "['text', '[1]', 'call']": 5, "['text', '[1]', 'args']": 6, "['text', '[1]', 'args', 'question']": 7, "['text', '[1]', 'args', 'model']": 8}), pdl__timing=PdlTiming(start_nanos=1743268261750085000, end_nanos=1743268268250432000, first_use_nanos=0, timezone=''), pdl__is_leaf=True, kind=, model='${ model }', input='${ pdl_context }', modelResponse=None, pdl__usage=None, pdl__model_input=None, platform=, parameters=LitellmParameters(timeout=None, temperature=0.0, top_p=None, n=None, stop=None, max_tokens=None, presence_penalty=None, frequency_penalty=None, logit_bias=None, user=None, response_format=None, seed=None, tools=None, tool_choice=None, logprobs=None, top_logprobs=None, parallel_tool_calls=None, extra_headers=None, functions=None, function_call=None, base_url=None, api_version=None, api_key=None, model_list=None, mock_response=None, custom_llm_provider=None, max_retries=None, stop_sequences='Action:')), 'Action:\n', LitellmModelBlock(description=None, spec=None, defs={}, def_='action', contribute=[, ], parser='json', fallback=None, role=None, context=[], pdl__id='text.1.call.call.text.9.repeat.0.text.2.model', pdl__result=None, pdl__location=PdlLocationType(path=['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[2]'], file='examples/react/react_fun.pdl', table={"['description']": 1, "['text']": 2, "['text', '[0]']": 3, "['text', '[0]', 'import']": 3, "['text', '[0]', 'def']": 4, "['text', '[1]']": 5, "['text', '[1]', 'call']": 5, "['text', '[1]', 'args']": 6, "['text', '[1]', 'args', 'question']": 7, "['text', '[1]', 'args', 'model']": 8}), pdl__timing=PdlTiming(start_nanos=1743268268250595000, end_nanos=1743268269093080000, first_use_nanos=0, timezone=''), pdl__is_leaf=True, kind=, model='${ model }', input='${ pdl_context }', modelResponse=None, pdl__usage=None, pdl__model_input=None, platform=, parameters=LitellmParameters(timeout=None, temperature=0.0, top_p=None, n=None, stop=None, max_tokens=None, presence_penalty=None, frequency_penalty=None, logit_bias=None, user=None, response_format=None, seed=None, tools=None, tool_choice=None, logprobs=None, top_logprobs=None, parallel_tool_calls=None, extra_headers=None, functions=None, function_call=None, base_url=None, api_version=None, api_key=None, model_list=None, mock_response=None, custom_llm_provider=None, max_retries=None, stop_sequences='\n')), IfBlock(description=None, spec=None, defs={}, def_=None, contribute=[, ], parser=None, fallback=None, role=None, context=[], pdl__id='text.1.call.call.text.9.repeat.0.text.3.if', pdl__result=None, pdl__location=PdlLocationType(path=['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]'], file='examples/react/react_fun.pdl', table={"['description']": 1, "['text']": 2, "['text', '[0]']": 3, "['text', '[0]', 'import']": 3, "['text', '[0]', 'def']": 4, "['text', '[1]']": 5, "['text', '[1]', 'call']": 5, "['text', '[1]', 'args']": 6, "['text', '[1]', 'args', 'question']": 7, "['text', '[1]', 'args', 'model']": 8}), pdl__timing=PdlTiming(start_nanos=1743268269093158000, end_nanos=1743268269096208000, first_use_nanos=0, timezone=''), pdl__is_leaf=False, kind=, condition='${ action != prev_action}', then=IfBlock(description=None, spec=None, defs={}, def_='observation', contribute=[, ], parser=None, fallback=None, role=None, context=[], pdl__id='text.1.call.call.text.9.repeat.0.text.3.if.0.if', pdl__result=None, pdl__location=PdlLocationType(path=['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then'], file='examples/react/react_fun.pdl', table={"['description']": 1, "['text']": 2, "['text', '[0]']": 3, "['text', '[0]', 'import']": 3, "['text', '[0]', 'def']": 4, "['text', '[1]']": 5, "['text', '[1]', 'call']": 5, "['text', '[1]', 'args']": 6, "['text', '[1]', 'args', 'question']": 7, "['text', '[1]', 'args', 'model']": 8}), pdl__timing=PdlTiming(start_nanos=1743268269094033000, end_nanos=1743268269096197000, first_use_nanos=0, timezone=''), pdl__is_leaf=False, kind=, condition='${ action[0].name == "Search" }', then=TextBlock(description=None, spec=None, defs={}, def_=None, contribute=[, ], parser=None, fallback=None, role=None, context=[], pdl__id='', pdl__result=None, pdl__location=None, pdl__timing=None, pdl__is_leaf=False, kind=, text=['\nObservation: ', CodeBlock(description=None, spec=None, defs={}, def_=None, contribute=[, ], parser=None, fallback=None, role=None, context=[], pdl__id='', pdl__result=None, pdl__location=None, pdl__timing=None, pdl__is_leaf=True, kind=, lang='python', code='import warnings, wikipedia\nwarnings.simplefilter("ignore")\ntry:\n result = wikipedia.summary("${ action[0].arguments.topic }")\nexcept wikipedia.WikipediaException as e:\n result = str(e)\n'), '\n']), else_=IfBlock(description=None, spec=None, defs={}, def_=None, contribute=[, ], parser=None, fallback=None, role=None, context=[], pdl__id='text.1.call.call.text.9.repeat.0.text.3.if.0.if.0.if', pdl__result=None, pdl__location=PdlLocationType(path=['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'else'], file='examples/react/react_fun.pdl', table={"['description']": 1, "['text']": 2, "['text', '[0]']": 3, "['text', '[0]', 'import']": 3, "['text', '[0]', 'def']": 4, "['text', '[1]']": 5, "['text', '[1]', 'call']": 5, "['text', '[1]', 'args']": 6, "['text', '[1]', 'args', 'question']": 7, "['text', '[1]', 'args', 'model']": 8}), pdl__timing=PdlTiming(start_nanos=1743268269094841000, end_nanos=1743268269096179000, first_use_nanos=0, timezone=''), pdl__is_leaf=False, kind=, condition='${ action[0].name == "Calc" }', then=TextBlock(description=None, spec=None, defs={}, def_=None, contribute=[, ], parser=None, fallback=None, role=None, context=[], pdl__id='', pdl__result=None, pdl__location=None, pdl__timing=None, pdl__is_leaf=False, kind=, text=['\nObservation: ', CodeBlock(description=None, spec=None, defs={}, def_=None, contribute=[, ], parser=None, fallback=None, role=None, context=[], pdl__id='', pdl__result=None, pdl__location=None, pdl__timing=None, pdl__is_leaf=True, kind=, lang='python', code='result = ${ action[0].arguments.expr }'), '\n']), else_=None, if_result=None), if_result=None), else_=DataBlock(description=None, spec=None, defs={}, def_='exit', contribute=[], parser=None, fallback=None, role=None, context=[], pdl__id='', pdl__result=None, pdl__location=None, pdl__timing=None, pdl__is_leaf=True, kind=, data=True, raw=False), if_result=None), DataBlock(description=None, spec=None, defs={}, def_='prev_action', contribute=[], parser=None, fallback=None, role=None, context=[], pdl__id='text.1.call.call.text.9.repeat.0.text.4.data', pdl__result=None, pdl__location=PdlLocationType(path=['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[4]', 'data'], file='examples/react/react_fun.pdl', table={"['description']": 1, "['text']": 2, "['text', '[0]']": 3, "['text', '[0]', 'import']": 3, "['text', '[0]', 'def']": 4, "['text', '[1]']": 5, "['text', '[1]', 'call']": 5, "['text', '[1]', 'args']": 6, "['text', '[1]', 'args', 'question']": 7, "['text', '[1]', 'args', 'model']": 8}), pdl__timing=PdlTiming(start_nanos=1743268269096231000, end_nanos=1743268269096499000, first_use_nanos=0, timezone=''), pdl__is_leaf=True, kind=, data='${ action }', raw=False)]), until='${ action[0].name == "Finish" or exit }', max_iterations=None, join=JoinText(as_=, with_=''), pdl__trace=None)])), 'react': FunctionBlock(description=None, spec=None, defs={}, def_=None, contribute=[, ], parser=None, fallback=None, role=None, context=[], pdl__id='text.0.import.empty.1.function', pdl__result=None, pdl__location=PdlLocationType(path=['defs', 'react'], file='examples/react/react_fun.pdl', table={"['description']": 1, "['defs']": 2, "['defs', 'react_inner']": 3, "['defs', 'react_inner', 'function']": 4, "['defs', 'react_inner', 'function', 'examples']": 5, "['defs', 'react_inner', 'function', 'question']": 6, "['defs', 'react_inner', 'function', 'model']": 7, "['defs', 'react_inner', 'return']": 8, "['defs', 'react_inner', 'return', 'text']": 9, "['defs', 'react_inner', 'return', 'text', '[0]']": 10, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs']": 10, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools']": 11, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data']": 12, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[0]']": 13, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[0]', 'name']": 13, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[0]', 'description']": 14, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[0]', 'arguments']": 15, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[0]', 'arguments', 'expr']": 16, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[0]', 'arguments', 'expr', 'type']": 17, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[0]', 'arguments', 'expr', 'description']": 18, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[1]']": 19, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[1]', 'name']": 19, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[1]', 'description']": 20, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[1]', 'arguments']": 21, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[1]', 'arguments', 'topic']": 22, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[1]', 'arguments', 'topic', 'type']": 23, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[1]', 'arguments', 'topic', 'description']": 24, "['defs', 'react_inner', 'return', 'text', '[1]']": 25, "['defs', 'react_inner', 'return', 'text', '[1]', 'for']": 25, "['defs', 'react_inner', 'return', 'text', '[1]', 'for', 'ex']": 26, "['defs', 'react_inner', 'return', 'text', '[1]', 'repeat']": 27, "['defs', 'react_inner', 'return', 'text', '[2]']": 29, "['defs', 'react_inner', 'return', 'text', '[3]']": 30, "['defs', 'react_inner', 'return', 'text', '[4]']": 31, "['defs', 'react_inner', 'return', 'text', '[5]']": 32, "['defs', 'react_inner', 'return', 'text', '[5]', 'role']": 32, "['defs', 'react_inner', 'return', 'text', '[5]', 'text']": 33, "['defs', 'react_inner', 'return', 'text', '[5]', 'contribute']": 34, "['defs', 'react_inner', 'return', 'text', '[6]']": 35, "['defs', 'react_inner', 'return', 'text', '[6]', 'role']": 35, "['defs', 'react_inner', 'return', 'text', '[6]', 'text']": 36, "['defs', 'react_inner', 'return', 'text', '[6]', 'contribute']": 37, "['defs', 'react_inner', 'return', 'text', '[7]']": 38, "['defs', 'react_inner', 'return', 'text', '[7]', 'def']": 38, "['defs', 'react_inner', 'return', 'text', '[7]', 'contribute']": 39, "['defs', 'react_inner', 'return', 'text', '[7]', 'data']": 40, "['defs', 'react_inner', 'return', 'text', '[8]']": 41, "['defs', 'react_inner', 'return', 'text', '[8]', 'def']": 41, "['defs', 'react_inner', 'return', 'text', '[8]', 'contribute']": 42, "['defs', 'react_inner', 'return', 'text', '[8]', 'data']": 43, "['defs', 'react_inner', 'return', 'text', '[9]']": 44, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat']": 44, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text']": 45, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[0]']": 46, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[0]', 'def']": 46, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[0]', 'model']": 47, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[0]', 'parameters']": 48, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[0]', 'parameters', 'temperature']": 49, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[0]', 'parameters', 'stop_sequences']": 50, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[1]']": 51, '[\'defs\', \'react_inner\', \'return\', \'text\', \'[9]\', \'repeat\', \'text\', \'[1]\', \'"Action\']': 51, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[2]']": 52, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[2]', 'def']": 52, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[2]', 'model']": 53, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[2]', 'parameters']": 54, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[2]', 'parameters', 'temperature']": 55, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[2]', 'parameters', 'stop_sequences']": 56, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[2]', 'parser']": 57, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]']": 58, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'if']": 58, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then']": 59, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'def']": 60, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'if']": 61, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'then']": 62, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'then', 'text']": 63, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'then', 'text', '[0]']": 64, '[\'defs\', \'react_inner\', \'return\', \'text\', \'[9]\', \'repeat\', \'text\', \'[3]\', \'then\', \'then\', \'text\', \'[0]\', \'"\\\\nObservation\']': 64, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'then', 'text', '[1]']": 65, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'then', 'text', '[1]', 'lang']": 65, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'then', 'text', '[1]', 'code']": 66, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'then', 'text', '[1]', 'code', 'try']": 69, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'then', 'text', '[1]', 'code', 'except wikipedia.WikipediaException as e']": 71, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'then', 'text', '[2]']": 73, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'else']": 74, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'else', 'if']": 75, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'else', 'then']": 76, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'else', 'then', 'text']": 77, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'else', 'then', 'text', '[0]']": 78, '[\'defs\', \'react_inner\', \'return\', \'text\', \'[9]\', \'repeat\', \'text\', \'[3]\', \'then\', \'else\', \'then\', \'text\', \'[0]\', \'"\\\\nObservation\']': 78, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'else', 'then', 'text', '[1]']": 79, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'else', 'then', 'text', '[1]', 'lang']": 79, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'else', 'then', 'text', '[1]', 'code']": 80, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'else', 'then', 'text', '[2]']": 81, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'else']": 82, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'else', 'def']": 83, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'else', 'contribute']": 84, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'else', 'data']": 85, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[4]']": 86, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[4]', 'def']": 86, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[4]', 'contribute']": 87, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[4]', 'data']": 88, "['defs', 'react_inner', 'return', 'text', '[9]', 'until']": 89, "['defs', 'react']": 91, "['defs', 'react', 'function']": 92, "['defs', 'react', 'function', 'question']": 93, "['defs', 'react', 'function', 'model']": 94, "['defs', 'react', 'return']": 95, "['defs', 'react', 'return', 'defs']": 96, "['defs', 'react', 'return', 'defs', 'examples']": 97, "['defs', 'react', 'return', 'defs', 'examples', 'array']": 98, "['defs', 'react', 'return', 'defs', 'examples', 'array', '[0]']": 99, "['defs', 'react', 'return', 'defs', 'examples', 'array', '[0]', 'text']": 99, "['defs', 'react', 'return', 'defs', 'examples', 'array', '[0]', 'text', 'Thought']": 110, "['defs', 'react', 'return', 'defs', 'examples', 'array', '[0]', 'text', 'Action']": 111, '[\'defs\', \'react\', \'return\', \'defs\', \'examples\', \'array\', \'[0]\', \'text\', \'[{"name"\']': 112, "['defs', 'react', 'return', 'defs', 'examples', 'array', '[0]', 'text', 'Observation']": 109, "['defs', 'Thought']": 121, "['defs', 'Action']": 122, '[\'defs\', \'[{"name"\']': 123, "['defs', 'Observation']": 119, "['defs', 'call']": 125, "['defs', 'args']": 126, "['defs', 'args', 'pdl_context']": 127, "['defs', 'args', 'examples']": 128, "['defs', 'args', 'question']": 129, "['defs', 'args', 'model']": 130}), pdl__timing=PdlTiming(start_nanos=1743268261744034000, end_nanos=1743268261744053000, first_use_nanos=0, timezone=''), pdl__is_leaf=True, kind=, function={'question': 'str', 'model': 'str'}, returns=CallBlock(description=None, spec=None, defs={'examples': ArrayBlock(description=None, spec=None, defs={}, def_=None, contribute=[, ], parser=None, fallback=None, role=None, context=[], pdl__id='text.1.call.call.0.array', pdl__result=None, pdl__location=PdlLocationType(path=['defs', 'react', 'return', 'defs', 'examples'], file='examples/react/react_fun.pdl', table={"['description']": 1, "['text']": 2, "['text', '[0]']": 3, "['text', '[0]', 'import']": 3, "['text', '[0]', 'def']": 4, "['text', '[1]']": 5, "['text', '[1]', 'call']": 5, "['text', '[1]', 'args']": 6, "['text', '[1]', 'args', 'question']": 7, "['text', '[1]', 'args', 'model']": 8}), pdl__timing=PdlTiming(start_nanos=1743268261745357000, end_nanos=1743268261745593000, first_use_nanos=0, timezone=''), pdl__is_leaf=False, kind=, array=[TextBlock(description=None, spec=None, defs={}, def_=None, contribute=[, ], parser=None, fallback=None, role=None, context=[], pdl__id='text.1.call.call.0.array.0.text', pdl__result=None, pdl__location=PdlLocationType(path=['defs', 'react', 'return', 'defs', 'examples', 'array', '[0]'], file='examples/react/react_fun.pdl', table={"['description']": 1, "['text']": 2, "['text', '[0]']": 3, "['text', '[0]', 'import']": 3, "['text', '[0]', 'def']": 4, "['text', '[1]']": 5, "['text', '[1]', 'call']": 5, "['text', '[1]', 'args']": 6, "['text', '[1]', 'args', 'question']": 7, "['text', '[1]', 'args', 'model']": 8}), pdl__timing=PdlTiming(start_nanos=1743268261745395000, end_nanos=1743268261745582000, first_use_nanos=0, timezone=''), pdl__is_leaf=False, kind=, text='What profession does Nicholas Ray and Elia Kazan have in common?\nThought: I need to search Nicholas Ray and Elia Kazan, find their professions, then find the profession they have in common.\nAction:\n[{"name": "Search", "arguments": {"topic": "Nicholas Ray"}}]\nObservation: Nicholas Ray (born Raymond Nicholas Kienzle Jr., August 7, 1911 - June 16, 1979) was an American film director, screenwriter, and actor best known for the 1955 film Rebel Without a Cause.\nThought: Professions of Nicholas Ray are director, screenwriter, and actor. I need to search Elia Kazan next and find his professions.\nAction:\n[{"name": "Search", "arguments": {"topic": "Elia Kazan"}}]\nObservation: Elia Kazan was an American film and theatre director, producer, screenwriter and actor.\nThought: Professions of Elia Kazan are director, producer, screenwriter, and actor. So profession Nicholas Ray and Elia Kazan have in common is director, screenwriter, and actor.\nAction:\n[{"name": "Finish", "arguments": {"topic": "director, screenwriter, actor"}}]\n\n\nWhat is the elevation range for the area that the eastern sector of the Colorado orogeny extends into?\nThought: I need to search Colorado orogeny, find the area that the eastern sector of the Colorado ...\nAction:\n[{"name": "Search", "arguments": {"topic": "Colorado orogeny"}}]\nObservation: The Colorado orogeny was an episode of mountain building (an orogeny) ...\nThought: It does not mention the eastern sector. So I need to look up eastern sector.\nThought: High Plains rise in elevation from around 1,800 to 7,000 ft, so the answer is 1,800 to 7,000 ft.\nAction:\n[{"name": "Finish", "arguments": {"topic": "1,800 to 7,000 ft"}}]\n')])}, def_=None, contribute=[, ], parser=None, fallback=None, role=None, context=[], pdl__id='text.1.call.call', pdl__result=None, pdl__location=None, pdl__timing=PdlTiming(start_nanos=1743268261745340000, end_nanos=1743268269097286000, first_use_nanos=0, timezone=''), pdl__is_leaf=True, kind=, call='${ react_inner }', args={'pdl_context': [], 'examples': '${ examples }', 'question': '${ question }', 'model': '${ model }'}, pdl__trace=None))}What profession does Nicholas Ray and Elia Kazan have in common? +{'pdl_context': [], 'react_inner': FunctionBlock(description=None, spec=None, defs={}, def_=None, contribute=[, ], parser=None, fallback=None, role=None, context=[], pdl__id='text.0.import.empty.0.function', pdl__result=None, pdl__location=PdlLocationType(path=['defs', 'react_inner'], file='examples/react/react_fun.pdl', table={"['description']": 1, "['defs']": 2, "['defs', 'react_inner']": 3, "['defs', 'react_inner', 'function']": 4, "['defs', 'react_inner', 'function', 'examples']": 5, "['defs', 'react_inner', 'function', 'question']": 6, "['defs', 'react_inner', 'function', 'model']": 7, "['defs', 'react_inner', 'return']": 8, "['defs', 'react_inner', 'return', 'text']": 9, "['defs', 'react_inner', 'return', 'text', '[0]']": 10, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs']": 10, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools']": 11, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data']": 12, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[0]']": 13, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[0]', 'name']": 13, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[0]', 'description']": 14, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[0]', 'arguments']": 15, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[0]', 'arguments', 'expr']": 16, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[0]', 'arguments', 'expr', 'type']": 17, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[0]', 'arguments', 'expr', 'description']": 18, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[1]']": 19, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[1]', 'name']": 19, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[1]', 'description']": 20, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[1]', 'arguments']": 21, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[1]', 'arguments', 'topic']": 22, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[1]', 'arguments', 'topic', 'type']": 23, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[1]', 'arguments', 'topic', 'description']": 24, "['defs', 'react_inner', 'return', 'text', '[1]']": 25, "['defs', 'react_inner', 'return', 'text', '[1]', 'for']": 25, "['defs', 'react_inner', 'return', 'text', '[1]', 'for', 'ex']": 26, "['defs', 'react_inner', 'return', 'text', '[1]', 'repeat']": 27, "['defs', 'react_inner', 'return', 'text', '[2]']": 29, "['defs', 'react_inner', 'return', 'text', '[3]']": 30, "['defs', 'react_inner', 'return', 'text', '[4]']": 31, "['defs', 'react_inner', 'return', 'text', '[5]']": 32, "['defs', 'react_inner', 'return', 'text', '[5]', 'role']": 32, "['defs', 'react_inner', 'return', 'text', '[5]', 'text']": 33, "['defs', 'react_inner', 'return', 'text', '[5]', 'contribute']": 34, "['defs', 'react_inner', 'return', 'text', '[6]']": 35, "['defs', 'react_inner', 'return', 'text', '[6]', 'role']": 35, "['defs', 'react_inner', 'return', 'text', '[6]', 'text']": 36, "['defs', 'react_inner', 'return', 'text', '[6]', 'contribute']": 37, "['defs', 'react_inner', 'return', 'text', '[7]']": 38, "['defs', 'react_inner', 'return', 'text', '[7]', 'def']": 38, "['defs', 'react_inner', 'return', 'text', '[7]', 'contribute']": 39, "['defs', 'react_inner', 'return', 'text', '[7]', 'data']": 40, "['defs', 'react_inner', 'return', 'text', '[8]']": 41, "['defs', 'react_inner', 'return', 'text', '[8]', 'def']": 41, "['defs', 'react_inner', 'return', 'text', '[8]', 'contribute']": 42, "['defs', 'react_inner', 'return', 'text', '[8]', 'data']": 43, "['defs', 'react_inner', 'return', 'text', '[9]']": 44, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat']": 44, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text']": 45, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[0]']": 46, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[0]', 'def']": 46, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[0]', 'model']": 47, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[0]', 'parameters']": 48, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[0]', 'parameters', 'temperature']": 49, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[0]', 'parameters', 'stop_sequences']": 50, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[1]']": 51, '[\'defs\', \'react_inner\', \'return\', \'text\', \'[9]\', \'repeat\', \'text\', \'[1]\', \'"Action\']': 51, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[2]']": 52, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[2]', 'def']": 52, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[2]', 'model']": 53, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[2]', 'parameters']": 54, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[2]', 'parameters', 'temperature']": 55, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[2]', 'parameters', 'stop_sequences']": 56, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[2]', 'parser']": 57, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]']": 58, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'if']": 58, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then']": 59, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'def']": 60, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'if']": 61, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'then']": 62, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'then', 'text']": 63, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'then', 'text', '[0]']": 64, '[\'defs\', \'react_inner\', \'return\', \'text\', \'[9]\', \'repeat\', \'text\', \'[3]\', \'then\', \'then\', \'text\', \'[0]\', \'"\\\\nObservation\']': 64, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'then', 'text', '[1]']": 65, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'then', 'text', '[1]', 'lang']": 65, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'then', 'text', '[1]', 'code']": 66, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'then', 'text', '[1]', 'code', 'try']": 69, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'then', 'text', '[1]', 'code', 'except wikipedia.WikipediaException as e']": 71, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'then', 'text', '[2]']": 73, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'else']": 74, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'else', 'if']": 75, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'else', 'then']": 76, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'else', 'then', 'text']": 77, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'else', 'then', 'text', '[0]']": 78, '[\'defs\', \'react_inner\', \'return\', \'text\', \'[9]\', \'repeat\', \'text\', \'[3]\', \'then\', \'else\', \'then\', \'text\', \'[0]\', \'"\\\\nObservation\']': 78, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'else', 'then', 'text', '[1]']": 79, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'else', 'then', 'text', '[1]', 'lang']": 79, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'else', 'then', 'text', '[1]', 'code']": 80, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'else', 'then', 'text', '[2]']": 81, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'else']": 82, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'else', 'def']": 83, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'else', 'contribute']": 84, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'else', 'data']": 85, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[4]']": 86, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[4]', 'def']": 86, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[4]', 'contribute']": 87, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[4]', 'data']": 88, "['defs', 'react_inner', 'return', 'text', '[9]', 'until']": 89, "['defs', 'react']": 91, "['defs', 'react', 'function']": 92, "['defs', 'react', 'function', 'question']": 93, "['defs', 'react', 'function', 'model']": 94, "['defs', 'react', 'return']": 95, "['defs', 'react', 'return', 'defs']": 96, "['defs', 'react', 'return', 'defs', 'examples']": 97, "['defs', 'react', 'return', 'defs', 'examples', 'array']": 98, "['defs', 'react', 'return', 'defs', 'examples', 'array', '[0]']": 99, "['defs', 'react', 'return', 'defs', 'examples', 'array', '[0]', 'text']": 99, "['defs', 'react', 'return', 'defs', 'examples', 'array', '[0]', 'text', 'Thought']": 110, "['defs', 'react', 'return', 'defs', 'examples', 'array', '[0]', 'text', 'Action']": 111, '[\'defs\', \'react\', \'return\', \'defs\', \'examples\', \'array\', \'[0]\', \'text\', \'[{"name"\']': 112, "['defs', 'react', 'return', 'defs', 'examples', 'array', '[0]', 'text', 'Observation']": 109, "['defs', 'Thought']": 121, "['defs', 'Action']": 122, '[\'defs\', \'[{"name"\']': 123, "['defs', 'Observation']": 119, "['defs', 'call']": 125, "['defs', 'args']": 126, "['defs', 'args', 'pdl_context']": 127, "['defs', 'args', 'examples']": 128, "['defs', 'args', 'question']": 129, "['defs', 'args', 'model']": 130}), pdl__timing=PdlTiming(start_nanos=1743268261743942000, end_nanos=1743268261744003000, first_use_nanos=0, timezone=''), pdl__is_leaf=True, kind=, function={'examples': ['string'], 'question': 'string', 'model': 'string'}, returns=TextBlock(description=None, spec=None, defs={}, def_=None, contribute=[, ], parser=None, fallback=None, role=None, context=[], pdl__id='text.1.call.call.text', pdl__result=None, pdl__location=PdlLocationType(path=['defs', 'react_inner', 'return'], file='examples/react/react_fun.pdl', table={"['description']": 1, "['text']": 2, "['text', '[0]']": 3, "['text', '[0]', 'import']": 3, "['text', '[0]', 'def']": 4, "['text', '[1]']": 5, "['text', '[1]', 'call']": 5, "['text', '[1]', 'args']": 6, "['text', '[1]', 'args', 'question']": 7, "['text', '[1]', 'args', 'model']": 8}), pdl__timing=PdlTiming(start_nanos=1743268261747530000, end_nanos=1743268269097271000, first_use_nanos=0, timezone=''), pdl__is_leaf=False, kind=, text=[EmptyBlock(description=None, spec=None, defs={'tools': DataBlock(description=None, spec=None, defs={}, def_=None, contribute=[, ], parser=None, fallback=None, role=None, context=[], pdl__id='text.1.call.call.text.0.empty.0.data', pdl__result=None, pdl__location=PdlLocationType(path=['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data'], file='examples/react/react_fun.pdl', table={"['description']": 1, "['text']": 2, "['text', '[0]']": 3, "['text', '[0]', 'import']": 3, "['text', '[0]', 'def']": 4, "['text', '[1]']": 5, "['text', '[1]', 'call']": 5, "['text', '[1]', 'args']": 6, "['text', '[1]', 'args', 'question']": 7, "['text', '[1]', 'args', 'model']": 8}), pdl__timing=PdlTiming(start_nanos=1743268261747571000, end_nanos=1743268261747890000, first_use_nanos=0, timezone=''), pdl__is_leaf=True, kind=, data=[{'name': 'Calc', 'description': 'Calculator function', 'arguments': {'expr': {'type': 'string', 'description': 'Arithmetic expression to calculate'}}}, {'name': 'Search', 'description': 'Wikipedia search', 'arguments': {'topic': {'type': 'string', 'description': 'Topic to search'}}}], raw=False)}, def_=None, contribute=[, ], parser=None, fallback=None, role=None, context=[], pdl__id='text.1.call.call.text.0.empty', pdl__result=None, pdl__location=None, pdl__timing=PdlTiming(start_nanos=1743268261747554000, end_nanos=1743268261747913000, first_use_nanos=0, timezone=''), pdl__is_leaf=True, kind=), RepeatBlock(description=None, spec=None, defs={}, def_=None, contribute=[, ], parser=None, fallback=None, role=None, context=[], pdl__id='text.1.call.call.text.1.repeat', pdl__result=None, pdl__location=PdlLocationType(path=['defs', 'react_inner', 'return', 'text', '[1]'], file='examples/react/react_fun.pdl', table={"['description']": 1, "['text']": 2, "['text', '[0]']": 3, "['text', '[0]', 'import']": 3, "['text', '[0]', 'def']": 4, "['text', '[1]']": 5, "['text', '[1]', 'call']": 5, "['text', '[1]', 'args']": 6, "['text', '[1]', 'args', 'question']": 7, "['text', '[1]', 'args', 'model']": 8}), pdl__timing=PdlTiming(start_nanos=1743268261747930000, end_nanos=1743268261748738000, first_use_nanos=0, timezone=''), pdl__is_leaf=False, kind=, for_={'ex': '${ examples }'}, while_=True, repeat='${ ex }\n', until=False, max_iterations=None, join=JoinText(as_=, with_=''), pdl__trace=None), '\n', '${ question }', '\n', TextBlock(description=None, spec=None, defs={}, def_=None, contribute=[], parser=None, fallback=None, role='system', context=[], pdl__id='text.1.call.call.text.5.text', pdl__result=None, pdl__location=PdlLocationType(path=['defs', 'react_inner', 'return', 'text', '[5]'], file='examples/react/react_fun.pdl', table={"['description']": 1, "['text']": 2, "['text', '[0]']": 3, "['text', '[0]', 'import']": 3, "['text', '[0]', 'def']": 4, "['text', '[1]']": 5, "['text', '[1]', 'call']": 5, "['text', '[1]', 'args']": 6, "['text', '[1]', 'args', 'question']": 7, "['text', '[1]', 'args', 'model']": 8}), pdl__timing=PdlTiming(start_nanos=1743268261749504000, end_nanos=1743268261749584000, first_use_nanos=0, timezone=''), pdl__is_leaf=False, kind=, text="You are Granite, developed by IBM. You are a helpful AI assistant with access to the following tools. When a tool is required to answer the user's query, respond with <|tool_call|> followed by a JSON list of tools used. If a tool does not exist in the provided list of tools, notify the user that you do not have the ability to fulfill the request."), TextBlock(description=None, spec=None, defs={}, def_=None, contribute=[], parser=None, fallback=None, role='tools', context=[], pdl__id='text.1.call.call.text.6.text', pdl__result=None, pdl__location=PdlLocationType(path=['defs', 'react_inner', 'return', 'text', '[6]'], file='examples/react/react_fun.pdl', table={"['description']": 1, "['text']": 2, "['text', '[0]']": 3, "['text', '[0]', 'import']": 3, "['text', '[0]', 'def']": 4, "['text', '[1]']": 5, "['text', '[1]', 'call']": 5, "['text', '[1]', 'args']": 6, "['text', '[1]', 'args', 'question']": 7, "['text', '[1]', 'args', 'model']": 8}), pdl__timing=PdlTiming(start_nanos=1743268261749599000, end_nanos=1743268261749888000, first_use_nanos=0, timezone=''), pdl__is_leaf=False, kind=, text='${ tools }'), DataBlock(description=None, spec=None, defs={}, def_='prev_action', contribute=[], parser=None, fallback=None, role=None, context=[], pdl__id='text.1.call.call.text.7.data', pdl__result=None, pdl__location=PdlLocationType(path=['defs', 'react_inner', 'return', 'text', '[7]', 'data'], file='examples/react/react_fun.pdl', table={"['description']": 1, "['text']": 2, "['text', '[0]']": 3, "['text', '[0]', 'import']": 3, "['text', '[0]', 'def']": 4, "['text', '[1]']": 5, "['text', '[1]', 'call']": 5, "['text', '[1]', 'args']": 6, "['text', '[1]', 'args', 'question']": 7, "['text', '[1]', 'args', 'model']": 8}), pdl__timing=PdlTiming(start_nanos=1743268261749905000, end_nanos=1743268261749978000, first_use_nanos=0, timezone=''), pdl__is_leaf=True, kind=, data='none', raw=False), DataBlock(description=None, spec=None, defs={}, def_='exit', contribute=[], parser=None, fallback=None, role=None, context=[], pdl__id='text.1.call.call.text.8.data', pdl__result=None, pdl__location=PdlLocationType(path=['defs', 'react_inner', 'return', 'text', '[8]', 'data'], file='examples/react/react_fun.pdl', table={"['description']": 1, "['text']": 2, "['text', '[0]']": 3, "['text', '[0]', 'import']": 3, "['text', '[0]', 'def']": 4, "['text', '[1]']": 5, "['text', '[1]', 'call']": 5, "['text', '[1]', 'args']": 6, "['text', '[1]', 'args', 'question']": 7, "['text', '[1]', 'args', 'model']": 8}), pdl__timing=PdlTiming(start_nanos=1743268261749992000, end_nanos=1743268261750018000, first_use_nanos=0, timezone=''), pdl__is_leaf=True, kind=, data=False, raw=False), RepeatBlock(description=None, spec=None, defs={}, def_=None, contribute=[, ], parser=None, fallback=None, role=None, context=[], pdl__id='text.1.call.call.text.9.repeat', pdl__result=None, pdl__location=PdlLocationType(path=['defs', 'react_inner', 'return', 'text', '[9]'], file='examples/react/react_fun.pdl', table={"['description']": 1, "['text']": 2, "['text', '[0]']": 3, "['text', '[0]', 'import']": 3, "['text', '[0]', 'def']": 4, "['text', '[1]']": 5, "['text', '[1]', 'call']": 5, "['text', '[1]', 'args']": 6, "['text', '[1]', 'args', 'question']": 7, "['text', '[1]', 'args', 'model']": 8}), pdl__timing=PdlTiming(start_nanos=1743268261750031000, end_nanos=1743268269097254000, first_use_nanos=0, timezone=''), pdl__is_leaf=False, kind=, for_=None, while_=True, repeat=TextBlock(description=None, spec=None, defs={}, def_=None, contribute=[, ], parser=None, fallback=None, role=None, context=[], pdl__id='text.1.call.call.text.9.repeat.0.text', pdl__result=None, pdl__location=PdlLocationType(path=['defs', 'react_inner', 'return', 'text', '[9]', 'repeat'], file='examples/react/react_fun.pdl', table={"['description']": 1, "['text']": 2, "['text', '[0]']": 3, "['text', '[0]', 'import']": 3, "['text', '[0]', 'def']": 4, "['text', '[1]']": 5, "['text', '[1]', 'call']": 5, "['text', '[1]', 'args']": 6, "['text', '[1]', 'args', 'question']": 7, "['text', '[1]', 'args', 'model']": 8}), pdl__timing=PdlTiming(start_nanos=1743268261750053000, end_nanos=1743268269096538000, first_use_nanos=0, timezone=''), pdl__is_leaf=False, kind=, text=[LitellmModelBlock(description=None, spec=None, defs={}, def_='thought', contribute=[, ], parser=None, fallback=None, role=None, context=[], pdl__id='text.1.call.call.text.9.repeat.0.text.0.model', pdl__result=None, pdl__location=PdlLocationType(path=['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[0]'], file='examples/react/react_fun.pdl', table={"['description']": 1, "['text']": 2, "['text', '[0]']": 3, "['text', '[0]', 'import']": 3, "['text', '[0]', 'def']": 4, "['text', '[1]']": 5, "['text', '[1]', 'call']": 5, "['text', '[1]', 'args']": 6, "['text', '[1]', 'args', 'question']": 7, "['text', '[1]', 'args', 'model']": 8}), pdl__timing=PdlTiming(start_nanos=1743268261750085000, end_nanos=1743268268250432000, first_use_nanos=0, timezone=''), pdl__is_leaf=True, kind=, model='${ model }', input='${ pdl_context }', modelResponse=None, pdl__usage=None, pdl__model_input=None, platform=, parameters=LitellmParameters(timeout=None, temperature=0.0, top_p=None, n=None, stop=None, max_tokens=None, presence_penalty=None, frequency_penalty=None, logit_bias=None, user=None, response_format=None, seed=None, tools=None, tool_choice=None, logprobs=None, top_logprobs=None, parallel_tool_calls=None, extra_headers=None, functions=None, function_call=None, base_url=None, api_version=None, api_key=None, model_list=None, mock_response=None, custom_llm_provider=None, max_retries=None, stop_sequences='Action:')), 'Action:\n', LitellmModelBlock(description=None, spec=None, defs={}, def_='action', contribute=[, ], parser='json', fallback=None, role=None, context=[], pdl__id='text.1.call.call.text.9.repeat.0.text.2.model', pdl__result=None, pdl__location=PdlLocationType(path=['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[2]'], file='examples/react/react_fun.pdl', table={"['description']": 1, "['text']": 2, "['text', '[0]']": 3, "['text', '[0]', 'import']": 3, "['text', '[0]', 'def']": 4, "['text', '[1]']": 5, "['text', '[1]', 'call']": 5, "['text', '[1]', 'args']": 6, "['text', '[1]', 'args', 'question']": 7, "['text', '[1]', 'args', 'model']": 8}), pdl__timing=PdlTiming(start_nanos=1743268268250595000, end_nanos=1743268269093080000, first_use_nanos=0, timezone=''), pdl__is_leaf=True, kind=, model='${ model }', input='${ pdl_context }', modelResponse=None, pdl__usage=None, pdl__model_input=None, platform=, parameters=LitellmParameters(timeout=None, temperature=0.0, top_p=None, n=None, stop=None, max_tokens=None, presence_penalty=None, frequency_penalty=None, logit_bias=None, user=None, response_format=None, seed=None, tools=None, tool_choice=None, logprobs=None, top_logprobs=None, parallel_tool_calls=None, extra_headers=None, functions=None, function_call=None, base_url=None, api_version=None, api_key=None, model_list=None, mock_response=None, custom_llm_provider=None, max_retries=None, stop_sequences='\n')), IfBlock(description=None, spec=None, defs={}, def_=None, contribute=[, ], parser=None, fallback=None, role=None, context=[], pdl__id='text.1.call.call.text.9.repeat.0.text.3.if', pdl__result=None, pdl__location=PdlLocationType(path=['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]'], file='examples/react/react_fun.pdl', table={"['description']": 1, "['text']": 2, "['text', '[0]']": 3, "['text', '[0]', 'import']": 3, "['text', '[0]', 'def']": 4, "['text', '[1]']": 5, "['text', '[1]', 'call']": 5, "['text', '[1]', 'args']": 6, "['text', '[1]', 'args', 'question']": 7, "['text', '[1]', 'args', 'model']": 8}), pdl__timing=PdlTiming(start_nanos=1743268269093158000, end_nanos=1743268269096208000, first_use_nanos=0, timezone=''), pdl__is_leaf=False, kind=, condition='${ action != prev_action}', then=IfBlock(description=None, spec=None, defs={}, def_='observation', contribute=[, ], parser=None, fallback=None, role=None, context=[], pdl__id='text.1.call.call.text.9.repeat.0.text.3.if.0.if', pdl__result=None, pdl__location=PdlLocationType(path=['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then'], file='examples/react/react_fun.pdl', table={"['description']": 1, "['text']": 2, "['text', '[0]']": 3, "['text', '[0]', 'import']": 3, "['text', '[0]', 'def']": 4, "['text', '[1]']": 5, "['text', '[1]', 'call']": 5, "['text', '[1]', 'args']": 6, "['text', '[1]', 'args', 'question']": 7, "['text', '[1]', 'args', 'model']": 8}), pdl__timing=PdlTiming(start_nanos=1743268269094033000, end_nanos=1743268269096197000, first_use_nanos=0, timezone=''), pdl__is_leaf=False, kind=, condition='${ action[0].name == "Search" }', then=TextBlock(description=None, spec=None, defs={}, def_=None, contribute=[, ], parser=None, fallback=None, role=None, context=[], pdl__id='', pdl__result=None, pdl__location=None, pdl__timing=None, pdl__is_leaf=False, kind=, text=['\nObservation: ', CodeBlock(description=None, spec=None, defs={}, def_=None, contribute=[, ], parser=None, fallback=None, role=None, context=[], pdl__id='', pdl__result=None, pdl__location=None, pdl__timing=None, pdl__is_leaf=True, kind=, lang='python', code='import warnings, wikipedia\nwarnings.simplefilter("ignore")\ntry:\n result = wikipedia.summary("${ action[0].arguments.topic }")\nexcept wikipedia.WikipediaException as e:\n result = str(e)\n'), '\n']), else_=IfBlock(description=None, spec=None, defs={}, def_=None, contribute=[, ], parser=None, fallback=None, role=None, context=[], pdl__id='text.1.call.call.text.9.repeat.0.text.3.if.0.if.0.if', pdl__result=None, pdl__location=PdlLocationType(path=['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'else'], file='examples/react/react_fun.pdl', table={"['description']": 1, "['text']": 2, "['text', '[0]']": 3, "['text', '[0]', 'import']": 3, "['text', '[0]', 'def']": 4, "['text', '[1]']": 5, "['text', '[1]', 'call']": 5, "['text', '[1]', 'args']": 6, "['text', '[1]', 'args', 'question']": 7, "['text', '[1]', 'args', 'model']": 8}), pdl__timing=PdlTiming(start_nanos=1743268269094841000, end_nanos=1743268269096179000, first_use_nanos=0, timezone=''), pdl__is_leaf=False, kind=, condition='${ action[0].name == "Calc" }', then=TextBlock(description=None, spec=None, defs={}, def_=None, contribute=[, ], parser=None, fallback=None, role=None, context=[], pdl__id='', pdl__result=None, pdl__location=None, pdl__timing=None, pdl__is_leaf=False, kind=, text=['\nObservation: ', CodeBlock(description=None, spec=None, defs={}, def_=None, contribute=[, ], parser=None, fallback=None, role=None, context=[], pdl__id='', pdl__result=None, pdl__location=None, pdl__timing=None, pdl__is_leaf=True, kind=, lang='python', code='result = ${ action[0].arguments.expr }'), '\n']), else_=None, if_result=None), if_result=None), else_=DataBlock(description=None, spec=None, defs={}, def_='exit', contribute=[], parser=None, fallback=None, role=None, context=[], pdl__id='', pdl__result=None, pdl__location=None, pdl__timing=None, pdl__is_leaf=True, kind=, data=True, raw=False), if_result=None), DataBlock(description=None, spec=None, defs={}, def_='prev_action', contribute=[], parser=None, fallback=None, role=None, context=[], pdl__id='text.1.call.call.text.9.repeat.0.text.4.data', pdl__result=None, pdl__location=PdlLocationType(path=['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[4]', 'data'], file='examples/react/react_fun.pdl', table={"['description']": 1, "['text']": 2, "['text', '[0]']": 3, "['text', '[0]', 'import']": 3, "['text', '[0]', 'def']": 4, "['text', '[1]']": 5, "['text', '[1]', 'call']": 5, "['text', '[1]', 'args']": 6, "['text', '[1]', 'args', 'question']": 7, "['text', '[1]', 'args', 'model']": 8}), pdl__timing=PdlTiming(start_nanos=1743268269096231000, end_nanos=1743268269096499000, first_use_nanos=0, timezone=''), pdl__is_leaf=True, kind=, data='${ action }', raw=False)]), until='${ action[0].name == "Finish" or exit }', max_iterations=None, join=JoinText(as_=, with_=''), pdl__trace=None)])), 'react': FunctionBlock(description=None, spec=None, defs={}, def_=None, contribute=[, ], parser=None, fallback=None, role=None, context=[], pdl__id='text.0.import.empty.1.function', pdl__result=None, pdl__location=PdlLocationType(path=['defs', 'react'], file='examples/react/react_fun.pdl', table={"['description']": 1, "['defs']": 2, "['defs', 'react_inner']": 3, "['defs', 'react_inner', 'function']": 4, "['defs', 'react_inner', 'function', 'examples']": 5, "['defs', 'react_inner', 'function', 'question']": 6, "['defs', 'react_inner', 'function', 'model']": 7, "['defs', 'react_inner', 'return']": 8, "['defs', 'react_inner', 'return', 'text']": 9, "['defs', 'react_inner', 'return', 'text', '[0]']": 10, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs']": 10, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools']": 11, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data']": 12, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[0]']": 13, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[0]', 'name']": 13, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[0]', 'description']": 14, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[0]', 'arguments']": 15, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[0]', 'arguments', 'expr']": 16, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[0]', 'arguments', 'expr', 'type']": 17, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[0]', 'arguments', 'expr', 'description']": 18, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[1]']": 19, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[1]', 'name']": 19, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[1]', 'description']": 20, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[1]', 'arguments']": 21, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[1]', 'arguments', 'topic']": 22, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[1]', 'arguments', 'topic', 'type']": 23, "['defs', 'react_inner', 'return', 'text', '[0]', 'defs', 'tools', 'data', '[1]', 'arguments', 'topic', 'description']": 24, "['defs', 'react_inner', 'return', 'text', '[1]']": 25, "['defs', 'react_inner', 'return', 'text', '[1]', 'for']": 25, "['defs', 'react_inner', 'return', 'text', '[1]', 'for', 'ex']": 26, "['defs', 'react_inner', 'return', 'text', '[1]', 'repeat']": 27, "['defs', 'react_inner', 'return', 'text', '[2]']": 29, "['defs', 'react_inner', 'return', 'text', '[3]']": 30, "['defs', 'react_inner', 'return', 'text', '[4]']": 31, "['defs', 'react_inner', 'return', 'text', '[5]']": 32, "['defs', 'react_inner', 'return', 'text', '[5]', 'role']": 32, "['defs', 'react_inner', 'return', 'text', '[5]', 'text']": 33, "['defs', 'react_inner', 'return', 'text', '[5]', 'contribute']": 34, "['defs', 'react_inner', 'return', 'text', '[6]']": 35, "['defs', 'react_inner', 'return', 'text', '[6]', 'role']": 35, "['defs', 'react_inner', 'return', 'text', '[6]', 'text']": 36, "['defs', 'react_inner', 'return', 'text', '[6]', 'contribute']": 37, "['defs', 'react_inner', 'return', 'text', '[7]']": 38, "['defs', 'react_inner', 'return', 'text', '[7]', 'def']": 38, "['defs', 'react_inner', 'return', 'text', '[7]', 'contribute']": 39, "['defs', 'react_inner', 'return', 'text', '[7]', 'data']": 40, "['defs', 'react_inner', 'return', 'text', '[8]']": 41, "['defs', 'react_inner', 'return', 'text', '[8]', 'def']": 41, "['defs', 'react_inner', 'return', 'text', '[8]', 'contribute']": 42, "['defs', 'react_inner', 'return', 'text', '[8]', 'data']": 43, "['defs', 'react_inner', 'return', 'text', '[9]']": 44, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat']": 44, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text']": 45, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[0]']": 46, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[0]', 'def']": 46, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[0]', 'model']": 47, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[0]', 'parameters']": 48, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[0]', 'parameters', 'temperature']": 49, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[0]', 'parameters', 'stop_sequences']": 50, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[1]']": 51, '[\'defs\', \'react_inner\', \'return\', \'text\', \'[9]\', \'repeat\', \'text\', \'[1]\', \'"Action\']': 51, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[2]']": 52, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[2]', 'def']": 52, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[2]', 'model']": 53, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[2]', 'parameters']": 54, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[2]', 'parameters', 'temperature']": 55, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[2]', 'parameters', 'stop_sequences']": 56, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[2]', 'parser']": 57, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]']": 58, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'if']": 58, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then']": 59, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'def']": 60, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'if']": 61, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'then']": 62, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'then', 'text']": 63, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'then', 'text', '[0]']": 64, '[\'defs\', \'react_inner\', \'return\', \'text\', \'[9]\', \'repeat\', \'text\', \'[3]\', \'then\', \'then\', \'text\', \'[0]\', \'"\\\\nObservation\']': 64, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'then', 'text', '[1]']": 65, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'then', 'text', '[1]', 'lang']": 65, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'then', 'text', '[1]', 'code']": 66, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'then', 'text', '[1]', 'code', 'try']": 69, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'then', 'text', '[1]', 'code', 'except wikipedia.WikipediaException as e']": 71, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'then', 'text', '[2]']": 73, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'else']": 74, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'else', 'if']": 75, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'else', 'then']": 76, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'else', 'then', 'text']": 77, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'else', 'then', 'text', '[0]']": 78, '[\'defs\', \'react_inner\', \'return\', \'text\', \'[9]\', \'repeat\', \'text\', \'[3]\', \'then\', \'else\', \'then\', \'text\', \'[0]\', \'"\\\\nObservation\']': 78, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'else', 'then', 'text', '[1]']": 79, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'else', 'then', 'text', '[1]', 'lang']": 79, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'else', 'then', 'text', '[1]', 'code']": 80, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'then', 'else', 'then', 'text', '[2]']": 81, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'else']": 82, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'else', 'def']": 83, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'else', 'contribute']": 84, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[3]', 'else', 'data']": 85, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[4]']": 86, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[4]', 'def']": 86, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[4]', 'contribute']": 87, "['defs', 'react_inner', 'return', 'text', '[9]', 'repeat', 'text', '[4]', 'data']": 88, "['defs', 'react_inner', 'return', 'text', '[9]', 'until']": 89, "['defs', 'react']": 91, "['defs', 'react', 'function']": 92, "['defs', 'react', 'function', 'question']": 93, "['defs', 'react', 'function', 'model']": 94, "['defs', 'react', 'return']": 95, "['defs', 'react', 'return', 'defs']": 96, "['defs', 'react', 'return', 'defs', 'examples']": 97, "['defs', 'react', 'return', 'defs', 'examples', 'array']": 98, "['defs', 'react', 'return', 'defs', 'examples', 'array', '[0]']": 99, "['defs', 'react', 'return', 'defs', 'examples', 'array', '[0]', 'text']": 99, "['defs', 'react', 'return', 'defs', 'examples', 'array', '[0]', 'text', 'Thought']": 110, "['defs', 'react', 'return', 'defs', 'examples', 'array', '[0]', 'text', 'Action']": 111, '[\'defs\', \'react\', \'return\', \'defs\', \'examples\', \'array\', \'[0]\', \'text\', \'[{"name"\']': 112, "['defs', 'react', 'return', 'defs', 'examples', 'array', '[0]', 'text', 'Observation']": 109, "['defs', 'Thought']": 121, "['defs', 'Action']": 122, '[\'defs\', \'[{"name"\']': 123, "['defs', 'Observation']": 119, "['defs', 'call']": 125, "['defs', 'args']": 126, "['defs', 'args', 'pdl_context']": 127, "['defs', 'args', 'examples']": 128, "['defs', 'args', 'question']": 129, "['defs', 'args', 'model']": 130}), pdl__timing=PdlTiming(start_nanos=1743268261744034000, end_nanos=1743268261744053000, first_use_nanos=0, timezone=''), pdl__is_leaf=True, kind=, function={'question': 'string', 'model': 'string'}, returns=CallBlock(description=None, spec=None, defs={'examples': ArrayBlock(description=None, spec=None, defs={}, def_=None, contribute=[, ], parser=None, fallback=None, role=None, context=[], pdl__id='text.1.call.call.0.array', pdl__result=None, pdl__location=PdlLocationType(path=['defs', 'react', 'return', 'defs', 'examples'], file='examples/react/react_fun.pdl', table={"['description']": 1, "['text']": 2, "['text', '[0]']": 3, "['text', '[0]', 'import']": 3, "['text', '[0]', 'def']": 4, "['text', '[1]']": 5, "['text', '[1]', 'call']": 5, "['text', '[1]', 'args']": 6, "['text', '[1]', 'args', 'question']": 7, "['text', '[1]', 'args', 'model']": 8}), pdl__timing=PdlTiming(start_nanos=1743268261745357000, end_nanos=1743268261745593000, first_use_nanos=0, timezone=''), pdl__is_leaf=False, kind=, array=[TextBlock(description=None, spec=None, defs={}, def_=None, contribute=[, ], parser=None, fallback=None, role=None, context=[], pdl__id='text.1.call.call.0.array.0.text', pdl__result=None, pdl__location=PdlLocationType(path=['defs', 'react', 'return', 'defs', 'examples', 'array', '[0]'], file='examples/react/react_fun.pdl', table={"['description']": 1, "['text']": 2, "['text', '[0]']": 3, "['text', '[0]', 'import']": 3, "['text', '[0]', 'def']": 4, "['text', '[1]']": 5, "['text', '[1]', 'call']": 5, "['text', '[1]', 'args']": 6, "['text', '[1]', 'args', 'question']": 7, "['text', '[1]', 'args', 'model']": 8}), pdl__timing=PdlTiming(start_nanos=1743268261745395000, end_nanos=1743268261745582000, first_use_nanos=0, timezone=''), pdl__is_leaf=False, kind=, text='What profession does Nicholas Ray and Elia Kazan have in common?\nThought: I need to search Nicholas Ray and Elia Kazan, find their professions, then find the profession they have in common.\nAction:\n[{"name": "Search", "arguments": {"topic": "Nicholas Ray"}}]\nObservation: Nicholas Ray (born Raymond Nicholas Kienzle Jr., August 7, 1911 - June 16, 1979) was an American film director, screenwriter, and actor best known for the 1955 film Rebel Without a Cause.\nThought: Professions of Nicholas Ray are director, screenwriter, and actor. I need to search Elia Kazan next and find his professions.\nAction:\n[{"name": "Search", "arguments": {"topic": "Elia Kazan"}}]\nObservation: Elia Kazan was an American film and theatre director, producer, screenwriter and actor.\nThought: Professions of Elia Kazan are director, producer, screenwriter, and actor. So profession Nicholas Ray and Elia Kazan have in common is director, screenwriter, and actor.\nAction:\n[{"name": "Finish", "arguments": {"topic": "director, screenwriter, actor"}}]\n\n\nWhat is the elevation range for the area that the eastern sector of the Colorado orogeny extends into?\nThought: I need to search Colorado orogeny, find the area that the eastern sector of the Colorado ...\nAction:\n[{"name": "Search", "arguments": {"topic": "Colorado orogeny"}}]\nObservation: The Colorado orogeny was an episode of mountain building (an orogeny) ...\nThought: It does not mention the eastern sector. So I need to look up eastern sector.\nThought: High Plains rise in elevation from around 1,800 to 7,000 ft, so the answer is 1,800 to 7,000 ft.\nAction:\n[{"name": "Finish", "arguments": {"topic": "1,800 to 7,000 ft"}}]\n')])}, def_=None, contribute=[, ], parser=None, fallback=None, role=None, context=[], pdl__id='text.1.call.call', pdl__result=None, pdl__location=None, pdl__timing=PdlTiming(start_nanos=1743268261745340000, end_nanos=1743268269097286000, first_use_nanos=0, timezone=''), pdl__is_leaf=True, kind=, call='${ react_inner }', args={'pdl_context': [], 'examples': '${ examples }', 'question': '${ question }', 'model': '${ model }'}, pdl__trace=None))}What profession does Nicholas Ray and Elia Kazan have in common? Thought: I need to search Nicholas Ray and Elia Kazan, find their professions, then find the profession they have in common. Action: [{"name": "Search", "arguments": {"topic": "Nicholas Ray"}}] diff --git a/tests/results/examples/tutorial/function_definition.2.result b/tests/results/examples/tutorial/function_definition.2.result new file mode 100644 index 000000000..5fd7a7220 --- /dev/null +++ b/tests/results/examples/tutorial/function_definition.2.result @@ -0,0 +1,2 @@ +'J'adore Paris !' +The translation of "I love Madrid!" into Spanish is: "Me encanta Madrid!" \ No newline at end of file diff --git a/tests/test_expr.py b/tests/test_expr.py index ed3fb4ede..09089bcbb 100644 --- a/tests/test_expr.py +++ b/tests/test_expr.py @@ -120,7 +120,7 @@ def test_expr_detection1(): prog = """ lastOf: - '${ 1 }' -spec: int +spec: integer """ result = exec_str(prog) assert result == 1 @@ -130,7 +130,7 @@ def test_expr_detection2(): prog = """ lastOf: - '${ { "a": 1 }["a"] }' -spec: int +spec: integer """ result = exec_str(prog) assert result == 1 @@ -140,7 +140,7 @@ def test_expr_detection3(): prog = """ lastOf: - '${ 1 } ${ 2 }' -spec: str +spec: string """ result = exec_str(prog) assert result == "1 2" @@ -150,7 +150,7 @@ def test_expr_detection4(): prog = """ lastOf: - '${ 1 } { 2 }' -spec: str +spec: string """ result = exec_str(prog) assert result == "1 { 2 }" diff --git a/tests/test_fallback.py b/tests/test_fallback.py index d906674ff..bc33cfbef 100644 --- a/tests/test_fallback.py +++ b/tests/test_fallback.py @@ -57,7 +57,7 @@ def test_parse_regex_error(): def test_type_checking(): prog_str = """ text: "Hello" -spec: int +spec: integer fallback: 4012 """ result = exec_str(prog_str) @@ -67,7 +67,7 @@ def test_type_checking(): def test_type_checking_in_fallback(): prog_str = """ model: "raise an error" -spec: int +spec: integer fallback: "Error" """ with pytest.raises(PDLRuntimeError) as exc: diff --git a/tests/test_function.py b/tests/test_function.py index d78094421..c2ce7ab48 100644 --- a/tests/test_function.py +++ b/tests/test_function.py @@ -37,7 +37,7 @@ def test_hello_signature(): { "description": "Define hello", "def": "hello", - "function": {"name": "str"}, + "function": {"name": "string"}, "return": {"text": ["Hello ", {"get": "name"}, "!"]}, }, {"call": "${ hello }", "args": {"name": "World"}}, @@ -106,7 +106,7 @@ def test_function_explicit_context(): { "description": "Define hello", "def": "f", - "function": {"name": "str"}, + "function": {"name": "string"}, "return": {"text": ["Hello ", {"get": "name"}, "!"]}, }, {"lang": "python", "code": "result = alias['hello'] = f"}, diff --git a/tests/test_parse.py b/tests/test_parse.py index bbccf8906..c2d25e646 100644 --- a/tests/test_parse.py +++ b/tests/test_parse.py @@ -4,7 +4,7 @@ "description": "Parsing using regex", "text": "Malcolm Reynolds", "parser": { - "spec": {"first_name": "str", "last_name": "str"}, + "spec": {"first_name": "string", "last_name": "string"}, "regex": "(?P\\w+) (?P\\w+)", }, } diff --git a/tests/test_parser.py b/tests/test_parser.py index ff7ea14a6..b5861e7ae 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -6,7 +6,7 @@ model_parser = { "model": "watsonx_text/ibm/granite-20b-code-instruct", - "spec": {"bob": "int", "carol": "int"}, + "spec": {"bob": "integer", "carol": "integer"}, "input": { "text": [ "Write a JSON object with 2 fields 'a' and 'b' of type int and set to 0.", @@ -33,7 +33,7 @@ def test_model_parser(): model_parser1 = { "model": "watsonx_text/ibm/granite-34b-code-instruct", - "spec": {"bob": "int", "carol": "int"}, + "spec": {"bob": "integer", "carol": "integer"}, "input": { "text": [ "Write a JSON object with 2 fields 'bob' and 'carol' set to '20' and '30' respectively. Write 30 in letters", diff --git a/tests/test_runtime_errors.py b/tests/test_runtime_errors.py index 26c9967da..52f91414e 100644 --- a/tests/test_runtime_errors.py +++ b/tests/test_runtime_errors.py @@ -73,7 +73,7 @@ def test_parser_regex(): def test_type_result(): prog_str = """ text: "Hello" -spec: int +spec: integer """ with pytest.raises(PDLRuntimeError) as exc: exec_str(prog_str) @@ -126,7 +126,7 @@ def test_call_bad_args(): defs: f: function: - x: int + x: integer return: Hello call: ${ f } args: diff --git a/tests/test_type_checking.py b/tests/test_type_checking.py index 23c24b750..842bce802 100644 --- a/tests/test_type_checking.py +++ b/tests/test_type_checking.py @@ -17,47 +17,47 @@ "json_schema": {"type": "null"}, }, { - "pdl_type": "bool", + "pdl_type": "boolean", "json_schema": {"type": "boolean"}, }, { - "pdl_type": "{str: {pattern: '^[A-Za-z][A-Za-z0-9_]*$'}}", + "pdl_type": "{type: string, pattern: '^[A-Za-z][A-Za-z0-9_]*$'}", "json_schema": {"type": "string", "pattern": "^[A-Za-z][A-Za-z0-9_]*$"}, }, { - "pdl_type": "float", + "pdl_type": "number", "json_schema": {"type": "number"}, }, { - "pdl_type": "{float: {minimum: 0, exclusiveMaximum: 1}}", + "pdl_type": "{type: number, minimum: 0, exclusiveMaximum: 1}", "json_schema": {"type": "number", "minimum": 0, "exclusiveMaximum": 1}, }, { - "pdl_type": "int", + "pdl_type": "integer", "json_schema": {"type": "integer"}, }, { - "pdl_type": "{list: int}", + "pdl_type": "[integer]", "json_schema": {"type": "array", "items": {"type": "integer"}}, }, { - "pdl_type": "[int]", + "pdl_type": "{type: array, items: {type: integer}}", "json_schema": {"type": "array", "items": {"type": "integer"}}, }, { - "pdl_type": "{list: {int: {minimum: 0}}}", + "pdl_type": "{type: array, items: {type: integer, minimum: 0}}", "json_schema": {"type": "array", "items": {"type": "integer", "minimum": 0}}, }, { - "pdl_type": "[{int: {minimum: 0}}]", + "pdl_type": "[{type: integer, minimum: 0}]", "json_schema": {"type": "array", "items": {"type": "integer", "minimum": 0}}, }, { - "pdl_type": "{list: {minItems: 1, int: {}}}", + "pdl_type": "{type: array, minItems: 1, items: {type: integer}}", "json_schema": {"type": "array", "items": {"type": "integer"}, "minItems": 1}, }, { - "pdl_type": "{obj: {latitude: float, longitude: float}}", + "pdl_type": "{object: {latitude: number, longitude: number}}", "json_schema": { "type": "object", "properties": { @@ -69,7 +69,7 @@ }, }, { - "pdl_type": "{latitude: float, longitude: float}", + "pdl_type": "{latitude: number, longitude: number}", "json_schema": { "type": "object", "properties": { @@ -81,7 +81,7 @@ }, }, { - "pdl_type": "{obj: {question: str, answer: str, context: {optional: str}}}", + "pdl_type": "{object: {question: string, answer: string, context: {optional: string}}}", "json_schema": { "type": "object", "properties": { @@ -94,7 +94,7 @@ }, }, { - "pdl_type": "{question: str, answer: str, context: {optional: str}}", + "pdl_type": "{question: string, answer: string, context: {optional: string}}", "json_schema": { "type": "object", "properties": { @@ -107,7 +107,7 @@ }, }, { - "pdl_type": "{list: {obj: {question: str, answer: str}}}", + "pdl_type": "{type: array, items: {type: object, properties: {question: {type: string}, answer: {type: string}}, required: [question, answer], additionalProperties: false }}", "json_schema": { "type": "array", "items": { @@ -122,7 +122,7 @@ }, }, { - "pdl_type": "[{question: str, answer: str}]", + "pdl_type": "[{question: string, answer: string}]", "json_schema": { "type": "array", "items": { @@ -202,7 +202,7 @@ def test_function_call(): { "description": "Define hello", "def": "hello", - "function": {"name": "str"}, + "function": {"name": "string"}, "return": {"text": ["Hello ", {"get": "name"}, "!"]}, }, {"call": "${ hello }", "args": {"name": "Bob"}}, @@ -221,7 +221,7 @@ def test_function_call1(): { "description": "Define hello", "def": "hello", - "function": {"name": "int"}, + "function": {"name": "integer"}, "return": {"text": ["Hello ", {"get": "name"}, "!"]}, }, {"call": "${ hello }", "args": {"name": 42}}, @@ -240,7 +240,7 @@ def test_function_call2(): { "description": "Define hello", "def": "hello", - "function": {"name": "list"}, + "function": {"name": "array"}, "return": {"text": ["Hello ", {"get": "name"}, "!"]}, }, {"call": "${ hello }", "args": {"name": ["Bob", "Carrol"]}}, @@ -259,7 +259,7 @@ def test_function_call3(): { "description": "Define hello", "def": "hello", - "function": {"name": "obj"}, + "function": {"name": "object"}, "return": {"text": ["Hello ", {"get": "name"}, "!"]}, }, {"call": "${ hello }", "args": {"name": {"bob": "caroll"}}}, @@ -278,7 +278,7 @@ def test_function_call4(): { "description": "Define hello", "def": "hello", - "function": {"name": "bool"}, + "function": {"name": "boolean"}, "return": {"text": ["Hello ", {"get": "name"}, "!"]}, }, {"call": "${ hello }", "args": {"name": True}}, @@ -297,7 +297,7 @@ def test_function_call5(): { "description": "Define hello", "def": "hello", - "function": {"name": "float"}, + "function": {"name": "number"}, "return": {"text": ["Hello ", {"get": "name"}, "!"]}, }, {"call": "${ hello }", "args": {"name": 6.6}}, @@ -316,7 +316,7 @@ def test_function_call6(): { "description": "Define hello", "def": "hello", - "function": {"name": "float"}, + "function": {"name": "number"}, "return": {"text": ["Hello ", {"get": "name"}, "!"]}, }, {"call": "${ hello }", "args": {"name": 7.6}}, @@ -335,7 +335,7 @@ def test_function_call7(): { "description": "Define hello", "def": "hello", - "function": {"name": "floats"}, + "function": {"name": "numbers"}, "return": {"text": ["Hello ", {"get": "name"}, "!"]}, }, {"call": "${ hello }", "args": {"name": 6.6}}, @@ -354,7 +354,7 @@ def test_function_call8(): { "description": "Define hello", "def": "hello", - "function": {"name": "float", "address": "str"}, + "function": {"name": "number", "address": "string"}, "return": {"text": ["Hello ", {"get": "name"}, " ${ address}", "!"]}, }, {"call": "${ hello }", "args": {"name": 6.6, "address": "street"}}, @@ -373,7 +373,7 @@ def test_function_call9(): { "description": "Define hello", "def": "hello", - "function": {"name": "float", "address": "str"}, + "function": {"name": "number", "address": "string"}, "return": {"text": ["Hello ", {"get": "name"}, " ${ address}", "!"]}, }, { @@ -417,7 +417,7 @@ def test_function_call11(): { "description": "Define hello", "def": "hello", - "function": {"name": "float", "address": "str"}, + "function": {"name": "number", "address": "string"}, "return": {"text": ["Hello ", {"get": "name"}, " ${ address}", "!"]}, }, {"call": "${ hello }", "args": {}}, @@ -436,7 +436,7 @@ def test_function_call12(): { "description": "Define hello", "def": "hello", - "function": {"name": "float", "address": "str", "extra": "int"}, + "function": {"name": "number", "address": "string", "extra": "integer"}, "return": {"text": ["Hello ", "!"]}, }, {"call": "${ hello }", "args": {"name": "Bob", "extra": 2}}, @@ -474,8 +474,8 @@ def test_function_call14(): { "description": "Define hello", "def": "hello", - "function": {"name": "float", "address": "str"}, - "spec": "str", + "function": {"name": "number", "address": "string"}, + "spec": "string", "return": {"text": ["Hello ", {"get": "name"}, " ${ address}", "!"]}, }, {"call": "${ hello }", "args": {"name": 6.6, "address": "street"}}, @@ -494,8 +494,8 @@ def test_function_call15(): { "description": "Define hello", "def": "hello", - "function": {"name": "float", "address": "str"}, - "spec": "int", + "function": {"name": "number", "address": "string"}, + "spec": "integer", "return": {"text": ["Hello ", {"get": "name"}, " ${ address}", "!"]}, }, {"call": "${ hello }", "args": {"name": 6.6, "address": "street"}}, @@ -514,8 +514,8 @@ def test_function_call16(): { "description": "Define hello", "def": "hello", - "function": {"name": "float", "address": "str"}, - "spec": {"list": "int"}, + "function": {"name": "number", "address": "string"}, + "spec": ["integer"], "return": {"data": [1, 2, 3]}, }, {"call": "${ hello }", "args": {"name": 6.6, "address": "street"}}, @@ -534,8 +534,8 @@ def test_function_call17(): { "description": "Define hello", "def": "hello", - "function": {"name": "float", "address": "str"}, - "spec": {"list": "int"}, + "function": {"name": "number", "address": "string"}, + "spec": ["integer"], "return": {"data": [1, 2, "foo"]}, }, {"call": "${ hello }", "args": {"name": 6.6, "address": "street"}}, @@ -550,7 +550,7 @@ def test_function_call18(): hello = { "description": "Hello world!", - "spec": "str", + "spec": "string", "text": ["Hello, world!"], } @@ -562,7 +562,7 @@ def test_hello(): hello1 = { "description": "Hello world!", - "spec": {"obj": {"a": "str", "b": "str"}}, + "spec": {"object": {"a": "string", "b": "string"}}, "data": {"a": "Hello", "b": "World"}, } @@ -574,7 +574,12 @@ def test_hello1(): hello2 = { "description": "Hello world!", - "spec": {"list": {"minItems": 0, "maxItems": 0, "str": {}}}, + "spec": { + "type": "array", + "minItems": 0, + "maxItems": 0, + "items": {"type": "string"}, + }, "data": ["Hello", "World"], }