Skip to content

Commit

Permalink
refactor: yaml -> dotenv
Browse files Browse the repository at this point in the history
  • Loading branch information
kooqooo committed Aug 8, 2024
1 parent e207f5a commit e854b6c
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions config.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import os
import yaml
import socket
import requests

from dotenv import load_dotenv

def get_public_ip():
response = requests.get('https://checkip.amazonaws.com')
Expand All @@ -24,20 +23,20 @@ def get_private_ip():
path = os.getcwd() # 상위 폴더에서 실행된 경우 -> secret_key.yaml이 상위 폴더에 있음
# path = os.path.dirname(os.path.abspath(__file__)) # 현재 폴더에서 실행된 경우 -> secret_key.yaml이 현재 폴더에 있음

with open(os.path.join(path, "secret_key.yaml"), "r") as yaml_file:
cfg = yaml.safe_load(yaml_file)
load_dotenv(override=True)

OPENAI_API_KEY = cfg["OPENAI_API_KEY"]
COHERE_API_KEY = cfg["COHERE_API_KEY"]
MODEL_NAME = os.getenv("MODEL_NAME", "gpt-4o-mini")
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
COHERE_API_KEY = os.getenv("COHERE_API_KEY")

INSIDE_IP = get_private_ip()
OUTSIDE_IP = get_public_ip()

PORT = 8001
STREAMLIT_PORT = 8501

CLIENT_ID = cfg["CLIENT_ID"]
CLIENT_SECRET = cfg["CLIENT_SECRET"]
CLIENT_ID = os.getenv("CLIENT_ID")
CLIENT_SECRET = os.getenv("CLIENT_SECRET")

DATA_DIR = os.path.join(path, "data")
IMG_PATH = os.path.join(path, "data", "images")
Expand Down

0 comments on commit e854b6c

Please sign in to comment.