Skip to content

Commit 42b792e

Browse files
authored
The argument of call: is a closure, not a name (#242)
1 parent dd446ab commit 42b792e

29 files changed

+140
-123
lines changed

docs/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ Suppose we want to define a translation function that takes a string and calls a
144144

145145
In this program, the first block 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 multilingual model.
146146

147-
The last two blocks are calls to this function, as indicated by `call: translate`. This block specifies the arguments to be passed. When we execute this program, we obtain:
147+
The last two blocks are calls to this function, as indicated by `call: ${ translate }`. This block specifies the arguments to be passed. When we execute this program, we obtain:
148148

149149
```
150150
The translation of 'I love Paris!' to French is 'J'aime Paris!'.

examples/demo/2-teacher.pdl

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ defs:
4848
return:
4949
defs:
5050
prompt_data:
51-
call: question_template_freeform
51+
call: ${question_template_freeform}
5252
spec: { introduction: str, principles: str, examples: str, generation: str, max_new_tokens: int }
5353
args:
5454
num_samples: ${num_samples}
5555
task_description: ${task_description}
5656
icl_question: ${icl_question}
5757
teacher_input:
58-
call: teacher_template
58+
call: ${teacher_template}
5959
args:
6060
sys_prompt: ${teacher_sys_prompt}
6161
prompt: |-
@@ -94,7 +94,7 @@ defs:
9494
for:
9595
example: ${seed_examples}
9696
repeat:
97-
call: gen_questions_freeform_inner
97+
call: ${gen_questions_freeform_inner}
9898
args:
9999
num_samples: 2
100100
task_description: ${task_description}
@@ -139,13 +139,13 @@ defs:
139139
return:
140140
defs:
141141
prompt_data:
142-
call: filter_questions_template
142+
call: ${filter_questions_template}
143143
spec: {introduction: str, principles: str, generation: str, max_new_tokens: int}
144144
args:
145145
task_description: ${task_description}
146146
question: ${question}
147147
teacher_input:
148-
call: teacher_template
148+
call: ${teacher_template}
149149
args:
150150
sys_prompt: ${teacher_sys_prompt}
151151
prompt: |-
@@ -179,7 +179,7 @@ defs:
179179
repeat:
180180
defs:
181181
filter_output:
182-
call: filter_questions_inner
182+
call: ${filter_questions_inner}
183183
args:
184184
task_description: ${task_description}
185185
question: ${question.question}
@@ -233,14 +233,14 @@ defs:
233233
return:
234234
defs:
235235
prompt_data:
236-
call: answer_template
236+
call: ${answer_template}
237237
spec: {introduction: str, principles: str, examples: str, generation: str, max_new_tokens: int, additional_stop_tokens: [str]}
238238
args:
239239
icl_question: ${question.icl_question}
240240
icl_response: ${question.icl_answer}
241241
question: ${question.question}
242242
teacher_input:
243-
call: teacher_template
243+
call: ${teacher_template}
244244
args:
245245
sys_prompt: ${teacher_sys_prompt}
246246
prompt: |-
@@ -278,7 +278,7 @@ defs:
278278
for:
279279
question: ${ questions }
280280
repeat:
281-
call: gen_answers_inner
281+
call: ${gen_answers_inner}
282282
args:
283283
question: ${question}
284284
join:
@@ -322,13 +322,13 @@ defs:
322322
return:
323323
defs:
324324
prompt_data:
325-
call: filter_qa_template
325+
call: ${filter_qa_template}
326326
spec: {introduction: str, principles: str, generation: str, max_new_tokens: int}
327327
args:
328328
question: ${question}
329329
answer: ${answer}
330330
teacher_input:
331-
call: teacher_template
331+
call: ${teacher_template}
332332
args:
333333
sys_prompt: ${teacher_sys_prompt}
334334
prompt: |-
@@ -360,7 +360,7 @@ defs:
360360
repeat:
361361
defs:
362362
filter_output:
363-
call: filter_question_answer_pair_inner
363+
call: ${filter_question_answer_pair_inner}
364364
spec: float
365365
args:
366366
question: ${qa_pair.question}
@@ -385,25 +385,25 @@ text:
385385
parser: yaml
386386
- "\n\n----- Generating questions -----\n\n"
387387
- def: generated_questions
388-
call: gen_questions_freeform
388+
call: ${gen_questions_freeform}
389389
spec: [{icl_question: str, icl_answer: str, question: str}]
390390
args:
391391
task_description: ${seed_examples.task_description}
392392
seed_examples: ${seed_examples.seed_examples}
393393
- "\n\n----- Filtering questions -----\n\n"
394394
- def: filtered_questions
395-
call: filter_questions
395+
call: ${filter_questions}
396396
spec: [{icl_question: str, icl_answer: str, question: str}]
397397
args:
398398
task_description: ${seed_examples.task_description}
399399
questions: ${generated_questions}
400400
- "\n\n----- Generating answers -----\n\n"
401401
- def: qa_pairs
402-
call: gen_answers
402+
call: ${gen_answers}
403403
args:
404404
questions: ${filtered_questions}
405405
- "\n\n----- Filtering QA pairs -----\n\n"
406-
- call: filter_question_answer_pair
406+
- call: ${filter_question_answer_pair}
407407
args:
408408
qa_pairs: ${qa_pairs}
409409

examples/hello/hello-data.pdl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ text:
66
return:
77
${ something }
88
- "Hello World!\n"
9-
- call: stutter
9+
- call: ${ stutter }
1010
- "\n"
1111

1212

examples/hello/hello-defs.pdl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ defs:
77
bye:
88
"Good bye"
99
text:
10-
- call: hello
10+
- call: ${ hello }
1111
args:
1212
name: World
1313
- "\n"

examples/hello/hello-function-alias.pdl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ defs:
44
function:
55
name: str
66
return: Hello ${ name }!
7-
alias: hello
7+
alias: ${ hello }
88
text:
99
- call: ${ alias }
1010
args:

examples/hello/hello-function.pdl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ text:
44
function:
55
name: str
66
return: Hello ${ name }!
7-
- call: hello
7+
- call: ${ hello }
88
args:
99
name: World

examples/hello/hello-type.pdl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ text:
1414
- model: replicate/ibm-granite/granite-3.0-8b-instruct
1515
parameters:
1616
stop_sequences: "\n"
17-
- call: translate
17+
- call: ${ translate }
1818
spec: str
1919
args:
2020
sentence: ${ GEN }
2121
language: French
22-
- call: translate
22+
- call: ${ translate }
2323
args:
2424
sentence: ${ GEN }
2525
language: Spanish

examples/notebooks/notebook_debug.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@
180180
],
181181
"metadata": {
182182
"kernelspec": {
183-
"display_name": "Python 3 (ipykernel)",
183+
"display_name": "pdl-3.12",
184184
"language": "python",
185185
"name": "python3"
186186
},

examples/react/react_call.pdl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
description: Wikipedia example using the react_fun function definition
22
text:
33
- include: ./react_fun.pdl
4-
- call: react
4+
- call: ${ react }
55
args:
66
question: How many years ago was the discoverer of the Hudson River born? Keep in mind we are in 2024.
77
model: replicate/ibm-granite/granite-3.0-8b-instruct

examples/react/react_fun.pdl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ defs:
121121
Act:
122122
[{"name": "Finish", "arguments": {"topic": "director, screenwriter, actor"}}]
123123

124-
call: react_inner
124+
call: ${ react_inner }
125125
args:
126126
pdl_context: []
127127
examples: ${ examples }

0 commit comments

Comments
 (0)