Skip to content

[Fix] Add Content_filter Error Case in openai_api.py#2167

Merged
tonysy merged 1 commit intoopen-compass:mainfrom
Myhs-phz:contentfilter
Jul 1, 2025
Merged

[Fix] Add Content_filter Error Case in openai_api.py#2167
tonysy merged 1 commit intoopen-compass:mainfrom
Myhs-phz:contentfilter

Conversation

@Myhs-phz
Copy link
Copy Markdown
Collaborator

No description provided.

Copy link
Copy Markdown
Collaborator

@tonysy tonysy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As comments.

'and stop reason is <stop>, '
'the input query is: %s', query_data)
return ''
if responses.choices[0].finish_reason == 'content_filter':
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which API may cause this reason? You'd better add comments (with doc url or something else) to improve the readability.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, it would be better to replace all empty returns with OC_API_ERROR_CODE. We can maintain a mapping dictionary, and return the ERROR code string to help locate the bug.

An example:

OC_API_ERROR_CODE_MAPS = {
"OC_API_ERROR_CODE: 01" : "xxx",
"OC_API_ERROR_CODE: 02" : "xxx",
}

Copy link
Copy Markdown
Collaborator Author

@Myhs-phz Myhs-phz Jul 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is hard to handle all error case with ERROR_MAP. So it would be better to maintain the status quo.

TBR

Copy link
Copy Markdown
Collaborator

@Zhudongsheng75 Zhudongsheng75 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Collaborator

@tonysy tonysy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tonysy tonysy merged commit 488057b into open-compass:main Jul 1, 2025
8 checks passed
zyc140345 pushed a commit to zyc140345/opencompass that referenced this pull request Oct 23, 2025
iamkaia pushed a commit to iamkaia/opencompass that referenced this pull request Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants