mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-09-17 17:16:38 +08:00
Merge 3e6c785955
into 09911a301d
This commit is contained in:
commit
5b5dc5da5a
@ -2,11 +2,12 @@ package middleware
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/songquanpeng/one-api/common"
|
"github.com/songquanpeng/one-api/common"
|
||||||
"github.com/songquanpeng/one-api/common/helper"
|
"github.com/songquanpeng/one-api/common/helper"
|
||||||
"github.com/songquanpeng/one-api/common/logger"
|
"github.com/songquanpeng/one-api/common/logger"
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func abortWithMessage(c *gin.Context, statusCode int, message string) {
|
func abortWithMessage(c *gin.Context, statusCode int, message string) {
|
||||||
@ -28,7 +29,7 @@ func getRequestModel(c *gin.Context) (string, error) {
|
|||||||
}
|
}
|
||||||
if strings.HasPrefix(c.Request.URL.Path, "/v1/moderations") {
|
if strings.HasPrefix(c.Request.URL.Path, "/v1/moderations") {
|
||||||
if modelRequest.Model == "" {
|
if modelRequest.Model == "" {
|
||||||
modelRequest.Model = "text-moderation-stable"
|
modelRequest.Model = "omni-moderation-latest"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if strings.HasSuffix(c.Request.URL.Path, "embeddings") {
|
if strings.HasSuffix(c.Request.URL.Path, "embeddings") {
|
||||||
|
@ -15,7 +15,7 @@ var ModelList = []string{
|
|||||||
"gpt-4-vision-preview",
|
"gpt-4-vision-preview",
|
||||||
"text-embedding-ada-002", "text-embedding-3-small", "text-embedding-3-large",
|
"text-embedding-ada-002", "text-embedding-3-small", "text-embedding-3-large",
|
||||||
"text-curie-001", "text-babbage-001", "text-ada-001", "text-davinci-002", "text-davinci-003",
|
"text-curie-001", "text-babbage-001", "text-ada-001", "text-davinci-002", "text-davinci-003",
|
||||||
"text-moderation-latest", "text-moderation-stable",
|
"text-moderation-latest", "text-moderation-stable", "omni-moderation-latest", "omni-moderation-2024-09-26",
|
||||||
"text-davinci-edit-001",
|
"text-davinci-edit-001",
|
||||||
"davinci-002", "babbage-002",
|
"davinci-002", "babbage-002",
|
||||||
"dall-e-2", "dall-e-3",
|
"dall-e-2", "dall-e-3",
|
||||||
|
@ -23,65 +23,67 @@ const (
|
|||||||
// 1 === ¥0.014 / 1k tokens
|
// 1 === ¥0.014 / 1k tokens
|
||||||
var ModelRatio = map[string]float64{
|
var ModelRatio = map[string]float64{
|
||||||
// https://openai.com/pricing
|
// https://openai.com/pricing
|
||||||
"gpt-4": 15,
|
"gpt-4": 15,
|
||||||
"gpt-4-0314": 15,
|
"gpt-4-0314": 15,
|
||||||
"gpt-4-0613": 15,
|
"gpt-4-0613": 15,
|
||||||
"gpt-4-32k": 30,
|
"gpt-4-32k": 30,
|
||||||
"gpt-4-32k-0314": 30,
|
"gpt-4-32k-0314": 30,
|
||||||
"gpt-4-32k-0613": 30,
|
"gpt-4-32k-0613": 30,
|
||||||
"gpt-4-1106-preview": 5, // $0.01 / 1K tokens
|
"gpt-4-1106-preview": 5, // $0.01 / 1K tokens
|
||||||
"gpt-4-0125-preview": 5, // $0.01 / 1K tokens
|
"gpt-4-0125-preview": 5, // $0.01 / 1K tokens
|
||||||
"gpt-4-turbo-preview": 5, // $0.01 / 1K tokens
|
"gpt-4-turbo-preview": 5, // $0.01 / 1K tokens
|
||||||
"gpt-4-turbo": 5, // $0.01 / 1K tokens
|
"gpt-4-turbo": 5, // $0.01 / 1K tokens
|
||||||
"gpt-4-turbo-2024-04-09": 5, // $0.01 / 1K tokens
|
"gpt-4-turbo-2024-04-09": 5, // $0.01 / 1K tokens
|
||||||
"gpt-4o": 2.5, // $0.005 / 1K tokens
|
"gpt-4o": 2.5, // $0.005 / 1K tokens
|
||||||
"chatgpt-4o-latest": 2.5, // $0.005 / 1K tokens
|
"chatgpt-4o-latest": 2.5, // $0.005 / 1K tokens
|
||||||
"gpt-4o-2024-05-13": 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-08-06": 1.25, // $0.0025 / 1K tokens
|
||||||
"gpt-4o-2024-11-20": 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": 0.075, // $0.00015 / 1K tokens
|
||||||
"gpt-4o-mini-2024-07-18": 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
|
"gpt-4-vision-preview": 5, // $0.01 / 1K tokens
|
||||||
"gpt-3.5-turbo": 0.25, // $0.0005 / 1K tokens
|
"gpt-3.5-turbo": 0.25, // $0.0005 / 1K tokens
|
||||||
"gpt-3.5-turbo-0301": 0.75,
|
"gpt-3.5-turbo-0301": 0.75,
|
||||||
"gpt-3.5-turbo-0613": 0.75,
|
"gpt-3.5-turbo-0613": 0.75,
|
||||||
"gpt-3.5-turbo-16k": 1.5, // $0.003 / 1K tokens
|
"gpt-3.5-turbo-16k": 1.5, // $0.003 / 1K tokens
|
||||||
"gpt-3.5-turbo-16k-0613": 1.5,
|
"gpt-3.5-turbo-16k-0613": 1.5,
|
||||||
"gpt-3.5-turbo-instruct": 0.75, // $0.0015 / 1K tokens
|
"gpt-3.5-turbo-instruct": 0.75, // $0.0015 / 1K tokens
|
||||||
"gpt-3.5-turbo-1106": 0.5, // $0.001 / 1K tokens
|
"gpt-3.5-turbo-1106": 0.5, // $0.001 / 1K tokens
|
||||||
"gpt-3.5-turbo-0125": 0.25, // $0.0005 / 1K tokens
|
"gpt-3.5-turbo-0125": 0.25, // $0.0005 / 1K tokens
|
||||||
"o1": 7.5, // $15.00 / 1M input tokens
|
"o1": 7.5, // $15.00 / 1M input tokens
|
||||||
"o1-2024-12-17": 7.5,
|
"o1-2024-12-17": 7.5,
|
||||||
"o1-preview": 7.5, // $15.00 / 1M input tokens
|
"o1-preview": 7.5, // $15.00 / 1M input tokens
|
||||||
"o1-preview-2024-09-12": 7.5,
|
"o1-preview-2024-09-12": 7.5,
|
||||||
"o1-mini": 1.5, // $3.00 / 1M input tokens
|
"o1-mini": 1.5, // $3.00 / 1M input tokens
|
||||||
"o1-mini-2024-09-12": 1.5,
|
"o1-mini-2024-09-12": 1.5,
|
||||||
"davinci-002": 1, // $0.002 / 1K tokens
|
"davinci-002": 1, // $0.002 / 1K tokens
|
||||||
"babbage-002": 0.2, // $0.0004 / 1K tokens
|
"babbage-002": 0.2, // $0.0004 / 1K tokens
|
||||||
"text-ada-001": 0.2,
|
"text-ada-001": 0.2,
|
||||||
"text-babbage-001": 0.25,
|
"text-babbage-001": 0.25,
|
||||||
"text-curie-001": 1,
|
"text-curie-001": 1,
|
||||||
"text-davinci-002": 10,
|
"text-davinci-002": 10,
|
||||||
"text-davinci-003": 10,
|
"text-davinci-003": 10,
|
||||||
"text-davinci-edit-001": 10,
|
"text-davinci-edit-001": 10,
|
||||||
"code-davinci-edit-001": 10,
|
"code-davinci-edit-001": 10,
|
||||||
"whisper-1": 15, // $0.006 / minute -> $0.006 / 150 words -> $0.006 / 200 tokens -> $0.03 / 1k tokens
|
"whisper-1": 15, // $0.006 / minute -> $0.006 / 150 words -> $0.006 / 200 tokens -> $0.03 / 1k tokens
|
||||||
"tts-1": 7.5, // $0.015 / 1K characters
|
"tts-1": 7.5, // $0.015 / 1K characters
|
||||||
"tts-1-1106": 7.5,
|
"tts-1-1106": 7.5,
|
||||||
"tts-1-hd": 15, // $0.030 / 1K characters
|
"tts-1-hd": 15, // $0.030 / 1K characters
|
||||||
"tts-1-hd-1106": 15,
|
"tts-1-hd-1106": 15,
|
||||||
"davinci": 10,
|
"davinci": 10,
|
||||||
"curie": 10,
|
"curie": 10,
|
||||||
"babbage": 10,
|
"babbage": 10,
|
||||||
"ada": 10,
|
"ada": 10,
|
||||||
"text-embedding-ada-002": 0.05,
|
"text-embedding-ada-002": 0.05,
|
||||||
"text-embedding-3-small": 0.01,
|
"text-embedding-3-small": 0.01,
|
||||||
"text-embedding-3-large": 0.065,
|
"text-embedding-3-large": 0.065,
|
||||||
"text-search-ada-doc-001": 10,
|
"text-search-ada-doc-001": 10,
|
||||||
"text-moderation-stable": 0.1,
|
"text-moderation-stable": 0.1,
|
||||||
"text-moderation-latest": 0.1,
|
"text-moderation-latest": 0.1,
|
||||||
"dall-e-2": 0.02 * USD, // $0.016 - $0.020 / image
|
"omni-moderation-latest": 0.1,
|
||||||
"dall-e-3": 0.04 * USD, // $0.040 - $0.120 / image
|
"omni-moderation-2024-09-26": 0.1,
|
||||||
|
"dall-e-2": 0.02 * USD, // $0.016 - $0.020 / image
|
||||||
|
"dall-e-3": 0.04 * USD, // $0.040 - $0.120 / image
|
||||||
// https://www.anthropic.com/api#pricing
|
// https://www.anthropic.com/api#pricing
|
||||||
"claude-instant-1.2": 0.8 / 1000 * USD,
|
"claude-instant-1.2": 0.8 / 1000 * USD,
|
||||||
"claude-2.0": 8.0 / 1000 * USD,
|
"claude-2.0": 8.0 / 1000 * USD,
|
||||||
|
@ -4,11 +4,12 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/songquanpeng/one-api/relay/constant/role"
|
|
||||||
"math"
|
"math"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/songquanpeng/one-api/relay/constant/role"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/songquanpeng/one-api/common"
|
"github.com/songquanpeng/one-api/common"
|
||||||
"github.com/songquanpeng/one-api/common/config"
|
"github.com/songquanpeng/one-api/common/config"
|
||||||
@ -30,7 +31,7 @@ func getAndValidateTextRequest(c *gin.Context, relayMode int) (*relaymodel.Gener
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if relayMode == relaymode.Moderations && textRequest.Model == "" {
|
if relayMode == relaymode.Moderations && textRequest.Model == "" {
|
||||||
textRequest.Model = "text-moderation-latest"
|
textRequest.Model = "omni-moderation-latest"
|
||||||
}
|
}
|
||||||
if relayMode == relaymode.Embeddings && textRequest.Model == "" {
|
if relayMode == relaymode.Embeddings && textRequest.Model == "" {
|
||||||
textRequest.Model = c.Param("model")
|
textRequest.Model = c.Param("model")
|
||||||
|
@ -150,6 +150,8 @@ export const modelColorMap = {
|
|||||||
'text-embedding-v1': 'rgb(255,174,185)', // 浅粉红色(略有区别)
|
'text-embedding-v1': 'rgb(255,174,185)', // 浅粉红色(略有区别)
|
||||||
'text-moderation-latest': 'rgb(255,130,171)', // 强粉色
|
'text-moderation-latest': 'rgb(255,130,171)', // 强粉色
|
||||||
'text-moderation-stable': 'rgb(255,160,122)', // 浅珊瑚色(与Babbage相同,表示同一类功能)
|
'text-moderation-stable': 'rgb(255,160,122)', // 浅珊瑚色(与Babbage相同,表示同一类功能)
|
||||||
|
'omni-moderation-latest': 'rgb(255,130,171)', // 强粉色
|
||||||
|
'omni-moderation-2024-09-26': 'rgb(255,130,171)', // 强粉色
|
||||||
'tts-1': 'rgb(255,140,0)', // 深橙色
|
'tts-1': 'rgb(255,140,0)', // 深橙色
|
||||||
'tts-1-1106': 'rgb(255,165,0)', // 橙色
|
'tts-1-1106': 'rgb(255,165,0)', // 橙色
|
||||||
'tts-1-hd': 'rgb(255,215,0)', // 金色
|
'tts-1-hd': 'rgb(255,215,0)', // 金色
|
||||||
|
Loading…
Reference in New Issue
Block a user