import configparser import logging import os import ast import re from dotenv import load_dotenv # Local .env file load_dotenv() def getconfig(configfile_path: str): """ Read the config file Params ---------------- configfile_path: file path of .cfg file """ config = configparser.ConfigParser() try: config.read_file(open(configfile_path)) return config except: logging.warning("config file not found") def get_auth(provider: str) -> dict: """Get authentication configuration for different providers""" auth_configs = { "huggingface": {"api_key": os.getenv("HF_TOKEN")}, "qdrant": {"api_key": os.getenv("QDRANT_API_KEY")}, } provider = provider.lower() # Normalize to lowercase if provider not in auth_configs: raise ValueError(f"Unsupported provider: {provider}") auth_config = auth_configs[provider] api_key = auth_config.get("api_key") if not api_key: logging.warning(f"No API key found for provider '{provider}'. Please set the appropriate environment variable.") auth_config["api_key"] = None return auth_config