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
7eaa8058
authored
Jan 25, 2026
by
Seefs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "feat: xai refusal reason"
This reverts commit
2548eaf8
.
parent
2548eaf8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
21 deletions
+0
-21
relay/channel/openai/relay-openai.go
+0
-21
No files found.
relay/channel/openai/relay-openai.go
View file @
7eaa8058
package
openai
package
openai
import
(
import
(
"bytes"
"fmt"
"fmt"
"io"
"io"
"net/http"
"net/http"
...
@@ -23,19 +22,6 @@ import (
...
@@ -23,19 +22,6 @@ import (
"github.com/gorilla/websocket"
"github.com/gorilla/websocket"
)
)
const
xaiCSAMSafetyCheckType
=
"SAFETY_CHECK_TYPE_CSAM"
func
maybeMarkXaiCSAMRefusal
(
c
*
gin
.
Context
,
info
*
relaycommon
.
RelayInfo
,
responseBody
[]
byte
)
bool
{
if
c
==
nil
||
info
==
nil
||
len
(
responseBody
)
==
0
{
return
false
}
if
!
bytes
.
Contains
(
responseBody
,
[]
byte
(
xaiCSAMSafetyCheckType
))
{
return
false
}
common
.
SetContextKey
(
c
,
constant
.
ContextKeyAdminRejectReason
,
"grok_safety_check_type=csam"
)
return
true
}
func
sendStreamData
(
c
*
gin
.
Context
,
info
*
relaycommon
.
RelayInfo
,
data
string
,
forceFormat
bool
,
thinkToContent
bool
)
error
{
func
sendStreamData
(
c
*
gin
.
Context
,
info
*
relaycommon
.
RelayInfo
,
data
string
,
forceFormat
bool
,
thinkToContent
bool
)
error
{
if
data
==
""
{
if
data
==
""
{
return
nil
return
nil
...
@@ -215,7 +201,6 @@ func OpenaiHandler(c *gin.Context, info *relaycommon.RelayInfo, resp *http.Respo
...
@@ -215,7 +201,6 @@ func OpenaiHandler(c *gin.Context, info *relaycommon.RelayInfo, resp *http.Respo
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
types
.
NewOpenAIError
(
err
,
types
.
ErrorCodeReadResponseBodyFailed
,
http
.
StatusInternalServerError
)
return
nil
,
types
.
NewOpenAIError
(
err
,
types
.
ErrorCodeReadResponseBodyFailed
,
http
.
StatusInternalServerError
)
}
}
isXaiCSAMRefusal
:=
maybeMarkXaiCSAMRefusal
(
c
,
info
,
responseBody
)
if
common
.
DebugEnabled
{
if
common
.
DebugEnabled
{
println
(
"upstream response body:"
,
string
(
responseBody
))
println
(
"upstream response body:"
,
string
(
responseBody
))
}
}
...
@@ -237,16 +222,10 @@ func OpenaiHandler(c *gin.Context, info *relaycommon.RelayInfo, resp *http.Respo
...
@@ -237,16 +222,10 @@ func OpenaiHandler(c *gin.Context, info *relaycommon.RelayInfo, resp *http.Respo
err
=
common
.
Unmarshal
(
responseBody
,
&
simpleResponse
)
err
=
common
.
Unmarshal
(
responseBody
,
&
simpleResponse
)
if
err
!=
nil
{
if
err
!=
nil
{
if
isXaiCSAMRefusal
{
return
nil
,
types
.
NewOpenAIError
(
err
,
types
.
ErrorCodeBadResponseBody
,
http
.
StatusInternalServerError
,
types
.
ErrOptionWithSkipRetry
())
}
return
nil
,
types
.
NewOpenAIError
(
err
,
types
.
ErrorCodeBadResponseBody
,
http
.
StatusInternalServerError
)
return
nil
,
types
.
NewOpenAIError
(
err
,
types
.
ErrorCodeBadResponseBody
,
http
.
StatusInternalServerError
)
}
}
if
oaiError
:=
simpleResponse
.
GetOpenAIError
();
oaiError
!=
nil
&&
oaiError
.
Type
!=
""
{
if
oaiError
:=
simpleResponse
.
GetOpenAIError
();
oaiError
!=
nil
&&
oaiError
.
Type
!=
""
{
if
isXaiCSAMRefusal
{
return
nil
,
types
.
WithOpenAIError
(
*
oaiError
,
resp
.
StatusCode
,
types
.
ErrOptionWithSkipRetry
())
}
return
nil
,
types
.
WithOpenAIError
(
*
oaiError
,
resp
.
StatusCode
)
return
nil
,
types
.
WithOpenAIError
(
*
oaiError
,
resp
.
StatusCode
)
}
}
...
...
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