Skip to content

Commit dc6192f

Browse files
committed
Merge branch 'main' into pdl-199
2 parents f409029 + 53004df commit dc6192f

File tree

153 files changed

+2041
-696
lines changed

Some content is hidden

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

153 files changed

+2041
-696
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
strategy:
1111
fail-fast: false
1212
matrix:
13-
python-version: ['3.11', '3.12']
13+
python-version: ['3.11', '3.12', '3.13']
1414

1515
steps:
1616
- uses: actions/checkout@v4

.github/workflows/run-examples.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
python-version: ['3.11', '3.12']
16+
python-version: ['3.11', '3.12', '3.13']
1717

1818
steps:
1919
- uses: actions/checkout@v4

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ repos:
4545
"-sn", # Don't display the score
4646
"--rcfile=pylintrc"
4747
]
48+
# run the bandit security linter
49+
- repo: https://github.com/PyCQA/bandit
50+
rev: 1.7.10
51+
hooks:
52+
- id: bandit
53+
args: [-c, bandit.yaml]
4854
# Type check the Python code with MyPy
4955
- repo: https://github.com/pre-commit/mirrors-mypy
5056
rev: 'v1.11.2'

README.md

Lines changed: 130 additions & 396 deletions
Large diffs are not rendered by default.

bandit.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
# This is the configuration file for the bandit python static analysis tool
3+
exclude_dirs:
4+
- build
5+
# We are less worried about tests, as they are not a part of the library meant to be used by users
6+
# with untrusted inputs.
7+
- test
8+
skips:
9+
- B101 # allow the use of assert

docs/README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Pro Tip: When writing loops and conditionals with `repeat`, `for`, and `if-then-
3535

3636
## Interpreter Installation
3737

38-
The interpreter has been tested with Python versions **3.11** and **3.12**, on macOS and Linux. For Windows, please use WSL.
38+
The interpreter has been tested with Python versions **3.11**, **3.12**, and **3.13**, on macOS and Linux. For Windows, please use WSL.
3939

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

@@ -438,6 +438,28 @@ in the right pane.
438438
439439
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.
440440
441+
## Best Practices
442+
443+
1. **Template Organization**:
444+
- Keep templates modular and reusable
445+
- Use variables for dynamic content
446+
- Document template purpose and requirements
447+
448+
2. **Error Handling**:
449+
- Validate model inputs/outputs
450+
- Include fallback logic
451+
- Log intermediate results
452+
453+
3. **Performance**:
454+
- Cache frequent LLM calls
455+
- Use appropriate temperature settings
456+
- Implement retry logic for API calls
457+
458+
4. **Security**:
459+
- Enabling sandbox mode for untrusted code
460+
- Validate all inputs
461+
- Follow API key best practices
462+
441463
442464
## Additional Notes
443465

docs/contrib.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,19 @@ You can report issues or open a pull request (PR) to suggest changes.
44

55
## Reporting an issue
66

7-
To report an issue, or to suggest an idea for a change that you haven't
8-
had time to write-up yet:
9-
1. [Review existing issues](https://github.com/IBM/prompt-declaration-language/issues) to see if a similar issue has been opened or discussed.
10-
2. [Open an
11-
issue](https://github.com/IBM/prompt-declaration-language/issues/new). Be sure to include any helpful information, such as your Kubernetes environment details, error messages, or logs that you might have.
7+
To report an issue, or to suggest an idea for a change that you haven't had time to write-up yet:
128

9+
1. [Review existing issues](https://github.com/IBM/prompt-declaration-language/issues) to see if a similar issue has been opened or discussed.
10+
11+
2. [Open an
12+
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.
13+
14+
15+
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)).
1316

1417
## Suggesting a change
1518

16-
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.
19+
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.
1720

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

docs/tutorial.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ Bob lives at the following address:
305305

306306
## Calling code
307307

308-
The following script shows how to execute python code ([file](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/calling_code.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. 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.
308+
The following script shows how to execute python code ([file](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/calling_code.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.
309309

310310
In order to define variables that are carried over to the next Python code block, a special variable `PDL_SESSION` can be used, and
311311
variables assigned to it as fields.
@@ -668,6 +668,7 @@ text:
668668
decoding_method: greedy
669669
```
670670

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

672673
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:
673674

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
description: Hello world showing call out to shell command
2+
lang: command
3+
code: |
4+
echo "Hello World!"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
description: Hello world showing call out to Jinja
2+
defs:
3+
world: "World"
4+
lang: jinja
5+
code: |
6+
Hello {{ world }}!

0 commit comments

Comments
 (0)