mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-09-17 17:16:38 +08:00
feat: improve error handling and update billing model with latest ratio
This commit is contained in:
parent
082cfbe574
commit
d097011cd5
@ -34,7 +34,7 @@ func ShouldDisableChannel(err *model.Error, statusCode int) bool {
|
|||||||
strings.Contains(lowerMessage, "credit") ||
|
strings.Contains(lowerMessage, "credit") ||
|
||||||
strings.Contains(lowerMessage, "balance") ||
|
strings.Contains(lowerMessage, "balance") ||
|
||||||
strings.Contains(lowerMessage, "permission denied") ||
|
strings.Contains(lowerMessage, "permission denied") ||
|
||||||
strings.Contains(lowerMessage, "organization has been restricted") || // groq
|
strings.Contains(lowerMessage, "organization has been restricted") || // groq
|
||||||
strings.Contains(lowerMessage, "已欠费") {
|
strings.Contains(lowerMessage, "已欠费") {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -30,8 +30,8 @@ func ConvertRequest(request model.GeneralOpenAIRequest) *ChatRequest {
|
|||||||
TopP: request.TopP,
|
TopP: request.TopP,
|
||||||
FrequencyPenalty: request.FrequencyPenalty,
|
FrequencyPenalty: request.FrequencyPenalty,
|
||||||
PresencePenalty: request.PresencePenalty,
|
PresencePenalty: request.PresencePenalty,
|
||||||
NumPredict: request.MaxTokens,
|
NumPredict: request.MaxTokens,
|
||||||
NumCtx: request.NumCtx,
|
NumCtx: request.NumCtx,
|
||||||
},
|
},
|
||||||
Stream: request.Stream,
|
Stream: request.Stream,
|
||||||
}
|
}
|
||||||
@ -121,7 +121,7 @@ func StreamHandler(c *gin.Context, resp *http.Response) (*model.ErrorWithStatusC
|
|||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
data := scanner.Text()
|
data := scanner.Text()
|
||||||
if strings.HasPrefix(data, "}") {
|
if strings.HasPrefix(data, "}") {
|
||||||
data = strings.TrimPrefix(data, "}") + "}"
|
data = strings.TrimPrefix(data, "}") + "}"
|
||||||
}
|
}
|
||||||
|
|
||||||
var ollamaResponse ChatResponse
|
var ollamaResponse ChatResponse
|
||||||
|
@ -83,6 +83,7 @@ var ModelRatio = map[string]float64{
|
|||||||
"claude-3-sonnet-20240229": 3.0 / 1000 * USD,
|
"claude-3-sonnet-20240229": 3.0 / 1000 * USD,
|
||||||
"claude-3-5-sonnet-20240620": 3.0 / 1000 * USD,
|
"claude-3-5-sonnet-20240620": 3.0 / 1000 * USD,
|
||||||
"claude-3-5-sonnet-20241022": 3.0 / 1000 * USD,
|
"claude-3-5-sonnet-20241022": 3.0 / 1000 * USD,
|
||||||
|
"claude-3-5-sonnet-latest": 3.0 / 1000 * USD,
|
||||||
"claude-3-opus-20240229": 15.0 / 1000 * USD,
|
"claude-3-opus-20240229": 15.0 / 1000 * USD,
|
||||||
// https://cloud.baidu.com/doc/WENXINWORKSHOP/s/hlrk4akp7
|
// https://cloud.baidu.com/doc/WENXINWORKSHOP/s/hlrk4akp7
|
||||||
"ERNIE-4.0-8K": 0.120 * RMB,
|
"ERNIE-4.0-8K": 0.120 * RMB,
|
||||||
|
Loading…
Reference in New Issue
Block a user