Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
521fb413
authored
Apr 17, 2024
by
Calcium-Ion
Committed by
GitHub
Apr 17, 2024
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #205 from MapleEve/main
fix: Gemini new model name error and Support both v1 and v1beta models
parents
c9d1842b
645c2487
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
12 deletions
+27
-12
common/model-ratio.go
+4
-1
relay/channel/gemini/adaptor.go
+21
-9
relay/channel/gemini/constant.go
+2
-2
No files found.
common/model-ratio.go
View file @
521fb413
...
...
@@ -76,7 +76,10 @@ var DefaultModelRatio = map[string]float64{
"gemini-pro-vision"
:
1
,
// $0.00025 / 1k characters -> $0.001 / 1k tokens
"gemini-1.0-pro-vision-001"
:
1
,
"gemini-1.0-pro-001"
:
1
,
"gemini-1.5-pro"
:
1
,
"gemini-1.5-pro-latest"
:
1
,
"gemini-1.0-pro-latest"
:
1
,
"gemini-1.0-pro-vision-latest"
:
1
,
"gemini-ultra"
:
1
,
"chatglm_turbo"
:
0.3572
,
// ¥0.005 / 1k tokens
"chatglm_pro"
:
0.7143
,
// ¥0.01 / 1k tokens
"chatglm_std"
:
0.3572
,
// ¥0.005 / 1k tokens
...
...
relay/channel/gemini/adaptor.go
View file @
521fb413
...
...
@@ -18,16 +18,28 @@ type Adaptor struct {
func
(
a
*
Adaptor
)
Init
(
info
*
relaycommon
.
RelayInfo
,
request
dto
.
GeneralOpenAIRequest
)
{
}
// 定义一个映射,存储模型名称和对应的版本
var
modelVersionMap
=
map
[
string
]
string
{
"gemini-1.5-pro-latest"
:
"v1beta"
,
"gemini-ultra"
:
"v1beta"
,
}
func
(
a
*
Adaptor
)
GetRequestURL
(
info
*
relaycommon
.
RelayInfo
)
(
string
,
error
)
{
version
:=
"v1"
if
info
.
ApiVersion
!=
""
{
version
=
info
.
ApiVersion
}
action
:=
"generateContent"
if
info
.
IsStream
{
action
=
"streamGenerateContent"
}
return
fmt
.
Sprintf
(
"%s/%s/models/%s:%s"
,
info
.
BaseUrl
,
version
,
info
.
UpstreamModelName
,
action
),
nil
// 从映射中获取模型名称对应的版本,如果找不到就使用 info.ApiVersion 或默认的版本 "v1"
version
,
beta
:=
modelVersionMap
[
info
.
UpstreamModelName
]
if
!
beta
{
if
info
.
ApiVersion
!=
""
{
version
=
info
.
ApiVersion
}
else
{
version
=
"v1"
}
}
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
{
...
...
relay/channel/gemini/constant.go
View file @
521fb413
...
...
@@ -5,8 +5,8 @@ const (
)
var
ModelList
=
[]
string
{
"gemini-
pro"
,
"gemini-1.0-pro-001"
,
"gemini-1.5-pro
"
,
"gemini-
pro-vision
"
,
"gemini-1.0-pro-vision-001"
,
"gemini-
1.0-pro-latest"
,
"gemini-1.0-pro-001"
,
"gemini-1.5-pro-latest"
,
"gemini-ultra
"
,
"gemini-
1.0-pro-vision-latest
"
,
"gemini-1.0-pro-vision-001"
,
}
var
ChannelName
=
"google gemini"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment