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
7e90c832
authored
Jan 20, 2026
by
Seefs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: issue where consecutive calls to multiple tools in gemini all returned an index of 0
parent
b311d482
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
0 deletions
+24
-0
relay/channel/gemini/relay-gemini.go
+24
-0
No files found.
relay/channel/gemini/relay-gemini.go
View file @
7e90c832
...
@@ -1141,6 +1141,8 @@ func GeminiChatStreamHandler(c *gin.Context, info *relaycommon.RelayInfo, resp *
...
@@ -1141,6 +1141,8 @@ func GeminiChatStreamHandler(c *gin.Context, info *relaycommon.RelayInfo, resp *
id
:=
helper
.
GetResponseID
(
c
)
id
:=
helper
.
GetResponseID
(
c
)
createAt
:=
common
.
GetTimestamp
()
createAt
:=
common
.
GetTimestamp
()
finishReason
:=
constant
.
FinishReasonStop
finishReason
:=
constant
.
FinishReasonStop
toolCallIndexByChoice
:=
make
(
map
[
int
]
map
[
string
]
int
)
nextToolCallIndexByChoice
:=
make
(
map
[
int
]
int
)
usage
,
err
:=
geminiStreamHandler
(
c
,
info
,
resp
,
func
(
data
string
,
geminiResponse
*
dto
.
GeminiChatResponse
)
bool
{
usage
,
err
:=
geminiStreamHandler
(
c
,
info
,
resp
,
func
(
data
string
,
geminiResponse
*
dto
.
GeminiChatResponse
)
bool
{
response
,
isStop
:=
streamResponseGeminiChat2OpenAI
(
geminiResponse
)
response
,
isStop
:=
streamResponseGeminiChat2OpenAI
(
geminiResponse
)
...
@@ -1148,6 +1150,28 @@ func GeminiChatStreamHandler(c *gin.Context, info *relaycommon.RelayInfo, resp *
...
@@ -1148,6 +1150,28 @@ func GeminiChatStreamHandler(c *gin.Context, info *relaycommon.RelayInfo, resp *
response
.
Id
=
id
response
.
Id
=
id
response
.
Created
=
createAt
response
.
Created
=
createAt
response
.
Model
=
info
.
UpstreamModelName
response
.
Model
=
info
.
UpstreamModelName
for
choiceIdx
:=
range
response
.
Choices
{
choiceKey
:=
response
.
Choices
[
choiceIdx
]
.
Index
for
toolIdx
:=
range
response
.
Choices
[
choiceIdx
]
.
Delta
.
ToolCalls
{
tool
:=
&
response
.
Choices
[
choiceIdx
]
.
Delta
.
ToolCalls
[
toolIdx
]
if
tool
.
ID
==
""
{
continue
}
m
:=
toolCallIndexByChoice
[
choiceKey
]
if
m
==
nil
{
m
=
make
(
map
[
string
]
int
)
toolCallIndexByChoice
[
choiceKey
]
=
m
}
if
idx
,
ok
:=
m
[
tool
.
ID
];
ok
{
tool
.
SetIndex
(
idx
)
continue
}
idx
:=
nextToolCallIndexByChoice
[
choiceKey
]
nextToolCallIndexByChoice
[
choiceKey
]
=
idx
+
1
m
[
tool
.
ID
]
=
idx
tool
.
SetIndex
(
idx
)
}
}
logger
.
LogDebug
(
c
,
fmt
.
Sprintf
(
"info.SendResponseCount = %d"
,
info
.
SendResponseCount
))
logger
.
LogDebug
(
c
,
fmt
.
Sprintf
(
"info.SendResponseCount = %d"
,
info
.
SendResponseCount
))
if
info
.
SendResponseCount
==
0
{
if
info
.
SendResponseCount
==
0
{
...
...
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