Skip to content

Commit 6cde7d8

Browse files
committed
Merge branch 'main' into pdl-182
2 parents 8e2ef13 + 53004df commit 6cde7d8

File tree

130 files changed

+1414
-514
lines changed

Some content is hidden

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

130 files changed

+1414
-514
lines changed

README.md

Lines changed: 130 additions & 396 deletions
Large diffs are not rendered by default.

docs/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,28 @@ in the right pane.
438438
439439
This is similar to a spreadsheet for tabular data, where data is in the forefront and the user can inspect the formula that generates the data in each cell. In the Live Document, cells are not uniform but can take arbitrary extents. Clicking on them similarly reveals the part of the code that produced them.
440440
441+
## Best Practices
442+
443+
1. **Template Organization**:
444+
- Keep templates modular and reusable
445+
- Use variables for dynamic content
446+
- Document template purpose and requirements
447+
448+
2. **Error Handling**:
449+
- Validate model inputs/outputs
450+
- Include fallback logic
451+
- Log intermediate results
452+
453+
3. **Performance**:
454+
- Cache frequent LLM calls
455+
- Use appropriate temperature settings
456+
- Implement retry logic for API calls
457+
458+
4. **Security**:
459+
- Enabling sandbox mode for untrusted code
460+
- Validate all inputs
461+
- Follow API key best practices
462+
441463
442464
## Additional Notes
443465

pdl-live/index.html

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@
3333
background-color: rgb(219, 215, 250);
3434
}
3535

36+
.pdl_lastOf {
37+
background-color: rgb(186, 186, 190);
38+
}
39+
40+
.pdl_object {
41+
background-color: rgb(188, 188, 254);
42+
}
43+
44+
.pdl_array {
45+
background-color: rgb(149, 149, 241);
46+
}
47+
3648
.pdl_model {
3749
background-color: rgb(215, 250, 224);
3850
}
@@ -54,7 +66,7 @@
5466
}
5567

5668
.pdl_if {
57-
background-color: rgb(248, 99, 141);
69+
background-color: rgb(253, 167, 5);
5870
}
5971

6072
.pdl_repeat {
@@ -70,11 +82,11 @@
7082
}
7183

7284
.pdl_read {
73-
background-color: rgb(243, 77, 113);
85+
background-color: rgb(5, 204, 61);
7486
}
7587

7688
.pdl_include {
77-
background-color: rgb(245, 18, 67);
89+
background-color: rgb(11, 251, 87);
7890
}
7991

8092
.pdl_function {
@@ -83,7 +95,9 @@
8395
.pdl_call {
8496
background-color: rgb(80, 243, 77);
8597
}
86-
98+
.pdl_error {
99+
background-color: rgb(243, 0, 0);
100+
}
87101
</style>
88102

89103
<!-- Main script -->

src/pdl/pdl-schema.json

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -449,9 +449,6 @@
449449
"kind": {
450450
"const": "array",
451451
"default": "array",
452-
"enum": [
453-
"array"
454-
],
455452
"title": "Kind",
456453
"type": "string"
457454
},
@@ -1072,9 +1069,6 @@
10721069
"kind": {
10731070
"const": "model",
10741071
"default": "model",
1075-
"enum": [
1076-
"model"
1077-
],
10781072
"title": "Kind",
10791073
"type": "string"
10801074
},
@@ -1348,9 +1342,6 @@
13481342
},
13491343
"platform": {
13501344
"const": "bam",
1351-
"enum": [
1352-
"bam"
1353-
],
13541345
"title": "Platform",
13551346
"type": "string"
13561347
},
@@ -2089,9 +2080,6 @@
20892080
"kind": {
20902081
"const": "call",
20912082
"default": "call",
2092-
"enum": [
2093-
"call"
2094-
],
20952083
"title": "Kind",
20962084
"type": "string"
20972085
},
@@ -2730,9 +2718,6 @@
27302718
"kind": {
27312719
"const": "code",
27322720
"default": "code",
2733-
"enum": [
2734-
"code"
2735-
],
27362721
"title": "Kind",
27372722
"type": "string"
27382723
},
@@ -3390,9 +3375,6 @@
33903375
"kind": {
33913376
"const": "data",
33923377
"default": "data",
3393-
"enum": [
3394-
"data"
3395-
],
33963378
"title": "Kind",
33973379
"type": "string"
33983380
},
@@ -3876,9 +3858,6 @@
38763858
"kind": {
38773859
"const": "empty",
38783860
"default": "empty",
3879-
"enum": [
3880-
"empty"
3881-
],
38823861
"title": "Kind",
38833862
"type": "string"
38843863
}
@@ -4334,9 +4313,6 @@
43344313
"kind": {
43354314
"const": "error",
43364315
"default": "error",
4337-
"enum": [
4338-
"error"
4339-
],
43404316
"title": "Kind",
43414317
"type": "string"
43424318
},
@@ -4963,9 +4939,6 @@
49634939
"kind": {
49644940
"const": "for",
49654941
"default": "for",
4966-
"enum": [
4967-
"for"
4968-
],
49694942
"title": "Kind",
49704943
"type": "string"
49714944
},
@@ -5794,9 +5767,6 @@
57945767
"kind": {
57955768
"const": "function",
57965769
"default": "function",
5797-
"enum": [
5798-
"function"
5799-
],
58005770
"title": "Kind",
58015771
"type": "string"
58025772
},
@@ -6444,9 +6414,6 @@
64446414
"kind": {
64456415
"const": "get",
64466416
"default": "get",
6447-
"enum": [
6448-
"get"
6449-
],
64506417
"title": "Kind",
64516418
"type": "string"
64526419
},
@@ -6911,9 +6878,6 @@
69116878
"kind": {
69126879
"const": "if",
69136880
"default": "if",
6914-
"enum": [
6915-
"if"
6916-
],
69176881
"title": "Kind",
69186882
"type": "string"
69196883
},
@@ -7723,9 +7687,6 @@
77237687
"kind": {
77247688
"const": "include",
77257689
"default": "include",
7726-
"enum": [
7727-
"include"
7728-
],
77297690
"title": "Kind",
77307691
"type": "string"
77317692
},
@@ -7910,9 +7871,6 @@
79107871
"as": {
79117872
"const": "array",
79127873
"description": "Return the result of each iteration as an array.\n ",
7913-
"enum": [
7914-
"array"
7915-
],
79167874
"title": "As",
79177875
"type": "string"
79187876
}
@@ -7929,9 +7887,6 @@
79297887
"as": {
79307888
"const": "lastOf",
79317889
"description": "Return the result of the last iteration.\n ",
7932-
"enum": [
7933-
"lastOf"
7934-
],
79357890
"title": "As",
79367891
"type": "string"
79377892
}
@@ -7949,9 +7904,6 @@
79497904
"const": "text",
79507905
"default": "text",
79517906
"description": "String concatenation of the result of each iteration.\n ",
7952-
"enum": [
7953-
"text"
7954-
],
79557907
"title": "As",
79567908
"type": "string"
79577909
},
@@ -8414,9 +8366,6 @@
84148366
"kind": {
84158367
"const": "lastOf",
84168368
"default": "lastOf",
8417-
"enum": [
8418-
"lastOf"
8419-
],
84208369
"title": "Kind",
84218370
"type": "string"
84228371
},
@@ -9071,9 +9020,6 @@
90719020
"kind": {
90729021
"const": "model",
90739022
"default": "model",
9074-
"enum": [
9075-
"model"
9076-
],
90779023
"title": "Kind",
90789024
"type": "string"
90799025
},
@@ -9348,9 +9294,6 @@
93489294
"platform": {
93499295
"const": "litellm",
93509296
"default": "litellm",
9351-
"enum": [
9352-
"litellm"
9353-
],
93549297
"title": "Platform",
93559298
"type": "string"
93569299
},
@@ -10277,9 +10220,6 @@
1027710220
"kind": {
1027810221
"const": "message",
1027910222
"default": "message",
10280-
"enum": [
10281-
"message"
10282-
],
1028310223
"title": "Kind",
1028410224
"type": "string"
1028510225
},
@@ -11174,9 +11114,6 @@
1117411114
"kind": {
1117511115
"const": "object",
1117611116
"default": "object",
11177-
"enum": [
11178-
"object"
11179-
],
1118011117
"title": "Kind",
1118111118
"type": "string"
1118211119
},
@@ -12512,9 +12449,6 @@
1251212449
"kind": {
1251312450
"const": "read",
1251412451
"default": "read",
12515-
"enum": [
12516-
"read"
12517-
],
1251812452
"title": "Kind",
1251912453
"type": "string"
1252012454
},
@@ -13056,9 +12990,6 @@
1305612990
"kind": {
1305712991
"const": "repeat",
1305812992
"default": "repeat",
13059-
"enum": [
13060-
"repeat"
13061-
],
1306212993
"title": "Kind",
1306312994
"type": "string"
1306412995
},
@@ -13879,9 +13810,6 @@
1387913810
"kind": {
1388013811
"const": "repeat_until",
1388113812
"default": "repeat_until",
13882-
"enum": [
13883-
"repeat_until"
13884-
],
1388513813
"title": "Kind",
1388613814
"type": "string"
1388713815
},
@@ -14707,9 +14635,6 @@
1470714635
"kind": {
1470814636
"const": "text",
1470914637
"default": "text",
14710-
"enum": [
14711-
"text"
14712-
],
1471314638
"title": "Kind",
1471414639
"type": "string"
1471514640
},

src/pdl/pdl_ast.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"""
33

44
from enum import StrEnum
5-
from typing import Any, Literal, Optional, TypeAlias, Union
5+
from typing import Any, Literal, Optional, Sequence, TypeAlias, Union
66

77
import strictyaml
88
from genai.schema import (
@@ -129,7 +129,7 @@ class Block(BaseModel):
129129
assign: Optional[str] = Field(default=None, alias="def")
130130
"""Name of the variable used to store the result of the execution of the block.
131131
"""
132-
contribute: list[ContributeTarget | dict[ContributeTarget, ContributeValue]] = [
132+
contribute: Sequence[ContributeTarget | dict[str, ContributeValue]] = [
133133
ContributeTarget.RESULT,
134134
ContributeTarget.CONTEXT,
135135
]

src/pdl/pdl_interpreter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ def step_block(
306306

307307

308308
def context_in_contribute(block: AdvancedBlockType) -> bool:
309-
if ContributeTarget.CONTEXT in block.contribute:
309+
if ContributeTarget.CONTEXT.value in block.contribute:
310310
return True
311311
if get_contribute_value(block.contribute) is not None:
312312
return True

src/pdl/pdl_utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
from typing import Sequence
23

34
from .pdl_ast import ContributeTarget, ContributeValue, FunctionBlock, Message, Messages
45

@@ -17,7 +18,7 @@ def stringify(result):
1718

1819

1920
def replace_contribute_value(
20-
contribute: list[ContributeTarget | dict[ContributeTarget, ContributeValue]],
21+
contribute: Sequence[ContributeTarget | dict[str, ContributeValue]],
2122
value: ContributeValue,
2223
):
2324
ret = []
@@ -31,7 +32,7 @@ def replace_contribute_value(
3132

3233

3334
def get_contribute_value(
34-
contribute: list[ContributeTarget | dict[ContributeTarget, ContributeValue]] | None
35+
contribute: Sequence[ContributeTarget | dict[str, ContributeValue]] | None
3536
):
3637
if contribute is None:
3738
return None

0 commit comments

Comments
 (0)