Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
5812163f
authored
Jan 12, 2026
by
Seefs
Committed by
GitHub
Jan 12, 2026
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2646 from deanxv/fix/gemini-unmarshal
parents
71460cba
5568423e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
82 additions
and
0 deletions
+82
-0
dto/gemini.go
+82
-0
No files found.
dto/gemini.go
View file @
5812163f
...
...
@@ -341,6 +341,88 @@ type GeminiChatGenerationConfig struct {
ImageConfig
json
.
RawMessage
`json:"imageConfig,omitempty"`
// RawMessage to allow flexible image config
}
// UnmarshalJSON allows GeminiChatGenerationConfig to accept both snake_case and camelCase fields.
func
(
c
*
GeminiChatGenerationConfig
)
UnmarshalJSON
(
data
[]
byte
)
error
{
type
Alias
GeminiChatGenerationConfig
var
aux
struct
{
Alias
TopPSnake
float64
`json:"top_p,omitempty"`
TopKSnake
float64
`json:"top_k,omitempty"`
MaxOutputTokensSnake
uint
`json:"max_output_tokens,omitempty"`
CandidateCountSnake
int
`json:"candidate_count,omitempty"`
StopSequencesSnake
[]
string
`json:"stop_sequences,omitempty"`
ResponseMimeTypeSnake
string
`json:"response_mime_type,omitempty"`
ResponseSchemaSnake
any
`json:"response_schema,omitempty"`
ResponseJsonSchemaSnake
json
.
RawMessage
`json:"response_json_schema,omitempty"`
PresencePenaltySnake
*
float32
`json:"presence_penalty,omitempty"`
FrequencyPenaltySnake
*
float32
`json:"frequency_penalty,omitempty"`
ResponseLogprobsSnake
bool
`json:"response_logprobs,omitempty"`
MediaResolutionSnake
MediaResolution
`json:"media_resolution,omitempty"`
ResponseModalitiesSnake
[]
string
`json:"response_modalities,omitempty"`
ThinkingConfigSnake
*
GeminiThinkingConfig
`json:"thinking_config,omitempty"`
SpeechConfigSnake
json
.
RawMessage
`json:"speech_config,omitempty"`
ImageConfigSnake
json
.
RawMessage
`json:"image_config,omitempty"`
}
if
err
:=
common
.
Unmarshal
(
data
,
&
aux
);
err
!=
nil
{
return
err
}
*
c
=
GeminiChatGenerationConfig
(
aux
.
Alias
)
// Prioritize snake_case if present
if
aux
.
TopPSnake
!=
0
{
c
.
TopP
=
aux
.
TopPSnake
}
if
aux
.
TopKSnake
!=
0
{
c
.
TopK
=
aux
.
TopKSnake
}
if
aux
.
MaxOutputTokensSnake
!=
0
{
c
.
MaxOutputTokens
=
aux
.
MaxOutputTokensSnake
}
if
aux
.
CandidateCountSnake
!=
0
{
c
.
CandidateCount
=
aux
.
CandidateCountSnake
}
if
len
(
aux
.
StopSequencesSnake
)
>
0
{
c
.
StopSequences
=
aux
.
StopSequencesSnake
}
if
aux
.
ResponseMimeTypeSnake
!=
""
{
c
.
ResponseMimeType
=
aux
.
ResponseMimeTypeSnake
}
if
aux
.
ResponseSchemaSnake
!=
nil
{
c
.
ResponseSchema
=
aux
.
ResponseSchemaSnake
}
if
len
(
aux
.
ResponseJsonSchemaSnake
)
>
0
{
c
.
ResponseJsonSchema
=
aux
.
ResponseJsonSchemaSnake
}
if
aux
.
PresencePenaltySnake
!=
nil
{
c
.
PresencePenalty
=
aux
.
PresencePenaltySnake
}
if
aux
.
FrequencyPenaltySnake
!=
nil
{
c
.
FrequencyPenalty
=
aux
.
FrequencyPenaltySnake
}
if
aux
.
ResponseLogprobsSnake
{
c
.
ResponseLogprobs
=
aux
.
ResponseLogprobsSnake
}
if
aux
.
MediaResolutionSnake
!=
""
{
c
.
MediaResolution
=
aux
.
MediaResolutionSnake
}
if
len
(
aux
.
ResponseModalitiesSnake
)
>
0
{
c
.
ResponseModalities
=
aux
.
ResponseModalitiesSnake
}
if
aux
.
ThinkingConfigSnake
!=
nil
{
c
.
ThinkingConfig
=
aux
.
ThinkingConfigSnake
}
if
len
(
aux
.
SpeechConfigSnake
)
>
0
{
c
.
SpeechConfig
=
aux
.
SpeechConfigSnake
}
if
len
(
aux
.
ImageConfigSnake
)
>
0
{
c
.
ImageConfig
=
aux
.
ImageConfigSnake
}
return
nil
}
type
MediaResolution
string
type
GeminiChatCandidate
struct
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment