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
3f208ee3
authored
Jan 21, 2026
by
Calcium-Ion
Committed by
GitHub
Jan 21, 2026
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2701 from seefs001/fix/gemini-tool-call-index
fix: calls to multiple tools in gemini all return index=0
parents
14d2290b
7e90c832
Show 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 @
3f208ee3
...
...
@@ -1208,6 +1208,8 @@ func GeminiChatStreamHandler(c *gin.Context, info *relaycommon.RelayInfo, resp *
id
:=
helper
.
GetResponseID
(
c
)
createAt
:=
common
.
GetTimestamp
()
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
{
response
,
isStop
:=
streamResponseGeminiChat2OpenAI
(
geminiResponse
)
...
...
@@ -1215,6 +1217,28 @@ func GeminiChatStreamHandler(c *gin.Context, info *relaycommon.RelayInfo, resp *
response
.
Id
=
id
response
.
Created
=
createAt
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
))
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