diff --git a/src/pdl/pdl-schema.json b/src/pdl/pdl-schema.json index a3fb10088..88290ad2c 100644 --- a/src/pdl/pdl-schema.json +++ b/src/pdl/pdl-schema.json @@ -449,9 +449,6 @@ "kind": { "const": "array", "default": "array", - "enum": [ - "array" - ], "title": "Kind", "type": "string" }, @@ -1072,9 +1069,6 @@ "kind": { "const": "model", "default": "model", - "enum": [ - "model" - ], "title": "Kind", "type": "string" }, @@ -1345,9 +1339,6 @@ }, "platform": { "const": "bam", - "enum": [ - "bam" - ], "title": "Platform", "type": "string" }, @@ -2086,9 +2077,6 @@ "kind": { "const": "call", "default": "call", - "enum": [ - "call" - ], "title": "Kind", "type": "string" }, @@ -2721,9 +2709,6 @@ "kind": { "const": "code", "default": "code", - "enum": [ - "code" - ], "title": "Kind", "type": "string" }, @@ -3381,9 +3366,6 @@ "kind": { "const": "data", "default": "data", - "enum": [ - "data" - ], "title": "Kind", "type": "string" }, @@ -3861,9 +3843,6 @@ "kind": { "const": "empty", "default": "empty", - "enum": [ - "empty" - ], "title": "Kind", "type": "string" } @@ -4319,9 +4298,6 @@ "kind": { "const": "error", "default": "error", - "enum": [ - "error" - ], "title": "Kind", "type": "string" }, @@ -4948,9 +4924,6 @@ "kind": { "const": "for", "default": "for", - "enum": [ - "for" - ], "title": "Kind", "type": "string" }, @@ -5771,9 +5744,6 @@ "kind": { "const": "function", "default": "function", - "enum": [ - "function" - ], "title": "Kind", "type": "string" }, @@ -6421,9 +6391,6 @@ "kind": { "const": "get", "default": "get", - "enum": [ - "get" - ], "title": "Kind", "type": "string" }, @@ -6888,9 +6855,6 @@ "kind": { "const": "if", "default": "if", - "enum": [ - "if" - ], "title": "Kind", "type": "string" }, @@ -7694,9 +7658,6 @@ "kind": { "const": "include", "default": "include", - "enum": [ - "include" - ], "title": "Kind", "type": "string" }, @@ -7881,9 +7842,6 @@ "as": { "const": "array", "description": "Return the result of each iteration as an array.\n ", - "enum": [ - "array" - ], "title": "As", "type": "string" } @@ -7900,9 +7858,6 @@ "as": { "const": "lastOf", "description": "Return the result of the last iteration.\n ", - "enum": [ - "lastOf" - ], "title": "As", "type": "string" } @@ -7920,9 +7875,6 @@ "const": "text", "default": "text", "description": "String concatenation of the result of each iteration.\n ", - "enum": [ - "text" - ], "title": "As", "type": "string" }, @@ -8385,9 +8337,6 @@ "kind": { "const": "lastOf", "default": "lastOf", - "enum": [ - "lastOf" - ], "title": "Kind", "type": "string" }, @@ -9042,9 +8991,6 @@ "kind": { "const": "model", "default": "model", - "enum": [ - "model" - ], "title": "Kind", "type": "string" }, @@ -9316,9 +9262,6 @@ "platform": { "const": "litellm", "default": "litellm", - "enum": [ - "litellm" - ], "title": "Platform", "type": "string" }, @@ -10220,9 +10163,6 @@ "kind": { "const": "message", "default": "message", - "enum": [ - "message" - ], "title": "Kind", "type": "string" }, @@ -11117,9 +11057,6 @@ "kind": { "const": "object", "default": "object", - "enum": [ - "object" - ], "title": "Kind", "type": "string" }, @@ -12455,9 +12392,6 @@ "kind": { "const": "read", "default": "read", - "enum": [ - "read" - ], "title": "Kind", "type": "string" }, @@ -12996,9 +12930,6 @@ "kind": { "const": "repeat", "default": "repeat", - "enum": [ - "repeat" - ], "title": "Kind", "type": "string" }, @@ -13819,9 +13750,6 @@ "kind": { "const": "repeat_until", "default": "repeat_until", - "enum": [ - "repeat_until" - ], "title": "Kind", "type": "string" }, @@ -14641,9 +14569,6 @@ "kind": { "const": "text", "default": "text", - "enum": [ - "text" - ], "title": "Kind", "type": "string" }, diff --git a/src/pdl/pdl_ast.py b/src/pdl/pdl_ast.py index cff890f75..f7f4af0eb 100644 --- a/src/pdl/pdl_ast.py +++ b/src/pdl/pdl_ast.py @@ -2,7 +2,7 @@ """ from enum import StrEnum -from typing import Any, Literal, Optional, TypeAlias, Union +from typing import Any, Literal, Optional, Sequence, TypeAlias, Union from genai.schema import ( DecodingMethod, @@ -110,7 +110,7 @@ class Block(BaseModel): assign: Optional[str] = Field(default=None, alias="def") """Name of the variable used to store the result of the execution of the block. """ - contribute: list[ContributeTarget | dict[ContributeTarget, ContributeValue]] = [ + contribute: Sequence[ContributeTarget | dict[str, ContributeValue]] = [ ContributeTarget.RESULT, ContributeTarget.CONTEXT, ] diff --git a/src/pdl/pdl_interpreter.py b/src/pdl/pdl_interpreter.py index e40047760..3eaf932da 100644 --- a/src/pdl/pdl_interpreter.py +++ b/src/pdl/pdl_interpreter.py @@ -305,7 +305,7 @@ def step_block( def context_in_contribute(block: AdvancedBlockType) -> bool: - if ContributeTarget.CONTEXT in block.contribute: + if ContributeTarget.CONTEXT.value in block.contribute: return True if get_contribute_value(block.contribute) is not None: return True diff --git a/src/pdl/pdl_utils.py b/src/pdl/pdl_utils.py index a6ef5c98e..3d8d607fc 100644 --- a/src/pdl/pdl_utils.py +++ b/src/pdl/pdl_utils.py @@ -1,4 +1,5 @@ import json +from typing import Sequence from .pdl_ast import ContributeTarget, ContributeValue, FunctionBlock, Message, Messages @@ -17,7 +18,7 @@ def stringify(result): def replace_contribute_value( - contribute: list[ContributeTarget | dict[ContributeTarget, ContributeValue]], + contribute: Sequence[ContributeTarget | dict[str, ContributeValue]], value: ContributeValue, ): ret = [] @@ -31,7 +32,7 @@ def replace_contribute_value( def get_contribute_value( - contribute: list[ContributeTarget | dict[ContributeTarget, ContributeValue]] | None + contribute: Sequence[ContributeTarget | dict[str, ContributeValue]] | None ): if contribute is None: return None