Skip to content

Commit 182f08a

Browse files
committed
Merge branch 'main' into pdl-182
2 parents 20fff9f + 37231dc commit 182f08a

File tree

94 files changed

+1131
-29
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+1131
-29
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
- name: pre-commit checks
4040
run: pre-commit run -a
4141
- name: run tests
42-
run: py.test -v --capture=tee-sys tests
42+
run: py.test -v --capture=tee-sys --ignore=tests/test_examples_run.py tests
4343

4444
viewer:
4545
name: Build PDL live viewer

.github/workflows/run-examples.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
name: Run examples
3+
4+
on:
5+
schedule:
6+
- cron: '0 1 * * *'
7+
workflow_dispatch:
8+
9+
jobs:
10+
tests:
11+
name: Exeution tests
12+
runs-on: ubuntu-latest
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
python-version: ['3.11', '3.12']
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: Set up Python ${{ matrix.python-version }}
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
- name: Cache pip
25+
uses: actions/cache@v4
26+
with:
27+
# This path is specific to Ubuntu
28+
path: ${{ env.pythonLocation }}
29+
# Look to see if there is a cache hit for the setup file
30+
key: ${{ runner.os }}-pip-new3-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}
31+
restore-keys: |
32+
${{ runner.os }}-pip-new3
33+
${{ runner.os }}-new3
34+
- name: Install dependencies
35+
run: pip install --upgrade --upgrade-strategy eager .[all]
36+
- name: pip list packages
37+
run: pip list
38+
- name: show pip dependencies
39+
run: |
40+
pip install pipdeptree
41+
pipdeptree -fl
42+
- name: run tests
43+
env:
44+
WATSONX_PROJECT_ID: ${{ secrets.WATSONX_PROJECT_ID }}
45+
WATSONX_APIKEY: ${{ secrets.WATSONX_APIKEY }}
46+
WATSONX_URL: ${{ secrets.WATSONX_URL }}
47+
run: py.test -v --capture=tee-sys tests/test_examples_run.py

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ pdl <path/to/example.pdl>
5252

5353
The folder `examples` contains many examples of PDL programs. Several of these examples have been adapted from the LMQL [paper](https://arxiv.org/abs/2212.06094) by Beurer-Kellner et al. The examples cover a variety of prompting patterns such as CoT, RAG, ReAct, and tool use.
5454

55-
We highly recommend using VSCode to edit PDL YAML files. This project has been configured so that every YAML file is associated with the PDL grammar JSONSchema (see [settings](https://github.com/IBM/prompt-declaration-language/blob/main/.vscode/settings.json) and [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. You can set up your own VSCode PDL projects similarly using the following `.vscode/settings.json` file:
55+
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.
56+
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:
5657

5758
```
5859
{

docs/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ pdl <path/to/example.pdl>
5757

5858
The folder `examples` contains many examples of PDL programs. Several of these examples have been adapted from the LMQL [paper](https://arxiv.org/abs/2212.06094) by Beurer-Kellner et al. The examples cover a variety of prompting patterns such as CoT, RAG, ReAct, and tool use.
5959

60-
We highly recommend using VSCode to edit PDL YAML files. This project has been configured so that every YAML file is associated with the PDL grammar JSONSchema (see [settings](https://github.com/IBM/prompt-declaration-language/blob/main/.vscode/settings.json) and [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. You can set up your own VSCode PDL projects similarly using the following `./vscode/settings.json` file:
60+
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.
61+
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:
6162

6263
```
6364
{

docs/tutorial.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -734,11 +734,15 @@ See examples of PDL being called programmatically in Python
734734
735735
## Debugging PDL Programs
736736
737-
We highly recommend to use VSCode to edit PDL YAML files. This project has been configured so that every YAML file is associated with the PDL grammar JSONSchema (see [settings](https://github.com/IBM/prompt-declaration-language//blob/main/.vscode/settings.json) and [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. You can set up your own VSCode PDL projects similarly using this settings and schema files. 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. You may also need to install the VSCode extension: `YAML Language Support by Red Hat`.
737+
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)).
738+
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.
738739
739740
The interpreter prints out a log by default in the file `log.txt`. This log contains the details of inputs and outputs to every block in the program. It is useful to examine this file when the program is behaving differently than expected.
740741
741742
To change the log filename, you can pass it to the interpreter as follows:
743+
```
744+
pdl --log <my-example.log> <my-example>
745+
```
742746
743747
744748
## Live Document Visualizer
@@ -747,7 +751,7 @@ PDL has a Live Document visualizer to help in program understanding given an exe
747751
To produce an execution trace consumable by the Live Document, you can run the interpreter with the `--trace` argument and set the value to either `json` or `yaml`:
748752
749753
```
750-
pdl --trace <file.json> <my-example>
754+
pdl --trace <my-example_trace.json> <my-example>
751755
```
752756
753757
This produces an additional file named `my-example_trace.json` that can be uploaded to the [Live Document](https://ibm.github.io/prompt-declaration-language/viewer/) visualizer tool. Clicking on different parts of the Live Document will show the PDL code that produced that part

examples/hello/test.pdl

Lines changed: 0 additions & 7 deletions
This file was deleted.

examples/react/multi-agent.pdl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ text:
66
call: react
77
args:
88
question: ${ question }
9-
model: watsonx/ibm/granite-34b-code-instruct
9+
model: watsonx/ibm/granite-20b-code-instruct
1010

1111
- "\n\n----- Verifying answer... -----\n\n"
1212
- def: verified

examples/react/react_call.pdl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ text:
44
- call: react
55
args:
66
question: How many years ago was the discoverer of the Hudson River born?
7-
model: watsonx/mistralai/mistral-large
8-
7+
model: watsonx/ibm/granite-34b-code-instruct

examples/react/react_fun.pdl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ defs:
111111
Act: {"name": "Finish", "arguments": {"topic": "2.869047619047619"}}
112112
- call: react_inner
113113
args:
114-
context: []
114+
pdl_context: []
115115
examples: ${ examples }
116116
question: ${ question }
117117
model: ${ model }

examples/talk/react_fun.pdl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ defs:
111111
Act: {"name": "Finish", "arguments": {"topic": "2.869047619047619"}}
112112
- call: react_inner
113113
args:
114-
context: []
114+
pdl_context: []
115115
examples: ${ examples }
116116
question: ${ question }
117117
model: ${ model }

0 commit comments

Comments
 (0)