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
1c95a9fe
authored
Jan 03, 2026
by
Calcium-Ion
Committed by
GitHub
Jan 03, 2026
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2558 from seefs001/fix/gemini-tool-call
fix: gemini request -> openai tool call
parents
93527862
336e7a5b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
5 deletions
+6
-5
dto/gemini.go
+1
-1
service/convert.go
+5
-4
No files found.
dto/gemini.go
View file @
1c95a9fe
...
@@ -126,7 +126,7 @@ func (r *GeminiChatRequest) SetModelName(modelName string) {
...
@@ -126,7 +126,7 @@ func (r *GeminiChatRequest) SetModelName(modelName string) {
func
(
r
*
GeminiChatRequest
)
GetTools
()
[]
GeminiChatTool
{
func
(
r
*
GeminiChatRequest
)
GetTools
()
[]
GeminiChatTool
{
var
tools
[]
GeminiChatTool
var
tools
[]
GeminiChatTool
if
strings
.
Has
Suf
fix
(
string
(
r
.
Tools
),
"["
)
{
if
strings
.
Has
Pre
fix
(
string
(
r
.
Tools
),
"["
)
{
// is array
// is array
if
err
:=
common
.
Unmarshal
(
r
.
Tools
,
&
tools
);
err
!=
nil
{
if
err
:=
common
.
Unmarshal
(
r
.
Tools
,
&
tools
);
err
!=
nil
{
logger
.
LogError
(
nil
,
"error_unmarshalling_tools: "
+
err
.
Error
())
logger
.
LogError
(
nil
,
"error_unmarshalling_tools: "
+
err
.
Error
())
...
...
service/convert.go
View file @
1c95a9fe
...
@@ -674,9 +674,11 @@ func GeminiToOpenAIRequest(geminiRequest *dto.GeminiChatRequest, info *relaycomm
...
@@ -674,9 +674,11 @@ func GeminiToOpenAIRequest(geminiRequest *dto.GeminiChatRequest, info *relaycomm
var
tools
[]
dto
.
ToolCallRequest
var
tools
[]
dto
.
ToolCallRequest
for
_
,
tool
:=
range
geminiRequest
.
GetTools
()
{
for
_
,
tool
:=
range
geminiRequest
.
GetTools
()
{
if
tool
.
FunctionDeclarations
!=
nil
{
if
tool
.
FunctionDeclarations
!=
nil
{
// 将 Gemini 的 FunctionDeclarations 转换为 OpenAI 的 ToolCallRequest
functionDeclarations
,
err
:=
common
.
Any2Type
[[]
dto
.
FunctionRequest
](
tool
.
FunctionDeclarations
)
functionDeclarations
,
ok
:=
tool
.
FunctionDeclarations
.
([]
dto
.
FunctionRequest
)
if
err
!=
nil
{
if
ok
{
common
.
SysError
(
fmt
.
Sprintf
(
"failed to parse gemini function declarations: %v (type=%T)"
,
err
,
tool
.
FunctionDeclarations
))
continue
}
for
_
,
function
:=
range
functionDeclarations
{
for
_
,
function
:=
range
functionDeclarations
{
openAITool
:=
dto
.
ToolCallRequest
{
openAITool
:=
dto
.
ToolCallRequest
{
Type
:
"function"
,
Type
:
"function"
,
...
@@ -690,7 +692,6 @@ func GeminiToOpenAIRequest(geminiRequest *dto.GeminiChatRequest, info *relaycomm
...
@@ -690,7 +692,6 @@ func GeminiToOpenAIRequest(geminiRequest *dto.GeminiChatRequest, info *relaycomm
}
}
}
}
}
}
}
if
len
(
tools
)
>
0
{
if
len
(
tools
)
>
0
{
openaiRequest
.
Tools
=
tools
openaiRequest
.
Tools
=
tools
}
}
...
...
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