chore: keep exception handling changes to instructor adapters

This commit is contained in:
Daulet Amirkhanov 2025-10-07 22:03:16 +01:00
parent c81315d177
commit ee079604f4
3 changed files with 9 additions and 5 deletions

View file

@ -6,6 +6,10 @@ on:
permissions:
contents: read
env:
RUNTIME__LOG_LEVEL: ERROR
ENV: 'test'
jobs:
test-gemini:
name: Run S3 File Storage Test

View file

@ -118,7 +118,7 @@ class GenericAPIAdapter(LLMInterface):
if not (self.fallback_model and self.fallback_api_key and self.fallback_endpoint):
raise ContentPolicyFilterError(
f"The provided input contains content that is not aligned with our content policy: {text_input}"
)
) from error
try:
return await self.aclient.chat.completions.create(
@ -151,4 +151,4 @@ class GenericAPIAdapter(LLMInterface):
else:
raise ContentPolicyFilterError(
f"The provided input contains content that is not aligned with our content policy: {text_input}"
)
) from error

View file

@ -146,11 +146,11 @@ class OpenAIAdapter(LLMInterface):
ContentFilterFinishReasonError,
ContentPolicyViolationError,
InstructorRetryException,
):
) as e:
if not (self.fallback_model and self.fallback_api_key):
raise ContentPolicyFilterError(
f"The provided input contains content that is not aligned with our content policy: {text_input}"
)
) from e
try:
return await self.aclient.chat.completions.create(
@ -183,7 +183,7 @@ class OpenAIAdapter(LLMInterface):
else:
raise ContentPolicyFilterError(
f"The provided input contains content that is not aligned with our content policy: {text_input}"
)
) from error
@observe
@sleep_and_retry_sync()