Skip to content

Commit fada2d7

Browse files
committed
Merge branch 'main' into pdl-250
2 parents ccd4220 + cdd6a6f commit fada2d7

Some content is hidden

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

43 files changed

+1967
-2031
lines changed

.github/workflows/tauri-cli.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
# 3. `run` subcommand works with UI demos (json source)
5252
# demo8 uses a private model? not sure
5353
for i in ./src/demos/*.json
54-
do if [[ $(basename $i) != "demo8.json" ]]; then pdl run $i; fi
54+
do if [[ $(basename $i) != "demo8.json" ]] && [[ $(basename $i) != "demo9.json" ]]; then pdl run $i; fi
5555
done
5656
5757
- name: Tear down xvfb

examples/gsm8k/gsm8.pdl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#
99
#
1010

11-
description: Grade School Math example
11+
description: Grade School Math
1212
defs:
1313
# The Grade School Math Dataset
1414
ALL_TESTS:

examples/gsm8k/gsm8k-plan.pdl

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
description: Grade School Math -- for every problem we generate a plan, then exectute and evaluate it.
2+
defs:
3+
problems:
4+
read: ./test.jsonl
5+
parser: jsonl
6+
7+
MAX_ITERATIONS: 50
8+
9+
planning:
10+
function:
11+
problem: str
12+
return:
13+
text:
14+
- >
15+
Please generate a high-level plan for solving the following question.
16+
As the first step, just say what method and idea you will use to solve the question.
17+
You can reorganize the information in the question. Do not do the actual calculation.
18+
Keep your response concise and within 80 words.
19+
Question:
20+
- ${ problem }
21+
- "\nThe plan is:\n"
22+
- model: ollama/granite3.2:8b
23+
24+
solve:
25+
function:
26+
plan: str
27+
return:
28+
text:
29+
- ${ plan }
30+
- >
31+
The plan looks good! Now, use real numbers and do the calculation. Please solve the question
32+
step-by-step according to the high-level plan. Give me the final answer. Make your response short.
33+
- "\nThe answer is:\n"
34+
- model: ollama/granite3.2:8b
35+
36+
extract_final_answer:
37+
function:
38+
solution: str
39+
return:
40+
lastOf:
41+
- ${ solution }
42+
- Extract the result from the above solution into a JSON object with field "result" and a float as value. Remove any dollar signs or other symbols.
43+
- model: ollama/granite3.2:8b
44+
parser: json
45+
def: result
46+
spec: { "result": float }
47+
fallback:
48+
data:
49+
result: 0
50+
51+
compare_to_ground_truth:
52+
function:
53+
result: obj
54+
truth: str
55+
return:
56+
lastOf:
57+
- data: ${ truth }
58+
parser:
59+
regex: "(.|\n)*#### (?P<answer>([0-9])*)\n*"
60+
spec:
61+
answer: str
62+
def: ground_truth
63+
- if: ${ result.result|float == ground_truth.answer|float}
64+
then:
65+
1
66+
else:
67+
0
68+
69+
text:
70+
- for:
71+
problem: ${ problems }
72+
repeat:
73+
call: ${ planning }
74+
args:
75+
pdl_context: []
76+
problem: ${ problem.question }
77+
max_iterations: ${ MAX_ITERATIONS }
78+
def: plans
79+
join:
80+
as: array
81+
82+
- for:
83+
plan: ${ plans }
84+
repeat:
85+
call: ${ solve }
86+
args:
87+
pdl_context: []
88+
plan: ${ plan }
89+
max_iterations: ${ MAX_ITERATIONS }
90+
def: solutions
91+
join:
92+
as: array
93+
94+
- for:
95+
solution: ${ solutions }
96+
repeat:
97+
call: ${ extract_final_answer }
98+
args:
99+
pdl_context: []
100+
solution: ${ solution }
101+
max_iterations: ${ MAX_ITERATIONS }
102+
def: results
103+
join:
104+
as: array
105+
106+
- for:
107+
result: ${ results }
108+
problem: ${ problems[:MAX_ITERATIONS] }
109+
repeat:
110+
call: ${ compare_to_ground_truth }
111+
args:
112+
pdl_context: []
113+
result: ${ result }
114+
truth: ${ problem.answer }
115+
max_iterations: ${ MAX_ITERATIONS }
116+
def: stats
117+
join:
118+
as: array
119+
120+
- "\nAccuracy: ${ stats|sum / MAX_ITERATIONS * 100}% "

examples/tools/calc.pdl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ text:
2020
model: replicate/ibm-granite/granite-3.1-8b-instruct
2121
parser: json
2222
spec: [{ name: str, arguments: { expr: str }}]
23+
parameters:
24+
drop_params: true # This is needed because the model does not support structured decoding. It directs LiteLLM to ignore parameters sent for structured decoding.
2325
- "\n"
2426
- if: ${ actions[0].name == "calc" }
2527
then:

pdl-live-react/demos/run.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@ EOF
1717
pdl --trace "$T"/demo5.json "$TOP"/examples/talk/6-code-json.pdl
1818
pdl --trace "$T"/demo6.json "$UI"/demos/error.pdl || true
1919
pdl --trace "$T"/demo7.json "$TOP"/examples/talk/4-function.pdl
20+
# TODO demo8...
21+
exit
22+
pdl --stream none --trace "$T"/demo9.json "$TOP"/examples/gsm8k/gsm8.pdl

0 commit comments

Comments
 (0)