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
15b38adf
authored
Dec 26, 2025
by
Calcium-Ion
Committed by
GitHub
Dec 26, 2025
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2460 from seefs001/feature/gemini-flash-minial
fix(gemini): handle minimal reasoning effort budget
parents
8e4b8cc6
39df4748
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
11 deletions
+7
-11
relay/channel/gemini/adaptor.go
+2
-1
relay/channel/gemini/relay-gemini.go
+4
-9
setting/reasoning/suffix.go
+1
-1
No files found.
relay/channel/gemini/adaptor.go
View file @
15b38adf
...
@@ -13,6 +13,7 @@ import (
...
@@ -13,6 +13,7 @@ import (
relaycommon
"github.com/QuantumNous/new-api/relay/common"
relaycommon
"github.com/QuantumNous/new-api/relay/common"
"github.com/QuantumNous/new-api/relay/constant"
"github.com/QuantumNous/new-api/relay/constant"
"github.com/QuantumNous/new-api/setting/model_setting"
"github.com/QuantumNous/new-api/setting/model_setting"
"github.com/QuantumNous/new-api/setting/reasoning"
"github.com/QuantumNous/new-api/types"
"github.com/QuantumNous/new-api/types"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin"
...
@@ -137,7 +138,7 @@ func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
...
@@ -137,7 +138,7 @@ func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
info
.
UpstreamModelName
=
strings
.
TrimSuffix
(
info
.
UpstreamModelName
,
"-thinking"
)
info
.
UpstreamModelName
=
strings
.
TrimSuffix
(
info
.
UpstreamModelName
,
"-thinking"
)
}
else
if
strings
.
HasSuffix
(
info
.
UpstreamModelName
,
"-nothinking"
)
{
}
else
if
strings
.
HasSuffix
(
info
.
UpstreamModelName
,
"-nothinking"
)
{
info
.
UpstreamModelName
=
strings
.
TrimSuffix
(
info
.
UpstreamModelName
,
"-nothinking"
)
info
.
UpstreamModelName
=
strings
.
TrimSuffix
(
info
.
UpstreamModelName
,
"-nothinking"
)
}
else
if
baseModel
,
level
:=
parseThinkingLevelSuffix
(
info
.
UpstreamModelName
);
level
!=
""
{
}
else
if
baseModel
,
level
,
ok
:=
reasoning
.
TrimEffortSuffix
(
info
.
UpstreamModelName
);
ok
&&
level
!=
""
{
info
.
UpstreamModelName
=
baseModel
info
.
UpstreamModelName
=
baseModel
}
}
}
}
...
...
relay/channel/gemini/relay-gemini.go
View file @
15b38adf
...
@@ -98,6 +98,7 @@ func clampThinkingBudget(modelName string, budget int) int {
...
@@ -98,6 +98,7 @@ func clampThinkingBudget(modelName string, budget int) int {
// "effort": "high" - Allocates a large portion of tokens for reasoning (approximately 80% of max_tokens)
// "effort": "high" - Allocates a large portion of tokens for reasoning (approximately 80% of max_tokens)
// "effort": "medium" - Allocates a moderate portion of tokens (approximately 50% of max_tokens)
// "effort": "medium" - Allocates a moderate portion of tokens (approximately 50% of max_tokens)
// "effort": "low" - Allocates a smaller portion of tokens (approximately 20% of max_tokens)
// "effort": "low" - Allocates a smaller portion of tokens (approximately 20% of max_tokens)
// "effort": "minimal" - Allocates a minimal portion of tokens (approximately 5% of max_tokens)
func
clampThinkingBudgetByEffort
(
modelName
string
,
effort
string
)
int
{
func
clampThinkingBudgetByEffort
(
modelName
string
,
effort
string
)
int
{
isNew25Pro
:=
isNew25ProModel
(
modelName
)
isNew25Pro
:=
isNew25ProModel
(
modelName
)
is25FlashLite
:=
is25FlashLiteModel
(
modelName
)
is25FlashLite
:=
is25FlashLiteModel
(
modelName
)
...
@@ -118,18 +119,12 @@ func clampThinkingBudgetByEffort(modelName string, effort string) int {
...
@@ -118,18 +119,12 @@ func clampThinkingBudgetByEffort(modelName string, effort string) int {
maxBudget
=
maxBudget
*
50
/
100
maxBudget
=
maxBudget
*
50
/
100
case
"low"
:
case
"low"
:
maxBudget
=
maxBudget
*
20
/
100
maxBudget
=
maxBudget
*
20
/
100
case
"minimal"
:
maxBudget
=
maxBudget
*
5
/
100
}
}
return
clampThinkingBudget
(
modelName
,
maxBudget
)
return
clampThinkingBudget
(
modelName
,
maxBudget
)
}
}
func
parseThinkingLevelSuffix
(
modelName
string
)
(
string
,
string
)
{
base
,
level
,
ok
:=
reasoning
.
TrimEffortSuffix
(
modelName
)
if
!
ok
{
return
modelName
,
""
}
return
base
,
level
}
func
ThinkingAdaptor
(
geminiRequest
*
dto
.
GeminiChatRequest
,
info
*
relaycommon
.
RelayInfo
,
oaiRequest
...
dto
.
GeneralOpenAIRequest
)
{
func
ThinkingAdaptor
(
geminiRequest
*
dto
.
GeminiChatRequest
,
info
*
relaycommon
.
RelayInfo
,
oaiRequest
...
dto
.
GeneralOpenAIRequest
)
{
if
model_setting
.
GetGeminiSettings
()
.
ThinkingAdapterEnabled
{
if
model_setting
.
GetGeminiSettings
()
.
ThinkingAdapterEnabled
{
modelName
:=
info
.
UpstreamModelName
modelName
:=
info
.
UpstreamModelName
...
@@ -186,7 +181,7 @@ func ThinkingAdaptor(geminiRequest *dto.GeminiChatRequest, info *relaycommon.Rel
...
@@ -186,7 +181,7 @@ func ThinkingAdaptor(geminiRequest *dto.GeminiChatRequest, info *relaycommon.Rel
ThinkingBudget
:
common
.
GetPointer
(
0
),
ThinkingBudget
:
common
.
GetPointer
(
0
),
}
}
}
}
}
else
if
_
,
level
:=
parseThinkingLevelSuffix
(
modelName
);
level
!=
""
{
}
else
if
_
,
level
,
ok
:=
reasoning
.
TrimEffortSuffix
(
info
.
UpstreamModelName
);
ok
&&
level
!=
""
{
geminiRequest
.
GenerationConfig
.
ThinkingConfig
=
&
dto
.
GeminiThinkingConfig
{
geminiRequest
.
GenerationConfig
.
ThinkingConfig
=
&
dto
.
GeminiThinkingConfig
{
IncludeThoughts
:
true
,
IncludeThoughts
:
true
,
ThinkingLevel
:
level
,
ThinkingLevel
:
level
,
...
...
setting/reasoning/suffix.go
View file @
15b38adf
...
@@ -6,7 +6,7 @@ import (
...
@@ -6,7 +6,7 @@ import (
"github.com/samber/lo"
"github.com/samber/lo"
)
)
var
EffortSuffixes
=
[]
string
{
"-high"
,
"-medium"
,
"-low"
}
var
EffortSuffixes
=
[]
string
{
"-high"
,
"-medium"
,
"-low"
,
"-minimal"
}
// TrimEffortSuffix -> modelName level(low) exists
// TrimEffortSuffix -> modelName level(low) exists
func
TrimEffortSuffix
(
modelName
string
)
(
string
,
string
,
bool
)
{
func
TrimEffortSuffix
(
modelName
string
)
(
string
,
string
,
bool
)
{
...
...
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