Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c45f3a0

Browse files
committed
Merge remote-tracking branch 'upstream/main' into docs
2 parents b558e16 + c30472e commit c45f3a0

Some content is hidden

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

65 files changed

+1656
-14737
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -50,22 +50,3 @@ jobs:
5050
run: py.test -v --capture=tee-sys --ignore=tests/test_examples_run.py tests
5151
if: matrix.python-version != '3.11'
5252

53-
viewer:
54-
name: Build PDL live viewer
55-
runs-on: ubuntu-latest
56-
needs: tests
57-
defaults:
58-
run:
59-
working-directory: ./pdl-live
60-
steps:
61-
- uses: actions/checkout@v4
62-
- name: Set up node
63-
uses: actions/setup-node@v4
64-
with:
65-
node-version: 22
66-
- name: Install dependencies
67-
run: npm install
68-
- name: Generate pdl_ast.d.ts
69-
run: npx json2ts ../src/pdl/pdl-schema.json src/pdl_ast.d.ts --unreachableDefinitions
70-
- name: Build viewer
71-
run: npm run build

.github/workflows/mkdocs-gh-pages.yml

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
paths:
1010
- "mkdocs.yml"
1111
- "docs/**"
12-
- "pdl-live"
12+
- "pdl-live-react"
1313

1414
# Allows you to run this workflow manually from the Actions tab
1515
workflow_dispatch:
@@ -33,25 +33,6 @@ jobs:
3333
steps:
3434
- name: Checkout
3535
uses: actions/checkout@v4
36-
# Viewer
37-
- name: Set up node
38-
uses: actions/setup-node@v4
39-
with:
40-
node-version: 22
41-
- name: Install dependencies
42-
working-directory: ./pdl-live
43-
run: npm install
44-
- name: Generate pdl_ast.d.ts
45-
working-directory: ./pdl-live
46-
run: npx json2ts ../src/pdl/pdl-schema.json src/pdl_ast.d.ts --unreachableDefinitions
47-
- name: Build viewer
48-
working-directory: ./pdl-live
49-
run: npm run build
50-
- name: Copy viewer
51-
working-directory: ./pdl-live
52-
run: cp ./dist/bundle.js ../docs/dist/bundle.js
53-
- name: Copy schema
54-
run: cp ./src/pdl/pdl-schema.json ./docs/dist/pdl-schema.json
5536
# Docs
5637
- name: Setup Pages
5738
uses: actions/configure-pages@v5

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ pdl-live/package-lock.json
151151
*_result.yaml
152152
*_trace.json
153153

154+
# Demo files
155+
pdl-rag-demo.db
156+
154157
# Built docs
155158
_site
156159

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ text:
3636
- "write a hello world example\n"
3737
- model: ollama/granite-code:8b
3838
parameters:
39-
stop_sequences: '!'
39+
stop: ['!']
4040
temperature: 0
4141
```
4242
192 KB
Binary file not shown.
-163 KB
Loading

docs/dist/bundle.js

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

docs/viewer.md

Lines changed: 16 additions & 177 deletions
Original file line numberDiff line numberDiff line change
@@ -2,184 +2,23 @@
22
hide:
33
- navigation
44
- toc
5+
- footer
56
---
6-
# PDL Live Viewer
7-
8-
!!! note
9-
This is the PDL Live Document viewer. The left pane contains the final result of the program, and upon interaction, the right pane displays the code that created that part of the document, along with a breakdown of the PDL blocks on the left pane.
10-
To use the tool, upload a json using the following command:
11-
pdl --trace myresult.json myexample.pdl
127

138
<style>
14-
.pdl_block {
15-
border-radius: 3px;
16-
margin: 3px;
17-
padding: 5px;
18-
margin: 2px;
19-
vertical-align: middle;
20-
display: inline-block;
21-
}
22-
.pdl_show_result_false {
23-
color: rgba(0, 0, 0, 0.5);
24-
}
25-
.pdl_string {
26-
background-color: antiquewhite;
27-
}
28-
.pdl_empty {
29-
background-color: rgb(238, 184, 112);
30-
}
31-
.pdl_text {
32-
background-color: rgb(219, 215, 250);
33-
}
34-
.pdl_model {
35-
background-color: rgb(215, 250, 224);
36-
}
37-
.pdl_code {
38-
background-color: rgb(250, 215, 225);
39-
}
40-
.pdl_api {
41-
background-color: rgb(122, 246, 113);
42-
}
43-
.pdl_get {
44-
background-color: rgb(125, 229, 243);
45-
}
46-
.pdl_data {
47-
background-color: rgb(146, 181, 245);
48-
}
49-
.pdl_if {
50-
background-color: rgb(248, 99, 141);
51-
}
52-
.pdl_repeat {
53-
background-color: rgb(251, 201, 86);
54-
}
55-
.pdl_read {
56-
background-color: rgb(243, 77, 113);
57-
}
58-
.pdl_include {
59-
background-color: rgb(245, 18, 67);
60-
}
61-
.pdl_function {
62-
background-color: rgb(77, 243, 132);
63-
}
64-
.pdl_call {
65-
background-color: rgb(80, 243, 77);
66-
}
9+
.md-typeset {
10+
margin: 0;
11+
padding: 0;
12+
}
13+
.md-grid {margin-top: 0;}
14+
.md-typeset > h1,
15+
.md-content__button {
16+
display: none;
17+
}
18+
iframe {
19+
width: 100%;
20+
min-height: 800px; /* TODO */
21+
}
6722
</style>
68-
<!-- Main script -->
69-
<script src="../dist/bundle.js"></script>
70-
<!-- Multi column layout -->
71-
<link rel="stylesheet" type="text/css" href="https://rawgit.com/vitmalina/w2ui/master/dist/w2ui.min.css">
72-
<!-- Main window -->
73-
<div id="mainview">
74-
<!-- Main window layout -->
75-
<input type="file" name="input_file" id="input_file">
76-
<script type="text/javascript">
77-
document.getElementById('input_file')
78-
.addEventListener('change', function () {
79-
let fr = new FileReader();
80-
fr.onload = function () {
81-
data = JSON.parse(fr.result)
82-
pdl_viewer.replace_div('doc', pdl_viewer.show_output(data))
83-
}
84-
fr.readAsText(this.files[0]);
85-
})
86-
</script>
87-
<div id="layout" style="height: 900px;"></div>
88-
<script type="module">
89-
import { w2layout } from 'https://rawgit.com/vitmalina/w2ui/master/dist/w2ui.es6.min.js'
90-
let pstyle = 'border: 1px solid #efefef; padding: 5px'
91-
new w2layout({
92-
box: '#layout',
93-
name: 'layout',
94-
panels: [
95-
{ type: 'left', size: 600, resizable: true, style: pstyle, html: '<div id="doc"></div>' },
96-
{ type: 'main', style: pstyle, html: '<div id="code">Please click on a word on the left to get started.</div>' }
97-
]
98-
})
99-
</script>
100-
<script type="text/javascript">
101-
const example = {
102-
"kind": "text",
103-
"description": "Teaching PDL",
104-
"defs": {},
105-
"text": [{
106-
"kind": "read",
107-
"defs": {},
108-
"read": null,
109-
"message": null,
110-
"multiline": true,
111-
"def": "QUERY",
112-
"show_result": false,
113-
"result": "Bobby had 3 apples. He then added 2. Hence 3 + 2 = 5 How many apple did Bobby have?\n",
114-
}, {
115-
"kind": "model",
116-
"defs": {},
117-
"model": "ibm/granite-20b-code-instruct-v2",
118-
"input": {
119-
"kind": "text",
120-
"defs": {},
121-
"text": ["Question: Replace all arithmetic expressions by surrounding them with << >>\nBob had 5 + 2 apples. He ate all them and bought 8 * 67 skittles.\nHe wanted to distribute those among all of 10 children. So each kid\ngot a grand total of 8 * 67 / 10 skittle. Amazing!\n\nAnswer:\nBob had << 5 + 2 >> apples. He ate all them and bought << 8 * 67 >> skittles.\nHe wanted to distribute those among all of 10 children. So each kid\ngot a grand total of << 8 * 67 / 10 >> skittle. Amazing!\n\nQuestion:\nThe world contains lots of soccer balls. Each team has 5 soccer balls per kid.\nThis team has 30 kids, so the team has 5 * 30 soccer balls.\n\nAnswer:\nThe world contains lots of soccer balls. Each team has 5 soccer balls per kid.\nThis team has 30 kids, so the team has << 5 * 30 >> soccer balls.\n\nQuestion:\nWhat is 5 + 2?\n\nAnswer:\nWhat is << 5 + 2 >>?\n\nQuestion:", {
122-
"kind": "get",
123-
"defs": {},
124-
"get": "QUERY",
125-
"result": "Bobby had 3 apples. He then added 2. Hence 3 + 2 = 5 How many apple did Bobby have?\n",
126-
}, "\n\n"],
127-
"result": "Question: Replace all arithmetic expressions by surrounding them with << >>\nBob had 5 + 2 apples. He ate all them and bought 8 * 67 skittles.\nHe wanted to distribute those among all of 10 children. So each kid\ngot a grand total of 8 * 67 / 10 skittle. Amazing!\n\nAnswer:\nBob had << 5 + 2 >> apples. He ate all them and bought << 8 * 67 >> skittles.\nHe wanted to distribute those among all of 10 children. So each kid\ngot a grand total of << 8 * 67 / 10 >> skittle. Amazing!\n\nQuestion:\nThe world contains lots of soccer balls. Each team has 5 soccer balls per kid.\nThis team has 30 kids, so the team has 5 * 30 soccer balls.\n\nAnswer:\nThe world contains lots of soccer balls. Each team has 5 soccer balls per kid.\nThis team has 30 kids, so the team has << 5 * 30 >> soccer balls.\n\nQuestion:\nWhat is 5 + 2?\n\nAnswer:\nWhat is << 5 + 2 >>?\n\nQuestion:Bobby had 3 apples. He then added 2. Hence 3 + 2 = 5 How many apple did Bobby have?\n\n\n",
128-
"parameters": {
129-
"decoding_method": "greedy",
130-
"max_new_tokens": 1024,
131-
"min_new_tokens": 1,
132-
"repetition_penalty": 1.05
133-
},
134-
"def": "QUERY1",
135-
"show_result": false,
136-
"result": "\nAnswer:\nBobby had 3 apples. He then added 2. Hence 3 + 2 = 5 How many apple did Bobby have?",
137-
}, {
138-
"kind": "model",
139-
"defs": {},
140-
"model": "ibm/granite-20b-code-instruct-v2",
141-
"input": {
142-
"kind": "text",
143-
"defs": {},
144-
"text": ["Question: Write the following prompts in PDL:\nHello world!\nThis is your first prompt descriptor!\n\nAnswer:\n```\ndescription: Hello world!\ntext:\n- \"Hello, world!\\n\"\n- \"This is your first prompt descriptor!\\n\" \n```\n\nQuestion: Turn the code into PDL:\ncontents = []\nwhile True:\ntry:\n line = input()\nexcept EOFError:\n break\ncontents.append(line + \"\\n\")\nresult = ''.join(contents)\n\nAnswer:\n```\ndescription: Example of PDL code block\ntext:\n- lang: python\n code:\n - |\n contents = []\n while True:\n try:\n line = input()\n except EOFError:\n break\n contents.append(line + \"\\n\")\n result = ''.join(contents)\n```\n\nQuestion: Write the following in PDL where the parts in << >> are done in Python.\nHello world!\nThis is your << expr >> prompt descriptor!\n\nAnswer:\n```\ndescription: Hello world!\ntext:\n- \"Hello, world!\\n\"\n- \"This is your \"\n- lang: python\n code:\n - |\n result = expr\n- \" prompt descriptor!\"\n```\nQuestion: Write the following in PDL where the parts in << >> are done in Python.\nWhat is << 67+ 67 - 78 + 2 >>\n\nAnswer:\n```\ndescription: Hello world!\ntext:\n- \"What is \"\n- lang: python\n code:\n - |\n result = 67+ 67 - 78 + 2\n```\n\n\nQuestion: Write the following in PDL with parts << >> written in Python", {
145-
"kind": "get",
146-
"defs": {},
147-
"get": "QUERY1",
148-
"result": "\nAnswer:\nBobby had 3 apples. He then added 2. Hence 3 + 2 = 5 How many apple did Bobby have?",
149-
}, "\n\n"],
150-
"result": "Question: Write the following prompts in PDL:\nHello world!\nThis is your first prompt descriptor!\n\nAnswer:\n```\ndescription: Hello world!\ntext:\n- \"Hello, world!\\n\"\n- \"This is your first prompt descriptor!\\n\" \n```\n\nQuestion: Turn the code into PDL:\ncontents = []\nwhile True:\ntry:\n line = input()\nexcept EOFError:\n break\ncontents.append(line + \"\\n\")\nresult = ''.join(contents)\n\nAnswer:\n```\ndescription: Example of PDL code block\ntext:\n- lang: python\n code:\n - |\n contents = []\n while True:\n try:\n line = input()\n except EOFError:\n break\n contents.append(line + \"\\n\")\n result = ''.join(contents)\n```\n\nQuestion: Write the following in PDL where the parts in << >> are done in Python.\nHello world!\nThis is your << expr >> prompt descriptor!\n\nAnswer:\n```\ndescription: Hello world!\ntext:\n- \"Hello, world!\\n\"\n- \"This is your \"\n- lang: python\n code:\n - |\n result = expr\n- \" prompt descriptor!\"\n```\nQuestion: Write the following in PDL where the parts in << >> are done in Python.\nWhat is << 67+ 67 - 78 + 2 >>\n\nAnswer:\n```\ndescription: Hello world!\ntext:\n- \"What is \"\n- lang: python\n code:\n - |\n result = 67+ 67 - 78 + 2\n```\n\n\nQuestion: Write the following in PDL with parts << >> written in Python\nAnswer:\nBobby had 3 apples. He then added 2. Hence 3 + 2 = 5 How many apple did Bobby have?\n\n",
151-
},
152-
"parameters": {
153-
"decoding_method": "greedy",
154-
"max_new_tokens": 1024,
155-
"min_new_tokens": 1,
156-
"repetition_penalty": 1.05
157-
},
158-
"def": "PDL",
159-
"show_result": false,
160-
"result": "\nAnswer:\n```\ndescription: Bobby had 3 apples. He then added 2. Hence 3 + 2 = 5 How many apple did Bobby have?\ntext:\n- \"Bobby had 3 apples. He then added 2. Hence 3 + 2 = 5 How many apple did Bobby have?\"\n```",
161-
}, {
162-
"kind": "code",
163-
"defs": {},
164-
"lang": "python",
165-
"code": ["from pdl import pdl_ast, pdl_interpreter\nfrom pdl.pdl_ast import Program\nfrom pdl.pdl_interpreter import process_prog\nfrom pdl.pdl_interpreter import InterpreterState\nfrom pdl.pdl_interpreter import empty_scope\nimport re\nimport yaml\ns = \"\"\"'\n", {
166-
"kind": "get",
167-
"defs": {},
168-
"get": "PDL",
169-
"result": "\nAnswer:\n```\ndescription: Bobby had 3 apples. He then added 2. Hence 3 + 2 = 5 How many apple did Bobby have?\ntext:\n- \"Bobby had 3 apples. He then added 2. Hence 3 + 2 = 5 How many apple did Bobby have?\"\n```",
170-
}, "'\"\"\"\npdl = s.split(\"```\")[1]\nobj = yaml.safe_load(pdl)\nstate = InterpreterState()\ndata = Program.model_validate(obj)\n_, result, _, _ = process_prog(state, empty_scope, data)\n"],
171-
"def": "RESULT",
172-
"result": "Bobby had 3 apples. He then added 2. Hence 3 + 2 = 5 How many apple did Bobby have?",
173-
}, "\n", {
174-
"kind": "model",
175-
"defs": {},
176-
"model": "ibm/granite-13b-instruct-v2",
177-
"result": "5",
178-
}],
179-
"result": "Bobby had 3 apples. He then added 2. Hence 3 + 2 = 5 How many apple did Bobby have?\n5",
180-
}
181-
window.addEventListener("load", function () {
182-
pdl_viewer.replace_div('doc', pdl_viewer.show_output(example))
183-
});
184-
</script>
185-
</div>
23+
24+
<iframe src="https://pdl.s3-web.us-east.cloud-object-storage.appdomain.cloud/" frameborder="0" height="100%"></iframe>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
description: Hello world with function definition and call
2+
text:
3+
- def: hello
4+
function:
5+
name: str
6+
return:
7+
text:
8+
- Hello ${ name }!
9+
- model: ollama_chat/granite3-dense:8b
10+
- call: ${ hello }
11+
args:
12+
name: World
13+
pdl_context: []
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
defs:
3+
b:
4+
function:
5+
arg: str
6+
return:
7+
${ arg }
8+
9+
a:
10+
function:
11+
arg: str
12+
return:
13+
call: ${ b }
14+
args:
15+
pdl_context: []
16+
arg: ${ arg }

0 commit comments

Comments
 (0)