最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

google cloud platform - Dot Prompt syntax for defined prompt in Firebase Genkit - Stack Overflow

programmeradmin5浏览0评论

Below are the important variables defined in order to call prompt from CLI or Firebase Web.

Schema & Function

export const OperationSchema = z.object({
    a: z.number(),
    b: z.number(),
});

export const QuestionSchema = z.object({
    question: z.string(),
});

function sum(a: number, b: number): number {
    return a + b;
}

Tools

export const sumTool = defineTool(
    {
        name: 'sum',
        description: 'Adds two numbers',
        inputSchema: OperationSchema,
        outputSchema: z.number(),
    },
    async (input) => {
        return sum(input.a, input.b);
    }
);

DotPrompt

export const mathOperationsPrompt = defineDotprompt(
    {
        name: 'mathOperations',
        tools: [sumTool],
    },
    `

answer the user’s {{question}} but to not do any math itself, make use of available tools
`
);

Flow

export const mathOperationsFlow = defineFlow(
    {
        name: 'mathOperations',
        inputSchema: QuestionSchema,
        outputSchema: z.string(),
    },
    async () => {
        const response = await generate({
            prompt: mathOperationsPrompt,
            model: gemini15Flash,
        });
        return response.text();
    }
);

After defining prompt, tools and flow. when I am calling the flow it is giving below error. When I was going through documentation from firebase it is not showing any specific example for dotprompt. can anyone provide any references for dotprompt definition, so that I can further correct the missing attributes.


"stacktrace": "Error: No recognized fields in content\n at getRoleFromPart (/home/student/genkit-intro/node_modules/@genkit-ai/ai/lib/generate.js:398:9)
 at inferRoleFromParts (/home/student/genkit-intro/node_modules/@genkit-ai/ai/lib/generate.js:403:18)
 at /home/student/genkit-intro/node_modules/@genkit-ai/ai/lib/generate.js:421:28\n at Generator.next (<anonymous>)
 at /home/student/genkit-intro/node_modules/@genkit-ai/ai/lib/generate.js:56:61\n at new Promise (<anonymous>)
 at __async (/home/student/genkit-intro/node_modules/@genkit-ai/ai/lib/generate.js:40:10)
 at toGenerateRequest (/home/student/genkit-intro/node_modules/@genkit-ai/ai/lib/generate.js:412:10)
 at /home/student/genkit-intro/node_modules/@genkit-ai/ai/lib/generate.js:524:27
 at Generator.next (<anonymous>)"

I referred the following documentation:

The correct output should come as applied operation like: while running command :

genkit flow:run mathOperations '{"question": "four plus 5"}'

should give

{response:"9"}

发布评论

评论列表(0)

  1. 暂无评论