Skip to content

Commit

Permalink
Fix OpenAI API error with OpenAI-compatible providers (#351)
Browse files Browse the repository at this point in the history
Co-authored-by: Jan Philipp Harries <[email protected]>
  • Loading branch information
jphme and Jan Philipp Harries authored Feb 21, 2024
1 parent 3aa69e4 commit 213bc57
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/distilabel/llm/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,12 @@ def __init__(

self.client = client or OpenAI(api_key=api_key, max_retries=6)

assert (
model in self.available_models
), f"Provided `model` is not available in your OpenAI account, available models are {self.available_models}"
try:
assert (
model in self.available_models
), f"Provided `model` is not available in your OpenAI account, available models are {self.available_models}"
except AttributeError:
logger.warning("Unable to check if model is available in your account.")
self.model = model

def __rich_repr__(self) -> Generator[Any, None, None]:
Expand Down

0 comments on commit 213bc57

Please sign in to comment.