Skip to content

Commit

Permalink
raise error for content_filter (#849)
Browse files Browse the repository at this point in the history
* raise error for content_filter

* use the code field

* simplify
  • Loading branch information
sonichi authored Dec 6, 2023
1 parent fa11c4f commit 31c1664
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions autogen/oai/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,16 @@ def yes_or_no_filter(context, response):
continue # filter is not passed; try the next config
try:
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
raise
logger.debug(f"config {i} failed", exc_info=1)
if i == last:
raise
else:
# add cost calculation before caching not matter filter is passed or not
# add cost calculation before caching no matter filter is passed or not
response.cost = self.cost(response)
self._update_usage_summary(response, use_cache=False)
if cache_seed is not None:
Expand Down

0 comments on commit 31c1664

Please sign in to comment.