Using dotprompt in chat
Hi. I have a hard time understanding how to use a Dotprompt template in a chat. I currently have the following which does not work
I am getting the following error
Here is my prompt template:
const promptTemplate = ai.prompt("story_structure");
const prompt = await promptTemplate.render(input);
const chat = session.chat({ system: prompt.system, tools: [getStoryStrucutures] }); // prompt.system is undefined
const chatStream = chat.sendStream(prompt); const promptTemplate = ai.prompt("story_structure");
const prompt = await promptTemplate.render(input);
const chat = session.chat({ system: prompt.system, tools: [getStoryStrucutures] }); // prompt.system is undefined
const chatStream = chat.sendStream(prompt);I am getting the following error
TypeError: Cannot read properties of undefined (reading 'role')
at toGeminiMessage (/backend/functions/node_modules/@genkit-ai/googleai/src/gemini.ts:511:32)TypeError: Cannot read properties of undefined (reading 'role')
at toGeminiMessage (/backend/functions/node_modules/@genkit-ai/googleai/src/gemini.ts:511:32)Here is my prompt template:
---
model: googleai/gemini-2.0-flash
input:
schema: StoryStrucutreRequestSchema
output:
schema: StoryStrucutreOutputSchema
---
{{role "system"}}
You are the world's best writing assistant that helps writers determine the most suitable story structure for their novel.
You engage in a conversation to understand the story’s genre, themes, complexity, and tone before recommending a structure.
You can get a list of available story strucutres from the getStoryStrucutures tool.
A selection from this list should eventually be returned to the user.
Once you know enough give the user a few suggestions that best suit his use case and explain why these options are best for his story.
{{role "user"}}
{{text}}---
model: googleai/gemini-2.0-flash
input:
schema: StoryStrucutreRequestSchema
output:
schema: StoryStrucutreOutputSchema
---
{{role "system"}}
You are the world's best writing assistant that helps writers determine the most suitable story structure for their novel.
You engage in a conversation to understand the story’s genre, themes, complexity, and tone before recommending a structure.
You can get a list of available story strucutres from the getStoryStrucutures tool.
A selection from this list should eventually be returned to the user.
Once you know enough give the user a few suggestions that best suit his use case and explain why these options are best for his story.
{{role "user"}}
{{text}}