File tree Expand file tree Collapse file tree 3 files changed +31
-22
lines changed
Expand file tree Collapse file tree 3 files changed +31
-22
lines changed Original file line number Diff line number Diff line change @@ -305,3 +305,15 @@ export function extractStructuredModelResponse({
305305export function isArgs ( block : ArgsBlock | CodeBlock ) : block is ArgsBlock {
306306 return Array . isArray ( ( block as ArgsBlock ) . args )
307307}
308+
309+ export function extractCode ( { code } : CodeBlock ) : string {
310+ if (
311+ isNonScalarPdlBlock ( code ) &&
312+ hasResult ( code ) &&
313+ typeof code . pdl__result !== "object"
314+ ) {
315+ return String ( code . pdl__result )
316+ }
317+
318+ return String ( code )
319+ }
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ export default function DrawerContentBody({
5353
5454 default : {
5555 // some blocks have nothing interesting to show other than their result
56- const hasSummary = ! ( block . kind === "data" || block . kind === "code" )
56+ const hasSummary = ! ( block . kind === "data" )
5757
5858 return [
5959 ...( ! hasSummary
Original file line number Diff line number Diff line change 11import Group from "../Group"
22
33import Code from "../../code/Code"
4- import Result from "../../Result"
5- import { isArgs } from "../../../helpers"
4+ import { isArgs , extractCode } from "../../../helpers"
65
76export default function CodeItems ( {
87 block,
@@ -11,27 +10,25 @@ export default function CodeItems({
1110 | import ( "../../../pdl_ast" ) . ArgsBlock
1211 | import ( "../../../pdl_ast" ) . CodeBlock
1312} ) {
14- const { lang, pdl__result } = block
15- const code = isArgs ( block ) ? block . args . join ( " " ) : block . code
13+ const { lang } = block
14+ const code = isArgs ( block ) ? block . args . join ( " " ) : extractCode ( block )
15+
1616 return (
1717 < >
18- { typeof code === "string" && (
19- < Group
20- term = "Code"
21- description = {
22- < Code
23- block = { code . trim ( ) }
24- showLineNumbers
25- language = {
26- lang === "pdl" || lang === "jinja" || lang === "command"
27- ? "plaintext"
28- : lang || "yaml"
29- }
30- />
31- }
32- />
33- ) }
34- < Result result = { pdl__result } term = "Execution Output" />
18+ < Group
19+ term = "Code"
20+ description = {
21+ < Code
22+ block = { code . trim ( ) }
23+ showLineNumbers
24+ language = {
25+ lang === "pdl" || lang === "jinja" || lang === "command"
26+ ? "plaintext"
27+ : lang || "yaml"
28+ }
29+ />
30+ }
31+ />
3532 </ >
3633 )
3734}
You can’t perform that action at this time.
0 commit comments