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: permissions:
contents: read contents: read
env:
RUNTIME__LOG_LEVEL: ERROR
ENV: 'test'
jobs: jobs:
test-gemini: test-gemini:
name: Run S3 File Storage Test 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): if not (self.fallback_model and self.fallback_api_key and self.fallback_endpoint):
raise ContentPolicyFilterError( raise ContentPolicyFilterError(
f"The provided input contains content that is not aligned with our content policy: {text_input}" f"The provided input contains content that is not aligned with our content policy: {text_input}"
) ) from error
try: try:
return await self.aclient.chat.completions.create( return await self.aclient.chat.completions.create(
@ -151,4 +151,4 @@ class GenericAPIAdapter(LLMInterface):
else: else:
raise ContentPolicyFilterError( raise ContentPolicyFilterError(
f"The provided input contains content that is not aligned with our content policy: {text_input}" 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, ContentFilterFinishReasonError,
ContentPolicyViolationError, ContentPolicyViolationError,
InstructorRetryException, InstructorRetryException,
): ) as e:
if not (self.fallback_model and self.fallback_api_key): if not (self.fallback_model and self.fallback_api_key):
raise ContentPolicyFilterError( raise ContentPolicyFilterError(
f"The provided input contains content that is not aligned with our content policy: {text_input}" f"The provided input contains content that is not aligned with our content policy: {text_input}"
) ) from e
try: try:
return await self.aclient.chat.completions.create( return await self.aclient.chat.completions.create(
@ -183,7 +183,7 @@ class OpenAIAdapter(LLMInterface):
else: else:
raise ContentPolicyFilterError( raise ContentPolicyFilterError(
f"The provided input contains content that is not aligned with our content policy: {text_input}" f"The provided input contains content that is not aligned with our content policy: {text_input}"
) ) from error
@observe @observe
@sleep_and_retry_sync() @sleep_and_retry_sync()