diff --git a/packages/core/src/promptdom.ts b/packages/core/src/promptdom.ts index 5e77976f46..1f79f16df9 100644 --- a/packages/core/src/promptdom.ts +++ b/packages/core/src/promptdom.ts @@ -17,6 +17,7 @@ import { } from "./chat" import { errorMessage } from "./error" import { tidyData } from "./tidy" +import { inspect } from "./logging" export interface PromptNode extends ContextExpansionOptions { type?: @@ -391,7 +392,15 @@ async function resolvePromptNode( try { const resolvedArgs: any[] = [] for (const arg of args) { - const resolvedArg = await arg + let resolvedArg = await arg + // render objects + if ( + typeof resolvedArg === "object" || + Array.isArray(resolvedArg) + ) + resolvedArg = inspect(resolvedArg, { + maxDepth: 3, + }) resolvedArgs.push(resolvedArg ?? "") } const value = dedent(strings, ...resolvedArgs) diff --git a/packages/sample/genaisrc/defdata.genai.js b/packages/sample/genaisrc/defdata.genai.js index 98353ab15b..c5f4d9d4b1 100644 --- a/packages/sample/genaisrc/defdata.genai.js +++ b/packages/sample/genaisrc/defdata.genai.js @@ -1,6 +1,6 @@ script({ title: "defData demo", - model: "gpt-3.5-turbo", + model: "openai:gpt-3.5-turbo", tests: {}, system: ["system"] }) @@ -17,5 +17,10 @@ defData( { format: "csv" } ) -$`Identify the data formats of A,B,C,D and return the format results as CSV with key value pairs variable,format. +$` +E: +${[{ a: 7, b: 8 }, + { a: 9, b: 10 },]} + +Identify the data formats of A,B,C,D,E and return the format results as CSV with key value pairs variable,format. ` \ No newline at end of file