import os from huggingface_hub import HfApi def get_secret(): # Try to get from environment variable first (for local development) api_key = os.getenv("GROQ_API_KEY") # If not found, try to get from Hugging Face secrets if not api_key: try: api_key = HfApi().get_space_variable("GROQ_API_KEY") except Exception as e: print(f"Error getting secret: {e}") return None return api_key