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
5cae6be1
authored
Sep 19, 2025
by
creamlike1024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 支持 gemini-embedding-001
parent
e81e2ee3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
3 deletions
+16
-3
relay/channel/gemini/adaptor.go
+2
-2
relay/helper/valid_request.go
+13
-1
setting/ratio_setting/model_ratio.go
+1
-0
No files found.
relay/channel/gemini/adaptor.go
View file @
5cae6be1
...
...
@@ -215,8 +215,8 @@ func (a *Adaptor) DoRequest(c *gin.Context, info *relaycommon.RelayInfo, request
func
(
a
*
Adaptor
)
DoResponse
(
c
*
gin
.
Context
,
resp
*
http
.
Response
,
info
*
relaycommon
.
RelayInfo
)
(
usage
any
,
err
*
types
.
NewAPIError
)
{
if
info
.
RelayMode
==
constant
.
RelayModeGemini
{
if
strings
.
HasSuffix
(
info
.
RequestURLPath
,
":embedContent"
)
||
strings
.
HasSuffix
(
info
.
RequestURLPath
,
":batchEmbedContents"
)
{
if
strings
.
Contains
(
info
.
RequestURLPath
,
":embedContent"
)
||
strings
.
Contains
(
info
.
RequestURLPath
,
":batchEmbedContents"
)
{
return
NativeGeminiEmbeddingHandler
(
c
,
resp
,
info
)
}
if
info
.
IsStream
{
...
...
relay/helper/valid_request.go
View file @
5cae6be1
...
...
@@ -21,7 +21,11 @@ func GetAndValidateRequest(c *gin.Context, format types.RelayFormat) (request dt
case
types
.
RelayFormatOpenAI
:
request
,
err
=
GetAndValidateTextRequest
(
c
,
relayMode
)
case
types
.
RelayFormatGemini
:
if
strings
.
Contains
(
c
.
Request
.
URL
.
Path
,
":embedContent"
)
||
strings
.
Contains
(
c
.
Request
.
URL
.
Path
,
":batchEmbedContents"
)
{
request
,
err
=
GetAndValidateGeminiEmbeddingRequest
(
c
)
}
else
{
request
,
err
=
GetAndValidateGeminiRequest
(
c
)
}
case
types
.
RelayFormatClaude
:
request
,
err
=
GetAndValidateClaudeRequest
(
c
)
case
types
.
RelayFormatOpenAIResponses
:
...
...
@@ -288,7 +292,6 @@ func GetAndValidateTextRequest(c *gin.Context, relayMode int) (*dto.GeneralOpenA
}
func
GetAndValidateGeminiRequest
(
c
*
gin
.
Context
)
(
*
dto
.
GeminiChatRequest
,
error
)
{
request
:=
&
dto
.
GeminiChatRequest
{}
err
:=
common
.
UnmarshalBodyReusable
(
c
,
request
)
if
err
!=
nil
{
...
...
@@ -304,3 +307,12 @@ func GetAndValidateGeminiRequest(c *gin.Context) (*dto.GeminiChatRequest, error)
return
request
,
nil
}
func
GetAndValidateGeminiEmbeddingRequest
(
c
*
gin
.
Context
)
(
*
dto
.
GeminiEmbeddingRequest
,
error
)
{
request
:=
&
dto
.
GeminiEmbeddingRequest
{}
err
:=
common
.
UnmarshalBodyReusable
(
c
,
request
)
if
err
!=
nil
{
return
nil
,
err
}
return
request
,
nil
}
setting/ratio_setting/model_ratio.go
View file @
5cae6be1
...
...
@@ -178,6 +178,7 @@ var defaultModelRatio = map[string]float64{
"gemini-2.5-flash-lite-preview-thinking-*"
:
0.05
,
"gemini-2.5-flash-lite-preview-06-17"
:
0.05
,
"gemini-2.5-flash"
:
0.15
,
"gemini-embedding-001"
:
0.075
,
"text-embedding-004"
:
0.001
,
"chatglm_turbo"
:
0.3572
,
// ¥0.005 / 1k tokens
"chatglm_pro"
:
0.7143
,
// ¥0.01 / 1k tokens
...
...
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