Skip to content

Commit

Permalink
refactor: Improve channel status update logic and clean up code
Browse files Browse the repository at this point in the history
- Simplified conditional checks in UpdateChannelStatusById function in channel.go to enhance readability.
- Commented out unused image number check in relay-gemini.go for clarity.
- Updated JSON field in en.json for currency consistency, changing "元" from "RMB/CNY" to "CNY" and added a space in "实付金额:" for formatting.
  • Loading branch information
Calcium-Ion committed Dec 17, 2024
1 parent 70e7860 commit 2d865eb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
17 changes: 9 additions & 8 deletions model/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,19 +292,20 @@ func (channel *Channel) Delete() error {
}

var channelStatusLock sync.Mutex

func UpdateChannelStatusById(id int, status int, reason string) {
if (common.MemoryCacheEnabled) {
if common.MemoryCacheEnabled {
channelStatusLock.Lock()
channelCache, err := CacheGetChannel(id)
// 如果缓存渠道存在,且状态已是目标状态,直接返回
if channelCache != nil && channelCache.Status == status {
channelCache, _ := CacheGetChannel(id)
// 如果缓存渠道存在,且状态已是目标状态,直接返回
if channelCache != nil && channelCache.Status == status {
channelStatusLock.Unlock()
return
return
}
// 如果缓存渠道不存在(说明已经被禁用),且要设置的状态不为启用,直接返回
if channelCache == nil && status != common.ChannelStatusEnabled {
// 如果缓存渠道不存在(说明已经被禁用),且要设置的状态不为启用,直接返回
if channelCache == nil && status != common.ChannelStatusEnabled {
channelStatusLock.Unlock()
return
return
}
CacheUpdateChannelStatus(id, status)
channelStatusLock.Unlock()
Expand Down
6 changes: 3 additions & 3 deletions relay/channel/gemini/relay-gemini.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ func CovertGemini2OpenAI(textRequest dto.GeneralOpenAIRequest) *GeminiChatReques
})
} else if part.Type == dto.ContentTypeImageURL {
imageNum += 1
if imageNum > GeminiVisionMaxImageNum {
continue
}
//if imageNum > GeminiVisionMaxImageNum {
// continue
//}
// 判断是否是url
if strings.HasPrefix(part.ImageUrl.(dto.MessageImageUrl).Url, "http") {
// 是url,获取图片的类型和base64编码的数据
Expand Down
4 changes: 2 additions & 2 deletions web/src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@
"管理员未开启Stripe在线充值!": "The administrator has not enabled Stripe online recharge!",
"当前充值1美金=": "Current recharge = 1 USD =",
"请选择充值方式!": "Please choose a recharge method!",
"元": "RMB/CNY",
"元": "CNY",
"充值记录": "Recharge record",
"返利记录": "Rebate record",
"确定要充值 $": "Confirm to top up $",
Expand Down Expand Up @@ -963,7 +963,7 @@
"请输入星火大模型版本,注意是接口地址中的版本号,例如:v2[1]": "Please enter the Spark model version, note that it is the version number in the interface address, for example: v2.1",
"等待中": "Waiting",
"所有各厂聊天模型请统一使用OpenAI方式请求,支持OpenAI官方库": "Please use the OpenAI method to request all chat models from each factory, and support the OpenAI official library.",
"实付金额:": "Actual payment amount:",
"实付金额:": "Actual payment amount: ",
"金额": "Amount",
"充值金额": "Recharge amount",
"易支付 实付金额:": "Easy Pay Actual payment amount:",
Expand Down

0 comments on commit 2d865eb

Please sign in to comment.