fix: 支持传入system_instruction和systemInstruction两种风格系统提示词参数名
This commit is contained in:
@@ -22,6 +22,27 @@ type GeminiChatRequest struct {
|
|||||||
CachedContent string `json:"cachedContent,omitempty"`
|
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 {
|
type ToolConfig struct {
|
||||||
FunctionCallingConfig *FunctionCallingConfig `json:"functionCallingConfig,omitempty"`
|
FunctionCallingConfig *FunctionCallingConfig `json:"functionCallingConfig,omitempty"`
|
||||||
RetrievalConfig *RetrievalConfig `json:"retrievalConfig,omitempty"`
|
RetrievalConfig *RetrievalConfig `json:"retrievalConfig,omitempty"`
|
||||||
|
|||||||
Reference in New Issue
Block a user