Skip to content

Commit 23c7000

Browse files
authored
File names relative to current file in read and include blocks (#27)
* File names relative to current file in read and include blocks * Update examples
1 parent 99c7d45 commit 23c7000

40 files changed

+125
-84
lines changed

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ Notice that in PDL variables are used to templatize any entity in the document,
230230
```yaml
231231
description: Code explanation example
232232
document:
233-
- read: examples/code/data.yaml
233+
- read: ./data.yaml
234234
parser: yaml
235235
def: CODE
236236
show_result: False
@@ -248,7 +248,7 @@ document:
248248
Explain the following code:
249249
```
250250
{{ CODE.source_code }}```
251-
- read: examples/code/ground_truth.txt
251+
- read: ./ground_truth.txt
252252
def: TRUTH
253253
show_result: False
254254
- |
@@ -304,11 +304,11 @@ Finally, we can output JSON data as a result of this program, as follows:
304304
```yaml
305305
description: Code explanation example
306306
document:
307-
- read: examples/code/data.yaml
307+
- read: ./data.yaml
308308
parser: yaml
309309
def: CODE
310310
show_result: False
311-
- read: examples/code/ground_truth.txt
311+
- read: ./ground_truth.txt
312312
def: TRUTH
313313
show_result: False
314314
- model: ibm/granite-34b-code-instruct

docs/README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ In PDL, this would be expressed as follows (see [file](https://github.com/IBM/pr
158158
```yaml
159159
description: Code explanation example
160160
document:
161-
- read: examples/code/data.json
161+
- read: ./data.json
162162
parser: json
163163
def: CODE
164164
show_result: False
@@ -212,11 +212,11 @@ Notice that in PDL variables are used to templatize any entity in the document,
212212
```yaml
213213
description: Code explanation example
214214
document:
215-
- read: examples/code/data.json
215+
- read: ./data.json
216216
parser: json
217217
def: CODE
218218
show_result: False
219-
- read: examples/code/ground_truth.txt
219+
- read: ./ground_truth.txt
220220
def: TRUTH
221221
show_result: False
222222
- "\n{{ CODE.source_code }}\n"
@@ -289,11 +289,11 @@ Finally, we can output JSON data as a result of this program, as follows:
289289
```yaml
290290
description: Code explanation example
291291
document:
292-
- read: examples/code/data.json
292+
- read: ./data.json
293293
parser: json
294294
def: CODE
295295
show_result: False
296-
- read: examples/code/ground_truth.txt
296+
- read: ./ground_truth.txt
297297
def: TRUTH
298298
show_result: False
299299
- model: ibm/granite-20b-code-instruct-v2

examples/arith/Arith-simple.pdl

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
description: Math Problems
22
document:
3-
- read: examples/arith/example1.txt
4-
- read: examples/arith/example2.txt
3+
- read: ./example1.txt
4+
- read: ./example2.txt
55
- "\n"
66
- |
77
Question: Noah charges $10 for a large box and $5 for a small box.

examples/code/code-defs.pdl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
description: Code explanation example
22
defs:
33
CODE:
4-
read: examples/code/data.yaml
4+
read: ./data.yaml
55
parser: yaml
66
def: CODE
77
EXPLANATION:

examples/code/code-eval.pdl

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
description: Code explanation example
22
document:
3-
- read: examples/code/data.yaml
3+
- read: ./data.yaml
44
parser: yaml
55
def: CODE
66
show_result: False
@@ -18,7 +18,7 @@ document:
1818
Explain the following code:
1919
```
2020
{{ CODE.source_code }}```
21-
- read: examples/code/ground_truth.txt
21+
- read: ./ground_truth.txt
2222
def: TRUTH
2323
show_result: False
2424
- |

examples/code/code-json.pdl

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
description: Code explanation example
22
document:
3-
- read: examples/code/data.yaml
3+
- read: ./data.yaml
44
parser: yaml
55
def: CODE
66
show_result: False
7-
- read: examples/code/ground_truth.txt
7+
- read: ./ground_truth.txt
88
def: TRUTH
99
show_result: False
1010
- model: ibm/granite-34b-code-instruct

examples/code/code.pdl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
description: Code explanation example
22
document:
3-
- read: examples/code/data.yaml
3+
- read: ./data.yaml
44
parser: yaml
55
def: CODE
66
show_result: False

examples/demo/1-gen-data.pdl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
description: Creating JSON Data
22
defs:
33
data:
4-
read: examples/demo/data.yaml
4+
read: ./data.yaml
55
parser: yaml
66
spec: { questions: [str], answers: [obj] }
77
document:

examples/demo/2-teacher.pdl

+1-1
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ defs:
369369
document:
370370
- "----- Loading seed examples -----\n\n"
371371
- def: seed_examples
372-
read: examples/teacher/qna.yaml
372+
read: ./qna.yaml
373373
parser: yaml
374374
- "\n\n----- Generating questions -----\n\n"
375375
- def: generated_questions

examples/granite/multi_round_chat.pdl

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
description: Granite Multi-Round Chat
22
document:
3-
- include: examples/granite/granite_defs.pdl
4-
- read: examples/granite/multi-prompts.json
3+
- include: ./granite_defs.pdl
4+
- read: ./multi-prompts.json
55
parser: json
66
def: prompts
77
spec: {prompts: [str]}

examples/granite/single_round_chat.pdl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
description: Granite Single-Round Chat
22
document:
3-
- include: examples/granite/granite_defs.pdl
3+
- include: ./granite_defs.pdl
44
- |
55
{{ SYSTEM_CONTENT_CHAT }}
66
{{ USER_TAG }}

examples/gsm8k/math-patterns.pdl

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ defs:
88
# cluster by similarity, or classify e.g. 5 classes that don't work
99

1010
document:
11-
- include: examples/prompt_library/ReWOO.pdl
12-
- include: examples/prompt_library/ReAct.pdl
13-
- include: examples/prompt_library/CoT.pdl
11+
- include: ../prompt_library/ReWOO.pdl
12+
- include: ../prompt_library/ReAct.pdl
13+
- include: ../prompt_library/CoT.pdl
1414
- def: filtered_tools
1515
call: filter_tools_by_name
1616
show_result: false

examples/hello/hello-parser-json.pdl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
description: Creating JSON Data
22
defs:
33
data:
4-
read: examples/hello/hello21_data.yaml
4+
read: ./hello21_data.yaml
55
parser: yaml
66
spec: { "questions": ["str"], "answers": ["obj"] }
77
document:

examples/input/input_test.pdl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
description: Hello world!
22
defs:
3-
file: examples/input/data.tx
3+
file: ./data.tx
44
document:
55
- read: "{{ file }}"
66
def: HELLO

examples/prompt_library/demos/CoT.pdl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
description: Demo of CoT template
22
document:
3-
- include: examples/prompt_library/CoT.pdl
3+
- include: ../CoT.pdl
44
- call: fewshot_cot
55
args:
66
examples:

examples/prompt_library/demos/PoT.pdl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
description: Demo of PoT template
22
document:
3-
- include: examples/prompt_library/PoT.pdl
3+
- include: ../PoT.pdl
44
- def: ANSWER
55
call: program_of_thought
66
args:

examples/prompt_library/demos/RAG.pdl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
description: Demo of RAG template
22
document:
3-
- include: examples/prompt_library/RAG.pdl
3+
- include: ../RAG.pdl
44
- call: corpus
55
args:
66
corpus:

examples/prompt_library/demos/ReAct.pdl

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ defs:
33
available_tools:
44
data: ["Search"]
55
document:
6-
- include: examples/prompt_library/tools.pdl
7-
- include: examples/prompt_library/ReAct.pdl
6+
- include: ../tools.pdl
7+
- include: ../ReAct.pdl
88
- def: filtered_tools
99
call: filter_tools_by_name
1010
show_result: false

examples/prompt_library/demos/ReWOO.pdl

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ defs:
33
available_tools:
44
data: ["Search"]
55
document:
6-
- include: examples/prompt_library/ReWOO.pdl
6+
- include: ../ReWOO.pdl
77
# - def: filtered_tools
88
# call: filter_tools_by_name
99
# show_result: false

examples/prompt_library/demos/Verifier.pdl

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ defs:
33
available_tools:
44
data: ["Search"]
55
document:
6-
- include: examples/prompt_library/ReAct.pdl
7-
- include: examples/granite/granite_defs.pdl
6+
- include: ../ReAct.pdl
7+
- include: ../../granite/granite_defs.pdl
88
- def: filtered_tools
99
call: filter_tools_by_name
1010
show_result: false

examples/prompt_library/demos/Verifier_json.pdl

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
document:
2-
- include: examples/prompt_library/tools.pdl
3-
- include: examples/prompt_library/ReAct.pdl
4-
- include: examples/granite/granite_defs.pdl
2+
- include: ../tools.pdl
3+
- include: ../ReAct.pdl
4+
- include: ../../granite/granite_defs.pdl
55
- def: filtered_tools
66
call: filter_tools_by_name
77
show_result: false

examples/prompt_library/demos/gsm8k/CoT.pdl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
description: Demo of CoT template
22
document:
3-
- include: examples/prompt_library/CoT.pdl
3+
- include: ../CoT.pdl
44
- call: chain_of_thought
55
args:
66
examples:

examples/prompt_library/demos/gsm8k/ReAct.pdl

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ defs:
2525
- thought: He sold $1200 this month.
2626
- action: Finish[$1200]
2727
document:
28-
- include: examples/prompt_library/tools.pdl
29-
- include: examples/prompt_library/ReAct.pdl
28+
- include: ../tools.pdl
29+
- include: ../ReAct.pdl
3030
- call: react
3131
args:
3232
question: "Jake earns thrice what Jacob does. If Jacob earns $6 per hour, how much does Jake earn in 5 days working 8 hours a day?"

examples/teacher/teacher.pdl

+1-1
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ defs:
369369
document:
370370
- "----- Loading seed examples -----\n\n"
371371
- def: seed_examples
372-
read: examples/teacher/qna.yaml
372+
read: ./qna.yaml
373373
parser: yaml
374374
- "\n\n----- Generating questions -----\n\n"
375375
- def: generated_questions

examples/tutorial/conditionals_loops.pdl

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
description: Arithmetic Expressions
22
document:
3-
- read: examples/arith/example1.txt
4-
- read: examples/arith/example2.txt
3+
- read: ./example1.txt
4+
- read: ./example2.txt
55
- repeat:
66
- "\nQuestion: "
77
- def: QUESTION

examples/tutorial/data.yaml

+16-13
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
questions:
2-
- >
3-
Question: Write a YAML object with 2 fields 'a' and 'b' of type int and set to 0.
4-
- >
5-
Question: Write a YAML object with 3 fields 'number' and 'street' and 'town' set to '10', 'Miller Road', 'Armonk' respectively.
6-
7-
answers:
8-
- a: 0
9-
b: 0
10-
11-
- number: 10
12-
street: miller Road
13-
town: armonk
1+
source_code:
2+
|
3+
@SuppressWarnings("unchecked")
4+
public static Map<String, String> deserializeOffsetMap(String lastSourceOffset) throws IOException {
5+
Map<String, String> offsetMap;
6+
if (lastSourceOffset == null || lastSourceOffset.isEmpty()) {
7+
offsetMap = new HashMap<>();
8+
} else {
9+
offsetMap = JSON_MAPPER.readValue(lastSourceOffset, Map.class);
10+
}
11+
return offsetMap;
12+
}
13+
repo_info:
14+
repo: streamsets/datacollector
15+
path: stagesupport/src/main/java/com/.../OffsetUtil.java
16+
function_name: OffsetUtil.deserializeOffsetMap

examples/tutorial/data_block.pdl

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
description: Code explanation example
22
document:
3-
- read: examples/code/data.json
3+
- read: ./data.json
44
parser: json
55
def: CODE
66
show_result: False
7-
- read: examples/code/ground_truth.txt
7+
- read: ./ground_truth.txt
88
def: TRUTH
99
show_result: False
1010
- model: ibm/granite-20b-code-instruct-v2

examples/tutorial/example1.txt

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Question: Noah charges $60 for a large painting and $30 for a small painting.
2+
Last month he sold eight large paintings and four small paintings.
3+
If he sold twice as much this month, how much is his sales for this month?
4+
5+
Answer: Let's think step by step.
6+
He sold 8 large paintings and 4 small paintings last month.
7+
He sold twice as many this month.
8+
8 large paintings x $60 = << 8*60= 480 >> 480
9+
4 small paintings x $30 = << 4*30= 120 >> 120
10+
So he sold << 480+120= 600 >> 600 paintings last month.
11+
Therefore he sold << 600*2= 1200 >> this month.
12+
The answer is $1200.
13+

examples/tutorial/example2.txt

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Question: Noah charges $10 for a small vase and $30 for a large vases
2+
Last month he sold five large vases and three small vases.
3+
If he sold three times as much this month, how much is his sales for this month?
4+
5+
Answer: Let's think step by step.
6+
He sold 5 large vases and 3 small vases last month.
7+
He sold three times as many this month.
8+
5 large vases x $30 = << 5*30= 150 >> 150
9+
3 small vases x $10 = << 3*10= 30 >> 30
10+
So he sold << 150+30= 180 >> 180 vases last month.
11+
Therefore he sold << 180*3= 540 >> this month.
12+
The answer is $540.

examples/tutorial/gen-data.pdl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
description: Creating JSON Data
22
defs:
33
data:
4-
read: examples/demo/data.yaml
4+
read: ../demo/data.yaml
55
parser: yaml
66
spec: { questions: [str], answers: [obj] }
77
document:

examples/tutorial/ground_truth.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The function `deserializeOffsetMap` takes a string as input and returns a map. It first checks if the input string is null or empty. If it is, it creates a new empty map and returns it. Otherwise, it uses the Jackson library to parse the input string into a map and returns it.
2+
3+
The `@SuppressWarnings("unchecked")` annotation is used to suppress the warning that the type of the parsed map is not checked. This is because the Jackson library is used to parse the input string into a map, but the specific type of the map is not known at compile time. Therefore, the warning is suppressed to avoid potential issues.

examples/tutorial/input_file.pdl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
description: PDL code with input block
22
document:
3-
- read: examples/input/data.txt
3+
- read: ./data.txt
44
def: HELLO

examples/tutorial/input_file_json.pdl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
description: Input block example with json input
22
document:
3-
- read: examples/tutorial/input.json
3+
- read: ./input.json
44
parser: json
55
def: PERSON
66
show_result: false

0 commit comments

Comments
 (0)