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
7391b15b
authored
Oct 13, 2025
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: remove redundant error handling for empty Gemini API response
parent
ae8b8b34
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
relay/channel/gemini/relay-gemini.go
+5
-5
No files found.
relay/channel/gemini/relay-gemini.go
View file @
7391b15b
...
...
@@ -1061,11 +1061,11 @@ func GeminiChatHandler(c *gin.Context, info *relaycommon.RelayInfo, resp *http.R
}
if
len
(
geminiResponse
.
Candidates
)
==
0
{
//return nil, types.NewOpenAIError(errors.New("no candidates returned"), types.ErrorCodeBadResponseBody, http.StatusInternalServerError)
if
geminiResponse
.
PromptFeedback
!=
nil
&&
geminiResponse
.
PromptFeedback
.
BlockReason
!=
nil
{
return
nil
,
types
.
NewOpenAIError
(
errors
.
New
(
"request blocked by Gemini API: "
+*
geminiResponse
.
PromptFeedback
.
BlockReason
),
types
.
ErrorCodePromptBlocked
,
http
.
StatusBadRequest
)
}
else
{
return
nil
,
types
.
NewOpenAIError
(
errors
.
New
(
"empty response from Gemini API"
),
types
.
ErrorCodeEmptyResponse
,
http
.
StatusInternalServerError
)
}
//
if geminiResponse.PromptFeedback != nil && geminiResponse.PromptFeedback.BlockReason != nil {
//
return nil, types.NewOpenAIError(errors.New("request blocked by Gemini API: "+*geminiResponse.PromptFeedback.BlockReason), types.ErrorCodePromptBlocked, http.StatusBadRequest)
//
} else {
//
return nil, types.NewOpenAIError(errors.New("empty response from Gemini API"), types.ErrorCodeEmptyResponse, http.StatusInternalServerError)
//
}
}
fullTextResponse
:=
responseGeminiChat2OpenAI
(
c
,
&
geminiResponse
)
fullTextResponse
.
Model
=
info
.
UpstreamModelName
...
...
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