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
f470310d
authored
Jan 29, 2026
by
Calcium-Ion
Committed by
GitHub
Jan 29, 2026
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2779 from RedwindA/feat/gemini2oaiSTOP
feat(gemini): map OpenAI stop to Gemini stopSequences
parents
8aa025f6
9899073e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
0 deletions
+32
-0
relay/channel/gemini/relay-gemini.go
+32
-0
No files found.
relay/channel/gemini/relay-gemini.go
View file @
f470310d
...
@@ -217,6 +217,13 @@ func CovertOpenAI2Gemini(c *gin.Context, textRequest dto.GeneralOpenAIRequest, i
...
@@ -217,6 +217,13 @@ func CovertOpenAI2Gemini(c *gin.Context, textRequest dto.GeneralOpenAIRequest, i
"IMAGE"
,
"IMAGE"
,
}
}
}
}
if
stopSequences
:=
parseStopSequences
(
textRequest
.
Stop
);
len
(
stopSequences
)
>
0
{
// Gemini supports up to 5 stop sequences
if
len
(
stopSequences
)
>
5
{
stopSequences
=
stopSequences
[
:
5
]
}
geminiRequest
.
GenerationConfig
.
StopSequences
=
stopSequences
}
adaptorWithExtraBody
:=
false
adaptorWithExtraBody
:=
false
...
@@ -631,6 +638,31 @@ func CovertOpenAI2Gemini(c *gin.Context, textRequest dto.GeneralOpenAIRequest, i
...
@@ -631,6 +638,31 @@ func CovertOpenAI2Gemini(c *gin.Context, textRequest dto.GeneralOpenAIRequest, i
return
&
geminiRequest
,
nil
return
&
geminiRequest
,
nil
}
}
// parseStopSequences 解析停止序列,支持字符串或字符串数组
func
parseStopSequences
(
stop
any
)
[]
string
{
if
stop
==
nil
{
return
nil
}
switch
v
:=
stop
.
(
type
)
{
case
string
:
if
v
!=
""
{
return
[]
string
{
v
}
}
case
[]
string
:
return
v
case
[]
interface
{}
:
sequences
:=
make
([]
string
,
0
,
len
(
v
))
for
_
,
item
:=
range
v
{
if
str
,
ok
:=
item
.
(
string
);
ok
&&
str
!=
""
{
sequences
=
append
(
sequences
,
str
)
}
}
return
sequences
}
return
nil
}
func
hasFunctionCallContent
(
call
*
dto
.
FunctionCall
)
bool
{
func
hasFunctionCallContent
(
call
*
dto
.
FunctionCall
)
bool
{
if
call
==
nil
{
if
call
==
nil
{
return
false
return
false
...
...
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