From 093f05a4bf166b6f4482cdf4f8ff9338c39031c9 Mon Sep 17 00:00:00 2001 From: hawkgs Date: Fri, 24 Oct 2025 11:55:45 +0300 Subject: [PATCH] feat: provide system instructions separately via Genkit.generate system opt param Provide system instructions as a separate prompt via the `system` option parameter of `Genkit.generate` instead of concatenating them to the main executable prompt. --- runner/codegen/genkit/genkit-runner.ts | 4 +++- runner/codegen/llm-runner.ts | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/runner/codegen/genkit/genkit-runner.ts b/runner/codegen/genkit/genkit-runner.ts index 1e5983d..001f658 100644 --- a/runner/codegen/genkit/genkit-runner.ts +++ b/runner/codegen/genkit/genkit-runner.ts @@ -68,7 +68,8 @@ export class GenkitRunner implements LlmRunner { ): Promise { const requestOptions: LocalLlmConstrainedOutputGenerateRequestOptions = { ...options, - prompt: options.context.combinedPrompt, + prompt: options.context.executablePrompt, + systemPrompt: options.context.systemInstructions, schema: z.object({ outputFiles: z.array( z.object({ @@ -145,6 +146,7 @@ export class GenkitRunner implements LlmRunner { const response = await this.genkitInstance.generate({ prompt: options.prompt, + system: options.systemPrompt, model, output: schema ? { diff --git a/runner/codegen/llm-runner.ts b/runner/codegen/llm-runner.ts index 75baca0..ba1cd83 100644 --- a/runner/codegen/llm-runner.ts +++ b/runner/codegen/llm-runner.ts @@ -96,6 +96,8 @@ interface BaseLlmRequestOptions { export interface LocalLlmGenerateTextRequestOptions extends BaseLlmRequestOptions { /** Prompt to send. */ prompt: string; + /** System prompt. */ + systemPrompt?: string; } /** Context needed for an file generation context. */ @@ -123,6 +125,8 @@ export interface LocalLlmConstrainedOutputGenerateRequestOptions< > extends BaseLlmRequestOptions { /** Prompt to send. */ prompt: string; + /** System prompt. */ + systemPrompt?: string; /** Schema that the response should conform to. */ schema: T; }