mirror of
https://github.com/linux-do/new-api.git
synced 2025-09-19 00:46:37 +08:00
feat: support google v1beta and Gemini Ultra
This commit is contained in:
parent
300947f400
commit
21250a46a6
@ -77,6 +77,7 @@ var DefaultModelRatio = map[string]float64{
|
|||||||
"gemini-1.0-pro-vision-001": 1,
|
"gemini-1.0-pro-vision-001": 1,
|
||||||
"gemini-1.0-pro-001": 1,
|
"gemini-1.0-pro-001": 1,
|
||||||
"gemini-1.5-pro": 1,
|
"gemini-1.5-pro": 1,
|
||||||
|
"gemini-ultra": 1,
|
||||||
"chatglm_turbo": 0.3572, // ¥0.005 / 1k tokens
|
"chatglm_turbo": 0.3572, // ¥0.005 / 1k tokens
|
||||||
"chatglm_pro": 0.7143, // ¥0.01 / 1k tokens
|
"chatglm_pro": 0.7143, // ¥0.01 / 1k tokens
|
||||||
"chatglm_std": 0.3572, // ¥0.005 / 1k tokens
|
"chatglm_std": 0.3572, // ¥0.005 / 1k tokens
|
||||||
|
@ -18,16 +18,28 @@ type Adaptor struct {
|
|||||||
func (a *Adaptor) Init(info *relaycommon.RelayInfo, request dto.GeneralOpenAIRequest) {
|
func (a *Adaptor) Init(info *relaycommon.RelayInfo, request dto.GeneralOpenAIRequest) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 定义一个映射,存储模型名称和对应的版本
|
||||||
|
var modelVersionMap = map[string]string{
|
||||||
|
"gemini-1.5-pro": "v1beta",
|
||||||
|
"gemini-ultra": "v1beta",
|
||||||
|
}
|
||||||
|
|
||||||
func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
|
func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
|
||||||
version := "v1"
|
// 从映射中获取模型名称对应的版本,如果找不到就使用 info.ApiVersion 或默认的版本 "v1"
|
||||||
if info.ApiVersion != "" {
|
version, beta := modelVersionMap[info.UpstreamModelName]
|
||||||
version = info.ApiVersion
|
if !beta {
|
||||||
}
|
if info.ApiVersion != "" {
|
||||||
action := "generateContent"
|
version = info.ApiVersion
|
||||||
if info.IsStream {
|
} else {
|
||||||
action = "streamGenerateContent"
|
version = "v1"
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("%s/%s/models/%s:%s", info.BaseUrl, version, info.UpstreamModelName, action), nil
|
}
|
||||||
|
|
||||||
|
action := "generateContent"
|
||||||
|
if info.IsStream {
|
||||||
|
action = "streamGenerateContent"
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("%s/%s/models/%s:%s", info.BaseUrl, version, info.UpstreamModelName, action), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Adaptor) SetupRequestHeader(c *gin.Context, req *http.Request, info *relaycommon.RelayInfo) error {
|
func (a *Adaptor) SetupRequestHeader(c *gin.Context, req *http.Request, info *relaycommon.RelayInfo) error {
|
||||||
|
@ -5,7 +5,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var ModelList = []string{
|
var ModelList = []string{
|
||||||
"gemini-pro", "gemini-1.0-pro-001", "gemini-1.5-pro",
|
"gemini-pro", "gemini-1.0-pro-001", "gemini-1.5-pro", "gemini-ultra",
|
||||||
"gemini-pro-vision", "gemini-1.0-pro-vision-001",
|
"gemini-pro-vision", "gemini-1.0-pro-vision-001",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user