Skip to content

Commit

Permalink
more specific try except
Browse files Browse the repository at this point in the history
  • Loading branch information
CharlieJCJ committed Dec 4, 2024
1 parent 2ba4bdf commit 232dab5
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,18 @@ class User(BaseModel):
f"Model {self.model} supports structured output via instructor, response: {response}"
)
return True
except Exception as e:
logger.warning(
f"Model {self.model} does not support structured output via instructor: {e}"
)
return False
except instructor.exceptions.InstructorRetryException as e:
if "litellm.AuthenticationError" in str(e):
logger.warning(
f"Please provide a valid API key for model {self.model}."
)
raise e
else:
logger.warning(
f"Model {self.model} does not support structured output via instructor: {e} {type(e)} {e.__cause__}"
)
return False


def estimate_output_tokens(self) -> int:
"""Estimate the number of tokens in the model's response.
Expand Down

0 comments on commit 232dab5

Please sign in to comment.