File tree 2 files changed +22
-18
lines changed
2 files changed +22
-18
lines changed Original file line number Diff line number Diff line change 8
8
hasParser ,
9
9
hasScalarResult ,
10
10
hasModelUsage ,
11
+ hasResult ,
11
12
hasTimingInformation ,
12
13
capitalizeAndUnSnakeCase ,
13
14
extractStructuredModelResponse ,
@@ -37,10 +38,16 @@ import { hasStabilityMetrics, type StabilityMetric } from "./stability"
37
38
} */
38
39
39
40
/** Remove objects from the Masonry model that aren't helpful to display */
40
- function removeFluff ( { kind } : { kind ?: string } ) {
41
+ function removeFluff ( { kind, block } : Tile ) {
41
42
// re: empty, these house only defs, which are spliced in below via
42
43
// `withDefs()`
43
- return kind !== "if" && kind !== "empty"
44
+ return (
45
+ kind !== "if" &&
46
+ kind !== "empty" &&
47
+ ( ! hasResult ( block ) ||
48
+ typeof block . pdl__result !== "string" ||
49
+ block . pdl__result . trim ( ) . length > 0 )
50
+ )
44
51
}
45
52
46
53
export default function computeModel ( block : import ( "../../pdl_ast" ) . PdlBlock ) {
Original file line number Diff line number Diff line change @@ -64,24 +64,21 @@ export function computeModel(block: unknown | PdlBlock): TimelineModel {
64
64
* blocks.
65
65
*/
66
66
function squashProximateModelInputs ( model : TimelineModel ) : TimelineModel {
67
- return model
68
- . reduceRight ( ( model , row , idx , A ) => {
69
- if ( idx < A . length - 1 ) {
70
- const prior = A [ idx + 1 ] . block
71
- if ( isLLMBlock ( prior ) && hasInput ( prior ) ) {
72
- const lastInput =
73
- prior . pdl__model_input [ prior . pdl__model_input . length - 1 ]
74
- if ( ! ! lastInput && lastInput . defsite === row . id ) {
75
- // Skip! We have found block_i such that block_(i+1) is a
76
- // model block whose final input message was defined by
77
- // block_i. No sense in repeating ourselves...
78
- return model
79
- }
67
+ const modelInputDefsites = model . reduce (
68
+ ( M , { block } ) => {
69
+ if ( isLLMBlock ( block ) && hasInput ( block ) ) {
70
+ const lastInput =
71
+ block . pdl__model_input [ block . pdl__model_input . length - 1 ]
72
+ if ( lastInput && typeof lastInput . defsite === "string" ) {
73
+ M [ lastInput . defsite ] = true
80
74
}
81
75
}
82
- return [ ...model , row ]
83
- } , [ ] as TimelineModel )
84
- . reverse ( )
76
+ return M
77
+ } ,
78
+ { } as Record < string , boolean > ,
79
+ )
80
+
81
+ return model . filter ( ( { id } ) => ! modelInputDefsites [ id ] ) . filter ( nonNullable )
85
82
}
86
83
87
84
function computeModelIter (
You can’t perform that action at this time.
0 commit comments