From 8467a6d759b9f9070e1231915ace1a1388bf84c3 Mon Sep 17 00:00:00 2001 From: Matt Low Date: Sat, 1 Jun 2024 19:47:08 +0000 Subject: [PATCH] Fixed gemini system prompt handling --- pkg/lmcli/provider/google/google.go | 13 +++++++++++-- pkg/lmcli/provider/google/types.go | 8 ++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/pkg/lmcli/provider/google/google.go b/pkg/lmcli/provider/google/google.go index 51ca5e0..27026ec 100644 --- a/pkg/lmcli/provider/google/google.go +++ b/pkg/lmcli/provider/google/google.go @@ -158,8 +158,7 @@ func createGenerateContentRequest( } request := &GenerateContentRequest{ - Contents: requestContents, - SystemInstructions: system, + Contents: requestContents, GenerationConfig: &GenerationConfig{ MaxOutputTokens: ¶ms.MaxTokens, Temperature: ¶ms.Temperature, @@ -167,6 +166,16 @@ func createGenerateContentRequest( }, } + if system != "" { + request.SystemInstruction = Content{ + Parts: []ContentPart{ + { + Text: system, + }, + }, + } + } + if len(params.ToolBag) > 0 { request.Tools = convertTools(params.ToolBag) } diff --git a/pkg/lmcli/provider/google/types.go b/pkg/lmcli/provider/google/types.go index 1d2eb30..277ce95 100644 --- a/pkg/lmcli/provider/google/types.go +++ b/pkg/lmcli/provider/google/types.go @@ -34,10 +34,10 @@ type GenerationConfig struct { } type GenerateContentRequest struct { - Contents []Content `json:"contents"` - Tools []Tool `json:"tools,omitempty"` - SystemInstructions string `json:"systemInstructions,omitempty"` - GenerationConfig *GenerationConfig `json:"generationConfig,omitempty"` + Contents []Content `json:"contents"` + Tools []Tool `json:"tools,omitempty"` + SystemInstruction Content `json:"systemInstruction,omitempty"` + GenerationConfig *GenerationConfig `json:"generationConfig,omitempty"` } type Candidate struct {