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
475450cd
authored
Nov 17, 2024
by
Calcium-Ion
Committed by
GitHub
Nov 17, 2024
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #569 from utopeadia/main
Modify the default gemini API to v1beta
parents
2a58ed06
3ededac1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
5 additions
and
15 deletions
+5
-15
.env.example
+1
-1
README.md
+1
-1
constant/env.go
+1
-11
relay/channel/gemini/adaptor.go
+2
-2
No files found.
.env.example
View file @
475450cd
...
...
@@ -53,7 +53,7 @@
# Gemini 安全设置
# GEMINI_SAFETY_SETTING=BLOCK_NONE
# Gemini版本设置
# GEMINI_MODEL_MAP=gemini-1.
5-pro-latest:v1beta,gemini-1.5-pro-001:v1beta
# GEMINI_MODEL_MAP=gemini-1.
0-pro:v1
# Cohere 安全设置
# COHERE_SAFETY_SETTING=NONE
# 是否统计图片token
...
...
README.md
View file @
475450cd
...
...
@@ -74,7 +74,7 @@
-
`GET_MEDIA_TOKEN`
:是统计图片token,默认为
`true`
,关闭后将不再在本地计算图片token,可能会导致和上游计费不同,此项覆盖
`GET_MEDIA_TOKEN_NOT_STREAM`
选项作用。
-
`GET_MEDIA_TOKEN_NOT_STREAM`
:是否在非流(
`stream=false`
)情况下统计图片token,默认为
`true`
。
-
`UPDATE_TASK`
:是否更新异步任务(Midjourney、Suno),默认为
`true`
,关闭后将不会更新任务进度。
-
`GEMINI_MODEL_MAP`
:Gemini模型指定版本(v1/v1beta),使用“模型:版本”指定,","分隔,例如:-e GEMINI_MODEL_MAP="gemini-1.5-pro-latest:v1beta,gemini-1.5-pro-001:v1beta",为空则使用默认配置
-
`GEMINI_MODEL_MAP`
:Gemini模型指定版本(v1/v1beta),使用“模型:版本”指定,","分隔,例如:-e GEMINI_MODEL_MAP="gemini-1.5-pro-latest:v1beta,gemini-1.5-pro-001:v1beta",为空则使用默认配置
(v1beta)
-
`COHERE_SAFETY_SETTING`
:Cohere模型
[
安全设置
](
https://docs.cohere.com/docs/safety-modes#overview
)
,可选值为
`NONE`
,
`CONTEXTUAL`
,
`STRICT`
,默认为
`NONE`
。
## 部署
### 部署要求
...
...
constant/env.go
View file @
475450cd
...
...
@@ -20,17 +20,7 @@ var GetMediaTokenNotStream = common.GetEnvOrDefaultBool("GET_MEDIA_TOKEN_NOT_STR
var
UpdateTask
=
common
.
GetEnvOrDefaultBool
(
"UPDATE_TASK"
,
true
)
var
GeminiModelMap
=
map
[
string
]
string
{
"gemini-1.5-pro-latest"
:
"v1beta"
,
"gemini-1.5-pro-001"
:
"v1beta"
,
"gemini-1.5-pro"
:
"v1beta"
,
"gemini-1.5-pro-exp-0801"
:
"v1beta"
,
"gemini-1.5-pro-exp-0827"
:
"v1beta"
,
"gemini-1.5-flash-latest"
:
"v1beta"
,
"gemini-1.5-flash-exp-0827"
:
"v1beta"
,
"gemini-1.5-flash-001"
:
"v1beta"
,
"gemini-1.5-flash"
:
"v1beta"
,
"gemini-ultra"
:
"v1beta"
,
"gemini-exp-1114"
:
"v1beta"
,
"gemini-1.0-pro"
:
"v1"
,
}
func
InitEnv
()
{
...
...
relay/channel/gemini/adaptor.go
View file @
475450cd
...
...
@@ -30,13 +30,13 @@ func (a *Adaptor) Init(info *relaycommon.RelayInfo) {
}
func
(
a
*
Adaptor
)
GetRequestURL
(
info
*
relaycommon
.
RelayInfo
)
(
string
,
error
)
{
// 从映射中获取模型名称对应的版本,如果找不到就使用 info.ApiVersion 或默认的版本 "v1"
// 从映射中获取模型名称对应的版本,如果找不到就使用 info.ApiVersion 或默认的版本 "v1
beta
"
version
,
beta
:=
constant
.
GeminiModelMap
[
info
.
UpstreamModelName
]
if
!
beta
{
if
info
.
ApiVersion
!=
""
{
version
=
info
.
ApiVersion
}
else
{
version
=
"v1"
version
=
"v1
beta
"
}
}
...
...
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