Skip to content

Commit

Permalink
👔 gpt-4o is a fallback OpenAI model if DEBUG is on
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmytro Parfeniuk committed Jul 29, 2024
1 parent 4163232 commit 6d386fb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
5 changes: 5 additions & 0 deletions src/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ class Settings(BaseSettings):
extra="ignore",
)

# TODO: add to the DEVELOPING.md after
# https://github.com/neuralmagic/guidellm/pull/17
# is merged
debug: bool = False

logging: LoggingSettings = LoggingSettings()
openai: OpenAISettings = OpenAISettings()

Expand Down
20 changes: 14 additions & 6 deletions src/guidellm/backend/openai.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import functools
from typing import Any, Dict, Generator, List, Optional

import openai
from loguru import logger
from openai import OpenAI, Stream
from openai.types import Completion
Expand Down Expand Up @@ -128,12 +129,19 @@ def available_models(self) -> List[str]:
:rtype: List[str]
"""

models: List[str] = [
model.id for model in self.openai_client.models.list().data
]
logger.info(f"Available models: {models}")

return models
try:
models: List[str] = [
model.id for model in self.openai_client.models.list().data
]
logger.info(f"Available models: {models}")
except openai.NotFoundError as error:
logger.error(error)
if settings.debug is True:
return ["gpt-4o"]
else:
raise error
else:
return models

@property
@functools.lru_cache(maxsize=1)
Expand Down

0 comments on commit 6d386fb

Please sign in to comment.