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
a696cf58
authored
Mar 27, 2025
by
1808837298@qq.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: Enhance GetCompletionRatio function
parent
29ef1307
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
33 deletions
+42
-33
setting/operation_setting/model-ratio.go
+42
-33
No files found.
setting/operation_setting/model-ratio.go
View file @
a696cf58
...
...
@@ -375,6 +375,17 @@ func GetCompletionRatio(name string) float64 {
return
ratio
}
}
hardCodedRatio
,
contain
:=
getHardcodedCompletionModelRatio
(
name
)
if
contain
{
return
hardCodedRatio
}
if
ratio
,
ok
:=
CompletionRatio
[
name
];
ok
{
return
ratio
}
return
hardCodedRatio
}
func
getHardcodedCompletionModelRatio
(
name
string
)
(
float64
,
bool
)
{
lowercaseName
:=
strings
.
ToLower
(
name
)
if
strings
.
HasPrefix
(
name
,
"gpt-4-gizmo"
)
{
name
=
"gpt-4-gizmo-*"
...
...
@@ -385,87 +396,85 @@ func GetCompletionRatio(name string) float64 {
if
strings
.
HasPrefix
(
name
,
"gpt-4"
)
&&
!
strings
.
HasSuffix
(
name
,
"-all"
)
&&
!
strings
.
HasSuffix
(
name
,
"-gizmo-*"
)
{
if
strings
.
HasPrefix
(
name
,
"gpt-4o"
)
{
if
name
==
"gpt-4o-2024-05-13"
{
return
3
return
3
,
true
}
return
4
return
4
,
true
}
if
strings
.
HasPrefix
(
name
,
"gpt-4.5"
)
{
return
2
if
strings
.
HasPrefix
(
name
,
"gpt-4.5"
)
&&
strings
.
HasSuffix
(
name
,
"preview"
)
{
return
2
,
true
}
if
strings
.
HasPrefix
(
name
,
"gpt-4-turbo"
)
||
(
strings
.
HasPrefix
(
name
,
"gpt-4-"
)
&&
strings
.
HasSuffix
(
name
,
"preview"
))
{
return
3
return
3
,
true
}
return
2
// 没有特殊标记的 gpt-4 模型默认倍率为 2
return
2
,
false
}
if
strings
.
HasPrefix
(
name
,
"o1"
)
||
strings
.
HasPrefix
(
name
,
"o3"
)
{
return
4
return
4
,
true
}
if
name
==
"chatgpt-4o-latest"
{
return
3
return
3
,
true
}
if
strings
.
Contains
(
name
,
"claude-instant-1"
)
{
return
3
return
3
,
true
}
else
if
strings
.
Contains
(
name
,
"claude-2"
)
{
return
3
return
3
,
true
}
else
if
strings
.
Contains
(
name
,
"claude-3"
)
{
return
5
return
5
,
true
}
if
strings
.
HasPrefix
(
name
,
"gpt-3.5"
)
{
if
name
==
"gpt-3.5-turbo"
||
strings
.
HasSuffix
(
name
,
"0125"
)
{
// https://openai.com/blog/new-embedding-models-and-api-updates
// Updated GPT-3.5 Turbo model and lower pricing
return
3
return
3
,
true
}
if
strings
.
HasSuffix
(
name
,
"1106"
)
{
return
2
return
2
,
true
}
return
4.0
/
3.0
return
4.0
/
3.0
,
true
}
if
strings
.
HasPrefix
(
name
,
"mistral-"
)
{
return
3
return
3
,
true
}
if
strings
.
HasPrefix
(
name
,
"gemini-"
)
{
return
4
return
4
,
true
}
if
strings
.
HasPrefix
(
name
,
"command"
)
{
switch
name
{
case
"command-r"
:
return
3
return
3
,
true
case
"command-r-plus"
:
return
5
return
5
,
true
case
"command-r-08-2024"
:
return
4
return
4
,
true
case
"command-r-plus-08-2024"
:
return
4
return
4
,
true
default
:
return
4
return
4
,
true
}
}
// hint 只给官方上4倍率,由于开源模型供应商自行定价,不对其进行补全倍率进行强制对齐
if
lowercaseName
==
"deepseek-chat"
||
lowercaseName
==
"deepseek-reasoner"
{
return
4
return
4
,
true
}
if
strings
.
HasPrefix
(
name
,
"ERNIE-Speed-"
)
{
return
2
return
2
,
true
}
else
if
strings
.
HasPrefix
(
name
,
"ERNIE-Lite-"
)
{
return
2
return
2
,
true
}
else
if
strings
.
HasPrefix
(
name
,
"ERNIE-Character"
)
{
return
2
return
2
,
true
}
else
if
strings
.
HasPrefix
(
name
,
"ERNIE-Functions"
)
{
return
2
return
2
,
true
}
switch
name
{
case
"llama2-70b-4096"
:
return
0.8
/
0.64
return
0.8
/
0.64
,
true
case
"llama3-8b-8192"
:
return
2
return
2
,
true
case
"llama3-70b-8192"
:
return
0.79
/
0.59
}
if
ratio
,
ok
:=
CompletionRatio
[
name
];
ok
{
return
ratio
return
0.79
/
0.59
,
true
}
return
1
return
1
,
false
}
func
GetAudioRatio
(
name
string
)
float64
{
...
...
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