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
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
14 deletions
+15
-14
dto/gemini.go
+1
-1
service/convert.go
+14
-13
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,20 +674,21 @@ func GeminiToOpenAIRequest(geminiRequest *dto.GeminiChatRequest, info *relaycomm
...
@@ -674,20 +674,21 @@ 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
))
for
_
,
function
:=
range
functionDeclarations
{
continue
openAITool
:=
dto
.
ToolCallRequest
{
}
Type
:
"function"
,
for
_
,
function
:=
range
functionDeclarations
{
Function
:
dto
.
Function
Request
{
openAITool
:=
dto
.
ToolCall
Request
{
Name
:
function
.
Name
,
Type
:
"function"
,
Description
:
function
.
Description
,
Function
:
dto
.
FunctionRequest
{
Parameters
:
function
.
Parameters
,
Name
:
function
.
Name
,
}
,
Description
:
function
.
Description
,
}
Parameters
:
function
.
Parameters
,
tools
=
append
(
tools
,
openAITool
)
},
}
}
tools
=
append
(
tools
,
openAITool
)
}
}
}
}
}
}
...
...
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