Skip to content

Commit

Permalink
fix(js/ai/prompt): also delete null description from input schema (#1691
Browse files Browse the repository at this point in the history
)
  • Loading branch information
pavelgj authored Jan 29, 2025
1 parent f6696da commit 76aa1df
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 4 additions & 1 deletion js/ai/src/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,10 @@ function loadPrompt(

// dotprompt can set null description on the schema, which can confuse downstream schema consumers
if (promptMetadata.output?.schema?.description === null) {
delete promptMetadata.output?.schema?.description;
delete promptMetadata.output.schema.description;
}
if (promptMetadata.input?.schema?.description === null) {
delete promptMetadata.input.schema.description;
}

return {
Expand Down
12 changes: 11 additions & 1 deletion js/genkit/tests/prompts_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ describe('definePrompt', () => {
});
});

describe.only('prompt', () => {
describe('prompt', () => {
let ai: GenkitBeta;
let pm: ProgrammableModel;

Expand Down Expand Up @@ -1031,6 +1031,16 @@ describe.only('prompt', () => {
required: ['output'],
type: 'object',
});

assert.deepStrictEqual(
(await (await prompt.asTool())({ foo: 'bar' })).messages,
[
{
role: 'user',
content: [{ text: 'Write a poem about bar.' }],
},
]
);
});

it('loads a varaint from from the folder', async () => {
Expand Down

0 comments on commit 76aa1df

Please sign in to comment.