mirror of
https://github.com/microsoft/autogen.git
synced 2026-01-26 21:18:45 -05:00
raise error for content_filter (#849)
* raise error for content_filter * use the code field * simplify
This commit is contained in:
@@ -248,12 +248,16 @@ class OpenAIWrapper:
|
||||
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:
|
||||
|
||||
Reference in New Issue
Block a user