-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenv_value.py
More file actions
112 lines (89 loc) · 3.16 KB
/
env_value.py
File metadata and controls
112 lines (89 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import os
from dotenv import dotenv_values
from rich.pretty import pprint
def find_root_path(start_path=None, root_marker='.projectroot'):
"""
Find the root path of the project by searching for a root marker file.
:param start_path: The path to start searching from. Defaults to the current working directory.
:param root_marker: The name of the file that marks the root directory.
:return: The absolute path of the root directory, or None if not found.
"""
if start_path is None:
start_path = os.getcwd()
current_path = os.path.abspath(start_path)
while True:
if os.path.exists(os.path.join(current_path, root_marker)):
return current_path
parent_path = os.path.dirname(current_path)
if parent_path == current_path: # Reached the filesystem root
return None
current_path = parent_path
class EnvValue(object):
@staticmethod
def initLangsmith():
env = EnvValue.get_env_o()
os.environ["LANGSMITH_TRACING"] = env['LANGSMITH_TRACING']
os.environ["LANGSMITH_ENDPOINT"] = env['LANGSMITH_ENDPOINT']
os.environ["LANGSMITH_API_KEY"] = env['LANGSMITH_API_KEY']
os.environ["LANGSMITH_PROJECT"] = env['LANGSMITH_PROJECT']
# OPENAI_API_KEY
os.environ["OPENAI_API_KEY"] = EnvValue.get_open_ai_key()
@staticmethod
def get_env_o():
# ROOT_DIR = os.path.dirname(os.path.abspath("../"))
# ROOT_DIR = os.path.dirname(os.path.abspath("../"))
ROOT_DIR = find_root_path()
# pprint(ROOT_DIR)
final_path = ROOT_DIR + '/.env'
# pprint(final_path)
config = dotenv_values(final_path)
if config is None or len(config.keys()) == 0:
# pprint('use environ')
return os.environ
else:
# pprint('use .env')
return config
@staticmethod
def gte_flyqueque_api_uuid():
env = EnvValue.get_env_o()
return env['FLY_QUEQUE_API_UUID']
@staticmethod
def get_google_ai_key():
env = EnvValue.get_env_o()
return env['google_ai_key']
@staticmethod
def get_open_ai_key():
env = EnvValue.get_env_o()
return env['open_ai_key']
@staticmethod
def get_neo4j_uri():
env = EnvValue.get_env_o()
return env['NEO4J_URI']
@staticmethod
def get_neo4j_username():
env = EnvValue.get_env_o()
return env['NEO4J_USERNAME']
@staticmethod
def get_neo4j_password():
env = EnvValue.get_env_o()
return env['NEO4J_PASSWORD']
@staticmethod
def get_flyqueque_domain():
env = EnvValue.get_env_o()
return env['FLYQUEQUE_API_DOMAIN']
@staticmethod
def get_geo_api_key():
env = EnvValue.get_env_o()
return env['geo_api_key']
@staticmethod
def get_GOOGLE_PLACE_API_TOKEN():
env = EnvValue.get_env_o()
return env['GOOGLE_PLACE_API_TOKEN']
@staticmethod
def get_aws_access_key():
env = EnvValue.get_env_o()
return env['AWS_ACCESS_KEY']
@staticmethod
def get_aws_secret_key():
env = EnvValue.get_env_o()
return env['AWS_SECRET_KEY']