@@ -7,19 +7,11 @@ import {
77import { getEntityId , setBobbyServerUrl , storage } from "@commontools/runner" ;
88import { createSession , Identity } from "@commontools/identity" ;
99import { LLMClient , setLLMUrl } from "@commontools/llm" ;
10- import { processWorkflow } from "@commontools/charm" ;
10+ import { createDataCharm , processWorkflow } from "@commontools/charm" ;
1111import { type CharmResult , CommandType , type Step } from "./interfaces.ts" ;
1212import { scenarios } from "./scenarios.ts" ;
1313import { toolshedUrl } from "./env.ts" ;
1414import { llmVerifyCharm } from "./judge.ts" ;
15- import {
16- createJsonSchema ,
17- derive ,
18- NAME ,
19- recipe ,
20- UI ,
21- } from "@commontools/builder" ;
22- import { h } from "@commontools/html" ;
2315import { ensureReportDir , generateReport } from "./report.ts" ;
2416import {
2517 addErrorListeners ,
@@ -140,53 +132,18 @@ async function processCommand(
140132 throw new Error ( "Missing data for JSON import." ) ;
141133 }
142134
143- // FIXME(ja): we should move this to a common charm method so that
144- // jumble and seeder can share
145- const schema = step . dataSchema ?? createJsonSchema ( step . data ) ;
146- const schemaString = JSON . stringify ( schema , null , 2 ) ;
147- const result = Object . keys ( schema . properties ?? { } ) . map ( ( key ) =>
148- ` ${ key } : data.${ key } ,\n`
149- ) . join ( "\n" ) ;
150-
151- const dataRecipeSrc = `import { h } from "@commontools/html";
152- import { recipe, UI, NAME, derive, type JSONSchema } from "@commontools/builder";
153-
154- const schema = ${ schemaString } ;
155-
156- export default recipe(schema, schema, (data) => ({
157- [NAME]: "Data Import",
158- [UI]: <div><h2>schema</h2><pre>${
159- schemaString . replaceAll ( "{" , "{" )
160- . replaceAll ( "}" , "}" )
161- . replaceAll ( "\n" , "<br/>" )
162- } </pre></div>,
163- ${ result }
164- }));` ;
165-
166- const dataCharm = await compileAndRunRecipe (
135+ const charm = await createDataCharm (
167136 charmManager ,
168- dataRecipeSrc ,
169- "data import" ,
170137 step . data ,
138+ step . dataSchema ,
139+ prompt ,
171140 ) ;
172141
173- const form = await processWorkflow ( prompt , charmManager , {
174- existingCharm : dataCharm ,
175- cache,
176- prefill : {
177- classification : {
178- workflowType : "imagine" ,
179- confidence : 1.0 ,
180- reasoning : "hard coded" ,
181- } ,
182- } ,
183- } ) ;
184-
185- const newCharm = form . generation ?. charm ;
186- const id = getEntityId ( newCharm ) ;
142+ const id = getEntityId ( charm ) ;
143+ console . log ( `Charm added from JSON import` , { id } ) ;
187144 if ( id ) {
188145 console . log ( `Charm added from JSON import: ${ id [ "/" ] } ` ) ;
189- await verifyCharm ( id [ "/" ] , prompt ) ;
146+ await verifyCharm ( id [ "/" ] , "shows a jsonschema for " + prompt ) ;
190147 return id [ "/" ] ;
191148 }
192149 break ;
0 commit comments