Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/pdl/pdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class InterpreterConfig(TypedDict, total=False):
"""
event_loop: AbstractEventLoop
"""Event loop to schedule LLM calls."""
llm_usage: PdlUsage
"""Data structure where to accumulate LLMs usage."""


class Result(TypedDict):
Expand Down
6 changes: 4 additions & 2 deletions src/pdl/pdl_interpreter_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ class InterpreterState(BaseModel):
"""Cache containing the imported files."""
event_loop: AbstractEventLoop = Field(default_factory=create_event_loop_thread)
"""Event loop to schedule LLM calls."""
current_pdl_context: Ref[LazyMessages] = Ref(DependentContext([]))
current_pdl_context: Ref[LazyMessages] = Field(
default_factory=lambda: Ref(DependentContext([]))
)
"""Current value of the context set at the beginning of the execution of the block."""
replay: dict[str, Any] = {}
"""Dictionary that associate runtime block ids with their values to be able to replay an execution."""
llm_usage: PdlUsage = PdlUsage()
"""Record statistics about LLM usage."""
"""Data structure where to accumulate LLMs usage."""

def with_yield_result(self: "InterpreterState", b: bool) -> "InterpreterState":
return self.model_copy(update={"yield_result": b})
Expand Down