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
f5a52bc5
authored
Aug 09, 2025
by
RedwindA
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: update dto for embeddings
parent
1dcb9a01
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
15 deletions
+5
-15
dto/gemini.go
+2
-2
relay/channel/gemini/adaptor.go
+3
-13
No files found.
dto/gemini.go
View file @
f5a52bc5
...
@@ -218,7 +218,7 @@ type GeminiEmbeddingRequest struct {
...
@@ -218,7 +218,7 @@ type GeminiEmbeddingRequest struct {
}
}
type
GeminiBatchEmbeddingRequest
struct
{
type
GeminiBatchEmbeddingRequest
struct
{
Requests
[]
GeminiEmbeddingRequest
`json:"requests"`
Requests
[]
*
GeminiEmbeddingRequest
`json:"requests"`
}
}
type
GeminiEmbeddingResponse
struct
{
type
GeminiEmbeddingResponse
struct
{
...
@@ -226,7 +226,7 @@ type GeminiEmbeddingResponse struct {
...
@@ -226,7 +226,7 @@ type GeminiEmbeddingResponse struct {
}
}
type
GeminiBatchEmbeddingResponse
struct
{
type
GeminiBatchEmbeddingResponse
struct
{
Embeddings
[]
ContentEmbedding
`json:"embeddings"`
Embeddings
[]
*
ContentEmbedding
`json:"embeddings"`
}
}
type
ContentEmbedding
struct
{
type
ContentEmbedding
struct
{
...
...
relay/channel/gemini/adaptor.go
View file @
f5a52bc5
...
@@ -119,7 +119,6 @@ func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
...
@@ -119,7 +119,6 @@ func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
action
=
"batchEmbedContents"
action
=
"batchEmbedContents"
}
}
return
fmt
.
Sprintf
(
"%s/%s/models/%s:%s"
,
info
.
BaseUrl
,
version
,
info
.
UpstreamModelName
,
action
),
nil
return
fmt
.
Sprintf
(
"%s/%s/models/%s:%s"
,
info
.
BaseUrl
,
version
,
info
.
UpstreamModelName
,
action
),
nil
return
fmt
.
Sprintf
(
"%s/%s/models/%s:batchEmbedContents"
,
info
.
BaseUrl
,
version
,
info
.
UpstreamModelName
),
nil
}
}
action
:=
"generateContent"
action
:=
"generateContent"
...
@@ -164,6 +163,9 @@ func (a *Adaptor) ConvertEmbeddingRequest(c *gin.Context, info *relaycommon.Rela
...
@@ -164,6 +163,9 @@ func (a *Adaptor) ConvertEmbeddingRequest(c *gin.Context, info *relaycommon.Rela
if
len
(
inputs
)
==
0
{
if
len
(
inputs
)
==
0
{
return
nil
,
errors
.
New
(
"input is empty"
)
return
nil
,
errors
.
New
(
"input is empty"
)
}
}
// We always build a batch-style payload with `requests`, so ensure we call the
// batch endpoint upstream to avoid payload/endpoint mismatches.
info
.
IsGeminiBatchEmbedding
=
true
// process all inputs
// process all inputs
geminiRequests
:=
make
([]
map
[
string
]
interface
{},
0
,
len
(
inputs
))
geminiRequests
:=
make
([]
map
[
string
]
interface
{},
0
,
len
(
inputs
))
for
_
,
input
:=
range
inputs
{
for
_
,
input
:=
range
inputs
{
...
@@ -234,18 +236,6 @@ func (a *Adaptor) DoResponse(c *gin.Context, resp *http.Response, info *relaycom
...
@@ -234,18 +236,6 @@ func (a *Adaptor) DoResponse(c *gin.Context, resp *http.Response, info *relaycom
return
GeminiChatHandler
(
c
,
info
,
resp
)
return
GeminiChatHandler
(
c
,
info
,
resp
)
}
}
//if usage.(*dto.Usage).CompletionTokenDetails.ReasoningTokens > 100 {
// // 没有请求-thinking的情况下,产生思考token,则按照思考模型计费
// if !strings.HasSuffix(info.OriginModelName, "-thinking") &&
// !strings.HasSuffix(info.OriginModelName, "-nothinking") {
// thinkingModelName := info.OriginModelName + "-thinking"
// if operation_setting.SelfUseModeEnabled || helper.ContainPriceOrRatio(thinkingModelName) {
// info.OriginModelName = thinkingModelName
// }
// }
//}
return
nil
,
types
.
NewError
(
errors
.
New
(
"not implemented"
),
types
.
ErrorCodeBadResponseBody
)
}
}
func
(
a
*
Adaptor
)
GetModelList
()
[]
string
{
func
(
a
*
Adaptor
)
GetModelList
()
[]
string
{
...
...
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