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
400014d1
authored
Oct 17, 2025
by
creamlike1024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: gemini batch embedding token not counted
parent
2df75d14
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
1 deletions
+12
-1
relay/helper/valid_request.go
+12
-1
No files found.
relay/helper/valid_request.go
View file @
400014d1
...
@@ -22,8 +22,10 @@ func GetAndValidateRequest(c *gin.Context, format types.RelayFormat) (request dt
...
@@ -22,8 +22,10 @@ func GetAndValidateRequest(c *gin.Context, format types.RelayFormat) (request dt
case
types
.
RelayFormatOpenAI
:
case
types
.
RelayFormatOpenAI
:
request
,
err
=
GetAndValidateTextRequest
(
c
,
relayMode
)
request
,
err
=
GetAndValidateTextRequest
(
c
,
relayMode
)
case
types
.
RelayFormatGemini
:
case
types
.
RelayFormatGemini
:
if
strings
.
Contains
(
c
.
Request
.
URL
.
Path
,
":embedContent"
)
||
strings
.
Contains
(
c
.
Request
.
URL
.
Path
,
":batchEmbedContents"
)
{
if
strings
.
Contains
(
c
.
Request
.
URL
.
Path
,
":embedContent"
)
{
request
,
err
=
GetAndValidateGeminiEmbeddingRequest
(
c
)
request
,
err
=
GetAndValidateGeminiEmbeddingRequest
(
c
)
}
else
if
strings
.
Contains
(
c
.
Request
.
URL
.
Path
,
":batchEmbedContents"
)
{
request
,
err
=
GetAndValidateGeminiBatchEmbeddingRequest
(
c
)
}
else
{
}
else
{
request
,
err
=
GetAndValidateGeminiRequest
(
c
)
request
,
err
=
GetAndValidateGeminiRequest
(
c
)
}
}
...
@@ -319,3 +321,12 @@ func GetAndValidateGeminiEmbeddingRequest(c *gin.Context) (*dto.GeminiEmbeddingR
...
@@ -319,3 +321,12 @@ func GetAndValidateGeminiEmbeddingRequest(c *gin.Context) (*dto.GeminiEmbeddingR
}
}
return
request
,
nil
return
request
,
nil
}
}
func
GetAndValidateGeminiBatchEmbeddingRequest
(
c
*
gin
.
Context
)
(
*
dto
.
GeminiBatchEmbeddingRequest
,
error
)
{
request
:=
&
dto
.
GeminiBatchEmbeddingRequest
{}
err
:=
common
.
UnmarshalBodyReusable
(
c
,
request
)
if
err
!=
nil
{
return
nil
,
err
}
return
request
,
nil
}
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