diff --git a/README.md b/README.md
index a9db89a825..853ec06794 100644
--- a/README.md
+++ b/README.md
@@ -175,6 +175,10 @@ sudo service nginx restart
初始账号用户名为 `root`,密码为 `123456`。
+### 通过宝塔面板进行一键部署
+1. 安装宝塔面板9.2.0及以上版本,前往 [宝塔面板](https://www.bt.cn/new/download.html?r=dk_oneapi) 官网,选择正式版的脚本下载安装;
+2. 安装后登录宝塔面板,在左侧菜单栏中点击 `Docker`,首次进入会提示安装 `Docker` 服务,点击立即安装,按提示完成安装;
+3. 安装完成后在应用商店中搜索 `One-API`,点击安装,配置域名等基本信息即可完成安装;
### 基于 Docker Compose 进行部署
@@ -218,7 +222,7 @@ docker-compose ps
3. 所有从服务器必须设置 `NODE_TYPE` 为 `slave`,不设置则默认为主服务器。
4. 设置 `SYNC_FREQUENCY` 后服务器将定期从数据库同步配置,在使用远程数据库的情况下,推荐设置该项并启用 Redis,无论主从。
5. 从服务器可以选择设置 `FRONTEND_BASE_URL`,以重定向页面请求到主服务器。
-6. 从服务器上**分别**装好 Redis,设置好 `REDIS_CONN_STRING`,这样可以做到在缓存未过期的情况下数据库零访问,可以减少延迟。
+6. 从服务器上**分别**装好 Redis,设置好 `REDIS_CONN_STRING`,这样可以做到在缓存未过期的情况下数据库零访问,可以减少延迟(Redis 集群或者哨兵模式的支持请参考环境变量说明)。
7. 如果主服务器访问数据库延迟也比较高,则也需要启用 Redis,并设置 `SYNC_FREQUENCY`,以定期从数据库同步配置。
环境变量的具体使用方法详见[此处](#环境变量)。
@@ -347,6 +351,11 @@ graph LR
1. `REDIS_CONN_STRING`:设置之后将使用 Redis 作为缓存使用。
+ 例子:`REDIS_CONN_STRING=redis://default:redispw@localhost:49153`
+ 如果数据库访问延迟很低,没有必要启用 Redis,启用后反而会出现数据滞后的问题。
+ + 如果需要使用哨兵或者集群模式:
+ + 则需要把该环境变量设置为节点列表,例如:`localhost:49153,localhost:49154,localhost:49155`。
+ + 除此之外还需要设置以下环境变量:
+ + `REDIS_PASSWORD`:Redis 集群或者哨兵模式下的密码设置。
+ + `REDIS_MASTER_NAME`:Redis 哨兵模式下主节点的名称。
2. `SESSION_SECRET`:设置之后将使用固定的会话密钥,这样系统重新启动后已登录用户的 cookie 将依旧有效。
+ 例子:`SESSION_SECRET=random_string`
3. `SQL_DSN`:设置之后将使用指定数据库而非 SQLite,请使用 MySQL 或 PostgreSQL。
diff --git a/common/redis.go b/common/redis.go
index f32055679f..55d4931c92 100644
--- a/common/redis.go
+++ b/common/redis.go
@@ -2,13 +2,15 @@ package common
import (
"context"
- "github.com/go-redis/redis/v8"
- "github.com/songquanpeng/one-api/common/logger"
"os"
+ "strings"
"time"
+
+ "github.com/go-redis/redis/v8"
+ "github.com/songquanpeng/one-api/common/logger"
)
-var RDB *redis.Client
+var RDB redis.Cmdable
var RedisEnabled = true
// InitRedisClient This function is called after init()
@@ -23,13 +25,23 @@ func InitRedisClient() (err error) {
logger.SysLog("SYNC_FREQUENCY not set, Redis is disabled")
return nil
}
- logger.SysLog("Redis is enabled")
- opt, err := redis.ParseURL(os.Getenv("REDIS_CONN_STRING"))
- if err != nil {
- logger.FatalLog("failed to parse Redis connection string: " + err.Error())
+ redisConnString := os.Getenv("REDIS_CONN_STRING")
+ if os.Getenv("REDIS_MASTER_NAME") == "" {
+ logger.SysLog("Redis is enabled")
+ opt, err := redis.ParseURL(redisConnString)
+ if err != nil {
+ logger.FatalLog("failed to parse Redis connection string: " + err.Error())
+ }
+ RDB = redis.NewClient(opt)
+ } else {
+ // cluster mode
+ logger.SysLog("Redis cluster mode enabled")
+ RDB = redis.NewUniversalClient(&redis.UniversalOptions{
+ Addrs: strings.Split(redisConnString, ","),
+ Password: os.Getenv("REDIS_PASSWORD"),
+ MasterName: os.Getenv("REDIS_MASTER_NAME"),
+ })
}
- RDB = redis.NewClient(opt)
-
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
diff --git a/controller/channel-billing.go b/controller/channel-billing.go
index a6ffaafe7c..e69cd9c256 100644
--- a/controller/channel-billing.go
+++ b/controller/channel-billing.go
@@ -4,16 +4,17 @@ import (
"encoding/json"
"errors"
"fmt"
+ "io"
+ "net/http"
+ "strconv"
+ "time"
+
"github.com/songquanpeng/one-api/common/client"
"github.com/songquanpeng/one-api/common/config"
"github.com/songquanpeng/one-api/common/logger"
"github.com/songquanpeng/one-api/model"
"github.com/songquanpeng/one-api/monitor"
"github.com/songquanpeng/one-api/relay/channeltype"
- "io"
- "net/http"
- "strconv"
- "time"
"github.com/gin-gonic/gin"
)
@@ -101,6 +102,16 @@ type SiliconFlowUsageResponse struct {
} `json:"data"`
}
+type DeepSeekUsageResponse struct {
+ IsAvailable bool `json:"is_available"`
+ BalanceInfos []struct {
+ Currency string `json:"currency"`
+ TotalBalance string `json:"total_balance"`
+ GrantedBalance string `json:"granted_balance"`
+ ToppedUpBalance string `json:"topped_up_balance"`
+ } `json:"balance_infos"`
+}
+
// GetAuthHeader get auth header
func GetAuthHeader(token string) http.Header {
h := http.Header{}
@@ -237,7 +248,36 @@ func updateChannelSiliconFlowBalance(channel *model.Channel) (float64, error) {
if response.Code != 20000 {
return 0, fmt.Errorf("code: %d, message: %s", response.Code, response.Message)
}
- balance, err := strconv.ParseFloat(response.Data.Balance, 64)
+ balance, err := strconv.ParseFloat(response.Data.TotalBalance, 64)
+ if err != nil {
+ return 0, err
+ }
+ channel.UpdateBalance(balance)
+ return balance, nil
+}
+
+func updateChannelDeepSeekBalance(channel *model.Channel) (float64, error) {
+ url := "https://api.deepseek.com/user/balance"
+ body, err := GetResponseBody("GET", url, channel, GetAuthHeader(channel.Key))
+ if err != nil {
+ return 0, err
+ }
+ response := DeepSeekUsageResponse{}
+ err = json.Unmarshal(body, &response)
+ if err != nil {
+ return 0, err
+ }
+ index := -1
+ for i, balanceInfo := range response.BalanceInfos {
+ if balanceInfo.Currency == "CNY" {
+ index = i
+ break
+ }
+ }
+ if index == -1 {
+ return 0, errors.New("currency CNY not found")
+ }
+ balance, err := strconv.ParseFloat(response.BalanceInfos[index].TotalBalance, 64)
if err != nil {
return 0, err
}
@@ -271,6 +311,8 @@ func updateChannelBalance(channel *model.Channel) (float64, error) {
return updateChannelAIGC2DBalance(channel)
case channeltype.SiliconFlow:
return updateChannelSiliconFlowBalance(channel)
+ case channeltype.DeepSeek:
+ return updateChannelDeepSeekBalance(channel)
default:
return 0, errors.New("尚未实现")
}
diff --git a/go.mod b/go.mod
index ada53bc33c..2106cf0f79 100644
--- a/go.mod
+++ b/go.mod
@@ -25,7 +25,7 @@ require (
github.com/pkoukk/tiktoken-go v0.1.7
github.com/smartystreets/goconvey v1.8.1
github.com/stretchr/testify v1.9.0
- golang.org/x/crypto v0.24.0
+ golang.org/x/crypto v0.31.0
golang.org/x/image v0.18.0
google.golang.org/api v0.187.0
gorm.io/driver/mysql v1.5.6
@@ -99,9 +99,9 @@ require (
golang.org/x/arch v0.8.0 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
- golang.org/x/sync v0.7.0 // indirect
- golang.org/x/sys v0.21.0 // indirect
- golang.org/x/text v0.16.0 // indirect
+ golang.org/x/sync v0.10.0 // indirect
+ golang.org/x/sys v0.28.0 // indirect
+ golang.org/x/text v0.21.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240617180043-68d350f18fd4 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240624140628-dc46fd24d27d // indirect
diff --git a/go.sum b/go.sum
index 53db8df289..c98f19656c 100644
--- a/go.sum
+++ b/go.sum
@@ -222,8 +222,8 @@ golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc=
golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
-golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI=
-golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM=
+golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
+golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/image v0.18.0 h1:jGzIakQa/ZXI1I0Fxvaa9W7yP25TqT6cHIHn+6CqvSQ=
golang.org/x/image v0.18.0/go.mod h1:4yyo5vMFQjVjUcVk4jEQcU9MGy/rulF5WvUILseCM2E=
@@ -244,20 +244,20 @@ golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbht
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
-golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
+golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
+golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
-golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
+golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
-golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
-golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
+golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
+golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
diff --git a/relay/adaptor/ali/constants.go b/relay/adaptor/ali/constants.go
index 3f24ce2e14..f3d9952000 100644
--- a/relay/adaptor/ali/constants.go
+++ b/relay/adaptor/ali/constants.go
@@ -1,7 +1,23 @@
package ali
var ModelList = []string{
- "qwen-turbo", "qwen-plus", "qwen-max", "qwen-max-longcontext",
- "text-embedding-v1",
+ "qwen-turbo", "qwen-turbo-latest",
+ "qwen-plus", "qwen-plus-latest",
+ "qwen-max", "qwen-max-latest",
+ "qwen-max-longcontext",
+ "qwen-vl-max", "qwen-vl-max-latest", "qwen-vl-plus", "qwen-vl-plus-latest",
+ "qwen-vl-ocr", "qwen-vl-ocr-latest",
+ "qwen-audio-turbo",
+ "qwen-math-plus", "qwen-math-plus-latest", "qwen-math-turbo", "qwen-math-turbo-latest",
+ "qwen-coder-plus", "qwen-coder-plus-latest", "qwen-coder-turbo", "qwen-coder-turbo-latest",
+ "qwq-32b-preview", "qwen2.5-72b-instruct", "qwen2.5-32b-instruct", "qwen2.5-14b-instruct", "qwen2.5-7b-instruct", "qwen2.5-3b-instruct", "qwen2.5-1.5b-instruct", "qwen2.5-0.5b-instruct",
+ "qwen2-72b-instruct", "qwen2-57b-a14b-instruct", "qwen2-7b-instruct", "qwen2-1.5b-instruct", "qwen2-0.5b-instruct",
+ "qwen1.5-110b-chat", "qwen1.5-72b-chat", "qwen1.5-32b-chat", "qwen1.5-14b-chat", "qwen1.5-7b-chat", "qwen1.5-1.8b-chat", "qwen1.5-0.5b-chat",
+ "qwen-72b-chat", "qwen-14b-chat", "qwen-7b-chat", "qwen-1.8b-chat", "qwen-1.8b-longcontext-chat",
+ "qwen2-vl-7b-instruct", "qwen2-vl-2b-instruct", "qwen-vl-v1", "qwen-vl-chat-v1",
+ "qwen2-audio-instruct", "qwen-audio-chat",
+ "qwen2.5-math-72b-instruct", "qwen2.5-math-7b-instruct", "qwen2.5-math-1.5b-instruct", "qwen2-math-72b-instruct", "qwen2-math-7b-instruct", "qwen2-math-1.5b-instruct",
+ "qwen2.5-coder-32b-instruct", "qwen2.5-coder-14b-instruct", "qwen2.5-coder-7b-instruct", "qwen2.5-coder-3b-instruct", "qwen2.5-coder-1.5b-instruct", "qwen2.5-coder-0.5b-instruct",
+ "text-embedding-v1", "text-embedding-v3", "text-embedding-v2", "text-embedding-async-v2", "text-embedding-async-v1",
"ali-stable-diffusion-xl", "ali-stable-diffusion-v1.5", "wanx-v1",
}
diff --git a/relay/adaptor/anthropic/constants.go b/relay/adaptor/anthropic/constants.go
index cb574706d4..8ea7c4d878 100644
--- a/relay/adaptor/anthropic/constants.go
+++ b/relay/adaptor/anthropic/constants.go
@@ -9,5 +9,4 @@ var ModelList = []string{
"claude-3-5-sonnet-20240620",
"claude-3-5-sonnet-20241022",
"claude-3-5-sonnet-latest",
- "claude-3-5-haiku-20241022",
}
diff --git a/relay/adaptor/gemini/constants.go b/relay/adaptor/gemini/constants.go
index fa53d63baf..9d1cbc4acd 100644
--- a/relay/adaptor/gemini/constants.go
+++ b/relay/adaptor/gemini/constants.go
@@ -7,4 +7,5 @@ var ModelList = []string{
"gemini-1.5-flash", "gemini-1.5-pro",
"text-embedding-004", "aqa",
"gemini-2.0-flash-exp",
+ "gemini-2.0-flash-thinking-exp",
}
diff --git a/relay/adaptor/gemini/main.go b/relay/adaptor/gemini/main.go
index d6ab45d489..3aa4974b83 100644
--- a/relay/adaptor/gemini/main.go
+++ b/relay/adaptor/gemini/main.go
@@ -55,6 +55,10 @@ func ConvertRequest(textRequest model.GeneralOpenAIRequest) *ChatRequest {
Category: "HARM_CATEGORY_DANGEROUS_CONTENT",
Threshold: config.GeminiSafetySetting,
},
+ {
+ Category: "HARM_CATEGORY_CIVIC_INTEGRITY",
+ Threshold: config.GeminiSafetySetting,
+ },
},
GenerationConfig: ChatGenerationConfig{
Temperature: textRequest.Temperature,
@@ -247,7 +251,14 @@ func responseGeminiChat2OpenAI(response *ChatResponse) *openai.TextResponse {
if candidate.Content.Parts[0].FunctionCall != nil {
choice.Message.ToolCalls = getToolCalls(&candidate)
} else {
- choice.Message.Content = candidate.Content.Parts[0].Text
+ var builder strings.Builder
+ for _, part := range candidate.Content.Parts {
+ if i > 0 {
+ builder.WriteString("\n")
+ }
+ builder.WriteString(part.Text)
+ }
+ choice.Message.Content = builder.String()
}
} else {
choice.Message.Content = ""
diff --git a/relay/adaptor/openai/constants.go b/relay/adaptor/openai/constants.go
index be4804c259..8a643bc6ad 100644
--- a/relay/adaptor/openai/constants.go
+++ b/relay/adaptor/openai/constants.go
@@ -9,6 +9,7 @@ var ModelList = []string{
"gpt-4-turbo-preview", "gpt-4-turbo", "gpt-4-turbo-2024-04-09",
"gpt-4o", "gpt-4o-2024-05-13",
"gpt-4o-2024-08-06",
+ "gpt-4o-2024-11-20",
"chatgpt-4o-latest",
"gpt-4o-mini", "gpt-4o-mini-2024-07-18",
"gpt-4-vision-preview",
diff --git a/relay/adaptor/vertexai/gemini/adapter.go b/relay/adaptor/vertexai/gemini/adapter.go
index 0557b075c6..b537787553 100644
--- a/relay/adaptor/vertexai/gemini/adapter.go
+++ b/relay/adaptor/vertexai/gemini/adapter.go
@@ -18,7 +18,7 @@ var ModelList = []string{
"gemini-pro", "gemini-pro-vision",
"gemini-1.5-pro-001", "gemini-1.5-flash-001",
"gemini-1.5-pro-002", "gemini-1.5-flash-002",
- "gemini-2.0-flash-exp",
+ "gemini-2.0-flash-exp", "gemini-2.0-flash-thinking-exp",
}
type Adaptor struct {
diff --git a/relay/billing/ratio/model.go b/relay/billing/ratio/model.go
index 613d2b3124..f83aa70c11 100644
--- a/relay/billing/ratio/model.go
+++ b/relay/billing/ratio/model.go
@@ -37,6 +37,7 @@ var ModelRatio = map[string]float64{
"chatgpt-4o-latest": 2.5, // $0.005 / 1K tokens
"gpt-4o-2024-05-13": 2.5, // $0.005 / 1K tokens
"gpt-4o-2024-08-06": 1.25, // $0.0025 / 1K tokens
+ "gpt-4o-2024-11-20": 1.25, // $0.0025 / 1K tokens
"gpt-4o-mini": 0.075, // $0.00015 / 1K tokens
"gpt-4o-mini-2024-07-18": 0.075, // $0.00015 / 1K tokens
"gpt-4-vision-preview": 5, // $0.01 / 1K tokens
@@ -108,14 +109,15 @@ var ModelRatio = map[string]float64{
"bge-large-en": 0.002 * RMB,
"tao-8k": 0.002 * RMB,
// https://ai.google.dev/pricing
- "gemini-pro": 1, // $0.00025 / 1k characters -> $0.001 / 1k tokens
- "gemini-1.0-pro": 1,
- "gemini-1.5-pro": 1,
- "gemini-1.5-pro-001": 1,
- "gemini-1.5-flash": 1,
- "gemini-1.5-flash-001": 1,
- "gemini-2.0-flash-exp": 1,
- "aqa": 1,
+ "gemini-pro": 1, // $0.00025 / 1k characters -> $0.001 / 1k tokens
+ "gemini-1.0-pro": 1,
+ "gemini-1.5-pro": 1,
+ "gemini-1.5-pro-001": 1,
+ "gemini-1.5-flash": 1,
+ "gemini-1.5-flash-001": 1,
+ "gemini-2.0-flash-exp": 1,
+ "gemini-2.0-flash-thinking-exp": 1,
+ "aqa": 1,
// https://open.bigmodel.cn/pricing
"glm-4": 0.1 * RMB,
"glm-4v": 0.1 * RMB,
@@ -127,29 +129,94 @@ var ModelRatio = map[string]float64{
"chatglm_lite": 0.1429, // ¥0.002 / 1k tokens
"cogview-3": 0.25 * RMB,
// https://help.aliyun.com/zh/dashscope/developer-reference/tongyi-thousand-questions-metering-and-billing
- "qwen-turbo": 0.5715, // ¥0.008 / 1k tokens
- "qwen-plus": 1.4286, // ¥0.02 / 1k tokens
- "qwen-max": 1.4286, // ¥0.02 / 1k tokens
- "qwen-max-longcontext": 1.4286, // ¥0.02 / 1k tokens
- "text-embedding-v1": 0.05, // ¥0.0007 / 1k tokens
- "ali-stable-diffusion-xl": 8,
- "ali-stable-diffusion-v1.5": 8,
- "wanx-v1": 8,
- "SparkDesk": 1.2858, // ¥0.018 / 1k tokens
- "SparkDesk-v1.1": 1.2858, // ¥0.018 / 1k tokens
- "SparkDesk-v2.1": 1.2858, // ¥0.018 / 1k tokens
- "SparkDesk-v3.1": 1.2858, // ¥0.018 / 1k tokens
- "SparkDesk-v3.1-128K": 1.2858, // ¥0.018 / 1k tokens
- "SparkDesk-v3.5": 1.2858, // ¥0.018 / 1k tokens
- "SparkDesk-v3.5-32K": 1.2858, // ¥0.018 / 1k tokens
- "SparkDesk-v4.0": 1.2858, // ¥0.018 / 1k tokens
- "360GPT_S2_V9": 0.8572, // ¥0.012 / 1k tokens
- "embedding-bert-512-v1": 0.0715, // ¥0.001 / 1k tokens
- "embedding_s1_v1": 0.0715, // ¥0.001 / 1k tokens
- "semantic_similarity_s1_v1": 0.0715, // ¥0.001 / 1k tokens
- "hunyuan": 7.143, // ¥0.1 / 1k tokens // https://cloud.tencent.com/document/product/1729/97731#e0e6be58-60c8-469f-bdeb-6c264ce3b4d0
- "ChatStd": 0.01 * RMB,
- "ChatPro": 0.1 * RMB,
+ "qwen-turbo": 1.4286, // ¥0.02 / 1k tokens
+ "qwen-turbo-latest": 1.4286,
+ "qwen-plus": 1.4286,
+ "qwen-plus-latest": 1.4286,
+ "qwen-max": 1.4286,
+ "qwen-max-latest": 1.4286,
+ "qwen-max-longcontext": 1.4286,
+ "qwen-vl-max": 1.4286,
+ "qwen-vl-max-latest": 1.4286,
+ "qwen-vl-plus": 1.4286,
+ "qwen-vl-plus-latest": 1.4286,
+ "qwen-vl-ocr": 1.4286,
+ "qwen-vl-ocr-latest": 1.4286,
+ "qwen-audio-turbo": 1.4286,
+ "qwen-math-plus": 1.4286,
+ "qwen-math-plus-latest": 1.4286,
+ "qwen-math-turbo": 1.4286,
+ "qwen-math-turbo-latest": 1.4286,
+ "qwen-coder-plus": 1.4286,
+ "qwen-coder-plus-latest": 1.4286,
+ "qwen-coder-turbo": 1.4286,
+ "qwen-coder-turbo-latest": 1.4286,
+ "qwq-32b-preview": 1.4286,
+ "qwen2.5-72b-instruct": 1.4286,
+ "qwen2.5-32b-instruct": 1.4286,
+ "qwen2.5-14b-instruct": 1.4286,
+ "qwen2.5-7b-instruct": 1.4286,
+ "qwen2.5-3b-instruct": 1.4286,
+ "qwen2.5-1.5b-instruct": 1.4286,
+ "qwen2.5-0.5b-instruct": 1.4286,
+ "qwen2-72b-instruct": 1.4286,
+ "qwen2-57b-a14b-instruct": 1.4286,
+ "qwen2-7b-instruct": 1.4286,
+ "qwen2-1.5b-instruct": 1.4286,
+ "qwen2-0.5b-instruct": 1.4286,
+ "qwen1.5-110b-chat": 1.4286,
+ "qwen1.5-72b-chat": 1.4286,
+ "qwen1.5-32b-chat": 1.4286,
+ "qwen1.5-14b-chat": 1.4286,
+ "qwen1.5-7b-chat": 1.4286,
+ "qwen1.5-1.8b-chat": 1.4286,
+ "qwen1.5-0.5b-chat": 1.4286,
+ "qwen-72b-chat": 1.4286,
+ "qwen-14b-chat": 1.4286,
+ "qwen-7b-chat": 1.4286,
+ "qwen-1.8b-chat": 1.4286,
+ "qwen-1.8b-longcontext-chat": 1.4286,
+ "qwen2-vl-7b-instruct": 1.4286,
+ "qwen2-vl-2b-instruct": 1.4286,
+ "qwen-vl-v1": 1.4286,
+ "qwen-vl-chat-v1": 1.4286,
+ "qwen2-audio-instruct": 1.4286,
+ "qwen-audio-chat": 1.4286,
+ "qwen2.5-math-72b-instruct": 1.4286,
+ "qwen2.5-math-7b-instruct": 1.4286,
+ "qwen2.5-math-1.5b-instruct": 1.4286,
+ "qwen2-math-72b-instruct": 1.4286,
+ "qwen2-math-7b-instruct": 1.4286,
+ "qwen2-math-1.5b-instruct": 1.4286,
+ "qwen2.5-coder-32b-instruct": 1.4286,
+ "qwen2.5-coder-14b-instruct": 1.4286,
+ "qwen2.5-coder-7b-instruct": 1.4286,
+ "qwen2.5-coder-3b-instruct": 1.4286,
+ "qwen2.5-coder-1.5b-instruct": 1.4286,
+ "qwen2.5-coder-0.5b-instruct": 1.4286,
+ "text-embedding-v1": 0.05, // ¥0.0007 / 1k tokens
+ "text-embedding-v3": 0.05,
+ "text-embedding-v2": 0.05,
+ "text-embedding-async-v2": 0.05,
+ "text-embedding-async-v1": 0.05,
+ "ali-stable-diffusion-xl": 8.00,
+ "ali-stable-diffusion-v1.5": 8.00,
+ "wanx-v1": 8.00,
+ "SparkDesk": 1.2858, // ¥0.018 / 1k tokens
+ "SparkDesk-v1.1": 1.2858, // ¥0.018 / 1k tokens
+ "SparkDesk-v2.1": 1.2858, // ¥0.018 / 1k tokens
+ "SparkDesk-v3.1": 1.2858, // ¥0.018 / 1k tokens
+ "SparkDesk-v3.1-128K": 1.2858, // ¥0.018 / 1k tokens
+ "SparkDesk-v3.5": 1.2858, // ¥0.018 / 1k tokens
+ "SparkDesk-v3.5-32K": 1.2858, // ¥0.018 / 1k tokens
+ "SparkDesk-v4.0": 1.2858, // ¥0.018 / 1k tokens
+ "360GPT_S2_V9": 0.8572, // ¥0.012 / 1k tokens
+ "embedding-bert-512-v1": 0.0715, // ¥0.001 / 1k tokens
+ "embedding_s1_v1": 0.0715, // ¥0.001 / 1k tokens
+ "semantic_similarity_s1_v1": 0.0715, // ¥0.001 / 1k tokens
+ "hunyuan": 7.143, // ¥0.1 / 1k tokens // https://cloud.tencent.com/document/product/1729/97731#e0e6be58-60c8-469f-bdeb-6c264ce3b4d0
+ "ChatStd": 0.01 * RMB,
+ "ChatPro": 0.1 * RMB,
// https://platform.moonshot.cn/pricing
"moonshot-v1-8k": 0.012 * RMB,
"moonshot-v1-32k": 0.024 * RMB,
@@ -387,11 +454,13 @@ func GetCompletionRatio(name string, channelType int) float64 {
return 4.0 / 3.0
}
if strings.HasPrefix(name, "gpt-4") {
- if strings.HasPrefix(name, "gpt-4o-mini") || name == "gpt-4o-2024-08-06" {
+ if strings.HasPrefix(name, "gpt-4o") {
+ if name == "gpt-4o-2024-05-13" {
+ return 3
+ }
return 4
}
if strings.HasPrefix(name, "gpt-4-turbo") ||
- strings.HasPrefix(name, "gpt-4o") ||
strings.HasSuffix(name, "preview") {
return 3
}
diff --git a/relay/controller/audio.go b/relay/controller/audio.go
index 83040662eb..e3d57b1eb4 100644
--- a/relay/controller/audio.go
+++ b/relay/controller/audio.go
@@ -110,16 +110,9 @@ func RelayAudioHelper(c *gin.Context, relayMode int) *relaymodel.ErrorWithStatus
}()
// map model name
- modelMapping := c.GetString(ctxkey.ModelMapping)
- if modelMapping != "" {
- modelMap := make(map[string]string)
- err := json.Unmarshal([]byte(modelMapping), &modelMap)
- if err != nil {
- return openai.ErrorWrapper(err, "unmarshal_model_mapping_failed", http.StatusInternalServerError)
- }
- if modelMap[audioModel] != "" {
- audioModel = modelMap[audioModel]
- }
+ modelMapping := c.GetStringMapString(ctxkey.ModelMapping)
+ if modelMapping != nil && modelMapping[audioModel] != "" {
+ audioModel = modelMapping[audioModel]
}
baseURL := channeltype.ChannelBaseURLs[channelType]
diff --git a/web/berry/src/views/Channel/component/TableRow.js b/web/berry/src/views/Channel/component/TableRow.js
index 3114479d9c..525f9188c9 100644
--- a/web/berry/src/views/Channel/component/TableRow.js
+++ b/web/berry/src/views/Channel/component/TableRow.js
@@ -268,6 +268,8 @@ function renderBalance(type, balance) {
return ¥{balance.toFixed(2)};
case 13: // AIGC2D
return {renderNumber(balance)};
+ case 36: // DeepSeek
+ return ¥{balance.toFixed(2)};
case 44: // SiliconFlow
return ¥{balance.toFixed(2)};
default:
diff --git a/web/default/src/components/ChannelsTable.js b/web/default/src/components/ChannelsTable.js
index 6e0ec05d2f..e745814b3f 100644
--- a/web/default/src/components/ChannelsTable.js
+++ b/web/default/src/components/ChannelsTable.js
@@ -52,6 +52,8 @@ function renderBalance(type, balance) {
return ¥{balance.toFixed(2)};
case 13: // AIGC2D
return {renderNumber(balance)};
+ case 36: // DeepSeek
+ return ¥{balance.toFixed(2)};
case 44: // SiliconFlow
return ¥{balance.toFixed(2)};
default: