Skip to content

Commit 873e64d

Browse files
authored
docs: update tutorial (#1080)
Signed-off-by: Louis Mandel <[email protected]>
1 parent cfa24dd commit 873e64d

Some content is hidden

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

51 files changed

+401
-462
lines changed

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ text:
201201
```
202202

203203

204-
A PDL program computes 2 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.
204+
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.
205205

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

docs/tutorial.md

Lines changed: 142 additions & 55 deletions
Large diffs are not rendered by default.

examples/sdk/hello_dict.py

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

examples/sdk/hello_prog.py

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

examples/tutorial/calling_llm.pdl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
description: Hello world calling a model
1+
description: Calling a model on the implicit background context
22
text:
33
- "Hello\n"
44
- model: ollama_chat/granite3.2:2b
55
parameters:
6-
stop: ['!']
6+
stop: ['!']

examples/tutorial/calling_llm_with_input.pdl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
description: Hello world calling a model
1+
description: Calling a model with an input text
22
text:
33
- "Hello\n"
44
- model: ollama_chat/granite3.2:2b

examples/tutorial/calling_llm_with_input_messages.pdl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
description: Hello world calling a model
1+
description: Calling a model with an explicit list of messages
22
text:
33
- "Hello\n"
44
- model: ollama_chat/granite3.2:2b

examples/tutorial/calling_llm_with_input_messages_var.pdl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ defs:
33
prompt:
44
array:
55
- role: system
6-
content: You are a helpful software engineer. You write clear, concise, well-commented code.
6+
content: You are a helpful assistant that is fluent in French.
77
- role: user
8-
content: Write a Python function that implement merge sort.
9-
model: ollama_chat/granite3.2:2b
10-
input: ${ prompt }
8+
content: Translate the word 'Hello' to French
9+
text:
10+
- "Hello\n"
11+
- model: ollama_chat/granite3.2:2b
12+
input: ${ prompt }

examples/tutorial/defs-hello.pdl

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

examples/tutorial/defs.pdl

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
1-
description: Function def and call
2-
defs:
3-
translate:
4-
function:
5-
sentence: string
6-
language: string
7-
return:
1+
text:
2+
- "Hello\n"
3+
- defs:
4+
fr:
85
lastOf:
9-
- "\nTranslate the sentence '${ sentence }' to ${ language }.\n"
6+
- "\nTranslate to French\n"
107
- model: ollama_chat/granite3.2:2b
11-
parameters:
12-
stop: ["\n"]
13-
text:
14-
- call: ${ translate }
15-
args:
16-
sentence: I love Paris!
17-
language: French
18-
- "\n"
19-
- call: ${ translate }
20-
args:
21-
sentence: I love Madrid!
22-
language: Spanish
8+
es:
9+
lastOf:
10+
- "\nTranslate to Spanish\n"
11+
- model: ollama_chat/granite3.2:2b
12+
text: |
13+
14+
In Fench: ${ fr }
15+
16+
In Spanish: ${ es }

0 commit comments

Comments
 (0)