From 3eee8c7a21e012cde776e768fd71511fd8ed0a87 Mon Sep 17 00:00:00 2001 From: Seefs Date: Tue, 16 Dec 2025 13:08:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=94=AF=E6=8C=81=E4=BC=A0=E5=85=A5syst?= =?UTF-8?q?em=5Finstruction=E5=92=8CsystemInstruction=E4=B8=A4=E7=A7=8D?= =?UTF-8?q?=E9=A3=8E=E6=A0=BC=E7=B3=BB=E7=BB=9F=E6=8F=90=E7=A4=BA=E8=AF=8D?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dto/gemini.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/dto/gemini.go b/dto/gemini.go index 1ee71a71..4d738c22 100644 --- a/dto/gemini.go +++ b/dto/gemini.go @@ -22,6 +22,27 @@ type GeminiChatRequest struct { CachedContent string `json:"cachedContent,omitempty"` } +// UnmarshalJSON allows GeminiChatRequest to accept both snake_case and camelCase fields. +func (r *GeminiChatRequest) UnmarshalJSON(data []byte) error { + type Alias GeminiChatRequest + var aux struct { + Alias + SystemInstructionSnake *GeminiChatContent `json:"system_instruction,omitempty"` + } + + if err := common.Unmarshal(data, &aux); err != nil { + return err + } + + *r = GeminiChatRequest(aux.Alias) + + if aux.SystemInstructionSnake != nil { + r.SystemInstructions = aux.SystemInstructionSnake + } + + return nil +} + type ToolConfig struct { FunctionCallingConfig *FunctionCallingConfig `json:"functionCallingConfig,omitempty"` RetrievalConfig *RetrievalConfig `json:"retrievalConfig,omitempty"`