Closed langgg0511 closed 10 months ago
I can confirm I have also this error since at least 7 or 8 versions. for gpt-4 model only, for the gpt-4-32k model no issue weirdly with Azure. There my config file if it's helping:
model_list:
- model_name: gpt-4-32k
litellm_params:
model: azure/gpt-4-32k
api_version: "2023-05-15"
api_base: "os.environ/AZURE_API_BASE"
api_key: "os.environ/AZURE_API_KEY"
- model_name: gpt-4
litellm_params:
model: azure/gpt-4
api_version: "2023-05-15"
api_base: "os.environ/AZURE_API_BASE"
api_key: "os.environ/AZURE_API_KEY"
litellm_settings:
set_verbose: True
drop_params: True
success_callback: ["langfuse"]
environment_variables:
LANGFUSE_PUBLIC_KEY: {{ LANGFUSE_PUBLIC_KEY }}
LANGFUSE_SECRET_KEY: {{ LANGFUSE_SECRET_KEY }}
LANGFUSE_HOST: "{{ LANGFUSE_HOST }}"
AZURE_API_KEY: {{ AZURE_API_KEY }}
AZURE_API_BASE: {{ AZURE_API_URL }}
Thanks for filing this @Extremys @langgg0511 will investigate and push a fix today hopefully
Just pushed a fix w/ testing - https://github.com/BerriAI/litellm/commit/23b59ac9b8a78ece3809a2ed33390063a75319fa
We now check for content policy violation errors during streaming by checking the finish reason. This is based on the azure docs - https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/content-filter?tabs=warning%2Cpython#scenario-details
Will update ticket once a release is out
Fixed on my side :) thanks!
Closing issue as the fix is live in v1.18.12
onwards
@krrishdholakia this issue still occurs occasionally. In my case with "model": "gpt-35-turbo-1106"
and I am using 1.19.2
6741, in exception_type
raise e
File "python3.11/site-packages/litellm/utils.py", line 6680, in exception_type
raise APIError(
└ <class 'litellm.exceptions.APIError'>
litellm.exceptions.APIError: AzureException - {"error": {"code": "content_filter_error", "message": "The contents are not filtered"}}
@hooman-bayer isn't that just azure raising the content filter error?
We're now just explicitly checking if the finish reason is a content filter and re-raising that
What happened?
https://github.com/BerriAI/litellm/blob/main/litellm/utils.py#L7376 if str_line.choices[0].content_filter_result=={} will raise AzureOpenAIError
Relevant log output
Twitter / LinkedIn details
No response