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
8504023d
authored
Dec 20, 2024
by
MartialBE
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: Fix the issue where Gemini loses content when converting OpenAI format in the stream.
parent
1dfdb44d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
relay/channel/gemini/relay-gemini.go
+7
-3
No files found.
relay/channel/gemini/relay-gemini.go
View file @
8504023d
...
@@ -236,13 +236,17 @@ func streamResponseGeminiChat2OpenAI(geminiResponse *GeminiChatResponse) *dto.Ch
...
@@ -236,13 +236,17 @@ func streamResponseGeminiChat2OpenAI(geminiResponse *GeminiChatResponse) *dto.Ch
var
choice
dto
.
ChatCompletionsStreamResponseChoice
var
choice
dto
.
ChatCompletionsStreamResponseChoice
//choice.Delta.SetContentString(geminiResponse.GetResponseText())
//choice.Delta.SetContentString(geminiResponse.GetResponseText())
if
len
(
geminiResponse
.
Candidates
)
>
0
&&
len
(
geminiResponse
.
Candidates
[
0
]
.
Content
.
Parts
)
>
0
{
if
len
(
geminiResponse
.
Candidates
)
>
0
&&
len
(
geminiResponse
.
Candidates
[
0
]
.
Content
.
Parts
)
>
0
{
respFirst
:=
geminiResponse
.
Candidates
[
0
]
.
Content
.
Parts
[
0
]
respFirst
Parts
:=
geminiResponse
.
Candidates
[
0
]
.
Content
.
Parts
if
respFirst
.
FunctionCall
!=
nil
{
if
respFirst
Parts
[
0
]
.
FunctionCall
!=
nil
{
// function response
// function response
choice
.
Delta
.
ToolCalls
=
getToolCalls
(
&
geminiResponse
.
Candidates
[
0
])
choice
.
Delta
.
ToolCalls
=
getToolCalls
(
&
geminiResponse
.
Candidates
[
0
])
}
else
{
}
else
{
// text response
// text response
choice
.
Delta
.
SetContentString
(
respFirst
.
Text
)
var
texts
[]
string
for
_
,
part
:=
range
respFirstParts
{
texts
=
append
(
texts
,
part
.
Text
)
}
choice
.
Delta
.
SetContentString
(
strings
.
Join
(
texts
,
"
\n
"
))
}
}
}
}
var
response
dto
.
ChatCompletionsStreamResponse
var
response
dto
.
ChatCompletionsStreamResponse
...
...
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