Skip to content

Commit 3bd82cc

Browse files
committed
example
Signed-off-by: Mandana Vaziri <[email protected]>
1 parent e5dfb97 commit 3bd82cc

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ jobs:
4444
- name: pre-commit checks
4545
run: pre-commit run -a
4646
- name: run tests
47-
run: py.test -v --capture=tee-sys --ignore=tests/test_examples_run.py --ignore=tests/test_schema.py tests
47+
run: py.test -v --capture=tee-sys --ignore=tests/test_examples_run.py --ignore=tests/test_optimizer.py --ignore=tests/test_schema.py tests
4848
if: matrix.python-version == '3.11'
4949
- name: run tests
50-
run: py.test -v --capture=tee-sys --ignore=tests/test_examples_run.py tests
50+
run: py.test -v --capture=tee-sys --ignore=tests/test_examples_run.py --ignore=tests/test_optimizer.py tests
5151
if: matrix.python-version != '3.11'
5252

examples/tutorial/test.pdl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
defs:
2+
m1:
3+
content: Hello
4+
m2:
5+
content: Bye
6+
m3:
7+
content: Hello again
8+
9+
mycontext: ${ (m1 + m2) * m3 }
10+
11+
text:
12+
- model: ollama_chat/granite3.2:2b
13+
input: ${ mycontext }
14+
- ${ mycontext }

src/pdl/pdl_context.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@
44

55
from .pdl_lazy import PdlApply, PdlDict, PdlLazy, PdlList
66

7+
# def _default(self, obj):
8+
# return getattr(obj.__class__, "to_json", _default.default)(obj) # pyright: ignore
9+
10+
# _default.default = JSONEncoder().default # pyright: ignore
11+
# JSONEncoder.default = _default # pyright: ignore
12+
13+
# TODO:
14+
# We could make only DependentContext implement Sequence, IndependentContext could implement Set instead. Review how getItem should be implemented.
15+
# Should single message (result of a block) be flattened in the interpreter?
16+
# Serialization
17+
718

819
class SerializeMode(StrEnum):
920
LITELLM = "litellm"
@@ -27,6 +38,9 @@ def __len__(self):
2738
def __getitem__(self, index: int | slice): # pyright: ignore
2839
return []
2940

41+
# def to_json(self):
42+
# return json.dumps(self.serialize(SerializeMode.LITELLM))
43+
3044

3145
class SingletonContext(PDLContext):
3246
message: PdlLazy[dict[str, Any]]

0 commit comments

Comments
 (0)