A programming framework for agentic AI
raise error for content_filter (#849)
Chi Wang31c166435e7e
diff --git a/autogen/oai/client.py b/autogen/oai/client.pyindex 70a28e15e..147f412fd 100644--- a/autogen/oai/client.py+++ b/autogen/oai/client.py@@ -248,12 +248,16 @@ class OpenAIWrapper:continue # filter is not passed; try the next configtry:response = self._completions_create(client, params)- except APIError:+ except APIError as err:+ error_code = getattr(err, "code", None)+ if error_code == "content_filter":+ # raise the error for content_filter+ raiselogger.debug(f"config {i} failed", exc_info=1)if i == last:raiseelse:- # add cost calculation before caching not matter filter is passed or not+ # add cost calculation before caching no matter filter is passed or notresponse.cost = self.cost(response)self._update_usage_summary(response, use_cache=False)if cache_seed is not None: