@@ -25,32 +25,34 @@ export default function SpellbookLaunchView() {
2525 }
2626
2727 // Get AI suggestions for initial data
28- const fulfillUrl = `/api/ai/spell/fulfill ` ;
29- const response = await fetch ( fulfillUrl , {
28+ const imagineUrl = `/api/ai/spell/imagine ` ;
29+ const response = await fetch ( imagineUrl , {
3030 method : "POST" ,
3131 headers : {
3232 "Content-Type" : "application/json" ,
3333 accepts : "application/json" ,
3434 } ,
3535 body : JSON . stringify ( {
3636 schema : recipe . argumentSchema ?. properties ,
37- many : false ,
38- prompt : "" ,
37+ prompt : "" , // TODO(bf): we can pass something to make this more personal
3938 options : {
40- format : "json" ,
41- validate : false ,
42- maxExamples : 5 ,
39+ many : false ,
4340 } ,
4441 } ) ,
4542 } ) ;
4643
4744 let initialData = { } ;
4845 if ( response . ok ) {
49- const spellCasterFulfillResponse = await response . json ( ) ;
50- // TODO(jake): If there's no good initialData from spellcaster above,
51- // what happens? Can/should we generate fake json data to fill the charm?
52- initialData = spellCasterFulfillResponse . result ;
53- console . log ( "AI response:" , spellCasterFulfillResponse ) ;
46+ const compatibleData = await response . json ( ) ;
47+ initialData = compatibleData . result ;
48+ console . log ( "AI response:" , compatibleData ) ;
49+ } else {
50+ console . error (
51+ `Failed to get AI suggestions: ${ response . status } ${ response . statusText } ` ,
52+ ) ;
53+ throw new Error (
54+ `Failed to get AI suggestions: ${ response . status } ${ response . statusText } ` ,
55+ ) ;
5456 }
5557
5658 // Run the recipe with the initial data
@@ -82,7 +84,9 @@ export default function SpellbookLaunchView() {
8284 < div className = "flex items-center justify-center h-screen" >
8385 < div className = "text-center" >
8486 < h1 className = "text-2xl font-bold mb-4" > Launching Spell...</ h1 >
85- < p className = "text-gray-600" > Please wait while we prepare your spell.</ p >
87+ < p className = "text-gray-600" >
88+ Please wait while we prepare your spell.
89+ </ p >
8690 </ div >
8791 </ div >
8892 ) ;
0 commit comments