main 77fda47aa61c cached
1057 files
6.0 MB
1.6M tokens
1736 symbols
1 requests
Download .txt
Showing preview only (6,552K chars total). Download the full file or copy to clipboard to get everything.
Repository: IBM/prompt-declaration-language
Branch: main
Commit: 77fda47aa61c
Files: 1057
Total size: 6.0 MB

Directory structure:
gitextract_ir46b86_/

├── .flake8
├── .github/
│   ├── ISSUE_TEMPLATE/
│   │   ├── bug_report.md
│   │   └── feature_request.md
│   ├── actions/
│   │   ├── ollama/
│   │   │   └── action.yml
│   │   └── run-examples/
│   │       └── action.yml
│   ├── dependabot.yml
│   └── workflows/
│       ├── build.yml
│       ├── mkdocs-gh-pages.yml
│       ├── pdl-live-react-tests.yml
│       ├── publish-quay.yaml
│       ├── release-static-web-app.yml
│       ├── release-ui.yml
│       ├── release.yml
│       ├── run-examples-prep.yml
│       ├── run-examples.yml
│       ├── rust-interpreter.yml
│       └── tauri-cli.yml
├── .gitignore
├── .pre-commit-config.yaml
├── .vscode/
│   ├── launch.json
│   └── settings.json
├── LICENSE
├── README.md
├── bandit.yaml
├── contrib/
│   └── prompt_library/
│       ├── CoT.pdl
│       ├── ProbReAct.pdl
│       ├── ReAct.pdl
│       ├── ReWoo.pdl
│       └── tools.pdl
├── dockerfile
├── docs/
│   ├── .nojekyll
│   ├── README.md
│   ├── api_reference.md
│   ├── autopdl.md
│   ├── contrib.md
│   ├── css/
│   │   └── index.css
│   ├── stylesheets/
│   │   └── extra.css
│   ├── telemetry.md
│   ├── tutorial.md
│   └── viewer.md
├── examples/
│   ├── aggregators/
│   │   ├── contribute_in_file.pdl
│   │   ├── contribute_in_stderr.pdl
│   │   └── contribute_in_stdout.pdl
│   ├── callback/
│   │   ├── README.md
│   │   ├── repair_main.py
│   │   └── repair_prompt.pdl
│   ├── chatbot/
│   │   └── chatbot.pdl
│   ├── cldk/
│   │   ├── README.md
│   │   └── cldk-assistant.pdl
│   ├── demo/
│   │   ├── 1-hello.pdl
│   │   ├── 10-sdg.pdl
│   │   ├── 11-repeat.pdl
│   │   ├── 2-model-chaining.pdl
│   │   ├── 3-def-use.pdl
│   │   ├── 4-function.pdl
│   │   ├── 5-code-eval.pdl
│   │   ├── 6-code-json.pdl
│   │   ├── 7-chatbot-roles.pdl
│   │   ├── 8-tools.pdl
│   │   ├── 9-react.pdl
│   │   ├── data.yaml
│   │   ├── ground_truth.txt
│   │   └── qna.yaml
│   ├── demos/
│   │   ├── granite_io_hallucinations.pdl
│   │   ├── react.pdl
│   │   ├── repair_main.py
│   │   └── repair_prompt.pdl
│   ├── expectations/
│   │   ├── email.pdl
│   │   ├── gsm8k_short.pdl
│   │   └── mbpp.pdl
│   ├── fibonacci/
│   │   └── fib.pdl
│   ├── granite-io/
│   │   ├── granite_io_hallucinations.pdl
│   │   ├── granite_io_object.pdl
│   │   ├── granite_io_openai.pdl
│   │   ├── granite_io_thinking.pdl
│   │   └── granite_io_transformers.pdl
│   ├── gsm8k/
│   │   ├── README.md
│   │   ├── demos.yaml
│   │   ├── gsm8k-loop-fission.pdl
│   │   ├── gsm8k-plan-few-shots.pdl
│   │   ├── gsm8k-plan.pdl
│   │   ├── gsm8k-tot-few-shot.pdl
│   │   ├── gsm8k-tot-multiplan.pdl
│   │   ├── gsm8k-tot.pdl
│   │   └── gsm8k.pdl
│   ├── independent/
│   │   ├── independent.pdl
│   │   ├── independent_docs.pdl
│   │   ├── independent_for.pdl
│   │   └── test.pdl
│   ├── input/
│   │   ├── data.txt
│   │   ├── input_test.pdl
│   │   ├── input_test1.pdl
│   │   └── input_test2.pdl
│   ├── intrinsics/
│   │   ├── README.md
│   │   ├── demo-hallucination.json
│   │   └── demo-hallucination.pdl
│   ├── map-reduce/
│   │   ├── context_fork.pdl
│   │   ├── python-reduce.pdl
│   │   └── reduce.pdl
│   ├── notebooks/
│   │   ├── data.yaml
│   │   ├── demo.ipynb
│   │   ├── demonstrations.txt
│   │   ├── granite_io_demo.ipynb
│   │   ├── ground_truth.txt
│   │   ├── notebook.ipynb
│   │   ├── notebook_debug.ipynb
│   │   └── pdl.ipynb
│   ├── openai/
│   │   ├── README.md
│   │   ├── openai_basic.pdl
│   │   └── openai_structured.pdl
│   ├── optimizer/
│   │   ├── __init__.py
│   │   ├── config.yml
│   │   ├── eval_levenshtein.pdl
│   │   ├── fever.pdl
│   │   ├── fever_evaluator.py
│   │   ├── grammar_correction.pdl
│   │   ├── grammar_correction.yaml
│   │   ├── gsm8k.pdl
│   │   ├── gsm8k_evaluator.py
│   │   ├── gsm8k_optimizer_config.yml
│   │   ├── gsmhard_evaluator.py
│   │   ├── mbpp.pdl
│   │   ├── mbpp_dataset.py
│   │   ├── mbpp_evaluator.py
│   │   ├── optimize.py
│   │   ├── optimized_grammar_correction.pdl
│   │   ├── process_fever.py
│   │   ├── process_grammar_correction.py
│   │   ├── process_gsm8k.py
│   │   └── process_mbpp.py
│   ├── ppdl/
│   │   ├── coin.pdl
│   │   ├── hmm.pdl
│   │   ├── hmm_nl_priors.pdl
│   │   ├── mbpp.pdl
│   │   ├── name_finder.ipynb
│   │   └── name_finder.pdl
│   ├── prompt_library/
│   │   ├── gsm8k_cot.pdl
│   │   ├── gsm8k_prob_react.pdl
│   │   ├── gsm8k_react.pdl
│   │   └── gsm8k_rewoo.pdl
│   ├── rag/
│   │   ├── README.md
│   │   ├── pdf_index.pdl
│   │   ├── pdf_query.pdl
│   │   ├── rag.py
│   │   ├── rag_library1.pdl
│   │   └── tfidf_rag.pdl
│   ├── react/
│   │   ├── demonstrations.txt
│   │   └── react_demo.pdl
│   ├── skeleton-of-thought/
│   │   ├── tips.pdl
│   │   └── topic.jsonl
│   ├── teacher/
│   │   ├── qna.yaml
│   │   └── teacher.pdl
│   ├── test.pdl
│   ├── tools/
│   │   ├── calc.pdl
│   │   └── search.pdl
│   └── tutorial/
│       ├── calling_llm.pdl
│       ├── calling_llm_chaining.pdl
│       ├── calling_llm_with_input.pdl
│       ├── calling_llm_with_input_messages.pdl
│       ├── calling_llm_with_input_messages_var.pdl
│       ├── code_command.pdl
│       ├── code_jinja.pdl
│       ├── code_jinja_parameters.pdl
│       ├── code_pdl.pdl
│       ├── code_python.pdl
│       ├── code_scope.pdl
│       ├── code_session.pdl
│       ├── data.txt
│       ├── data.yaml
│       ├── data_block_raw.pdl
│       ├── defs.pdl
│       ├── for.pdl
│       ├── for_array.pdl
│       ├── for_lastOf.pdl
│       ├── for_multiple_lists.pdl
│       ├── for_object.pdl
│       ├── for_with.pdl
│       ├── free_variables.pdl
│       ├── function_alias.pdl
│       ├── function_call_in_jinja.pdl
│       ├── function_definition.pdl
│       ├── function_empty_context.pdl
│       ├── function_optional_params.pdl
│       ├── if.pdl
│       ├── import.pdl
│       ├── import_lib.pdl
│       ├── input.json
│       ├── input_file.pdl
│       ├── input_file_json.pdl
│       ├── input_stdin.pdl
│       ├── input_stdin_multiline.pdl
│       ├── lastOf.pdl
│       ├── local_computation.pdl
│       ├── loop_index.pdl
│       ├── muting_block_output.pdl
│       ├── parser-regex.pdl
│       ├── parser_findall.pdl
│       ├── parser_regex_code.pdl
│       ├── pdl_scope.pdl
│       ├── pdl_usage.pdl
│       ├── programs/
│       │   ├── chatbot.pdl
│       │   ├── code/
│       │   │   ├── README.md
│       │   │   ├── code-eval.pdl
│       │   │   ├── code-json-output.json
│       │   │   ├── code-json.pdl
│       │   │   ├── code.pdl
│       │   │   ├── data.yaml
│       │   │   └── ground_truth.txt
│       │   ├── demo-hallucination.pdl
│       │   └── weather.pdl
│       ├── repeat.pdl
│       ├── role.pdl
│       ├── sdk/
│       │   ├── hello.pdl
│       │   ├── hello_dict.py
│       │   ├── hello_file.py
│       │   ├── hello_parallel.py
│       │   ├── hello_prog.py
│       │   ├── hello_str.py
│       │   ├── lib.pdl
│       │   └── run_pdl.py
│       ├── simple_program.pdl
│       ├── structured_decoding.pdl
│       ├── type_checking.pdl
│       ├── type_checking_data.yaml
│       ├── type_error.pdl
│       ├── type_list.pdl
│       ├── variable_def_use.pdl
│       └── while.pdl
├── mkdocs.yml
├── mypy.ini
├── pdl-live-react/
│   ├── .editorconfig
│   ├── .gitignore
│   ├── .vscode/
│   │   └── extensions.json
│   ├── README.md
│   ├── demos/
│   │   ├── beeai/
│   │   │   └── test1.py
│   │   ├── demo1.pdl
│   │   ├── demo2.pdl
│   │   ├── error.pdl
│   │   ├── gen-data.yaml
│   │   └── run.sh
│   ├── eslint.config.js
│   ├── index.html
│   ├── package.json
│   ├── playwright.config.ts
│   ├── src/
│   │   ├── App.tsx
│   │   ├── demos/
│   │   │   ├── README.md
│   │   │   ├── demo1.json
│   │   │   ├── demo2.json
│   │   │   ├── demo3.json
│   │   │   ├── demo4.json
│   │   │   ├── demo5.json
│   │   │   ├── demo6.json
│   │   │   ├── demo7.json
│   │   │   ├── demo8.json
│   │   │   ├── demo9.json
│   │   │   └── demos.ts
│   │   ├── helpers.ts
│   │   ├── main.tsx
│   │   ├── page/
│   │   │   ├── About.tsx
│   │   │   ├── ClearMyTraces.tsx
│   │   │   ├── DarkModeContext.ts
│   │   │   ├── DarkModeToggle.tsx
│   │   │   ├── Demo.tsx
│   │   │   ├── DemoNavItems.tsx
│   │   │   ├── Demos.tsx
│   │   │   ├── ErrorBoundary.tsx
│   │   │   ├── Local.tsx
│   │   │   ├── Masthead.css
│   │   │   ├── Masthead.tsx
│   │   │   ├── MyTrace.tsx
│   │   │   ├── MyTraces.ts
│   │   │   ├── MyTracesNavItems.tsx
│   │   │   ├── MyTracesPage.tsx
│   │   │   ├── Page.css
│   │   │   ├── Page.tsx
│   │   │   ├── PageBreadcrumbDropdown.tsx
│   │   │   ├── PageBreadcrumbDropdownItem.tsx
│   │   │   ├── PageBreadcrumbs.css
│   │   │   ├── PageBreadcrumbs.tsx
│   │   │   ├── Run.css
│   │   │   ├── Run.tsx
│   │   │   ├── Sidebar.tsx
│   │   │   ├── Uploader.css
│   │   │   ├── Uploader.tsx
│   │   │   └── welcome/
│   │   │       ├── Intro.tsx
│   │   │       ├── Links.tsx
│   │   │       ├── Tile.tsx
│   │   │       ├── Tiles.tsx
│   │   │       ├── Toolbar.tsx
│   │   │       ├── Welcome.css
│   │   │       ├── Welcome.tsx
│   │   │       └── tiles/
│   │   │           ├── Demos.tsx
│   │   │           └── MyTraces.tsx
│   │   ├── pdl_ast.d.ts
│   │   ├── pdl_ast_utils.ts
│   │   ├── pdl_code_cleanup.ts
│   │   ├── routes/
│   │   │   └── PdlRoutes.tsx
│   │   ├── svg.d.ts
│   │   ├── title.ts
│   │   ├── view/
│   │   │   ├── CopyToClipboard.css
│   │   │   ├── CopyToClipboard.tsx
│   │   │   ├── Markdown.css
│   │   │   ├── Markdown.tsx
│   │   │   ├── Result.tsx
│   │   │   ├── Value.tsx
│   │   │   ├── breadcrumbs/
│   │   │   │   ├── BreadcrumbBar.css
│   │   │   │   ├── BreadcrumbBar.tsx
│   │   │   │   ├── BreadcrumbBarForBlock.tsx
│   │   │   │   ├── BreadcrumbBarForBlockId.tsx
│   │   │   │   ├── BreadcrumbBarItem.tsx
│   │   │   │   └── Def.tsx
│   │   │   ├── code/
│   │   │   │   ├── Code.tsx
│   │   │   │   ├── CodeGroup.tsx
│   │   │   │   ├── PreviewLight.css
│   │   │   │   └── PreviewLight.tsx
│   │   │   ├── detail/
│   │   │   │   ├── BlockNotFound.tsx
│   │   │   │   ├── ContextTabContent.tsx
│   │   │   │   ├── DefContent.css
│   │   │   │   ├── DefContent.tsx
│   │   │   │   ├── DrawerContent.css
│   │   │   │   ├── DrawerContent.tsx
│   │   │   │   ├── DrawerContentBody.tsx
│   │   │   │   ├── Group.tsx
│   │   │   │   ├── RawTraceTabContent.tsx
│   │   │   │   ├── ResultTabContent.tsx
│   │   │   │   ├── SourceTabContent.tsx
│   │   │   │   ├── SummaryTabContent.tsx
│   │   │   │   ├── UsageTabContent.tsx
│   │   │   │   ├── find.ts
│   │   │   │   └── kind/
│   │   │   │       ├── Call.tsx
│   │   │   │       ├── Code.tsx
│   │   │   │       ├── Data.tsx
│   │   │   │       ├── Error.tsx
│   │   │   │       ├── Function.tsx
│   │   │   │       ├── If.tsx
│   │   │   │       ├── Model.tsx
│   │   │   │       ├── Read.tsx
│   │   │   │       └── Text.tsx
│   │   │   ├── masonry/
│   │   │   │   ├── Duration.css
│   │   │   │   ├── Duration.tsx
│   │   │   │   ├── Masonry.css
│   │   │   │   ├── Masonry.tsx
│   │   │   │   ├── MasonryCombo.tsx
│   │   │   │   ├── MasonryTile.tsx
│   │   │   │   ├── MasonryTileWrapper.tsx
│   │   │   │   ├── RunMenu.tsx
│   │   │   │   ├── Stability.css
│   │   │   │   ├── Tile.ts
│   │   │   │   ├── Toolbar.tsx
│   │   │   │   ├── ToolbarPaginator.tsx
│   │   │   │   ├── ToolbarReplayButton.tsx
│   │   │   │   ├── ToolbarSMLToggle.tsx
│   │   │   │   ├── ToolbarShowSourceButton.tsx
│   │   │   │   ├── View.ts
│   │   │   │   ├── condvar.ts
│   │   │   │   ├── model.ts
│   │   │   │   └── stability.ts
│   │   │   ├── term/
│   │   │   │   ├── RunTerminal.css
│   │   │   │   └── RunTerminal.tsx
│   │   │   └── timeline/
│   │   │       ├── Timeline.css
│   │   │       ├── Timeline.tsx
│   │   │       ├── TimelineBar.tsx
│   │   │       ├── TimelineFromModel.tsx
│   │   │       ├── TimelineRow.tsx
│   │   │       ├── TimelineRowKindCell.tsx
│   │   │       └── model.ts
│   │   ├── vite-env.d.ts
│   │   └── window.d.ts
│   ├── src-tauri/
│   │   ├── .gitignore
│   │   ├── .taurignore
│   │   ├── Cargo.toml
│   │   ├── build.rs
│   │   ├── capabilities/
│   │   │   ├── default.json
│   │   │   └── desktop.json
│   │   ├── icons/
│   │   │   └── icon.icns
│   │   ├── src/
│   │   │   ├── cli.rs
│   │   │   ├── commands/
│   │   │   │   ├── interpreter.rs
│   │   │   │   ├── mod.rs
│   │   │   │   ├── read_trace.rs
│   │   │   │   └── replay_prep.rs
│   │   │   ├── compile/
│   │   │   │   ├── beeai.rs
│   │   │   │   └── mod.rs
│   │   │   ├── gui.rs
│   │   │   ├── lib.rs
│   │   │   ├── main.rs
│   │   │   ├── pdl/
│   │   │   │   ├── ast.rs
│   │   │   │   ├── extract.rs
│   │   │   │   ├── interpreter.rs
│   │   │   │   ├── interpreter_tests.rs
│   │   │   │   ├── mod.rs
│   │   │   │   ├── pip.rs
│   │   │   │   ├── pull.rs
│   │   │   │   └── requirements.rs
│   │   │   ├── util/
│   │   │   │   └── shasum.rs
│   │   │   └── util.rs
│   │   ├── tauri.conf.json
│   │   └── tests/
│   │       ├── cli/
│   │       │   ├── call-no-args.pdl
│   │       │   ├── call-with-args.pdl
│   │       │   ├── code-python.pdl
│   │       │   ├── data1.pdl
│   │       │   ├── data2.pdl
│   │       │   ├── data3.pdl
│   │       │   ├── data4.pdl
│   │       │   ├── if1.pdl
│   │       │   ├── if2.pdl
│   │       │   ├── include1.pdl
│   │       │   ├── json-parser-lastOf.pdl
│   │       │   ├── json-parser.pdl
│   │       │   ├── jsonl-parser.pdl
│   │       │   ├── model-input-array.pdl
│   │       │   ├── model-input-nested.pdl
│   │       │   ├── model-input-string.pdl
│   │       │   ├── object1.pdl
│   │       │   ├── object2.pdl
│   │       │   ├── read-file.pdl
│   │       │   ├── read-stdin.pdl
│   │       │   ├── regex-findall.pdl
│   │       │   ├── repeat1.pdl
│   │       │   ├── repeat2.pdl
│   │       │   ├── repeat3.pdl
│   │       │   ├── scoping_1.pdl
│   │       │   └── scoping_1_wrapper.pdl
│   │       └── data/
│   │           ├── bee_1.py
│   │           ├── foo.txt
│   │           └── struct.yaml
│   ├── tests/
│   │   └── basics.spec.test.ts
│   ├── tsconfig.app.json
│   ├── tsconfig.json
│   ├── tsconfig.node.json
│   └── vite.config.ts
├── pylintrc
├── pyproject.toml
├── renovate.json
├── scripts/
│   └── generate_pdl_examples_runner.sh
├── src/
│   └── pdl/
│       ├── __init__.py
│       ├── optimize/
│       │   ├── __init__.py
│       │   ├── config_parser.py
│       │   ├── optimizer_evaluator.py
│       │   ├── parse_number.py
│       │   ├── pdl_evaluator.py
│       │   ├── pdl_optimizer.py
│       │   └── util.py
│       ├── pdl-schema.json
│       ├── pdl.py
│       ├── pdl_analysis.py
│       ├── pdl_ast.py
│       ├── pdl_ast_utils.py
│       ├── pdl_compilers/
│       │   ├── __init__.py
│       │   └── to_regex.py
│       ├── pdl_context.py
│       ├── pdl_distributions.py
│       ├── pdl_dumper.py
│       ├── pdl_granite_io.py
│       ├── pdl_infer.py
│       ├── pdl_inference.py
│       ├── pdl_interpreter.py
│       ├── pdl_interpreter_state.py
│       ├── pdl_lazy.py
│       ├── pdl_linter.py
│       ├── pdl_llms.py
│       ├── pdl_location_utils.py
│       ├── pdl_notebook_ext.py
│       ├── pdl_openai.py
│       ├── pdl_parser.py
│       ├── pdl_python_repl.py
│       ├── pdl_runner.py
│       ├── pdl_scheduler.py
│       ├── pdl_schema_error_analyzer.py
│       ├── pdl_schema_utils.py
│       ├── pdl_schema_validator.py
│       ├── pdl_stdlib.pdl
│       ├── pdl_stdlib.py
│       └── pdl_utils.py
└── tests/
    ├── __init__.py
    ├── data/
    │   ├── call_expression_args.pdl
    │   ├── function.pdl
    │   ├── hello.pdl
    │   ├── input.json
    │   ├── input1.json
    │   ├── input_data.txt
    │   ├── line/
    │   │   ├── hello.pdl
    │   │   ├── hello1.pdl
    │   │   ├── hello10.pdl
    │   │   ├── hello11.pdl
    │   │   ├── hello12.pdl
    │   │   ├── hello13.pdl
    │   │   ├── hello14.pdl
    │   │   ├── hello15.pdl
    │   │   ├── hello16.pdl
    │   │   ├── hello16_data.json
    │   │   ├── hello17.pdl
    │   │   ├── hello18.pdl
    │   │   ├── hello19.pdl
    │   │   ├── hello20.pdl
    │   │   ├── hello21.pdl
    │   │   ├── hello22.pdl
    │   │   ├── hello23.pdl
    │   │   ├── hello24.pdl
    │   │   ├── hello25.pdl
    │   │   ├── hello26.pdl
    │   │   ├── hello27.pdl
    │   │   ├── hello28.pdl
    │   │   ├── hello29.pdl
    │   │   ├── hello3.pdl
    │   │   ├── hello30.pdl
    │   │   ├── hello31.pdl
    │   │   ├── hello32.pdl
    │   │   ├── hello4.pdl
    │   │   ├── hello7.pdl
    │   │   ├── hello8.pdl
    │   │   └── hello9.pdl
    │   └── optimizer_gsm8k.pdl
    ├── results/
    │   ├── contrib/
    │   │   └── prompt_library/
    │   │       ├── CoT.0.result
    │   │       ├── ProbReAct.0.result
    │   │       ├── ReAct.0.result
    │   │       ├── ReWoo.0.result
    │   │       └── tools.0.result
    │   ├── examples/
    │   │   ├── aggregators/
    │   │   │   ├── contribute_in_file.0.result
    │   │   │   ├── contribute_in_file.1.result
    │   │   │   ├── contribute_in_file.2.result
    │   │   │   ├── contribute_in_file.3.result
    │   │   │   ├── contribute_in_file.4.result
    │   │   │   ├── contribute_in_stderr.0.result
    │   │   │   └── contribute_in_stdout.0.result
    │   │   ├── chatbot/
    │   │   │   ├── chatbot.0.result
    │   │   │   ├── chatbot.1.result
    │   │   │   ├── chatbot.2.result
    │   │   │   ├── chatbot.3.result
    │   │   │   ├── chatbot.4.result
    │   │   │   ├── chatbot.5.result
    │   │   │   ├── chatbot.6.result
    │   │   │   ├── chatbot.7.result
    │   │   │   └── chatbot.8.result
    │   │   ├── demo/
    │   │   │   ├── 1-hello.0.result
    │   │   │   ├── 10-sdg.0.result
    │   │   │   ├── 10-sdg.1.result
    │   │   │   ├── 10-sdg.2.result
    │   │   │   ├── 10-sdg.3.result
    │   │   │   ├── 10-sdg.4.result
    │   │   │   ├── 10-sdg.5.result
    │   │   │   ├── 10-sdg.6.result
    │   │   │   ├── 10-sdg.7.result
    │   │   │   ├── 11-repeat.0.result
    │   │   │   ├── 2-model-chaining.0.result
    │   │   │   ├── 2-model-chaining.1.result
    │   │   │   ├── 2-model-chaining.2.result
    │   │   │   ├── 3-def-use.0.result
    │   │   │   ├── 3-def-use.1.result
    │   │   │   ├── 3-def-use.2.result
    │   │   │   ├── 3-def-use.3.result
    │   │   │   ├── 3-def-use.4.result
    │   │   │   ├── 3-def-use.5.result
    │   │   │   ├── 4-function.0.result
    │   │   │   ├── 4-function.1.result
    │   │   │   ├── 4-function.2.result
    │   │   │   ├── 4-function.3.result
    │   │   │   ├── 4-function.4.result
    │   │   │   ├── 5-code-eval.0.result
    │   │   │   ├── 5-code-eval.1.result
    │   │   │   ├── 5-code-eval.2.result
    │   │   │   ├── 5-code-eval.3.result
    │   │   │   ├── 5-code-eval.4.result
    │   │   │   ├── 5-code-eval.5.result
    │   │   │   ├── 5-code-eval.6.result
    │   │   │   ├── 5-code-eval.7.result
    │   │   │   ├── 5-code-eval.8.result
    │   │   │   ├── 5-code-eval.9.result
    │   │   │   ├── 6-code-json.0.result
    │   │   │   ├── 6-code-json.1.result
    │   │   │   ├── 6-code-json.2.result
    │   │   │   ├── 6-code-json.3.result
    │   │   │   ├── 6-code-json.4.result
    │   │   │   ├── 6-code-json.5.result
    │   │   │   ├── 6-code-json.6.result
    │   │   │   ├── 6-code-json.7.result
    │   │   │   ├── 6-code-json.8.result
    │   │   │   ├── 7-chatbot-roles.0.result
    │   │   │   ├── 7-chatbot-roles.1.result
    │   │   │   ├── 7-chatbot-roles.2.result
    │   │   │   ├── 7-chatbot-roles.3.result
    │   │   │   ├── 7-chatbot-roles.4.result
    │   │   │   ├── 7-chatbot-roles.5.result
    │   │   │   ├── 7-chatbot-roles.6.result
    │   │   │   ├── 8-tools.0.result
    │   │   │   ├── 8-tools.1.result
    │   │   │   ├── 9-react.0.result
    │   │   │   ├── 9-react.1.result
    │   │   │   ├── 9-react.10.result
    │   │   │   ├── 9-react.11.result
    │   │   │   ├── 9-react.12.result
    │   │   │   ├── 9-react.13.result
    │   │   │   ├── 9-react.14.result
    │   │   │   ├── 9-react.15.result
    │   │   │   ├── 9-react.16.result
    │   │   │   ├── 9-react.17.result
    │   │   │   ├── 9-react.2.result
    │   │   │   ├── 9-react.3.result
    │   │   │   ├── 9-react.4.result
    │   │   │   ├── 9-react.5.result
    │   │   │   ├── 9-react.6.result
    │   │   │   ├── 9-react.7.result
    │   │   │   ├── 9-react.8.result
    │   │   │   └── 9-react.9.result
    │   │   ├── demos/
    │   │   │   ├── granite_io_hallucinations.0.result
    │   │   │   ├── granite_io_hallucinations.1.result
    │   │   │   ├── granite_io_hallucinations.2.result
    │   │   │   ├── granite_io_hallucinations.3.result
    │   │   │   ├── granite_io_hallucinations.4.result
    │   │   │   ├── react.0.result
    │   │   │   ├── react.1.result
    │   │   │   ├── react.2.result
    │   │   │   ├── react.3.result
    │   │   │   ├── react.4.result
    │   │   │   └── react_fun.0.result
    │   │   ├── fibonacci/
    │   │   │   ├── fib.0.result
    │   │   │   ├── fib.1.result
    │   │   │   ├── fib.2.result
    │   │   │   ├── fib.3.result
    │   │   │   ├── fib.4.result
    │   │   │   ├── fib.5.result
    │   │   │   ├── fib.6.result
    │   │   │   ├── fib.7.result
    │   │   │   ├── fib.8.result
    │   │   │   └── fib.9.result
    │   │   ├── granite-io/
    │   │   │   ├── granite_io_hallucinations.0.result
    │   │   │   ├── granite_io_hallucinations.1.result
    │   │   │   ├── granite_io_hallucinations.2.result
    │   │   │   ├── granite_io_hallucinations.3.result
    │   │   │   ├── granite_io_object.0.result
    │   │   │   ├── granite_io_object.1.result
    │   │   │   ├── granite_io_object.2.result
    │   │   │   ├── granite_io_object.3.result
    │   │   │   ├── granite_io_openai.0.result
    │   │   │   ├── granite_io_openai.1.result
    │   │   │   ├── granite_io_openai.2.result
    │   │   │   ├── granite_io_thinking.0.result
    │   │   │   ├── granite_io_thinking.1.result
    │   │   │   ├── granite_io_thinking.2.result
    │   │   │   └── granite_io_thinking.3.result
    │   │   ├── independent/
    │   │   │   ├── independent.0.result
    │   │   │   ├── independent.1.result
    │   │   │   ├── independent.2.result
    │   │   │   ├── independent.3.result
    │   │   │   ├── independent.4.result
    │   │   │   ├── independent.5.result
    │   │   │   ├── independent.6.result
    │   │   │   ├── independent.7.result
    │   │   │   ├── independent_docs.0.result
    │   │   │   ├── independent_docs.1.result
    │   │   │   ├── independent_docs.10.result
    │   │   │   ├── independent_docs.2.result
    │   │   │   ├── independent_docs.3.result
    │   │   │   ├── independent_docs.4.result
    │   │   │   ├── independent_docs.5.result
    │   │   │   ├── independent_docs.6.result
    │   │   │   ├── independent_docs.7.result
    │   │   │   ├── independent_docs.8.result
    │   │   │   ├── independent_docs.9.result
    │   │   │   ├── independent_for.0.result
    │   │   │   ├── independent_for.1.result
    │   │   │   ├── independent_for.2.result
    │   │   │   ├── independent_for.3.result
    │   │   │   ├── independent_for.4.result
    │   │   │   ├── independent_for.5.result
    │   │   │   ├── test.0.result
    │   │   │   ├── test.1.result
    │   │   │   ├── test.2.result
    │   │   │   ├── test.3.result
    │   │   │   ├── test.4.result
    │   │   │   ├── test.5.result
    │   │   │   ├── test.6.result
    │   │   │   ├── test.7.result
    │   │   │   └── test.8.result
    │   │   ├── input/
    │   │   │   ├── input_test.0.result
    │   │   │   ├── input_test1.0.result
    │   │   │   └── input_test2.0.result
    │   │   ├── intrinsics/
    │   │   │   └── demo-hallucination.0.result
    │   │   ├── map-reduce/
    │   │   │   ├── context_fork.0.result
    │   │   │   ├── context_fork.1.result
    │   │   │   ├── context_fork.2.result
    │   │   │   ├── context_fork.3.result
    │   │   │   ├── context_fork.4.result
    │   │   │   ├── context_fork.5.result
    │   │   │   ├── pipeline.0.result
    │   │   │   ├── python-reduce.0.result
    │   │   │   └── reduce.0.result
    │   │   ├── openai/
    │   │   │   ├── openai_basic.0.result
    │   │   │   ├── openai_basic.1.result
    │   │   │   ├── openai_basic.10.result
    │   │   │   ├── openai_basic.11.result
    │   │   │   ├── openai_basic.12.result
    │   │   │   ├── openai_basic.2.result
    │   │   │   ├── openai_basic.3.result
    │   │   │   ├── openai_basic.4.result
    │   │   │   ├── openai_basic.5.result
    │   │   │   ├── openai_basic.6.result
    │   │   │   ├── openai_basic.7.result
    │   │   │   ├── openai_basic.8.result
    │   │   │   ├── openai_basic.9.result
    │   │   │   └── openai_structured.0.result
    │   │   ├── ppdl/
    │   │   │   ├── hmm.0.result
    │   │   │   ├── hmm.1.result
    │   │   │   ├── name_finder.0.result
    │   │   │   ├── name_finder.1.result
    │   │   │   ├── name_finder.10.result
    │   │   │   ├── name_finder.11.result
    │   │   │   ├── name_finder.12.result
    │   │   │   ├── name_finder.13.result
    │   │   │   ├── name_finder.14.result
    │   │   │   ├── name_finder.15.result
    │   │   │   ├── name_finder.16.result
    │   │   │   ├── name_finder.17.result
    │   │   │   ├── name_finder.18.result
    │   │   │   ├── name_finder.19.result
    │   │   │   ├── name_finder.2.result
    │   │   │   ├── name_finder.20.result
    │   │   │   ├── name_finder.21.result
    │   │   │   ├── name_finder.22.result
    │   │   │   ├── name_finder.23.result
    │   │   │   ├── name_finder.24.result
    │   │   │   ├── name_finder.25.result
    │   │   │   ├── name_finder.26.result
    │   │   │   ├── name_finder.27.result
    │   │   │   ├── name_finder.28.result
    │   │   │   ├── name_finder.29.result
    │   │   │   ├── name_finder.3.result
    │   │   │   ├── name_finder.30.result
    │   │   │   ├── name_finder.31.result
    │   │   │   ├── name_finder.32.result
    │   │   │   ├── name_finder.33.result
    │   │   │   ├── name_finder.34.result
    │   │   │   ├── name_finder.4.result
    │   │   │   ├── name_finder.5.result
    │   │   │   ├── name_finder.6.result
    │   │   │   ├── name_finder.7.result
    │   │   │   ├── name_finder.8.result
    │   │   │   └── name_finder.9.result
    │   │   ├── prompt_library/
    │   │   │   ├── gsm8k_cot.0.result
    │   │   │   ├── gsm8k_cot.1.result
    │   │   │   ├── gsm8k_cot.2.result
    │   │   │   ├── gsm8k_cot.3.result
    │   │   │   ├── gsm8k_cot.4.result
    │   │   │   ├── gsm8k_cot.5.result
    │   │   │   ├── gsm8k_cot.6.result
    │   │   │   ├── gsm8k_prob_react.0.txt
    │   │   │   ├── gsm8k_react.0.result
    │   │   │   ├── gsm8k_react.1.result
    │   │   │   ├── gsm8k_react.2.result
    │   │   │   ├── gsm8k_react.3.result
    │   │   │   ├── gsm8k_react.4.result
    │   │   │   ├── gsm8k_react.5.result
    │   │   │   ├── gsm8k_react.6.result
    │   │   │   ├── gsm8k_react.7.result
    │   │   │   ├── gsm8k_react.8.result
    │   │   │   ├── gsm8k_rewoo.0.result
    │   │   │   ├── gsm8k_rewoo.1.result
    │   │   │   ├── gsm8k_rewoo.2.result
    │   │   │   ├── gsm8k_rewoo.3.result
    │   │   │   ├── gsm8k_rewoo.4.result
    │   │   │   └── gsm8k_rewoo.5.result
    │   │   ├── rag/
    │   │   │   ├── tfidf_rag.0.result
    │   │   │   ├── tfidf_rag.1.result
    │   │   │   ├── tfidf_rag.10.result
    │   │   │   ├── tfidf_rag.2.result
    │   │   │   ├── tfidf_rag.3.result
    │   │   │   ├── tfidf_rag.4.result
    │   │   │   ├── tfidf_rag.5.result
    │   │   │   ├── tfidf_rag.6.result
    │   │   │   ├── tfidf_rag.7.result
    │   │   │   ├── tfidf_rag.8.result
    │   │   │   └── tfidf_rag.9.result
    │   │   ├── react/
    │   │   │   ├── react_demo.0.result
    │   │   │   ├── react_demo.1.result
    │   │   │   ├── react_demo.2.result
    │   │   │   ├── react_demo.3.result
    │   │   │   ├── react_demo.4.result
    │   │   │   ├── react_demo.5.result
    │   │   │   └── react_demo.6.result
    │   │   ├── skeleton-of-thought/
    │   │   │   ├── tips.0.result
    │   │   │   ├── tips.1.result
    │   │   │   └── tips.2.result
    │   │   ├── teacher/
    │   │   │   ├── teacher.0.result
    │   │   │   ├── teacher.1.result
    │   │   │   ├── teacher.2.result
    │   │   │   ├── teacher.3.result
    │   │   │   ├── teacher.4.result
    │   │   │   ├── teacher.5.result
    │   │   │   └── teacher.6.result
    │   │   ├── tools/
    │   │   │   ├── calc.0.result
    │   │   │   ├── calc.1.result
    │   │   │   ├── calc.2.result
    │   │   │   ├── search.0.result
    │   │   │   ├── search.1.result
    │   │   │   ├── search.2.result
    │   │   │   ├── search.3.result
    │   │   │   └── search.4.result
    │   │   └── tutorial/
    │   │       ├── calling_llm.0.result
    │   │       ├── calling_llm_chaining.0.result
    │   │       ├── calling_llm_chaining.1.result
    │   │       ├── calling_llm_chaining.2.result
    │   │       ├── calling_llm_with_input.0.result
    │   │       ├── calling_llm_with_input.1.result
    │   │       ├── calling_llm_with_input.2.result
    │   │       ├── calling_llm_with_input.3.result
    │   │       ├── calling_llm_with_input_messages.0.result
    │   │       ├── calling_llm_with_input_messages.1.result
    │   │       ├── calling_llm_with_input_messages.2.result
    │   │       ├── calling_llm_with_input_messages.3.result
    │   │       ├── calling_llm_with_input_messages_var.0.result
    │   │       ├── calling_llm_with_input_messages_var.1.result
    │   │       ├── calling_llm_with_input_messages_var.2.result
    │   │       ├── code_command.0.result
    │   │       ├── code_jinja.0.result
    │   │       ├── code_jinja_parameters.0.result
    │   │       ├── code_pdl.0.result
    │   │       ├── code_pdl.1.result
    │   │       ├── code_python.0.result
    │   │       ├── code_python.1.result
    │   │       ├── code_python.10.result
    │   │       ├── code_python.11.result
    │   │       ├── code_python.12.result
    │   │       ├── code_python.13.result
    │   │       ├── code_python.14.result
    │   │       ├── code_python.15.result
    │   │       ├── code_python.16.result
    │   │       ├── code_python.17.result
    │   │       ├── code_python.18.result
    │   │       ├── code_python.19.result
    │   │       ├── code_python.2.result
    │   │       ├── code_python.20.result
    │   │       ├── code_python.21.result
    │   │       ├── code_python.22.result
    │   │       ├── code_python.23.result
    │   │       ├── code_python.24.result
    │   │       ├── code_python.25.result
    │   │       ├── code_python.3.result
    │   │       ├── code_python.4.result
    │   │       ├── code_python.5.result
    │   │       ├── code_python.6.result
    │   │       ├── code_python.7.result
    │   │       ├── code_python.8.result
    │   │       ├── code_python.9.result
    │   │       ├── code_scope.0.result
    │   │       ├── code_session.0.result
    │   │       ├── data_block_raw.0.result
    │   │       ├── defs.0.result
    │   │       ├── defs.1.result
    │   │       ├── defs.2.result
    │   │       ├── defs.3.result
    │   │       ├── defs.4.result
    │   │       ├── for.0.result
    │   │       ├── for_array.0.result
    │   │       ├── for_lastOf.0.result
    │   │       ├── for_multiple_lists.0.result
    │   │       ├── for_object.0.result
    │   │       ├── for_with.0.result
    │   │       ├── free_variables.0.result
    │   │       ├── function_alias.0.result
    │   │       ├── function_call_in_jinja.0.result
    │   │       ├── function_call_in_jinja.1.result
    │   │       ├── function_definition.0.result
    │   │       ├── function_definition.1.result
    │   │       ├── function_definition.2.result
    │   │       ├── function_definition.3.result
    │   │       ├── function_definition.4.result
    │   │       ├── function_empty_context.0.result
    │   │       ├── function_empty_context.1.result
    │   │       ├── function_optional_params.0.result
    │   │       ├── if.0.result
    │   │       ├── import.0.result
    │   │       ├── import_lib.0.result
    │   │       ├── input_file.0.result
    │   │       ├── input_file_json.0.result
    │   │       ├── input_stdin.0.result
    │   │       ├── input_stdin_multiline.0.result
    │   │       ├── lastOf.0.result
    │   │       ├── lastOf.1.result
    │   │       ├── lastOf.2.result
    │   │       ├── local_computation.0.result
    │   │       ├── loop_index.0.result
    │   │       ├── muting_block_output.0.result
    │   │       ├── muting_block_output.1.result
    │   │       ├── muting_block_output.2.result
    │   │       ├── muting_block_output.3.result
    │   │       ├── parser-regex.0.result
    │   │       ├── parser_findall.0.result
    │   │       ├── parser_regex_code.0.result
    │   │       ├── parser_regex_code.1.result
    │   │       ├── parser_regex_code.2.result
    │   │       ├── parser_regex_code.3.result
    │   │       ├── pdl_scope.0.result
    │   │       ├── pdl_scope.1.result
    │   │       ├── pdl_usage.0.result
    │   │       ├── programs/
    │   │       │   ├── chatbot.0.result
    │   │       │   ├── chatbot.1.result
    │   │       │   ├── chatbot.2.result
    │   │       │   ├── chatbot.3.result
    │   │       │   ├── chatbot.4.result
    │   │       │   ├── chatbot.5.result
    │   │       │   ├── chatbot.6.result
    │   │       │   ├── chatbot.7.result
    │   │       │   ├── chatbot.8.result
    │   │       │   ├── code/
    │   │       │   │   ├── code-eval.0.result
    │   │       │   │   ├── code-eval.1.result
    │   │       │   │   ├── code-eval.10.result
    │   │       │   │   ├── code-eval.2.result
    │   │       │   │   ├── code-eval.3.result
    │   │       │   │   ├── code-eval.4.result
    │   │       │   │   ├── code-eval.5.result
    │   │       │   │   ├── code-eval.6.result
    │   │       │   │   ├── code-eval.7.result
    │   │       │   │   ├── code-eval.8.result
    │   │       │   │   ├── code-eval.9.result
    │   │       │   │   ├── code-json.0.result
    │   │       │   │   ├── code-json.1.result
    │   │       │   │   ├── code-json.2.result
    │   │       │   │   ├── code-json.3.result
    │   │       │   │   ├── code-json.4.result
    │   │       │   │   ├── code-json.5.result
    │   │       │   │   ├── code-json.6.result
    │   │       │   │   ├── code-json.7.result
    │   │       │   │   ├── code-json.8.result
    │   │       │   │   ├── code-json.9.result
    │   │       │   │   ├── code.0.result
    │   │       │   │   ├── code.1.result
    │   │       │   │   ├── code.10.result
    │   │       │   │   ├── code.2.result
    │   │       │   │   ├── code.3.result
    │   │       │   │   ├── code.4.result
    │   │       │   │   ├── code.5.result
    │   │       │   │   ├── code.6.result
    │   │       │   │   ├── code.7.result
    │   │       │   │   ├── code.8.result
    │   │       │   │   └── code.9.result
    │   │       │   ├── demo-hallucination.0.result
    │   │       │   ├── weather.0.result
    │   │       │   ├── weather.1.result
    │   │       │   ├── weather.2.result
    │   │       │   ├── weather.3.result
    │   │       │   ├── weather.4.result
    │   │       │   ├── weather.5.result
    │   │       │   ├── weather.6.result
    │   │       │   ├── weather.7.result
    │   │       │   └── weather.8.result
    │   │       ├── repeat.0.result
    │   │       ├── role.0.result
    │   │       ├── role.1.result
    │   │       ├── role.2.result
    │   │       ├── sdk/
    │   │       │   └── hello.0.result
    │   │       ├── simple_program.0.result
    │   │       ├── structured_decoding.0.result
    │   │       ├── structured_decoding.1.result
    │   │       ├── type_checking.0.result
    │   │       ├── type_checking.1.result
    │   │       ├── type_checking.2.result
    │   │       ├── variable_def_use.0.result
    │   │       └── while.0.result
    │   ├── pdl-live-react/
    │   │   ├── demos/
    │   │   │   ├── demo1.0.result
    │   │   │   ├── demo2.0.result
    │   │   │   └── demo2.1.result
    │   │   └── src-tauri/
    │   │       └── tests/
    │   │           └── cli/
    │   │               ├── call-no-args.0.result
    │   │               ├── call-with-args.0.result
    │   │               ├── code-python.0.result
    │   │               ├── data1.0.result
    │   │               ├── data2.0.result
    │   │               ├── data3.0.result
    │   │               ├── data4.0.result
    │   │               ├── if1.0.result
    │   │               ├── if2.0.result
    │   │               ├── include1.0.result
    │   │               ├── json-parser-lastOf.0.result
    │   │               ├── json-parser.0.result
    │   │               ├── jsonl-parser.0.result
    │   │               ├── model-input-array.0.result
    │   │               ├── model-input-array.1.result
    │   │               ├── model-input-array.2.result
    │   │               ├── model-input-array.3.result
    │   │               ├── model-input-array.4.result
    │   │               ├── model-input-array.5.result
    │   │               ├── model-input-array.6.result
    │   │               ├── model-input-array.7.result
    │   │               ├── model-input-array.8.result
    │   │               ├── model-input-array.9.result
    │   │               ├── model-input-nested.0.result
    │   │               ├── model-input-nested.1.result
    │   │               ├── model-input-nested.10.result
    │   │               ├── model-input-nested.2.result
    │   │               ├── model-input-nested.3.result
    │   │               ├── model-input-nested.4.result
    │   │               ├── model-input-nested.5.result
    │   │               ├── model-input-nested.6.result
    │   │               ├── model-input-nested.7.result
    │   │               ├── model-input-nested.8.result
    │   │               ├── model-input-nested.9.result
    │   │               ├── model-input-string.0.result
    │   │               ├── model-input-string.1.result
    │   │               ├── model-input-string.2.result
    │   │               ├── model-input-string.3.result
    │   │               ├── model-input-string.4.result
    │   │               ├── model-input-string.5.result
    │   │               ├── model-input-string.6.result
    │   │               ├── model-input-string.7.result
    │   │               ├── object1.0.result
    │   │               ├── object2.0.result
    │   │               ├── read-file.0.result
    │   │               ├── regex-findall.0.result
    │   │               ├── regex-findall.1.result
    │   │               ├── repeat1.0.result
    │   │               ├── repeat2.0.result
    │   │               ├── repeat3.0.result
    │   │               ├── scoping_1.0.result
    │   │               ├── scoping_1_wrapper.0.result
    │   │               └── tips.0.result
    │   ├── src/
    │   │   └── pdl/
    │   │       └── pdl_stdlib.0.result
    │   └── tests/
    │       └── data/
    │           ├── call_expression_args.12.result
    │           ├── function.0.result
    │           ├── hello.0.result
    │           └── optimizer_gsm8k.0.result
    ├── test_array.py
    ├── test_ast_utils.py
    ├── test_code.py
    ├── test_cond.py
    ├── test_context.py
    ├── test_data.py
    ├── test_defaults.py
    ├── test_defs.py
    ├── test_dump.py
    ├── test_errors.py
    ├── test_examples_parse.py
    ├── test_examples_run.py
    ├── test_examples_run.yaml
    ├── test_expr.py
    ├── test_fallback.py
    ├── test_for.py
    ├── test_function.py
    ├── test_include.py
    ├── test_independent.py
    ├── test_input.py
    ├── test_lib_version.py
    ├── test_line_table.py
    ├── test_linter.py
    ├── test_match.py
    ├── test_messages.py
    ├── test_model.py
    ├── test_object.py
    ├── test_optimizer.py
    ├── test_parse.py
    ├── test_parser.py
    ├── test_repeat.py
    ├── test_retry.py
    ├── test_role.py
    ├── test_runtime_errors.py
    ├── test_schema.py
    ├── test_secrets_redaction.py
    ├── test_sequence.py
    ├── test_type_checking.py
    └── test_var.py

================================================
FILE CONTENTS
================================================

================================================
FILE: .flake8
================================================
[flake8]
    max-line-length = 89
    max-complexity = 18
    extend-ignore = E203, E501


================================================
FILE: .github/ISSUE_TEMPLATE/bug_report.md
================================================
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
PDL program and command

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
 - OS: [e.g. iOS]
 - Browser [e.g. Chrome, Safari]
 - Version [e.g. 22]

**Additional context**
Add any other context about the problem here.


================================================
FILE: .github/ISSUE_TEMPLATE/feature_request.md
================================================
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: feature
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.


================================================
FILE: .github/actions/ollama/action.yml
================================================
name: 'Ollama Setup'
description: 'Composte action for Ollama set up in GH environment'
runs:
  using: 'composite'
  steps:
    - name: Remove unnecessary files
      shell: bash
      run: |
        sudo rm -rf /usr/share/dotnet
        sudo rm -rf "$AGENT_TOOLSDIRECTORY"

      # Set up Ollama
    - name: Install Ollama and start server
      shell: bash
      run: |
        curl -fsSL https://ollama.com/install.sh | sudo -E sh

    - name: Wait for Ollama server
      shell: bash
      run: |
        max_attempts=30
        attempt=1
        sleep 15
        
        while [ $attempt -le $max_attempts ]; do
          echo "Attempt $attempt of $max_attempts..."
          if time curl -i http://localhost:11434; then
            echo "✅ Ollama server is ready!"
            exit 0
          else
            echo "❌ Attempt $attempt failed"
            if [ $attempt -lt $max_attempts ]; then
              echo "Retrying in 10 seconds..."
              sleep 10
            fi
          fi
          attempt=$((attempt + 1))
        done
        
        echo "❌ Failed to connect to Ollama server after $max_attempts attempts"
        exit 1

    - name: Pull models in examples/
      shell: bash
      run: |
        ollama pull granite4:micro
        ollama pull mxbai-embed-large
        ollama list

    - name: Check that all required models are available
      shell: bash
      run: |
        models=("mxbai-embed-large" "granite4:micro")
        missing=0
        for model in "${models[@]}"; do
          if ! ollama list | awk 'NR>1 {print $1}' | grep -q "$model"; then
            echo "❌ Model $model is missing!"
            missing=1
          fi
        done

        if [ "$missing" -eq 1 ]; then
          exit 1
        else
          echo "✅ All expected models are available."
        fi


================================================
FILE: .github/actions/run-examples/action.yml
================================================
name: 'Ollama Setup'
description: 'Composte action to set up Run Examples'
inputs:
  python-version:
    description: 'Python version'
    required: true
    default: '3.11'
  runner-os:
    description: 'Runner OS'
    required: true
  repository:
    description: 'Repository name this pull request is initiated from'
    required: false
  head-ref:
    description: 'Head ref of the repo'
    required: false
    default: 'main'
  token: 
    description: 'Github token'
    required: false 
  update-results:
    description: 'Whether to update the results for this run. Must be false for nightly runs'
    required: true
  check:
    description: 'Files to patch tests/test_examples_run.yaml with. These are the PDL files that the test will run against. Defaults to all PDL files.'
    required: false
    default: '[]'
runs:
  using: 'composite'
  steps:
    # # Set up Ollama
    - uses: ./.github/actions/ollama

    # Configure Run Examples environment
    - uses: actions/checkout@v6
      with:
        token: ${{ inputs.token }}
        ref: ${{ inputs.head-ref }}
        repository: ${{ inputs.repository }}
        fetch-depth: 0
    
    - name: Patch tests/test_examples_run.yaml check with modified files
      shell: bash 
      run: |
        yq -i '.check = (${{ inputs.check }})' tests/test_examples_run.yaml
        
    - name: Print test Run Examples config
      shell: bash
      run: cat tests/test_examples_run.yaml

    # Run tests
    - name: Set up Python ${{ inputs.python-version }}
      uses: actions/setup-python@v6
      with:
        python-version: ${{ inputs.python-version }}
    - name: Cache pip
      uses: actions/cache@v5
      with:
        # This path is specific to Ubuntu
        path: ${{ env.pythonLocation }}
        # Look to see if there is a cache hit for the setup file
        key: ${{ inputs.runner-os }}-pip-new3-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}
        restore-keys: |
          ${{ inputs.runner-os }}-pip-new3
          ${{ inputs.runner-os }}-new3
    - name: Install dependencies
      shell: bash
      run: pip install --upgrade --upgrade-strategy eager .[all]
    - name: Pip list packages
      shell: bash
      run: pip list
    - name: Run Pytest
      shell: bash
      run: |
        cat tests/test_examples_run.yaml        
        (
          set +e
          py.test -v --capture=tee-sys -rfE -s tests/test_examples_run.py --disable-pytest-warnings
          EXIT_CODE=$?

          if [ $EXIT_CODE -eq 0 ]; then
            echo "TEST_RESULT=PASSED" >> $GITHUB_ENV
          else
            echo "TEST_RESULT=FAILED" >> $GITHUB_ENV
          fi
        )
    
    # Commit the results if update results
    - name: Push new results to branch
      shell: bash
      if: ${{ inputs.update-results == 'true' }}
      run: |
        git config --local user.name github-actions[bot]
        git config --local user.email 41898282+github-actions[bot]@users.noreply.github.com
        git status
        git pull origin ${{ inputs.head-ref }}
        git add tests/results/
        git diff --cached --quiet || git commit -s -m "github-actions[bot]: Run examples: updated result files on your behalf"
        # git push origin ${{ inputs.head-ref }}
        git push https://x-access-token:${{ inputs.token }}@github.com/${{ inputs.repository }} HEAD:${{ inputs.head-ref }}

    - name: Check if pytest passed
      shell: bash
      run: |
        if [ "$TEST_RESULT" == "PASSED" ]; then
          exit 0
        else
            exit 1
        fi


================================================
FILE: .github/dependabot.yml
================================================
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
  - package-ecosystem: "pip" # See documentation for possible values
    directory: "/" # Location of package manifests
    schedule:
      interval: "weekly"

  # Maintain dependencies for npm
  - package-ecosystem: "npm"
    directory: "/pdl-live"
    schedule:
      interval: "weekly"


================================================
FILE: .github/workflows/build.yml
================================================
---
name: Build

on: [push, pull_request]

# cancel any prior runs for this workflow and this PR (or branch)
concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
  cancel-in-progress: true

jobs:
  tests:
    name: static checks / linters
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        python-version: ['3.11', '3.12', '3.14']

    steps:
    - uses: actions/checkout@v6
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v6
      with:
        python-version: ${{ matrix.python-version }}
    - name: Cache pip
      uses: actions/cache@v5
      with:
        # This path is specific to Ubuntu
        path: ${{ env.pythonLocation }}
        # Look to see if there is a cache hit for the setup file
        key: ${{ runner.os }}-pip-new3-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}
        restore-keys: |
          ${{ runner.os }}-pip-new3
          ${{ runner.os }}-new3
    - name: Install dependencies
      run: pip install --upgrade --upgrade-strategy eager .[all]
    - name: pip list packages
      run: pip list
    - name: show pip dependencies
      run: |
        pip install pipdeptree
        pipdeptree -fl
    - name: pre-commit checks
      run: pre-commit run -a
    - name: run tests
      run: py.test -v --capture=tee-sys --ignore=tests/test_examples_run.py --ignore=tests/test_schema.py tests
      if: matrix.python-version == '3.11'
    - name: run tests
      run: py.test -v --capture=tee-sys --ignore=tests/test_examples_run.py tests
      if: matrix.python-version != '3.11'



================================================
FILE: .github/workflows/mkdocs-gh-pages.yml
================================================
# Workflow for building and deploying a MkDocs site to GitHub Pages
name: Build Docs & Deploy to Pages

on:
  # Runs on pushes targeting the default branch
  push:
    branches:
      - "main"
    paths:
      - "mkdocs.yml"
      - "docs/**"
      - "pdl-live-react"

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
  contents: read
  pages: write
  id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
  group: "pages"
  cancel-in-progress: false

jobs:
  # Build docs
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v6
      # Schema
      - name: Copy schema
        run: |
          mkdir -p ./docs/dist
          cp ./src/pdl/pdl-schema.json ./docs/dist/pdl-schema.json
      # Docs
      - name: Setup Pages
        uses: actions/configure-pages@v6
      - name: Setup Python
        uses: actions/setup-python@v6
        with:
          python-version: '3.14'
      - name: Install required packages
        run: pip install -U mkdocs "mkdocstrings[python]" mkdocs-material pymdown-extensions
      - name: Build site (_site directory name is used for Jekyll compatiblity)
        run: mkdocs build --config-file ./mkdocs.yml --strict --site-dir ./_site
        env:
          CI: true
      # Deploy
      - name: Upload artifact
        uses: actions/upload-pages-artifact@v5

  # Deployment job
  deploy:
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    runs-on: ubuntu-latest
    needs: build
    steps:
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v5


================================================
FILE: .github/workflows/pdl-live-react-tests.yml
================================================
name: Viewer Tests

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

# cancel any prior runs for this workflow and this PR (or branch)
concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
  cancel-in-progress: true

jobs:
  viewer:
    name: Test PDL live viewer
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: ./pdl-live-react
    steps:
      - uses: actions/checkout@v6
      - name: Set up node
        uses: actions/setup-node@v6
        with:
          node-version: 24
      - name: Install dependencies
        run: |
          npm ci & sudo apt update && sudo apt install -y libgtk-3-dev libwebkit2gtk-4.1-dev librsvg2-dev patchelf at-spi2-core
          wait
      - name: Install Playwright Browsers
        run: npx playwright install --with-deps
      - name: Test pdl-live viewer
        run: npm test


================================================
FILE: .github/workflows/publish-quay.yaml
================================================
name: Quay Publish

on:
  release:
    types: [published]

permissions:
  contents: read

env:
  REGISTRY: quay.io
  # github.repository as account/repo
  IMAGE_NAME: project_pdl/pdl 

jobs:
  # Build and push a multi-platform Docker image to Docker Hub
  publish-image:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write

    steps:
      - name: Checkout repository
        uses: actions/checkout@v6

      - name: Docker Setup QEMU
        uses: docker/setup-qemu-action@v4
        
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v4

      - name: Login to Docker Hub
        uses: docker/login-action@v4
        with:
          registry: ${{ env.REGISTRY }}
          username: ${{ secrets.QUAYIO_USERNAME }}
          password: ${{ secrets.QUAYIO_TOKEN }}          

      - name: Build and push ${{ github.ref_name }} to ${{ env.REGISTRY }}
        uses: docker/build-push-action@v7
        with:
          context: .
          platforms: linux/amd64,linux/arm64
          push: true
          tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest

================================================
FILE: .github/workflows/release-static-web-app.yml
================================================
name: 'Publish ui to static web site'

on:
  release:
    types:
      - released
  workflow_dispatch:

# This workflow will trigger on each push to the `release` branch to create or update a GitHub release, build your app, and upload the artifacts to the release.

jobs:
  publish-static-web-app:
    strategy:
      fail-fast: false

    runs-on: 'ubuntu-24.04'
    defaults:
      run:
        working-directory: ./pdl-live-react
    steps:
      - uses: actions/checkout@v6

      - name: setup node
        uses: actions/setup-node@v6
        with:
          node-version: lts/*

      - name: install dependencies (ubuntu only)
        run: |
          sudo apt-get update
          sudo apt-get install -y wget
          wget https://dl.min.io/client/mc/release/linux-amd64/mc
          chmod +x mc
          sudo mv mc /usr/local/bin/mc
      - name: configure minio client
        env:
          PDL_WEBSITE_S3_ENDPOINT: ${{ secrets.PDL_WEBSITE_S3_ENDPOINT }}
          PDL_WEBSITE_S3_ACCESS_KEY: ${{ secrets.PDL_WEBSITE_S3_ACCESS_KEY }}
          PDL_WEBSITE_S3_SECRET_KEY: ${{ secrets.PDL_WEBSITE_S3_SECRET_KEY }}
        run: |
          mc alias set s3 $PDL_WEBSITE_S3_ENDPOINT $PDL_WEBSITE_S3_ACCESS_KEY $PDL_WEBSITE_S3_SECRET_KEY --api s3v4

      - name: install frontend dependencies
        run: npm ci # change this to npm, pnpm or bun depending on which one you use.

      - name: build web site
        run: npm run build

      - name: upload web site
        env:
          PDL_WEBSITE_S3_PATH: ${{ secrets.PDL_WEBSITE_S3_PATH }}
        run: |
          cd dist
          mc mirror --overwrite --remove . s3/$PDL_WEBSITE_S3_PATH


================================================
FILE: .github/workflows/release-ui.yml
================================================
name: 'Publish ui to GitHub release'

on:
  release:
    types:
      - released
  workflow_dispatch:

# This workflow will trigger on each push to the `release` branch to create or update a GitHub release, build your app, and upload the artifacts to the release.

jobs:
  publish-tauri:
    permissions:
      contents: write
    strategy:
      fail-fast: false
      matrix:
        include:
          - platform: 'macos-latest' # for Arm based macs (M1 and above).
            args: '--target universal-apple-darwin'
          - platform: 'ubuntu-22.04-arm'
            args: '--target aarch64-unknown-linux-gnu' # <-- The system library `gdk-3.0` required by crate `gdk-sys` was not found.
          - platform: 'ubuntu-22.04'
            args: '--target x86_64-unknown-linux-gnu'
          - platform: 'windows-latest'
            args: ''

    runs-on: ${{ matrix.platform }}
    defaults:
      run:
        working-directory: ./pdl-live-react
    steps:
      - uses: actions/checkout@v6

      - name: setup node
        uses: actions/setup-node@v6
        with:
          node-version: lts/*

#      - name: install Rust stable
#        uses: dtolnay/rust-toolchain@stable
#        with:
#          # Those targets are only used on macos runners so it's in an `if` to slightly speed up windows and linux builds.
#          targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}

      - name: install dependencies (mac only)
        if: matrix.platform == 'macos-latest' # This must match the platform value defined above.
        run: |
          rustup target add aarch64-apple-darwin
          rustup target add x86_64-apple-darwin
          
      - name: install dependencies (ubuntu only)
        if: matrix.platform == 'ubuntu-22.04' || matrix.platform == 'ubuntu-22.04-arm' # This must match the platform value defined above.
        run: |
          sudo apt-get update
          sudo apt-get install -y libwebkit2gtk-4.1-dev librsvg2-dev patchelf libgtk-3-dev libglib2.0-dev xdg-utils
          ls /usr/lib/*-linux-gnu/pkgconfig/gdk*

      - name: install frontend dependencies
        run: npm ci # change this to npm, pnpm or bun depending on which one you use.

      - name: Install wget for Windows
        if: matrix.platform == 'windows-latest'
        run: choco install wget --no-progress

      - name: download tauri-action
        run: |
          mkdir tauri-action && cd tauri-action
          mkdir dist && cd dist
          wget https://raw.githubusercontent.com/tauri-apps/tauri-action/refs/heads/dev/dist/index.js
          wget https://raw.githubusercontent.com/tauri-apps/tauri-action/refs/heads/dev/dist/package.json
          cd ..
          wget https://raw.githubusercontent.com/tauri-apps/tauri-action/refs/heads/dev/action.yml
          cd ..
          
#      - uses: tauri-apps/tauri-action@v0
      - uses: ./pdl-live-react/tauri-action
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
          APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
          APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
          APPLE_ID: ${{ secrets.APPLE_ID }}
          APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
          APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
        with:
          tagName: v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version.
          releaseName: 'Version __VERSION__ (ui build test)'
          args: ${{ matrix.args }}


================================================
FILE: .github/workflows/release.yml
================================================
---
name: Publish prompt-declaration-language to PyPI and TestPyPI

on:
  # push:
  #   branches:
  #     - "main"
  release:
    types:
      - released
  workflow_dispatch:

jobs:
  build:
    name: Build distribution 📦
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v6
    - name: Set up Python
      uses: actions/setup-python@v6
      with:
        python-version: "3.x"
    - name: Install pypa/build
      run: >-
        python3 -m
        pip install
        build
        --user
    - name: Build a binary wheel and a source tarball
      run: python3 -m build
    - name: Store the distribution packages
      uses: actions/upload-artifact@v7
      with:
        name: python-package-distributions
        path: dist/

  publish-to-pypi:
    name: >-
      Publish prompt-declaration-language to PyPI
    if: startsWith(github.ref, 'refs/tags/')  # only publish to PyPI on tag pushes
    needs:
    - build
    runs-on: ubuntu-latest
    environment:
      name: pypi
      url: https://pypi.org/p/prompt-declaration-language
    permissions:
      id-token: write  # IMPORTANT: mandatory for trusted publishing

    steps:
    - name: Download all the dists
      uses: actions/download-artifact@v8
      with:
        name: python-package-distributions
        path: dist/
    - name: Publish distribution 📦 to PyPI
      uses: pypa/gh-action-pypi-publish@release/v1

  # github-release:
  #   name: >-
  #     Sign prompt-declaration-language with Sigstore
  #     and upload them to GitHub Release
  #   needs:
  #   - publish-to-pypi
  #   runs-on: ubuntu-latest

  #   permissions:
  #     contents: write  # IMPORTANT: mandatory for making GitHub Releases
  #     id-token: write  # IMPORTANT: mandatory for sigstore

  #   steps:
  #   - name: Download all the dists
  #     uses: actions/download-artifact@v4
  #     with:
  #       name: python-package-distributions
  #       path: dist/
  #   - name: Sign the dists with Sigstore
  #     uses: sigstore/gh-action-sigstore-python@v2.1.1
  #     with:
  #       inputs: >-
  #         ./dist/*.tar.gz
  #         ./dist/*.whl
  #   - name: Create GitHub Release
  #     env:
  #       GITHUB_TOKEN: ${{ github.token }}
  #     run: >-
  #       gh release create
  #       '${{ github.ref_name }}'
  #       --repo '${{ github.repository }}'
  #       --notes ""
  #   - name: Upload artifact signatures to GitHub Release
  #     env:
  #       GITHUB_TOKEN: ${{ github.token }}
  #     # Upload to GitHub Release using the `gh` CLI.
  #     # `dist/` contains the built packages, and the
  #     # sigstore-produced signatures and certificates.
  #     run: >-
  #       gh release upload
  #       '${{ github.ref_name }}' dist/**
  #       --repo '${{ github.repository }}'

  publish-to-testpypi:
    name: Publish prompt-declaration-language to TestPyPI
    needs:
    - build
    runs-on: ubuntu-latest

    environment:
      name: testpypi
      url: https://test.pypi.org/p/prompt-declaration-language

    permissions:
      id-token: write  # IMPORTANT: mandatory for trusted publishing

    steps:
    - name: Download all the dists
      uses: actions/download-artifact@v8
      with:
        name: python-package-distributions
        path: dist/
    - name: Publish distribution 📦 to TestPyPI
      uses: pypa/gh-action-pypi-publish@release/v1
      with:
        repository-url: https://test.pypi.org/legacy/
        verbose: true

================================================
FILE: .github/workflows/run-examples-prep.yml
================================================
---
name: Run examples on modified PDL files
on: [pull_request]
jobs:
  tests:
    name: Execution tests
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        python-version: ['3.11', '3.12', '3.14']
        
    steps:
    # Detect modified PDL files, includes Add, Modified, but not Deleted
    - uses: actions/checkout@v6
      with:
        fetch-depth: 0
    - name: Detect all PDL files that were changed or added
      id: changed-pdl-files
      uses: tj-actions/changed-files@24d32ffd492484c1d75e0c0b894501ddb9d30d62 # v47
      with:
        files: |
          **.pdl
        json: "true"
        escape_json: "false"
    - name: List PDL files that were modified or added and append to test_examples_run.yaml
      run: |
        echo ${{ steps.changed-pdl-files.outputs.all_changed_files }}
        if [ ${{ steps.changed-pdl-files.outputs.all_changed_files_count }} -gt 0 ]; then
          echo "early-stop=false" >> $GITHUB_ENV
        else
          echo "No file need to be checked, skipping all subsequent tests."
          echo "early-stop=true" >> $GITHUB_ENV
        fi

    - name: Run examples 
      uses:  ./.github/actions/run-examples
      # Only run if there are modified PDL files
      if:  env.early-stop == 'false'
      with: 
        python-version: ${{ matrix.python-version }}
        runner-os: ${{ runner.os }}
        repository: ${{ github.event.pull_request.head.repo.full_name }}
        head-ref: ${{ github.event.pull_request.head.ref }}
        token: ${{ github.token }}
        update-results: 'false'
        check: ${{ steps.changed-pdl-files.outputs.all_changed_files }}

================================================
FILE: .github/workflows/run-examples.yml
================================================
---
name: Run examples

on:
  schedule:
    - cron:  '0 1 * * *'
  workflow_dispatch:

jobs:
  tests:
    name: Execution tests
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        python-version: ['3.11', '3.12', '3.14']
    steps:
      - uses: actions/checkout@v6
        with:
          ref: ${{ github.head_ref }}
      - uses: ./.github/actions/run-examples
        with:
          python-version: ${{ matrix.python-version }}
          runner-os: ${{ runner.os }}
          repository: ${{ github.repository }}
          head-ref: ${{ github.head_ref }}
          token: ${{ github.token }}
          update-results: 'false'
          check: '[]'   # Empty list means run against all PDL programs
          


================================================
FILE: .github/workflows/rust-interpreter.yml
================================================
name: Rust Interpreter Tests

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]
  workflow_dispatch:

# cancel any prior runs for this workflow and this PR (or branch)
concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
  cancel-in-progress: true

jobs:
  rust-interpreter:
    name: Test Rust interpreter
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: ./pdl-live-react
    steps:
      - uses: actions/checkout@v6
      - name: Set up node
        uses: actions/setup-node@v6
        with:
          node-version: 24
      - name: Install dependencies
        # sleep 2 to wait for ollama to be running... hack warning
        run: |
          npm ci & sudo apt update && sudo apt install -y libgtk-3-dev libwebkit2gtk-4.1-dev librsvg2-dev patchelf at-spi2-core &
            (curl -fsSL https://ollama.com/install.sh | sudo -E sh && sleep 2)
          wait
      - name: Run interpreter tests
        run: |
          python3.12 -mvenv venv
          source venv/bin/activate
          pip install nested-diff
          npm run test:interpreter


================================================
FILE: .github/workflows/tauri-cli.yml
================================================
name: Tauri CLI Tests

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

# cancel any prior runs for this workflow and this PR (or branch)
concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
  cancel-in-progress: true

jobs:
  cli:
    name: Test pdl CLI using Tauri
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: ./pdl-live-react
    steps:
      - uses: actions/checkout@v6
      - name: Set up node
        uses: actions/setup-node@v6
        with:
          node-version: 24
      - name: Install dependencies
        # sleep 2 to wait for ollama to be running... hack warning
        run: |
          npm ci & sudo apt update && \
            sudo apt install -y libgtk-3-dev libwebkit2gtk-4.1-dev librsvg2-dev patchelf at-spi2-core && \
            (curl -fsSL https://ollama.com/install.sh | sudo -E sh && sleep 2)
          wait
      - name: Test production build  # Skip testing appimage, is this dangerous? It's slow...
        run: |
          npm run tauri build -- --ci --bundles deb
      - name: Install production build
        run: |
          ls ./src-tauri/target/release/bundle/deb && sudo apt install -y ./src-tauri/target/release/bundle/deb/*.deb
      - name: Setup xvfb for screen 0
        run: |
          Xvfb :1 -screen 0 1600x1200x24 &

      - name: Test 'pdl run' against production build
        env:
          DISPLAY: :1
        run: |
          # 1a. `run` subcommand errors due to missing required positional parameter
          pdl run && (echo "This should have failed" && exit 1) || (echo "Great, expected failure received" && exit 0)

          # 1b.`run` subcommand works without any arguments to print Usage
          pdl run 2>&1 | grep Usage

          # 1c.`run` subcommand works with -h to print Usage
          pdl run -h 2>&1 | grep Usage

          # 2. `run` subcommand works with UI demos (yaml source)
          pdl run ./demos/demo1.pdl | grep 'write a hello'

          # 3. `run` subcommand works with UI demos (json source)
          # demo4 depends on user input
          # demo5,demo6 each depend on an external file, and the interpreter does not currently capture this in the trace
          # demo8 currently requires building a model which the interpreter does not directly support
          # demo9 takes forever, so... for now skip it
          #for i in ./src/demos/*.json
          #do if [[ $(basename $i) != "demo4.json" ]] && [[ $(basename $i) != "demo5.json" ]] && [[ $(basename $i) != "demo6.json" ]] && [[ $(basename $i) != "demo8.json" ]] && [[  $(basename $i) != "demo9.json" ]]; then pdl run $i; fi
          #done

      - name: Tear down xvfb
        run: killall Xvfb || true


================================================
FILE: .gitignore
================================================
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
#  Usually these files are written by a python script from a template
#  before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
#   According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
#   However, in case of collaboration, if having platform-specific dependencies or dependencies
#   having no cross-platform support, pipenv may install dependencies that don't work, or not
#   install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

log.txt
log.out

# UI
ui/node_modules/
ui/package-lock.json

# TypeScript
pdl-live/node_modules
pdl-live/package-lock.json

# Latex
*.aux
*.fdb_latexmk
*.fls
*.synctex.gz


# PDL trace
*_result.json
*_result.yaml
*_trace.json

# Demo files
pdl-rag-demo.db
test.jsonl
train.jsonl
validation.jsonl
experiments/

# Built docs
_site

# Generated version
src/pdl/_version.py

# Emacs temps
*~

# Mac
.DS_Store

================================================
FILE: .pre-commit-config.yaml
================================================
---
default_language_version:
  python: python3
  node: system
repos:
  # check some basic stuff
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v5.0.0
    hooks:
      # Check for files that would conflict in case-insensitive filesystems
      - id: check-case-conflict
      # Check for files that contain merge conflict strings
      - id: check-merge-conflict
      # Check Python source for debugger imports and
      # py37+ `breakpoint()`
      - id: debug-statements
  # Clean up imports in Python using isort
  - repo: https://github.com/pycqa/isort
    rev: 6.0.1
    hooks:
      - id: isort
        args: [--filter-files, --profile, black]
  # Format the python code with black
  - repo: https://github.com/psf/black
    rev: 25.1.0
    hooks:
      - id: black
  # Lint the python code with flake
  - repo: https://github.com/PyCQA/flake8
    rev: 7.2.0
    hooks:
      - id: flake8
  # Type check the Python code with pylint
  - repo: local
    hooks:
      - id: pylint
        name: pylint
        entry: pylint
        language: python
        types: [python]
        additional_dependencies: ['pylint==4.0.3']
        args:
          [
            "-rn", # Only display messages
            "-sn", # Don't display the score
            "--rcfile=pylintrc"
          ]
  # run the bandit security linter
  - repo: https://github.com/PyCQA/bandit
    rev: 1.8.3
    hooks:
      - id: bandit
        args: [-c, bandit.yaml]
  # Type check the Python code with MyPy
  - repo: https://github.com/pre-commit/mirrors-mypy
    rev: 'v1.15.0'
    hooks:
      - id: mypy
        args: [--explicit-package-bases]
        verbose: true
        additional_dependencies: ['types-PyYAML']
  # type check the Python code using pyright
  - repo: local
    hooks:
      - id: pyright
        name: pyright
        entry: pyright
        language: node
        pass_filenames: false
        types: [python]
        additional_dependencies: ['pyright@1.1.381']


================================================
FILE: .vscode/launch.json
================================================
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Module",
            "type": "python",
            "request": "launch",
            "module": "src.pdl.pdl",
            "justMyCode": false,
            "args": [
                "examples/expectations/email.pdl",
                "--stream", "none",
                "--trace",
            ]
        }
    ]
    // "configurations": [
    //     {
    //         "name": "Python: Module",
    //         "type": "debugpy",
    //         "request": "launch",
    //         "program": "examples/sdk/hello_str.py",
    //         // "justMyCode": true,
    //     }
    // ]
    // "configurations": [
    //     {
    //         "name": "Python: Module",
    //         "type": "python",
    //         "request": "launch",
    //         "module": "pdl.benchmark",
    //         "justMyCode": true,
    //         "args": [ "-b", "gsm8k"
    //         ]
    //     }
    // ]
}

================================================
FILE: .vscode/settings.json
================================================
{
    "yaml.schemas": {
        "./src/pdl/pdl-schema.json": "*.pdl"
    },
    "files.associations": {
        "*.pdl": "yaml",
    },
    "python.testing.pytestArgs": [
        "."
    ],
    "python.testing.unittestEnabled": false,
    "python.testing.pytestEnabled": true
}


================================================
FILE: LICENSE
================================================
                              Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   APPENDIX: How to apply the Apache License to your work.

      To apply the Apache License to your work, attach the following
      boilerplate notice, with the fields enclosed by brackets "[]"
      replaced with your own identifying information. (Don't include
      the brackets!)  The text should be enclosed in the appropriate
      comment syntax for the file format. We also recommend that a
      file or class name and description of purpose be included on the
      same "printed page" as the copyright notice for easier
      identification within third-party archives.

   Copyright [yyyy] [name of copyright owner]

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.


================================================
FILE: README.md
================================================
# PDL (Prompt Declaration Language)

[![tests](https://github.com/IBM/prompt-declaration-language/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/IBM/prompt-declaration-language/actions?query=workflow%3Abuild+branch%3Amain)
[![night tests](https://github.com/IBM/prompt-declaration-language/actions/workflows/run-examples.yml/badge.svg?branch=main)](https://github.com/IBM/prompt-declaration-language/actions?query=workflow%3Arun-examples+branch%3Amain)
[![documentation](https://github.com/IBM/prompt-declaration-language/actions/workflows/mkdocs-gh-pages.yml/badge.svg?branch=main)](https://github.com/IBM/prompt-declaration-language/actions?query=workflow%3Amkdocs-gh-pages+branch%3Amain)
[![PyPI version shields.io](https://img.shields.io/pypi/v/prompt-declaration-language?color=success)](https://pypi.python.org/pypi/prompt-declaration-language/)
[![Quay Publish](https://github.com/IBM/prompt-declaration-language/actions/workflows/publish-quay.yaml/badge.svg)](https://github.com/IBM/prompt-declaration-language/actions/workflows/publish-quay.yaml)
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![linting: pylint](https://img.shields.io/badge/linting-pylint-yellowgreen)](https://github.com/PyCQA/pylint)
[![security: bandit](https://img.shields.io/badge/security-bandit-yellow.svg)](https://github.com/PyCQA/bandit)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/9672/badge)](https://bestpractices.coreinfrastructure.org/projects/9672)

PDL is a declarative language designed for developers to create reliable, composable LLM prompts and integrate them into software systems. It provides a structured way to specify prompt templates, enforce validation, and compose LLM calls with traditional rule-based systems.

[**Quick Start**](#quick-start) **|** [**Example**](#example-program-a-basic-llm-call) **|** [**GUI**](#graphical-experience) **|** [**Key Features**](#key-features) **|** [**Documentation**](#documentation) **|** [**API Cheat Sheet**](#api-cheat-sheet)

## Quick Start

A PDL program is written *declaratively*, in YAML. The `pdl` command
line tool interprets this program, accumulating messages and sending
them to the models as specified by your program. PDL supports both
hosted and local models. See
[here](https://ibm.github.io/prompt-declaration-language/tutorial/#using-ollama-models)
for instructions on how to install an Ollama model locally.

To install the `pdl` command line tool:

```bash
pip install prompt-declaration-language
```

## What's New

Check out <b>AutoPDL</b>, PDL's prompt optimizer tool [Spiess et al. (2025)](https://openreview.net/forum?id=CAeISyE3aR)! AutoPDL can be used to optimize any part of a PDL program. This includes few-shots examples and textual prompts, but also prompting patterns. It outputs an optimized PDL program with optimal values.

For a tutorial on how to use AutoPDL, see [AutoPDL](https://ibm.github.io/prompt-declaration-language/autopdl/)

## Example Program: A Basic LLM Call

<img src="docs/assets/pdl-ui-3.png" width="500" align="right" alt="PDL GUI"/>

The following program accumulates a single message `write a hello
world example…` and sends it to the `ollama/granite-3.2:8b` model:

```yaml
text:
- "write a hello world example, and explain how to run it"
- model: ollama/granite-3.2:8b
```

To run this program:

```bash
pdl <path/to/example.pdl>
```

For more information on the `pdl` CLI see
[here](https://ibm.github.io/prompt-declaration-language/). To try the
screenshot on the right live, click
[here](https://pdl.s3-web.us-east.cloud-object-storage.appdomain.cloud/#/demos/Simple%20LLM%20interaction).

## Graphical Experience

The screenshot on the right (above) shows PDL's graphical user
interface. This GUI allows for interactive debugging and live
programming. You may install this via `brew install pdl` on MacOS. For
other platforms, downloads are available
[here](https://github.com/IBM/prompt-declaration-language/releases/latest). You
may also kick the tires with a web version of the GUI
[here](https://pdl.s3-web.us-east.cloud-object-storage.appdomain.cloud/).

To generate a trace for use in the GUI:
```bash
pdl --trace <file.json> <my-example.pdl> 
```


<img src="docs/assets/ui.gif" alt="PDL GUI"/>

## Key Features

- **LLM Integration**: Compatible with any LLM, including IBM watsonx
- **Prompt Engineering**: 
  - Template system for single/multi-shot prompting
  - Composition of multiple LLM calls
  - Integration with tools (code execution & APIs)
- **Development Tools**:
  - Type checking for model I/O
  - Python SDK
  - Chat API support
  - Live document visualization for debugging
- **Control Flow**: Variables, conditionals, loops, and functions
- **I/O Operations**: File/stdin reading, JSON parsing
- **API Integration**: Native REST API support (Python)

## Documentation

- [Documentation](https://ibm.github.io/prompt-declaration-language/)
- [Tutorial](https://ibm.github.io/prompt-declaration-language/tutorial/)
- [API References](https://ibm.github.io/prompt-declaration-language/api_reference/)


### API Cheat Sheet

<img src="docs/assets/pdl_quick_reference.png" alt="PDL Quick Reference"/>


## Installation Details

PDL requires Python 3.11+ (Windows users should use WSL).

```bash
# Basic installation
pip install prompt-declaration-language

# Development installation with examples
pip install 'prompt-declaration-language[examples]'
```

### Environment Setup

You can run PDL with LLM models in local using [Ollama](https://ollama.com), or other cloud service.
See [here](https://ibm.github.io/prompt-declaration-language/tutorial/#using-ollama-models) for 
instructions on how to install an Ollama model locally.

If you use watsonx:
```bash
export WX_URL="https://{region}.ml.cloud.ibm.com"
export WX_API_KEY="your-api-key"
export WATSONX_PROJECT_ID="your-project-id"
```

If you use [Replicate](https://replicate.com/):
```bash
export REPLICATE_API_TOKEN="your-token"
```

### IDE Configuration 

Install the `YAML Language Support by Red Hat` extension in VSCode.
VSCode setup for syntax highlighting and validation:

```json
// .vscode/settings.json
{
    "yaml.schemas": {
        "https://ibm.github.io/prompt-declaration-language/dist/pdl-schema.json": "*.pdl"
    },
    "files.associations": {
        "*.pdl": "yaml",
    }
}
```

## Code Examples

### Variable Definition & Template Usage

In this example we use external content _data.yaml_ and watsonx as an LLM provider.

```yaml
description: Template with variables
defs:
  user_input:
    read: ../code/data.yaml
    parser: yaml
text:
- model: watsonx/ibm/granite-34b-code-instruct
  input: |
    Process this input: ${user_input}
    Format the output as JSON.
```

### Python Code Integration

```yaml
description: Code execution example
text:
- "\nFind a random number between 1 and 20\n"
- def: N
  lang: python
  code: |
    import random
    # (In PDL, set `result` to the output you wish for your code block.)
    result = random.randint(1, 20)
- "\nthe result is (${ N })\n"
```

### Chat

chat interactions:

```yaml
description: chatbot
text:
- read:
  def: user_input
  message: "hi? [/bye to exit]\n"
  contribute: [context]
- repeat:
    text:
    - model: ollama/granite-code:8b
    - read:
      def: user_input
      message: "> "
      contribute: [context]
  until: ${ user_input == '/bye'}
```


## Trace Telemetry

PDL includes experimental support for gathering trace telemetry.  This can
be used for debugging or performance analysis, and to see the shape of prompts sent by LiteLLM to models.

For more information see [here](https://github.com/IBM/prompt-declaration-language/blob/main/docs/telemetry.md).

<img src="https://ibm.github.io/prompt-declaration-language/assets/telemetry.png" alt="Trace Telemetry"/>



## Contributing

See the [contribution guidelines](https://ibm.github.io/prompt-declaration-language/contrib) for details on:
- Code style
- Testing requirements
- PR process
- Issue reporting

## References

- [PDL Schema](https://github.com/IBM/prompt-declaration-language/blob/main/src/pdl/pdl-schema.json)
- [arXiv Paper](http://arxiv.org/abs/2410.19135)



================================================
FILE: bandit.yaml
================================================
---
# This is the configuration file for the bandit python static analysis tool
exclude_dirs:
  - build
# We are less worried about tests, as they are not a part of the library meant to be used by users
# with untrusted inputs.
  - test
skips:
  - B101 # allow the use of assert


================================================
FILE: contrib/prompt_library/CoT.pdl
================================================
description: CoT pattern introduced by Wei et al. (2022)
defs:
  # Chain of Thought
  cot_block:
    function:
      question: string
      reasoning: string
      answer: string
    return: |-
      Question: ${ question }
      Answer: Let's think step by step. ${ reasoning }
      The answer is ${ answer }

  fewshot_cot:
    function:
      examples: [{ question: string, reasoning: string, answer: string }]
    return:
      text:
        - for:
            example: ${ examples }
          repeat:
            call: ${ cot_block }
            args:
              question: ${ example.question }
              reasoning: ${ example.reasoning }
              answer: ${ example.answer }
          join:
            with: "\n\n"

  chain_of_thought:
    function:
      question: string
      model: string
      examples: [{ question: string, reasoning: string, answer: string }]
    return:
      lastOf:
        - call: ${ fewshot_cot }
          args:
            examples: ${ examples }
        - "Question: ${ question }\n"
        - "Answer: Let's think step by step. "
        - model: ${ model }
          def: answer
          parameters:
            max_tokens: 1024
            temperature: 0
            stop:
              - "<|endoftext|>"
              - "Question:"
            include_stop_sequence: false
        - data:
            answer: ${ answer|trim }


================================================
FILE: contrib/prompt_library/ProbReAct.pdl
================================================
description: ReAct pattern from Yao et al., [ICLR 2023](https://openreview.net/forum?id=WE_vluYUL-X)
# See alternative implementation here: https://smith.langchain.com/hub/hwchase17/react-chat
defs:
  render_icl_sample:
    function:
      trajectory: [ object ]
    return:
      text:
        - for:
            trajectory: ${ trajectory }
          repeat:
            defs:
              type: ${ trajectory.keys()|first }
            match: ${ type }
            with:
              - case: question
                then: |
                  Question: ${ trajectory[type]|trim }
              - case: task
                then: |
                  Task: ${ trajectory[type]|trim }
              - case: thought
                then: |
                  Tho: ${ trajectory[type]|trim }
              - case: action
                then: |
                  Act: ${ trajectory[type]|trim }
              - case: observation
                then: |
                  Obs: ${ trajectory[type]|trim }
              - then: "${ type }: ${ trajectory[type]|trim }"
        - "\n"

  react:
    function:
      task: string
      model: string
      tool_schema: [ object ]
      tools: object
      trajectories: [ array ]
    return:
      lastOf:
        - role: system
          text:
            - "Today's Date: "
            - lang: python
              code: |
                from datetime import datetime
                result = datetime.today().strftime('%B %d, %Y.\n')
            - |
              You are a helpful assistant with access to the following function calls. Your task is to produce a sequence of function calls necessary to generate response to the user utterance. Use the following function calls as required.

              Respond in the format {"name": function name, "arguments": dictionary of argument name and its value}. Do not use variables.

              ${ tool_schema }
        - "\n"
        - for:
            traj: ${ trajectories }
          repeat:
            text:
              call: ${ render_icl_sample }
              args:
                trajectory: ${ traj }
        - ${ task }
        - defs:
            prev_action: null
            exit: false
            tool_names: ${ tool_schema|map(attribute='name')|list }
          repeat:
            text:
              - "\nTho: "
              - defs:
                  thought:
                    model: "${ model }"
                    parameters:
                      stop:
                        - "Act:"
                      max_tokens: 256
                      temperature: 0.7
                      include_stop_sequence: false
              - "${ thought|trim }"
              - "\nAct: "
              - defs:
                  action:
                    model: "${ model }"
                    parser: json
                    parameters:
                      temperature: 0.7
                      stop: ["\n", "Obs:", "<|eom_id|>"]
                      include_stop_sequence: false
                    spec: { name: string, arguments: object }
                    fallback:
                      defs:
                        _:
                          factor: ${ -10 }
                      data:
                        name: error
                        arguments: { msg: "failed to generate a valid action" }
              - "${ action|trim }"
              - match: ${ action.name.lower() }
                with:
                - case: finish
                  then:
                    def: exit
                    data: true
                    contribute: []
                - if: ${ action == prev_action }
                  then:
                    def: exit
                    data: true
                    contribute: []
                - if: ${ action.name.lower() in tools }
                  then:
                    def: observation
                    text:
                      - "\nObs: "
                      - call: ${ tools[action.name.lower()] }
                        args:
                          arguments: ${ action.arguments }
                - then:
                    def: observation
                    text:
                      - factor: -0.5
                      - "\nObs: "
                      - "Invalid action. Valid actions are ${ tool_names[:-1]|join(', ') }, and ${ tool_names[-1] }."

              - defs:
                  prev_action: ${ action }
                factor: -0.05
          until: ${ exit }
        - data:
            answer: ${ action.arguments.answer | trim }
          fallback:
            defs:
              _:
                factor: -10000
            data:
              answer: "No answer found."


================================================
FILE: contrib/prompt_library/ReAct.pdl
================================================
description: ReAct pattern from Yao et al., [ICLR 2023](https://openreview.net/forum?id=WE_vluYUL-X)
# See alternative implementation here: https://smith.langchain.com/hub/hwchase17/react-chat
defs:
  render_icl_sample:
    function:
      trajectory: [ object ]
    return:
      text:
        - for:
            trajectory: ${ trajectory }
          repeat:
            defs:
              type: ${ trajectory.keys()|first }
            match: ${ type }
            with:
              - case: question
                then: |
                  Question: ${ trajectory[type]|trim }
              - case: task
                then: |
                  Task: ${ trajectory[type]|trim }
              - case: thought
                then: |
                  Tho: ${ trajectory[type]|trim }
              - case: action
                then: |
                  Act: ${ trajectory[type]|trim }
              - case: observation
                then: |
                  Obs: ${ trajectory[type]|trim }
              - then: "${ type }: ${ trajectory[type]|trim }"
        - "\n"

  react:
    function:
      task: string
      model: string
      tool_schema: [ object ]
      tools: object
      trajectories: [ array ]
    return:
      lastOf:
        - role: system
          text:
            - "Today's Date: "
            - lang: python
              code: |
                from datetime import datetime
                result = datetime.today().strftime('%B %d, %Y.\n')
            - |
              You are a helpful assistant with access to the following function calls. Your task is to produce a sequence of function calls necessary to generate response to the user utterance. Use the following function calls as required.

              Respond in the format {"name": function name, "arguments": dictionary of argument name and its value}. Do not use variables.

              ${ tool_schema }
        - "\n"
        - for:
            traj: ${ trajectories }
          repeat:
            text:
              call: ${ render_icl_sample }
              args:
                trajectory: ${ traj }
        - ${ task }
        - defs:
            prev_action: null
            exit: false
            tool_names: ${ tool_schema|map(attribute='name')|list }
          repeat:
            text:
              - "\nTho: "
              - defs:
                  thought:
                    model: "${ model }"
                    parameters:
                      stop:
                        - "Act:"
                      max_tokens: 256
                      include_stop_sequence: false
              - "${ thought|trim }"
              - "\nAct: "
              - defs:
                  action:
                    model: "${ model }"
                    parser: json
                    parameters:
                      temperature: 1.0
                      stop: ["\n", "Obs:", "<|eom_id|>"]
                      include_stop_sequence: false
                    spec: { name: string, arguments: object }
                    fallback:
                      data:
                        name: error
                        arguments: { msg: "failed to generate a valid action" }
              - "${ action|trim }"
              - match: ${ action.name.lower() }
                with:
                - case: finish
                  then:
                    def: exit
                    data: true
                    contribute: []
                - if: ${ action == prev_action }
                  then:
                    def: exit
                    data: true
                    contribute: []
                - if: ${ action.name.lower() in tools }
                  then:
                    def: observation
                    text:
                      - "\nObs: "
                      - call: ${ tools[action.name.lower()] }
                        args:
                          arguments: ${ action.arguments }
                - then:
                    def: observation
                    text:
                      - "\nObs: "
                      - "Invalid action. Valid actions are ${ tool_names[:-1]|join(', ') }, and ${ tool_names[-1] }."

              - defs:
                  prev_action: ${ action }
          until: ${ exit }
        - data:
            answer: ${ action.arguments.answer | trim }
          fallback:
            data:
              answer: "No answer found."


================================================
FILE: contrib/prompt_library/ReWoo.pdl
================================================
description: ReWOO (Reasoning without observation) pattern from Xu et al., (http://arxiv.org/abs/2305.18323)
# Compared to ReAct, reduced token consumption (and thus execution time),
# by generating full chain of tools in a single pass
# see: https://github.com/langchain-ai/langgraph/blob/main/examples/rewoo/rewoo.ipynb
defs:
  rewoo_block:
    function:
      trajectory: [ object ]
    return:
      text:
        - defs:
            i:
              data: 1
        - for:
            trajectory: ${ trajectory }
          repeat:
            text:
              - defs:
                  type:
                    text: ${ trajectory.keys()|first }
                  content:
                    text: ${ trajectory.values()|first }
              - match: ${ type }
                with:
                  - case: task
                    then: |-
                      Task: ${ content|trim }
                  - case: question
                    then: |-
                      Task: ${ content|trim }
                  - case: thought
                    then: |-

                      Plan: ${ content|trim }
                  - case: action
                    then:
                      text:
                        - " #E${ i } = ${ content|trim }"
                        - defs:
                            i:
                              data: ${ i+1 }
                  - case: observation
                    then: ""
                  - if: ${ type not in ['question', 'task', 'thought', 'action', 'observation'] }
                    then: "${ type }: ${ content|trim }\n"
        - "\n"

  rewoo:
    function:
      task: string
      model: string
      tool_schema: [object]
      tools: object
      trajectories: array
      show_plans: boolean
    return:
      lastOf:
        - |
          For the following task, make plans that can solve the problem step by step. For each plan, indicate which external tool together with tool input to retrieve evidence. You can store the evidence into a variable #E that can be called by later tools. (Plan, #E1, Plan, #E2, Plan, ...)

          Tools can be one of the following:
          ${ tool_schema }
        - "\n"
        - for:
            traj: ${ trajectories }
          repeat:
            text:
              - call: ${ rewoo_block }
                args:
                  trajectory: ${ traj }
              - "\n"
        - |
          Begin!
          Describe your plans with rich details. Each Plan should be followed by only one #E.

          ${ task }
        - def: PLANS
          model: ${ model }
          contribute: []
          parser: # plan, step_name, tool, tool_input
            regex: 'Plan:\s*(?P<plan>(?:.|\n)*?)\s*(?P<step_name>#E\d+)\s*=\s*(?P<act>\{.+\})'
            mode: findall
          parameters:
            temperature: 0
            stop:
              - "<|endoftext|>"
              - "\n\n"
              - "Task:"
            include_stop_sequence: false
            max_tokens: 1024
        - if: ${ show_plans }
          contribute: [result, context]
          then:
            text:
              - "\n\n--- Raw plans ---\n"
              - ${ PLANS }
              - "\n\n--- Extracted Blueprint ---\n"
              - for:
                  plan: ${ PLANS }
                repeat:
                  text:
                    - "Plan: ${ plan[0] }\n"
                    - "${ plan[1] } = ${ plan[2] }\n"
              - "----------------------------\n\n"
        - defs:
            SOLUTION:
              text: "No plans found."
            output:
              data: {}
            plans:
              for:
                plan: ${ PLANS }
              repeat:
                lastOf:
                  - defs:
                      PLAN: ${ plan[0] }
                      ID: ${ plan[1] }
                      ACTION_RAW: ${ plan[2] }
                      ACTION:
                        parser: json
                        lang: python
                        code: |-
                          for k,v in output.items():
                            if k in ACTION_RAW:
                              ACTION_RAW = ACTION_RAW.replace(k, v)
                          result = ACTION_RAW
                      tool_output:
                        if: ${ ACTION.name.lower() in tools }
                        then:
                          call: ${ tools[ACTION.name.lower()] }
                          args:
                            arguments: ${ ACTION.arguments }
                        else: "Invalid action. Valid actions are ${ tools.keys() }"
                  - def: output
                    lang: python
                    contribute: []
                    code: |
                      output[ID] = str(tool_output)
                      result = output
                  - |
                    Plan: ${ PLAN }
                    Evidence: ${ tool_output }
        - if: ${ plans is not none and plans|length > 0 }
          then:
            text:
              - "\n\n"
              - def: solution_input
                text: |-
                  Solve the following task or problem. To solve the problem, we have made step-by-step Plan and retrieved corresponding Evidence to each Plan. Use them with caution since long evidence might contain irrelevant information.

                  ${ plans|join }
                  Now solve the question or task according to provided Evidence above. Respond with the answer directly with no extra words.

                  ${ task }
                  Response:
              - def: SOLUTION
                model: ${ model }
                parameters:
                  temperature: 0
                  stop:
                    - "<|endoftext|>"
                  include_stop_sequence: false
                  max_tokens: 1024
                input:
                  text: ${ solution_input }
        - data:
            answer: ${ SOLUTION|trim }


================================================
FILE: contrib/prompt_library/tools.pdl
================================================
description: Toolbox of PDL functions for agents
defs:
  # Note: Although PDL functions can be properly typed,
  # the input to a function via the LLM is fundamentally a string.
  # Therefore, parsing the input is the responsibility of the
  # function, not the caller. In the future, one could
  # imagine the use of constrained decoding to force
  # LLM to produce a type-compliant JSON as input.

  wrap_document:
    data: true

  filter_tools_by_name:
    function:
      tools: [object]
      tool_names: [string]
    return:
      data: ${ tools|selectattr('name', 'in', tool_names)|list }

  finish_action:
    data:
      name: finish
      description: Respond with the answer
      parameters:
        type: object
        properties:
          answer:
            type: str
            description: The answer
          required:
            - answer

  tool_schema:
    data:
      - name: calculator
        description: Calculator function
        parameters:
          type: object
          properties:
            expr:
              type: string
              description: Arithmetic expression to calculate
          required:
            - expr
      - name: Search
        description: Search Wikipedia for a summary
        parameters:
          type: object
          properties:
            topic:
              type: string
              description: The topic of interest
          required:
            - topic
      - ${ finish_action }

  tools:
    object:
      calculator:
        function:
          arguments: object
        return:
          lang: python
          code: |
            from sympy.parsing.sympy_parser import parse_expr
            result = None

            def main(expr: str, *args, **kwargs) -> str:
              try:
                exp = "${ arguments.expr|replace(",", "")|replace("$","")|replace("^","**")|replace("%","*0.01") }"

                result = float(parse_expr(exp).evalf())
                result = round(result, 2)
                if result.is_integer():
                  result = int(result)
              except Exception as e:
                  result = f"There was an error calculating: {e}. Please try again."

              return result

            result = main(**arguments)
      search:
        function:
          arguments: object
        return:
          lastOf:
            - def: result
              lang: python
              code: |
                import warnings, wikipedia
                warnings.simplefilter("ignore")

                def main(topic: str, *args, **kwargs) -> str:
                  try:
                    return wikipedia.summary(topic)
                  except wikipedia.DisambiguationError as d:
                    return f"\"{topic}\" may refer to one of {d.args[1]}. Please retry the search with a more specific subject."
                  except wikipedia.WikipediaException as e:
                    return str(e)

                result = main(**arguments)
            - if: ${ wrap_document }
              then: "[Document]\n${ result|trim }\n[End]"
              else: ${ result }


================================================
FILE: dockerfile
================================================
FROM python:3.14-slim

WORKDIR /pdl

RUN apt-get update && apt-get install -y git

COPY . /pdl

RUN pip install prompt-declaration-language[examples]

ENTRYPOINT ["pdl"]


================================================
FILE: docs/.nojekyll
================================================


================================================
FILE: docs/README.md
================================================
<!-- ---
hide:
  - navigation
  - toc
--- -->
# Prompt Declaration Language

LLMs will continue to change the way we build software systems. They are not only useful as coding assistants, providing snippets of code, explanations, and code transformations, but they can also help replace components that could only previously be achieved with rule-based systems. Whether LLMs are used as coding assistants or software components, reliability remains an important concern. LLMs have a textual interface and the structure of useful prompts is not captured formally. Programming frameworks do not enforce or validate such structures since they are not specified in a machine-consumable way. The purpose of the Prompt Declaration Language (PDL) is to allow developers to specify the structure of prompts and to enforce it, while providing a unified programming framework for composing LLMs with rule-based systems.

PDL is based on the premise that interactions with an LLM are mainly for the purpose of generating some kind of data. So PDL allows users to specify the shape of data to be generated in a declarative way (in YAML),  and is agnostic of any programming language. Because of its data-oriented nature, it can be used to easily express a variety of data generation tasks (inference, data synthesis, data generation for model training, etc...). PDL takes care of chat templates and accumulates input messages to LLMs implicitly, making it easier to interact with LLMs and less verbose.

PDL provides the following features:

- Ability to use any LLM locally or remotely via [LiteLLM](https://www.litellm.ai/), including [IBM's watsonx](https://www.ibm.com/watsonx), as well as the [Granite IO Processor](https://github.com/ibm-granite/granite-io) framework
- Ability to templatize not only prompts for one LLM call, but also composition of LLMs with tools (code and APIs). Templates can encompass tasks of larger granularity than a single LLM call
- Control structures: variable definitions and use, conditionals, loops, functions
- Ability to read from files and stdin, including JSON data
- Ability to call out to code and call REST APIs (Python)
- Type checking input and output of model calls, used for structured decoding
- Python SDK
- Support for chat APIs and chat templates
- Live Explorer, a UI tool for exploring traces and live programming

The PDL interpreter takes a PDL program as input and generates data by executing its instructions (calling out to models, code, etc...).

See below for a quick reference, followed by [installation notes](#interpreter-installation) and an [overview](#overview) of the language. A more detailed description of the language features can be found in this [tutorial](https://ibm.github.io/prompt-declaration-language/tutorial).


## Quick Reference

<img src="https://ibm.github.io/prompt-declaration-language/assets/pdl_quick_reference.png" alt="PDL Quick Reference"/>

(See also [PDF version](https://github.com/IBM/prompt-declaration-language/blob/main/docs/assets/pdl_quick_reference.pdf).)


## Interpreter Installation

The interpreter has been tested with Python versions **3.11**, **3.12**, and **3.14**, on macOS and Linux. For Windows, please use WSL.

To install the requirements for `pdl`, execute the command:

```
pip install prompt-declaration-language
```

To install the dependencies for development of PDL and execute all the example, execute the command:
```
pip install 'prompt-declaration-language[examples]'
```

The Live Explorer can be installed as follows (MacOS):
```
brew install pdl
```

For other platforms, see installation notes.

You can run PDL with LLM models in local using [Ollama](https://ollama.com), or other cloud service.
See [here](https://ibm.github.io/prompt-declaration-language/tutorial/#using-ollama-models) for
instructions on how to install an Ollama model locally.

Most examples in this repository use IBM Granite models on [Ollama](https://ollama.com) and some are on [Replicate](https://replicate.com/). In order to run these examples, you need to create a free account
on Replicate, get an API key and store it in the environment variable:

- `REPLICATE_API_TOKEN`

In order to use foundation models hosted on [watsonx](https://www.ibm.com/watsonx) via LiteLLM, you need a watsonx account (a free plan is available) and set up the following environment variables:

- `WX_URL`, the API url (set to `https://{region}.ml.cloud.ibm.com`) of your watsonx instance. The region can be found by clicking in the upper right corner of the watsonx dashboard (for example a valid region is `us-south` ot `eu-gb`).
- `WX_API_KEY`, the API key (see information on [key creation](https://cloud.ibm.com/docs/account?topic=account-userapikey&interface=ui#create_user_key))
- `WATSONX_PROJECT_ID`, the project hosting the resources (see information about [project creation](https://www.ibm.com/docs/en/watsonx/saas?topic=projects-creating-project) and [finding project ID](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-project-id.html?context=wx)).

For more information, see [documentation](https://docs.litellm.ai/docs/providers/watsonx).

To run the interpreter:

```
pdl <path/to/example.pdl>
```

The folder `examples` contains many examples of PDL programs. They cover a variety of prompting patterns such as CoT, RAG, ReAct, and tool use.

We highly recommend to edit PDL programs using an editor that support YAML with JSON Schema validation. For example, you can use VSCode with the [YAML extension](https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml) and configure it to use the [PDL schema](https://github.com/IBM/prompt-declaration-language/blob/main/src/pdl/pdl-schema.json). This enables the editor to display error messages when the yaml deviates from the PDL syntax and grammar. It also provides code completion.
The PDL repository has been configured so that every `*.pdl` file is associated with the PDL grammar JSONSchema (see [settings](https://github.com/IBM/prompt-declaration-language/blob/main/.vscode/settings.json)).  You can set up your own VSCode PDL projects similarly using the following `.vscode/settings.json` file:

```
{
    "yaml.schemas": {
        "https://ibm.github.io/prompt-declaration-language/dist/pdl-schema.json": "*.pdl"
    },
    "files.associations": {
        "*.pdl": "yaml",
    }
}
```

The interpreter executes Python code specified in PDL code blocks. To sandbox the interpreter for safe execution,
you can use the `--sandbox` flag which runs the interpreter in a Docker-compatible container. Without this flag, the interpreter
and all code is executed locally. To use the `--sandbox` flag, you need to have a Docker daemon running, such as
[Rancher Desktop](https://rancherdesktop.io).


We can pass initial data to the interpreter to populate variables used in a PDL program, as follows:

```
pdl --data <JSON-or-YAML-data> <my-example>
```

For an example, see [file](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/free_variables.pdl).

This can also be done by passing a JSON or YAML file:

```
pdl --data-file <JSON-or-YAML-file> <my-example>
```

The interpreter can also output a trace file that is used by the Live Explorer app (see [Live Document](#live-explorer)):

```
pdl --trace <file.json> <my-example>
```

The interpreter can be made to output the background context:
```
pdl --stream context <my-example>
```

For more information:
```
pdl --help
```

## Overview

In PDL, we can write some YAML to create a prompt and call an LLM:

```yaml
description: Simple LLM interaction
text:
- "Hello\n"
- model: ollama/granite-code:8b
  parameters:
    stop: ['!']
    temperature: 0
```

The `description` field is a description for the program. Field `text` contains a list of either strings or *block*s which together form the text to be produced. In this example, the text starts with the string `"Hello\n"` followed by a block that calls out to a model. In this case, it is model with id `ollama/granite-code:8b` on Ollama, via LiteLLM, with the indicated parameters: the stop sequence is `!`, and temperature set to `0`. Stop sequences are provided as a list of strings. The input to the model call is everything that has been produced so far in the program (here `"Hello\n"`).

When we execute this program using the PDL interpreter:

```
pdl examples/hello/hello.pdl
```

we obtain the following:

```
Hello
Hi there
```

where `Hi there` was produced by Granite. In general, PDL provides blocks for calling models, Python code, and makes it easy to compose them together with control structures (sequencing, conditions, loops).

A similar example on watsonx would look as follows:

```yaml
text:
- "Hello\n"
- model: watsonx/ibm/granite-34b-code-instruct
  parameters:
    stop: ['!']
    temperature: 0
```

Notice the syntactic differences. Model ids on watsonx start with `watsonx`.

Watsonx also provides a text completion endpoint as shown in the following example. A text completion endpoint does not take chat
templates into account:

```yaml
text:
- "Hello\n"
- model: watsonx_text/ibm/granite-34b-code-instruct
  parameters:
    stop: ['!']
    decoding_method: sample
```

Instead of providing `temperature: 0`, the user can write `decoding_method: greedy`, or choose `sample` as in the above example.


The same example on Replicate:

```yaml
text:
- "Hello\n"
- model: replicate/ibm-granite/granite-3.2-8b-instruct
  parameters:
    stop: "!"
    temperature: 0
```


A PDL program computes two data structures. The first is a JSON corresponding to the result of the overall program, obtained by aggregating the results of each block. This is what is printed by default when we run the interpreter. The second is a conversational background context, which is a list of role/content pairs, where we implicitly keep track of roles and content for the purpose of communicating with models that support chat APIs. The contents in the latter correspond to the results of each block. The conversational background context is the list of messages used to make calls to LLMs via LiteLLM.

The PDL interpreter can also stream the background conversation instead of the result:

```
pdl --stream context examples/hello/hello.pdl
```

See the [tutorial](https://ibm.github.io/prompt-declaration-language/tutorial) for more information about the conversational background context and how to use roles and chat templates.


Consider now an example from AI for code, where we want to build a prompt template for code explanation. We have a JSON file as input
containing the source code and some information regarding the repository where it came from.

For example, given the data in this JSON [file](https://github.com/IBM/prompt-declaration-language/blob/main/examples/examples/tutorial/programs/code/data.yaml):
```yaml
--8<-- "./examples/tutorial/programs/code/data.yaml"
```

we would like to express the following prompt and submit it to an LLM:

```
Here is some info about the location of the function in the repo.
repo:
streamsets/datacollector
path: stagesupport/src/main/java/com/.../OffsetUtil.java
Function_name: OffsetUtil.deserializeOffsetMap


Explain the following code:

@SuppressWarnings("unchecked")
public static Map<String, String> deserializeOffsetMap(String lastSourceOffset) throws IOException {
  Map<String, String> offsetMap;
  if (lastSourceOffset == null || lastSourceOffset.isEmpty()) {
    offsetMap = new HashMap<>();
  } else {
    offsetMap = JSON_MAPPER.readValue(lastSourceOffset, Map.class);
  }
  return offsetMap;
}
```

In PDL, this would be expressed as follows (see [file](https://github.com/IBM/prompt-declaration-language/blob/main/examples/tutorial/programs/code/code.pdl)):

```yaml
--8<-- "./examples/tutorial/programs/code/code.pdl"
```

In this program we first define some variables using the `defs` construct. Here `CODE` is defined to be a new variable, holding the result of the `read` block that follows.
A `read` block can be used to read from a file or stdin. In this case, we read the content of the file `./data.yaml`, parse it as YAML using the `parser` construct, then
assign the result to variable `CODE`.

Next we define a `text`, where the first block is simply a string and writes out the source code. This is done by accessing the variable `CODE`. The syntax `${ var }` is a Jinja expression and means accessing the value of a variable in the scope. Since `CODE` contains YAML data, we can also access fields such as `CODE.source_code`.

The second block calls a granite model on Ollama via LiteLLM. Here we explicitly provide an `input` field which means that we do not pass the entire text produced so far to the model, but only what is specified in this field. In this case, we specify our template by using the variable `CODE` as shown above.

When we execute this program with the PDL interpreter, we obtain the following text:

```


@SuppressWarnings("unchecked")
public static Map<String, String> deserializeOffsetMap(String lastSourceOffset) throws IOException {
  Map<String, String> offsetMap;
  if (lastSourceOffset == null || lastSourceOffset.isEmpty()) {
    offsetMap = new HashMap<>();
  } else {
    offsetMap = JSON_MAPPER.readValue(lastSourceOffset, Map.class);
  }
  return offsetMap;
}

The code is a Java method that takes a string `lastSourceOffset` as input and returns a `Map<String, String>`. The method uses the Jackson library to deserialize the JSON-formatted string into a map. If the input string is null or empty, an empty HashMap is returned. Otherwise, the string is deserialized into a Map using the `JSON_MAPPER.readValue()` method.
```

Notice that in PDL variables are used to templatize any entity in the document, not just textual prompts to LLMs. We can add a block to this document to evaluate the quality of the output using a similarity metric with respect to our [ground truth](https://github.com/IBM/prompt-declaration-language/blob/main/examples/tutorial/programs/code/ground_truth.txt). See [file](https://github.com/IBM/prompt-declaration-language/blob/main/examples/tutorial/programs/code/code-eval.pdl):

```yaml
--8<-- "./examples/tutorial/programs/code/code-eval.pdl"
```

This program has an input block that reads the ground truth from filename `examples/code/ground_truth.txt` and assigns its contents to variable `TRUTH`. It also assigns the output of the model to the variable `EXPLANATION`, using a `def` construct. In PDL, any block can have a `def` to capture the result of that block in a variable. The last block is a call to Python code, which is included after the `code` field. Notice how code is included here simply as data. We collate fragments of Python with outputs obtained from previous blocks. This is one of the powerful features of PDL: the ability to specify the execution of code that is not known ahead of time. We can use LLMs to generate code that is later executed in the same programming model. This is made possible because PDL treats code as data, like any another part of the document.

When we execute this new program, we obtain the following:

```


@SuppressWarnings("unchecked")
public static Map<String, String> deserializeOffsetMap(String lastSourceOffset) throws IOException {
  Map<String, String> offsetMap;
  if (lastSourceOffset == null || lastSourceOffset.isEmpty()) {
    offsetMap = new HashMap<>();
  } else {
    offsetMap = JSON_MAPPER.readValue(lastSourceOffset, Map.class);
  }
  return offsetMap;
}

The code is a Java method that takes a string `lastSourceOffset` as input and returns a `Map<String, String>`. The method uses the Jackson library to deserialize the JSON-formatted string into a map. If the input string is empty or null, an empty HashMap is returned. Otherwise, the string is deserialized into a Map using the `JSON_MAPPER.readValue()` method.


EVALUATION:
The similarity (Levenshtein) between this answer and the ground truth is:
0.3090614886731392
```

PDL allows rapid prototyping of prompts by allowing the user to change prompts and see their immediate effects on metrics. Try it!

Finally, we can output JSON data as a result of this program, as follows:

```yaml
--8<-- "./examples/tutorial/programs/code/code-json.pdl"
```

The data block takes various variables and combines their values into a JSON object with fields `input`, `output`, and `metric`.
The output of this program is the corresponding serialized JSON object, with the appropriate treatment of quotation marks. Similarly PDL can read jsonl files and create jsonl files by piping to a file.

## PDL Language Tutorial

See [PDL Language Tutorial](https://ibm.github.io/prompt-declaration-language/tutorial)

## Debugging Tools

### Live Explorer

PDL has a Live Explorer to help in program understanding given an execution trace.
To produce an execution trace consumable by the Live Explorer, you can run the interpreter with the `--trace` argument:

```
pdl <my-example> --trace <my-example_trace.json>
```

This produces an additional file named `my-example_trace.json` that can be uploaded to the [Live Explorer](https://ibm.github.io/prompt-declaration-language/viewer/) visualizer tool. The Live Explorer shows a timeline of execution and a tile for every block. By clicking on a tile, the user can discover more information such as input/context/output for LLM calls. It also provides the ability to re-run a block for eventual live programming.

This is similar to a spreadsheet for tabular data, where data is in the forefront and the user can inspect the formula that generates the data in each cell. In the Live Explorer, cells are not uniform but can take arbitrary extents. Clicking on them similarly reveals the part of the code that produced them.

### Trace Telemetry

PDL includes experimental support for gathering trace telemetry.  This can
be used for debugging or performance analysis, and to see the shape of prompts sent by LiteLLM to models.

For more information see [here](https://github.com/IBM/prompt-declaration-language/blob/main/docs/telemetry.md).

<img src="https://ibm.github.io/prompt-declaration-language/assets/telemetry.png" alt="Trace Telemetry"/>

## Best Practices

1. **Template Organization**:
    - Keep templates modular and reusable
    - Use variables for dynamic content
    - Document template purpose and requirements

2. **Error Handling**:

     - Validate model inputs/outputs
     - Include fallback logic
     - Log intermediate results

3. **Performance**:

     - Cache frequent LLM calls
     - Use appropriate temperature settings
     - Implement retry logic for API calls

4. **Security**:

     - Enabling sandbox mode for untrusted code
     - Validate all inputs
     - Follow API key best practices


## Additional Notes

When using Granite models, we use the following defaults for model parameters:

  - `temperature`: 0
  - `max_new_tokens`: 1024
  - `min_new_tokens`: 1
  - `repetition_penalty`: 1.05

  Also if the `decoding_method` is `sample` (for `watsonx_text` text completion endpoint on watsonx), then the following defaults are used:

  - `temperature`: 0.7
  - `top_p`: 0.85
  - `top_k`: 50

For a complete list of issues see [here](https://github.com/IBM/prompt-declaration-language/issues).


## Contributing to the Project

See [Contributing to PDL](https://ibm.github.io/prompt-declaration-language/contrib).


================================================
FILE: docs/api_reference.md
================================================
# API Reference

This page documents the PDL members that likely to be used to run PDL programs from Python.

## Program
::: src.pdl.pdl_ast

## Interpreter
::: src.pdl.pdl

<!-- 
::: pdl.pdl_interpreter

::: pdl.pdl_interpreter.InterpreterState
    options:
        show_if_no_docstring: true

::: pdl.pdl_interpreter.empty_scope
    options:
        show_if_no_docstring: true

::: pdl.pdl_interpreter.process_prog
    options:
        show_if_no_docstring: true -->


================================================
FILE: docs/autopdl.md
================================================
---
hide:
  - navigation
  - toc
  - footer
---

# AutoPDL Tutorial

This tutorial describes how to use AutoPDL, PDL's prompt optimizer tool [Spiess et al. (2025)](https://openreview.net/forum?id=CAeISyE3aR). AutoPDL can be used to optimize any part of a PDL program. This includes few-shots examples and textual prompts, but also prompting patterns. It outputs an optimized PDL program with optimal values.

## Installing AutoPDL

Please ensure PDL was installed with extras e.g.

``` { .bash .copy .annotate linenums="1" }
pip install 'prompt-declaration-language[all]'
# or from source
git clone git@github.com:IBM/prompt-declaration-language.git
cd prompt-declaration-language
pip install -e '.[all]'
```

## Writing a PDL program to optimize

The first step in using AutoPDL is to write a PDL program that has free variables. Consider for example, the following PDL program, which queries an LLM to correct a sentence with grammatical errors ([file](https://github.com/IBM/prompt-declaration-language/blob/main/examples/optimizer/grammar_correction.pdl)):

```yaml linenums="1"
--8<-- "./examples/optimizer/grammar_correction.pdl"
```

This program starts with a definition section. Note that a `defs` section is necessary. This is followed by a `lastOf` sequence (a list of blocks to be executed where the result of the last block is returned as the result of the whole sequence). First, the program establishes some demonstrations obtained from a `demonstrations` variable. The `for` loop at lines 5 to 10 ensures that all demonstrations are formatted in a consistent way. On lines 11 to 16 the program formulates a prompt to correct a sentence stored in variable `input`. Lines 17 through 21 show a model call where the model id is given by variable `model`. Finally, lines 23 through 28 check if variable `verify` is set to `true`. If so, it makes another model to verify the previous response and to produce a new one if needed.

Notice that variables `input`, `model`, `demonstrations`, `verify` are not defined. The first of these is an instance variable that will help in holding different instances when the optimizer is running. The rest of them are parameters to be optimized. We can pick among different models, different demonstrations, and especially different prompting patterns. PDL supports first-class functions, so the program could be made to pick the optimal function to be used, thereby choosing the prompting pattern. In this example, finding an optimal value for `verify` will determine whether it's best to call the model once or twice.



## Dataset

In addition to the PDL program, AutoPDL also needs a dataset. These will be used to perform the optimization, and as a source of demonstrations. The train split will be used to draw instances and demonstrations, the validation for checking during the optimization, and test to evaluate and obtain a final score at the end of the optimization run.

 In this example, we need a dataset containing sentences with mistakes and the corrected version. We can use [process_grammar_correction.py](https://github.com/IBM/prompt-declaration-language/blob/main/examples/optimizer/process_grammar_correction.py) to obtain a dataset split into train/validation/test. Simply run:

```
python process_grammar_correction.py
```

## Loss function

The loss function is use to guide the optimizer towards the best solution and evaluate the final program. The loss function can must be a PDL function named `score` that takes as input the result of the program, the ground truth, and returns a floating point number.
In our example, we are using the Levenshtein distance that we import from the `textdistance` Python module. The `score` function is defined in the [`eval_levenshtein.pdl` file](https://github.com/IBM/prompt-declaration-language/blob/main/examples/optimizer/eval_levenshtein.pdl):

```yaml
--8<-- "./examples/optimizer/eval_levenshtein.pdl"
```

The final ingredient needed is a configuration file as explained in the next section.

## Writing a configuration file

An AutoPDL configuration file describes the state-space and parameters for the search. In this example, the configuration is given in the following [file](https://github.com/IBM/prompt-declaration-language/blob/main/examples/optimizer/grammar_correction.yaml):

```yaml
--8<-- "./examples/optimizer/grammar_correction.yaml"
```

Field `pdl_path` is the path to the PDL program to optimize. `dataset` points to the dataset to be used. In this case, it's an object with paths for train/validation/test splits. 
`demonstrations_variable_name` gives the name of the PDL variable that will hold the demonstrations in the optimized program. `demonstration_columns` indicates the field names in the dataset that will be used to create demonstrations, and `instance_columns` are those fields that will be used to formulate an instance query (see the query in the PDL program above, which uses `input`). The `groundtruth_column` holds the field with the ground truth (in this case `output`). `eval_pdl` is the path of the PDL program that encapsulates the loss function.

`initial_validation_set_size` is the initial size of the validation set (i.e., the number of tests used initially to validate candidates). `max_validation_set_size` indicates the maximum to which this validation set will grow. For more details on the successive halving algorithm used in AutoPDL see [here](https://arxiv.org/abs/2504.04365). `max_test_set_size: 10` is the maximum of the test set used to evaluate at the end of the evaluation run. `num_candidates` indicates the number of candidates to consider (sampled randomly). `parallelism` indicates the level of parallelism used by the optimizer.

Last but not least, `variables` indicates the domain of each variable that needs to be tuned. In this case, `model` can be either an Ollama Granite model or gpt-oss. `num_demonstration` is a special variable that the user can set to indicate how many demonstrations to consider. In this case, zero-shot is also included. Finally, the domain of variable `verify` can be `true` or `false`.

Notice that variable `input` in the PDL program is not given a domain. This is because it will hold the different instances that will be evaluated (it was included in the `instance_columns` field).

The complete list of fields available in the configuration file is given in the configuration parser [file](https://github.com/IBM/prompt-declaration-language/blob/main/src/pdl/optimize/config_parser.py).


We are ready to run the optimizer!

## Running AutoPDL

To run the optimizer, execute the following command:

```
pdl-optimize -c grammar_correction_example.yml
```

After a while, AutoPDL creates a new file `optimized_grammar_correction.pdl` with definitions for all the free variables. It determined that gtp-oss is the better model for the task at hand, and that `verify` is best set to False. The optimized program contains the selection of demonstrations. To run this program add a definition for `input`:

```
defs:
  ...
  input: This sentence have an error.
```

To run the optimized program, execute the command:
```
pdl optimized_grammar_correction.pdl
```

A log of the optimization process is written to `experiments/` by default.


================================================
FILE: docs/contrib.md
================================================
# Contributing to PDL

You can report issues or open a pull request (PR) to suggest changes.

## Reporting an issue

To report an issue, or to suggest an idea for a change that you haven't had time to write-up yet:

1. [Review existing issues](https://github.com/IBM/prompt-declaration-language/issues) to see if a similar issue has been opened or discussed.

2. [Open an
issue](https://github.com/IBM/prompt-declaration-language/issues/new). Be sure to include any helpful information, such as version used, error messages, or logs that you might have.


To report vulnerabilities privately, you can contact the authors by email (see [pyproject.toml](https://github.com/IBM/prompt-declaration-language/blob/main/pyproject.toml)).

## Suggesting a change

To suggest a change to this repository, [submit a pull request](https://github.com/IBM/prompt-declaration-language/pulls) with the complete set of changes that you want to suggest. Before creating a PR, make sure that your changes pass all of the tests and add tests for new features.

The test suite can be executed with the following command in the top-level folder:
```
pytest tests
```

Also, please make sure that your changes pass static checks such as code styles by executing the following command:
```
pre-commit run --all-files
```

## Development environment

### PDL development

Follow the following instructions to set up a dev environment to get started with contributing to PDL.

1. Create a fork of https://github.com/IBM/prompt-declaration-language
2. Clone your fork
3. Set up a Python virtual environment and install dependencies

    ```
    cd prompt-declaration-language
    python -m venv .venv
    source .venv/bin/activate
    pip install -e .
    ```

4. Test that you can run an editable version of PDL

    ```
    pdl examples/demo/1-hello.pdl

    Hello
    Hello
    ```

### Documentation updates

When you make changes to PDL, ensure to document any new features in the docs section. You can serve the docs locally to preview changes.

Install the required dependencies for documentation.

```
pip install -e .[docs]
```

Then serve the docs to load a preview.

```
mkdocs serve
```

You are all set!

### Run examples

PDL executes nightly runs for Run Examples, which searches for all the `.pdl` programs in the repo and runs the interpreter against each file. The [config file for Run Examples](https://github.com/IBM/prompt-declaration-language/blob/main/tests/test_examples_run.yaml) describes how to handle each file. There are four conditions:

1. `skip`: a list of PDL files that are skipped in Run Examples
2. `with_inputs`: PDL files that require user input. Each file name is mapped to two fields that describe how inputs are patched
   1. `stdin`: separated by a newline, each line represents the user input (string)
   2. `scope`: scope for the PDL program (a dictionary of key-value pairs)
3. `expected_parse_error`: a list of PDL files that expect parse errors 
4. `expected_runtime_error`: a list of PDL files that expect runtime errors
   
If you wish to make a contribution to PDL and modify or add any PDL program to the repo, it is important that you provide the new expected results for those files so that the Run Examples nightly test does not break. 

#### Local dev

Under `check`, you can provide a list of files that you want to run Pytest against. If you leave it empty (`check: ` or `check: []`), then by default, Pytest will be executed against all files in the repo, except for those under `skip`. For local development, it is useful to only test against a subset of files so that Pytest executes faster.

If you expect the files to produce a different result, setting `update_results: true` will automatically create a new file under `tests/examples/results` capturing the new output for each of the file in `check`. It is useful to set this field to `true` before opening a PR. 

Run this Pytest command for Run Examples, which is the same command for the nightly test.

```
pytest --capture=tee-sys -rfE -s tests/test_examples_run.py --disable-pytest-warnings
```

#### Opening a pull request

A slight variation in the Python version and OS environment can cause a different LLM response, thus Run Examples might fail because it uses exact string matching for PDL outputs.

When you open a pull request (PR) against the `main` branch, a series of status checks will be executed. Specifically, three Run Examples test will be initiated against the PDL files you have added and modified as part of the PR. If there's any variation, you should manually examine the results produced in the Github Actions environment, then copy and paste the results to a new file, and push another commit to your PR so the CI can pass. Be aware of whitespaces in between sentences. 

Below is what the CI might look like if the results differ. If the results look reasonable, you should
1. copy and paste the result for that file 
2. create a new file in `tests/results` in the format of `tests/results/<path/to/file>.<i>.result` where `<i>` should be incremented from the highest number of `<i>.result` in the folder

If the test fails, look for something similar like the following:
```
tests/test_examples_run.py 
============================================================================
File that produced wrong result: examples/demo/1-hello.pdl
Actual result (copy everything below this line):
✂️ ------------------------------------------------------------
Hello
Hello
-------------------------------------------------------------

============================================================================
File that produced wrong result: examples/demo/2-model-chaining.pdl
Actual result (copy everything below this line):
✂️ ------------------------------------------------------------
Hello
Hello
Did you just say Hello?
Yes, I did. It's a common greeting, similar to how humans might respond when they first interact with an artificial intelligence like me. How can I assist you today?
-------------------------------------------------------------
F
```

Note: Your PR should always set `update_results: false` before merging, though the CI pipeline will not attempt to write the results to your PR even if you forget to set this field to `false`. 

Here's a preview of the current configuration file for Run Examples:

```yaml
--8<-- "tests/test_examples_run.yaml"
```

================================================
FILE: docs/css/index.css
================================================
html,body {
    font-family: 'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif;
    background: var(--cds-background, #ffffff);
}

#mainview {
    margin-top: 4rem;
    height: calc(100% - 4rem);
}


================================================
FILE: docs/stylesheets/extra.css
================================================
:root {
    --md-primary-fg-color:        #0f62fe;
    --md-primary-fg-color--light: #4589ff;
    --md-primary-fg-color--dark:  #002d9c;
  }

================================================
FILE: docs/telemetry.md
================================================


# Gathering telemetry for PDL programs

PDL includes experimental support for gathering trace telemetry.  This can
be used for debugging or performance analysis.

##  Installing prerequisites

The OpenTelemetry client libraries are not installed by default.
To install them, use

```bash
pip install opentelemetry-api opentelemetry-sdk opentelemetry-exporter-otlp-proto-http opentelemetry-exporter-otlp-proto-grpc
```

## Installing an OpenTelemetry collector

PDL should work with any OpenTelemetry collector including [the official
collector](https://opentelemetry.io/docs/collector/installation/) or [Jaeger](https://www.jaegertracing.io/).

For example, start the all-in-one Jaeger using

```bash
docker run -d --name jaeger \
  -e COLLECTOR_OTLP_GRPC_HOST_PORT=0.0.0.0:4317 \
  -e COLLECTOR_OTLP_HTTP_HOST_PORT=0.0.0.0:4318 \
  -p 4317:4317 \
  -p 4318:4318 \
  -p 5778:5778 \
  -p 16686:16686 \
  quay.io/jaegertracing/all-in-one:1.63.0
```

## Running PDL with OpenTelemetry

To run PDL with OpenTelemetry, define environment variables before running
your PDL program

```bash
export OTEL_EXPORTER="otlp_http"
export OTEL_ENDPOINT="http://localhost:4318/v1/traces"
export OTEL_SERVICE_NAME=calling_llm
export OTEL_ENVIRONMENT_NAME=dev
pdl ./examples/tutorial/calling_llm.pdl
```

## Viewing trace data

To view trace data, follow the instructions from your OpenTelemetry user interface provider.  For example, if you are using the Jaeger all-in-one, browse to [http://localhost:16686/](http://localhost:16686/).

- In Jaeger, the _Service_ drop-down should include the `$OTEL_SERVICE_NAME`
you specified.  (Click **Reload** of it doesn't.)  Click **Find Traces** to see details of recent traces.  Click on an individual trace to see trace details.


================================================
FILE: docs/tutorial.md
================================================

# PDL Language Tutorial

The following sections give a step-by-step overview of PDL language features.
All the examples in this tutorial can be found in `examples/tutorial`.

## Simple text

The simplest PDL program is one that generates a small text ([file](https://github.com/IBM/prompt-declaration-language/blob/main/examples/tutorial/simple_program.pdl)):

```yaml
--8<-- "./examples/tutorial/simple_program.pdl"
```

This program has a `description` field, which contains a title. The `description` field is optional. It also has a `text` field, which can be either a string, a *block*, or a list of strings and blocks. A block is a recipe for how to obtain data (e.g., model call, code call, etc...). In this case, there are no calls to an LLM or other tools, and `text` consists of a simple string.

To render the program into an actual text, we have a PDL interpreter that can be invoked as follows:

```
pdl examples/tutorial/simple_program.pdl
```

This results in the following output:

```
Hello, world!
```

## Calling an LLM

```yaml
--8<-- "./examples/tutorial/calling_llm.pdl"
```

In this program ([file](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/calling_llm.pdl)), the `text` starts with the word `"Hello\n"`, and we call a model (`ollama/granite4:micro`) with this as input prompt.
The model is passed a parameter `stop` to indicate the stop sequences.

A PDL program computes two data structures. The first is a JSON corresponding to the result of the overall program, obtained by aggregating the results of each block. This is what is printed by default when we run the interpreter. The second is a conversational background context, which is a list of role/content pairs (list of messages), where we implicitly keep track of roles and content for the purpose of communicating with models that support chat APIs. The contents in the latter correspond to the results of each block. The conversational background context is what is used to make calls to LLMs via LiteLLM.

In this example, the input of the model is `[{"role": "user", "content": "Hello\n"}]` which corresponds to the entire text up to that point using the
default role `user`.

When we execute this program using the interpreter, we obtain the following result where the second `Hello` has been generated by Granite:

```
Hello
Hello
```

The input of to the model can also be provided explicitly using the `input` field.
Here is an example of model call using this feature ([file](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/calling_llm_with_input.pdl)):

```yaml
--8<-- "./examples/tutorial/calling_llm_with_input.pdl"
```

In this case, the input passed to the model is `[{"role": "user", "content": "Translate the word 'Hello' to French"}]` and nothing else from the surrounding document. When we execute this program, we obtain the following result where the second line is generated by the model.:

```
Hello
Bonjour (pronounced bon-zhoor) is the translation for "Hello" in French. It's an informal greeting used during the day, similar to how we use "Hi" or "Hello." For a more formal context, you might say "Bonjour," which means "Good day."
```

Using the `input` field, we can also give a directly an array of messages (`role`/`content`) to the model ([file](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/calling_llm_with_input_messages.pdl)):

```yaml
--8<-- "./examples/tutorial/calling_llm_with_input_messages.pdl"
```

This has a similar output as the previous program. An alternative way of writing this program using a variable to store the prompt is [this program](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/calling_llm_with_input_messages_var.pdl).

### Parameter defaults for watsonx Granite models

When using Granite models, we use the following defaults for model parameters:

- `temperature`: 0
- `max_new_tokens`: 1024
- `min_new_tokens`: 1
- `repetition_penalty`: 1.05

  Also if the `decoding_method` is `sample` (`watsonx_text` text completion endpoint), then the following defaults are used:

- `temperature`: 0.7
- `top_p`: 0.85
- `top_k`: 50

The user can override these defaults by explicitly including them in the model call.


## Building the background context with `lastOf`

The previous example explicitly provides a list of messages with different roles to the LLM call. This can also be done implicitly using the background context.

Each block can be annotated with a `role` field indicating the role that is used when a message is added to the background context by the block or any of the sub-block that does not redefine it.
In this example, we add a `system` message asking the model to provide answer formally ([file](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/role.pdl)):

```yaml
--8<-- "./examples/tutorial/role.pdl"
```

In this program, we explicitly indicated the top-level `user` role which is added automatically by the interpreter otherwise.
This role is inherited by the `"Hello\n"` block and masked in the next block to define a system prompt.
So the context provided as input to the LLM is `[{"role": "user", "content": "Hello\n"}, {"role": "system", "content": "You are a polite assistant that likes to answer very formally."}]`. The answer produced by the model block has the `assistant` role.

The execution of this program produces:

```
Hello
You are a polite assistant that likes to answer very formally.
Greetings! I trust this message finds you in good health and high spirits. How may I be of assistance today? Please feel free to pose your query or request, knowing that I am here to serve with diligence and precision.
```

If we want to add the `system` message to the background context without having it present in the result, we can use a `lastOf` block.
The `lastOf` is associated to a list of blocks that are executed in sequence.
Each sub-block contributes messages to the background context but the result of the block is the result of the last block.
The following program provides the same input to the LLM, but the system prompt is not part of the result ([file](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/lastOf.pdl)):

```yaml
--8<-- "./examples/tutorial/lastOf.pdl"
```

Therefore, the result of the program is:

```
Hello

Greetings! I trust this message finds you in good health and high spirits. How may I be of assistance today? Please feel free to pose your query or request, knowing that I am here to serve with diligence and precision.
```

## Model Chaining

In PDL, we can declaratively chain models together as in the following example ([file](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/calling_llm_chaining.pdl)):

```yaml
--8<-- "./examples/tutorial/calling_llm_chaining.pdl"
```

In this program, the first block result is `Hello\n` and adds a message with this value to the background context. The second block calls Granite on the background context containing the Hello message and adds the response of the model to the result and context. The following block contributes the sentence: `\nTranslate the above to French\n`. The final line of the program takes the entire context produced so far and passes it as input to the Granite model. Notice that the input passed to this model is the context up to that point, represented as a conversation. This makes it easy to chain models together and continue building on previous interactions. Notice how the conversational context is accumulated implicitly without requiring the user to explicitly manage messages.

When we execute this program, we obtain:

```
Hello
Hello
Translate the above to French
Bonjour
```

## Variable Definition and Use

Any block can define a variable using a `def: <var>` field. This means that the result of that block is assigned to the variable `<var>`, which may be reused at a later point in the document.

Consider the following example ([file](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/variable_def_use.pdl)):

```yaml
--8<-- "./examples/tutorial/variable_def_use.pdl"
```

Here we assign the response of the model to variable `GEN` using the `def` field. The last line of the program prints out the value of `GEN`. Notice the notation `${ }` for accessing the value of a variable. Any [Jinja](https://jinja.palletsprojects.com/en/3.1.x/) expression is allowed to be used inside these braces. These expressions
are also used to specify conditions for loops and conditionals. See for example this [file](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/programs/chatbot.pdl).

When we execute this program, we obtain:

```
Hello
Hello
The variable GEN is equal to: Hello
```

## Local Computation Using `defs`

In the previous example, the value of the variable `GEN` computed by the `model` block is part of the result and is added to the background context. To define the variable `GEN` without contributing to the result and context, the `model` block can be moved into a `defs` ([file](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/local_computation.pdl)):

```yaml
--8<-- "./examples/tutorial/local_computation.pdl"
```

The execution of this program produces:

```
Hello
The variable GEN is equal to: Hello
```

The `defs` field can be added on any block and can introduce multiple variables.
The following program defines two variables `fr` and `es` associated to a `text` block that uses them ([file](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/defs.pdl)):

```yaml
--8<-- "./examples/tutorial/defs.pdl"
```

This program first output `Hello` and add it in the context.
Then, the blocks defining the `fr` and `es` variables are both executed in a context containing only the `Hello` message. These blocks are using a `lastOf` that adds the value to each sub-blocs to the context and output the value of the last block. Finally, the value of the variables are used in the `text` block.

The output of this program is:

```
Hello

In Fench: Bonjour!

Translation of "Hello" in French is "Bonjour".

In Spanish: Hola!

La traducción de "Hello" al español es "Hola".
```

## Control Block Outputs with `contribute`

By default, when a PDL block is executed, it produces a result that is contributed to the overall result, and it also contributes to the background context. We saw that `defs` and `lastOf` gives some control over the contribution to the result of context. `defs` executes a block without contributing to the context and name the result that can be used later. `lastOf` contributes only to the context for all of its sun-blocks except the last one. It is also possible to control the contribution of each block using the `contribute` field.

Consider an example similar as above, but that uses `contribute` instead of `defs` and `lastOf` ([file](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/muting_block_output.pdl)):

```yaml
--8<-- "./examples/tutorial/muting_block_output.pdl"
```

Instead of a `lastOf`, we set `contribute` to `[context]` for the block that produces `"\nTranslate to French\n"`. That way, we only contribute to the context and not to the result.
We set `contribute` to `[]` for the call to the LLM such that it does not produce an output but only save the result in the `fr` variable that is used in the last block of the program. When we execute this program, we obtain:

```
Hello

In Fench: Bonjour!

Translation of "Hello" in French is "Bonjour".
``` 

In general, `contribute` can be used to set how the result of the block contribute to the final result and the background context.
Here are its possible values:

- `[]`: no contribution to either the final result or the background context

- `[result]`: contribute to the final result but not the background context

- `[context]`: contribute to the background context but not the final result

- `[result, context]`: contribute to both, which is also the default setting.


## Function Definition

PDL supports function definitions to make it easier to reuse code.
Suppose we want to define a translation function that takes a string and calls a Granite model for the translation. This would be written in PDL as follows ([file](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/function_definition.pdl)):

```yaml
--8<-- "./examples/tutorial/function_definition.pdl"
```

In this program, the `defs` field defines a function `translate` that takes as parameters `sentence` and `language`, both of which are of type string. The body of the function is defined by its `return` field. In this case, we formulate a translation prompt using the parameters and send it to a Granite model.

The body of the program is a `text` block that calls this function twice, as indicated by `call: ${ translate }`. The `call` block specifies the arguments to be passed. When we execute this program, we obtain:

```
J'aime Paris !
Me encanta Madrid.
```

When we call a function, we implicitly pass the current background context, and this is used as input to model calls inside the function body. In the above example, since the `input` field is omitted, the entire document produced at that point is passed as input to the Granite model.

To reset the context when calling a function, we can pass the special argument: `pdl_context: []` (see [example](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/function_empty_context.pdl)).

Functions can be declared with optional parameters (see [example](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/function_optional_params.pdl)).

PDL is a language with higher order functions meaning that functions are values. So for example, a function can be aliased (see [example](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/function_alias.pdl)).

PDL functions can also be called from Jinja expressions as in the following example ([file](https://github.com/IBM/prompt-declaration-language/blob/main/examples/tutorial/function_call_in_jinja.pdl)):

```yaml
--8<-- "./examples/tutorial/function_call_in_jinja.pdl"
```

Notice that arguments can be positional or named. 


## Building Data Structures

In PDL, the user specifies step by step the shape of data they wish to generate. A `text` block takes a list of blocks, stringifies the result of each block,
and concatenates them.

An `array` takes a list of blocks and creates an array of the results of each block:

```yaml
array:
  - apple
  - orange
  - banana
```

This results in the following output:

```
["apple", "orange", "banana"]
```

Each list item can contain any PDL block (strings are shown here), and the overall result is presented as an array.

An `object` constructs an object:

```
object:
  name: Bob
  job: manager
```

This results in the following output:

```
{"name": "Bob", "job": "manager"}
```

Each value in the object can be any PDL block, and the result is presented as an object.

A `lastOf` is a sequence, where each block in the sequence is executed and the overall result is that of the last block.

```
lastOf:
  - 1
  - 2
  - 3
```

This results in the following output:

```
3
```

Each list item can contain any PDL block (strings are shown here), and the result of the whole list is that of the last block.

Notice that block types that require lists (`repeat`, `for`, `if-then-else`) need to specify the shape of data in their bodies, for
example `text` or `array`. It is a syntax error to omit it. For more detailed discussion on this see [this section](#conditionals-and-loops).

## Input from File or Stdin

PDL can accept textual input from a file or stdin. In the following example ([file](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/input_file.pdl)), the contents of this [file](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/data.txt) are read by PDL and incorporated in the document. The result is also assigned to a variable `HELLO`.

```yaml
--8<-- "./examples/tutorial/input_file.pdl"
```

In the next example, prompts are obtained from stdin ([file](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/input_stdin.pdl)). This is indicated by assigning the value `null` to the `read` field.

```yaml
--8<-- "./examples/tutorial/input_stdin.pdl"
```

If the `message` field is omitted then one is provided for you.

The following example shows a multiline stdin input ([file](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/input_stdin_multiline.pdl)). When executing this code and to exit from the multiline input simply press control D (on macOS).

```yaml
--8<-- "./examples/tutorial/input_stdin_multiline.pdl"
```

Finally, the following example shows reading content in JSON format.

Consider the JSON content in this [file](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/input.json):

```yaml
--8<-- "./examples/tutorial/input.json"
```

The following PDL program reads this content and assigns it to variable `PERSON` in JSON format using the `parser` ([file](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/input_file_json.pdl)). The reference `PERSON.address.street` then refers to that field inside the JSON object. Note that the PDL interpreter performs automatic repair of JSON objects generated by LLMs.

```yaml
--8<-- "./examples/tutorial/input_file_json.pdl"
```

When we execute this program, we obtain:

```
Bob lives at the following address:
87 Smith Road in the town of Armonk, NY
```

## Parsing the output of a block

As we saw in the previous section, it is possible to use the `parser: json` setting to parse the result of a block as a JSON.
Other possible values for `parser` are `yaml`, `jsonl`, `regex`, or `csv`.

The following example extracts using a regular expression parser the code between triple backtick generated by a model:

```yaml
--8<-- "./examples/tutorial/parser_regex_code.pdl"
```

Here is another example using a regular expression:

```yaml
--8<-- "./examples/tutorial/parser_regex.pdl"
```

We support the following operations with the`regex` parser (indicated with the `mode` field):

- `fullmatch` (default)

- `search`

- `match`

- `split`

- `findall`

Here is an example using the `findall` mode that returns the list `['1', '2', '3', '4']`:

```yaml
--8<-- "./examples/tutorial/parser_findall.pdl"
```

See [here](https://docs.python.org/3/library/re.html) for more information on how to write regular expressions.

## Calling code

The following script shows how to execute python code ([file](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/code_python.pdl)). The python code is executed locally (or in a containerized way if using `pdl --sandbox`).  In principle, PDL is agnostic of any specific programming language, but we currently only support Python, Jinja, and shell commands. Variables defined in PDL are copied into the global scope of the Python code, so those variables can be used directly in the code. However, mutating variables in Python has no effect on the variables in the PDL program. The result of the code must be assigned to the variable `result` internally to be propagated to the result of the block. A variable `def` on the code block will then be set to this result.

```yaml
--8<-- "./examples/tutorial/code_python.pdl"
```

This results in the following output (for example):

```
Hello, r!
```

In order to define variables that are carried over to the next Python code block, without returning from the code block a special variable `PDL_SESSION` can be used, and
variables assigned to it as fields.
See for example: ([file](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/code_session.pdl)).


PDL also supports Jinja code blocks, shell commands, as well as PDL code blocks for meta-cycle programming. For more examples, see
([Jinja code](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/code_jinja.pdl)),
([shell command](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/code_command.pdl)),
([PDL code](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/code_pdl.pdl)).

### Using the scope field

Code blocks can use the optional `scope` field to provide a custom set of variables for code execution, instead of using the global PDL scope. This is useful when you want to isolate variables or provide specific values to a code block without affecting the rest of the program.

```yaml
--8<-- "./examples/tutorial/code_scope.pdl"
```

In this example, the variables `x` and `y` are defined in the `scope` field and are available directly in the Python code. The `scope` field accepts a dictionary of variable names and their values. This feature works with all supported code languages (Python, Jinja, and PDL).

When using `scope`:

- Variables from the scope are available in the code block

- The global PDL scope is not affected by variables defined in the `scope` field

- If `scope` is not provided, the code block uses the global PDL scope as usual

### Using the parameters field with Jinja

Jinja code blocks support an optional `parameters` field that allows you to configure Jinja template behavior. The parameters are passed directly to the Jinja `Template` constructor, giving you control over template rendering options.

```yaml
--8<-- "./examples/tutorial/code_jinja_parameters.pdl"
```

In this example ([file](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/code_jinja_parameters.pdl)), we use the `parameters` field to configure Jinja's whitespace handling:

- `trim_blocks: true` Removes the first newline after a template tag

- `lstrip_blocks: true` Strips leading whitespace from the start of a line to the start of a block

These parameters help produce cleaner output by controlling how Jinja handles whitespace around template control structures like `{% for %}` loops.

For a complete list of available parameters, see the [Jinja Template documentation](https://jinja.palletsprojects.com/en/3.1.x/api/#jinja2.Environment).

### Accessing the pdl_scope variable

The `pdl_scope` variable is a special built-in variable that provides access to the entire scope dictionary within code blocks and Jinja expressions. This is useful when you need to introspect available variables, iterate over them, or access variables dynamically.

```yaml
--8<-- "./examples/tutorial/pdl_scope.pdl"
```

In this example ([file](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/pdl_scope.pdl)), we demonstrate how to use `pdl_scope`:

1. Access variables through `pdl_scope` using dictionary syntax: `pdl_scope["greeting"]`
2. Iterate over all available variables using `pdl_scope.keys()`

The `pdl_scope` variable contains all variables in the current scope, including:

- User-defined variables (like `greeting` and `name` in the example)

- Built-in PDL variables (like `pdl_context`, `pdl_usage`, `stdlib`, etc.)

### Accessing the pdl_usage variable

The `pdl_usage` variable is a special built-in variable that tracks LLM usage statistics throughout the execution of a PDL program. This is useful for monitoring token consumption, tracking costs, and optimizing your prompts.

```yaml
--8<-- "./examples/tutorial/pdl_usage.pdl"
```

In this example ([file](https://github.com/IBM/prompt-declaration-language/blob/main/examples/tutorial/pdl_usage.pdl)), we demonstrate how to access usage statistics after making an LLM call. The `pdl_usage` variable contains three fields:

- `model_calls`: The total number of calls made to LLMs during program execution

- `prompt_tokens`: The total number of tokens used in prompts sent to LLMs

- `completion_tokens`: The total number of tokens generated by LLMs in their responses

These statistics are accumulated across all LLM calls in your program, making it easy to track total resource consumption. This information can be particularly useful for estimating costs when using paid LLM APIs, optimizing prompts to reduce token usage, debugging and understanding program behavior, or monitoring resource consumption in production environments.

Warning: The `pdl_usage` variable is updated when the model call is complete, so it may not reflect the current state of your program. For example, if the previous example is executed in none streaming mode (which enable non-blocking model calls), the usage displayed is `0` for all the fields.

## Calling REST APIs

PDL programs can contain calls to REST APIs with Python code. Consider a simple weather app ([file](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/programs/weather.pdl)):

```yaml
--8<-- "./examples/tutorial/programs/weather.pdl"
```

In this program, we first define a query about the weather in some location (assigned to variable `QUERY`). The next block is a call to a Granite model with few-shot examples to extract the location, which we assign to variable `LOCATION`. The next block makes an API call with Python (mocked in this example). Here the `LOCATION` is appended to the `url`. The result is a JSON object, which may be hard to interpret for a human user. So we make a final call to an LLM to interpret the JSON in terms of weather. Notice that many blocks have `contribute` set to `[]` to hide intermediate results.

## Data Block

PDL offers the ability to create JSON data as illustrated by the following example (described in detail in the [Overview](https://ibm.github.io/prompt-declaration-language/#overview) section). The `data` block can gather previously defined variables into a JSON structure. This feature is useful for data generation. Programs such as this one can be generalized to read jsonl files to generate data en masse by piping into another jsonl file ([file](https://github.com/IBM/prompt-declaration-language/blob/main/examples/tutorial/programs/code/code-json.pdl)).

```yaml
--8<-- "./examples/tutorial/programs/code/code-json.pdl"
```

Notice that in the `data` block the values are interpreted as Jinja expressions. If values need to be PDL programs to be interpreted, then you need to use
the `object` block instead (see [this section](#specifying-data)).

In the example above, the expressions inside the `data` block are interpreted, but in some cases it may be useful not to interpret the values in a `data` block.
The `raw` field can be used to turn off the interpreter inside a `data` block. For example, consider the ([file](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/data_block_raw.pdl)):

```yaml
--8<-- "./examples/tutorial/data_block_raw.pdl"
```

The result of this program is the JSON object:

```
{
  "name": "${ name }",
  "phone": "${ phone }"
}
```

where the values of `name` and `phone` have been left uninterpreted.

## Import Block

PDL allows programs to be defined over multiple files. The `import` block allows one file to incorporate another, as shown in the
following [example](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/import.pdl):

```yaml
--8<-- "./examples/tutorial/import.pdl"
```

which imports the following [file](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/import_lib.pdl):

The `import` block means that the PDL code at that file is executed and its scope is assigned to the variable defined in that block. So all the `defs` in the imported file are made available via that variable. This feature allows reuse of common templates and patterns and to build libraries. Notice that relative paths are relative to the containing file.

## Prompt Library

A prompt library is included in the `contrib/` directory. These modules define some common patterns such Chain-of-Thought, ReAct, and ReWOO. Example usage can be found in `examples/prompt_library`. Note that `import` blocks resolve file paths relative to the PDL file being executed.

### Chain-of-Thought

In the `GSM8K` example below, we import `CoT` [(Wei et al., 2022)](https://arxiv.org/abs/2201.11903) and define our model, demonstrations, and the question. Demonstrations are a list of dictionaries with `question`, `reasoning`, and `answer` keys. The `cot.chain_of_thought` function returns a dictionary with an `answer` key.

``` yaml title="examples/prompt_library/gsm8k_cot.pdl"
--8<-- "./examples/prompt_library/gsm8k_cot.pdl"
```

Executing this example produces the following background context (model response highlighted):

``` text hl_lines="27-31"
Answer the questions to the best of your abilities.

Question: Noah charges $60 for a large painting and $30 for a small painting.
Last month he sold eight large paintings and four small paintings.
If he sold twice as much this month, how much is his sales for this month?
Answer: Let's think step by step. He sold 8 large paintings and 4 small paintings last month.
He sold twice as many this month.
8 large paintings x $60 = << 8*60= 480 >> 480
4 small paintings x $30 = << 4*30= 120 >> 120
So he sold << 480+120= 600 >> 600 paintings last month.
Therefore he sold << 600*2= 1200 >> this month.
The answer is $1200

Question: Noah charges $30 for a large vases and $10 for a small vases.
Last month he sold five large vases and three small vases.
If he sold three times as much this month, how much is his sales for this month?
Answer: Let's think step by step. He sold 5 large vases and 3 small vases last month.
He sold three times as many this month.
5 large vases x $30 = << 5*30= 150 >> 150
3 small vases x $10 = << 3*10= 30 >> 30
So he sold << 150+30= 180 >> 180 vases last month.
Therefore he sold << 180*3= 540 >> this month.
The answer is $540

Question: Jake earns thrice what Jacob does. If Jacob earns $6 per hour, how much does Jake earn in 5 days working 8 hours a day?
Answer: Let's think step by step.
1. Jacob earns $6 per hour.
2. Jake earns thrice what Jacob does, so Jake earns 3 * $6 = $18 per hour.
3. Jake works 8 hours a day, so he earns $18 * 8 = $144 per day.
4. Jake works 5 days, so he earns $144 * 5 = $720 in 5 days.
The answer is $720.
```

The final result is:

``` text
Answer the questions to the best of your abilities.

Result: {'answer': '1. Jacob earns $6 per hour.\n2. Jake earns thrice what Jacob does, so Jake earns 3 * $6 = $18 per hour.\n3. Jake works 8 hours a day, so he earns $18 * 8 = $144 per day.\n4. Jake works 5 days, so he earns $144 * 5 = $720 in 5 days.\nThe answer is $720.'}
```

### ReAct

In the ReAct [(Yao et al., 2022)](https://arxiv.org/abs/2210.03629) example below, we import the ReAct library and provide tools from `tools.pdl`. Demonstrations consist of agent trajectories represented as a list of lists with key names `question` or `task`, `thought`, `action`, and `observation`. Actions follow this pattern: `{"name": "tool_name", "arguments": {"arg1": "..."}}`. The function returns a dictionary with a `answer` key, containing the answer.

``` yaml title="examples/prompt_library/gsm8k_react.pdl"
--8<-- "./examples/prompt_library/gsm8k_react.pdl"
```

Produces background context (model responses highlighted):

``` text hl_lines="22 23 25 26 28 29 31 32"
Question: Noah charges $60 for a large painting and $30 for a small painting.  Last month he sold eight large paintings and four small paintings.  If he sold twice as much this month, how much is his sales for this month?
Tho: He sold 8 large paintings and 4 small paintings last month.  He sold twice as many this month. I need to calculate (8 large paintings x $60 + 4 small paintings x $30)
Act: {"name": "calculator", "arguments": {"expr": "8*60+4*30"}}
Obs: 600
Tho: He sold twice as many paintings this month, therefore I need to calculate 600*2.
Act: {"name": "calculator", "arguments": {"expr": "600*2"}}
Obs: 1200
Tho: He sold $1200 this month.
Act: {"name": "finish", "arguments": {"answer": "$1200"}}

Question: Teresa is 59 and her husband Morio is 71 years old. Their daughter, Michiko was born when Morio was 38. How old was Teresa when she gave birth to Michiko?
Tho: I need to calculate the difference in age between Teresa and Morio.
Act: {"name": "calculator", "arguments": {"expr": "71-59"}}
Obs: 12
Tho: I need to calculate how old Teresa is when their daughter is born.
Act: {"name": "calculator", "arguments": {"expr": "38-12"}}
Obs: 26
Tho: Teresa was 26 when she gave birth to Michiko.
Act: {"name": "finish", "arguments": {"answer": "26"}}

Question: Jake earns thrice what Jacob does. If Jacob earns $6 per hour, how much does Jake earn in 5 days working 8 hours a day?
Tho: Jacob earns $6 per hour. Jake earns thrice as much.
Act: {"name": "calculator", "arguments": {"expr": "6*3"}}
Obs: 18
Tho: Jake earns $18 per hour.
Act: {"name": "calculator", "arguments": {"expr": "18*8"}}
Obs: 144
Tho: Jake earns $144 in a day.
Act: {"name": "calculator", "arguments": {"expr": "144*5"}}
Obs: 720
Tho: Jake earns $720 in 5 days.
Act: {"name": "finish", "arguments": {"answer": "$720"}}
```

The final result is:

``` text
Result: {'answer': '$720'}
```

#### Tools

Tools allow the agentic patterns to call PDL functions. The tools are defined in two parts. The `tools` object is a dictionary of tool names to PDL functions. The `tool_schema` is a JSON schema, represented as a `data` block consisting of list of dictionaries, that describes the tools to the LLM. The `tools` library contains a calculator and a Wikipedia search tool by default. There are a few requirements to consider when using tools.

1. You must have a `finish` tool in the _schema_. You do not need a PDL function for this, but the LLM needs to be aware of the `finish` tool so the `ReAct` loop can end.
2. A PDL tool function must accept only `arguments: obj` as parameters.

Here we define our tools in PDL, with an example using a `python` block. Note the use of `arguments: obj`.

``` yaml
tools:
  object:
    hello:
      function:
        arguments: object
      return:
        lang: python
        code: |
          result = None
          def main(name: str, *args, **kwargs) -> str:
            return f"hello {name}"
          result = main(**arguments)

    another_function: ...
```

Once we have defined our PDL functions, we describe them in the `tool_schema`.

``` yaml
tool_schema:
  data:
    - name: hello
      description: Hello function, returns "hello <name>"
      parameters:
        type: object
        properties:
          name:
            type: string
            description: Name to greet
        required:
          - name

    - name: finish
      description: Respond with the answer
      parameters:
        type: object
        properties:
          answer:
            type: string
            description: The answer
          required:
            - answer
```

Another useful thing to remember is that data blocks are templated in PDL. For example, this is valid:

``` yaml
finish_action:
  data:
    name: finish
    description: Respond with the answer
    parameters:
      type: object
      properties:
        answer:
          type: string
          description: The answer
        required:
          - answer

tool_schema:
  data:
    - name: calculator
      description: Calculator function
      parameters:
        type: object
        properties:
          expr:
            type: string
            description: Arithmetic expression to calculate
        required:
          - expr
    - ${ finish_action }
```

In fact, you can reuse the `finish_action` from `tools` in your own tool schemas:

``` yaml
defs:
  tools:
    import: ../../contrib/prompt_library/tools
  my_tool_schema:
    data:
      - ${ tools.finish_action }
      - ...
```

Additionally, there is a helper function `filter_tools_by_name` in `tools`, that given a JSON tools schema and a list of tool names, returns a schema with only those tools in it. This is useful if you have defined many tools, but don't need all of them for a particular task.

``` yaml
call: ${ tools.filter_tools_by_name }
args:
  tools: ${ tools.tool_schema }
  tool_names: ['calculator', 'finish']
```

### ReWOO

The tools can be reused for ReWOO [(Xu et al., 2023)](https://arxiv.org/abs/2305.18323). Demonstrations follow a similar pattern as for ReAct, except that ReWOO does not use a `finish` tool/action, nor does it include `observation`, and thus should be omitted from the demonstrations. The argument `show_plans` is used for displaying the extracted ReWOO plans in the background context for debugging purposes i.e. `--stream context`. The function returns a dictionary with a `answer` key, containing the answer.

``` yaml title="examples/prompt_library/gsm8k_rewoo.pdl"
--8<-- "./examples/prompt_library/gsm8k_rewoo.pdl"
```

This results in the following background context:

``` text hl_lines="18 28-30"
For the following task, make plans that can solve the problem step by step. For each plan, indicate which external tool together with tool input to retrieve evidence. You can store the evidence into a variable #E that can be called by later tools. (Plan, #E1, Plan, #E2, Plan, ...)

Tools can be one of the following:
[{'type': 'function', 'function': {'name': 'calculator', 'description': 'Calculator function', 'parameters': {'type': 'object', 'properties': {'expr': {'type': 'string', 'description': 'Arithmetic expression to calculate'}}, 'required': ['expr']}}}]

Task: Noah charges $60 for a large painting and $30 for a small painting. Last month he sold eight large paintings and four small paintings. If he sold twice as much this month, how much is his sales for this month?
Plan: He sold 8 large paintings and 4 small paintings last month. He sold twice as many this month. I need to calculate (8 large paintings x $60 + 4 small paintings x $30) #E1 = {"name": "calculator", "arguments": {"expr": "8*60+4*30"}}
Plan: He sold twice as many paintings this month, therefore I need to calculate 600*2. #E2 = {"name": "calculator", "arguments": {"expr": "600*2"}}

Task: Teresa is 59 and her husband Morio is 71 years old. Their daughter, Michiko was born when Morio was 38. How old was Teresa when she gave birth to Michiko?
Plan: I need to calculate the difference in age between Teresa and Morio. #E1 = {"name": "calculator", "arguments": {"expr": "71-59"}}
Plan: I need to calculate how old Teresa is when their daughter is born. #E2 = {"name": "calculator", "arguments": {"expr": "38-12"}}

Begin!
Describe your plans with rich details. Each Plan should be followed by only one #E.

Question: Jake earns thrice what Jacob does. If Jacob earns $6 per hour, how much does Jake earn in 5 days working 8 hours a day?
[["First, I need to calculate Jake's hourly wage. Since Jake earns thrice what Jacob does, and Jacob earns $6 per hour, Jake earns 3 * $6 = $18 per hour.", "#E1", "{\"name\": \"calculator\", \"arguments\": {\"expr\": \"6*3\"}}"]]

Solve the following task or problem. To solve the problem, we have made step-by-step Plan and retrieved corresponding Evidence to each Plan. Use them with caution since long evidence might contain irrelevant information.

Plan: First, I need to calculate Jake's hourly wage. Since Jake earns thrice what Jacob does, and Jacob earns $6 per hour, Jake earns 3 * $6 = $18 per hour.
Evidence: 18

Now solve the question or task according to provided Evidence above. Respond with the answer directly with no extra words.

Question: Jake earns thrice what Jacob does. If Jacob earns $6 per hour, how much does Jake earn in 5 days working 8 hours a day?
Response: Jake earns $18 per hour. In 5 days, working 8 hours a day, Jake works 5 * 8 = 40 hours. Therefore, Jake earns 40 * $18 = $720 in 5 days.

Answer: $720
```

The final result of this example is

``` text
Result: {"answer": "Jake earns $18 per hour. In 5 days, working 8 hours a day, Jake works 5 * 8 = 40 hours. Therefore, Jake earns 40 * $18 = $720 in 5 days.\n\nAnswer: $720"}
```

## Conditionals and Loops

PDL supports conditionals and loops as illustrated in the following example ([file](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/programs/chatbot.pdl)), which implements a chatbot.

```yaml
--8<-- "./examples/tutorial/programs/chatbot.pdl"
```

The first block prompts the user for a query, and this is contributed to the background context. The next
block is a `repeat-until`, which repeats the contained `text` block until the condition in the `until` becomes
true. The field `repeat` can contain a string, or a block, or a list. If it contains a list, then the list must be a `text`,
`array` or `lastOf` (which means that all the blocks in the list are executed and the result of the body is that of the last block).

The example also shows the use of an `if-then-else` block. The `if` field contains a condition, the `then` field
can also contain either a string, or a block, or a list (and similarly for `else`).

The chatbot keeps looping by making a call to a model, asking the user if the generated text is a good answer,
and asking `why not?` if the answer (stored in variable `eval`) is `no`. The loop ends when `eval` becomes `yes`. This is specified with a Jinja expression on line 18.

Notice that the `repeat` and `then` blocks are followed by `text`. This is because of the semantics of lists in PDL. If we want to aggregate the result by stringifying every element in the list and collating them together, then we need the keyword `text` to precede a list. The number of iterations of a loop can be bounded by adding a `maxIterations` field.

The way that the result of each iteration is collated with other iterations can be customized in PDL using
the `join` feature (see the following section).

Another simple example of using an `if` statement is [this](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/if.pdl).

### For Loops

PDL also offers `for` loops over lists.
The following [example](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/for.pdl) stringifies and outputs each number.

```yaml
--8<-- "./examples/tutorial/for.pdl"
```

This program outputs:

```
1234
```

To output a number of each line, we can specify which string to use to join the results.

```yaml
--8<-- "./examples/tutorial/for_with.pdl"
```

```
1
2
3
4
```

To create an array as a result of iteration, we would write:

```yaml
--8<-- "./examples/tutorial/for_array.pdl"
```

which outputs the following list:

```
[1, 2, 3, 4]
```

To retain only the result of the last iteration of the loop, we would write:

```yaml
--8<-- "./examples/tutorial/for_lastOf.pdl"
```

which outputs:

```
4
```

When `join` is not specified, the collation defaults to

```
join:
  as: text
  with: ""
```

meaning that result of each iteration is stringified and concatenated with that of other iterations. When using `with`,
`as: text` can be elided.

Note that `join` can be added to any looping construct (`repeat`) not just `for` loops.

The `for` loop construct also allows iterating over 2 or more lists of the same length simultaneously:

```yaml
--8<-- "./examples/tutorial/for_multiple_lists.pdl"
```

This results in the following output:

```
Bob's number is 1
Carol's number is 2
David's number is 3
Ernest's number is 4
```

The loop constructs also allow to build an object:

```yaml
--8<-- "./examples/tutorial/for_object.pdl"
```

This results in the following output:

```
{"Bob": 1, "Carol": 2, "David": 3, "Ernest": 4}
```

### Other loops

The following example shows a while loop in PDL:

```yaml
--8<-- "./examples/tutorial/while.pdl"
```

The `while` field indicates the looping condition and `repeat` contains the body of the loop.

This loop can be rewritten using `maxIterations` to bound the number of iterations and `index` to name the iteration number.

```yaml
--8<-- "./examples/tutorial/loop_index.pdl"
```


Notice that `for`, `while`, `until`, and `maxIterations` can all be combined in the same `repeat` block. The loop exits as soon as one of the exit conditions is satisfied:

```yaml
--8<-- "./examples/tutorial/repeat.pdl"
```

### Match block

PDL provides a match block for convenience.
Consider the [example](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/programs/demo-hallucination.pdl). This shows retrieved RAG documents
that are then submitted with a query to a RAG Granite model.
The output contains an answer to the query together with hallucination
score and possibly a citation.

To obtain and install the Granite model locally follow these
[instructions](https://github.com/IBM/prompt-declaration-language//blob/main/examples/intrinsics/README.md).

The end of this program contains a match block:

```yaml
...
  The answer is: ${ out[0].sentence }
- match: ${out[0].meta.hallucination_level}
  with:
  - case: "high"
    then: Totally hallucinating, sorry!
  - case: "low"
    if: ${ out[0].meta.citation }
    then: |
      I am not hallucinating, promise!
      The citation is: ${ out[0].meta.citation.snippet }
  - then: Not sure if I am hallucinating...
```

The `match` field indicates an expression to match on. The cases follow the `with` field. Additional conditions can be indicated as shown in the second case.

## Roles and Chat Templates

Consider again the chatbot example ([file](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/programs/chatbot.pdl)). By default blocks have role `user`, except for model call blocks, which have role `assistant`.
If we write roles explicitly for the chatbot, we obtain:

```yaml
description: chatbot
text:
- read:
  message: "What is your query?\n"
  contribute: [context]
- repeat:
    text:
    - model: replicate/ibm-granite/granite-3.1-8b-instruct
      role: assistant
    - read:
      def: eval
      message: "\nIs this a good answer[yes/no]?\n"
      contribute: []
    - if: ${ eval == 'no' }
      then:
        text:
        - read:
          message: "Why not?\n"
  until: ${ eval == 'yes'}
role: user
```

In PDL, any block can be adorned with a `role` field indicating the role for that block. These are high-level annotations
that help to make programs more portable across different models. If the role of a block is not specified (except for model blocks that have `assistant` role),
then the role is inherited from the surrounding block. So in the above example, we only need to specify `role: user` at the top level (this is the default, so it doesn't
need to be specified explicitly).

PDL takes care of applying appropriate chat templates (done either in LiteLLM or at the server side).

The prompt that is actually submitted to the first model call (with query `What is APR?`) is the following:

```
<|start_of_role|>user<|end_of_role|>What is APR?<|end_of_text|>
<|start_of_role|>assistant<|end_of_role|>
```

To change the template that is applied, you can specify it as a parameter of the model call:

```yaml
model: replicate/ibm-granite/granite-3.1-8b-instruct
parameters:
  roles:
    system:
       pre_message: <insert text here>
       post_message: <insert text here>
    user:
       pre_message: <insert text here>
       post_message: <insert text here>
    assistant:
       pre_message: <insert text here>
       post_message: <insert text here>
```

## Type Checking and Structured Decoding

Consider the following PDL program ([file](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/type_checking.pdl)). It first reads the data
found [here](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/type_checking_data.yaml) to form few-shot examples. These demonstrations show how to create
some JSON data.

```yaml
--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 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.

When we run this program, we obtain the output:

```
{'name': 'John', 'age': 'twentyfive'}
```

If we add the type annotation `spec: {name: string, age: integer}` on the model block (see [file](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/structured_decoding.pdl)), even if we asked the model to produce the age in letters, we are getting the following output:

```
{'name': 'John', 'age': 30}
```

We are getting the age as an integer because the model block automatically enable structured decoding. The fields `guided_json` and `response_format` are added automatically by the interpreter to the LiteLLM request with the JSON Schema value obtained from the type. Models on platforms that support structured decoding then use this to generate JSON of the correct format.


If we disable structured decoding by setting the field `structuredDecoding` to false (see [file](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/type_error.pdl)), we are getting a type error:

```
{'name': 'John', 'age': 'twentyfive'}
examples/tutorial/type_error.pdl:24 - Type errors during spec checking:
examples/tutorial/type_error.pdl:24 - twentyfive should be of type <class 'int'>
```



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).


## Python SDK

PDL programs can be defined and called programmatically directly in Python.
In the following example, the PDL program is defined as a string and then parsed and executed using the [`exec_str`](https://ibm.github.io/prompt-declaration-language/api_reference/#src.pdl.pdl.exec_str) function ([file](https://github.com/IBM/prompt-declaration-language/blob/main/examples/tutorial/sdk/hello_str.py)).

```python
--8<-- "./examples/tutorial/sdk/hello_str.py"
```

The SDK also provides functions to execute programs defined in a file (see [example](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/sdk/hello_file.py)), as a Python dictionary (see [example](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/sdk/hello_dict.py)), or PDL abstract syntax tree defined by a [Pydantic](https://docs.pydantic.dev) data structure (see [example](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/sdk/hello_prog.py)). The documentation of the API is available [here](https://ibm.github.io/prompt-declaration-language/api_reference/).


A way to handle the processing of large datasets using PDL is to use Python multiprocessing capabilities to launch multiple instances of the PDL interpreter. The example below, w are using the Python's `concurrent.futures.ProcessPoolExecutor` to execute in parallel multiple instances of the PDL program `HELLO` where the free variable `name` is instantiated with a different value for each instance ([file](https://github.com/IBM/prompt-declaration-language/blob/main/examples/tutorial/sdk/hello_parallel.py)).

```python
--8<-- "./examples/tutorial/sdk/hello_parallel.py"
```

Finally, it possible to interleave the use of Python and PDL.
You can find an example [here](https://github.com/IBM/prompt-declaration-language/blob/main/examples/callback) of a Python application which is using a function defined in PDL which itself depend on the Python application.

## Debugging PDL Programs

We highly recommend to edit PDL programs using an editor that support YAML with JSON Schema validation. For example, you can use VSCode with the [YAML extension](https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml) and configure it to use the [PDL schema](https://github.com/IBM/prompt-declaration-language/blob/main/src/pdl/pdl-schema.json). The PDL repository has been configured so that every `*.pdl` file is associated with the PDL grammar JSONSchema (see [settings](https://github.com/IBM/prompt-declaration-language/blob/main/.vscode/settings.json)).
This enables the editor to display error messages when the yaml deviates from the PDL syntax and grammar. It also provides code completion. The PDL interpreter also provides similar error messages. To make sure that the schema is associated with your PDL files, be sure that `PDL Schemas` appear at the bottom right of your VSCode window, or on top of the editor window.

PDL provides a graphical user experience to help with debugging, program understanding and live programming. You may install this via `brew install pdl` on MacOS. For
other platforms, downloads are available
[here](https://github.com/IBM/prompt-declaration-language/releases/latest). You
may also kick the tires with a web version of the GUI
[here](https://pdl.s3-web.us-east.cloud-object-storage.appdomain.cloud/).

To generate a trace for use in the GUI:

```bash
pdl --trace <file.json> <my-example.pdl>
```

This is similar to a spreadsheet for tabular data, where data is in the forefront and the user can inspect the formula that generates the data in each cell. In the Live Document, cells are not uniform but can take arbitrary extents. Clicking on them similarly reveals the part of the code that produced them.

Finally, PDL includes experimental support for gathering trace telemetry.  This can
be used for debugging or performance analysis, and to see the shape of prompts sent by LiteLLM to models.

For more information see [here](https://github.com/IBM/prompt-declaration-language/blob/main/docs/telemetry.md).

## Using Ollama models

1. Install Ollama e.g., `brew install --cask ollama`
2. Run a model e.g., `ollama run granite-code:8b`. See [the Ollama library for more models](https://ollama.com/library/granite-code/tags)
3. An OpenAI style server is running locally at [http://localhost:11434/](http://localhost:11434/), see [the Ollama blog](https://ollama.com/blog/openai-compatibility) for more details.

Example:

```
text:
- Hello,
- model: ollama_chat/granite-code:8b
  parameters:
    stop:
    - '!'
    decoding_method: greedy
```

If you want to use an external Ollama instance, the env variable `OLLAMA_API_BASE` should be defined, by default is `http://localhost:11434`.

Alternatively, one could also use Ollama's OpenAI-style endpoint using the `openai/` prefix instead of `ollama_chat/`. In this case, set the `OPENAI_API_BASE`, `OPENAI_API_KEY`, and `OPENAI_ORGANIZATION` (if necessary) environment variables. If you were using the official OpenAI API, you would only have to set the api key and possibly the organization. For local use e.g., using Ollama, this could look like so:

```bash
export OPENAI_API_BASE=http://localhost:11434/v1
export OPENAI_API_KEY=ollama # required, but unused
export OPENAI_ORGANIZATION=ollama # not required

pdl <...>
```

## Strings in Yaml

Multiline strings are commonly used when writing PDL programs. There are two types of formats that YAML supports for strings: block scalar and flow scalar formats. Scalars are what YAML calls basic values like numbers or strings, as opposed to complex types like arrays or objects. Block scalars have more control over how they are interpreted, whereas flow scalars have more limited escaping support. (Explanation in this section are based on [yaml-multiline.info](https://yaml-multiline.info/) by Wolfgang Faust.)

### Block Scalars

**Block Style Indicator**: The block style indicates how newlines inside the block should behave. If you would like them to be **kept** as newlines, use the literal style, indicated by a pipe `|`. Note that without a chomping indicator, described next, only the *last* newline is kept.

PDL:

```
text:
  - |
    Several lines of text,
    with some "quotes" of various 'types',
    and also a blank line:

    and some text with
        extra indentation
    on the next line,
    plus another line at the end.


  - "End."
```

Output:

```
Several lines of text,
with some "quotes" of various 'types',
and also a blank line:

and some text with
    extra indentation
on the next line,
plus another line at the end.
End.
```

If instead you want them to be replaced by spaces, use the folded style, indicated by a right angle bracket `>`. To get a newline using the folded style, leave a blank line by putting *two* newlines in. Lines with extra indentation are also not folded.

PDL:

```
text:
  - >
    Several lines of text,
    with some "quotes" of various 'types',
    and also a blank line:

    and some text with
        extra indentation
    on the next line,
    plus another line at the end.


  - "End."
```

Output:

```
Several lines of text, with some "quotes" of various 'types', and also a blank line:
and some text with
    extra indentation
on the next line, plus another line at the end.
End.
```

**Block Chomping Indicator**: The chomping indicator controls what should happen with newlines at the end of the string. The default, clip, puts a single newline at the end of the string. To remove all newlines, strip them by putting a minus sign `-` after the style indicator. Both clip and strip ignore how many newlines are actually at the end of the block; to keep them all put a plus sign `+` after the style indicator.

PDL:

```
text:
  - |-
    Several lines of text,
    with some "quotes" of various 'types',
    and also a blank line:

    and some text with
        extra indentation
    on the next line,
    plus another line at the end.


  - "End."
```

Output:

```
Several lines of text,
with some "quotes" of various 'types',
and also a blank line:

and some text with
    extra indentation
on the next line,
plus another line at the end.End.
```

PDL:

```
text:
  - |+
    Several lines of text,
    with some "quotes" of various 'types',
    and also a blank line:

    and some text with
        extra indentation
    on the next line,
    plus another line at the end.


  - "End."
```

Output:

```
Several lines of text,
with some "quotes" of various 'types',
and also a blank line:

and some text with
    extra indentation
on the next line,
plus another line at the end.


End.
```

If you don't have enough newline characters using the above methods, you can always add more like so:

```
text:
  - |-
    Several lines of text,
    with some "quotes" of various 'types',
    and also a blank line:

    and some text with
        extra indentation
    on the next line,
    plus another line at the end.


  - "\n\n\n\n"
  - "End."
```

Output:

```
Several lines of text,
with some "quotes" of various 'types',
and also a blank line:

and some text with
    extra indentation
on the next line,
plus another line at the end.



End.
```

**Indentation Indicator**: Ordinarily, the number of spaces you're using to indent a block will be automatically guessed from its first line. You may need a block indentation indicator if the first line of the block starts with extra spaces. In this case, simply put the number of spaces used for indentation (between 1 and 9) at the end of the header.

PDL:

```
text:
  - |1
    Several lines of text,
    with some "quotes" of various 'types',
    and also a blank line:

    and some text with
        extra indentation
    on the next line.
```

Output:

```
 Several lines of text,
 with some "quotes" of various 'types',
 and also a blank line:

 and some text with
     extra indentation
 on the next line.
```

### Flow Scalars

**Single-quoted**:

PDL:

```
text: 'Several lines of text,
  containing ''single quotes''. Escapes (like \n) don''t do anything.

  Newlines can be added by leaving a blank line.
    Leading whitespace on lines is ignored.'
```

Output:

```
Several lines of text, containing 'single quotes'. Escapes (like \n) don't do anything.
Newlines can be added by leaving a blank line. Leading whitespace on lines is ignored.
```

**Double-quoted**:

PDL:

```
text: "Several lines of text,
  containing \"double quotes\". Escapes (like \\n) work.\nIn addition,
  newlines can be esc\
  aped to prevent them from being converted to a space.

  Newlines can also be added by leaving a blank line.
    Leading whitespace on lines is ignored."
```

Output:

```
Several lines of text, containing "double quotes". Escapes (like \n) work.
In addition, newlines can be escaped to prevent them from being converted to a space.
Newlines can also be added by leaving a blank line. Leading whitespace on lines is ignored.
```

**Plain**:

PDL:

```
text: Several lines of text,
  with some "quotes" of various 'types'.
  Escapes (like \n) don't do anything.

  Newlines can be added by leaving a blank line.
    Additional leading whitespace is ignored.
```

Output:

```
Several lines of text, with some "quotes" of various 'types'. Escapes (like \n) don't do anything.
Newlines can be added by leaving a blank line. Additional leading whitespace is ignored.
```


================================================
FILE: docs/viewer.md
================================================
---
hide:
  - navigation
  - toc
  - footer
---

<style>
.md-typeset {
  margin: 0;
  padding: 0;
}
.md-grid {margin-top: 0;}
.md-typeset > h1,
.md-content__button {
  display: none;
}
iframe {
  width: 100%;
  min-height: 800px; /* TODO */
}
</style>

<iframe src="https://pdl.s3-web.us-east.cloud-object-storage.appdomain.cloud/#?iframe" frameborder="0" height="100%"></iframe>


================================================
FILE: examples/aggregators/contribute_in_file.pdl
================================================
defs:
  log:
    aggregator: 
      file: /tmp/log.txt
text:
- Hello
- model: ollama_chat/granite4:micro
  parameters:
    temperature: 0
  contribute: [ result, context, log ]
- nice to meet you.
- model: ollama_chat/granite4:micro
  parameters:
    temperature: 0
  modelResponse: raw_response
  contribute:
    - result
    - log:
        value: ${raw_response}
- Bye


================================================
FILE: examples/aggregators/contribute_in_stderr.pdl
================================================
text:
- Hello
- text: Before model call
  contribute: [ stderr ]
- model: ollama_chat/granite4:micro
  parameters:
    temperature: 0
- contribute:
    - stderr:
        value: After model call


================================================
FILE: examples/aggregators/contribute_in_stdout.pdl
================================================
text:
- Hello
- text: Before model call
  contribute: [ stdout ]
- model: ollama_chat/granite4:micro
  parameters:
    temperature: 0
- contribute:
    - stdout:
        value: After model call


================================================
FILE: examples/callback/README.md
================================================
# Callback example

This example shows a Python program `repair_main.py` that calls a PDL program `repair_prompt.pdl` through the SDK. Then, `repair_prompt.pdl` calls a function `parse_output` defined in `repair_main.py` to obtain more information. Finally, the PDL program returns to Python an output that the Python code prints. In this example, all data is passed back and forth between Python and PDL using JSON. This JSON data is type-checked using `TypedDict` on the Python side and using `spec` on the PDL side.

To run:

```
python repair_main.py
```

Expected output:

```
---- before call to PDL ----
---- during callback from PDL ----
---- after return from PDL ----
{'before': "print('Hello, world!']", 'after': "print('Hello, world!')"}
```

================================================
FILE: examples/callback/repair_main.py
================================================
import re
from typing import TypedDict, cast

import pdl.pdl

PDLScope = TypedDict("PDLScope", {"code_line": str, "error_msg": str})
ParsedOutput = TypedDict("ParsedOutput", {"thought": str, "code_line": str | None})
PDLResult = TypedDict("PDLResult", {"before": str, "after": str | None})


def parse_output(raw_output: str) -> ParsedOutput:
    print("---- during callback from PDL ----")
    match_start = re.search(r"```python\s", raw_output)
    if not match_start:
        return ParsedOutput(thought=raw_output, code_line=None)
    thought = raw_output[: match_start.start()]
    rest = raw_output[match_start.end() :]
    match_end = re.search(r"\s```", rest)
    if not match_end:
        return ParsedOutput(thought=thought, code_line=rest)
    return ParsedOutput(thought=thought, code_line=rest[: match_end.start()])


if __name__ == "__main__":
    pdl_input = PDLScope(
        code_line="print('Hello, world!']",
        error_msg="SyntaxError: closing parenthesis ']' does not match opening '('",
    )
    print("---- before call to PDL ----")
    pdl_output: PDLResult = pdl.pdl.exec_file(
        "./repair_prompt.pdl", scope=cast(dict, pdl_input)
    )
    print("---- after return from PDL ----")
    print(pdl_output)


================================================
FILE: examples/callback/repair_prompt.pdl
================================================
lastOf:
- |
  Given the following code:
  ```python
  ${code_line}
  ```
  and the following error:
  ${error_msg}
  Please repair the code!

- def: raw_output
  model: ollama_chat/granite4:micro
  parameters:
    temperature: 0

- lang: python
  def: parsed_output
  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: string, after: string}
  object:
    before: ${code_line}
    after: ${parsed_output.code_line}


================================================
FILE: examples/chatbot/chatbot.pdl
================================================
description: A Chatbot that responds to user's questions
text:
# Allow the user to type any question, implicitly adding the question to the context.
- read:
  message: "What is your query?\n"
- repeat:
    text:
    # Send context to Granite model hosted at ollama
    - model: ollama_chat/granite4:micro
    # Allow the user to type 'yes', 'no', or anything else, storing
    # the input into a variable named `eval`.  The input is also implicitly
    # added to the context.
    - read:
      def: eval
      message: "\nIs this a good answer[yes/no]?\n"
    - "\n"
    # If the user only typed "no", prompt the user for input to add to the context.
    - if: ${ eval == 'no' }
      then:
        text:
        - read:
          message: "Why not?\n"
  # If the user typed only "yes", finish the `repeat` and end the program
  until: ${ eval == 'yes'}


================================================
FILE: examples/cldk/README.md
================================================
The PDL program `cldk-assistant.pdl` makes use of the [CLDK](https://github.com/IBM/codellm-devkit) toolkit to analyze a Java project and answer user questions about the project.

To install CLDK:
```
pip install git+https://github.com/IBM/codellm-devkit.git
```

For example, download the `commons-cli` Java project as follows:
```
wget https://github.com/apache/commons-cli/archive/refs/tags/rel/commons-cli-1.7.0.zip -O commons-cli-1.7.0.zip && unzip commons-cli-1.7.0.zip
```

To run the CLDK assistant:
```
pdl cldk-assistant.pdl
```

Enter the path to the above Java project when prompted. Then you can make queries such as "what are all the classes?".

================================================
FILE: examples/cldk/cldk-assistant.pdl
================================================
description: CodeLLM-Devkit Assistant
text:
- read:
  def: project
  message: "Please enter the path to your Java project:\n"
  contribute: []
- "***Analyzing...\n"
- lang: python
  def: analysis
  contribute: []
  code: |
    import os
    from rich import print  # Optional, for pretty printing.
    from cldk import CLDK
    from cldk.models.java.models import *

    # Initialize the Codellm-DevKit object with the project directory, language, and backend.
    cldk = CLDK("java")
    cldk_state = cldk.analysis(
        project_path="${ project }",   # Change this to the path of the project you want to analyze.
        # language="java",  # The language of the project.
        # backend="codeanalyzer",  # The backend to use for the analysis.
        # analysis_db="/tmp",  # A temporary directory to store the analysis results.
        # sdg=True, # Generate the System Dependence Graph (SDG) for the project.
    )
    PDL_SESSION.cldk_state = cldk_state
    result = cldk_state
- " done!"
- repeat:
    text:
    - read:
      def: query
      message: "\n\nHow can I help you [Type 'quit' to quit]?\n"
      contribute: []
    - "\n***Generating PDL code for your query:\n"
    - if: ${ query != 'quit'}
      then:
        text:
          - model: ollama_chat/granite4:micro
            def: PDL
            input: |
                Question: What are all the classes?
                Answer:
                ```
                text:
                - lang: python
                  code:|
                    classes = PDL_SESSION.cldk_state.get_classes().keys()
                    result = ", ".join(classes)
                ```

                Question: What are all the constructors of class org.ibm.App?
                Answer:
                ```
                text:
                - lang: python
                  code: |
                    constructors = PDL_SESSION.cldk_state.get_constructors("org.ibm.App")
                    result = ", ".join(constructors)
                ```

                Question: What are all the fields of class org.ibm.App?
                Answer:
                ```
                text:
                - lang: python
                  code: |
                    fields = PDL_SESSION.cldk_state.get_fields("org.ibm.App")
                    names = sum([f.variables for f in fields], [])
                    result = ", ".join(names)
                ```

                Question: What are all the methods of class org.ibm.App?
                Answer:
                ```
                text:
                - lang: python
                  code: |
                    methods = PDL_SESSION.cldk_state.get_methods_in_class("org.ibm.App")
                    result = ", ".join(methods)
                ```

                Question: Show me the call graph of class "org.ibm.App"
                Answer:
                ```
                text:
                - lang: python
                  code: |
                    graph =  PDL_SESSION.cldk_state.get_class_call_graph("org.ibm.App", method_name=None)
                    result = graph
                ```

                Question: What is the code of method Foo(string) of class org.ibm.App?
                Answer:
                ```
                text:
                - lang: python
                  code: |
                    method = PDL_SESSION.cldk_state.get_method("org.ibm.App", "Foo(string)")
                    result = method.code
                ```

                Question: Generate a summary for method Foo(string) of class org.ibm.App
                Answer:
                ```
                text:
                - lang: python
                  code: |
                    method = PDL_SESSION.cldk_state.get_method("org.ibm.App", "Foo(string)")
                    result = method
                - "\n\nGenerate a summary of method Foo\n\n"
                - model: ollama_chat/granite4:micro
                ```

                Question: Generate a different comment for method Foo(string) in class org.ibm.App?
                Answer:
                ```
                text:
                - lang: python
                  code: |
                    method = PDL_SESSION.cldk_state.get_method("org.ibm.App", "Foo(string)")
                    result = method
                - "\n\nGenerate a different comment for method Foo(string)\n\n"
                - model: ollama_chat/granite4:micro
                ```

                If the query contains something about a field be sure to call a model.

                Question: ${ query }


            parameters:
              stop: ["Question"]
              temperature: 0
          - "\n\n***Executing the above PDL code:\n\n"
          - lang: python
            contribute: [result]
            code: |
              from pdl.pdl import exec_str
              s = """${ PDL }"""
              pdl = s.split("```")[1]
              result = exec_str(pdl)

  until: ${ query == 'quit' }


================================================
FILE: examples/demo/1-hello.pdl
================================================
description: Model call
text:
- "Hello\n"
- model: ollama_chat/granite4:micro
  parameters:
    stop: ["!"]




================================================
FILE: examples/demo/10-sdg.pdl
================================================
defs:
  teacher_sys_prompt: You are a very knowledgeable AI Assistant that will faithfully assist the user with their task.
  teacher_model: ollama_chat/granite4:micro
  teacher_template:
    function:
      sys_prompt: string
      prompt: string
    return: <s> [INST] ${sys_prompt} ${prompt} [/INST]
  teacher_stop_token: </s>


  question_template_freeform:
    function:
      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: |
          You are asked to come up with a set of ${num_samples} diverse questions - ${task_description}.
        principles: |
          Please follow these guiding principles when generating responses:
          * Use proper grammar and punctuation.
          * Always generate safe and respectful content. Do not generate content that is harmful, abusive, or offensive.
          * Always generate content that is factually accurate and relevant to the prompt.
          * The questions should be clear and human-like.
          * The questions should be diverse and cover a wide range of topics.
          * The questions should not be template-based or generic, it should be very diverse.
          * Simply return the questions, do not return any answers or explanations.
          * Strictly adhere to the prompt and generate responses in the same style and format as the example.
          Use this format to generate the questions:
          ### Question 1:
        examples: |
          To better assist you with this task, here is an example:
          ### Question 1: ${icl_question}
        generation: |
          Now generate ${num_samples} such questions, remember to follow the principles mentioned above and use the same format as the examples. Remember to use the same style and format as the example above.
        max_new_tokens: 10000

  gen_questions_freeform_inner:
    function:
      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: string, principles: string, examples: string, generation: string, max_new_tokens: integer }
          args:
            num_samples: ${num_samples}
            task_description: ${task_description}
            icl_question: ${icl_question}
        teacher_input:
          call: ${teacher_template}
          args:
            sys_prompt: ${teacher_sys_prompt}
            prompt: |-
              ${prompt_data.introduction}
              ${prompt_data.principles}
              ${prompt_data.examples}
              ${prompt_data.generation}
        teacher_output:
          model: ${teacher_model}
          input: ${teacher_input}
          parameters:
            temperature: 0
            stop: ["${teacher_stop_token}"]
            max_new_tokens: ${prompt_data.max_new_tokens}
          parser:
            regex: '### Question [0-9]+:\s*([^#\n]+)'
            mode: findall
      for:
        question: ${teacher_output}
      repeat:
        data:
          icl_question: ${icl_question}
          icl_answer: ${icl_answer}
          question: ${question}
      join:
        as: array

  gen_questions_freeform:
    function:
      task_description: string
      seed_examples: [{question: string, answer: string}]
    spec: [{icl_question: string, icl_answer: string, question: string}]
    return:
      defs:
        list_of_lists:
          for:
            example: ${seed_examples}
          repeat:
            call: ${gen_questions_freeform_inner}
            args:
              num_samples: 2
              task_description: ${task_description}
              icl_question: ${example.question}
              icl_answer: ${example.answer}
          join:
            as: array
      lang: python
      code: | # flatten list_of_lists into simple list
          result = [q for qs in ${list_of_lists} for q in qs]


  filter_questions_template:
    function:
      task_description: string
      question: string
    spec: {introduction: string, principles: string, generation: string, max_new_tokens: integer}
    return:
      data:
        introduction: |
          Please act as an impartial judge and evaluate the questions generated by an AI assistant displayed below. Evaluate whether or not the question is a good question of how AI Assistant should respond to the user's instruction. Please assign a score using a binary 0/1 scale.
        principles: |
          Here are the requirements:
          * A large language model should be able to complete the question. For example, do not ask the assistant to create any visual or audio output. For another example, do not ask the assistant to wake you up at 5pm or set a reminder because it cannot perform any action.
          * The questions should be in English.
          * The questions should be 1 to 2 sentences long and should be properly formatted.
          * The question should not be offensive, abusive, or harmful. It should be safe and respectful.
          * The question should be relevant to the task given - ${task_description}.
          If the question meets the above requirements, please rate it 1. If not, please rate it 0.
        generation: |
          Begin your evaluation by providing a short explanation. Be as objective as possible. After providing your explanation, you must rate the question on a scale of 0 or 1 as mentioned above by strictly following this format: \"[[rating]]\", for example: \"Rating: [[1]]\"
          Here is the question you need to evaluate:
          ${question}
        max_new_tokens: 256

  # https://github.com/instruct-lab/datagen-pipeline/blob/main/sdg/filter_questions.py
  filter_questions_inner:
    function:
      task_description: string
      question: string
    spec: number
    return:
      defs:
        prompt_data:
          call: ${filter_questions_template}
          spec: {introduction: string, principles: string, generation: string, max_new_tokens: integer}
          args:
            task_description: ${task_description}
            question: ${question}
        teacher_input:
          call: ${teacher_template}
          args:
            sys_prompt: ${teacher_sys_prompt}
            prompt: |-
              ${prompt_data.introduction}
              ${prompt_data.principles}
              ${prompt_data.generation}
        teacher_output:
          model: ${teacher_model}
          input: ${teacher_input}
          parameters:
            stop: ["${teacher_stop_token}"]
            max_new_tokens: ${prompt_data.max_new_tokens}
            temperature: 0
          parser:
            spec: { "rating": string }
            # regex: "Rating.*\\[\\[(?P<rating>\\d+\\.?\\d*)\\]\\]"
            regex: 'Rating.*\[\[(?P<rating>\d+\.?\d*)\]\]'
            mode: search
      data: ${ (teacher_output.rating if teacher_output is not none else 0.0) | float }

  filter_questions:
    function:
      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:
          for:
            question: ${questions}
          repeat:
            defs:
              filter_output:
                call: ${filter_questions_inner}
                args:
                  task_description: ${task_description}
                  question: ${question.question}
            data:
              question: ${question}
              keep: ${filter_output}
          join:
            as: array
        filtered:
          lang: python
          code: | # keep only if "keep" column is non-zero
              result = [p["question"] for p in ${ list_of_pairs } if p["keep"]]
      data: ${filtered}


  answer_template:
    function:
      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.
        principles: |
          Please follow these guiding principles when generating responses:
          * Use proper grammar and punctuation.
          * Always generate safe and respectful content. Do not generate content that is harmful, abusive, or offensive.
          * Always generate content that is factually accurate and relevant to the prompt.
          * Strictly adhere to the prompt and generate responses in the same style and format as the example.
        examples: |
          To better assist you with this task, here is an example:
          [Question]
          ${icl_question}
          [Response]
          ${icl_response}
        generation: |
          Now generate a response to the following prompt. Remember to use the same style and format as the example above.
          [Question]
          ${question}
          [Response]
        max_new_tokens: 2048
        additional_stop_tokens:
        - "[Question]"


  gen_answers_inner:
    function:
      question: {icl_question: string, icl_answer: string, question: string}
    spec: {question: string, answer: string}
    return:
      defs:
        prompt_data:
          call: ${answer_template}
          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}
            question: ${question.question}
        teacher_input:
          call: ${teacher_template}
          args:
            sys_prompt: ${teacher_sys_prompt}
            prompt: |-
              ${prompt_data.introduction}
              ${prompt_data.principles}
              ${prompt_data.examples}
              ${prompt_data.generation}
        teacher_output:
          model: ${teacher_model}
          input: ${teacher_input}
          parameters:
            stop: ["${ ([teacher_stop_token] + prompt_data.additional_stop_tokens) | join(',') }"]
            max_new_tokens: ${prompt_data.max_new_tokens}
            temperature: 0
        parsed_answer:
          lang: python
          code: | # parse model output
            result = """ ${teacher_output} """.strip()
            if "[Response]" in result:
              result = result[result.find("[Response]") + len("[Response]"):]
            if "[Question]" in result:
              result = result[:result.find("[Question]")]
      data:
        question: ${question.question}
        answer: ${parsed_answer}

  gen_answers:
    function:
      questions: [{icl_question: string, icl_answer: string, question: st
Download .txt
gitextract_ir46b86_/

├── .flake8
├── .github/
│   ├── ISSUE_TEMPLATE/
│   │   ├── bug_report.md
│   │   └── feature_request.md
│   ├── actions/
│   │   ├── ollama/
│   │   │   └── action.yml
│   │   └── run-examples/
│   │       └── action.yml
│   ├── dependabot.yml
│   └── workflows/
│       ├── build.yml
│       ├── mkdocs-gh-pages.yml
│       ├── pdl-live-react-tests.yml
│       ├── publish-quay.yaml
│       ├── release-static-web-app.yml
│       ├── release-ui.yml
│       ├── release.yml
│       ├── run-examples-prep.yml
│       ├── run-examples.yml
│       ├── rust-interpreter.yml
│       └── tauri-cli.yml
├── .gitignore
├── .pre-commit-config.yaml
├── .vscode/
│   ├── launch.json
│   └── settings.json
├── LICENSE
├── README.md
├── bandit.yaml
├── contrib/
│   └── prompt_library/
│       ├── CoT.pdl
│       ├── ProbReAct.pdl
│       ├── ReAct.pdl
│       ├── ReWoo.pdl
│       └── tools.pdl
├── dockerfile
├── docs/
│   ├── .nojekyll
│   ├── README.md
│   ├── api_reference.md
│   ├── autopdl.md
│   ├── contrib.md
│   ├── css/
│   │   └── index.css
│   ├── stylesheets/
│   │   └── extra.css
│   ├── telemetry.md
│   ├── tutorial.md
│   └── viewer.md
├── examples/
│   ├── aggregators/
│   │   ├── contribute_in_file.pdl
│   │   ├── contribute_in_stderr.pdl
│   │   └── contribute_in_stdout.pdl
│   ├── callback/
│   │   ├── README.md
│   │   ├── repair_main.py
│   │   └── repair_prompt.pdl
│   ├── chatbot/
│   │   └── chatbot.pdl
│   ├── cldk/
│   │   ├── README.md
│   │   └── cldk-assistant.pdl
│   ├── demo/
│   │   ├── 1-hello.pdl
│   │   ├── 10-sdg.pdl
│   │   ├── 11-repeat.pdl
│   │   ├── 2-model-chaining.pdl
│   │   ├── 3-def-use.pdl
│   │   ├── 4-function.pdl
│   │   ├── 5-code-eval.pdl
│   │   ├── 6-code-json.pdl
│   │   ├── 7-chatbot-roles.pdl
│   │   ├── 8-tools.pdl
│   │   ├── 9-react.pdl
│   │   ├── data.yaml
│   │   ├── ground_truth.txt
│   │   └── qna.yaml
│   ├── demos/
│   │   ├── granite_io_hallucinations.pdl
│   │   ├── react.pdl
│   │   ├── repair_main.py
│   │   └── repair_prompt.pdl
│   ├── expectations/
│   │   ├── email.pdl
│   │   ├── gsm8k_short.pdl
│   │   └── mbpp.pdl
│   ├── fibonacci/
│   │   └── fib.pdl
│   ├── granite-io/
│   │   ├── granite_io_hallucinations.pdl
│   │   ├── granite_io_object.pdl
│   │   ├── granite_io_openai.pdl
│   │   ├── granite_io_thinking.pdl
│   │   └── granite_io_transformers.pdl
│   ├── gsm8k/
│   │   ├── README.md
│   │   ├── demos.yaml
│   │   ├── gsm8k-loop-fission.pdl
│   │   ├── gsm8k-plan-few-shots.pdl
│   │   ├── gsm8k-plan.pdl
│   │   ├── gsm8k-tot-few-shot.pdl
│   │   ├── gsm8k-tot-multiplan.pdl
│   │   ├── gsm8k-tot.pdl
│   │   └── gsm8k.pdl
│   ├── independent/
│   │   ├── independent.pdl
│   │   ├── independent_docs.pdl
│   │   ├── independent_for.pdl
│   │   └── test.pdl
│   ├── input/
│   │   ├── data.txt
│   │   ├── input_test.pdl
│   │   ├── input_test1.pdl
│   │   └── input_test2.pdl
│   ├── intrinsics/
│   │   ├── README.md
│   │   ├── demo-hallucination.json
│   │   └── demo-hallucination.pdl
│   ├── map-reduce/
│   │   ├── context_fork.pdl
│   │   ├── python-reduce.pdl
│   │   └── reduce.pdl
│   ├── notebooks/
│   │   ├── data.yaml
│   │   ├── demo.ipynb
│   │   ├── demonstrations.txt
│   │   ├── granite_io_demo.ipynb
│   │   ├── ground_truth.txt
│   │   ├── notebook.ipynb
│   │   ├── notebook_debug.ipynb
│   │   └── pdl.ipynb
│   ├── openai/
│   │   ├── README.md
│   │   ├── openai_basic.pdl
│   │   └── openai_structured.pdl
│   ├── optimizer/
│   │   ├── __init__.py
│   │   ├── config.yml
│   │   ├── eval_levenshtein.pdl
│   │   ├── fever.pdl
│   │   ├── fever_evaluator.py
│   │   ├── grammar_correction.pdl
│   │   ├── grammar_correction.yaml
│   │   ├── gsm8k.pdl
│   │   ├── gsm8k_evaluator.py
│   │   ├── gsm8k_optimizer_config.yml
│   │   ├── gsmhard_evaluator.py
│   │   ├── mbpp.pdl
│   │   ├── mbpp_dataset.py
│   │   ├── mbpp_evaluator.py
│   │   ├── optimize.py
│   │   ├── optimized_grammar_correction.pdl
│   │   ├── process_fever.py
│   │   ├── process_grammar_correction.py
│   │   ├── process_gsm8k.py
│   │   └── process_mbpp.py
│   ├── ppdl/
│   │   ├── coin.pdl
│   │   ├── hmm.pdl
│   │   ├── hmm_nl_priors.pdl
│   │   ├── mbpp.pdl
│   │   ├── name_finder.ipynb
│   │   └── name_finder.pdl
│   ├── prompt_library/
│   │   ├── gsm8k_cot.pdl
│   │   ├── gsm8k_prob_react.pdl
│   │   ├── gsm8k_react.pdl
│   │   └── gsm8k_rewoo.pdl
│   ├── rag/
│   │   ├── README.md
│   │   ├── pdf_index.pdl
│   │   ├── pdf_query.pdl
│   │   ├── rag.py
│   │   ├── rag_library1.pdl
│   │   └── tfidf_rag.pdl
│   ├── react/
│   │   ├── demonstrations.txt
│   │   └── react_demo.pdl
│   ├── skeleton-of-thought/
│   │   ├── tips.pdl
│   │   └── topic.jsonl
│   ├── teacher/
│   │   ├── qna.yaml
│   │   └── teacher.pdl
│   ├── test.pdl
│   ├── tools/
│   │   ├── calc.pdl
│   │   └── search.pdl
│   └── tutorial/
│       ├── calling_llm.pdl
│       ├── calling_llm_chaining.pdl
│       ├── calling_llm_with_input.pdl
│       ├── calling_llm_with_input_messages.pdl
│       ├── calling_llm_with_input_messages_var.pdl
│       ├── code_command.pdl
│       ├── code_jinja.pdl
│       ├── code_jinja_parameters.pdl
│       ├── code_pdl.pdl
│       ├── code_python.pdl
│       ├── code_scope.pdl
│       ├── code_session.pdl
│       ├── data.txt
│       ├── data.yaml
│       ├── data_block_raw.pdl
│       ├── defs.pdl
│       ├── for.pdl
│       ├── for_array.pdl
│       ├── for_lastOf.pdl
│       ├── for_multiple_lists.pdl
│       ├── for_object.pdl
│       ├── for_with.pdl
│       ├── free_variables.pdl
│       ├── function_alias.pdl
│       ├── function_call_in_jinja.pdl
│       ├── function_definition.pdl
│       ├── function_empty_context.pdl
│       ├── function_optional_params.pdl
│       ├── if.pdl
│       ├── import.pdl
│       ├── import_lib.pdl
│       ├── input.json
│       ├── input_file.pdl
│       ├── input_file_json.pdl
│       ├── input_stdin.pdl
│       ├── input_stdin_multiline.pdl
│       ├── lastOf.pdl
│       ├── local_computation.pdl
│       ├── loop_index.pdl
│       ├── muting_block_output.pdl
│       ├── parser-regex.pdl
│       ├── parser_findall.pdl
│       ├── parser_regex_code.pdl
│       ├── pdl_scope.pdl
│       ├── pdl_usage.pdl
│       ├── programs/
│       │   ├── chatbot.pdl
│       │   ├── code/
│       │   │   ├── README.md
│       │   │   ├── code-eval.pdl
│       │   │   ├── code-json-output.json
│       │   │   ├── code-json.pdl
│       │   │   ├── code.pdl
│       │   │   ├── data.yaml
│       │   │   └── ground_truth.txt
│       │   ├── demo-hallucination.pdl
│       │   └── weather.pdl
│       ├── repeat.pdl
│       ├── role.pdl
│       ├── sdk/
│       │   ├── hello.pdl
│       │   ├── hello_dict.py
│       │   ├── hello_file.py
│       │   ├── hello_parallel.py
│       │   ├── hello_prog.py
│       │   ├── hello_str.py
│       │   ├── lib.pdl
│       │   └── run_pdl.py
│       ├── simple_program.pdl
│       ├── structured_decoding.pdl
│       ├── type_checking.pdl
│       ├── type_checking_data.yaml
│       ├── type_error.pdl
│       ├── type_list.pdl
│       ├── variable_def_use.pdl
│       └── while.pdl
├── mkdocs.yml
├── mypy.ini
├── pdl-live-react/
│   ├── .editorconfig
│   ├── .gitignore
│   ├── .vscode/
│   │   └── extensions.json
│   ├── README.md
│   ├── demos/
│   │   ├── beeai/
│   │   │   └── test1.py
│   │   ├── demo1.pdl
│   │   ├── demo2.pdl
│   │   ├── error.pdl
│   │   ├── gen-data.yaml
│   │   └── run.sh
│   ├── eslint.config.js
│   ├── index.html
│   ├── package.json
│   ├── playwright.config.ts
│   ├── src/
│   │   ├── App.tsx
│   │   ├── demos/
│   │   │   ├── README.md
│   │   │   ├── demo1.json
│   │   │   ├── demo2.json
│   │   │   ├── demo3.json
│   │   │   ├── demo4.json
│   │   │   ├── demo5.json
│   │   │   ├── demo6.json
│   │   │   ├── demo7.json
│   │   │   ├── demo8.json
│   │   │   ├── demo9.json
│   │   │   └── demos.ts
│   │   ├── helpers.ts
│   │   ├── main.tsx
│   │   ├── page/
│   │   │   ├── About.tsx
│   │   │   ├── ClearMyTraces.tsx
│   │   │   ├── DarkModeContext.ts
│   │   │   ├── DarkModeToggle.tsx
│   │   │   ├── Demo.tsx
│   │   │   ├── DemoNavItems.tsx
│   │   │   ├── Demos.tsx
│   │   │   ├── ErrorBoundary.tsx
│   │   │   ├── Local.tsx
│   │   │   ├── Masthead.css
│   │   │   ├── Masthead.tsx
│   │   │   ├── MyTrace.tsx
│   │   │   ├── MyTraces.ts
│   │   │   ├── MyTracesNavItems.tsx
│   │   │   ├── MyTracesPage.tsx
│   │   │   ├── Page.css
│   │   │   ├── Page.tsx
│   │   │   ├── PageBreadcrumbDropdown.tsx
│   │   │   ├── PageBreadcrumbDropdownItem.tsx
│   │   │   ├── PageBreadcrumbs.css
│   │   │   ├── PageBreadcrumbs.tsx
│   │   │   ├── Run.css
│   │   │   ├── Run.tsx
│   │   │   ├── Sidebar.tsx
│   │   │   ├── Uploader.css
│   │   │   ├── Uploader.tsx
│   │   │   └── welcome/
│   │   │       ├── Intro.tsx
│   │   │       ├── Links.tsx
│   │   │       ├── Tile.tsx
│   │   │       ├── Tiles.tsx
│   │   │       ├── Toolbar.tsx
│   │   │       ├── Welcome.css
│   │   │       ├── Welcome.tsx
│   │   │       └── tiles/
│   │   │           ├── Demos.tsx
│   │   │           └── MyTraces.tsx
│   │   ├── pdl_ast.d.ts
│   │   ├── pdl_ast_utils.ts
│   │   ├── pdl_code_cleanup.ts
│   │   ├── routes/
│   │   │   └── PdlRoutes.tsx
│   │   ├── svg.d.ts
│   │   ├── title.ts
│   │   ├── view/
│   │   │   ├── CopyToClipboard.css
│   │   │   ├── CopyToClipboard.tsx
│   │   │   ├── Markdown.css
│   │   │   ├── Markdown.tsx
│   │   │   ├── Result.tsx
│   │   │   ├── Value.tsx
│   │   │   ├── breadcrumbs/
│   │   │   │   ├── BreadcrumbBar.css
│   │   │   │   ├── BreadcrumbBar.tsx
│   │   │   │   ├── BreadcrumbBarForBlock.tsx
│   │   │   │   ├── BreadcrumbBarForBlockId.tsx
│   │   │   │   ├── BreadcrumbBarItem.tsx
│   │   │   │   └── Def.tsx
│   │   │   ├── code/
│   │   │   │   ├── Code.tsx
│   │   │   │   ├── CodeGroup.tsx
│   │   │   │   ├── PreviewLight.css
│   │   │   │   └── PreviewLight.tsx
│   │   │   ├── detail/
│   │   │   │   ├── BlockNotFound.tsx
│   │   │   │   ├── ContextTabContent.tsx
│   │   │   │   ├── DefContent.css
│   │   │   │   ├── DefContent.tsx
│   │   │   │   ├── DrawerContent.css
│   │   │   │   ├── DrawerContent.tsx
│   │   │   │   ├── DrawerContentBody.tsx
│   │   │   │   ├── Group.tsx
│   │   │   │   ├── RawTraceTabContent.tsx
│   │   │   │   ├── ResultTabContent.tsx
│   │   │   │   ├── SourceTabContent.tsx
│   │   │   │   ├── SummaryTabContent.tsx
│   │   │   │   ├── UsageTabContent.tsx
│   │   │   │   ├── find.ts
│   │   │   │   └── kind/
│   │   │   │       ├── Call.tsx
│   │   │   │       ├── Code.tsx
│   │   │   │       ├── Data.tsx
│   │   │   │       ├── Error.tsx
│   │   │   │       ├── Function.tsx
│   │   │   │       ├── If.tsx
│   │   │   │       ├── Model.tsx
│   │   │   │       ├── Read.tsx
│   │   │   │       └── Text.tsx
│   │   │   ├── masonry/
│   │   │   │   ├── Duration.css
│   │   │   │   ├── Duration.tsx
│   │   │   │   ├── Masonry.css
│   │   │   │   ├── Masonry.tsx
│   │   │   │   ├── MasonryCombo.tsx
│   │   │   │   ├── MasonryTile.tsx
│   │   │   │   ├── MasonryTileWrapper.tsx
│   │   │   │   ├── RunMenu.tsx
│   │   │   │   ├── Stability.css
│   │   │   │   ├── Tile.ts
│   │   │   │   ├── Toolbar.tsx
│   │   │   │   ├── ToolbarPaginator.tsx
│   │   │   │   ├── ToolbarReplayButton.tsx
│   │   │   │   ├── ToolbarSMLToggle.tsx
│   │   │   │   ├── ToolbarShowSourceButton.tsx
│   │   │   │   ├── View.ts
│   │   │   │   ├── condvar.ts
│   │   │   │   ├── model.ts
│   │   │   │   └── stability.ts
│   │   │   ├── term/
│   │   │   │   ├── RunTerminal.css
│   │   │   │   └── RunTerminal.tsx
│   │   │   └── timeline/
│   │   │       ├── Timeline.css
│   │   │       ├── Timeline.tsx
│   │   │       ├── TimelineBar.tsx
│   │   │       ├── TimelineFromModel.tsx
│   │   │       ├── TimelineRow.tsx
│   │   │       ├── TimelineRowKindCell.tsx
│   │   │       └── model.ts
│   │   ├── vite-env.d.ts
│   │   └── window.d.ts
│   ├── src-tauri/
│   │   ├── .gitignore
│   │   ├── .taurignore
│   │   ├── Cargo.toml
│   │   ├── build.rs
│   │   ├── capabilities/
│   │   │   ├── default.json
│   │   │   └── desktop.json
│   │   ├── icons/
│   │   │   └── icon.icns
│   │   ├── src/
│   │   │   ├── cli.rs
│   │   │   ├── commands/
│   │   │   │   ├── interpreter.rs
│   │   │   │   ├── mod.rs
│   │   │   │   ├── read_trace.rs
│   │   │   │   └── replay_prep.rs
│   │   │   ├── compile/
│   │   │   │   ├── beeai.rs
│   │   │   │   └── mod.rs
│   │   │   ├── gui.rs
│   │   │   ├── lib.rs
│   │   │   ├── main.rs
│   │   │   ├── pdl/
│   │   │   │   ├── ast.rs
│   │   │   │   ├── extract.rs
│   │   │   │   ├── interpreter.rs
│   │   │   │   ├── interpreter_tests.rs
│   │   │   │   ├── mod.rs
│   │   │   │   ├── pip.rs
│   │   │   │   ├── pull.rs
│   │   │   │   └── requirements.rs
│   │   │   ├── util/
│   │   │   │   └── shasum.rs
│   │   │   └── util.rs
│   │   ├── tauri.conf.json
│   │   └── tests/
│   │       ├── cli/
│   │       │   ├── call-no-args.pdl
│   │       │   ├── call-with-args.pdl
│   │       │   ├── code-python.pdl
│   │       │   ├── data1.pdl
│   │       │   ├── data2.pdl
│   │       │   ├── data3.pdl
│   │       │   ├── data4.pdl
│   │       │   ├── if1.pdl
│   │       │   ├── if2.pdl
│   │       │   ├── include1.pdl
│   │       │   ├── json-parser-lastOf.pdl
│   │       │   ├── json-parser.pdl
│   │       │   ├── jsonl-parser.pdl
│   │       │   ├── model-input-array.pdl
│   │       │   ├── model-input-nested.pdl
│   │       │   ├── model-input-string.pdl
│   │       │   ├── object1.pdl
│   │       │   ├── object2.pdl
│   │       │   ├── read-file.pdl
│   │       │   ├── read-stdin.pdl
│   │       │   ├── regex-findall.pdl
│   │       │   ├── repeat1.pdl
│   │       │   ├── repeat2.pdl
│   │       │   ├── repeat3.pdl
│   │       │   ├── scoping_1.pdl
│   │       │   └── scoping_1_wrapper.pdl
│   │       └── data/
│   │           ├── bee_1.py
│   │           ├── foo.txt
│   │           └── struct.yaml
│   ├── tests/
│   │   └── basics.spec.test.ts
│   ├── tsconfig.app.json
│   ├── tsconfig.json
│   ├── tsconfig.node.json
│   └── vite.config.ts
├── pylintrc
├── pyproject.toml
├── renovate.json
├── scripts/
│   └── generate_pdl_examples_runner.sh
├── src/
│   └── pdl/
│       ├── __init__.py
│       ├── optimize/
│       │   ├── __init__.py
│       │   ├── config_parser.py
│       │   ├── optimizer_evaluator.py
│       │   ├── parse_number.py
│       │   ├── pdl_evaluator.py
│       │   ├── pdl_optimizer.py
│       │   └── util.py
│       ├── pdl-schema.json
│       ├── pdl.py
│       ├── pdl_analysis.py
│       ├── pdl_ast.py
│       ├── pdl_ast_utils.py
│       ├── pdl_compilers/
│       │   ├── __init__.py
│       │   └── to_regex.py
│       ├── pdl_context.py
│       ├── pdl_distributions.py
│       ├── pdl_dumper.py
│       ├── pdl_granite_io.py
│       ├── pdl_infer.py
│       ├── pdl_inference.py
│       ├── pdl_interpreter.py
│       ├── pdl_interpreter_state.py
│       ├── pdl_lazy.py
│       ├── pdl_linter.py
│       ├── pdl_llms.py
│       ├── pdl_location_utils.py
│       ├── pdl_notebook_ext.py
│       ├── pdl_openai.py
│       ├── pdl_parser.py
│       ├── pdl_python_repl.py
│       ├── pdl_runner.py
│       ├── pdl_scheduler.py
│       ├── pdl_schema_error_analyzer.py
│       ├── pdl_schema_utils.py
│       ├── pdl_schema_validator.py
│       ├── pdl_stdlib.pdl
│       ├── pdl_stdlib.py
│       └── pdl_utils.py
└── tests/
    ├── __init__.py
    ├── data/
    │   ├── call_expression_args.pdl
    │   ├── function.pdl
    │   ├── hello.pdl
    │   ├── input.json
    │   ├── input1.json
    │   ├── input_data.txt
    │   ├── line/
    │   │   ├── hello.pdl
    │   │   ├── hello1.pdl
    │   │   ├── hello10.pdl
    │   │   ├── hello11.pdl
    │   │   ├── hello12.pdl
    │   │   ├── hello13.pdl
    │   │   ├── hello14.pdl
    │   │   ├── hello15.pdl
    │   │   ├── hello16.pdl
    │   │   ├── hello16_data.json
    │   │   ├── hello17.pdl
    │   │   ├── hello18.pdl
    │   │   ├── hello19.pdl
    │   │   ├── hello20.pdl
    │   │   ├── hello21.pdl
    │   │   ├── hello22.pdl
    │   │   ├── hello23.pdl
    │   │   ├── hello24.pdl
    │   │   ├── hello25.pdl
    │   │   ├── hello26.pdl
    │   │   ├── hello27.pdl
    │   │   ├── hello28.pdl
    │   │   ├── hello29.pdl
    │   │   ├── hello3.pdl
    │   │   ├── hello30.pdl
    │   │   ├── hello31.pdl
    │   │   ├── hello32.pdl
    │   │   ├── hello4.pdl
    │   │   ├── hello7.pdl
    │   │   ├── hello8.pdl
    │   │   └── hello9.pdl
    │   └── optimizer_gsm8k.pdl
    ├── results/
    │   ├── contrib/
    │   │   └── prompt_library/
    │   │       ├── CoT.0.result
    │   │       ├── ProbReAct.0.result
    │   │       ├── ReAct.0.result
    │   │       ├── ReWoo.0.result
    │   │       └── tools.0.result
    │   ├── examples/
    │   │   ├── aggregators/
    │   │   │   ├── contribute_in_file.0.result
    │   │   │   ├── contribute_in_file.1.result
    │   │   │   ├── contribute_in_file.2.result
    │   │   │   ├── contribute_in_file.3.result
    │   │   │   ├── contribute_in_file.4.result
    │   │   │   ├── contribute_in_stderr.0.result
    │   │   │   └── contribute_in_stdout.0.result
    │   │   ├── chatbot/
    │   │   │   ├── chatbot.0.result
    │   │   │   ├── chatbot.1.result
    │   │   │   ├── chatbot.2.result
    │   │   │   ├── chatbot.3.result
    │   │   │   ├── chatbot.4.result
    │   │   │   ├── chatbot.5.result
    │   │   │   ├── chatbot.6.result
    │   │   │   ├── chatbot.7.result
    │   │   │   └── chatbot.8.result
    │   │   ├── demo/
    │   │   │   ├── 1-hello.0.result
    │   │   │   ├── 10-sdg.0.result
    │   │   │   ├── 10-sdg.1.result
    │   │   │   ├── 10-sdg.2.result
    │   │   │   ├── 10-sdg.3.result
    │   │   │   ├── 10-sdg.4.result
    │   │   │   ├── 10-sdg.5.result
    │   │   │   ├── 10-sdg.6.result
    │   │   │   ├── 10-sdg.7.result
    │   │   │   ├── 11-repeat.0.result
    │   │   │   ├── 2-model-chaining.0.result
    │   │   │   ├── 2-model-chaining.1.result
    │   │   │   ├── 2-model-chaining.2.result
    │   │   │   ├── 3-def-use.0.result
    │   │   │   ├── 3-def-use.1.result
    │   │   │   ├── 3-def-use.2.result
    │   │   │   ├── 3-def-use.3.result
    │   │   │   ├── 3-def-use.4.result
    │   │   │   ├── 3-def-use.5.result
    │   │   │   ├── 4-function.0.result
    │   │   │   ├── 4-function.1.result
    │   │   │   ├── 4-function.2.result
    │   │   │   ├── 4-function.3.result
    │   │   │   ├── 4-function.4.result
    │   │   │   ├── 5-code-eval.0.result
    │   │   │   ├── 5-code-eval.1.result
    │   │   │   ├── 5-code-eval.2.result
    │   │   │   ├── 5-code-eval.3.result
    │   │   │   ├── 5-code-eval.4.result
    │   │   │   ├── 5-code-eval.5.result
    │   │   │   ├── 5-code-eval.6.result
    │   │   │   ├── 5-code-eval.7.result
    │   │   │   ├── 5-code-eval.8.result
    │   │   │   ├── 5-code-eval.9.result
    │   │   │   ├── 6-code-json.0.result
    │   │   │   ├── 6-code-json.1.result
    │   │   │   ├── 6-code-json.2.result
    │   │   │   ├── 6-code-json.3.result
    │   │   │   ├── 6-code-json.4.result
    │   │   │   ├── 6-code-json.5.result
    │   │   │   ├── 6-code-json.6.result
    │   │   │   ├── 6-code-json.7.result
    │   │   │   ├── 6-code-json.8.result
    │   │   │   ├── 7-chatbot-roles.0.result
    │   │   │   ├── 7-chatbot-roles.1.result
    │   │   │   ├── 7-chatbot-roles.2.result
    │   │   │   ├── 7-chatbot-roles.3.result
    │   │   │   ├── 7-chatbot-roles.4.result
    │   │   │   ├── 7-chatbot-roles.5.result
    │   │   │   ├── 7-chatbot-roles.6.result
    │   │   │   ├── 8-tools.0.result
    │   │   │   ├── 8-tools.1.result
    │   │   │   ├── 9-react.0.result
    │   │   │   ├── 9-react.1.result
    │   │   │   ├── 9-react.10.result
    │   │   │   ├── 9-react.11.result
    │   │   │   ├── 9-react.12.result
    │   │   │   ├── 9-react.13.result
    │   │   │   ├── 9-react.14.result
    │   │   │   ├── 9-react.15.result
    │   │   │   ├── 9-react.16.result
    │   │   │   ├── 9-react.17.result
    │   │   │   ├── 9-react.2.result
    │   │   │   ├── 9-react.3.result
    │   │   │   ├── 9-react.4.result
    │   │   │   ├── 9-react.5.result
    │   │   │   ├── 9-react.6.result
    │   │   │   ├── 9-react.7.result
    │   │   │   ├── 9-react.8.result
    │   │   │   └── 9-react.9.result
    │   │   ├── demos/
    │   │   │   ├── granite_io_hallucinations.0.result
    │   │   │   ├── granite_io_hallucinations.1.result
    │   │   │   ├── granite_io_hallucinations.2.result
    │   │   │   ├── granite_io_hallucinations.3.result
    │   │   │   ├── granite_io_hallucinations.4.result
    │   │   │   ├── react.0.result
    │   │   │   ├── react.1.result
    │   │   │   ├── react.2.result
    │   │   │   ├── react.3.result
    │   │   │   ├── react.4.result
    │   │   │   └── react_fun.0.result
    │   │   ├── fibonacci/
    │   │   │   ├── fib.0.result
    │   │   │   ├── fib.1.result
    │   │   │   ├── fib.2.result
    │   │   │   ├── fib.3.result
    │   │   │   ├── fib.4.result
    │   │   │   ├── fib.5.result
    │   │   │   ├── fib.6.result
    │   │   │   ├── fib.7.result
    │   │   │   ├── fib.8.result
    │   │   │   └── fib.9.result
    │   │   ├── granite-io/
    │   │   │   ├── granite_io_hallucinations.0.result
    │   │   │   ├── granite_io_hallucinations.1.result
    │   │   │   ├── granite_io_hallucinations.2.result
    │   │   │   ├── granite_io_hallucinations.3.result
    │   │   │   ├── granite_io_object.0.result
    │   │   │   ├── granite_io_object.1.result
    │   │   │   ├── granite_io_object.2.result
    │   │   │   ├── granite_io_object.3.result
    │   │   │   ├── granite_io_openai.0.result
    │   │   │   ├── granite_io_openai.1.result
    │   │   │   ├── granite_io_openai.2.result
    │   │   │   ├── granite_io_thinking.0.result
    │   │   │   ├── granite_io_thinking.1.result
    │   │   │   ├── granite_io_thinking.2.result
    │   │   │   └── granite_io_thinking.3.result
    │   │   ├── independent/
    │   │   │   ├── independent.0.result
    │   │   │   ├── independent.1.result
    │   │   │   ├── independent.2.result
    │   │   │   ├── independent.3.result
    │   │   │   ├── independent.4.result
    │   │   │   ├── independent.5.result
    │   │   │   ├── independent.6.result
    │   │   │   ├── independent.7.result
    │   │   │   ├── independent_docs.0.result
    │   │   │   ├── independent_docs.1.result
    │   │   │   ├── independent_docs.10.result
    │   │   │   ├── independent_docs.2.result
    │   │   │   ├── independent_docs.3.result
    │   │   │   ├── independent_docs.4.result
    │   │   │   ├── independent_docs.5.result
    │   │   │   ├── independent_docs.6.result
    │   │   │   ├── independent_docs.7.result
    │   │   │   ├── independent_docs.8.result
    │   │   │   ├── independent_docs.9.result
    │   │   │   ├── independent_for.0.result
    │   │   │   ├── independent_for.1.result
    │   │   │   ├── independent_for.2.result
    │   │   │   ├── independent_for.3.result
    │   │   │   ├── independent_for.4.result
    │   │   │   ├── independent_for.5.result
    │   │   │   ├── test.0.result
    │   │   │   ├── test.1.result
    │   │   │   ├── test.2.result
    │   │   │   ├── test.3.result
    │   │   │   ├── test.4.result
    │   │   │   ├── test.5.result
    │   │   │   ├── test.6.result
    │   │   │   ├── test.7.result
    │   │   │   └── test.8.result
    │   │   ├── input/
    │   │   │   ├── input_test.0.result
    │   │   │   ├── input_test1.0.result
    │   │   │   └── input_test2.0.result
    │   │   ├── intrinsics/
    │   │   │   └── demo-hallucination.0.result
    │   │   ├── map-reduce/
    │   │   │   ├── context_fork.0.result
    │   │   │   ├── context_fork.1.result
    │   │   │   ├── context_fork.2.result
    │   │   │   ├── context_fork.3.result
    │   │   │   ├── context_fork.4.result
    │   │   │   ├── context_fork.5.result
    │   │   │   ├── pipeline.0.result
    │   │   │   ├── python-reduce.0.result
    │   │   │   └── reduce.0.result
    │   │   ├── openai/
    │   │   │   ├── openai_basic.0.result
    │   │   │   ├── openai_basic.1.result
    │   │   │   ├── openai_basic.10.result
    │   │   │   ├── openai_basic.11.result
    │   │   │   ├── openai_basic.12.result
    │   │   │   ├── openai_basic.2.result
    │   │   │   ├── openai_basic.3.result
    │   │   │   ├── openai_basic.4.result
    │   │   │   ├── openai_basic.5.result
    │   │   │   ├── openai_basic.6.result
    │   │   │   ├── openai_basic.7.result
    │   │   │   ├── openai_basic.8.result
    │   │   │   ├── openai_basic.9.result
    │   │   │   └── openai_structured.0.result
    │   │   ├── ppdl/
    │   │   │   ├── hmm.0.result
    │   │   │   ├── hmm.1.result
    │   │   │   ├── name_finder.0.result
    │   │   │   ├── name_finder.1.result
    │   │   │   ├── name_finder.10.result
    │   │   │   ├── name_finder.11.result
    │   │   │   ├── name_finder.12.result
    │   │   │   ├── name_finder.13.result
    │   │   │   ├── name_finder.14.result
    │   │   │   ├── name_finder.15.result
    │   │   │   ├── name_finder.16.result
    │   │   │   ├── name_finder.17.result
    │   │   │   ├── name_finder.18.result
    │   │   │   ├── name_finder.19.result
    │   │   │   ├── name_finder.2.result
    │   │   │   ├── name_finder.20.result
    │   │   │   ├── name_finder.21.result
    │   │   │   ├── name_finder.22.result
    │   │   │   ├── name_finder.23.result
    │   │   │   ├── name_finder.24.result
    │   │   │   ├── name_finder.25.result
    │   │   │   ├── name_finder.26.result
    │   │   │   ├── name_finder.27.result
    │   │   │   ├── name_finder.28.result
    │   │   │   ├── name_finder.29.result
    │   │   │   ├── name_finder.3.result
    │   │   │   ├── name_finder.30.result
    │   │   │   ├── name_finder.31.result
    │   │   │   ├── name_finder.32.result
    │   │   │   ├── name_finder.33.result
    │   │   │   ├── name_finder.34.result
    │   │   │   ├── name_finder.4.result
    │   │   │   ├── name_finder.5.result
    │   │   │   ├── name_finder.6.result
    │   │   │   ├── name_finder.7.result
    │   │   │   ├── name_finder.8.result
    │   │   │   └── name_finder.9.result
    │   │   ├── prompt_library/
    │   │   │   ├── gsm8k_cot.0.result
    │   │   │   ├── gsm8k_cot.1.result
    │   │   │   ├── gsm8k_cot.2.result
    │   │   │   ├── gsm8k_cot.3.result
    │   │   │   ├── gsm8k_cot.4.result
    │   │   │   ├── gsm8k_cot.5.result
    │   │   │   ├── gsm8k_cot.6.result
    │   │   │   ├── gsm8k_prob_react.0.txt
    │   │   │   ├── gsm8k_react.0.result
    │   │   │   ├── gsm8k_react.1.result
    │   │   │   ├── gsm8k_react.2.result
    │   │   │   ├── gsm8k_react.3.result
    │   │   │   ├── gsm8k_react.4.result
    │   │   │   ├── gsm8k_react.5.result
    │   │   │   ├── gsm8k_react.6.result
    │   │   │   ├── gsm8k_react.7.result
    │   │   │   ├── gsm8k_react.8.result
    │   │   │   ├── gsm8k_rewoo.0.result
    │   │   │   ├── gsm8k_rewoo.1.result
    │   │   │   ├── gsm8k_rewoo.2.result
    │   │   │   ├── gsm8k_rewoo.3.result
    │   │   │   ├── gsm8k_rewoo.4.result
    │   │   │   └── gsm8k_rewoo.5.result
    │   │   ├── rag/
    │   │   │   ├── tfidf_rag.0.result
    │   │   │   ├── tfidf_rag.1.result
    │   │   │   ├── tfidf_rag.10.result
    │   │   │   ├── tfidf_rag.2.result
    │   │   │   ├── tfidf_rag.3.result
    │   │   │   ├── tfidf_rag.4.result
    │   │   │   ├── tfidf_rag.5.result
    │   │   │   ├── tfidf_rag.6.result
    │   │   │   ├── tfidf_rag.7.result
    │   │   │   ├── tfidf_rag.8.result
    │   │   │   └── tfidf_rag.9.result
    │   │   ├── react/
    │   │   │   ├── react_demo.0.result
    │   │   │   ├── react_demo.1.result
    │   │   │   ├── react_demo.2.result
    │   │   │   ├── react_demo.3.result
    │   │   │   ├── react_demo.4.result
    │   │   │   ├── react_demo.5.result
    │   │   │   └── react_demo.6.result
    │   │   ├── skeleton-of-thought/
    │   │   │   ├── tips.0.result
    │   │   │   ├── tips.1.result
    │   │   │   └── tips.2.result
    │   │   ├── teacher/
    │   │   │   ├── teacher.0.result
    │   │   │   ├── teacher.1.result
    │   │   │   ├── teacher.2.result
    │   │   │   ├── teacher.3.result
    │   │   │   ├── teacher.4.result
    │   │   │   ├── teacher.5.result
    │   │   │   └── teacher.6.result
    │   │   ├── tools/
    │   │   │   ├── calc.0.result
    │   │   │   ├── calc.1.result
    │   │   │   ├── calc.2.result
    │   │   │   ├── search.0.result
    │   │   │   ├── search.1.result
    │   │   │   ├── search.2.result
    │   │   │   ├── search.3.result
    │   │   │   └── search.4.result
    │   │   └── tutorial/
    │   │       ├── calling_llm.0.result
    │   │       ├── calling_llm_chaining.0.result
    │   │       ├── calling_llm_chaining.1.result
    │   │       ├── calling_llm_chaining.2.result
    │   │       ├── calling_llm_with_input.0.result
    │   │       ├── calling_llm_with_input.1.result
    │   │       ├── calling_llm_with_input.2.result
    │   │       ├── calling_llm_with_input.3.result
    │   │       ├── calling_llm_with_input_messages.0.result
    │   │       ├── calling_llm_with_input_messages.1.result
    │   │       ├── calling_llm_with_input_messages.2.result
    │   │       ├── calling_llm_with_input_messages.3.result
    │   │       ├── calling_llm_with_input_messages_var.0.result
    │   │       ├── calling_llm_with_input_messages_var.1.result
    │   │       ├── calling_llm_with_input_messages_var.2.result
    │   │       ├── code_command.0.result
    │   │       ├── code_jinja.0.result
    │   │       ├── code_jinja_parameters.0.result
    │   │       ├── code_pdl.0.result
    │   │       ├── code_pdl.1.result
    │   │       ├── code_python.0.result
    │   │       ├── code_python.1.result
    │   │       ├── code_python.10.result
    │   │       ├── code_python.11.result
    │   │       ├── code_python.12.result
    │   │       ├── code_python.13.result
    │   │       ├── code_python.14.result
    │   │       ├── code_python.15.result
    │   │       ├── code_python.16.result
    │   │       ├── code_python.17.result
    │   │       ├── code_python.18.result
    │   │       ├── code_python.19.result
    │   │       ├── code_python.2.result
    │   │       ├── code_python.20.result
    │   │       ├── code_python.21.result
    │   │       ├── code_python.22.result
    │   │       ├── code_python.23.result
    │   │       ├── code_python.24.result
    │   │       ├── code_python.25.result
    │   │       ├── code_python.3.result
    │   │       ├── code_python.4.result
    │   │       ├── code_python.5.result
    │   │       ├── code_python.6.result
    │   │       ├── code_python.7.result
    │   │       ├── code_python.8.result
    │   │       ├── code_python.9.result
    │   │       ├── code_scope.0.result
    │   │       ├── code_session.0.result
    │   │       ├── data_block_raw.0.result
    │   │       ├── defs.0.result
    │   │       ├── defs.1.result
    │   │       ├── defs.2.result
    │   │       ├── defs.3.result
    │   │       ├── defs.4.result
    │   │       ├── for.0.result
    │   │       ├── for_array.0.result
    │   │       ├── for_lastOf.0.result
    │   │       ├── for_multiple_lists.0.result
    │   │       ├── for_object.0.result
    │   │       ├── for_with.0.result
    │   │       ├── free_variables.0.result
    │   │       ├── function_alias.0.result
    │   │       ├── function_call_in_jinja.0.result
    │   │       ├── function_call_in_jinja.1.result
    │   │       ├── function_definition.0.result
    │   │       ├── function_definition.1.result
    │   │       ├── function_definition.2.result
    │   │       ├── function_definition.3.result
    │   │       ├── function_definition.4.result
    │   │       ├── function_empty_context.0.result
    │   │       ├── function_empty_context.1.result
    │   │       ├── function_optional_params.0.result
    │   │       ├── if.0.result
    │   │       ├── import.0.result
    │   │       ├── import_lib.0.result
    │   │       ├── input_file.0.result
    │   │       ├── input_file_json.0.result
    │   │       ├── input_stdin.0.result
    │   │       ├── input_stdin_multiline.0.result
    │   │       ├── lastOf.0.result
    │   │       ├── lastOf.1.result
    │   │       ├── lastOf.2.result
    │   │       ├── local_computation.0.result
    │   │       ├── loop_index.0.result
    │   │       ├── muting_block_output.0.result
    │   │       ├── muting_block_output.1.result
    │   │       ├── muting_block_output.2.result
    │   │       ├── muting_block_output.3.result
    │   │       ├── parser-regex.0.result
    │   │       ├── parser_findall.0.result
    │   │       ├── parser_regex_code.0.result
    │   │       ├── parser_regex_code.1.result
    │   │       ├── parser_regex_code.2.result
    │   │       ├── parser_regex_code.3.result
    │   │       ├── pdl_scope.0.result
    │   │       ├── pdl_scope.1.result
    │   │       ├── pdl_usage.0.result
    │   │       ├── programs/
    │   │       │   ├── chatbot.0.result
    │   │       │   ├── chatbot.1.result
    │   │       │   ├── chatbot.2.result
    │   │       │   ├── chatbot.3.result
    │   │       │   ├── chatbot.4.result
    │   │       │   ├── chatbot.5.result
    │   │       │   ├── chatbot.6.result
    │   │       │   ├── chatbot.7.result
    │   │       │   ├── chatbot.8.result
    │   │       │   ├── code/
    │   │       │   │   ├── code-eval.0.result
    │   │       │   │   ├── code-eval.1.result
    │   │       │   │   ├── code-eval.10.result
    │   │       │   │   ├── code-eval.2.result
    │   │       │   │   ├── code-eval.3.result
    │   │       │   │   ├── code-eval.4.result
    │   │       │   │   ├── code-eval.5.result
    │   │       │   │   ├── code-eval.6.result
    │   │       │   │   ├── code-eval.7.result
    │   │       │   │   ├── code-eval.8.result
    │   │       │   │   ├── code-eval.9.result
    │   │       │   │   ├── code-json.0.result
    │   │       │   │   ├── code-json.1.result
    │   │       │   │   ├── code-json.2.result
    │   │       │   │   ├── code-json.3.result
    │   │       │   │   ├── code-json.4.result
    │   │       │   │   ├── code-json.5.result
    │   │       │   │   ├── code-json.6.result
    │   │       │   │   ├── code-json.7.result
    │   │       │   │   ├── code-json.8.result
    │   │       │   │   ├── code-json.9.result
    │   │       │   │   ├── code.0.result
    │   │       │   │   ├── code.1.result
    │   │       │   │   ├── code.10.result
    │   │       │   │   ├── code.2.result
    │   │       │   │   ├── code.3.result
    │   │       │   │   ├── code.4.result
    │   │       │   │   ├── code.5.result
    │   │       │   │   ├── code.6.result
    │   │       │   │   ├── code.7.result
    │   │       │   │   ├── code.8.result
    │   │       │   │   └── code.9.result
    │   │       │   ├── demo-hallucination.0.result
    │   │       │   ├── weather.0.result
    │   │       │   ├── weather.1.result
    │   │       │   ├── weather.2.result
    │   │       │   ├── weather.3.result
    │   │       │   ├── weather.4.result
    │   │       │   ├── weather.5.result
    │   │       │   ├── weather.6.result
    │   │       │   ├── weather.7.result
    │   │       │   └── weather.8.result
    │   │       ├── repeat.0.result
    │   │       ├── role.0.result
    │   │       ├── role.1.result
    │   │       ├── role.2.result
    │   │       ├── sdk/
    │   │       │   └── hello.0.result
    │   │       ├── simple_program.0.result
    │   │       ├── structured_decoding.0.result
    │   │       ├── structured_decoding.1.result
    │   │       ├── type_checking.0.result
    │   │       ├── type_checking.1.result
    │   │       ├── type_checking.2.result
    │   │       ├── variable_def_use.0.result
    │   │       └── while.0.result
    │   ├── pdl-live-react/
    │   │   ├── demos/
    │   │   │   ├── demo1.0.result
    │   │   │   ├── demo2.0.result
    │   │   │   └── demo2.1.result
    │   │   └── src-tauri/
    │   │       └── tests/
    │   │           └── cli/
    │   │               ├── call-no-args.0.result
    │   │               ├── call-with-args.0.result
    │   │               ├── code-python.0.result
    │   │               ├── data1.0.result
    │   │               ├── data2.0.result
    │   │               ├── data3.0.result
    │   │               ├── data4.0.result
    │   │               ├── if1.0.result
    │   │               ├── if2.0.result
    │   │               ├── include1.0.result
    │   │               ├── json-parser-lastOf.0.result
    │   │               ├── json-parser.0.result
    │   │               ├── jsonl-parser.0.result
    │   │               ├── model-input-array.0.result
    │   │               ├── model-input-array.1.result
    │   │               ├── model-input-array.2.result
    │   │               ├── model-input-array.3.result
    │   │               ├── model-input-array.4.result
    │   │               ├── model-input-array.5.result
    │   │               ├── model-input-array.6.result
    │   │               ├── model-input-array.7.result
    │   │               ├── model-input-array.8.result
    │   │               ├── model-input-array.9.result
    │   │               ├── model-input-nested.0.result
    │   │               ├── model-input-nested.1.result
    │   │               ├── model-input-nested.10.result
    │   │               ├── model-input-nested.2.result
    │   │               ├── model-input-nested.3.result
    │   │               ├── model-input-nested.4.result
    │   │               ├── model-input-nested.5.result
    │   │               ├── model-input-nested.6.result
    │   │               ├── model-input-nested.7.result
    │   │               ├── model-input-nested.8.result
    │   │               ├── model-input-nested.9.result
    │   │               ├── model-input-string.0.result
    │   │               ├── model-input-string.1.result
    │   │               ├── model-input-string.2.result
    │   │               ├── model-input-string.3.result
    │   │               ├── model-input-string.4.result
    │   │               ├── model-input-string.5.result
    │   │               ├── model-input-string.6.result
    │   │               ├── model-input-string.7.result
    │   │               ├── object1.0.result
    │   │               ├── object2.0.result
    │   │               ├── read-file.0.result
    │   │               ├── regex-findall.0.result
    │   │               ├── regex-findall.1.result
    │   │               ├── repeat1.0.result
    │   │               ├── repeat2.0.result
    │   │               ├── repeat3.0.result
    │   │               ├── scoping_1.0.result
    │   │               ├── scoping_1_wrapper.0.result
    │   │               └── tips.0.result
    │   ├── src/
    │   │   └── pdl/
    │   │       └── pdl_stdlib.0.result
    │   └── tests/
    │       └── data/
    │           ├── call_expression_args.12.result
    │           ├── function.0.result
    │           ├── hello.0.result
    │           └── optimizer_gsm8k.0.result
    ├── test_array.py
    ├── test_ast_utils.py
    ├── test_code.py
    ├── test_cond.py
    ├── test_context.py
    ├── test_data.py
    ├── test_defaults.py
    ├── test_defs.py
    ├── test_dump.py
    ├── test_errors.py
    ├── test_examples_parse.py
    ├── test_examples_run.py
    ├── test_examples_run.yaml
    ├── test_expr.py
    ├── test_fallback.py
    ├── test_for.py
    ├── test_function.py
    ├── test_include.py
    ├── test_independent.py
    ├── test_input.py
    ├── test_lib_version.py
    ├── test_line_table.py
    ├── test_linter.py
    ├── test_match.py
    ├── test_messages.py
    ├── test_model.py
    ├── test_object.py
    ├── test_optimizer.py
    ├── test_parse.py
    ├── test_parser.py
    ├── test_repeat.py
    ├── test_retry.py
    ├── test_role.py
    ├── test_runtime_errors.py
    ├── test_schema.py
    ├── test_secrets_redaction.py
    ├── test_sequence.py
    ├── test_type_checking.py
    └── test_var.py
Download .txt
SYMBOL INDEX (1736 symbols across 203 files)

FILE: examples/callback/repair_main.py
  function parse_output (line 11) | def parse_output(raw_output: str) -> ParsedOutput:

FILE: examples/demos/repair_main.py
  function parse_output (line 11) | def parse_output(raw_output: str) -> ParsedOutput:

FILE: examples/optimizer/fever_evaluator.py
  class FEVEREvaluator (line 8) | class FEVEREvaluator(OptimizerEvaluator):
    method __init__ (line 9) | def __init__(
    method get_scope (line 17) | def get_scope(self) -> ScopeType:
    method extract_answer (line 66) | def extract_answer(self, document: str) -> bool | None:
    method score (line 85) | def score(self, document: str, ground_truth: Any) -> float:

FILE: examples/optimizer/gsm8k_evaluator.py
  class Gsm8kEvaluator (line 9) | class Gsm8kEvaluator(OptimizerEvaluator):
    method __init__ (line 10) | def __init__(
    method get_scope (line 17) | def get_scope(self) -> ScopeType:
    method score (line 67) | def score(self, document: str, ground_truth: Any) -> float:

FILE: examples/optimizer/gsmhard_evaluator.py
  function is_float (line 9) | def is_float(s: str | float) -> str:
  class GsmHardEvaluator (line 17) | class GsmHardEvaluator(OptimizerEvaluator):
    method __init__ (line 18) | def __init__(
    method get_scope (line 26) | def get_scope(self) -> ScopeType:
    method score (line 77) | def score(self, document: str, ground_truth: Any) -> float:

FILE: examples/optimizer/mbpp_dataset.py
  class SelectableList (line 11) | class SelectableList(list):
    method select (line 12) | def select(self, iterable):
  class MBPPDataset (line 16) | class MBPPDataset(dict):
    method __init__ (line 17) | def __init__(self, dataset_path: str) -> None:
    method __getitem__ (line 82) | def __getitem__(self, key):
    method __setitem__ (line 85) | def __setitem__(self, key, val) -> None:

FILE: examples/optimizer/mbpp_evaluator.py
  class MBPPEvaluator (line 12) | class MBPPEvaluator(OptimizerEvaluator):
    method __init__ (line 13) | def __init__(
    method get_scope (line 21) | def get_scope(self) -> ScopeType:
    method extract_answer (line 61) | def extract_answer(self, document: str) -> str:
    method score (line 68) | def score(self, document: str, ground_truth: Any) -> float:

FILE: examples/optimizer/process_fever.py
  function clean_fever (line 46) | def clean_fever(text: str) -> str:
  function search_new (line 67) | def search_new(
  function searcher (line 93) | def searcher(row: dict[str, Any], auto_suggest: bool):
  function remove_accents (line 106) | def remove_accents(x: str) -> str:
  function evidence_mapper (line 172) | def evidence_mapper(evidence: list[tuple]):
  function evidence_mapper_sentence (line 184) | def evidence_mapper_sentence(evidences: list[tuple[str, int]]):
  function search (line 316) | def search(query: str) -> tuple:
  function trajectorize (line 325) | def trajectorize(row: dict[str, Any]) -> dict[str, Any]:
  function sentencify (line 417) | def sentencify(row: dict[str, Any]) -> dict[str, str]:

FILE: examples/optimizer/process_grammar_correction.py
  function save_jsonl (line 28) | def save_jsonl(dataset, path: Path) -> None:

FILE: examples/optimizer/process_gsm8k.py
  function parse_answers (line 31) | def parse_answers(row: dict[str, Any]) -> dict[str, Any]:
  function react_trajectory (line 48) | def react_trajectory(row: dict[str, Any]) -> dict[str, list[str]]:
  function rewoo_trajectory (line 101) | def rewoo_trajectory(row: dict[str, Any]) -> dict[str, list[str]]:

FILE: examples/optimizer/process_mbpp.py
  function trajectify (line 30) | def trajectify(row: dict[str, Any]) -> dict[str, list[str]]:

FILE: examples/rag/rag.py
  function parse (line 8) | def parse(filename: str, chunk_size: int, chunk_overlap: int) -> list[str]:
  function rag_index (line 29) | def rag_index(
  function get_or_create_client (line 76) | def get_or_create_client(database_name: str):
  function rag_retrieve (line 89) | def rag_retrieve(

FILE: examples/tutorial/sdk/hello_dict.py
  function main (line 4) | def main():

FILE: examples/tutorial/sdk/hello_file.py
  function main (line 4) | def main():

FILE: examples/tutorial/sdk/hello_parallel.py
  function _run_agent (line 13) | def _run_agent(name):

FILE: examples/tutorial/sdk/hello_prog.py
  function main (line 5) | def main():

FILE: examples/tutorial/sdk/hello_str.py
  function main (line 13) | def main():

FILE: examples/tutorial/sdk/run_pdl.py
  function my_pdl_program (line 5) | def my_pdl_program(scope):
  function another (line 14) | def another(scope):
  function main (line 24) | def main():

FILE: pdl-live-react/demos/beeai/test1.py
  function main (line 9) | async def main() -> None:

FILE: pdl-live-react/src-tauri/build.rs
  function main (line 1) | fn main() {

FILE: pdl-live-react/src-tauri/src/cli.rs
  function setup (line 12) | pub fn setup(app: &mut tauri::App) -> Result<bool, Box<dyn ::std::error:...

FILE: pdl-live-react/src-tauri/src/commands/interpreter.rs
  function run_pdl_program (line 4) | pub async fn run_pdl_program(program: String) -> Result<String, String> {

FILE: pdl-live-react/src-tauri/src/commands/read_trace.rs
  function read_trace (line 5) | pub fn read_trace(trace_file: &str) -> Result<Vec<u8>, String> {

FILE: pdl-live-react/src-tauri/src/commands/replay_prep.rs
  function replay_prep (line 10) | pub async fn replay_prep(

FILE: pdl-live-react/src-tauri/src/compile/beeai.rs
  type BeeAiInputStateDict (line 32) | struct BeeAiInputStateDict {
  type BeeAiInputState (line 37) | struct BeeAiInputState {
  type BeeAiInput (line 42) | struct BeeAiInput {
  type BeeAiToolSchema (line 54) | struct BeeAiToolSchema {
  type BeeAiToolState (line 58) | struct BeeAiToolState {
  type BeeAiTool (line 65) | struct BeeAiTool {
  type BeeAiLlmParametersState (line 72) | struct BeeAiLlmParametersState {
  type BeeAiLlmParameters (line 77) | struct BeeAiLlmParameters {
  type BeeAiWorkflowStepStateAgentMetadataStateDict (line 82) | struct BeeAiWorkflowStepStateAgentMetadataStateDict {
  type BeeAiWorkflowStepStateAgentMetadataState (line 93) | struct BeeAiWorkflowStepStateAgentMetadataState {
  type BeeAiWorkflowStepStateAgentMetadata (line 98) | struct BeeAiWorkflowStepStateAgentMetadata {
  type BeeAiWorkflowStepStateDict (line 103) | struct BeeAiWorkflowStepStateDict {
  type BeeAiWorkflowStepState (line 107) | struct BeeAiWorkflowStepState {
  type BeeAiWorkflowStep (line 112) | struct BeeAiWorkflowStep {
  type BeeAiWorkflowInner (line 117) | struct BeeAiWorkflowInner {
  type BeeAiWorkflow (line 124) | struct BeeAiWorkflow {
  type BeeAiProgram (line 128) | struct BeeAiProgram {
  function a_tool (line 133) | fn a_tool(tool: &BeeAiToolState) -> Value {
  function strip_nulls (line 149) | fn strip_nulls(parameters: &HashMap<String, Value>) -> HashMap<String, V...
  function strip_nulls2 (line 160) | fn strip_nulls2(parameters: &Map<String, Value>) -> Map<String, Value> {
  function with_tools (line 171) | fn with_tools(
  function call_tools (line 193) | fn call_tools(model: &String, parameters: &HashMap<String, Value>) -> Pd...
  function json_loads (line 278) | fn json_loads(
  function json_schema_type_to_pdl_type (line 309) | fn json_schema_type_to_pdl_type(spec: &Value) -> PdlType {
  function json_schema_to_pdl (line 353) | fn json_schema_to_pdl(properties: &HashMap<String, Value>) -> HashMap<St...
  function pdl_args_schema (line 360) | fn pdl_args_schema(schema: HashMap<String, PdlType>) -> HashMap<String, ...
  function tool_imports (line 366) | fn tool_imports(object: &String) -> (&str, &str) {
  function python_source_to_json (line 374) | fn python_source_to_json(source_file_path: &str, debug: bool) -> Result<...
  function compile (line 403) | pub fn compile(source_file_path: &str, debug: bool) -> Result<PdlBlock, ...
  function compile_to_file (line 637) | pub fn compile_to_file(

FILE: pdl-live-react/src-tauri/src/gui.rs
  function new_window (line 4) | pub fn new_window(

FILE: pdl-live-react/src-tauri/src/lib.rs
  function run (line 12) | pub fn run() {

FILE: pdl-live-react/src-tauri/src/main.rs
  function main (line 4) | fn main() {

FILE: pdl-live-react/src-tauri/src/pdl/ast.rs
  type Role (line 11) | pub enum Role {
  type RegexMode (line 24) | pub enum RegexMode {
  type RegexParser (line 39) | pub struct RegexParser {
  type PdlParser (line 52) | pub enum PdlParser {
  type PdlBaseType (line 64) | pub enum PdlBaseType {
  type PdlOptionalType (line 76) | pub struct PdlOptionalType {
  type PdlType (line 82) | pub enum PdlType {
  type Timing (line 90) | pub struct Timing {
    method now (line 99) | fn now() -> Result<u64, TimingError> {
    method start (line 105) | pub fn start() -> Result<Timing, TimingError> {
    method end (line 112) | pub fn end(&mut self) -> Result<(), TimingError> {
  type TimingError (line 97) | type TimingError = Box<dyn Error + Send + Sync>;
  type Metadata (line 122) | pub struct Metadata {
  type CallBlock (line 159) | pub struct CallBlock {
    method new (line 171) | pub fn new(call: String) -> Self {
  type SequencingBlock (line 180) | pub trait SequencingBlock {
    method kind (line 181) | fn kind(&self) -> &str;
    method role (line 182) | fn role(&self) -> &Option<Role>;
    method items (line 183) | fn items(&self) -> &Vec<PdlBlock>;
    method with_items (line 184) | fn with_items(&self, items: Vec<PdlBlock>) -> Self;
    method parser (line 185) | fn parser(&self) -> &Option<PdlParser>;
    method to_block (line 186) | fn to_block(&self) -> Body;
    method result_for (line 187) | fn result_for(&self, output_results: Vec<PdlResult>) -> PdlResult;
    method messages_for (line 188) | fn messages_for<T: Clone>(&self, output_messages: &Vec<T>) -> Vec<T>;
    method kind (line 206) | fn kind(&self) -> &str {
    method role (line 209) | fn role(&self) -> &Option<Role> {
    method items (line 212) | fn items(&self) -> &Vec<PdlBlock> {
    method with_items (line 215) | fn with_items(&self, items: Vec<PdlBlock>) -> Self {
    method parser (line 220) | fn parser(&self) -> &Option<PdlParser> {
    method to_block (line 223) | fn to_block(&self) -> Body {
    method result_for (line 226) | fn result_for(&self, output_results: Vec<PdlResult>) -> PdlResult {
    method messages_for (line 232) | fn messages_for<T: Clone>(&self, output_messages: &Vec<T>) -> Vec<T> {
    method kind (line 259) | fn kind(&self) -> &str {
    method role (line 262) | fn role(&self) -> &Option<Role> {
    method items (line 265) | fn items(&self) -> &Vec<PdlBlock> {
    method with_items (line 268) | fn with_items(&self, items: Vec<PdlBlock>) -> Self {
    method parser (line 273) | fn parser(&self) -> &Option<PdlParser> {
    method to_block (line 276) | fn to_block(&self) -> Body {
    method result_for (line 279) | fn result_for(&self, output_results: Vec<PdlResult>) -> PdlResult {
    method messages_for (line 291) | fn messages_for<T: Clone>(&self, output_messages: &Vec<T>) -> Vec<T> {
  type LastOfBlock (line 194) | pub struct LastOfBlock {
  type TextBlock (line 245) | pub struct TextBlock {
  type FunctionBlock (line 298) | pub struct FunctionBlock {
  type PdlUsage (line 305) | pub struct PdlUsage {
  type ModelBlock (line 321) | pub struct ModelBlock {
  type ListOrString (line 345) | pub enum ListOrString {
  type IterationType (line 351) | pub enum IterationType {
  type JoinAs (line 363) | pub struct JoinAs {
  type JoinAsWith (line 368) | pub struct JoinAsWith {
  type JoinType (line 376) | pub enum JoinType {
  type RepeatBlock (line 393) | pub struct RepeatBlock {
  type MessageBlock (line 409) | pub struct MessageBlock {
  type ObjectBlock (line 434) | pub struct ObjectBlock {
  type DataBlock (line 462) | pub struct DataBlock {
  type PythonCodeBlock (line 485) | pub struct PythonCodeBlock {
  type StringOrNull (line 495) | pub enum StringOrNull {
  type ReadBlock (line 515) | pub struct ReadBlock {
  type StringOrBoolean (line 531) | pub enum StringOrBoolean {
  type Expr (line 537) | pub struct Expr<S, T> {
  type EvalsTo (line 547) | pub enum EvalsTo<S, T> {
  method default (line 554) | fn default() -> Self {
  function from (line 560) | fn from(s: &str) -> Self {
  function from (line 565) | fn from(s: String) -> Self {
  type IfBlock (line 583) | pub struct IfBlock {
  type ArrayBlock (line 604) | pub struct ArrayBlock {
  type IncludeBlock (line 612) | pub struct IncludeBlock {
  type ImportBlock (line 623) | pub struct ImportBlock {
  type EmptyBlock (line 634) | pub struct EmptyBlock {
  type PdlBlock (line 641) | pub enum PdlBlock {
    method from (line 684) | fn from(b: bool) -> Self {
    method from (line 690) | fn from(s: &str) -> Self {
    method from (line 696) | fn from(s: String) -> Self {
  type Block (line 654) | pub struct Block {
  type Body (line 666) | pub enum Body {
  function from (line 702) | fn from(s: &str) -> Self {
  type Scope (line 707) | pub type Scope = HashMap<String, PdlResult>;
  type Closure (line 710) | pub struct Closure {
  type PdlResult (line 717) | pub enum PdlResult {
    method fmt (line 727) | fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
    method from (line 733) | fn from(s: &str) -> Self {
    method from (line 738) | fn from(s: String) -> Self {
    method from (line 743) | fn from(b: &bool) -> Self {
    method from (line 748) | fn from(n: Number) -> Self {
  method eq (line 753) | fn eq(&self, other: &Self) -> bool {

FILE: pdl-live-react/src-tauri/src/pdl/extract.rs
  function extract_models (line 6) | pub fn extract_models(program: &PdlBlock) -> Vec<String> {
  function extract_values (line 11) | pub fn extract_values(program: &PdlBlock, field: &str) -> Vec<String> {
  function extract_values_iter (line 23) | fn extract_values_iter(program: &PdlBlock, field: &str, values: &mut Vec...

FILE: pdl-live-react/src-tauri/src/pdl/interpreter.rs
  type Messages (line 34) | type Messages = Vec<ChatMessage>;
  type ThreadSafeError (line 35) | type ThreadSafeError = dyn Error + Send + Sync;
  type PdlError (line 36) | type PdlError = Box<ThreadSafeError>;
  type Interpretation (line 37) | type Interpretation = Result<(PdlResult, Messages, PdlBlock), PdlError>;
  type BodyInterpretation (line 38) | type BodyInterpretation = Result<(PdlResult, Messages, Body), PdlError>;
  type InterpretationSync (line 39) | type InterpretationSync = Result<(PdlResult, Messages, PdlBlock), Box<dy...
  type RunOptions (line 41) | pub struct RunOptions<'a> {
  method default (line 48) | fn default() -> Self {
  type State (line 58) | struct State {
    method new (line 68) | fn new(initial_scope: Scope) -> Self {
    method id (line 79) | fn id(&self) -> String {
    method with_cwd (line 83) | fn with_cwd(&self, cwd: PathBuf) -> Self {
    method with_emit (line 89) | fn with_emit(&self, emit: bool) -> Self {
    method with_iter (line 95) | fn with_iter(&self, iter: usize) -> Self {
    method incr_iter (line 101) | fn incr_iter(&self, iter: usize) -> Self {
    method extend_scope (line 108) | fn extend_scope(&self, scopes: Vec<Scope>) -> Self {
  type Interpreter (line 115) | struct Interpreter<'a> {
  function new (line 122) | fn new(options: RunOptions<'a>) -> Self {
  function _run_with_state (line 140) | async fn _run_with_state(
  function run_advanced (line 199) | async fn run_advanced(&mut self, block: &Block, state: &mut State) -> In...
  function run_quiet (line 287) | async fn run_quiet(&mut self, program: &PdlBlock, state: &mut State) -> ...
  function run (line 293) | async fn run(&mut self, program: &PdlBlock, state: &mut State) -> Interp...
  function eval (line 299) | fn eval(&self, expr: &String, state: &State) -> Result<PdlResult, PdlErr...
  function eval_string (line 316) | fn eval_string(
  function eval_string_to_string (line 329) | fn eval_string_to_string(
  function eval_to_bool (line 341) | fn eval_to_bool(
  function eval_to_string (line 368) | fn eval_to_string(&self, expr: &String, state: &State) -> Result<String,...
  function eval_json (line 379) | fn eval_json(&self, expr: &Value, state: &State) -> Result<PdlResult, Pd...
  function eval_list_or_string (line 402) | fn eval_list_or_string(
  function closure (line 428) | fn closure(&self, f: &FunctionBlock, state: &State) -> Closure {
  function run_string (line 436) | async fn run_string(&self, msg: &String, state: &State) -> Interpretation {
  function path_to (line 461) | fn path_to(&self, file_path: &String, state: &State) -> PathBuf {
  function def (line 471) | fn def(
  function run_read (line 509) | async fn run_read(
  function run_call (line 559) | async fn run_call(
  function run_empty (line 594) | async fn run_empty(&mut self, block: &EmptyBlock, state: &mut State) -> ...
  function run_if (line 610) | async fn run_if(
  function run_include (line 640) | async fn run_include(
  function run_import (line 667) | async fn run_import(
  function to_ollama_model_options (line 693) | fn to_ollama_model_options(
  function run_python_code (line 754) | async fn run_python_code(
  function tool_call_prompt (line 845) | fn tool_call_prompt(
  function run_ollama_model (line 880) | async fn run_ollama_model(
  function run_openai_model (line 990) | async fn run_openai_model(
  function run_model (line 1037) | async fn run_model(
  function run_data (line 1137) | async fn run_data(
  function run_object (line 1187) | async fn run_object(
  function run_repeat (line 1217) | async fn run_repeat(
  function to_ollama_role (line 1265) | fn to_ollama_role(&self, role: &Role) -> MessageRole {
  function from_ollama_role (line 1274) | fn from_ollama_role(&self, role: &MessageRole) -> Role {
  function parse_result (line 1283) | fn parse_result(&self, parser: &PdlParser, result: &String) -> Result<Pd...
  function process_defs (line 1327) | async fn process_defs(
  function run_sequence (line 1348) | async fn run_sequence(
  function run_array (line 1411) | async fn run_array(
  function run_message (line 1437) | async fn run_message(
  function run (line 1486) | pub async fn run<'a>(
  function run_sync (line 1511) | pub fn run_sync<'a>(
  function parse_file (line 1522) | pub fn parse_file(path: &PathBuf) -> Result<PdlBlock, PdlError> {
  function run_file (line 1526) | pub async fn run_file<'a>(
  function run_file_sync (line 1539) | pub fn run_file_sync<'a>(
  function run_string (line 1548) | pub async fn run_string<'a>(
  function run_json (line 1557) | pub async fn run_json<'a>(
  function run_json_sync (line 1566) | pub fn run_json_sync<'a>(
  function pretty_print (line 1575) | pub fn pretty_print(messages: &Vec<ChatMessage>) -> String {
  function resultify (line 1601) | fn resultify(value: &Value) -> PdlResult {
  function resultify_as_litellm (line 1617) | fn resultify_as_litellm(value: &Value) -> PdlResult {
  function load_scope (line 1625) | pub fn load_scope(
  function get_paths (line 1662) | fn get_paths(env_variable_name: &str) -> impl Iterator<Item = String> + ...
  function split_paths (line 1679) | pub(crate) fn split_paths<T: AsRef<std::ffi::OsStr> + ?Sized>(
  constant __version__ (line 1695) | const __version__: u32 = 1;
  type BaseModel (line 1700) | struct BaseModel {}
  type Field (line 1708) | struct Field {}
  type ValidationError (line 1716) | struct ValidationError {}
  type InstanceOf (line 1724) | struct InstanceOf {}
  type ConfigDict (line 1732) | struct ConfigDict {}
  function SettingsConfigDict (line 1745) | fn SettingsConfigDict(_rest: FuncArgs, _vm: &VirtualMachine) -> PyResult...
  type BaseSettings (line 1752) | struct BaseSettings {}

FILE: pdl-live-react/src-tauri/src/pdl/interpreter_tests.rs
  constant DEFAULT_MODEL (line 13) | const DEFAULT_MODEL: &'static str = "ollama/granite4:micro";
  function streaming (line 15) | fn streaming<'a>() -> RunOptions<'a> {
  function initial_scope (line 27) | fn initial_scope() -> Scope {
  function string (line 32) | fn string() -> Result<(), Box<dyn Error>> {
  function string_via_initial_scope (line 41) | fn string_via_initial_scope() -> Result<(), Box<dyn Error>> {
  function single_model_via_input_string (line 61) | fn single_model_via_input_string() -> Result<(), Box<dyn Error>> {
  function single_model_via_text_chain_expr (line 83) | fn single_model_via_text_chain_expr() -> Result<(), Box<dyn Error>> {
  function single_model_via_text_chain (line 103) | fn single_model_via_text_chain() -> Result<(), Box<dyn Error>> {
  function single_model_via_input_array (line 123) | fn single_model_via_input_array() -> Result<(), Box<dyn Error>> {
  function two_models_via_text_chain (line 150) | fn two_models_via_text_chain() -> Result<(), Box<dyn Error>> {
  function text_parser_json (line 190) | fn text_parser_json() -> Result<(), Box<dyn Error>> {
  function text_parser_jsonl (line 209) | fn text_parser_jsonl() -> Result<(), Box<dyn Error>> {
  function last_of_parser_json (line 232) | fn last_of_parser_json() -> Result<(), Box<dyn Error>> {
  function text_call_function_no_args (line 249) | fn text_call_function_no_args() -> Result<(), Box<dyn Error>> {
  function text_call_function_with_args (line 275) | fn text_call_function_with_args() -> Result<(), Box<dyn Error>> {
  function text_python_code_result_int (line 303) | fn text_python_code_result_int() -> Result<(), Box<dyn Error>> {
  function text_python_code_result_str (line 317) | fn text_python_code_result_str() -> Result<(), Box<dyn Error>> {
  function text_python_code_result_dict (line 331) | fn text_python_code_result_dict() -> Result<(), Box<dyn Error>> {
  function text_python_two_code_result_dict (line 345) | fn text_python_two_code_result_dict() -> Result<(), Box<dyn Error>> {
  function text_python_code_import_venv (line 368) | fn text_python_code_import_venv() -> Result<(), Box<dyn Error>> {
  function text_read_file_text (line 384) | fn text_read_file_text() -> Result<(), Box<dyn Error>> {
  function text_read_file_struct (line 398) | fn text_read_file_struct() -> Result<(), Box<dyn Error>> {
  function text_repeat_numbers_1d (line 421) | fn text_repeat_numbers_1d() -> Result<(), Box<dyn Error>> {
  function text_repeat_numbers_2d (line 445) | fn text_repeat_numbers_2d() -> Result<(), Box<dyn Error>> {
  function text_repeat_mix_2d (line 470) | fn text_repeat_mix_2d() -> Result<(), Box<dyn Error>> {
  function text_if_true (line 495) | fn text_if_true() -> Result<(), Box<dyn Error>> {
  function text_if_false (line 509) | fn text_if_false() -> Result<(), Box<dyn Error>> {
  function text_if_with_defs (line 524) | fn text_if_with_defs() -> Result<(), Box<dyn Error>> {
  function text_object_via_defs_1 (line 542) | fn text_object_via_defs_1() -> Result<(), Box<dyn Error>> {
  function text_object_via_defs_2 (line 564) | fn text_object_via_defs_2() -> Result<(), Box<dyn Error>> {
  function include (line 590) | fn include() -> Result<(), Box<dyn Error>> {
  function data_1 (line 603) | fn data_1() -> Result<(), Box<dyn Error>> {
  function data_2 (line 616) | fn data_2() -> Result<(), Box<dyn Error>> {
  function data_3 (line 629) | fn data_3() -> Result<(), Box<dyn Error>> {
  function data_4 (line 642) | fn data_4() -> Result<(), Box<dyn Error>> {
  function import_1 (line 655) | fn import_1() -> Result<(), Box<dyn Error>> {
  function scoping_1 (line 668) | fn scoping_1() -> Result<(), Box<dyn Error>> {
  function regex_findall (line 683) | fn regex_findall() -> Result<(), Box<dyn Error>> {
  function regex_plain_1 (line 704) | fn regex_plain_1() -> Result<(), Box<dyn Error>> {
  function regex_plain_2 (line 725) | fn regex_plain_2() -> Result<(), Box<dyn Error>> {
  function bee_1 (line 744) | fn bee_1() -> Result<(), Box<dyn Error>> {

FILE: pdl-live-react/src-tauri/src/pdl/pip.rs
  function pip_install_if_needed (line 10) | pub async fn pip_install_if_needed(

FILE: pdl-live-react/src-tauri/src/pdl/pull.rs
  function pull_if_needed (line 20) | pub async fn pull_if_needed(program: &PdlBlock) -> Result<(), Error> {
  function ollama_exists (line 36) | fn ollama_exists(model: &str) -> bool {
  function ollama_pull_if_needed (line 48) | fn ollama_pull_if_needed(model: &str) -> Result<(), Error> {

FILE: pdl-live-react/src-tauri/src/pdl/requirements.rs
  constant BEEAI_FRAMEWORK (line 1) | pub const BEEAI_FRAMEWORK: &str = "-e git+https://github.com/starpit/bee...

FILE: pdl-live-react/src-tauri/src/util/shasum.rs
  function sha256sum_str (line 14) | pub fn sha256sum_str(s: &str) -> String {

FILE: pdl-live-react/src-tauri/tests/data/bee_1.py
  function main (line 9) | async def main() -> None:

FILE: pdl-live-react/src/App.tsx
  function App (line 6) | function App() {

FILE: pdl-live-react/src/demos/demos.ts
  type Demo (line 11) | type Demo = {

FILE: pdl-live-react/src/helpers.ts
  type ExpressionT (line 21) | type ExpressionT<T> = T | string | LocalizedExpression
  type MakeNonNullable (line 23) | type MakeNonNullable<T> = {
  type CodeBlock (line 27) | type CodeBlock =
  type ModelBlock (line 34) | type ModelBlock =
  type ModelBlockWithUsage (line 39) | type ModelBlockWithUsage = ModelBlock & {
  type NonScalarPdlBlock (line 43) | type NonScalarPdlBlock = Exclude<
  type PdlBlockWithResult (line 47) | type PdlBlockWithResult = NonScalarPdlBlock & {
  type WithTiming (line 51) | type WithTiming = Required<
  type PdlBlockWithTiming (line 55) | type PdlBlockWithTiming = NonScalarPdlBlock & { pdl__timing: WithTiming }
  type PdlBlockWithContext (line 57) | type PdlBlockWithContext = Omit<PdlBlockWithTiming, "pdl__context"> & {
  function hasResult (line 62) | function hasResult(block: unknown): block is PdlBlockWithResult {
  function isPdlBlock (line 71) | function isPdlBlock(
  function isNonScalarPdlBlock (line 84) | function isNonScalarPdlBlock(
  function hasParser (line 91) | function hasParser(
  function isMarkdownish (line 104) | function isMarkdownish(s: string): boolean {
  function isTextBlock (line 119) | function isTextBlock(data: PdlBlock): data is TextBlock {
  type TextBlockWithContent (line 124) | type TextBlockWithContent = TextBlock & {
  function isTextBlockWithContent (line 127) | function isTextBlockWithContent(
  function isTextBlockWithArrayContent (line 134) | function isTextBlockWithArrayContent(
  function isLLMBlock (line 141) | function isLLMBlock(data: unknown | PdlBlock): data is ModelBlock {
  function hasScalarResult (line 150) | function hasScalarResult(
  function firstLineOf (line 166) | function firstLineOf(s: string) {
  function nonNullable (line 175) | function nonNullable<T>(value: T): value is NonNullable<T> {
  function hasTimingInformation (line 180) | function hasTimingInformation(
  function hasModelUsage (line 193) | function hasModelUsage(
  function completionRate (line 206) | function completionRate(
  function ptcRatio (line 215) | function ptcRatio(block: ModelBlockWithUsage) {
  function hasContextInformation (line 220) | function hasContextInformation(
  function capitalizeAndUnSnakeCase (line 230) | function capitalizeAndUnSnakeCase(s: string) {
  type MessageBearing (line 241) | type MessageBearing = Omit<import("./pdl_ast").ReadBlock, "message"> & {
  function hasMessage (line 244) | function hasMessage(block: PdlBlock): block is MessageBearing {
  function hasInput (line 248) | function hasInput(block: PdlBlock): block is
  function tryJson (line 262) | function tryJson(s: unknown) {
  function tryJsonPrettyPrint (line 273) | function tryJsonPrettyPrint(s: string) {
  function extractStructuredModelResponse (line 282) | function extractStructuredModelResponse({
  function isArgs (line 323) | function isArgs(block: ArgsBlock | CodeBlock): block is ArgsBlock {
  function extractCode (line 327) | function extractCode({ code }: CodeBlock): string {
  function isExpr (line 339) | function isExpr(e: unknown): e is LocalizedExpression {
  function getValue (line 347) | function getValue<T>(expr: ExpressionT<T>) {
  function extractModel (line 359) | function extractModel(block: ModelBlock): string {

FILE: pdl-live-react/src/page/About.tsx
  function Welcome (line 4) | function Welcome() {

FILE: pdl-live-react/src/page/ClearMyTraces.tsx
  function ClearMyTraces (line 13) | function ClearMyTraces() {

FILE: pdl-live-react/src/page/DarkModeContext.ts
  function getDarkModeUserSetting (line 3) | function getDarkModeUserSetting(): boolean {
  function setDarkModeUserSetting (line 7) | function setDarkModeUserSetting(darkMode: boolean) {
  function setDarkModeForSession (line 11) | function setDarkModeForSession(darkMode: boolean) {

FILE: pdl-live-react/src/page/DarkModeToggle.tsx
  function DarkModeToggle (line 14) | function DarkModeToggle() {

FILE: pdl-live-react/src/page/Demo.tsx
  type Props (line 7) | type Props = {
  function DemosDropdown (line 13) | function DemosDropdown({ current }: { current: string }) {
  function Demo (line 28) | function Demo({ name, value }: Props) {

FILE: pdl-live-react/src/page/DemoNavItems.tsx
  function DemoNavItems (line 7) | function DemoNavItems({

FILE: pdl-live-react/src/page/Demos.tsx
  function DemoTiles (line 14) | function DemoTiles() {
  function Demos (line 61) | function Demos() {

FILE: pdl-live-react/src/page/ErrorBoundary.tsx
  type ErrorResponse (line 12) | type ErrorResponse = {
  function isErrorResponse (line 16) | function isErrorResponse(err: unknown): err is ErrorResponse {
  function message (line 21) | function message(error: unknown) {
  type Props (line 29) | type Props = import("react").PropsWithChildren
  method super (line 34) | super(props)

FILE: pdl-live-react/src/page/Local.tsx
  type Props (line 7) | type Props = {
  function Local (line 11) | function Local() {

FILE: pdl-live-react/src/page/Masthead.tsx
  function Toggle (line 23) | function Toggle() {
  function Brand (line 57) | function Brand() {
  function Main (line 73) | function Main() {
  function Content (line 82) | function Content() {
  function PDLMasthead (line 86) | function PDLMasthead() {

FILE: pdl-live-react/src/page/MyTrace.tsx
  type Props (line 7) | type Props = {
  function MyTracesDropdown (line 13) | function MyTracesDropdown({ current }: { current: string }) {
  function MyTrace (line 28) | function MyTrace({ name, value }: Props) {

FILE: pdl-live-react/src/page/MyTraces.ts
  type MyTrace (line 5) | type MyTrace = {
  function clear (line 13) | function clear() {
  function getMyTraces (line 17) | function getMyTraces(): MyTrace[] {
  function addMyTrace (line 32) | function addMyTrace(filename: string, value: string): MyTrace {

FILE: pdl-live-react/src/page/MyTracesNavItems.tsx
  function MyTracesNavItems (line 12) | function MyTracesNavItems({

FILE: pdl-live-react/src/page/MyTracesPage.tsx
  function MyTiles (line 14) | function MyTiles() {
  function MyTraces (line 64) | function MyTraces() {

FILE: pdl-live-react/src/page/Page.tsx
  function PDLPage (line 25) | function PDLPage(props: Props) {

FILE: pdl-live-react/src/page/PageBreadcrumbDropdown.tsx
  function PageBreadcrumbDropdown (line 9) | function PageBreadcrumbDropdown({

FILE: pdl-live-react/src/page/PageBreadcrumbDropdownItem.tsx
  function PageBreadcrumbDropdownItem (line 5) | function PageBreadcrumbDropdownItem({

FILE: pdl-live-react/src/page/PageBreadcrumbs.tsx
  type PageBreadcrumbProps (line 7) | type PageBreadcrumbProps = {
  function PageBreadcrumbs (line 15) | function PageBreadcrumbs({

FILE: pdl-live-react/src/page/Run.tsx
  function Run (line 28) | function Run() {

FILE: pdl-live-react/src/page/Sidebar.tsx
  function Sidebar (line 14) | function Sidebar() {

FILE: pdl-live-react/src/page/Uploader.tsx
  type Props (line 25) | type Props = {
  function Uploader (line 32) | function Uploader({

FILE: pdl-live-react/src/page/welcome/Intro.tsx
  function Intro (line 3) | function Intro() {

FILE: pdl-live-react/src/page/welcome/Links.tsx
  function Links (line 6) | function Links() {

FILE: pdl-live-react/src/page/welcome/Tile.tsx
  type Props (line 12) | type Props = PropsWithChildren<{
  function Tile (line 22) | function Tile({

FILE: pdl-live-react/src/page/welcome/Tiles.tsx
  type Props (line 7) | type Props = {
  function Tiles (line 13) | function Tiles(props: Props) {

FILE: pdl-live-react/src/page/welcome/Toolbar.tsx
  function WelcomeToolbar (line 7) | function WelcomeToolbar() {

FILE: pdl-live-react/src/page/welcome/Welcome.tsx
  type Props (line 14) | type Props = {
  function Welcome (line 20) | function Welcome(props: Props) {

FILE: pdl-live-react/src/page/welcome/tiles/Demos.tsx
  function Demos (line 9) | function Demos() {

FILE: pdl-live-react/src/page/welcome/tiles/MyTraces.tsx
  function MyTraces (line 12) | function MyTraces() {

FILE: pdl-live-react/src/pdl_ast.d.ts
  type PDLSchemas (line 8) | type PDLSchemas = Program | PdlBlock
  type Program (line 12) | type Program =
  type ExpressionBlock (line 44) | type ExpressionBlock = boolean | number | string | null
  type Enum (line 45) | type Enum = unknown[]
  type PdlTypeType (line 46) | type PdlTypeType =
  type Type (line 71) | type Type = string | string[]
  type BlockType (line 72) | type BlockType =
  type ContributeElement (line 104) | type ContributeElement =
  type ContributeTarget (line 113) | type ContributeTarget = "result" | "context" | "stdout" | "stderr"
  type Contribute (line 118) | type Contribute = ContributeElement[]
  type ParserType (line 119) | type ParserType =
  type Regex (line 123) | type Regex = string
  type Mode (line 124) | type Mode = "search" | "match" | "fullmatch" | "split" | "findall"
  type Feedback (line 125) | type Feedback = LocalizedExpression | FunctionBlock | string | null
  type Path (line 126) | type Path = string[]
  type File (line 127) | type File = string
  type ExpectationsType (line 132) | type ExpectationsType = ExpectationType[]
  type ModelInput (line 133) | type ModelInput = {
  type PdlIsLeaf (line 136) | type PdlIsLeaf = true
  type Kind (line 137) | type Kind = "call"
  type Call (line 142) | type Call = LocalizedExpression | FunctionBlock | string
  type Contribute1 (line 147) | type Contribute1 = ContributeElement[]
  type ExpectationsType1 (line 152) | type ExpectationsType1 = ExpectationType[]
  type PdlIsLeaf1 (line 153) | type PdlIsLeaf1 = true
  type Kind1 (line 154) | type Kind1 = "model"
  type Contribute2 (line 159) | type Contribute2 = ContributeElement[]
  type ExpectationsType2 (line 164) | type ExpectationsType2 = ExpectationType[]
  type PdlIsLeaf2 (line 165) | type PdlIsLeaf2 = true
  type Kind2 (line 166) | type Kind2 = "model"
  type Contribute3 (line 171) | type Contribute3 = ContributeElement[]
  type ExpectationsType3 (line 176) | type ExpectationsType3 = ExpectationType[]
  type PdlIsLeaf3 (line 177) | type PdlIsLeaf3 = true
  type Kind3 (line 178) | type Kind3 = "model"
  type Contribute4 (line 183) | type Contribute4 = ContributeElement[]
  type ExpectationsType4 (line 188) | type ExpectationsType4 = ExpectationType[]
  type PdlIsLeaf4 (line 189) | type PdlIsLeaf4 = true
  type Kind4 (line 190) | type Kind4 = "code"
  type Contribute5 (line 195) | type Contribute5 = ContributeElement[]
  type ExpectationsType5 (line 200) | type ExpectationsType5 = ExpectationType[]
  type PdlIsLeaf5 (line 201) | type PdlIsLeaf5 = true
  type Kind5 (line 202) | type Kind5 = "code"
  type Contribute6 (line 207) | type Contribute6 = ContributeElement[]
  type ExpectationsType6 (line 212) | type ExpectationsType6 = ExpectationType[]
  type PdlIsLeaf6 (line 213) | type PdlIsLeaf6 = true
  type Kind6 (line 214) | type Kind6 = "code"
  type Contribute7 (line 219) | type Contribute7 = ContributeElement[]
  type ExpectationsType7 (line 224) | type ExpectationsType7 = ExpectationType[]
  type PdlIsLeaf7 (line 225) | type PdlIsLeaf7 = true
  type Kind7 (line 226) | type Kind7 = "code"
  type Contribute8 (line 231) | type Contribute8 = ContributeElement[]
  type ExpectationsType8 (line 236) | type ExpectationsType8 = ExpectationType[]
  type PdlIsLeaf8 (line 237) | type PdlIsLeaf8 = true
  type Kind8 (line 238) | type Kind8 = "code"
  type Contribute9 (line 243) | type Contribute9 = ContributeElement[]
  type ExpectationsType9 (line 248) | type ExpectationsType9 = ExpectationType[]
  type PdlIsLeaf9 (line 249) | type PdlIsLeaf9 = true
  type Kind9 (line 250) | type Kind9 = "code"
  type Lang (line 251) | type Lang = "command"
  type ExpressionStr (line 252) | type ExpressionStr = LocalizedExpression | string
  type Args1 (line 257) | type Args1 = ExpressionStr[]
  type Contribute10 (line 262) | type Contribute10 = ContributeElement[]
  type ExpectationsType10 (line 267) | type ExpectationsType10 = ExpectationType[]
  type PdlIsLeaf10 (line 268) | type PdlIsLeaf10 = true
  type Kind10 (line 269) | type Kind10 = "get"
  type Get (line 273) | type Get = string
  type Contribute11 (line 278) | type Contribute11 = ContributeElement[]
  type ExpectationsType11 (line 283) | type ExpectationsType11 = ExpectationType[]
  type PdlIsLeaf11 (line 284) | type PdlIsLeaf11 = true
  type Kind11 (line 285) | type Kind11 = "data"
  type Raw (line 289) | type Raw = boolean
  type Contribute12 (line 294) | type Contribute12 = ContributeElement[]
  type ExpectationsType12 (line 299) | type ExpectationsType12 = ExpectationType[]
  type PdlIsLeaf12 (line 300) | type PdlIsLeaf12 = false
  type IndependentEnum (line 307) | type IndependentEnum = "independent" | "dependent"
  type Kind12 (line 308) | type Kind12 = "if"
  type Contribute13 (line 313) | type Contribute13 = ContributeElement[]
  type ExpectationsType13 (line 318) | type ExpectationsType13 = ExpectationType[]
  type PdlIsLeaf13 (line 319) | type PdlIsLeaf13 = false
  type IndependentEnum1 (line 326) | type IndependentEnum1 = "independent" | "dependent"
  type Kind13 (line 327) | type Kind13 = "match"
  type PatternType (line 328) | type PatternType =
  type Anyof (line 337) | type Anyof = PatternType[]
  type Array (line 338) | type Array = PatternType[]
  type Any (line 339) | type Any = null
  type ExpressionBool (line 340) | type ExpressionBool = LocalizedExpression | boolean | string
  type With (line 345) | type With = MatchCase[]
  type Contribute14 (line 350) | type Contribute14 = ContributeElement[]
  type ExpectationsType14 (line 355) | type ExpectationsType14 = ExpectationType[]
  type PdlIsLeaf14 (line 356) | type PdlIsLeaf14 = false
  type IndependentEnum2 (line 363) | type IndependentEnum2 = "independent" | "dependent"
  type Kind14 (line 364) | type Kind14 = "repeat"
  type For (line 369) | type For = {
  type Contribute15 (line 376) | type Contribute15 = ContributeElement[]
  type ExpectationsType15 (line 381) | type ExpectationsType15 = ExpectationType[]
  type PdlIsLeaf15 (line 382) | type PdlIsLeaf15 = false
  type IndependentEnum3 (line 389) | type IndependentEnum3 = "independent" | "dependent"
  type Kind15 (line 390) | type Kind15 = "map"
  type For1 (line 395) | type For1 = {
  type Contribute16 (line 402) | type Contribute16 = ContributeElement[]
  type ExpectationsType16 (line 407) | type ExpectationsType16 = ExpectationType[]
  type PdlIsLeaf16 (line 408) | type PdlIsLeaf16 = false
  type IndependentEnum4 (line 415) | type IndependentEnum4 = "independent" | "dependent"
  type Kind16 (line 416) | type Kind16 = "sequence"
  type Sequence (line 420) | type Sequence = BlockType[]
  type As (line 425) | type As = "text"
  type With1 (line 430) | type With1 = string
  type As1 (line 435) | type As1 = "array"
  type As2 (line 440) | type As2 = "object"
  type As3 (line 445) | type As3 = "lastOf"
  type As4 (line 446) | type As4 = "reduce"
  type Reduce (line 450) | type Reduce = LocalizedExpression | string
  type Contribute17 (line 455) | type Contribute17 = ContributeElement[]
  type ExpectationsType17 (line 460) | type ExpectationsType17 = ExpectationType[]
  type PdlIsLeaf17 (line 461) | type PdlIsLeaf17 = false
  type IndependentEnum5 (line 468) | type IndependentEnum5 = "independent" | "dependent"
  type Kind17 (line 469) | type Kind17 = "text"
  type Text (line 474) | type Text = BlockType | BlockType[]
  type Contribute18 (line 479) | type Contribute18 = ContributeElement[]
  type ExpectationsType18 (line 484) | type ExpectationsType18 = ExpectationType[]
  type PdlIsLeaf18 (line 485) | type PdlIsLeaf18 = false
  type IndependentEnum6 (line 492) | type IndependentEnum6 = "independent" | "dependent"
  type Kind18 (line 493) | type Kind18 = "lastOf"
  type Lastof (line 497) | type Lastof = BlockType[]
  type Contribute19 (line 502) | type Contribute19 = ContributeElement[]
  type ExpectationsType19 (line 507) | type ExpectationsType19 = ExpectationType[]
  type PdlIsLeaf19 (line 508) | type PdlIsLeaf19 = false
  type IndependentEnum7 (line 515) | type IndependentEnum7 = "independent" | "dependent"
  type Kind19 (line 516) | type Kind19 = "array"
  type Array1 (line 520) | type Array1 = BlockType[]
  type Contribute20 (line 525) | type Contribute20 = ContributeElement[]
  type ExpectationsType20 (line 530) | type ExpectationsType20 = ExpectationType[]
  type PdlIsLeaf20 (line 531) | type PdlIsLeaf20 = false
  type IndependentEnum8 (line 538) | type IndependentEnum8 = "independent" | "dependent"
  type Kind20 (line 539) | type Kind20 = "object"
  type Object2 (line 543) | type Object2 =
  type Contribute21 (line 552) | type Contribute21 = ContributeElement[]
  type ExpectationsType21 (line 557) | type ExpectationsType21 = ExpectationType[]
  type PdlIsLeaf21 (line 558) | type PdlIsLeaf21 = true
  type Kind21 (line 559) | type Kind21 = "message"
  type Contribute22 (line 564) | type Contribute22 = ContributeElement[]
  type ExpectationsType22 (line 569) | type ExpectationsType22 = ExpectationType[]
  type PdlIsLeaf22 (line 570) | type PdlIsLeaf22 = true
  type Kind22 (line 571) | type Kind22 = "read"
  type Multiline (line 576) | type Multiline = boolean
  type Contribute23 (line 581) | type Contribute23 = ContributeElement[]
  type ExpectationsType23 (line 586) | type ExpectationsType23 = ExpectationType[]
  type PdlIsLeaf23 (line 587) | type PdlIsLeaf23 = false
  type IndependentEnum9 (line 594) | type IndependentEnum9 = "independent" | "dependent"
  type Kind23 (line 595) | type Kind23 = "include"
  type Include (line 600) | type Include = string
  type Contribute24 (line 605) | type Contribute24 = ContributeElement[]
  type ExpectationsType24 (line 610) | type ExpectationsType24 = ExpectationType[]
  type PdlIsLeaf24 (line 611) | type PdlIsLeaf24 = true
  type Kind24 (line 612) | type Kind24 = "import"
  type Import (line 617) | type Import = string
  type Contribute25 (line 622) | type Contribute25 = ContributeElement[]
  type ExpectationsType25 (line 627) | type ExpectationsType25 = ExpectationType[]
  type PdlIsLeaf25 (line 628) | type PdlIsLeaf25 = true
  type Kind25 (line 629) | type Kind25 = "factor"
  type Factor (line 634) | type Factor = LocalizedExpression | number | string
  type Resample (line 639) | type Resample = boolean
  type Contribute26 (line 644) | type Contribute26 = ContributeElement[]
  type ExpectationsType26 (line 649) | type ExpectationsType26 = ExpectationType[]
  type PdlIsLeaf26 (line 650) | type PdlIsLeaf26 = true
  type Kind26 (line 651) | type Kind26 = "aggregator"
  type Aggregator (line 655) | type Aggregator = "context" | FileAggregatorConfig
  type Description (line 660) | type Description = string | null
  type File1 (line 664) | type File1 = LocalizedExpression | string
  type Mode1 (line 668) | type Mode1 = LocalizedExpression | string
  type Encoding (line 672) | type Encoding = LocalizedExpression | string | null
  type Prefix (line 676) | type Prefix = LocalizedExpression | string
  type Suffix (line 680) | type Suffix = LocalizedExpression | string
  type Flush (line 684) | type Flush = LocalizedExpression | boolean | string
  type Contribute27 (line 689) | type Contribute27 = ContributeElement[]
  type ExpectationsType27 (line 694) | type ExpectationsType27 = ExpectationType[]
  type PdlIsLeaf27 (line 695) | type PdlIsLeaf27 = true
  type Kind27 (line 696) | type Kind27 = "error"
  type Msg (line 701) | type Msg = string
  type Contribute28 (line 706) | type Contribute28 = ContributeElement[]
  type ExpectationsType28 (line 711) | type ExpectationsType28 = ExpectationType[]
  type PdlIsLeaf28 (line 712) | type PdlIsLeaf28 = true
  type Kind28 (line 713) | type Kind28 = "empty"
  type ExpressionList (line 714) | type ExpressionList = LocalizedExpression | unknown[] | string
  type ExpressionInt (line 715) | type ExpressionInt = LocalizedExpression | number | string
  type PdlTrace (line 716) | type PdlTrace = BlockType[] | null
  type PdlTrace1 (line 717) | type PdlTrace1 = BlockType[] | null
  type ExpressionDictStr (line 718) | type ExpressionDictStr =
  type Lang1 (line 728) | type Lang1 = "command"
  type Lang2 (line 733) | type Lang2 = "pdl"
  type Lang3 (line 738) | type Lang3 = "jinja"
  type Lang4 (line 743) | type Lang4 = "ipython"
  type Lang5 (line 748) | type Lang5 = "python"
  type ModelCalls (line 749) | type ModelCalls = number
  type CompletionTokens (line 750) | type CompletionTokens = number
  type PromptTokens (line 751) | type PromptTokens = number
  type Platform (line 756) | type Platform = "openai"
  type Parameters (line 761) | type Parameters =
  type ApiKey (line 769) | type ApiKey = string | null
  type BaseUrl (line 770) | type BaseUrl = string | null
  type Organization (line 771) | type Organization = string | null
  type Platform1 (line 776) | type Platform1 = "granite-io"
  type Parameters1 (line 781) | type Parameters1 =
  type Platform2 (line 792) | type Platform2 = "litellm"
  type Parameters2 (line 797) | type Parameters2 =
  type Timeout (line 805) | type Timeout = number | string | null
  type Temperature (line 806) | type Temperature = number | string | null
  type TopP (line 807) | type TopP = number | string | null
  type N (line 808) | type N = number | string | null
  type Stop (line 809) | type Stop = string | string[] | null
  type MaxTokens (line 810) | type MaxTokens = number | string | null
  type PresencePenalty (line 811) | type PresencePenalty = number | string | null
  type FrequencyPenalty (line 812) | type FrequencyPenalty = number | string | null
  type LogitBias (line 813) | type LogitBias =
  type User (line 819) | type User = string | null
  type ResponseFormat (line 820) | type ResponseFormat =
  type Seed (line 826) | type Seed = number | string | null
  type Tools (line 827) | type Tools = unknown[] | string | null
  type ToolChoice (line 828) | type ToolChoice =
  type Logprobs (line 834) | type Logprobs = boolean | string | null
  type TopLogprobs (line 835) | type TopLogprobs = number | string | null
  type ParallelToolCalls (line 836) | type ParallelToolCalls = boolean | string | null
  type ExtraHeaders (line 837) | type ExtraHeaders =
  type Functions (line 843) | type Functions = unknown[] | string | null
  type FunctionCall (line 844) | type FunctionCall = string | null
  type BaseUrl1 (line 845) | type BaseUrl1 = string | null
  type ApiVersion (line 846) | type ApiVersion = string | null
  type ApiKey1 (line 847) | type ApiKey1 = string | null
  type ModelList (line 848) | type ModelList = unknown[] | string | null
  type MockResponse (line 849) | type MockResponse = string | null
  type CustomLlmProvider (line 850) | type CustomLlmProvider = string | null
  type MaxRetries (line 851) | type MaxRetries = number | string | null
  type Contribute29 (line 856) | type Contribute29 = ContributeElement[]
  type ExpectationsType29 (line 861) | type ExpectationsType29 = ExpectationType[]
  type PdlIsLeaf29 (line 862) | type PdlIsLeaf29 = true
  type Kind29 (line 863) | type Kind29 = "function"
  type Function (line 868) | type Function = {
  type Signature (line 875) | type Signature = string | null
  type PdlBlock (line 882) | type PdlBlock =
  type FunctionBlock (line 918) | interface FunctionBlock {
  type EnumPdlType (line 1044) | interface EnumPdlType {
  type OptionalPdlType (line 1051) | interface OptionalPdlType {
  type JsonSchemaTypePdlType (line 1057) | interface JsonSchemaTypePdlType {
  type ObjectPdlType (line 1064) | interface ObjectPdlType {
  type Object (line 1067) | interface Object {
  type Defs (line 1074) | interface Defs {
  type CallBlock (line 1080) | interface CallBlock {
  type Defs1 (line 1172) | interface Defs1 {
  type ContributeValue (line 1178) | interface ContributeValue {
  type PdlParser (line 1184) | interface PdlParser {
  type RegexParser (line 1216) | interface RegexParser {
  type ExpectationType (line 1249) | interface ExpectationType {
  type LocalizedExpression (line 1253) | interface LocalizedExpression {
  type PdlExpr (line 1258) | interface PdlExpr {
  type PdlLocationType (line 1264) | interface PdlLocationType {
  type Table (line 1269) | interface Table {
  type PdlTiming (line 1275) | interface PdlTiming {
  type LitellmModelBlock (line 1291) | interface LitellmModelBlock {
  type Defs2 (line 1439) | interface Defs2 {
  type GraniteioModelBlock (line 1445) | interface GraniteioModelBlock {
  type Defs3 (line 1585) | interface Defs3 {
  type OpenaiModelBlock (line 1600) | interface OpenaiModelBlock {
  type Defs4 (line 1748) | interface Defs4 {
  type PythonCodeBlock (line 1763) | interface PythonCodeBlock {
  type Defs5 (line 1894) | interface Defs5 {
  type IPythonCodeBlock (line 1908) | interface IPythonCodeBlock {
  type Defs6 (line 2039) | interface Defs6 {
  type JinjaCodeBlock (line 2054) | interface JinjaCodeBlock {
  type Defs7 (line 2190) | interface Defs7 {
  type PdlCodeBlock (line 2208) | interface PdlCodeBlock {
  type Defs8 (line 2339) | interface Defs8 {
  type CommandCodeBlock (line 2352) | interface CommandCodeBlock {
  type Defs9 (line 2483) | interface Defs9 {
  type ArgsBlock (line 2497) | interface ArgsBlock {
  type Defs10 (line 2588) | interface Defs10 {
  type GetBlock (line 2596) | interface GetBlock {
  type Defs11 (line 2686) | interface Defs11 {
  type DataBlock (line 2713) | interface DataBlock {
  type Defs12 (line 2804) | interface Defs12 {
  type IfBlock (line 2820) | interface IfBlock {
  type Defs13 (line 2956) | interface Defs13 {
  type MatchBlock (line 2979) | interface MatchBlock {
  type Defs14 (line 3071) | interface Defs14 {
  type MatchCase (line 3077) | interface MatchCase {
  type OrPattern (line 3088) | interface OrPattern {
  type ArrayPattern (line 3095) | interface ArrayPattern {
  type ObjectPattern (line 3102) | interface ObjectPattern {
  type Object1 (line 3106) | interface Object1 {
  type AnyPattern (line 3112) | interface AnyPattern {
  type RepeatBlock (line 3142) | interface RepeatBlock {
  type Defs15 (line 3295) | interface Defs15 {
  type MapBlock (line 3322) | interface MapBlock {
  type Defs16 (line 3470) | interface Defs16 {
  type SequenceBlock (line 3476) | interface SequenceBlock {
  type Defs17 (line 3572) | interface Defs17 {
  type JoinText (line 3578) | interface JoinText {
  type JoinArray (line 3585) | interface JoinArray {
  type JoinObject (line 3591) | interface JoinObject {
  type JoinLastOf (line 3597) | interface JoinLastOf {
  type JoinReduce (line 3603) | interface JoinReduce {
  type TextBlock (line 3610) | interface TextBlock {
  type Defs18 (line 3701) | interface Defs18 {
  type LastOfBlock (line 3707) | interface LastOfBlock {
  type Defs19 (line 3798) | interface Defs19 {
  type ArrayBlock (line 3804) | interface ArrayBlock {
  type Defs20 (line 3895) | interface Defs20 {
  type ObjectBlock (line 3901) | interface ObjectBlock {
  type Defs21 (line 3992) | interface Defs21 {
  type MessageBlock (line 3998) | interface MessageBlock {
  type Defs22 (line 4134) | interface Defs22 {
  type ReadBlock (line 4152) | interface ReadBlock {
  type Defs23 (line 4252) | interface Defs23 {
  type IncludeBlock (line 4258) | interface IncludeBlock {
  type Defs24 (line 4350) | interface Defs24 {
  type ImportBlock (line 4356) | interface ImportBlock {
  type Defs25 (line 4447) | interface Defs25 {
  type FactorBlock (line 4453) | interface FactorBlock {
  type Defs26 (line 4545) | interface Defs26 {
  type AggregatorBlock (line 4551) | interface AggregatorBlock {
  type Defs27 (line 4641) | interface Defs27 {
  type FileAggregatorConfig (line 4644) | interface FileAggregatorConfig {
  type ErrorBlock (line 4656) | interface ErrorBlock {
  type Defs28 (line 4782) | interface Defs28 {
  type EmptyBlock (line 4788) | interface EmptyBlock {
  type Defs29 (line 4877) | interface Defs29 {
  type PdlUsage (line 4883) | interface PdlUsage {
  type OpenaiParameters (line 4892) | interface OpenaiParameters {
  type LitellmParameters (line 4903) | interface LitellmParameters {

FILE: pdl-live-react/src/pdl_ast_utils.ts
  function map_block_children (line 6) | function map_block_children(
  function iter_block_children (line 242) | function iter_block_children(

FILE: pdl-live-react/src/pdl_code_cleanup.ts
  function block_code_cleanup (line 19) | function block_code_cleanup(block: PdlBlock): PdlBlock {
  function clean_model_block (line 49) | function clean_model_block(
  function clean_data_block (line 64) | function clean_data_block(block: DataBlock) {
  function clean_match_block (line 89) | function clean_match_block(block: MatchBlock) {
  function remove_block_default_values (line 108) | function remove_block_default_values(
  function clean_repeat_block (line 125) | function clean_repeat_block(block: RepeatBlock) {
  function remove_internal_block_fields (line 144) | function remove_internal_block_fields(block: NonScalarPdlBlock) {
  function expr_code_cleanup (line 158) | function expr_code_cleanup(expr: ExpressionT<unknown>): ExpressionT<unkn...

FILE: pdl-live-react/src/routes/PdlRoutes.tsx
  function PdlRoutes (line 18) | function PdlRoutes() {

FILE: pdl-live-react/src/title.ts
  function capitalize (line 4) | function capitalize(s: string) {
  function useDynamicTitle (line 8) | function useDynamicTitle() {

FILE: pdl-live-react/src/view/CopyToClipboard.tsx
  function CopyToClipboard (line 6) | function CopyToClipboard(props: { children: string }) {

FILE: pdl-live-react/src/view/Markdown.tsx
  function Markdown (line 11) | function Markdown(props: MarkdownProps) {

FILE: pdl-live-react/src/view/Result.tsx
  type Props (line 14) | type Props = {
  function Result (line 21) | function Result({

FILE: pdl-live-react/src/view/Value.tsx
  type Props (line 4) | type Props = { children: boolean | number | string | unknown }
  function isJson (line 6) | function isJson(s: string) {
  function Value (line 15) | function Value({ children: s }: Props) {

FILE: pdl-live-react/src/view/breadcrumbs/BreadcrumbBar.tsx
  type Props (line 5) | type Props = {
  function BreadcrumbBar (line 10) | function BreadcrumbBar(props: Props) {

FILE: pdl-live-react/src/view/breadcrumbs/BreadcrumbBarForBlock.tsx
  type Props (line 5) | type Props = {
  function BreadcrumbBarForBlock (line 9) | function BreadcrumbBarForBlock({ block }: Props) {

FILE: pdl-live-react/src/view/breadcrumbs/BreadcrumbBarForBlockId.tsx
  type Props (line 10) | type Props = {
  function asIter (line 18) | function asIter(part: string) {
  function BreadcrumbBarForBlockId (line 24) | function BreadcrumbBarForBlockId({

FILE: pdl-live-react/src/view/breadcrumbs/BreadcrumbBarItem.tsx
  type Props (line 10) | type Props = PropsWithChildren<{
  type BreadcrumbBarItemComponent (line 17) | type BreadcrumbBarItemComponent = ReactElement<
  function BreadcrumbBarItem (line 22) | function BreadcrumbBarItem({

FILE: pdl-live-react/src/view/breadcrumbs/Def.tsx
  type Props (line 6) | type Props = {
  function Def (line 16) | function Def(props: Props) {

FILE: pdl-live-react/src/view/code/Code.tsx
  type SupportedLanguage (line 9) | type SupportedLanguage =
  type Props (line 17) | type Props = {
  function Code (line 26) | function Code({

FILE: pdl-live-react/src/view/code/CodeGroup.tsx
  type Props (line 9) | type Props = {
  function CodeGroup (line 15) | function CodeGroup({ code, lang, term = "Code" }: Props) {

FILE: pdl-live-react/src/view/code/PreviewLight.tsx
  type Props (line 15) | type Props = {
  function PreviewLight (line 22) | function PreviewLight({

FILE: pdl-live-react/src/view/detail/BlockNotFound.tsx
  function BlockNotFound (line 1) | function BlockNotFound(props: {

FILE: pdl-live-react/src/view/detail/ContextTabContent.tsx
  type Props (line 14) | type Props = {
  function ContextTabContent (line 18) | function ContextTabContent({ block }: Props) {

FILE: pdl-live-react/src/view/detail/DefContent.tsx
  type Props (line 8) | type Props = {
  function DefContent (line 12) | function DefContent({ value }: Props) {

FILE: pdl-live-react/src/view/detail/DrawerContent.tsx
  type Props (line 25) | type Props = {
  function header (line 29) | function header(objectType: string) {
  function description (line 38) | function description(block: Block) {
  function DrawerContent (line 42) | function DrawerContent({ value }: Props) {

FILE: pdl-live-react/src/view/detail/DrawerContentBody.tsx
  type Props (line 20) | type Props = {
  function DrawerContentBody (line 28) | function DrawerContentBody({

FILE: pdl-live-react/src/view/detail/Group.tsx
  function Group (line 9) | function Group({

FILE: pdl-live-react/src/view/detail/RawTraceTabContent.tsx
  function RawTraceTabContent (line 4) | function RawTraceTabContent({ block }: { block: Model }) {

FILE: pdl-live-react/src/view/detail/ResultTabContent.tsx
  function UsageTabContent (line 5) | function UsageTabContent({

FILE: pdl-live-react/src/view/detail/SourceTabContent.tsx
  function SourceTabContent (line 4) | function SourceTabContent({ block }: { block: Model }) {

FILE: pdl-live-react/src/view/detail/SummaryTabContent.tsx
  function SummaryTabContent (line 16) | function SummaryTabContent({ block }: { block: Block }) {
  function descriptionItems (line 20) | function descriptionItems(block: import("../../helpers").NonScalarPdlBlo...

FILE: pdl-live-react/src/view/detail/UsageTabContent.tsx
  function UsageTabContent (line 15) | function UsageTabContent({
  function descriptionItems (line 23) | function descriptionItems(block: ModelBlockWithUsage & PdlBlockWithTimin...

FILE: pdl-live-react/src/view/detail/find.ts
  function find (line 14) | function find(

FILE: pdl-live-react/src/view/detail/kind/Call.tsx
  function ModelItems (line 3) | function ModelItems({

FILE: pdl-live-react/src/view/detail/kind/Code.tsx
  function CodeItems (line 6) | function CodeItems({

FILE: pdl-live-react/src/view/detail/kind/Data.tsx
  function ModelItems (line 4) | function ModelItems({

FILE: pdl-live-react/src/view/detail/kind/Error.tsx
  function ErrorItems (line 3) | function ErrorItems({

FILE: pdl-live-react/src/view/detail/kind/Function.tsx
  function FunctionItems (line 7) | function FunctionItems({

FILE: pdl-live-react/src/view/detail/kind/If.tsx
  function ModelItems (line 5) | function ModelItems({

FILE: pdl-live-react/src/view/detail/kind/Model.tsx
  function ModelItems (line 13) | function ModelItems({ block }: { block: ModelBlock }) {

FILE: pdl-live-react/src/view/detail/kind/Read.tsx
  function ModelItems (line 4) | function ModelItems({

FILE: pdl-live-react/src/view/detail/kind/Text.tsx
  function TextItems (line 3) | function TextItems({

FILE: pdl-live-react/src/view/masonry/Duration.tsx
  type Props (line 14) | type Props = Pick<
  function duration (line 24) | function duration(timing: Props) {
  function format (line 28) | function format(nanos: number, _timezone: string) {
  function Duration (line 34) | function Duration(timing: Props) {

FILE: pdl-live-react/src/view/masonry/Masonry.tsx
  type Props (line 5) | type Props = import("react").PropsWithChildren<{

FILE: pdl-live-react/src/view/masonry/MasonryCombo.tsx
  type Runner (line 43) | type Runner = (
  type Props (line 51) | type Props = {
  function getSMLUserSetting (line 57) | function getSMLUserSetting(): SML {
  function setSMLUserSetting (line 60) | function setSMLUserSetting(sml: SML) {
  function MasonryCombo (line 65) | function MasonryCombo({ value, setValue }: Props) {
  function spliceSubtree (line 292) | function spliceSubtree(
  function updateIds (line 340) | function updateIds(

FILE: pdl-live-react/src/view/masonry/MasonryTile.tsx
  type Props (line 30) | type Props = import("./Tile").default & {
  function MasonryTile (line 40) | function MasonryTile({
  function renderValue (line 193) | function renderValue({

FILE: pdl-live-react/src/view/masonry/MasonryTileWrapper.tsx
  type Props (line 3) | type Props = import("react").PropsWithChildren<{
  function MasonryTileWrapper (line 11) | function MasonryTileWrapper({

FILE: pdl-live-react/src/view/masonry/RunMenu.tsx
  type Props (line 19) | type Props = Pick<import("./Tile").default, "block"> & {
  function RunMenu (line 27) | function RunMenu({ block, run }: Props) {

FILE: pdl-live-react/src/view/masonry/Tile.ts
  type Tile (line 1) | type Tile = {

FILE: pdl-live-react/src/view/masonry/Toolbar.tsx
  type SML (line 13) | type SML = "s" | "m" | "l" | "xl"
  type Props (line 15) | type Props = import("./ToolbarPaginator").Props & {
  function MasonryToolbar (line 24) | function MasonryToolbar({

FILE: pdl-live-react/src/view/masonry/ToolbarPaginator.tsx
  type Props (line 3) | type Props = Pick<
  function ToolbarPaginator (line 11) | function ToolbarPaginator({

FILE: pdl-live-react/src/view/masonry/ToolbarReplayButton.tsx
  type Props (line 4) | type Props = {
  function ToolbarReplayButton (line 9) | function ToolbarReplayButton({ run, isRunning }: Props) {

FILE: pdl-live-react/src/view/masonry/ToolbarSMLToggle.tsx
  function ToolbarAsToggler (line 4) | function ToolbarAsToggler({

FILE: pdl-live-react/src/view/masonry/ToolbarShowSourceButton.tsx
  type Props (line 7) | type Props = {
  function ToolbarShowSourceButton (line 12) | function ToolbarShowSourceButton({ root }: Props) {

FILE: pdl-live-react/src/view/masonry/View.ts
  type View (line 1) | type View = "program" | "source" | "rawtrace"
  function isView (line 3) | function isView(v: string): v is View {

FILE: pdl-live-react/src/view/masonry/condvar.ts
  class ConditionVariable (line 1) | class ConditionVariable {
    method wait (line 8) | public async wait(): Promise<void> {
    method signal (line 18) | public signal(): void {
    method reset (line 26) | public reset(): void {

FILE: pdl-live-react/src/view/masonry/model.ts
  function removeFluff (line 43) | function removeFluff({ kind, block }: Tile) {
  function computeModel (line 55) | function computeModel(block: import("../../pdl_ast").PdlBlock) {
  function withDefs (line 157) | function withDefs(block: NonScalarPdlBlock, tiles: Tile[]) {

FILE: pdl-live-react/src/view/masonry/stability.ts
  type StabilityMetric (line 13) | type StabilityMetric = {
  type BlockWithStabilityMetrics (line 19) | type BlockWithStabilityMetrics =
  function hasStabilityMetrics (line 24) | function hasStabilityMetrics(
  function addTemperature (line 31) | function addTemperature(block: NonScalarPdlBlock, temperature: number) {
  function runNTimes (line 44) | async function runNTimes(
  type Grouping (line 113) | type Grouping = Record<number, (PdlBlockWithResult & ModelBlock)[]>
  function groupByTemperature (line 115) | function groupByTemperature(
  function isLocalizedExpression (line 133) | function isLocalizedExpression(
  function isParameters (line 144) | function isParameters(

FILE: pdl-live-react/src/view/term/RunTerminal.tsx
  type Props (line 10) | type Props = {
  function RunTerminal (line 27) | function RunTerminal({

FILE: pdl-live-react/src/view/timeline/Timeline.tsx
  type Props (line 6) | type Props = {
  function Timeline (line 10) | function Timeline({ block }: Props) {

FILE: pdl-live-react/src/view/timeline/TimelineBar.tsx
  type Props (line 4) | type Props = import("./model").TimelineRowWithExtrema
  function TimelineBar (line 6) | function TimelineBar({

FILE: pdl-live-react/src/view/timeline/TimelineFromModel.tsx
  type Props (line 8) | type Props = {
  function TimelineFromModel (line 15) | function TimelineFromModel({ model, numbering }: Props) {

FILE: pdl-live-react/src/view/timeline/TimelineRow.tsx
  type Props (line 6) | type Props = import("./model").TimelineRowWithExtrema & {
  function TimelineRow (line 12) | function TimelineRow(row: Props) {
  function treeSymbols (line 35) | function treeSymbols(row: Props) {
  function prefixSymbols (line 39) | function prefixSymbols(row: Props) {
  function finalSymbol (line 43) | function finalSymbol(row: Props) {

FILE: pdl-live-react/src/view/timeline/TimelineRowKindCell.tsx
  type Props (line 7) | type Props = {
  function TimelineRowKindCell (line 12) | function TimelineRowKindCell({ row, ordinal }: Props) {

FILE: pdl-live-react/src/view/timeline/model.ts
  type TimelineRow (line 13) | type TimelineRow = {
  type TimelineRowWithExtrema (line 30) | type TimelineRowWithExtrema = TimelineRow & {
  type TimelineModel (line 38) | type TimelineModel = TimelineRow[]
  type Position (line 41) | type Position = "push" | "middle" | "pop"
  function ignore (line 43) | function ignore(_block: PdlBlockWithTiming) {
  function computeModel (line 47) | function computeModel(block: unknown | PdlBlock): TimelineModel {
  function squashProximateModelInputs (line 66) | function squashProximateModelInputs(model: TimelineModel): TimelineModel {
  function computeModelIter (line 84) | function computeModelIter(
  function childrenOf (line 125) | function childrenOf(block: NonScalarPdlBlock) {
  function positionOf (line 166) | function positionOf(row: TimelineRow): Position {
  function nextSibling (line 182) | function nextSibling(row: TimelineRow, idx: number, A: TimelineRow[]) {
  type PushPop (line 190) | type PushPop = { prefix: boolean[]; position: Position }
  function pushPopsFor (line 192) | function pushPopsFor(model: TimelineRow[]): PushPop[] {

FILE: pdl-live-react/src/window.d.ts
  type Window (line 1) | interface Window {

FILE: src/pdl/__init__.py
  function _get_distribution_version (line 6) | def _get_distribution_version(distribution_name: str) -> str:

FILE: src/pdl/optimize/config_parser.py
  class JsonlDataset (line 6) | class JsonlDataset(BaseModel):
  class OptimizationConfig (line 14) | class OptimizationConfig(BaseModel):
    method get_variable_names (line 40) | def get_variable_names(self) -> list[str]:

FILE: src/pdl/optimize/optimizer_evaluator.py
  class OptimizerEvaluator (line 18) | class OptimizerEvaluator(Thread):
    method __init__ (line 22) | def __init__(
    method get_scope (line 48) | def get_scope(self) -> ScopeType:
    method score (line 51) | def score(self, document: str, ground_truth: Any) -> float:
    method run (line 54) | def run(  # type: ignore # noqa: C901

FILE: src/pdl/optimize/parse_number.py
  function parse_number (line 39) | def parse_number(text):
  function extract_math_answer (line 60) | def extract_math_answer(result: str) -> float | int | None:
  function old_extract (line 71) | def old_extract(result: str) -> float:

FILE: src/pdl/optimize/pdl_evaluator.py
  class PdlEvaluator (line 9) | class PdlEvaluator(OptimizerEvaluator):
    method __init__ (line 10) | def __init__(
    method get_scope (line 22) | def get_scope(self) -> ScopeType:
    method score (line 42) | def score(self, document: str, ground_truth: Any) -> float:

FILE: src/pdl/optimize/pdl_optimizer.py
  function resave_pdl (line 44) | def resave_pdl(input_path: Path, output_path: Path, state: dict) -> int:
  class BudgetPolicy (line 68) | class BudgetPolicy(Enum):
  class PDLOptimizer (line 74) | class PDLOptimizer:
    method __init__ (line 76) | def __init__(
    method parse_budget (line 121) | def parse_budget(self):
    method load_pdl (line 144) | def load_pdl(self, path: Path) -> Program:
    method sample_random_indices (line 148) | def sample_random_indices(self, dataset: list, size: int) -> list[Any]:
    method sample_random_index (line 157) | def sample_random_index(self, items: list):
    method random_uuid (line 160) | def random_uuid(self, k: int = 8) -> str:
    method sample_candidates (line 164) | def sample_candidates(
    method save_pdl_program (line 253) | def save_pdl_program(self, pdl_program: Program) -> int:
    method save_experiment (line 260) | def save_experiment(self):
    method run (line 273) | def run(self) -> dict[str, Any]:
    method evaluate (line 590) | def evaluate(
    method benchmark (line 724) | def benchmark(self, test_set_size: int, candidate: dict | None = None):
  function run_optimizer (line 778) | def run_optimizer() -> int:

FILE: src/pdl/optimize/util.py
  class TrialOutput (line 20) | class TrialOutput:
    method to_dict (line 34) | def to_dict(self) -> dict:
  class CandidateResult (line 47) | class CandidateResult:
    method to_dict (line 55) | def to_dict(self) -> dict:
  function print_candidate (line 66) | def print_candidate(candidate: dict):
  function execute_threads (line 73) | def execute_threads(max_threads: int, pdl_threads: list, timeout: int | ...

FILE: src/pdl/pdl.py
  class InterpreterConfig (line 38) | class InterpreterConfig(TypedDict, total=False):
  class Result (line 73) | class Result(TypedDict):
  function exec_program (line 82) | def exec_program(
  function exec_dict (line 133) | def exec_dict(
  function exec_str (line 157) | def exec_str(
  function exec_file (line 179) | def exec_file(
  function pdl (line 205) | def pdl(func):
  function main (line 213) | def main():

FILE: src/pdl/pdl_ast.py
  function _ensure_lower (line 33) | def _ensure_lower(value):
  class BlockKind (line 72) | class BlockKind(StrEnum):
  class PdlLocationType (line 98) | class PdlLocationType(BaseModel):
  class LocalizedExpression (line 121) | class LocalizedExpression(BaseModel, Generic[LocalizedExpressionT]):
  class Pattern (line 173) | class Pattern(BaseModel):
  class OrPattern (line 182) | class OrPattern(Pattern):
  class ArrayPattern (line 189) | class ArrayPattern(Pattern):
  class ObjectPattern (line 196) | class ObjectPattern(Pattern):
  class AnyPattern (line 203) | class AnyPattern(Pattern):
  class PdlType (line 244) | class PdlType(BaseModel):
  class OptionalPdlType (line 250) | class OptionalPdlType(PdlType):
  class JsonSchemaTypePdlType (line 257) | class JsonSchemaTypePdlType(PdlType):
  class EnumPdlType (line 266) | class EnumPdlType(PdlType):
  class ObjectPdlType (line 275) | class ObjectPdlType(PdlType):
  class Parser (line 302) | class Parser(BaseModel):
  class PdlParser (line 314) | class PdlParser(Parser):
  class RegexParser (line 321) | class RegexParser(Parser):
  class ContributeTarget (line 344) | class ContributeTarget(StrEnum):
  class ContributeValue (line 353) | class ContributeValue(BaseModel):
  class ExpectationType (line 368) | class ExpectationType(BaseModel):
  class PdlTiming (line 384) | class PdlTiming(BaseModel):
  class PdlUsage (line 406) | class PdlUsage(BaseModel):
  class Block (line 424) | class Block(BaseModel):
  class LeafBlock (line 485) | class LeafBlock(Block):
  class IndependentEnum (line 492) | class IndependentEnum(StrEnum):
  class StructuredBlock (line 503) | class StructuredBlock(Block):
  class FunctionBlock (line 511) | class FunctionBlock(LeafBlock):
  class CallBlock (line 526) | class CallBlock(LeafBlock):
  class LitellmParameters (line 540) | class LitellmParameters(BaseModel):
  class OpenaiParameters (line 632) | class OpenaiParameters(BaseModel):
  class ModelPlatform (line 649) | class ModelPlatform(StrEnum):
  class ModelBlock (line 655) | class ModelBlock(LeafBlock):
  class LitellmModelBlock (line 673) | class LitellmModelBlock(ModelBlock):
  class GraniteioProcessor (line 698) | class GraniteioProcessor(BaseModel):
  class GraniteioModelBlock (line 710) | class GraniteioModelBlock(ModelBlock):
  class OpenaiModelBlock (line 724) | class OpenaiModelBlock(ModelBlock):
  class BaseCodeBlock (line 751) | class BaseCodeBlock(LeafBlock):
  class CodeBlock (line 757) | class CodeBlock(BaseCodeBlock):
  class PythonCodeBlock (line 768) | class PythonCodeBlock(CodeBlock):
  class IPythonCodeBlock (line 787) | class IPythonCodeBlock(CodeBlock):
  class JinjaCodeBlock (line 805) | class JinjaCodeBlock(CodeBlock):
  class PdlCodeBlock (line 828) | class PdlCodeBlock(CodeBlock):
  class CommandCodeBlock (line 850) | class CommandCodeBlock(CodeBlock):
  class ArgsBlock (line 867) | class ArgsBlock(BaseCodeBlock):
  class GetBlock (line 886) | class GetBlock(LeafBlock):
  class DataBlock (line 898) | class DataBlock(LeafBlock):
  class JoinConfig (line 931) | class JoinConfig(BaseModel):
  class JoinText (line 939) | class JoinText(JoinConfig):
  class JoinArray (line 951) | class JoinArray(JoinConfig):
  class JoinObject (line 959) | class JoinObject(JoinConfig):
  class JoinLastOf (line 967) | class JoinLastOf(JoinConfig):
  class JoinReduce (line 975) | class JoinReduce(JoinConfig):
  class SequenceBlock (line 990) | class SequenceBlock(StructuredBlock):
  class TextBlock (line 1001) | class TextBlock(StructuredBlock):
  class LastOfBlock (line 1010) | class LastOfBlock(StructuredBlock):
  class ArrayBlock (line 1018) | class ArrayBlock(StructuredBlock):
  class ObjectBlock (line 1026) | class ObjectBlock(StructuredBlock):
  class MessageBlock (line 1034) | class MessageBlock(LeafBlock):
  class IfBlock (line 1048) | class IfBlock(StructuredBlock):
  class MatchCase (line 1075) | class MatchCase(BaseModel):
  class MatchBlock (line 1094) | class MatchBlock(StructuredBlock):
  class RepeatBlock (line 1124) | class RepeatBlock(StructuredBlock):
  class MapBlock (line 1178) | class MapBlock(StructuredBlock):
  class ReadBlock (line 1227) | class ReadBlock(LeafBlock):
  class IncludeBlock (line 1255) | class IncludeBlock(StructuredBlock):
  class ImportBlock (line 1266) | class ImportBlock(LeafBlock):
  class FactorBlock (line 1277) | class FactorBlock(LeafBlock):
  class AggregatorConfig (line 1291) | class AggregatorConfig(BaseModel):
  class FileAggregatorConfig (line 1305) | class FileAggregatorConfig(AggregatorConfig):
  class AggregatorBlock (line 1323) | class AggregatorBlock(LeafBlock):
  class ErrorBlock (line 1331) | class ErrorBlock(LeafBlock):
  class EmptyBlock (line 1343) | class EmptyBlock(LeafBlock):
  class Program (line 1393) | class Program(RootModel):
  class PdlBlock (line 1403) | class PdlBlock(RootModel):
  class PDLException (line 1413) | class PDLException(Exception):
    method __init__ (line 1414) | def __init__(self, message):
  class PDLRuntimeError (line 1419) | class PDLRuntimeError(PDLException):
    method __init__ (line 1420) | def __init__(
  class PDLRuntimeExpressionError (line 1434) | class PDLRuntimeExpressionError(PDLRuntimeError):
  class PDLRuntimeParserError (line 1438) | class PDLRuntimeParserError(PDLRuntimeError):
  class PDLRuntimeProcessBlocksError (line 1442) | class PDLRuntimeProcessBlocksError(PDLException):
    method __init__ (line 1443) | def __init__(
  function get_default_model_parameters (line 1467) | def get_default_model_parameters() -> list[dict[str, Any]]:
  function get_sampling_defaults (line 1591) | def get_sampling_defaults() -> list[dict[str, Any]]:

FILE: src/pdl/pdl_ast_utils.py
  function iter_block_children (line 41) | def iter_block_children(f: Callable[[BlockType], None], block: BlockType...
  class MappedFunctions (line 131) | class MappedFunctions:
    method f_block (line 132) | def f_block(self, block: BlockType) -> BlockType:
    method f_expr (line 135) | def f_expr(self, expr: ExpressionType) -> ExpressionType:
  function map_block_children (line 139) | def map_block_children(f: MappedFunctions, block: BlockType) -> BlockType:
  function map_match_case (line 267) | def map_match_case(f: MappedFunctions, match_case: MatchCase) -> MatchCase:

FILE: src/pdl/pdl_compilers/to_regex.py
  class Re (line 33) | class Re(ABC):
    method to_re (line 35) | def to_re(self) -> str: ...
  class ReEmpty (line 38) | class ReEmpty(Re):
    method to_re (line 41) | def to_re(self):
  class ReConst (line 46) | class ReConst(Re):
    method to_re (line 51) | def to_re(self):
  class ReAnyChar (line 55) | class ReAnyChar(Re):
    method to_re (line 58) | def to_re(self):
  class ReDigit (line 62) | class ReDigit(Re):
    method to_re (line 65) | def to_re(self):
  class ReIn (line 70) | class ReIn(Re):
    method to_re (line 75) | def to_re(self):
  class ReNotIn (line 80) | class ReNotIn(Re):
    method to_re (line 85) | def to_re(self):
  class ReRange (line 90) | class ReRange(Re):
    method to_re (line 96) | def to_re(self):
  class ReBegin (line 100) | class ReBegin(Re):
    method to_re (line 103) | def to_re(self):
  class ReEnd (line 107) | class ReEnd(Re):
    method to_re (line 110) | def to_re(self):
  class ReStar (line 115) | class ReStar(Re):
    method to_re (line 120) | def to_re(self):
  class RePlus (line 126) | class RePlus(Re):
    method to_re (line 131) | def to_re(self):
  class ReRepeatN (line 137) | class ReRepeatN(Re):
    method to_re (line 143) | def to_re(self):
  class ReOpt (line 149) | class ReOpt(Re):
    method to_re (line 154) | def to_re(self):
  class ReSeq (line 160) | class ReSeq(Re):
    method to_re (line 165) | def to_re(self):
  class ReOr (line 171) | class ReOr(Re):
    method to_re (line 176) | def to_re(self):
  class ReAnyUpto (line 182) | class ReAnyUpto(Re):
    method to_re (line 187) | def to_re(self):
  class ReJson (line 191) | class ReJson(Re):
    method to_re (line 194) | def to_re(self):
  function _paren (line 212) | def _paren(s: str) -> str:
  function compile_blocks (line 246) | def compile_blocks(
  function compile_block (line 259) | def compile_block(
  function data_to_regex (line 360) | def data_to_regex(data: ExpressionType) -> RegexType:
  function scope_union (line 484) | def scope_union(scope1: CompileScope, scope2: CompileScope) -> CompileSc...

FILE: src/pdl/pdl_context.py
  class SerializeMode (line 20) | class SerializeMode(StrEnum):
  class PDLContext (line 26) | class PDLContext(ABC, Sequence):
    method serialize (line 29) | def serialize(self, mode: SerializeMode) -> list[dict[str, Any]]: ...
    method __add__ (line 31) | def __add__(self, value: "PDLContext"):
    method __mul__ (line 34) | def __mul__(self, value: "PDLContext"):
  class SingletonContext (line 41) | class SingletonContext(PDLContext):
    method __init__ (line 44) | def __init__(self, message: PdlLazy[dict[str, Any]] | dict[str, Any]):
    method serialize (line 50) | def serialize(self, mode: SerializeMode) -> list[dict[str, Any]]:
    method __len__ (line 54) | def __len__(self):
    method __getitem__ (line 57) | def __getitem__(self, index: int | slice):  # pyright: ignore
    method __repr__ (line 60) | def __repr__(self):  # pyright: ignore
  class IndependentContext (line 64) | class IndependentContext(PDLContext):
    method __init__ (line 67) | def __init__(self, context: list[PDLContext | dict[str, Any]]):
    method serialize (line 86) | def serialize(self, mode: SerializeMode) -> list[dict[str, Any]]:
    method __len__ (line 94) | def __len__(self):  # pyright: ignore
    method __getitem__ (line 97) | def __getitem__(self, index: int | slice):  # pyright: ignore
    method __repr__ (line 100) | def __repr__(self):  # pyright: ignore
  class DependentContext (line 106) | class DependentContext(PDLContext):
    method __init__ (line 109) | def __init__(self, context: list[PDLContext | dict[str, Any]]):
    method serialize (line 128) | def serialize(self, mode: SerializeMode) -> list[dict[str, Any]]:
    method __len__ (line 134) | def __len__(self):  # pyright: ignore
    method __getitem__ (line 137) | def __getitem__(self, index: int | slice):  # pyright: ignore
    method __repr__ (line 140) | def __repr__(self):  # pyright: ignore
  function ensure_context (line 146) | def ensure_context(context: dict | list | PDLContext) -> PDLContext:
  function deserialize (line 160) | def deserialize(
  function add_done_callback (line 172) | def add_done_callback(

FILE: src/pdl/pdl_distributions.py
  class Categorical (line 13) | class Categorical(Generic[T]):
    method __init__ (line 18) | def __init__(self, tuples: list[tuple[T, float, list[Any]]]):
    method shrink (line 27) | def shrink(self) -> "Categorical[T]":
    method sample (line 40) | def sample(self) -> T:
    method sort (line 45) | def sort(self) -> "Categorical[T]":
    method prob (line 54) | def prob(self, x: T) -> float:
  function viz (line 64) | def viz(dist: Categorical[float], **kwargs):

FILE: src/pdl/pdl_dumper.py
  function repr_str (line 83) | def repr_str(dumper, data):
  function dump_yaml (line 92) | def dump_yaml(data, **kwargs):
  function dumps_json (line 103) | def dumps_json(data, **kwargs):
  function program_to_dict (line 110) | def program_to_dict(
  function block_to_dict (line 116) | def block_to_dict(block: pdl_ast.BlockType, json_compatible: bool) -> Du...
  function advance_block_to_dict (line 122) | def advance_block_to_dict(  # noqa: C901
  function data_to_dict (line 387) | def data_to_dict(data: Any, json_compatible: bool):
  function expr_to_dict (line 398) | def expr_to_dict(expr: ExpressionType, json_compatible: bool):
  function type_to_dict (line 408) | def type_to_dict(t: PdlTypeType):
  function timing_to_dict (line 448) | def timing_to_dict(timing: PdlTiming) -> dict:
  function usage_to_dict (line 464) | def usage_to_dict(usage: PdlUsage) -> dict:
  function expectation_to_dict (line 472) | def expectation_to_dict(req: ExpectationType, json_compatible: bool) -> ...
  function pattern_to_dict (line 480) | def pattern_to_dict(pattern: PatternType):
  function join_to_dict (line 502) | def join_to_dict(join: JoinType, json_compatible: bool) -> dict[str, Any]:
  function as_json (line 521) | def as_json(value: Any) -> JsonType:
  function parser_to_dict (line 535) | def parser_to_dict(parser: ParserType) -> str | dict[str, Any]:
  function location_to_dict (line 554) | def location_to_dict(location: PdlLocationType) -> dict[str, Any]:
  function contribute_to_list (line 558) | def contribute_to_list(
  function aggregator_to_dict (line 570) | def aggregator_to_dict(aggregator: AggregatorType):
  function build_exclude (line 581) | def build_exclude(obj: Any, regex: re.Pattern[str]) -> Any:
  function dump_program_exclude_internals (line 612) | def dump_program_exclude_internals(program: Program) -> str:
  function dump_program (line 624) | def dump_program(program: Program, exclude: IncEx | None = None) -> str:

FILE: src/pdl/pdl_granite_io.py
  class GraniteioModel (line 19) | class GraniteioModel:
    method processor_of_block (line 21) | def processor_of_block(block: GraniteioModelBlock):
    method build_message (line 68) | def build_message(
    method async_generate_text (line 78) | async def async_generate_text(
    method generate_text (line 114) | def generate_text(

FILE: src/pdl/pdl_infer.py
  class PpdlConfig (line 33) | class PpdlConfig(TypedDict, total=False):
  function exec_program (line 53) | def exec_program(  # pylint: disable=too-many-arguments, too-many-positi...
  function exec_dict (line 146) | def exec_dict(  # pylint: disable=too-many-arguments, too-many-positiona...
  function exec_str (line 159) | def exec_str(
  function exec_file (line 171) | def exec_file(
  function main (line 187) | def main():

FILE: src/pdl/pdl_inference.py
  function resample (line 18) | def resample(particles: list[Any], scores: list[float]) -> list[Any]:
  function make_model (line 27) | def make_model(
  function infer_importance_sampling (line 44) | def infer_importance_sampling(  # pylint: disable=too-many-arguments
  function infer_importance_sampling_parallel (line 63) | def infer_importance_sampling_parallel(  # pylint: disable=too-many-argu...
  function _process_particle (line 104) | def _process_particle(
  function infer_smc (line 118) | def infer_smc(  # pylint: disable=too-many-arguments
  function infer_smc_parallel (line 156) | def infer_smc_parallel(  # pylint: disable=too-many-arguments
  function infer_rejection_sampling (line 200) | def infer_rejection_sampling(  # pylint: disable=too-many-arguments
  function infer_rejection_sampling_parallel (line 231) | def infer_rejection_sampling_parallel(  # pylint: disable=too-many-argum...
  function infer_majority_voting (line 267) | def infer_majority_voting(  # pylint: disable=too-many-arguments
  function infer_majority_voting_parallel (line 282) | def infer_majority_voting_parallel(  # pylint: disable=too-many-arguments

FILE: src/pdl/pdl_interpreter.py
  class ClosureBlock (line 173) | class ClosureBlock(FunctionBlock):
    method __call__ (line 178) | def __call__(self, *args, **kwargs):
  function generate (line 208) | def generate(
  function process_prog (line 252) | def process_prog(
  function process_block (line 304) | def process_block(
  function process_expression_block (line 339) | def process_expression_block(
  function process_advanced_block_timed (line 374) | def process_advanced_block_timed(
  function id_with_set_first_use_nanos (line 405) | def id_with_set_first_use_nanos(timing):
  function set_error_to_scope_for_retry (line 414) | def set_error_to_scope_for_retry(
  function process_advanced_block (line 441) | def process_advanced_block(  # noqa: C901
  function process_advance_block_retry (line 471) | def process_advance_block_retry(  # noqa: C901
  function context_in_contribute (line 638) | def context_in_contribute(block: AdvancedBlockType) -> bool:
  function result_with_type_checking (line 649) | def result_with_type_checking(
  function process_block_body_with_replay (line 668) | def process_block_body_with_replay(
  function process_block_body (line 722) | def process_block_body(
  function _split_map_output (line 1216) | def _split_map_output(
  function _evaluate_for_field (line 1234) | def _evaluate_for_field(
  function _evaluate_max_iterations_field (line 1276) | def _evaluate_max_iterations_field(
  function _evaluate_join_field (line 1289) | def _evaluate_join_field(
  function is_matching (line 1303) | def is_matching(  # pylint: disable=too-many-return-statements
  function process_defs (line 1356) | def process_defs(
  function process_block_of (line 1384) | def process_block_of(  # pylint: disable=too-many-arguments, too-many-po...
  function process_blocks_of (line 1415) | def process_blocks_of(  # pylint: disable=too-many-arguments, too-many-p...
  function process_blocks (line 1448) | def process_blocks(  # pylint: disable=too-many-arguments,too-many-posit...
  function combine_results (line 1522) | def combine_results(join_type: JoinType, results: list[PdlLazy[Any]]):
  function process_contribute_context (line 1562) | def process_contribute_context(
  function process_contribute (line 1591) | def process_contribute(
  function process_contribution (line 1608) | def process_contribution(
  function process_expr_of (line 1659) | def process_expr_of(
  function process_condition_of (line 1682) | def process_condition_of(
  function process_expr (line 1710) | def process_expr(  # pylint: disable=too-many-return-statements
  function _process_expr (line 1728) | def _process_expr(  # pylint: disable=too-many-return-statements
  function process_call_model (line 1819) | def process_call_model(
  function generate_client_response (line 1971) | def generate_client_response(
  function generate_client_response_streaming (line 1992) | def generate_client_response_streaming(
  function litellm_parameters_to_dict (line 2095) | def litellm_parameters_to_dict(
  function openai_parameters_to_dict (line 2106) | def openai_parameters_to_dict(
  function generate_client_response_single (line 2117) | def generate_client_response_single(
  function process_call_code (line 2175) | def process_call_code(
  function call_python (line 2378) | def call_python(code: str, scope: ScopeType, state: InterpreterState) ->...
  function call_ipython (line 2396) | def call_ipython(code: str, scope: ScopeType) -> Any:
  function call_command (line 2405) | def call_command(code: str, code_a: list[str] | None) -> PdlLazy[str]:
  function call_jinja (line 2423) | def call_jinja(code: str, scope: ScopeType, parameters: dict) -> PdlLazy...
  function call_pdl (line 2432) | def call_pdl(code: str, scope: ScopeType) -> PdlLazy[Any]:
  function process_call (line 2439) | def process_call(
  function execute_call (line 2480) | def execute_call(state, current_context, closure, args, loc):
  function process_input (line 2512) | def process_input(
  function process_include (line 2561) | def process_include(
  function process_import (line 2591) | def process_import(
  class Aggregator (line 2640) | class Aggregator(ABC):
    method contribute (line 2642) | def contribute(
  class ContextAggregator (line 2662) | class ContextAggregator(Aggregator):
    method __init__ (line 2663) | def __init__(self, messages: LazyMessages | None = None):
    method contribute (line 2669) | def contribute(
  class FileAggregator (line 2689) | class FileAggregator(Aggregator):
    method __init__ (line 2690) | def __init__(
    method contribute (line 2698) | def contribute(
  function process_aggregator (line 2714) | def process_aggregator(
  function get_contribute_aggregator (line 2774) | def get_contribute_aggregator(
  function parse_result (line 2806) | def parse_result(parser: ParserType, text: str) -> JSONReturnType:
  function get_var (line 2906) | def get_var(var: str, scope: ScopeType, loc: PdlLocationType) -> Any:

FILE: src/pdl/pdl_interpreter_state.py
  class ScopeType (line 14) | class ScopeType(PdlDict):
    method __getitem__ (line 17) | def __getitem__(self, key):  # pyright: ignore
    method __or__ (line 22) | def __or__(self, value: PdlLazy | dict):
  class InterpreterState (line 26) | class InterpreterState(BaseModel):
    method with_yield_result (line 68) | def with_yield_result(self: "InterpreterState", b: bool) -> "Interpret...
    method with_yield_background (line 71) | def with_yield_background(self: "InterpreterState", b: bool) -> "Inter...
    method with_role (line 74) | def with_role(self: "InterpreterState", role: RoleType) -> "Interprete...
    method with_id (line 77) | def with_id(self: "InterpreterState", n: str) -> "InterpreterState":
    method with_iter (line 81) | def with_iter(self: "InterpreterState", i: int) -> "InterpreterState":
    method add_usage (line 84) | def add_usage(self, usage: PdlUsage):

FILE: src/pdl/pdl_lazy.py
  class PdlLazy (line 9) | class PdlLazy(Generic[LazyDataT]):
    method result (line 13) | def result(self) -> LazyDataT:
    method data (line 18) | def data(self) -> Any:
  class PdlConst (line 25) | class PdlConst(PdlLazy[PdlConstT]):
    method __init__ (line 26) | def __init__(self, data: PdlConstT | Future[PdlConstT]):
    method data (line 30) | def data(self):
    method __repr__ (line 33) | def __repr__(self):
    method result (line 36) | def result(self) -> PdlConstT:
  class PdlList (line 45) | class PdlList(Sequence[PdlListElemT], PdlLazy[list[PdlListElemT]]):
    method __init__ (line 46) | def __init__(
    method data (line 57) | def data(self) -> Union[list[PdlListElemT], "PdlList"]:
    method __getitem__ (line 65) | def __getitem__(self, index: int | slice):  # pyright: ignore
    method __len__ (line 73) | def __len__(self):
    method __repr__ (line 76) | def __repr__(self):
    method __add__ (line 79) | def __add__(self, value: Union["PdlList", list]):
    method result (line 86) | def result(self):
  class PdlDict (line 94) | class PdlDict(
    method __init__ (line 97) | def __init__(
    method data (line 108) | def data(self):
    method __getitem__ (line 116) | def __getitem__(self, key):  # pyright: ignore
    method __iter__ (line 124) | def __iter__(self):
    method __len__ (line 127) | def __len__(self):
    method __repr__ (line 130) | def __repr__(self):
    method __or__ (line 133) | def __or__(self, value: Union["PdlLazy", dict]):
    method result (line 138) | def result(self):  # pyright: ignore
  class PdlApply (line 146) | class PdlApply(PdlLazy[ApplyOutputT]):
    method __init__ (line 147) | def __init__(
    method data (line 156) | def data(self):
    method __repr__ (line 164) | def __repr__(self):
    method result (line 167) | def result(self) -> ApplyOutputT:
  function lazy_apply (line 180) | def lazy_apply(
  class PdlApply2 (line 191) | class PdlApply2(PdlLazy[Apply2OutputT]):
    method __init__ (line 192) | def __init__(
    method data (line 205) | def data(self) -> Apply2OutputT | PdlLazy[Apply2OutputT]:
    method __repr__ (line 220) | def __repr__(self):
    method result (line 223) | def result(self) -> Apply2OutputT:
  function lazy_apply2 (line 237) | def lazy_apply2(

FILE: src/pdl/pdl_linter.py
  function _guess_project_root_dir (line 81) | def _guess_project_root_dir(start_path: Path = Path.cwd()) -> Path | None:
  class LinterConfig (line 150) | class LinterConfig(BaseModel):
    method model_post_init (line 211) | def model_post_init(self, __context: Any) -> None:
    method should_ignore (line 240) | def should_ignore(self, path: Path) -> bool:
    method load (line 269) | def load(cls) -> Self:
  function _lint_pdl_file (line 358) | def _lint_pdl_file(file_path: Path, config: LinterConfig) -> bool:
  function _lint_pdl_files_in_directory (line 379) | def _lint_pdl_files_in_directory(
  function _arg_parser (line 438) | def _arg_parser():
  function _setup_logging (line 489) | def _setup_logging(args: argparse.Namespace, config: LinterConfig):
  function run_linter (line 515) | def run_linter() -> int:

FILE: src/pdl/pdl_llms.py
  class LitellmModel (line 27) | class LitellmModel:
    method async_generate_text (line 29) | async def async_generate_text(
    method generate_text (line 73) | def generate_text(
    method generate_text_stream (line 146) | def generate_text_stream(
  function set_structured_decoding_parameters (line 174) | def set_structured_decoding_parameters(

FILE: src/pdl/pdl_location_utils.py
  function append (line 6) | def append(loc: PdlLocationType, seg: str) -> PdlLocationType:
  function normalize (line 10) | def normalize(indentation: list[int], is_array_item: list[bool]) -> list...
  function get_paths (line 25) | def get_paths(
  function get_line_map (line 73) | def get_line_map(prog: str) -> dict[str, int]:
  function get_loc_string (line 94) | def get_loc_string(loc: PdlLocationType) -> str:
  function get_line (line 102) | def get_line(table: dict[str, int], p: list[str]) -> int:

FILE: src/pdl/pdl_notebook_ext.py
  class PDLMagics (line 16) | class PDLMagics(Magics):
    method pdl (line 33) | def pdl(self, line, cell, local_ns):
    method pdl_viewer (line 74) | def pdl_viewer(self, trace):
  function load_ipython_extension (line 205) | def load_ipython_extension(ipython):

FILE: src/pdl/pdl_openai.py
  class OpenaiModel (line 26) | class OpenaiModel:
    method _get_client_config (line 28) | def _get_client_config(parameters: dict[str, Any]) -> dict[str, Any]:
    method _get_client (line 50) | def _get_client(config: dict[str, Any]):
    method _prepare_parameters (line 57) | def _prepare_parameters(
    method async_generate_text (line 80) | async def async_generate_text(
    method generate_text (line 142) | def generate_text(
    method generate_text_stream (line 215) | def generate_text_stream(

FILE: src/pdl/pdl_parser.py
  class PDLParseError (line 14) | class PDLParseError(PDLException):
  function parse_file (line 18) | def parse_file(pdl_file: str | Path) -> tuple[Program, PdlLocationType]:
  function parse_str (line 25) | def parse_str(
  function parse_dict (line 37) | def parse_dict(pdl_dict: dict[str, Any], loc: PdlLocationType | None = N...

FILE: src/pdl/pdl_python_repl.py
  class PythonREPL (line 15) | class PythonREPL:
    method __init__ (line 18) | def __init__(
    method _run_code_in_process (line 44) | def _run_code_in_process(self, code: str, namespace: dict, timeout: fl...
    method __call__ (line 94) | def __call__(self, query: str) -> str:

FILE: src/pdl/pdl_runner.py
  function exec_docker (line 7) | def exec_docker(*args):

FILE: src/pdl/pdl_scheduler.py
  function _start_background_loop (line 11) | def _start_background_loop(loop):
  function create_event_loop_thread (line 20) | def create_event_loop_thread() -> AbstractEventLoop:
  function color_of (line 27) | def color_of(kind: BlockKind):
  function color_of_role (line 79) | def color_of_role(role: str):
  function yield_result (line 93) | def yield_result(result: Any, kind: BlockKind) -> None:
  function yield_background (line 105) | def yield_background(background) -> None:

FILE: src/pdl/pdl_schema_error_analyzer.py
  function is_base_type (line 6) | def is_base_type(schema):
  function is_array (line 28) | def is_array(schema):
  function is_object (line 34) | def is_object(schema):
  function is_any_of (line 40) | def is_any_of(schema):
  function nullable (line 46) | def nullable(schema):
  function get_non_null_type (line 54) | def get_non_null_type(schema):
  function match (line 62) | def match(ref_type, data):
  function analyze_errors (line 68) | def analyze_errors(defs, schema, data, loc: PdlLocationType) -> list[str...

FILE: src/pdl/pdl_schema_utils.py
  function convert_to_json_type (line 30) | def convert_to_json_type(a_type):
  function pdltype_to_jsonschema (line 47) | def pdltype_to_jsonschema(
  function get_json_schema_object (line 96) | def get_json_schema_object(
  function get_json_schema (line 120) | def get_json_schema(

FILE: src/pdl/pdl_schema_validator.py
  function type_check_args (line 10) | def type_check_args(
  function type_check_spec (line 40) | def type_check_spec(result: Any, spec: PdlTypeType, loc) -> list[str]:
  function type_check (line 47) | def type_check(result: Any, schema: dict[str, Any], loc) -> list[str]:

FILE: src/pdl/pdl_stdlib.py
  function _get_logprob (line 4) | def _get_logprob(value: str, top_logprobs):
  function _find_first_token (line 13) | def _find_first_token(content: str, logprobs):
  function reward (line 20) | def reward(response):
  function bool_confidence (line 42) | def bool_confidence(response):

FILE: src/pdl/pdl_utils.py
  class Ref (line 23) | class Ref(Generic[RefT]):
    method __init__ (line 24) | def __init__(self, ref: RefT):
  class GeneratorWrapper (line 33) | class GeneratorWrapper(
    method __init__ (line 38) | def __init__(
    method __iter__ (line 46) | def __iter__(self):
  function step_to_completion (line 53) | def step_to_completion(gen: Generator[Any, Any, GeneratorReturnT]) -> Ge...
  function to_async (line 63) | async def to_async(value: ToAsyncT) -> ToAsyncT:
  function stringify (line 67) | def stringify(result):
  function value_of_expr (line 85) | def value_of_expr(expr: ExpressionType[ValueOfExprT]) -> ValueOfExprT:
  function replace_contribute_value (line 96) | def replace_contribute_value(  # TODO: remove
  function get_contribute_context_value (line 110) | def get_contribute_context_value(
  function message_post_processing (line 123) | def message_post_processing(message: dict) -> dict[str, Any]:
  function apply_defaults (line 143) | def apply_defaults(
  function apply_raw_defaults (line 160) | def apply_raw_defaults(
  function validate_scope (line 206) | def validate_scope(scope: dict):
  function validate_pdl_model_defaults (line 211) | def validate_pdl_model_defaults(model_defaults: list[dict[str, dict[str,...
  function redact_secrets (line 224) | def redact_secrets(data: Any, secrets: list[str]) -> Any:
  function write_trace (line 253) | def write_trace(
  class Resample (line 280) | class Resample(Exception):
    method __init__ (line 281) | def __init__(self, state, score):

FILE: tests/test_array.py
  function test_array_data (line 6) | def test_array_data():
  function test_for_data (line 21) | def test_for_data():
  function test_repeat_until (line 46) | def test_repeat_until():

FILE: tests/test_ast_utils.py
  class Counter (line 7) | class Counter:
    method __init__ (line 8) | def __init__(self):
    method incr (line 11) | def incr(self, *args):
  class IterCounter (line 15) | class IterCounter:
    method __init__ (line 16) | def __init__(self):
    method count (line 19) | def count(self, ast):
  class MapCounter (line 24) | class MapCounter:
    method __init__ (line 25) | def __init__(self):
    method count (line 28) | def count(map_self, ast):  # pylint: disable=no-self-argument # type: ...
  function test_ast_iterators (line 39) | def test_ast_iterators() -> None:

FILE: tests/test_code.py
  function test_python (line 19) | def test_python():
  function show_result_data (line 24) | def show_result_data(show):
  function test_contribute_result (line 37) | def test_contribute_result():
  function test_contribute_context (line 42) | def test_contribute_context():
  function test_contribute_false (line 53) | def test_contribute_false():
  function test_command (line 86) | def test_command():
  function test_command_args (line 94) | def test_command_args():
  function test_jinja1 (line 103) | def test_jinja1():
  function test_jinja2 (line 115) | def test_jinja2():
  function test_jinja3 (line 127) | def test_jinja3():
  function test_jinja4 (line 154) | def test_jinja4():
  function test_pdl1 (line 169) | def test_pdl1():
  function test_pdl2 (line 181) | def test_pdl2():
  function test_pdl3 (line 195) | def test_pdl3():
  function test_pdl4 (line 209) | def test_pdl4():
  function test_lang_casing (line 223) | def test_lang_casing():
  function test_scope1 (line 232) | def test_scope1():
  function test_scope2 (line 245) | def test_scope2():
  function test_scope3 (line 258) | def test_scope3():

FILE: tests/test_cond.py
  function test_bool (line 5) | def test_bool():
  function cond_data1 (line 152) | def cond_data1(show, name):
  function test_cond1 (line 181) | def test_cond1():
  function test_cond2 (line 186) | def test_cond2():
  function test_repeat_until (line 219) | def test_repeat_until():
  function test_repeat_until_array (line 257) | def test_repeat_until_array():
  function test_repeat_until_text (line 287) | def test_repeat_until_text():
  function test_repeat_until_text_with (line 330) | def test_repeat_until_text_with():
  function test_repeat_until_str (line 371) | def test_repeat_until_str():

FILE: tests/test_context.py
  function test_p (line 26) | def test_p():
  function test_p1 (line 36) | def test_p1():

FILE: tests/test_data.py
  function test_int (line 4) | def test_int():
  function test_array (line 12) | def test_array():
  function test_object (line 24) | def test_object():
  function test_expr (line 36) | def test_expr():
  function test_raw (line 51) | def test_raw():
  function test_null (line 67) | def test_null():
  function test_none (line 75) | def test_none():

FILE: tests/test_defaults.py
  function test_default_model_params_empty (line 5) | def test_default_model_params_empty():
  function test_default_model_params_nomatch (line 12) | def test_default_model_params_nomatch():
  function test_default_model_params_exact_match (line 21) | def test_default_model_params_exact_match():
  function test_default_model_params_partial_matches (line 37) | def test_default_model_params_partial_matches():
  function test_default_model_params (line 65) | def test_default_model_params():
  function test_default_not_granite_20b_code_instruct_r1_1 (line 109) | def test_default_not_granite_20b_code_instruct_r1_1():
  function test_default_granite_3_2 (line 118) | def test_default_granite_3_2():

FILE: tests/test_defs.py
  function test_defs (line 29) | def test_defs():
  function test_defs_chain (line 45) | def test_defs_chain():
  function test_defs_only (line 53) | def test_defs_only():

FILE: tests/test_dump.py
  function has_include (line 9) | def has_include(block: BlockType) -> bool:
  function test_dump (line 23) | def test_dump() -> None:
  function test_dump_exclude_internals (line 41) | def test_dump_exclude_internals() -> None:

FILE: tests/test_errors.py
  function error (line 12) | def error(raw_data, assertion):
  function test_error1 (line 34) | def test_error1():
  function test_error2 (line 62) | def test_error2():
  function test_error5 (line 139) | def test_error5():

FILE: tests/test_examples_parse.py
  function test_valid_programs (line 19) | def test_valid_programs(capsys: CaptureFixture[str]) -> None:

FILE: tests/test_examples_run.py
  class InputsType (line 22) | class InputsType:
  class ExecutionErrorCode (line 31) | class ExecutionErrorCode(Enum):
  class ExecutionResult (line 42) | class ExecutionResult:
  class ExpectedResult (line 52) | class ExpectedResult:
    method compare_to_execution (line 61) | def compare_to_execution(self, execution_result: ExecutionResult) -> b...
    method get_next_results_version (line 87) | def get_next_results_version(self) -> int:
  class FailedResults (line 98) | class FailedResults:
  class ExamplesRun (line 110) | class ExamplesRun:
    method __init__ (line 121) | def __init__(self, monkeypatch: MonkeyPatch) -> None:
    method __get_results_dir (line 171) | def __get_results_dir(self) -> pathlib.Path:
    method __collect_expected_results (line 174) | def __collect_expected_results(self) -> None:
    method __execute_and_replay_file (line 204) | def __execute_and_replay_file(self, pdl_file_name: str) -> None:
    method __execute_file (line 231) | def __execute_file(self, pdl_file_path, scope, replay):
    method populate_exec_result_for_checks (line 255) | def populate_exec_result_for_checks(self) -> None:
    method validate_expected_and_actual (line 264) | def validate_expected_and_actual(self) -> None:
    method write_results (line 303) | def write_results(self) -> None:
  function test_example_runs (line 328) | def test_example_runs(capsys: CaptureFixture[str], monkeypatch: MonkeyPa...

FILE: tests/test_expr.py
  function test_arith (line 13) | def test_arith():
  function test_var (line 25) | def test_var():
  function test_true (line 35) | def test_true():
  function test_false (line 45) | def test_false():
  function test_undefined_var (line 53) | def test_undefined_var():
  function test_autoescape (line 61) | def test_autoescape():
  function test_var1 (line 69) | def test_var1():
  function test_var2 (line 80) | def test_var2():
  function test_list (line 91) | def test_list():
  function test_disable_jinja_block (line 102) | def test_disable_jinja_block():
  function test_jinja_block (line 114) | def test_jinja_block():
  function test_expr_detection1 (line 119) | def test_expr_detection1():
  function test_expr_detection2 (line 129) | def test_expr_detection2():
  function test_expr_detection3 (line 139) | def test_expr_detection3():
  function test_expr_detection4 (line 149) | def test_expr_detection4():

FILE: tests/test_fallback.py
  function test_direct_fallback (line 9) | def test_direct_fallback():
  function test_indirect_fallback (line 20) | def test_indirect_fallback():
  function test_error_in_sequence (line 31) | def test_error_in_sequence():
  function test_python_exception (line 36) | def test_python_exception():
  function test_parse_regex_error (line 46) | def test_parse_regex_error():
  function test_type_checking (line 57) | def test_type_checking():
  function test_type_checking_in_fallback (line 67) | def test_type_checking_in_fallback():
  function test_fallback_and_parser (line 81) | def test_fallback_and_parser():

FILE: tests/test_for.py
  function for_data (line 7) | def for_data(loop_kind):
  function test_for_data (line 21) | def test_for_data():
  function for_data1 (line 27) | def for_data1(loop_kind):
  function test_for_data1 (line 39) | def test_for_data1():
  function for_data2 (line 45) | def for_data2(loop_kind):
  function test_for_data2 (line 62) | def test_for_data2():
  function for_data3 (line 68) | def for_data3(loop_kind):
  function test_for_data3 (line 86) | def test_for_data3():
  function for_data4 (line 92) | def for_data4(loop_kind):
  function test_for_data4 (line 106) | def test_for_data4():
  function for_as_text_data4 (line 113) | def for_as_text_data4(loop_kind):
  function test_for_as_text_data4 (line 126) | def test_for_as_text_data4():
  function for_data5 (line 133) | def for_data5(loop_kind):
  function test_for_data5 (line 149) | def test_for_data5():
  function test_for_nested_array (line 156) | def test_for_nested_array():
  function test_for_object (line 174) | def test_for_object():
  function test_for_nested_text (line 196) | def test_for_nested_text():
  function for_scope (line 213) | def for_scope(loop_kind):
  function test_for_scope (line 224) | def test_for_scope():
  function for_index (line 236) | def for_index(loop_kind):
  function test_for_index (line 247) | def test_for_index():
  function for_context (line 253) | def for_context(loop_kind):
  function test_for_context (line 272) | def test_for_context():
  function test_for_reduce (line 370) | def test_for_reduce():
  function test_for_reduce_python (line 389) | def test_for_reduce_python():
  function test_map_max_workers (line 408) | def test_map_max_workers():

FILE: tests/test_function.py
  function test_function_def (line 13) | def test_function_def():
  function test_function_call (line 18) | def test_function_call():
  function test_hello_signature (line 23) | def test_hello_signature():
  function test_function_params (line 50) | def test_function_params():
  function test_hello_params_signature (line 55) | def test_hello_params_signature():
  function test_function_implicit_context (line 83) | def test_function_implicit_context():
  function test_function_explicit_context (line 101) | def test_function_explicit_context():
  function test_call_template (line 122) | def test_call_template():
  function test_call_expression_args (line 127) | def test_call_expression_args():
  function test_call_from_code_01 (line 135) | def test_call_from_code_01():
  function test_call_from_code_02 (line 158) | def test_call_from_code_02():
  function test_call_from_code_03 (line 183) | def test_call_from_code_03():
  function test_call_from_code_04 (line 210) | def test_call_from_code_04():
  function test_call_from_code_05 (line 243) | def test_call_from_code_05():
  function test_call_from_code_06 (line 266) | def test_call_from_code_06():
  function test_call_from_code_07 (line 283) | def test_call_from_code_07():
  function test_call_from_code_08 (line 298) | def test_call_from_code_08():
  function test_call_from_code_09 (line 325) | def test_call_from_code_09():
  function test_call_from_code_10 (line 352) | def test_call_from_code_10():

FILE: tests/test_include.py
  function test_include (line 15) | def test_include():
  function test_biz (line 44) | def test_biz():

FILE: tests/test_independent.py
  function test_independent_data (line 22) | def test_independent_data():
  function test_for_data (line 51) | def test_for_data():
  function test_for_dependent_data (line 75) | def test_for_dependent_data():
  function test_lastof_independent_data (line 104) | def test_lastof_independent_data():
  function test_array_independent_data (line 141) | def test_array_independent_data():
  function test_object_independent_data (line 171) | def test_object_independent_data():

FILE: tests/test_input.py
  function test_input_json (line 33) | def test_input_json():
  function test_input_json_defs (line 49) | def test_input_json_defs():
  function test_input_json_defs1 (line 65) | def test_input_json_defs1():

FILE: tests/test_lib_version.py
  function test_version (line 6) | def test_version():

FILE: tests/test_line_table.py
  function do_test (line 6) | def do_test(t, capsys):
  function test_line (line 26) | def test_line(capsys: CaptureFixture[str]):
  function test_line1 (line 39) | def test_line1(capsys: CaptureFixture[str]):
  function test_line3 (line 53) | def test_line3(capsys: CaptureFixture[str]):
  function test_line4 (line 67) | def test_line4(capsys: CaptureFixture[str]):
  function test_line7 (line 80) | def test_line7(capsys: CaptureFixture[str]):
  function test_line8 (line 94) | def test_line8(capsys: CaptureFixture[str]):
  function test_line9 (line 108) | def test_line9(capsys: CaptureFixture[str]):
  function test_line10 (line 121) | def test_line10(capsys: CaptureFixture[str]):
  function test_line11 (line 134) | def test_line11(capsys: CaptureFixture[str]):
  function test_line12 (line 148) | def test_line12(capsys: CaptureFixture[str]):
  function test_line13 (line 162) | def test_line13(capsys: CaptureFixture[str]):
  function test_line14 (line 176) | def test_line14(capsys: CaptureFixture[str]):
  function test_line15 (line 189) | def test_line15(capsys: CaptureFixture[str]):
  function test_line16 (line 203) | def test_line16(capsys: CaptureFixture[str]):
  function test_line17 (line 217) | def test_line17(capsys: CaptureFixture[str]):
  function test_line18 (line 230) | def test_line18(capsys: CaptureFixture[str]):
  function test_line19 (line 245) | def test_line19(capsys: CaptureFixture[str]):
  function test_line20 (line 258) | def test_line20(capsys: CaptureFixture[str]):
  function test_line21 (line 271) | def test_line21(capsys: CaptureFixture[str]):
  function test_line22 (line 284) | def test_line22(capsys: CaptureFixture[str]):
  function test_line23 (line 297) | def test_line23(capsys: CaptureFixture[str]):
  function test_line24 (line 310) | def test_line24(capsys: CaptureFixture[str]):
  function test_line26 (line 338) | def test_line26(capsys: CaptureFixture[str]):
  function test_line27 (line 351) | def test_line27(capsys: CaptureFixture[str]):
  function test_line28 (line 364) | def test_line28(capsys: CaptureFixture[str]):
  function test_line29 (line 377) | def test_line29(capsys: CaptureFixture[str]):
  function test_line30 (line 390) | def test_line30(capsys: CaptureFixture[str]):
  function test_line31 (line 405) | def test_line31(capsys: CaptureFixture[str]):
  function test_line32 (line 419) | def test_line32(capsys: CaptureFixture[str]):

FILE: tests/test_linter.py
  class ChangeDir (line 30) | class ChangeDir:
    method __init__ (line 33) | def __init__(self, path: Path):
    method __enter__ (line 37) | def __enter__(self):
    method __exit__ (line 41) | def __exit__(self, _exc_type, _exc_value, _traceback):
  function temp_dir (line 46) | def temp_dir():
  function project_root (line 53) | def project_root(temp_dir):  # pylint: disable=redefined-outer-name
  function pdl_file (line 67) | def pdl_file(project_root):  # pylint: disable=redefined-outer-name
  function invalid_pdl_file (line 75) | def invalid_pdl_file(project_root):  # pylint: disable=redefined-outer-name
  function mock_parse_side_effect (line 83) | def mock_parse_side_effect(file_path):
  function mock_parse_pdl_file (line 93) | def mock_parse_pdl_file(side_effect=mock_parse_side_effect):
  function test_guess_project_root_dir_from_project_root (line 98) | def test_guess_project_root_dir_from_project_root(
  function test_guess_project_root_dir_from_subdir (line 107) | def test_guess_project_root_dir_from_subdir(
  function test_linter_config_validation (line 117) | def test_linter_config_validation():
  function test_linter_config_ignore_paths (line 128) | def test_linter_config_ignore_paths(
  function test_lint_pdl_file_valid (line 168) | def test_lint_pdl_file_valid(
  function test_lint_pdl_file_invalid (line 178) | def test_lint_pdl_file_invalid(
  function test_lint_pdl_file_nonexistent (line 190) | def test_lint_pdl_file_nonexistent(
  function test_lint_pdl_files_in_directory (line 203) | def test_lint_pdl_files_in_directory(
  function test_linter_configuration_loading (line 238) | def test_linter_configuration_loading(
  function test_run_linter (line 273) | def test_run_linter(
  function test_logging_configuration (line 338) | def test_logging_configuration(project_root):  # pylint: disable=redefin...
  function test_linter_with_extra_config_fields (line 358) | def test_linter_with_extra_config_fields(
  function test_guess_project_root_dir_hg (line 373) | def test_guess_project_root_dir_hg(temp_dir):  # pylint: disable=redefin...
  function test_guess_project_root_dir_git (line 383) | def test_guess_project_root_dir_git(temp_dir):  # pylint: disable=redefi...
  function test_guess_project_root_dir_requirements (line 392) | def test_guess_project_root_dir_requirements(
  function test_guess_project_root_dir_pyproject (line 403) | def test_guess_project_root_dir_pyproject(
  function test_guess_project_root_dir_setup_py (line 415) | def test_guess_project_root_dir_setup_py(
  function test_guess_project_root_dir_multiple_weak_indicators (line 427) | def test_guess_project_root_dir_multiple_weak_indicators(
  function test_guess_project_root_dir_no_indicators (line 443) | def test_guess_project_root_dir_no_indicators(
  function test_linter_config_post_init_warnings (line 454) | def test_linter_config_post_init_warnings(
  function test_linter_config_load_variations (line 488) | def test_linter_config_load_variations(
  function test_lint_pdl_file_generic_exception (line 541) | def test_lint_pdl_file_generic_exception(
  function test_lint_pdl_files_in_directory_no_pdl (line 560) | def test_lint_pdl_files_in_directory_no_pdl(
  function test_arg_parser_defaults_and_flags (line 578) | def test_arg_parser_defaults_and_flags():
  function test_setup_logging_levels_and_handlers (line 618) | def test_setup_logging_levels_and_handlers(
  function test_run_linter_multiple_paths (line 680) | def test_run_linter_multiple_paths(
  function test_run_linter_invalid_path_arg (line 722) | def test_run_linter_invalid_path_arg(
  function check_logs (line 751) | def check_logs(caplog, level, message_part):

FILE: tests/test_match.py
  function test_match0 (line 7) | def test_match0():
  function test_match1 (line 20) | def test_match1():
  function test_match_fail (line 33) | def test_match_fail():
  function test_match_if0 (line 46) | def test_match_if0():
  function test_match_if1 (line 61) | def test_match_if1():
  function test_match_if_fail (line 76) | def test_match_if_fail():
  function test_match_case_if1 (line 91) | def test_match_case_if1():
  function test_match_case_if2 (line 108) | def test_match_case_if2():
  function test_match_case_if3 (line 127) | def test_match_case_if3():
  function test_match_case_if4 (line 148) | def test_match_case_if4():
  function test_match_case_if5 (line 169) | def test_match_case_if5():
  function test_match_expr0 (line 189) | def test_match_expr0():
  function test_match_expr_in_case1 (line 204) | def test_match_expr_in_case1():
  function test_match_expr_in_case2 (line 219) | def test_match_expr_in_case2():
  function test_match_null0 (line 236) | def test_match_null0():
  function test_match_null1 (line 249) | def test_match_null1():
  function test_match_array0 (line 262) | def test_match_array0():
  function test_match_array1 (line 295) | def test_match_array1():
  function test_match_object0 (line 321) | def test_match_object0():
  function test_match_object1 (line 344) | def test_match_object1():
  function test_match_object2 (line 367) | def test_match_object2():
  function test_match_object3 (line 393) | def test_match_object3():
  function test_any0 (line 435) | def test_any0():
  function test_or0 (line 451) | def test_or0():
  function test_match_or1 (line 472) | def test_match_or1():
  function test_match_or2 (line 497) | def test_match_or2():
  function test_match_or3 (line 530) | def test_match_or3():
  function test_match_catch_all (line 563) | def test_match_catch_all():

FILE: tests/test_messages.py
  function test_message1 (line 5) | def test_message1():
  function test_message2 (line 45) | def test_message2():
  function test_message3 (line 72) | def test_message3():
  function test_message4 (line 96) | def test_message4():
  function test_messages5 (line 121) | def test_messages5():
  function test_messages6 (line 152) | def test_messages6():

FILE: tests/test_model.py
  function test_model (line 20) | def test_model():
  function test_model_chain (line 67) | def test_model_chain():
  function test_multi_shot (line 107) | def test_multi_shot():
  function test_data_missing_parameters (line 127) | def test_data_missing_parameters():
  function test_model_parameter (line 148) | def test_model_parameter():
  function test_model_parameter1 (line 166) | def test_model_parameter1():
  function test_litellm_mock (line 184) | def test_litellm_mock():

FILE: tests/test_object.py
  function test_direct_object (line 4) | def test_direct_object():
  function test_composed_object (line 18) | def test_composed_object():

FILE: tests/test_optimizer.py
  function test_gsm8k_cot (line 20) | def test_gsm8k_cot():
  function run_optimizer_gsm8k (line 387) | def run_optimizer_gsm8k(pattern, num_demonstrations=0):
  function run_optimizer_fever (line 743) | def run_optimizer_fever(pattern, num_demonstrations=0):
  function run_optimizer_mbpp (line 1113) | def run_optimizer_mbpp(pattern, num_demonstrations=0):
  function test_gsm8k_zeroshot_cot (line 1163) | def test_gsm8k_zeroshot_cot():
  function test_gsm8k_fiveshot_react (line 1168) | def test_gsm8k_fiveshot_react():
  function test_gsm8k_fiveshot_rewoo (line 1173) | def test_gsm8k_fiveshot_rewoo():
  function test_fever_zeroshot_cot (line 1178) | def test_fever_zeroshot_cot():
  function test_fever_fiveshot_react (line 1183) | def test_fever_fiveshot_react():
  function test_fever_zeroshot_rewoo (line 1188) | def test_fever_zeroshot_rewoo():
  function test_mbpp_zeroshot_cot (line 1193) | def test_mbpp_zeroshot_cot():
  function test_mbpp_zeroshot_react (line 1198) | def test_mbpp_zeroshot_react():

FILE: tests/test_parse.py
  function test_model (line 13) | def test_model():

FILE: tests/test_parser.py
  function test_model_parser (line 29) | def test_model_parser():
  function test_model_parser1 (line 51) | def test_model_parser1():
  function test_get_parser (line 59) | def test_get_parser():
  function test_code_parser (line 81) | def test_code_parser():
  function test_code_parser1 (line 92) | def test_code_parser1():
  function test_json_parser (line 97) | def test_json_parser():
  function test_jsonl_parser (line 120) | def test_jsonl_parser():
  function test_regex_findall (line 132) | def test_regex_findall():
  function test_regex_split (line 144) | def test_regex_split():
  function test_parser_case1 (line 155) | def test_parser_case1():
  function test_parser_case2 (line 165) | def test_parser_case2():
  function test_parser_csv (line 177) | def test_parser_csv():

FILE: tests/test_repeat.py
  function repeat_data (line 14) | def repeat_data(n):
  function nested_repeat_data (line 27) | def nested_repeat_data(n):
  function test_hello (line 41) | def test_hello():
  function test_hello_json (line 46) | def test_hello_json():
  function repeat (line 51) | def repeat(n):
  function test_repeat_neg (line 60) | def test_repeat_neg():
  function test_repeat0 (line 64) | def test_repeat0():
  function test_repeat1 (line 68) | def test_repeat1():
  function test_repeat2 (line 72) | def test_repeat2():
  function test_repeat3 (line 76) | def test_repeat3():
  function repeat_nested (line 80) | def repeat_nested(n):
  function test_repeat_nested0 (line 88) | def test_repeat_nested0():
  function test_repeat_nested1 (line 92) | def test_repeat_nested1():
  function test_repeat_nested2 (line 96) | def test_repeat_nested2():
  function test_repeat_nested3 (line 100) | def test_repeat_nested3():
  function test_repeat_error (line 117) | def test_repeat_error():
  function test_program_as_list (line 122) | def test_program_as_list():
  function _while_prog (line 132) | def _while_prog(n):
  function test_while1 (line 144) | def test_while1():
  function test_while2 (line 150) | def test_while2():
  function _for_max_iterations_prog (line 156) | def _for_max_iterations_prog(n):
  function test_for_max_iterations1 (line 165) | def test_for_max_iterations1():
  function test_for_max_iterations2 (line 171) | def test_for_max_iterations2():
  function _for_max_iterations_index_prog (line 177) | def _for_max_iterations_index_prog(n):
  function test_for_max_iterations_index1 (line 185) | def test_for_max_iterations_index1():
  function _for_until_prog (line 191) | def _for_until_prog(n):
  function test_for_until1 (line 200) | def test_for_until1():
  function test_for_until2 (line 206) | def test_for_until2():
  function _for_until_max_iterations_prog (line 212) | def _for_until_max_iterations_prog(n, m):
  function test_for_until_max_iterations1 (line 222) | def test_for_until_max_iterations1():
  function test_for_until_max_iterations2 (line 228) | def test_for_until_max_iterations2():
  function test_for_until_max_iterations3 (line 234) | def test_for_until_max_iterations3():

FILE: tests/test_retry.py
  function repeat_retry_data (line 7) | def repeat_retry_data(n: int):
  function repeat_retry (line 30) | def repeat_retry(n: int, should_be_no_error: bool = False):
  function test_repeat_retry_negative (line 46) | def test_repeat_retry_negative():
  function test_repeat_retry0 (line 50) | def test_repeat_retry0():
  function test_repeat_retry1 (line 54) | def test_repeat_retry1():
  function test_repeat_retry2 (line 58) | def test_repeat_retry2():
  function test_repeat_retry3 (line 62) | def test_repeat_retry3():
  function code_retry_data (line 66) | def code_retry_data(n: int):
  function code_retry (line 84) | def code_retry(n: int, should_be_no_error: bool = False):
  function test_code_retry_negative (line 99) | def test_code_retry_negative():
  function test_code_retry0 (line 103) | def test_code_retry0():
  function test_code_retry1 (line 107) | def test_code_retry1():
  function test_code_retry2 (line 111) | def test_code_retry2():
  function test_code_retry3 (line 115) | def test_code_retry3():

FILE: tests/test_role.py
  function test_role0 (line 5) | def test_role0():
  function test_role1 (line 17) | def test_role1():
  function test_role2 (line 30) | def test_role2():
  function test_role3 (line 44) | def test_role3():

FILE: tests/test_runtime_errors.py
  function test_jinja_undefined (line 7) | def test_jinja_undefined():
  function test_jinja_access (line 19) | def test_jinja_access():
  function test_jinja_syntax (line 31) | def test_jinja_syntax():
  function test_parser_jsonl (line 43) | def test_parser_jsonl():
  function test_parser_regex (line 56) | def test_parser_regex():
  function test_type_result (line 73) | def test_type_result():
  function test_get (line 86) | def test_get():
  function test_call_undefined (line 100) | def test_call_undefined():
  function test_call_bad_name (line 112) | def test_call_bad_name():
  function test_call_bad_args (line 124) | def test_call_bad_args():

FILE: tests/test_schema.py
  function test_saved_schema (line 10) | def test_saved_schema():

FILE: tests/test_secrets_redaction.py
  class TestRedactSecrets (line 11) | class TestRedactSecrets:
    method test_redact_simple_string (line 14) | def test_redact_simple_string(self):
    method test_redact_multiple_secrets (line 20) | def test_redact_multiple_secrets(self):
    method test_redact_nested_dict (line 26) | def test_redact_nested_dict(self):
    method test_redact_list (line 39) | def test_redact_list(self):
    method test_redact_mixed_structure (line 45) | def test_redact_mixed_structure(self):
    method test_empty_secrets_list (line 58) | def test_empty_secrets_list(self):
    method test_no_matching_secrets (line 64) | def test_no_matching_secrets(self):
    method test_case_sensitive (line 70) | def test_case_sensitive(self):
    method test_primitives_unchanged (line 76) | def test_primitives_unchanged(self):
    method test_partial_match_in_string (line 83) | def test_partial_match_in_string(self):
    method test_multiple_occurrences (line 89) | def test_multiple_occurrences(self):
  class TestWriteTrace (line 96) | class TestWriteTrace:
    method test_write_trace_without_secrets (line 99) | def test_write_trace_without_secrets(self):
    method test_write_trace_with_secrets (line 116) | def test_write_trace_with_secrets(self):
    method test_write_trace_backward_compatibility (line 135) | def test_write_trace_backward_compatibility(self):
    method test_write_trace_with_empty_secrets (line 149) | def test_write_trace_with_empty_secrets(self):
    method test_write_trace_with_none_secrets (line 167) | def test_write_trace_with_none_secrets(self):

FILE: tests/test_sequence.py
  function test_sequence_text1 (line 4) | def test_sequence_text1():
  function test_sequence_text2 (line 16) | def test_sequence_text2():
  function test_sequence_text3 (line 29) | def test_sequence_text3():
  function test_sequence_array1 (line 42) | def test_sequence_array1():
  function test_sequence_join1 (line 54) | def test_sequence_join1():

FILE: tests/test_type_checking.py
  function test_pdltype_to_jsonschema (line 166) | def test_pdltype_to_jsonschema():
  function test_function_call (line 194) | def test_function_call():
  function test_function_call1 (line 213) | def test_function_call1():
  function test_function_call2 (line 232) | def test_function_call2():
  function test_function_call3 (line 251) | def test_function_call3():
  function test_function_call4 (line 270) | def test_function_call4():
  function test_function_call5 (line 289) | def test_function_call5():
  function test_function_call6 (line 308) | def test_function_call6():
  function test_function_call7 (line 327) | def test_function_call7():
  function test_function_call8 (line 346) | def test_function_call8():
  function test_function_call9 (line 365) | def test_function_call9():
  function test_function_call10 (line 387) | def test_function_call10():
  function test_function_call11 (line 409) | def test_function_call11():
  function test_function_call12 (line 428) | def test_function_call12():
  function test_function_call13 (line 447) | def test_function_call13():
  function test_function_call14 (line 466) | def test_function_call14():
  function test_function_call15 (line 486) | def test_function_call15():
  function test_function_call16 (line 506) | def test_function_call16():
  function test_function_call17 (line 526) | def test_function_call17():
  function test_function_call18 (line 546) | def test_function_call18():
  function test_hello (line 558) | def test_hello():
  function test_hello1 (line 570) | def test_hello1():
  function test_hello2 (line 587) | def test_hello2():
  function do_test_stderr (line 592) | def do_test_stderr(capsys, prog, err):
  function test_deprecated (line 600) | def test_deprecated(capsys: pytest.CaptureFixture[str]):

FILE: tests/test_var.py
  function test_var (line 32) | def test_var():
  function test_code_shared_scope (line 65) | def test_code_shared_scope():
  function test_code_shared_scope_no_mutate (line 91) | def test_code_shared_scope_no_mutate():
  function test_code_var (line 112) | def test_code_var():
  function test_missing_var (line 129) | def test_missing_var():
  function test_missing_call (line 140) | def test_missing_call():
Condensed preview — 1057 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (6,707K chars).
[
  {
    "path": ".flake8",
    "chars": 89,
    "preview": "[flake8]\n    max-line-length = 89\n    max-complexity = 18\n    extend-ignore = E203, E501\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/bug_report.md",
    "chars": 585,
    "preview": "---\nname: Bug report\nabout: Create a report to help us improve\ntitle: ''\nlabels: bug\nassignees: ''\n\n---\n\n**Describe the "
  },
  {
    "path": ".github/ISSUE_TEMPLATE/feature_request.md",
    "chars": 600,
    "preview": "---\nname: Feature request\nabout: Suggest an idea for this project\ntitle: ''\nlabels: feature\nassignees: ''\n\n---\n\n**Is you"
  },
  {
    "path": ".github/actions/ollama/action.yml",
    "chars": 1821,
    "preview": "name: 'Ollama Setup'\ndescription: 'Composte action for Ollama set up in GH environment'\nruns:\n  using: 'composite'\n  ste"
  },
  {
    "path": ".github/actions/run-examples/action.yml",
    "chars": 3545,
    "preview": "name: 'Ollama Setup'\ndescription: 'Composte action to set up Run Examples'\ninputs:\n  python-version:\n    description: 'P"
  },
  {
    "path": ".github/dependabot.yml",
    "chars": 655,
    "preview": "# To get started with Dependabot version updates, you'll need to specify which\n# package ecosystems to update and where "
  },
  {
    "path": ".github/workflows/build.yml",
    "chars": 1639,
    "preview": "---\nname: Build\n\non: [push, pull_request]\n\n# cancel any prior runs for this workflow and this PR (or branch)\nconcurrency"
  },
  {
    "path": ".github/workflows/mkdocs-gh-pages.yml",
    "chars": 1933,
    "preview": "# Workflow for building and deploying a MkDocs site to GitHub Pages\nname: Build Docs & Deploy to Pages\n\non:\n  # Runs on "
  },
  {
    "path": ".github/workflows/pdl-live-react-tests.yml",
    "chars": 919,
    "preview": "name: Viewer Tests\n\non:\n  push:\n    branches: [ main ]\n  pull_request:\n    branches: [ main ]\n\n# cancel any prior runs f"
  },
  {
    "path": ".github/workflows/publish-quay.yaml",
    "chars": 1184,
    "preview": "name: Quay Publish\n\non:\n  release:\n    types: [published]\n\npermissions:\n  contents: read\n\nenv:\n  REGISTRY: quay.io\n  # g"
  },
  {
    "path": ".github/workflows/release-static-web-app.yml",
    "chars": 1654,
    "preview": "name: 'Publish ui to static web site'\n\non:\n  release:\n    types:\n      - released\n  workflow_dispatch:\n\n# This workflow "
  },
  {
    "path": ".github/workflows/release-ui.yml",
    "chars": 3584,
    "preview": "name: 'Publish ui to GitHub release'\n\non:\n  release:\n    types:\n      - released\n  workflow_dispatch:\n\n# This workflow w"
  },
  {
    "path": ".github/workflows/release.yml",
    "chars": 3438,
    "preview": "---\nname: Publish prompt-declaration-language to PyPI and TestPyPI\n\non:\n  # push:\n  #   branches:\n  #     - \"main\"\n  rel"
  },
  {
    "path": ".github/workflows/run-examples-prep.yml",
    "chars": 1652,
    "preview": "---\nname: Run examples on modified PDL files\non: [pull_request]\njobs:\n  tests:\n    name: Execution tests\n    runs-on: ub"
  },
  {
    "path": ".github/workflows/run-examples.yml",
    "chars": 748,
    "preview": "---\nname: Run examples\n\non:\n  schedule:\n    - cron:  '0 1 * * *'\n  workflow_dispatch:\n\njobs:\n  tests:\n    name: Executio"
  },
  {
    "path": ".github/workflows/rust-interpreter.yml",
    "chars": 1150,
    "preview": "name: Rust Interpreter Tests\n\non:\n  push:\n    branches: [ main ]\n  pull_request:\n    branches: [ main ]\n  workflow_dispa"
  },
  {
    "path": ".github/workflows/tauri-cli.yml",
    "chars": 2759,
    "preview": "name: Tauri CLI Tests\n\non:\n  push:\n    branches: [ main ]\n  pull_request:\n    branches: [ main ]\n\n# cancel any prior run"
  },
  {
    "path": ".gitignore",
    "chars": 2204,
    "preview": "# Byte-compiled / optimized / DLL files\n__pycache__/\n*.py[cod]\n*$py.class\n\n# C extensions\n*.so\n\n# Distribution / packagi"
  },
  {
    "path": ".pre-commit-config.yaml",
    "chars": 1980,
    "preview": "---\ndefault_language_version:\n  python: python3\n  node: system\nrepos:\n  # check some basic stuff\n  - repo: https://githu"
  },
  {
    "path": ".vscode/launch.json",
    "chars": 1170,
    "preview": "{\n    // Use IntelliSense to learn about possible attributes.\n    // Hover to view descriptions of existing attributes.\n"
  },
  {
    "path": ".vscode/settings.json",
    "chars": 278,
    "preview": "{\n    \"yaml.schemas\": {\n        \"./src/pdl/pdl-schema.json\": \"*.pdl\"\n    },\n    \"files.associations\": {\n        \"*.pdl\":"
  },
  {
    "path": "LICENSE",
    "chars": 11354,
    "preview": "                              Apache License\n                           Version 2.0, January 2004\n                      "
  },
  {
    "path": "README.md",
    "chars": 8492,
    "preview": "# PDL (Prompt Declaration Language)\n\n[![tests](https://github.com/IBM/prompt-declaration-language/actions/workflows/buil"
  },
  {
    "path": "bandit.yaml",
    "chars": 279,
    "preview": "---\n# This is the configuration file for the bandit python static analysis tool\nexclude_dirs:\n  - build\n# We are less wo"
  },
  {
    "path": "contrib/prompt_library/CoT.pdl",
    "chars": 1383,
    "preview": "description: CoT pattern introduced by Wei et al. (2022)\ndefs:\n  # Chain of Thought\n  cot_block:\n    function:\n      que"
  },
  {
    "path": "contrib/prompt_library/ProbReAct.pdl",
    "chars": 4705,
    "preview": "description: ReAct pattern from Yao et al., [ICLR 2023](https://openreview.net/forum?id=WE_vluYUL-X)\n# See alternative i"
  },
  {
    "path": "contrib/prompt_library/ReAct.pdl",
    "chars": 4435,
    "preview": "description: ReAct pattern from Yao et al., [ICLR 2023](https://openreview.net/forum?id=WE_vluYUL-X)\n# See alternative i"
  },
  {
    "path": "contrib/prompt_library/ReWoo.pdl",
    "chars": 5961,
    "preview": "description: ReWOO (Reasoning without observation) pattern from Xu et al., (http://arxiv.org/abs/2305.18323)\n# Compared "
  },
  {
    "path": "contrib/prompt_library/tools.pdl",
    "chars": 3112,
    "preview": "description: Toolbox of PDL functions for agents\ndefs:\n  # Note: Although PDL functions can be properly typed,\n  # the i"
  },
  {
    "path": "dockerfile",
    "chars": 170,
    "preview": "FROM python:3.14-slim\n\nWORKDIR /pdl\n\nRUN apt-get update && apt-get install -y git\n\nCOPY . /pdl\n\nRUN pip install prompt-d"
  },
  {
    "path": "docs/.nojekyll",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "docs/README.md",
    "chars": 19387,
    "preview": "<!-- ---\nhide:\n  - navigation\n  - toc\n--- -->\n# Prompt Declaration Language\n\nLLMs will continue to change the way we bui"
  },
  {
    "path": "docs/api_reference.md",
    "chars": 469,
    "preview": "# API Reference\n\nThis page documents the PDL members that likely to be used to run PDL programs from Python.\n\n## Program"
  },
  {
    "path": "docs/autopdl.md",
    "chars": 7251,
    "preview": "---\nhide:\n  - navigation\n  - toc\n  - footer\n---\n\n# AutoPDL Tutorial\n\nThis tutorial describes how to use AutoPDL, PDL's p"
  },
  {
    "path": "docs/contrib.md",
    "chars": 6389,
    "preview": "# Contributing to PDL\n\nYou can report issues or open a pull request (PR) to suggest changes.\n\n## Reporting an issue\n\nTo "
  },
  {
    "path": "docs/css/index.css",
    "chars": 201,
    "preview": "html,body {\n    font-family: 'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif;\n    background: var(--cds-background,"
  },
  {
    "path": "docs/stylesheets/extra.css",
    "chars": 140,
    "preview": ":root {\n    --md-primary-fg-color:        #0f62fe;\n    --md-primary-fg-color--light: #4589ff;\n    --md-primary-fg-color-"
  },
  {
    "path": "docs/telemetry.md",
    "chars": 1757,
    "preview": "\n\n# Gathering telemetry for PDL programs\n\nPDL includes experimental support for gathering trace telemetry.  This can\nbe "
  },
  {
    "path": "docs/tutorial.md",
    "chars": 62690,
    "preview": "\n# PDL Language Tutorial\n\nThe following sections give a step-by-step overview of PDL language features.\nAll the examples"
  },
  {
    "path": "docs/viewer.md",
    "chars": 380,
    "preview": "---\nhide:\n  - navigation\n  - toc\n  - footer\n---\n\n<style>\n.md-typeset {\n  margin: 0;\n  padding: 0;\n}\n.md-grid {margin-top"
  },
  {
    "path": "examples/aggregators/contribute_in_file.pdl",
    "chars": 371,
    "preview": "defs:\n  log:\n    aggregator: \n      file: /tmp/log.txt\ntext:\n- Hello\n- model: ollama_chat/granite4:micro\n  parameters:\n "
  },
  {
    "path": "examples/aggregators/contribute_in_stderr.pdl",
    "chars": 194,
    "preview": "text:\n- Hello\n- text: Before model call\n  contribute: [ stderr ]\n- model: ollama_chat/granite4:micro\n  parameters:\n    t"
  },
  {
    "path": "examples/aggregators/contribute_in_stdout.pdl",
    "chars": 194,
    "preview": "text:\n- Hello\n- text: Before model call\n  contribute: [ stdout ]\n- model: ollama_chat/granite4:micro\n  parameters:\n    t"
  },
  {
    "path": "examples/callback/README.md",
    "chars": 753,
    "preview": "# Callback example\n\nThis example shows a Python program `repair_main.py` that calls a PDL program `repair_prompt.pdl` th"
  },
  {
    "path": "examples/callback/repair_main.py",
    "chars": 1240,
    "preview": "import re\nfrom typing import TypedDict, cast\n\nimport pdl.pdl\n\nPDLScope = TypedDict(\"PDLScope\", {\"code_line\": str, \"error"
  },
  {
    "path": "examples/callback/repair_prompt.pdl",
    "chars": 581,
    "preview": "lastOf:\n- |\n  Given the following code:\n  ```python\n  ${code_line}\n  ```\n  and the following error:\n  ${error_msg}\n  Ple"
  },
  {
    "path": "examples/chatbot/chatbot.pdl",
    "chars": 855,
    "preview": "description: A Chatbot that responds to user's questions\ntext:\n# Allow the user to type any question, implicitly adding "
  },
  {
    "path": "examples/cldk/README.md",
    "chars": 658,
    "preview": "The PDL program `cldk-assistant.pdl` makes use of the [CLDK](https://github.com/IBM/codellm-devkit) toolkit to analyze a"
  },
  {
    "path": "examples/cldk/cldk-assistant.pdl",
    "chars": 5003,
    "preview": "description: CodeLLM-Devkit Assistant\ntext:\n- read:\n  def: project\n  message: \"Please enter the path to your Java projec"
  },
  {
    "path": "examples/demo/1-hello.pdl",
    "chars": 110,
    "preview": "description: Model call\ntext:\n- \"Hello\\n\"\n- model: ollama_chat/granite4:micro\n  parameters:\n    stop: [\"!\"]\n\n\n"
  },
  {
    "path": "examples/demo/10-sdg.pdl",
    "chars": 16549,
    "preview": "defs:\n  teacher_sys_prompt: You are a very knowledgeable AI Assistant that will faithfully assist the user with their ta"
  },
  {
    "path": "examples/demo/11-repeat.pdl",
    "chars": 306,
    "preview": "description: Loop semantics\ndefs:\n  numbers: \n    data: [1, 2, 3, 4]\n  names: \n    data: [\"Bob\", \"Carol\", \"David\", \"Erne"
  },
  {
    "path": "examples/demo/2-model-chaining.pdl",
    "chars": 210,
    "preview": "description: Model chaining\ntext:\n- \"Hello\\n\"\n- model: ollama_chat/granite4:micro\n  parameters:\n    stop: [\"!\"]\n- \"\\nDid"
  },
  {
    "path": "examples/demo/3-def-use.pdl",
    "chars": 295,
    "preview": "description: Variable def and use, model input\ntext:\n- \"Hello\\n\"\n- model: ollama_chat/granite4:micro\n  def: name\n  param"
  },
  {
    "path": "examples/demo/4-function.pdl",
    "chars": 474,
    "preview": "description: Function def and call\ntext:\n- def: translate\n  function:\n    sentence: string\n    language: string\n  return"
  },
  {
    "path": "examples/demo/5-code-eval.pdl",
    "chars": 1439,
    "preview": "description: Code explanation example\ndefs:\n  # The variable `CODE` shall be the contents of the parsed YAML file\n  CODE"
  },
  {
    "path": "examples/demo/6-code-json.pdl",
    "chars": 932,
    "preview": "description: Code explanation example\ndefs:\n  CODE:\n    read: ./data.yaml\n    parser: yaml\n  TRUTH:\n    read: ./ground_t"
  },
  {
    "path": "examples/demo/7-chatbot-roles.pdl",
    "chars": 434,
    "preview": "description: Chatbot, control structures, roles, contribute\ntext:\n- role: system\n  contribute: [context]\n  text: You are"
  },
  {
    "path": "examples/demo/8-tools.pdl",
    "chars": 1017,
    "preview": "description: Tool use\ndefs:\n  tools:\n    data:\n    - name: calc\n      description: Calculator function\n      arguments:\n"
  },
  {
    "path": "examples/demo/9-react.pdl",
    "chars": 4266,
    "preview": "description: Demonstrating a React program\ndefs:\n  problem: |\n    How many years ago was the discoverer of the Hudson Ri"
  },
  {
    "path": "examples/demo/data.yaml",
    "chars": 565,
    "preview": "source_code: \n  |\n  @SuppressWarnings(\"unchecked\")\n  public static Map<String, String> deserializeOffsetMap(String lastS"
  },
  {
    "path": "examples/demo/ground_truth.txt",
    "chars": 615,
    "preview": "The function `deserializeOffsetMap` takes a string as input and returns a map. It first checks if the input string is nu"
  },
  {
    "path": "examples/demo/qna.yaml",
    "chars": 454,
    "preview": "task_description: to teach a large language model to come up with puns\ncreated_by: mizmo\nseed_examples:\n- question: Tell"
  },
  {
    "path": "examples/demos/granite_io_hallucinations.pdl",
    "chars": 3703,
    "preview": "description: GraniteIO hallucination example\ndefs:\n  doc:\n    data:\n      text: |\n        Audrey Faith McGraw (born Sept"
  },
  {
    "path": "examples/demos/react.pdl",
    "chars": 4266,
    "preview": "description: Demonstrating a React program\ndefs:\n  problem: |\n    How many years ago was the discoverer of the Hudson Ri"
  },
  {
    "path": "examples/demos/repair_main.py",
    "chars": 1253,
    "preview": "import re\nfrom typing import TypedDict, cast\n\nimport pdl.pdl\n\nPDLScope = TypedDict(\"PDLScope\", {\"code_line\": str, \"error"
  },
  {
    "path": "examples/demos/repair_prompt.pdl",
    "chars": 581,
    "preview": "lastOf:\n- |\n  Given the following code:\n  ```python\n  ${code_line}\n  ```\n  and the following error:\n  ${error_msg}\n  Ple"
  },
  {
    "path": "examples/expectations/email.pdl",
    "chars": 1230,
    "preview": "description: Hello world calling a model\ndefs:\n  feedback: \n    function:\n      expectation: string\n      response: stri"
  },
  {
    "path": "examples/expectations/gsm8k_short.pdl",
    "chars": 906,
    "preview": "defs:\n  problem: |+\n    Carla is downloading a 200 GB file. Normally she can download 2 GB/minute, \n    but 40% of the w"
  },
  {
    "path": "examples/expectations/mbpp.pdl",
    "chars": 3715,
    "preview": "defs:\n  pdl_llm_as_judge: watsonx/ibm/granite-4-h-small\n  pdl_llm_context_transformer: watsonx/ibm/granite-4-h-small\n  m"
  },
  {
    "path": "examples/fibonacci/fib.pdl",
    "chars": 1473,
    "preview": "# Demonstrate using an LLM to write a program to compute Fibonacci numbers,\n# and invoke generated code with a random nu"
  },
  {
    "path": "examples/granite-io/granite_io_hallucinations.pdl",
    "chars": 3703,
    "preview": "description: GraniteIO hallucination example\ndefs:\n  doc:\n    data:\n      text: |\n        Audrey Faith McGraw (born Sept"
  },
  {
    "path": "examples/granite-io/granite_io_object.pdl",
    "chars": 377,
    "preview": "defs:\n  io_proc:\n    lang: python\n    code: |\n      from granite_io import make_backend, make_io_processor\n      model_n"
  },
  {
    "path": "examples/granite-io/granite_io_openai.pdl",
    "chars": 138,
    "preview": "text:\n- \"Hello!\\n\"\n- processor:\n    model: \"granite4:micro\"\n    backend: openai\n  parameters:\n    generate_inputs:\n     "
  },
  {
    "path": "examples/granite-io/granite_io_thinking.pdl",
    "chars": 395,
    "preview": "text:\n- Find the fastest way for a seller to visit all the cities in their region\n- def: response\n  processor:\n    model"
  },
  {
    "path": "examples/granite-io/granite_io_transformers.pdl",
    "chars": 137,
    "preview": "text:\n- \"Hello!\\n\"\n- processor:\n    type: granite3.2\n    model: ibm-granite/granite-3.2-2b-instruct\n    backend:\n      t"
  },
  {
    "path": "examples/gsm8k/README.md",
    "chars": 716,
    "preview": "\n# Grade School Math\n\nThis demo measures success with\n[Grade School Math](https://github.com/openai/grade-school-math),\n"
  },
  {
    "path": "examples/gsm8k/demos.yaml",
    "chars": 4751,
    "preview": "- |\n  Problem: \n  Natalia sold clips to 48 of her friends in April, and then she sold half as many clips in May. How man"
  },
  {
    "path": "examples/gsm8k/gsm8k-loop-fission.pdl",
    "chars": 4382,
    "preview": "#!/usr/bin/env pdl\n\n# Grade School Math https://github.com/openai/grade-school-math is an\n# open source AI dataset from "
  },
  {
    "path": "examples/gsm8k/gsm8k-plan-few-shots.pdl",
    "chars": 3097,
    "preview": "description: Grade School Math -- for every problem we generate a plan, then execute and evaluate it.\ndefs:\n  problems:\n"
  },
  {
    "path": "examples/gsm8k/gsm8k-plan.pdl",
    "chars": 2859,
    "preview": "description: Grade School Math -- for every problem we generate a plan, then execute and evaluate it.\ndefs:\n  problems:\n"
  },
  {
    "path": "examples/gsm8k/gsm8k-tot-few-shot.pdl",
    "chars": 4934,
    "preview": "description: Grade School Math -- for every problem we generate a plan, then execute and evaluate it.\ndefs:\n  problems:\n"
  },
  {
    "path": "examples/gsm8k/gsm8k-tot-multiplan.pdl",
    "chars": 3843,
    "preview": "description: Grade School Math -- for every problem we generate a plan, then execute and evaluate it.\ndefs:\n  problems:\n"
  },
  {
    "path": "examples/gsm8k/gsm8k-tot.pdl",
    "chars": 4683,
    "preview": "description: Grade School Math -- for every problem we generate a plan, then execute and evaluate it.\ndefs:\n  problems:\n"
  },
  {
    "path": "examples/gsm8k/gsm8k.pdl",
    "chars": 3826,
    "preview": "#!/usr/bin/env pdl\n\n# Grade School Math https://github.com/openai/grade-school-math is an\n# open source AI dataset from "
  },
  {
    "path": "examples/independent/independent.pdl",
    "chars": 380,
    "preview": "description: Independent example --- hello * ( (' in French'*g) + (' en Espanol'*g)) * Goodbye! * g \ntext:\n  - hello\n  -"
  },
  {
    "path": "examples/independent/independent_docs.pdl",
    "chars": 245,
    "preview": "description: Independent documents\ndefs:\n  doc1: \"Hello world!\"\n  doc2: \"Goodbye world!\"\ntext:\n  - context: independent\n"
  },
  {
    "path": "examples/independent/independent_for.pdl",
    "chars": 286,
    "preview": "description: Independent For loop example\ndefs:\n  list: \n    data: [\"in French\", \"en Espanol\"]\ntext:\n- \"Hello \"\n- for:\n "
  },
  {
    "path": "examples/independent/test.pdl",
    "chars": 229,
    "preview": "description: test\ndefs:\n  m1: \n    content: doc1\n  m2: \n    content: doc2\n  m3:\n    content: Compare the docs\n  \n  mycon"
  },
  {
    "path": "examples/input/data.txt",
    "chars": 12,
    "preview": "Hello World!"
  },
  {
    "path": "examples/input/input_test.pdl",
    "chars": 117,
    "preview": "description: Hello world!\ndefs:\n  file: ./data.txt\ntext:\n- read: ${ file }\n  def: HELLO\n  contribute: []\n- get: HELLO"
  },
  {
    "path": "examples/input/input_test1.pdl",
    "chars": 187,
    "preview": "description: PDL code with input block\ntext:\n- \"The following will prompt the user on stdin.\\n\"\n- read:\n  message: \"Plea"
  },
  {
    "path": "examples/input/input_test2.pdl",
    "chars": 89,
    "preview": "description: Hello world!\ntext:\n- \"A multiline stdin input.\\n\"\n- read:\n  multiline: True\n"
  },
  {
    "path": "examples/intrinsics/README.md",
    "chars": 1743,
    "preview": "To run the example in this folder, you need to first create the model on ollama by following the initial steps in this\nn"
  },
  {
    "path": "examples/intrinsics/demo-hallucination.json",
    "chars": 19710,
    "preview": "{\"kind\": \"text\", \"pdl__id\": \"text\", \"defs\": {}, \"text\": [{\"kind\": \"text\", \"pdl__id\": \"text.0.text\", \"role\": \"system\", \"d"
  },
  {
    "path": "examples/intrinsics/demo-hallucination.pdl",
    "chars": 5102,
    "preview": "# Granite.runtime Intrinsics Demo with PDL\n\n# Provide document(s) to Granite3-rag model with hallucination_tag\n# Granite"
  },
  {
    "path": "examples/map-reduce/context_fork.pdl",
    "chars": 161,
    "preview": "lastOf:\n- \"Hello, \"\n- for:\n    name: [Alice, Bob, Charlie]\n  map:\n    lastOf:\n    - my name is ${ name }\n    - model: ol"
  },
  {
    "path": "examples/map-reduce/python-reduce.pdl",
    "chars": 164,
    "preview": "defs:\n  plus:\n    lang: python\n    code: |\n      import operator\n      result = operator.add\nfor:\n  i: [1,2,3,4]\nmap:\n  "
  },
  {
    "path": "examples/map-reduce/reduce.pdl",
    "chars": 147,
    "preview": "defs:\n  plus:\n    function:\n      x: number\n      y: number\n    return:\n      ${ x + y }\nfor:\n  i: [1,2,3,4]\nmap:\n  ${i}"
  },
  {
    "path": "examples/notebooks/data.yaml",
    "chars": 565,
    "preview": "source_code: \n  |\n  @SuppressWarnings(\"unchecked\")\n  public static Map<String, String> deserializeOffsetMap(String lastS"
  },
  {
    "path": "examples/notebooks/demo.ipynb",
    "chars": 34736,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"a29514fc-9383-490c-8a73-63c547c21d95\",\n   \"metadata\": {},\n   \"so"
  },
  {
    "path": "examples/notebooks/demonstrations.txt",
    "chars": 2074,
    "preview": "\nWhat is the elevation range for the area that the eastern sector of the Colorado orogeny extends into?\nTho: I need to s"
  },
  {
    "path": "examples/notebooks/granite_io_demo.ipynb",
    "chars": 10053,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"50f4ce4a\",\n   \"metadata\": {},\n   \"source\": [\n    \"# PDL - Granit"
  },
  {
    "path": "examples/notebooks/ground_truth.txt",
    "chars": 615,
    "preview": "The function `deserializeOffsetMap` takes a string as input and returns a map. It first checks if the input string is nu"
  },
  {
    "path": "examples/notebooks/notebook.ipynb",
    "chars": 4790,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": 2,\n   \"id\": \"e25a6874-54d9-4167-82ed-ab2f4fdc0a6f\",\n   \""
  },
  {
    "path": "examples/notebooks/notebook_debug.ipynb",
    "chars": 6481,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": 1,\n   \"id\": \"e25a6874-54d9-4167-82ed-ab2f4fdc0a6f\",\n   \""
  },
  {
    "path": "examples/notebooks/pdl.ipynb",
    "chars": 15055,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"id\": \"50f4ce4a\",\n   \"metadata\": {},\n   \"source\": [\n    \"# Prompt Decla"
  },
  {
    "path": "examples/openai/README.md",
    "chars": 662,
    "preview": "# OpenAI Platform Examples\n\nThese examples demonstrate how to use the OpenAI platform in PDL.\n\n## Basic Usage\n\nSee `open"
  },
  {
    "path": "examples/openai/openai_basic.pdl",
    "chars": 268,
    "preview": "description: Test OpenAI platform\ntext:\n- \"Hello, can you respond with a simple greeting?\\n\"\n- platform: openai\n  model:"
  },
  {
    "path": "examples/openai/openai_structured.pdl",
    "chars": 390,
    "preview": "description: OpenAI platform with structured output\ntext:\n- \"Extract information about a person from this text: John Doe"
  },
  {
    "path": "examples/optimizer/__init__.py",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "examples/optimizer/config.yml",
    "chars": 377,
    "preview": "benchmark: \"gsm8k\"\ninitial_test_set_size: 1\nmax_test_set_size: 1\nnum_candidates: 5\nnum_demonstrations: 3\nparallelism: 1\n"
  },
  {
    "path": "examples/optimizer/eval_levenshtein.pdl",
    "chars": 257,
    "preview": "defs:\n  score:\n    function:\n      document: string\n      ground_truth: string\n    return:\n      lang: python\n      fall"
  },
  {
    "path": "examples/optimizer/fever.pdl",
    "chars": 1478,
    "preview": "description: Demo of ReAct template fever\ndefs:\n  cot:\n    import: ../../contrib/prompt_library/CoT\n  react:\n    import:"
  },
  {
    "path": "examples/optimizer/fever_evaluator.py",
    "chars": 2847,
    "preview": "from typing import Any\n\nfrom pdl.optimize.optimizer_evaluator import OptimizerEvaluator\nfrom pdl.pdl_interpreter import "
  },
  {
    "path": "examples/optimizer/grammar_correction.pdl",
    "chars": 735,
    "preview": "defs:\n  max_tokens: 1024\nlastOf:\n  - \"Here are examples of grammatically incorrect sentences and their corrected version"
  },
  {
    "path": "examples/optimizer/grammar_correction.yaml",
    "chars": 1733,
    "preview": "pdl_path: grammar_correction.pdl # Path to the PDL file to optimize\ndataset: \n  train: grammar_correction_jsonl/train.js"
  },
  {
    "path": "examples/optimizer/gsm8k.pdl",
    "chars": 1279,
    "preview": "description: Demo of template\ndefs:\n  cot:\n    import: ../../contrib/prompt_library/CoT\n  react:\n    import: ../../contr"
  },
  {
    "path": "examples/optimizer/gsm8k_evaluator.py",
    "chars": 2269,
    "preview": "from typing import Any\n\nfrom pdl.optimize.optimizer_evaluator import OptimizerEvaluator\nfrom pdl.optimize.parse_number i"
  },
  {
    "path": "examples/optimizer/gsm8k_optimizer_config.yml",
    "chars": 1495,
    "preview": "pdl_path: gsm8k.pdl # Path to the PDL file to optimize\ndataset: gsm8k # Name our benchmark\nbudget: null # Set a budget, "
  },
  {
    "path": "examples/optimizer/gsmhard_evaluator.py",
    "chars": 2611,
    "preview": "from typing import Any\n\nfrom pdl.optimize.optimizer_evaluator import OptimizerEvaluator\nfrom pdl.optimize.parse_number i"
  },
  {
    "path": "examples/optimizer/mbpp.pdl",
    "chars": 6721,
    "preview": "description: MBPP agent\ndefs:\n  react_code_block:\n    function:\n      trajectory: [object]\n    return:\n      text:\n     "
  },
  {
    "path": "examples/optimizer/mbpp_dataset.py",
    "chars": 2781,
    "preview": "# from pdl.optimize.optimize import config\n\n\nfrom copy import deepcopy\n\nfrom datasets.load import load_from_disk\nfrom ev"
  },
  {
    "path": "examples/optimizer/mbpp_evaluator.py",
    "chars": 3538,
    "preview": "import ast\nimport re\nfrom typing import Any\n\nfrom evalplus.evaluate import check_correctness\n\nfrom pdl.optimize.optimize"
  },
  {
    "path": "examples/optimizer/optimize.py",
    "chars": 4605,
    "preview": "import argparse\nimport sys\nimport traceback\nfrom pathlib import Path\nfrom typing import Any\n\nimport yaml\nfrom datasets i"
  },
  {
    "path": "examples/optimizer/optimized_grammar_correction.pdl",
    "chars": 1836,
    "preview": "defs:\n  max_tokens: 1024\n  model: ollama_chat/gpt-oss:20b\n  num_demonstrations:\n    data: 3\n  verify:\n    data: true\n  d"
  },
  {
    "path": "examples/optimizer/process_fever.py",
    "chars": 14713,
    "preview": "# Instructions for running this script:\n# 1. Ensure you have the required libraries installed.\n#    `datasets` should be"
  },
  {
    "path": "examples/optimizer/process_grammar_correction.py",
    "chars": 1092,
    "preview": "import json\nfrom pathlib import Path\n\nfrom datasets.dataset_dict import DatasetDict\nfrom datasets.load import load_datas"
  },
  {
    "path": "examples/optimizer/process_gsm8k.py",
    "chars": 5577,
    "preview": "import re\nfrom pathlib import Path\nfrom typing import Any\n\nfrom datasets.dataset_dict import DatasetDict\nfrom datasets.l"
  },
  {
    "path": "examples/optimizer/process_mbpp.py",
    "chars": 2508,
    "preview": "# Instructions:\n# 1. Install EvalPlus e.g. `pip install evalplus`\n# 2. Run this script to process the MBPP dataset into "
  },
  {
    "path": "examples/ppdl/coin.pdl",
    "chars": 963,
    "preview": "defs:\n  obs:\n    array: [0, 0, 1, 1, 1, 1, 1, 1, 1, 1]\n  p:\n    model: ollama_chat/granite4:micro\n    parameters:\n      "
  },
  {
    "path": "examples/ppdl/hmm.pdl",
    "chars": 905,
    "preview": "defs:\n  rng:\n    lang: python\n    code: |\n      import random\n      import numpy as np\n      seed_value = random.randint"
  },
  {
    "path": "examples/ppdl/hmm_nl_priors.pdl",
    "chars": 1302,
    "preview": "defs:\n  rng:\n    lang: python\n    code: |\n      import random\n      import numpy as np\n      seed_value = random.randint"
  },
  {
    "path": "examples/ppdl/mbpp.pdl",
    "chars": 3596,
    "preview": "defs:\n  log:\n    lang: python\n    code: |\n      import math\n      result = math.log\n  Geometric:\n    lang: python\n    co"
  },
  {
    "path": "examples/ppdl/name_finder.ipynb",
    "chars": 144464,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": 1,\n   \"id\": \"41e7b4fd-a40a-4cc3-9c31-e61279d85dea\",\n   \""
  },
  {
    "path": "examples/ppdl/name_finder.pdl",
    "chars": 4165,
    "preview": "defs:\n  model: ollama/granite4:micro\n  names_fr:\n    data: {\n      \"Louise\": {\"2020\": 5.30, \"2021\": 5.33, \"2022\": 4.94, "
  },
  {
    "path": "examples/prompt_library/gsm8k_cot.pdl",
    "chars": 1854,
    "preview": "description: Demo of CoT pattern\ndefs:\n  cot:\n    import: ../../contrib/prompt_library/CoT\n  model: ollama/granite4:micr"
  },
  {
    "path": "examples/prompt_library/gsm8k_prob_react.pdl",
    "chars": 2925,
    "preview": "description: Demo of ReAct pattern\ndefs:\n  react:\n    import: ../../contrib/prompt_library/ProbReAct\n  tools:\n    import"
  },
  {
    "path": "examples/prompt_library/gsm8k_react.pdl",
    "chars": 2184,
    "preview": "description: Demo of ReAct pattern\ndefs:\n  react:\n    import: ../../contrib/prompt_library/ReAct\n  tools:\n    import: .."
  },
  {
    "path": "examples/prompt_library/gsm8k_rewoo.pdl",
    "chars": 1847,
    "preview": "description: Demo of ReWOO pattern\ndefs:\n  rewoo:\n    import: ../../contrib/prompt_library/ReWoo\n  tools:\n    import: .."
  },
  {
    "path": "examples/rag/README.md",
    "chars": 908,
    "preview": "## pdf_query example \n\nThis example uses [Ollama](../../tutorial/#using-ollama-models).  Fetch the models used in this e"
  },
  {
    "path": "examples/rag/pdf_index.pdl",
    "chars": 526,
    "preview": "# Load PDF document into vector database\n\ndescription: Load document into vector database\ntext:\n- include: rag_library1."
  },
  {
    "path": "examples/rag/pdf_query.pdl",
    "chars": 1507,
    "preview": "# Query vector database for relevant passages; use passages to query LLM.\n\ndefs:\n  QUESTIONS:\n    data: [\n      \"Does PD"
  },
  {
    "path": "examples/rag/rag.py",
    "chars": 3808,
    "preview": "from langchain_community.document_loaders import PyPDFLoader\nfrom langchain_text_splitters import RecursiveCharacterText"
  },
  {
    "path": "examples/rag/rag_library1.pdl",
    "chars": 1016,
    "preview": "# This module can be included from a PDL program to bring in Python functions.\n\ndescription: RAG library for PDL\ntext:\n-"
  },
  {
    "path": "examples/rag/tfidf_rag.pdl",
    "chars": 1591,
    "preview": "description: Retrieval-augmented generation for NL-to-Code generation task.\ntext:\n- lang: python\n  code: | # initialize "
  },
  {
    "path": "examples/react/demonstrations.txt",
    "chars": 2076,
    "preview": "\nWhat is the elevation range for the area that the eastern sector of the Colorado orogeny extends into?\nTho: I need to s"
  },
  {
    "path": "examples/react/react_demo.pdl",
    "chars": 4266,
    "preview": "description: Demonstrating a React program\ndefs:\n  problem: |\n    How many years ago was the discoverer of the Hudson Ri"
  },
  {
    "path": "examples/skeleton-of-thought/tips.pdl",
    "chars": 3226,
    "preview": "description: Tip suggestion program illustration skeleton-of-thought\ndefs:\n  MAX_ITERATIONS: 5\n  topics:\n    read: topic"
  },
  {
    "path": "examples/skeleton-of-thought/topic.jsonl",
    "chars": 2716,
    "preview": "{\"topic\": \"organizing a successful charity event\", \"number\": 6}\n{\"topic\": \"improving personal credit scores\", \"number\": "
  },
  {
    "path": "examples/teacher/qna.yaml",
    "chars": 458,
    "preview": "task_description: to teach a large language model to come up with puns\ncreated_by: mizmo\nseed_examples:\n- question: Tell"
  },
  {
    "path": "examples/teacher/teacher.pdl",
    "chars": 16549,
    "preview": "defs:\n  teacher_sys_prompt: You are a very knowledgeable AI Assistant that will faithfully assist the user with their ta"
  },
  {
    "path": "examples/test.pdl",
    "chars": 112,
    "preview": "defs:\n  b: hi\ntext:\n- role: assistant\n  content: hello\n  tool_calls: \n  - a: ${ b }\n    c: d \n- ${ pdl_context }"
  },
  {
    "path": "examples/tools/calc.pdl",
    "chars": 865,
    "preview": "description: tool use\ndefs:\n  calc:\n    description: Calculator function\n    function:\n      expr:\n        type: string\n"
  },
  {
    "path": "examples/tools/search.pdl",
    "chars": 886,
    "preview": "description: tool use\ndefs:\n  search:\n    description: Wikipedia search\n    function:\n      topic:\n        type: string\n"
  },
  {
    "path": "examples/tutorial/calling_llm.pdl",
    "chars": 148,
    "preview": "description: Calling a model on the implicit background context\ntext:\n- \"Hello\\n\"\n- model: ollama_chat/granite4:micro\n  "
  },
  {
    "path": "examples/tutorial/calling_llm_chaining.pdl",
    "chars": 216,
    "preview": "description: Model chaining\ntext:\n- \"Hello\\n\"\n- model: ollama_chat/granite4:micro\n  parameters:\n    stop: [\"!\"]\n- \"\\nTra"
  },
  {
    "path": "examples/tutorial/calling_llm_with_input.pdl",
    "chars": 152,
    "preview": "description: Calling a model with an input text\ntext:\n- \"Hello\\n\"\n- model: ollama_chat/granite4:micro\n  input:\n    Trans"
  },
  {
    "path": "examples/tutorial/calling_llm_with_input_messages.pdl",
    "chars": 294,
    "preview": "description: Calling a model with an explicit list of messages\ntext:\n- \"Hello\\n\"\n- model: ollama_chat/granite4:micro\n  i"
  },
  {
    "path": "examples/tutorial/calling_llm_with_input_messages_var.pdl",
    "chars": 312,
    "preview": "description: Model call with explicit messages input\ndefs:\n  prompt:\n    array:\n    - role: system\n      content: You ar"
  },
  {
    "path": "examples/tutorial/code_command.pdl",
    "chars": 103,
    "preview": "description: Hello world showing call out to shell command\nlang: command\ncode: |\n  echo \"Hello World!\"\n"
  },
  {
    "path": "examples/tutorial/code_jinja.pdl",
    "chars": 115,
    "preview": "description: Hello world showing call out to Jinja\ndefs:\n  world: \"World\"\nlang: jinja\ncode: |\n  Hello {{ world }}!\n"
  },
  {
    "path": "examples/tutorial/code_jinja_parameters.pdl",
    "chars": 310,
    "preview": "description: Demonstrating Jinja code with parameters field\ndefs:\n  items:\n    data:\n    - apple\n    - banana\n    - cher"
  },
  {
    "path": "examples/tutorial/code_pdl.pdl",
    "chars": 191,
    "preview": "description: Hello world showing call out to PDL\nlang: pdl\ncode: |\n  description: Hello world\n  text:\n  - \"Hello\\n\"\n  - "
  },
  {
    "path": "examples/tutorial/code_python.pdl",
    "chars": 223,
    "preview": "description: Hello world showing call to Python code\ndefs:\n  name:\n    lang: python\n    code: \n      |\n      import rand"
  },
  {
    "path": "examples/tutorial/code_scope.pdl",
    "chars": 119,
    "preview": "description: Demonstrating the scope field in code blocks\nlang: python\nscope:\n  x: 10\n  y: 20\ncode: |\n  result = x + y\n"
  },
  {
    "path": "examples/tutorial/code_session.pdl",
    "chars": 239,
    "preview": "text:\n- lang: python\n  code: |\n    PDL_SESSION.fd = open(\"/tmp/output\", mode=\"w\")\n    result = \"File opened\"\n- Hello\n- l"
  },
  {
    "path": "examples/tutorial/data.txt",
    "chars": 12,
    "preview": "Hello World!"
  },
  {
    "path": "examples/tutorial/data.yaml",
    "chars": 566,
    "preview": "source_code: \n  |\n  @SuppressWarnings(\"unchecked\")\n  public static Map<String, String> deserializeOffsetMap(String lastS"
  },
  {
    "path": "examples/tutorial/data_block_raw.pdl",
    "chars": 81,
    "preview": "description: Raw data block\ndata:\n  name: ${ name }\n  phone: ${ phone }\nraw: True"
  },
  {
    "path": "examples/tutorial/defs.pdl",
    "chars": 283,
    "preview": "text:\n- \"Hello\\n\"\n- defs:\n    fr:\n      lastOf:\n      - \"\\nTranslate to French\\n\"\n      - model: ollama_chat/granite4:mi"
  },
  {
    "path": "examples/tutorial/for.pdl",
    "chars": 81,
    "preview": "description: for loop creating a string\nfor:\n  i: [1, 2, 3, 4]\nrepeat: \n  ${ i }\n"
  },
  {
    "path": "examples/tutorial/for_array.pdl",
    "chars": 91,
    "preview": "description: Array comprehension\nfor:\n  i: [1, 2, 3, 4]\nrepeat:\n  ${ i }\njoin:\n  as: array\n"
  },
  {
    "path": "examples/tutorial/for_lastOf.pdl",
    "chars": 130,
    "preview": "description: Loop where the result is the result of the last iteration\nfor:\n  i: [1, 2, 3, 4]\nrepeat:\n  ${ i }\njoin:\n  a"
  },
  {
    "path": "examples/tutorial/for_multiple_lists.pdl",
    "chars": 232,
    "preview": "description: for loop over multiple lists\ndefs:\n  numbers:\n    data: [1, 2, 3, 4]\n  names:\n    data: [\"Bob\", \"Carol\", \"D"
  },
  {
    "path": "examples/tutorial/for_object.pdl",
    "chars": 244,
    "preview": "description: for loop creating an object\ndefs:\n  numbers:\n    data: [1, 2, 3, 4]\n  names:\n    data: [\"Bob\", \"Carol\", \"Da"
  },
  {
    "path": "examples/tutorial/for_with.pdl",
    "chars": 116,
    "preview": "description: for loop with new lines between iterations\nfor:\n  i: [1, 2, 3, 4]\nrepeat: \n  ${ i }\njoin:\n  with: \"\\n\"\n"
  },
  {
    "path": "examples/tutorial/free_variables.pdl",
    "chars": 211,
    "preview": "# Call with pdl --data '\"something\": \"ABC\"' free_variables.pdl \ndescription: Hello world with data\ntext:\n- def: stutter\n"
  },
  {
    "path": "examples/tutorial/function_alias.pdl",
    "chars": 184,
    "preview": "description: Use a function as a value\ndefs:\n  hello:\n    function:\n      name: string\n    return: Hello ${ name }!\n  al"
  },
  {
    "path": "examples/tutorial/function_call_in_jinja.pdl",
    "chars": 406,
    "preview": "description: Calling a PDL function from Jinja\ndefs:\n  translate:\n    function:\n      sentence: string\n      language: s"
  },
  {
    "path": "examples/tutorial/function_definition.pdl",
    "chars": 488,
    "preview": "description: Function definition and call\ndefs:\n  translate:\n    function:\n      sentence: string\n      language: string"
  },
  {
    "path": "examples/tutorial/function_empty_context.pdl",
    "chars": 535,
    "preview": "description: Function call with an empty context\ndefs:\n  translate:\n    function:\n      sentence: string\n      language:"
  },
  {
    "path": "examples/tutorial/function_optional_params.pdl",
    "chars": 389,
    "preview": "description: Function with optional parameter\ndefs:\n  hello:\n    function:\n      name: string\n      lastName: {optional:"
  },
  {
    "path": "examples/tutorial/if.pdl",
    "chars": 216,
    "preview": "description: Hello world with condition\ntext:\n- 'Hello! '\n- lang: python\n  code: |\n    import random\n    result = random"
  },
  {
    "path": "examples/tutorial/import.pdl",
    "chars": 85,
    "preview": "defs:\n  lib: \n    import: import_lib\ntext:\n- call: ${ lib.a }\n  args: \n    arg: Bye!\n"
  },
  {
    "path": "examples/tutorial/import_lib.pdl",
    "chars": 202,
    "preview": "\ndefs: \n  b: \n    function:\n      arg: string \n    return:\n      ${ arg }\n\n  a: \n    function:\n      arg: string \n    re"
  },
  {
    "path": "examples/tutorial/input.json",
    "chars": 170,
    "preview": "{\n    \"name\": \"Bob\",\n    \"address\": {\n        \"number\": 87,\n        \"street\": \"Smith Road\",\n        \"town\": \"Armonk\", \n "
  },
  {
    "path": "examples/tutorial/input_file.pdl",
    "chars": 76,
    "preview": "description: PDL code with input block\ntext:\n- read: ./data.txt\n  def: HELLO"
  },
  {
    "path": "examples/tutorial/input_file_json.pdl",
    "chars": 291,
    "preview": "description: Input block example with json input\ndefs:\n  PERSON:\n    read: ./input.json\n    parser: json\ntext:\n- \"${ PER"
  },
  {
    "path": "examples/tutorial/input_stdin.pdl",
    "chars": 155,
    "preview": "description: PDL code with input block\ntext:\n- \"The following will prompt the user on stdin.\\n\"\n- read:\n  message: \"Plea"
  },
  {
    "path": "examples/tutorial/input_stdin_multiline.pdl",
    "chars": 101,
    "preview": "description: PDL code with input block\ntext:\n- \"A multiline stdin input.\\n\"\n- read:\n  multiline: true"
  },
  {
    "path": "examples/tutorial/lastOf.pdl",
    "chars": 203,
    "preview": "description: Explicit use of role\nrole: user\ntext:\n- \"Hello\\n\"\n- lastOf:\n  - role: system\n    text: \"You are a polite as"
  },
  {
    "path": "examples/tutorial/local_computation.pdl",
    "chars": 198,
    "preview": "description: Local computations using defs\ntext:\n- \"Hello\\n\"\n- defs:\n    GEN:\n      model: ollama_chat/granite4:micro\n  "
  },
  {
    "path": "examples/tutorial/loop_index.pdl",
    "chars": 50,
    "preview": "index: i\nrepeat:\n  text: ${i + 1}\nmaxIterations: 3"
  },
  {
    "path": "examples/tutorial/muting_block_output.pdl",
    "chars": 219,
    "preview": "description: Control block outputs with `contribute`\ntext:\n- \"Hello\\n\"\n- text: \"\\nTranslate to French\\n\"\n  contribute: ["
  },
  {
    "path": "examples/tutorial/parser-regex.pdl",
    "chars": 276,
    "preview": "description: Hello world with parser using regex\ntext:\n- model: ollama_chat/granite4:micro\n  input: \"Hello,\"\n  parameter"
  },
  {
    "path": "examples/tutorial/parser_findall.pdl",
    "chars": 66,
    "preview": "data: \"1 -- 2 -- 3 -- 4\"\nparser:\n  regex: '[0-9]+'\n  mode: findall"
  },
  {
    "path": "examples/tutorial/parser_regex_code.pdl",
    "chars": 342,
    "preview": "description: Parse a block output using a regex\ndefs:\n  output:\n    model: ollama_chat/granite4:micro\n    parameters:\n  "
  },
  {
    "path": "examples/tutorial/pdl_scope.pdl",
    "chars": 260,
    "preview": "description: Demonstrating the pdl_scope variable\ndefs:\n  greeting: Hello\n  name: World\ntext:\n- |\n  ${ pdl_scope[\"greeti"
  },
  {
    "path": "examples/tutorial/pdl_usage.pdl",
    "chars": 354,
    "preview": "description: Demonstrating the pdl_usage variable\ntext:\n- |\n  Hello\n\n- model: ollama/granite4:micro\n- |\n  \n  \n  Usage St"
  }
]

// ... and 857 more files (download for full content)

About this extraction

This page contains the full source code of the IBM/prompt-declaration-language GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 1057 files (6.0 MB), approximately 1.6M tokens, and a symbol index with 1736 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!