Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion js/genkit/src/genkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ export class Genkit {
// check the registry first as not all prompt types can be
// loaded by dotprompt (e.g. functional)
let action = (await this.registry.lookupAction(
`/prompt/${name}`
`/prompt/${name}${options?.variant ? `.${options?.variant}` : ''}`
)) as PromptAction<I>;
// nothing in registry - check for dotprompt file.
if (!action) {
Expand Down
6 changes: 6 additions & 0 deletions js/genkit/tests/prompts/test.variant.prompt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
description: a prompt variant in a file
config:
temperature: 13
---
Hello from a variant of the hello prompt
11 changes: 11 additions & 0 deletions js/genkit/tests/prompts_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,17 @@ describe('prompt', () => {
);
});

it('loads a varaint from from the folder', async () => {
const testPrompt = ai.prompt('test', { variant: 'variant' }); // see tests/prompts folder

const { text } = await testPrompt();

assert.strictEqual(
text,
'Echo: Hello from a variant of the hello prompt\n; config: {"temperature":13}'
);
});

it('returns a ref to functional prompts', async () => {
ai.definePrompt(
{
Expand Down
Loading