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
703d9265
authored
Sep 19, 2025
by
Calcium-Ion
Committed by
GitHub
Sep 19, 2025
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1834 from QuantumNous/gemini-embedding-001
feat: 支持 gemini-embedding-001
parents
e81e2ee3
5cae6be1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
4 deletions
+17
-4
relay/channel/gemini/adaptor.go
+2
-2
relay/helper/valid_request.go
+14
-2
setting/ratio_setting/model_ratio.go
+1
-0
No files found.
relay/channel/gemini/adaptor.go
View file @
703d9265
...
...
@@ -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 @
703d9265
...
...
@@ -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
:
request
,
err
=
GetAndValidateGeminiRequest
(
c
)
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 @
703d9265
...
...
@@ -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