You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Genkit Node.js SDK向Vertex模型传入systemInstruction

关于Genkit Node.js SDK传入Vertex模型systemInstruction的问题解答

Genkit Node.js SDK完全支持将{parts: [{text: ..}]}格式的systemInstruction传入Vertex模型,具体实现只需在调用generate方法时添加对应配置字段即可,修改后的代码示例如下:

export const processDocuemntFlow = defineFlow(
    {
        name: 'processDocuemntFlow',
        inputSchema: z.string(),
        outputSchema: noteSchema,
    },
   
    async (docuemntUrl) => {
        const llmResponse = await generate({
            model: gemini15FlashPreview,
            // 添加符合格式要求的systemInstruction配置
            systemInstruction: {
                parts: [{ text: '这里填写你的系统指令内容' }]
            },
            prompt: [{ text: `prompt` }],
            output: { format: "json", schema: noteSchema },
            config: {
                temperature: 1,
            },
        });
        console.log(JSON.stringify(llmResponse));

        return llmResponse.output();
    }
);

核心修改点是在generate的参数对象中新增systemInstruction字段,传入{parts: [{text: '...'}]}结构的对象即可。这个配置会被Genkit转译为Vertex模型能识别的系统指令格式,直接生效。

内容的提问来源于stack exchange,提问作者d-feverx

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.21 23:28:12