Skip to content

Commit

Permalink
feat: fallback to a default path for the yaml configuration files if …
Browse files Browse the repository at this point in the history
…no the corresponding env variable is not set
  • Loading branch information
jacopo-chevallard committed Sep 23, 2024
1 parent 98b3b4f commit 78b713d
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions backend/api/quivr_api/modules/chat/controller/chat/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,24 @@
logger = get_logger(__name__)


class RetrievalConfigPathEnv(str, Enum):
CHAT_WITH_LLM = "CHAT_LLM_CONFIG_PATH"
RAG = "BRAIN_CONFIG_PATH"
class RetrievalConfigPathEnv(Enum):
CHAT_WITH_LLM = ("CHAT_LLM_CONFIG_PATH", "chat_llm_config.yaml")
RAG = ("BRAIN_CONFIG_PATH", "config/retrieval_config_workflow.yaml")

@property
def env_var(self) -> str:
return self.value[0]

@property
def default_path(self) -> str:
return self.value[1]


def get_config_file_path(
config_path_env: RetrievalConfigPathEnv, current_path: str | None = None
) -> str:
_path = os.getenv(config_path_env.value)
if not _path:
raise ValueError(f"{config_path_env.value} is not set.")
# Get the environment variable or fallback to the default path
_path = os.getenv(config_path_env.env_var, config_path_env.default_path)

if not current_path:
return _path
Expand Down

0 comments on commit 78b713d

Please sign in to comment.