File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -877,7 +877,7 @@ export async function prompt<
877877> (
878878 registry : Registry ,
879879 name : string ,
880- options ?: { variant ?: string ; dir ?: string }
880+ options ?: { variant ?: string ; dir ?: string | null }
881881) : Promise < ExecutablePrompt < I , O , CustomOptions > > {
882882 return await lookupPrompt < I , O , CustomOptions > (
883883 registry ,
Original file line number Diff line number Diff line change @@ -147,8 +147,8 @@ export type PromptFn<
147147export interface GenkitOptions {
148148 /** List of plugins to load. */
149149 plugins ?: ( GenkitPlugin | GenkitPluginV2 ) [ ] ;
150- /** Directory where dotprompts are stored. */
151- promptDir ?: string ;
150+ /** Directory where dotprompts are stored. Set to `null` to disable automatic prompt loading. */
151+ promptDir ?: string | null ;
152152 /** Default model to use if no model is specified. */
153153 model ?: ModelArgument < any > ;
154154 /** Additional runtime context data for flows and tools. */
@@ -346,7 +346,10 @@ export class Genkit extends GenkitAI implements HasRegistry {
346346 `${ name } ${ options ?. variant ? `.${ options ?. variant } ` : '' } ` ,
347347 prompt ( this . registry , name , {
348348 ...options ,
349- dir : this . options . promptDir ?? './prompts' ,
349+ dir :
350+ this . options . promptDir === undefined
351+ ? './prompts'
352+ : this . options . promptDir ,
350353 } )
351354 ) ;
352355 }
Original file line number Diff line number Diff line change @@ -1057,6 +1057,19 @@ describe('prompt', () => {
10571057 } ) ;
10581058 } ) ;
10591059
1060+ it ( 'does not auto-load prompts when promptDir is null' , async ( ) => {
1061+ const aiWithoutPromptDir = genkit ( {
1062+ model : 'echoModel' ,
1063+ promptDir : null ,
1064+ } ) ;
1065+
1066+ const prompt = aiWithoutPromptDir . prompt ( 'test' ) ;
1067+ const response = prompt ( ) ;
1068+ await assert . rejects ( response , {
1069+ message : 'NOT_FOUND: Prompt test not found' ,
1070+ } ) ;
1071+ } ) ;
1072+
10601073 it ( 'loads from from the sub folder' , async ( ) => {
10611074 const testPrompt = ai . prompt ( 'sub/test' ) ; // see tests/prompts/sub folder
10621075
You can’t perform that action at this time.
0 commit comments