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
5b90f605
authored
Aug 29, 2025
by
t0ng7u
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/alpha' into alpha
parents
78260992
4bf9ef55
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
94 additions
and
2 deletions
+94
-2
model/pricing.go
+5
-2
model/pricing_default.go
+89
-0
No files found.
model/pricing.go
View file @
5b90f605
...
@@ -155,9 +155,12 @@ func updatePricing() {
...
@@ -155,9 +155,12 @@ func updatePricing() {
vendorMap
[
vendors
[
i
]
.
Id
]
=
&
vendors
[
i
]
vendorMap
[
vendors
[
i
]
.
Id
]
=
&
vendors
[
i
]
}
}
// 初始化默认供应商映射
initDefaultVendorMapping
(
metaMap
,
vendorMap
,
enableAbilities
)
// 构建对前端友好的供应商列表
// 构建对前端友好的供应商列表
vendorsList
=
make
([]
PricingVendor
,
0
,
len
(
vendor
s
))
vendorsList
=
make
([]
PricingVendor
,
0
,
len
(
vendor
Map
))
for
_
,
v
:=
range
vendor
s
{
for
_
,
v
:=
range
vendor
Map
{
vendorsList
=
append
(
vendorsList
,
PricingVendor
{
vendorsList
=
append
(
vendorsList
,
PricingVendor
{
ID
:
v
.
Id
,
ID
:
v
.
Id
,
Name
:
v
.
Name
,
Name
:
v
.
Name
,
...
...
model/pricing_default.go
0 → 100644
View file @
5b90f605
package
model
import
(
"strings"
)
// 简化的供应商映射规则
var
defaultVendorRules
=
map
[
string
]
string
{
"gpt"
:
"OpenAI"
,
"dall-e"
:
"OpenAI"
,
"whisper"
:
"OpenAI"
,
"o1"
:
"OpenAI"
,
"o3"
:
"OpenAI"
,
"claude"
:
"Anthropic"
,
"gemini"
:
"Google"
,
"moonshot"
:
"Moonshot"
,
"kimi"
:
"Moonshot"
,
"chatglm"
:
"智谱"
,
"glm-"
:
"智谱"
,
"qwen"
:
"阿里巴巴"
,
"deepseek"
:
"DeepSeek"
,
"abab"
:
"MiniMax"
,
"ernie"
:
"百度"
,
"spark"
:
"讯飞"
,
"hunyuan"
:
"腾讯"
,
"command"
:
"Cohere"
,
"@cf/"
:
"Cloudflare"
,
"360"
:
"360"
,
"yi"
:
"零一万物"
,
"jina"
:
"Jina"
,
"mistral"
:
"Mistral"
,
"grok"
:
"xAI"
,
"llama"
:
"Meta"
,
"doubao"
:
"字节跳动"
,
"kling"
:
"快手"
,
"jimeng"
:
"即梦"
,
"vidu"
:
"Vidu"
,
}
// initDefaultVendorMapping 简化的默认供应商映射
func
initDefaultVendorMapping
(
metaMap
map
[
string
]
*
Model
,
vendorMap
map
[
int
]
*
Vendor
,
enableAbilities
[]
AbilityWithChannel
)
{
for
_
,
ability
:=
range
enableAbilities
{
modelName
:=
ability
.
Model
if
_
,
exists
:=
metaMap
[
modelName
];
exists
{
continue
}
// 匹配供应商
vendorID
:=
0
modelLower
:=
strings
.
ToLower
(
modelName
)
for
pattern
,
vendorName
:=
range
defaultVendorRules
{
if
strings
.
Contains
(
modelLower
,
pattern
)
{
vendorID
=
getOrCreateVendor
(
vendorName
,
vendorMap
)
break
}
}
// 创建模型元数据
metaMap
[
modelName
]
=
&
Model
{
ModelName
:
modelName
,
VendorID
:
vendorID
,
Status
:
1
,
NameRule
:
NameRuleExact
,
}
}
}
// 查找或创建供应商
func
getOrCreateVendor
(
vendorName
string
,
vendorMap
map
[
int
]
*
Vendor
)
int
{
// 查找现有供应商
for
id
,
vendor
:=
range
vendorMap
{
if
vendor
.
Name
==
vendorName
{
return
id
}
}
// 创建新供应商
newVendor
:=
&
Vendor
{
Name
:
vendorName
,
Status
:
1
,
}
if
err
:=
newVendor
.
Insert
();
err
!=
nil
{
return
0
}
vendorMap
[
newVendor
.
Id
]
=
newVendor
return
newVendor
.
Id
}
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