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
f95feae5
authored
Jun 09, 2025
by
Calcium-Ion
Committed by
GitHub
Jun 09, 2025
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1180 from RedwindA/fix/gemini-tool
🐛
fix(Gemini): improve JSON parsing for tool content handling
parents
b21e378f
da415451
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
1 deletions
+16
-1
relay/channel/gemini/relay-gemini.go
+16
-1
No files found.
relay/channel/gemini/relay-gemini.go
View file @
f95feae5
...
...
@@ -205,7 +205,22 @@ func CovertGemini2OpenAI(textRequest dto.GeneralOpenAIRequest, info *relaycommon
}
else
if
val
,
exists
:=
tool_call_ids
[
message
.
ToolCallId
];
exists
{
name
=
val
}
contentMap
:=
common
.
StrToMap
(
message
.
StringContent
())
var
contentMap
map
[
string
]
interface
{}
contentStr
:=
message
.
StringContent
()
// 1. 尝试解析为 JSON 对象
if
err
:=
json
.
Unmarshal
([]
byte
(
contentStr
),
&
contentMap
);
err
!=
nil
{
// 2. 如果失败,尝试解析为 JSON 数组
var
contentSlice
[]
interface
{}
if
err
:=
json
.
Unmarshal
([]
byte
(
contentStr
),
&
contentSlice
);
err
==
nil
{
// 如果是数组,包装成对象
contentMap
=
map
[
string
]
interface
{}{
"result"
:
contentSlice
}
}
else
{
// 3. 如果再次失败,作为纯文本处理
contentMap
=
map
[
string
]
interface
{}{
"content"
:
contentStr
}
}
}
functionResp
:=
&
FunctionResponse
{
Name
:
name
,
Response
:
contentMap
,
...
...
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