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
a1caf37f
authored
Jul 29, 2025
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: auto ban
parent
e0d9a419
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
4 deletions
+4
-4
relay/channel/gemini/relay-gemini-native.go
+3
-3
relay/gemini_handler.go
+1
-1
No files found.
relay/channel/gemini/relay-gemini-native.go
View file @
a1caf37f
...
...
@@ -20,7 +20,7 @@ func GeminiTextGenerationHandler(c *gin.Context, info *relaycommon.RelayInfo, re
// 读取响应体
responseBody
,
err
:=
io
.
ReadAll
(
resp
.
Body
)
if
err
!=
nil
{
return
nil
,
types
.
New
Error
(
err
,
types
.
ErrorCodeBadResponseBody
)
return
nil
,
types
.
New
OpenAIError
(
err
,
types
.
ErrorCodeBadResponseBody
,
http
.
StatusInternalServerError
)
}
if
common
.
DebugEnabled
{
...
...
@@ -31,7 +31,7 @@ func GeminiTextGenerationHandler(c *gin.Context, info *relaycommon.RelayInfo, re
var
geminiResponse
GeminiChatResponse
err
=
common
.
Unmarshal
(
responseBody
,
&
geminiResponse
)
if
err
!=
nil
{
return
nil
,
types
.
New
Error
(
err
,
types
.
ErrorCodeBadResponseBody
)
return
nil
,
types
.
New
OpenAIError
(
err
,
types
.
ErrorCodeBadResponseBody
,
http
.
StatusInternalServerError
)
}
// 计算使用量(基于 UsageMetadata)
...
...
@@ -54,7 +54,7 @@ func GeminiTextGenerationHandler(c *gin.Context, info *relaycommon.RelayInfo, re
// 直接返回 Gemini 原生格式的 JSON 响应
jsonResponse
,
err
:=
common
.
Marshal
(
geminiResponse
)
if
err
!=
nil
{
return
nil
,
types
.
New
Error
(
err
,
types
.
ErrorCodeBadResponseBody
)
return
nil
,
types
.
New
OpenAIError
(
err
,
types
.
ErrorCodeBadResponseBody
,
http
.
StatusInternalServerError
)
}
common
.
IOCopyBytesGracefully
(
c
,
resp
,
jsonResponse
)
...
...
relay/gemini_handler.go
View file @
a1caf37f
...
...
@@ -230,7 +230,7 @@ func GeminiHelper(c *gin.Context) (newAPIError *types.NewAPIError) {
resp
,
err
:=
adaptor
.
DoRequest
(
c
,
relayInfo
,
requestBody
)
if
err
!=
nil
{
common
.
LogError
(
c
,
"Do gemini request failed: "
+
err
.
Error
())
return
types
.
New
Error
(
err
,
types
.
ErrorCodeDoRequestFailed
)
return
types
.
New
OpenAIError
(
err
,
types
.
ErrorCodeDoRequestFailed
,
http
.
StatusInternalServerError
)
}
statusCodeMappingStr
:=
c
.
GetString
(
"status_code_mapping"
)
...
...
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