@@ -91,51 +91,53 @@ def __init__(self, args):
9191 self .ingestion_storage_dir = self .result_dir / "storages"
9292 self .mos_config_path = Path (f"{ BASE_DIR } /configs-example/mos_w_scheduler_config.json" )
9393 self .mem_cube_config_path = Path (f"{ BASE_DIR } /configs-example/mem_cube_config.json" )
94+
9495 self .openai_api_key = os .getenv ("CHAT_MODEL_API_KEY" )
9596 self .openai_base_url = os .getenv ("CHAT_MODEL_BASE_URL" )
9697 self .openai_chat_model = os .getenv ("CHAT_MODEL" )
9798
9899 auth_config_path = Path (f"{ BASE_DIR } /scripts/temporal_locomo/eval_auth.json" )
99100 if auth_config_path .exists ():
100101 auth_config = AuthConfig .from_local_config (config_path = auth_config_path )
101-
102- self .openai_api_key = auth_config .openai .api_key
103- self .openai_base_url = auth_config .openai .base_url
104- self .openai_chat_model = auth_config .openai .default_model
105-
106- self .mos_config_data = json .load (self .mos_config_path .open ("r" , encoding = "utf-8" ))
107- self .mem_cube_config_data = json .load (
108- self .mem_cube_config_path .open ("r" , encoding = "utf-8" )
109- )
110-
111- # Update LLM authentication information in MOS configuration using dictionary assignment
112- self .mos_config_data ["mem_reader" ]["config" ]["llm" ]["config" ]["api_key" ] = (
113- auth_config .openai .api_key
114- )
115- self .mos_config_data ["mem_reader" ]["config" ]["llm" ]["config" ]["api_base" ] = (
116- auth_config .openai .base_url
117- )
118-
119- # Update graph database authentication information in memory cube configuration using dictionary assignment
120- self .mem_cube_config_data ["text_mem" ]["config" ]["graph_db" ]["config" ]["uri" ] = (
121- auth_config .graph_db .uri
122- )
123- self .mem_cube_config_data ["text_mem" ]["config" ]["graph_db" ]["config" ]["user" ] = (
124- auth_config .graph_db .user
125- )
126- self .mem_cube_config_data ["text_mem" ]["config" ]["graph_db" ]["config" ]["password" ] = (
127- auth_config .graph_db .password
128- )
129- self .mem_cube_config_data ["text_mem" ]["config" ]["graph_db" ]["config" ]["db_name" ] = (
130- auth_config .graph_db .db_name
102+ print (
103+ f"✅ Configuration loaded successfully: from local config file { auth_config_path } "
131104 )
132- self .mem_cube_config_data ["text_mem" ]["config" ]["graph_db" ]["config" ]["auto_create" ] = (
133- auth_config .graph_db .auto_create
134- )
135-
136105 else :
137- print ("Please referring to configs-example to provide valid configs." )
138- exit ()
106+ # Load .env file first before reading environment variables
107+ load_dotenv ()
108+ auth_config = AuthConfig .from_local_env ()
109+ print ("✅ Configuration loaded successfully: from environment variables" )
110+ self .openai_api_key = auth_config .openai .api_key
111+ self .openai_base_url = auth_config .openai .base_url
112+ self .openai_chat_model = auth_config .openai .default_model
113+
114+ self .mos_config_data = json .load (self .mos_config_path .open ("r" , encoding = "utf-8" ))
115+ self .mem_cube_config_data = json .load (self .mem_cube_config_path .open ("r" , encoding = "utf-8" ))
116+
117+ # Update LLM authentication information in MOS configuration using dictionary assignment
118+ self .mos_config_data ["mem_reader" ]["config" ]["llm" ]["config" ]["api_key" ] = (
119+ auth_config .openai .api_key
120+ )
121+ self .mos_config_data ["mem_reader" ]["config" ]["llm" ]["config" ]["api_base" ] = (
122+ auth_config .openai .base_url
123+ )
124+
125+ # Update graph database authentication information in memory cube configuration using dictionary assignment
126+ self .mem_cube_config_data ["text_mem" ]["config" ]["graph_db" ]["config" ]["uri" ] = (
127+ auth_config .graph_db .uri
128+ )
129+ self .mem_cube_config_data ["text_mem" ]["config" ]["graph_db" ]["config" ]["user" ] = (
130+ auth_config .graph_db .user
131+ )
132+ self .mem_cube_config_data ["text_mem" ]["config" ]["graph_db" ]["config" ]["password" ] = (
133+ auth_config .graph_db .password
134+ )
135+ self .mem_cube_config_data ["text_mem" ]["config" ]["graph_db" ]["config" ]["db_name" ] = (
136+ auth_config .graph_db .db_name
137+ )
138+ self .mem_cube_config_data ["text_mem" ]["config" ]["graph_db" ]["config" ]["auto_create" ] = (
139+ auth_config .graph_db .auto_create
140+ )
139141
140142 # Logger initialization
141143 self .logger = logger
@@ -158,7 +160,6 @@ def __init__(self, args):
158160
159161 self .can_answer_cases : list [RecordingCase ] = []
160162 self .cannot_answer_cases : list [RecordingCase ] = []
161- load_dotenv ()
162163
163164 def print_eval_info (self ):
164165 """
0 commit comments