Skip to content

Commit c302e31

Browse files
committed
Merge branch 'main' into pdl-182
2 parents 34d1ab3 + 90f2183 commit c302e31

File tree

8 files changed

+370
-51
lines changed

8 files changed

+370
-51
lines changed

pdl-live/src/pdl_ast.d.ts

Lines changed: 59 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,30 @@ export type Trace =
508508
| IncludeBlock
509509
| ErrorBlock
510510
| EmptyBlock
511+
| (
512+
| number
513+
| string
514+
| FunctionBlock
515+
| CallBlock
516+
| LitellmModelBlock
517+
| BamModelBlock
518+
| CodeBlock
519+
| GetBlock
520+
| DataBlock
521+
| IfBlock
522+
| RepeatBlock
523+
| RepeatUntilBlock
524+
| ForBlock
525+
| TextBlock
526+
| LastOfBlock
527+
| ArrayBlock
528+
| ObjectBlock
529+
| MessageBlock
530+
| ReadBlock
531+
| IncludeBlock
532+
| ErrorBlock
533+
| EmptyBlock
534+
)[]
511535
| null;
512536
/**
513537
* Name of the variable used to store the result of the execution of the block.
@@ -581,11 +605,6 @@ export type Fallback3 =
581605
*/
582606
export type Role3 = string | null;
583607
export type Kind3 = "read";
584-
/**
585-
* Name of the file to read. If `None`, read the standard input.
586-
*
587-
*/
588-
export type Read = string | null;
589608
/**
590609
* Message to prompt the user to enter a value.
591610
*
@@ -813,7 +832,31 @@ export type Object =
813832
| ReadBlock
814833
| IncludeBlock
815834
| ErrorBlock
816-
| EmptyBlock;
835+
| EmptyBlock
836+
| (
837+
| number
838+
| string
839+
| FunctionBlock
840+
| CallBlock
841+
| LitellmModelBlock
842+
| BamModelBlock
843+
| CodeBlock
844+
| GetBlock
845+
| DataBlock
846+
| IfBlock
847+
| RepeatBlock
848+
| RepeatUntilBlock
849+
| ForBlock
850+
| TextBlock
851+
| LastOfBlock
852+
| ArrayBlock
853+
| ObjectBlock
854+
| MessageBlock
855+
| ReadBlock
856+
| IncludeBlock
857+
| ErrorBlock
858+
| EmptyBlock
859+
)[];
817860
}
818861
| (
819862
| number
@@ -2287,7 +2330,6 @@ export type Fallback16 =
22872330
*/
22882331
export type Role16 = string | null;
22892332
export type Kind16 = "model";
2290-
export type Model = string;
22912333
export type Input =
22922334
| number
22932335
| string
@@ -2490,7 +2532,6 @@ export type Fallback17 =
24902532
*/
24912533
export type Role17 = string | null;
24922534
export type Kind17 = "model";
2493-
export type Model1 = string;
24942535
export type Input1 =
24952536
| number
24962537
| string
@@ -2689,11 +2730,6 @@ export type Fallback18 =
26892730
*/
26902731
export type Role18 = string | null;
26912732
export type Kind18 = "call";
2692-
/**
2693-
* Function to call.
2694-
*
2695-
*/
2696-
export type Call = string;
26972733
export type Trace6 =
26982734
| number
26992735
| string
@@ -3119,7 +3155,7 @@ export interface LitellmModelBlock {
31193155
result?: unknown;
31203156
location?: LocationType | null;
31213157
kind?: Kind17;
3122-
model: Model1;
3158+
model: unknown;
31233159
input?: Input1;
31243160
trace?: Trace5;
31253161
platform?: Platform1;
@@ -3197,7 +3233,7 @@ export interface BamModelBlock {
31973233
result?: unknown;
31983234
location?: LocationType | null;
31993235
kind?: Kind16;
3200-
model: Model;
3236+
model: unknown;
32013237
input?: Input;
32023238
trace?: Trace4;
32033239
platform: Platform;
@@ -4220,7 +4256,7 @@ export interface ReadBlock {
42204256
result?: unknown;
42214257
location?: LocationType | null;
42224258
kind?: Kind3;
4223-
read: Read;
4259+
read: unknown;
42244260
message?: Message;
42254261
multiline?: Multiline;
42264262
}
@@ -4681,6 +4717,13 @@ export interface LitellmParameters {
46814717
max_retries?: MaxRetries;
46824718
[k: string]: unknown;
46834719
}
4720+
/**
4721+
* Function to call.
4722+
*
4723+
*/
4724+
export interface Call {
4725+
[k: string]: unknown;
4726+
}
46844727
/**
46854728
* Arguments of the function with their values.
46864729
*

pdl-live/src/pdl_ast_utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export function map_block_children(
5757
object = block.object.map(f);
5858
} else {
5959
object = Object.fromEntries(
60-
Object.entries(block.object).map(([k, v]) => [k, f(v)])
60+
Object.entries(block.object).map(([k, v]) => [k, map_blocks(f, v)])
6161
);
6262
}
6363
return {...block, object: object};
@@ -154,7 +154,7 @@ export function iter_block_children(
154154
if (block.object instanceof Array) {
155155
iter_blocks(f, block.object);
156156
} else {
157-
Object.entries(block.object).forEach(([_, v]) => f(v));
157+
Object.entries(block.object).forEach(([_, v]) => iter_blocks(f, v));
158158
}
159159
return {...block, object: object};
160160
})

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ classifiers = [
3434

3535
[project.optional-dependencies]
3636
dev = [
37-
"pre-commit~=3.0",
37+
"pre-commit>=3,<5",
3838
"pytest~=8.0",
3939
"pydantic~=2.9"
4040
]

src/pdl/pdl-schema.json

Lines changed: 168 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,8 +1005,13 @@
10051005
"type": "string"
10061006
},
10071007
"model": {
1008-
"title": "Model",
1009-
"type": "string"
1008+
"anyOf": [
1009+
{
1010+
"type": "string"
1011+
},
1012+
{}
1013+
],
1014+
"title": "Model"
10101015
},
10111016
"input": {
10121017
"anyOf": [
@@ -1960,8 +1965,7 @@
19601965
},
19611966
"call": {
19621967
"description": "Function to call.\n ",
1963-
"title": "Call",
1964-
"type": "string"
1968+
"title": "Call"
19651969
},
19661970
"args": {
19671971
"default": {},
@@ -7269,6 +7273,82 @@
72697273
{
72707274
"$ref": "#/$defs/EmptyBlock"
72717275
},
7276+
{
7277+
"items": {
7278+
"anyOf": [
7279+
{
7280+
"type": "integer"
7281+
},
7282+
{
7283+
"type": "number"
7284+
},
7285+
{
7286+
"type": "string"
7287+
},
7288+
{
7289+
"$ref": "#/$defs/FunctionBlock"
7290+
},
7291+
{
7292+
"$ref": "#/$defs/CallBlock"
7293+
},
7294+
{
7295+
"$ref": "#/$defs/LitellmModelBlock"
7296+
},
7297+
{
7298+
"$ref": "#/$defs/BamModelBlock"
7299+
},
7300+
{
7301+
"$ref": "#/$defs/CodeBlock"
7302+
},
7303+
{
7304+
"$ref": "#/$defs/GetBlock"
7305+
},
7306+
{
7307+
"$ref": "#/$defs/DataBlock"
7308+
},
7309+
{
7310+
"$ref": "#/$defs/IfBlock"
7311+
},
7312+
{
7313+
"$ref": "#/$defs/RepeatBlock"
7314+
},
7315+
{
7316+
"$ref": "#/$defs/RepeatUntilBlock"
7317+
},
7318+
{
7319+
"$ref": "#/$defs/ForBlock"
7320+
},
7321+
{
7322+
"$ref": "#/$defs/TextBlock"
7323+
},
7324+
{
7325+
"$ref": "#/$defs/LastOfBlock"
7326+
},
7327+
{
7328+
"$ref": "#/$defs/ArrayBlock"
7329+
},
7330+
{
7331+
"$ref": "#/$defs/ObjectBlock"
7332+
},
7333+
{
7334+
"$ref": "#/$defs/MessageBlock"
7335+
},
7336+
{
7337+
"$ref": "#/$defs/ReadBlock"
7338+
},
7339+
{
7340+
"$ref": "#/$defs/IncludeBlock"
7341+
},
7342+
{
7343+
"$ref": "#/$defs/ErrorBlock"
7344+
},
7345+
{
7346+
"$ref": "#/$defs/EmptyBlock"
7347+
}
7348+
]
7349+
},
7350+
"type": "array"
7351+
},
72727352
{
72737353
"type": "null"
72747354
}
@@ -8383,8 +8463,13 @@
83838463
"type": "string"
83848464
},
83858465
"model": {
8386-
"title": "Model",
8387-
"type": "string"
8466+
"anyOf": [
8467+
{
8468+
"type": "string"
8469+
},
8470+
{}
8471+
],
8472+
"title": "Model"
83888473
},
83898474
"input": {
83908475
"anyOf": [
@@ -10452,6 +10537,82 @@
1045210537
},
1045310538
{
1045410539
"$ref": "#/$defs/EmptyBlock"
10540+
},
10541+
{
10542+
"items": {
10543+
"anyOf": [
10544+
{
10545+
"type": "integer"
10546+
},
10547+
{
10548+
"type": "number"
10549+
},
10550+
{
10551+
"type": "string"
10552+
},
10553+
{
10554+
"$ref": "#/$defs/FunctionBlock"
10555+
},
10556+
{
10557+
"$ref": "#/$defs/CallBlock"
10558+
},
10559+
{
10560+
"$ref": "#/$defs/LitellmModelBlock"
10561+
},
10562+
{
10563+
"$ref": "#/$defs/BamModelBlock"
10564+
},
10565+
{
10566+
"$ref": "#/$defs/CodeBlock"
10567+
},
10568+
{
10569+
"$ref": "#/$defs/GetBlock"
10570+
},
10571+
{
10572+
"$ref": "#/$defs/DataBlock"
10573+
},
10574+
{
10575+
"$ref": "#/$defs/IfBlock"
10576+
},
10577+
{
10578+
"$ref": "#/$defs/RepeatBlock"
10579+
},
10580+
{
10581+
"$ref": "#/$defs/RepeatUntilBlock"
10582+
},
10583+
{
10584+
"$ref": "#/$defs/ForBlock"
10585+
},
10586+
{
10587+
"$ref": "#/$defs/TextBlock"
10588+
},
10589+
{
10590+
"$ref": "#/$defs/LastOfBlock"
10591+
},
10592+
{
10593+
"$ref": "#/$defs/ArrayBlock"
10594+
},
10595+
{
10596+
"$ref": "#/$defs/ObjectBlock"
10597+
},
10598+
{
10599+
"$ref": "#/$defs/MessageBlock"
10600+
},
10601+
{
10602+
"$ref": "#/$defs/ReadBlock"
10603+
},
10604+
{
10605+
"$ref": "#/$defs/IncludeBlock"
10606+
},
10607+
{
10608+
"$ref": "#/$defs/ErrorBlock"
10609+
},
10610+
{
10611+
"$ref": "#/$defs/EmptyBlock"
10612+
}
10613+
]
10614+
},
10615+
"type": "array"
1045510616
}
1045610617
]
1045710618
},
@@ -11552,9 +11713,7 @@
1155211713
},
1155311714
"read": {
1155411715
"anyOf": [
11555-
{
11556-
"type": "string"
11557-
},
11716+
{},
1155811717
{
1155911718
"type": "null"
1156011719
}

0 commit comments

Comments
 (0)