Skip to content

Commit ef12314

Browse files
authored
Update documentation (#638)
1 parent 6124c52 commit ef12314

File tree

4 files changed

+33
-30
lines changed

4 files changed

+33
-30
lines changed

docs/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -440,20 +440,20 @@ See [PDL Language Tutorial](https://ibm.github.io/prompt-declaration-language/tu
440440
441441
## Debugging Tools
442442
443-
## Live Explorer
443+
### Live Explorer
444444
445445
PDL has a Live Explorer to help in program understanding given an execution trace.
446446
To produce an execution trace consumable by the Live Explorer, you can run the interpreter with the `--trace` argument:
447447
448448
```
449-
pdl --trace <file.json> <my-example>
449+
pdl <my-example> --trace <my-example_trace.json>
450450
```
451451
452452
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.
453453
454454
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.
455455
456-
## Trace Telemetry
456+
### Trace Telemetry
457457
458458
PDL includes experimental support for gathering trace telemetry. This can
459459
be used for debugging or performance analysis, and to see the shape of prompts sent by LiteLLM to models.

docs/tutorial.md

+18-12
Original file line numberDiff line numberDiff line change
@@ -306,25 +306,31 @@ Bob lives at the following address:
306306
## Parsing the output of a block
307307

308308
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.
309-
Other possible values for `parser` are `yaml`, `jsonl`, or a regular expression.
309+
Other possible values for `parser` are `yaml`, `jsonl`, or `regex`.
310310

311-
The following code shows an example of a regular expression parser:
311+
The following example extracts using a regular expression parser the code between triple backtick generated by a model:
312312
```yaml
313313
--8<-- "./examples/tutorial/parser_regex.pdl"
314314
```
315315

316-
See [here](https://docs.python.org/3/library/re.html) for more information on how to write regular expressions.
317-
We support the following operations (indicated with the `mode` field):
316+
We support the following operations with the`regex` parser (indicated with the `mode` field):
317+
318+
- `fullmatch` (default)
318319

319-
- search
320+
- `search`
320321

321-
- match
322-
323-
- fullmatch
322+
- `match`
323+
324+
- `split`
324325

325-
- split
326-
327-
- findall
326+
- `findall`
327+
328+
Here is an example that is using `findall`:
329+
```yaml
330+
--8<-- "./examples/tutorial/parser_findall.pdl"
331+
```
332+
333+
See [here](https://docs.python.org/3/library/re.html) for more information on how to write regular expressions.
328334

329335
## Calling code
330336

@@ -392,7 +398,7 @@ PDL allows programs to be defined over multiple files. The `import` block allows
392398
following [example](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/import.pdl):
393399

394400
```yaml
395-
--8<-- "./examples/tutorial/include.pdl"
401+
--8<-- "./examples/tutorial/import.pdl"
396402
```
397403

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

examples/tutorial/parser_regex.pdl

+10-14
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
description: Hello world with parser using regex
2-
text:
3-
- model: ollama/granite-code:8b
4-
parameters:
5-
temperature: 0
6-
input: "Hello,"
7-
parameters:
8-
# Tell the LLM to stop after generating an exclamation point.
9-
stop: ['!']
10-
spec: {"name": str}
11-
parser:
12-
spec:
13-
name: str
14-
regex: '\s*(?P<name>.*)\s*'
1+
description: Parse a block output using a regex
2+
defs:
3+
output:
4+
model: ollama/granite-code:8b
5+
input: Write a Python function that perform the addition of two numbers.
6+
parser:
7+
spec:
8+
code: str
9+
regex: (.|\n)*```python\n(?P<code>(.|\n)*)```(.|\n)*
10+
text: ${ output.code }
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
{"name": "Hello"}
1+
def add(a, b):
2+
return a + b

0 commit comments

Comments
 (0)