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
a5c2539c
authored
Aug 08, 2025
by
Calcium-Ion
Committed by
GitHub
Aug 08, 2025
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1525 from HynoR/chore/gpt5
feat: sync gpt-5 model ratio and support new reasoning effort
parents
047d4471
660b129b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
19 deletions
+31
-19
relay/channel/openai/adaptor.go
+27
-19
setting/ratio_setting/model_ratio.go
+4
-0
No files found.
relay/channel/openai/adaptor.go
View file @
a5c2539c
...
...
@@ -35,6 +35,21 @@ type Adaptor struct {
ResponseFormat
string
}
// parseReasoningEffortFromModelSuffix 从模型名称中解析推理级别
// support OAI models: o1-mini/o3-mini/o4-mini/o1/o3 etc...
// minimal effort only available in gpt-5
func
parseReasoningEffortFromModelSuffix
(
model
string
)
(
string
,
string
)
{
effortSuffixes
:=
[]
string
{
"-high"
,
"-minimal"
,
"-low"
,
"-medium"
}
for
_
,
suffix
:=
range
effortSuffixes
{
if
strings
.
HasSuffix
(
model
,
suffix
)
{
effort
:=
strings
.
TrimPrefix
(
suffix
,
"-"
)
originModel
:=
strings
.
TrimSuffix
(
model
,
suffix
)
return
effort
,
originModel
}
}
return
""
,
model
}
func
(
a
*
Adaptor
)
ConvertGeminiRequest
(
c
*
gin
.
Context
,
info
*
relaycommon
.
RelayInfo
,
request
*
dto
.
GeminiChatRequest
)
(
any
,
error
)
{
// 使用 service.GeminiToOpenAIRequest 转换请求格式
openaiRequest
,
err
:=
service
.
GeminiToOpenAIRequest
(
request
,
info
)
...
...
@@ -197,16 +212,14 @@ func (a *Adaptor) ConvertOpenAIRequest(c *gin.Context, info *relaycommon.RelayIn
request
.
MaxTokens
=
0
}
request
.
Temperature
=
nil
if
strings
.
HasSuffix
(
request
.
Model
,
"-high"
)
{
request
.
ReasoningEffort
=
"high"
request
.
Model
=
strings
.
TrimSuffix
(
request
.
Model
,
"-high"
)
}
else
if
strings
.
HasSuffix
(
request
.
Model
,
"-low"
)
{
request
.
ReasoningEffort
=
"low"
request
.
Model
=
strings
.
TrimSuffix
(
request
.
Model
,
"-low"
)
}
else
if
strings
.
HasSuffix
(
request
.
Model
,
"-medium"
)
{
request
.
ReasoningEffort
=
"medium"
request
.
Model
=
strings
.
TrimSuffix
(
request
.
Model
,
"-medium"
)
// 转换模型推理力度后缀
effort
,
originModel
:=
parseReasoningEffortFromModelSuffix
(
request
.
Model
)
if
effort
!=
""
{
request
.
ReasoningEffort
=
effort
request
.
Model
=
originModel
}
info
.
ReasoningEffort
=
request
.
ReasoningEffort
info
.
UpstreamModelName
=
request
.
Model
...
...
@@ -423,16 +436,11 @@ func detectImageMimeType(filename string) string {
}
func
(
a
*
Adaptor
)
ConvertOpenAIResponsesRequest
(
c
*
gin
.
Context
,
info
*
relaycommon
.
RelayInfo
,
request
dto
.
OpenAIResponsesRequest
)
(
any
,
error
)
{
// 模型后缀转换 reasoning effort
if
strings
.
HasSuffix
(
request
.
Model
,
"-high"
)
{
request
.
Reasoning
.
Effort
=
"high"
request
.
Model
=
strings
.
TrimSuffix
(
request
.
Model
,
"-high"
)
}
else
if
strings
.
HasSuffix
(
request
.
Model
,
"-low"
)
{
request
.
Reasoning
.
Effort
=
"low"
request
.
Model
=
strings
.
TrimSuffix
(
request
.
Model
,
"-low"
)
}
else
if
strings
.
HasSuffix
(
request
.
Model
,
"-medium"
)
{
request
.
Reasoning
.
Effort
=
"medium"
request
.
Model
=
strings
.
TrimSuffix
(
request
.
Model
,
"-medium"
)
// 转换模型推理力度后缀
effort
,
originModel
:=
parseReasoningEffortFromModelSuffix
(
request
.
Model
)
if
effort
!=
""
{
request
.
Reasoning
.
Effort
=
effort
request
.
Model
=
originModel
}
return
request
,
nil
}
...
...
setting/ratio_setting/model_ratio.go
View file @
a5c2539c
...
...
@@ -450,6 +450,10 @@ func getHardcodedCompletionModelRatio(name string) (float64, bool) {
}
return
4
,
true
}
// gpt-5 匹配
if
strings
.
HasPrefix
(
name
,
"gpt-5"
)
{
return
8
,
true
}
// gpt-4.5-preview匹配
if
strings
.
HasPrefix
(
name
,
"gpt-4.5-preview"
)
{
return
2
,
true
...
...
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