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
2e4d27e0
authored
Dec 02, 2025
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(token_estimator): add concurrency support for multipliers retrieval
parent
1fededce
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
2 deletions
+9
-2
service/token_estimator.go
+9
-2
No files found.
service/token_estimator.go
View file @
2e4d27e0
...
...
@@ -3,6 +3,7 @@ package service
import
(
"math"
"strings"
"sync"
"unicode"
)
...
...
@@ -31,7 +32,8 @@ type multipliers struct {
BasePad
int
// 基础起步消耗 (Start/End tokens)
}
var
multipliersMap
=
map
[
Provider
]
multipliers
{
var
(
multipliersMap
=
map
[
Provider
]
multipliers
{
Gemini
:
{
Word
:
1.15
,
Number
:
2.8
,
CJK
:
0.68
,
Symbol
:
0.38
,
MathSymbol
:
1.05
,
URLDelim
:
1.2
,
AtSign
:
2.5
,
Emoji
:
1.08
,
Newline
:
1.15
,
Space
:
0.2
,
BasePad
:
0
,
},
...
...
@@ -41,10 +43,15 @@ var multipliersMap = map[Provider]multipliers{
OpenAI
:
{
Word
:
1.02
,
Number
:
1.55
,
CJK
:
0.85
,
Symbol
:
0.4
,
MathSymbol
:
2.68
,
URLDelim
:
1.0
,
AtSign
:
2.0
,
Emoji
:
2.12
,
Newline
:
0.5
,
Space
:
0.42
,
BasePad
:
0
,
},
}
}
multipliersLock
sync
.
RWMutex
)
// getMultipliers 根据厂商获取权重配置
func
getMultipliers
(
p
Provider
)
multipliers
{
multipliersLock
.
RLock
()
defer
multipliersLock
.
RUnlock
()
switch
p
{
case
Gemini
:
return
multipliersMap
[
Gemini
]
...
...
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