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
03f6de49
authored
Apr 15, 2024
by
Maple Gao
Committed by
GitHub
Apr 15, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: support google v1beta and Gemini Ultra
parent
c9d1842b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
10 deletions
+23
-10
common/model-ratio.go
+1
-0
relay/channel/gemini/adaptor.go
+21
-9
relay/channel/gemini/constant.go
+1
-1
No files found.
common/model-ratio.go
View file @
03f6de49
...
@@ -77,6 +77,7 @@ var DefaultModelRatio = map[string]float64{
...
@@ -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
...
...
relay/channel/gemini/adaptor.go
View file @
03f6de49
...
@@ -18,16 +18,28 @@ type Adaptor struct {
...
@@ -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
{
...
...
relay/channel/gemini/constant.go
View file @
03f6de49
...
@@ -5,7 +5,7 @@ const (
...
@@ -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"
,
}
}
...
...
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