config.py 800 B

12345678910111213141516171819
  1. # Copyright (c) Meta Platforms, Inc. and affiliates.
  2. # This software may be used and distributed according to the terms of the Llama 2 Community License Agreement.
  3. import yaml
  4. import os
  5. def load_config(config_path: str = "./config.yaml"):
  6. # Read the YAML configuration file
  7. with open(config_path, "r") as file:
  8. config = yaml.safe_load(file)
  9. # Set the API key from the environment variable
  10. try:
  11. config["api_key"] = os.environ["OCTOAI_API_TOKEN"]
  12. except KeyError:
  13. print("API token did not found, please set the OCTOAI_API_TOKEN environment variable if using OctoAI, otherwise set api_key to default EMPTY")
  14. # local Vllm endpoint did not need API key, so set the API key to "EMPTY" if not found
  15. config["api_key"] = "EMPTY"
  16. return config