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
58 changes: 2 additions & 56 deletions pdl-live-react/src/pdl_ast.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2180,32 +2180,6 @@ export type Input =
export type Modelresponse = string | null
export type CompletionTokens = number | null
export type PromptTokens = number | null
export type PdlTrace3 =
| boolean
| number
| string
| FunctionBlock
| CallBlock
| LitellmModelBlock
| GraniteioModelBlock
| CodeBlock
| ArgsBlock
| GetBlock
| DataBlock
| IfBlock
| MatchBlock
| RepeatBlock
| TextBlock
| LastOfBlock
| ArrayBlock
| ObjectBlock
| MessageBlock
| ReadBlock
| IncludeBlock
| ImportBlock
| ErrorBlock
| EmptyBlock
| null
/**
* Optional field to ensure that the block is using granite-io.
*
Expand Down Expand Up @@ -2352,32 +2326,6 @@ export type Input1 =
*
*/
export type Modelresponse1 = string | null
export type PdlTrace4 =
| boolean
| number
| string
| FunctionBlock
| CallBlock
| LitellmModelBlock
| GraniteioModelBlock
| CodeBlock
| ArgsBlock
| GetBlock
| DataBlock
| IfBlock
| MatchBlock
| RepeatBlock
| TextBlock
| LastOfBlock
| ArrayBlock
| ObjectBlock
| MessageBlock
| ReadBlock
| IncludeBlock
| ImportBlock
| ErrorBlock
| EmptyBlock
| null
/**
* Optional field to ensure that the block is using LiteLLM.
*
Expand Down Expand Up @@ -2517,7 +2465,7 @@ export type Context19 =
export type PdlId19 = string | null
export type PdlIsLeaf19 = true
export type Kind19 = "call"
export type PdlTrace5 =
export type PdlTrace3 =
| boolean
| number
| string
Expand Down Expand Up @@ -2764,7 +2712,7 @@ export interface CallBlock {
kind?: Kind19
call: unknown
args?: unknown
pdl__trace?: PdlTrace5
pdl__trace?: PdlTrace3
}
/**
* Type specification of the result of the block.
Expand Down Expand Up @@ -2839,7 +2787,6 @@ export interface LitellmModelBlock {
*
*/
pdl__usage?: PdlUsage | null
pdl__trace?: PdlTrace4
platform?: Platform1
parameters?: Parameters1
}
Expand Down Expand Up @@ -2909,7 +2856,6 @@ export interface GraniteioModelBlock {
*
*/
pdl__usage?: PdlUsage | null
pdl__trace?: PdlTrace3
platform?: Platform
backend: Backend
processor?: Processor
Expand Down
168 changes: 0 additions & 168 deletions src/pdl/pdl-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4236,90 +4236,6 @@
"default": null,
"description": "Tokens consumed during model call\n "
},
"pdl__trace": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "integer"
},
{
"type": "number"
},
{
"type": "string"
},
{
"$ref": "#/$defs/FunctionBlock"
},
{
"$ref": "#/$defs/CallBlock"
},
{
"$ref": "#/$defs/LitellmModelBlock"
},
{
"$ref": "#/$defs/GraniteioModelBlock"
},
{
"$ref": "#/$defs/CodeBlock"
},
{
"$ref": "#/$defs/ArgsBlock"
},
{
"$ref": "#/$defs/GetBlock"
},
{
"$ref": "#/$defs/DataBlock"
},
{
"$ref": "#/$defs/IfBlock"
},
{
"$ref": "#/$defs/MatchBlock"
},
{
"$ref": "#/$defs/RepeatBlock"
},
{
"$ref": "#/$defs/TextBlock"
},
{
"$ref": "#/$defs/LastOfBlock"
},
{
"$ref": "#/$defs/ArrayBlock"
},
{
"$ref": "#/$defs/ObjectBlock"
},
{
"$ref": "#/$defs/MessageBlock"
},
{
"$ref": "#/$defs/ReadBlock"
},
{
"$ref": "#/$defs/IncludeBlock"
},
{
"$ref": "#/$defs/ImportBlock"
},
{
"$ref": "#/$defs/ErrorBlock"
},
{
"$ref": "#/$defs/EmptyBlock"
},
{
"type": "null"
}
],
"default": null,
"title": "Pdl Trace"
},
"platform": {
"const": "granite-io",
"default": "granite-io",
Expand Down Expand Up @@ -6770,90 +6686,6 @@
"default": null,
"description": "Tokens consumed during model call\n "
},
"pdl__trace": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "integer"
},
{
"type": "number"
},
{
"type": "string"
},
{
"$ref": "#/$defs/FunctionBlock"
},
{
"$ref": "#/$defs/CallBlock"
},
{
"$ref": "#/$defs/LitellmModelBlock"
},
{
"$ref": "#/$defs/GraniteioModelBlock"
},
{
"$ref": "#/$defs/CodeBlock"
},
{
"$ref": "#/$defs/ArgsBlock"
},
{
"$ref": "#/$defs/GetBlock"
},
{
"$ref": "#/$defs/DataBlock"
},
{
"$ref": "#/$defs/IfBlock"
},
{
"$ref": "#/$defs/MatchBlock"
},
{
"$ref": "#/$defs/RepeatBlock"
},
{
"$ref": "#/$defs/TextBlock"
},
{
"$ref": "#/$defs/LastOfBlock"
},
{
"$ref": "#/$defs/ArrayBlock"
},
{
"$ref": "#/$defs/ObjectBlock"
},
{
"$ref": "#/$defs/MessageBlock"
},
{
"$ref": "#/$defs/ReadBlock"
},
{
"$ref": "#/$defs/IncludeBlock"
},
{
"$ref": "#/$defs/ImportBlock"
},
{
"$ref": "#/$defs/ErrorBlock"
},
{
"$ref": "#/$defs/EmptyBlock"
},
{
"type": "null"
}
],
"default": null,
"title": "Pdl Trace"
},
"platform": {
"const": "litellm",
"default": "litellm",
Expand Down
3 changes: 1 addition & 2 deletions src/pdl/pdl_ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,11 +406,10 @@ class ModelBlock(LeafBlock):
modelResponse: Optional[str] = None
"""Variable where to store the raw response of the model.
"""
# Field for internal use
pdl__usage: Optional[PdlUsage] = None
"""Tokens consumed during model call
"""
# Field for internal use
pdl__trace: Optional["BlockType"] = None


class LitellmModelBlock(ModelBlock):
Expand Down
8 changes: 0 additions & 8 deletions src/pdl/pdl_ast_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ def iter_block_children(f: Callable[[BlockType], None], block: BlockType) -> Non
case ModelBlock():
if block.input is not None:
f(block.input)
if block.pdl__trace is not None:
f(block.pdl__trace)
case CodeBlock():
f(block.code)
case GetBlock():
Expand Down Expand Up @@ -137,16 +135,10 @@ def map_block_children(f: MappedFunctions, block: BlockType) -> BlockType:
block.model = f.f_expr(block.model)
if block.input is not None:
block.input = f.f_block(block.input)
if block.pdl__trace is not None:
block.pdl__trace = f.f_block(block.pdl__trace)
if block.parameters is not None:
block.parameters = f.f_expr(block.parameters)
case GraniteioModelBlock():
block.model = f.f_expr(block.model)
if block.input is not None:
block.input = f.f_block(block.input)
if block.pdl__trace is not None:
block.pdl__trace = f.f_block(block.pdl__trace)
if block.parameters is not None:
block.parameters = f.f_expr(block.parameters)
case CodeBlock():
Expand Down
8 changes: 3 additions & 5 deletions src/pdl/pdl_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1324,13 +1324,11 @@ def get_transformed_inputs(kwargs):
result = lazy_apply(
lambda msg: "" if msg["content"] is None else msg["content"], msg
)
trace = block.model_copy(
update={"pdl__result": result, "pdl__trace": concrete_block}
)
if concrete_block.pdl__usage is not None:
trace.pdl__usage = concrete_block.pdl__usage
if block.modelResponse is not None:
scope = scope | {block.modelResponse: raw_result}
trace: BlockTypeTVarProcessCallModel = concrete_block.model_copy(
update={"pdl__result": result}
) # pyright: ignore
return result, background, scope, trace
except httpx.RequestError as exc:
message = f"model '{model_id}' encountered {repr(exc)} trying to {exc.request.method} against {exc.request.url}"
Expand Down