Skip to content

Commit 0a8d72c

Browse files
committed
Improved robustness of tutor init
1 parent 9abdafe commit 0a8d72c

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

‎app/evaluation.py‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,26 @@
77
from time import sleep
88

99
import json
10+
import os
1011

1112
max_retries = 4
1213

13-
config_paths = ['config_tutor.json', 'app/config_tutor.json', 'app/config_tutor_test.json']
14+
# Get the directory of the current file to build relative paths
15+
current_dir = os.path.dirname(os.path.abspath(__file__))
16+
config_test_path = os.path.join(current_dir, 'config_tutor_test.json')
1417

1518
try:
16-
tutor = MathTutor('app/config_tutor_test.json')
19+
tutor = MathTutor(config_test_path)
1720
except Exception as e:
1821
error(f"An error occurred during the initialization of the tutor: {e}")
19-
try:
20-
tutor = MathTutor('app/config_tutor_test.json')
21-
except Exception as e:
22-
for _ in range(max_retries):
23-
sleep(1)
24-
try:
25-
tutor = MathTutor('config_tutor_test.json')
26-
except Exception as e:
27-
error(f"An error occurred during the initialization of the tutor: {e}")
28-
error(f"An error occurred during the initialization of the tutor: {e}")
29-
raise RuntimeError("Failed to initialize MathTutor with either config file") from e
22+
for _ in range(max_retries):
23+
sleep(1)
24+
try:
25+
tutor = MathTutor(config_test_path)
26+
except Exception as e:
27+
error(f"An error occurred during the initialization of the tutor: {e}")
28+
error(f"An error occurred during the initialization of the tutor: {e}")
29+
raise RuntimeError("Failed to initialize MathTutor with either config file") from e
3030

3131
class Params(TypedDict):
3232
model_name: str

0 commit comments

Comments
 (0)