Fixed issue with file_name
Browse files- evaluator.py +4 -3
- runner.py +2 -1
evaluator.py
CHANGED
@@ -59,7 +59,8 @@ class Evaluator():
|
|
59 |
|
60 |
def _read_answer_file(self, username) -> List[str]:
|
61 |
"""Read the question answer pairs from a user-specific answer file."""
|
62 |
-
|
|
|
63 |
pairs = [QuestionAnswerPair(**pair) for pair in json.load(f)]
|
64 |
formatted_data = [pair.get_answer() for pair in pairs]
|
65 |
return formatted_data
|
@@ -67,9 +68,9 @@ class Evaluator():
|
|
67 |
def submit_answers(self, username: str) -> str:
|
68 |
"""Submits saved answers to the scoring endpoint and returns the result."""
|
69 |
try:
|
70 |
-
answers_payload = self._read_answer_file(
|
71 |
except FileNotFoundError:
|
72 |
-
return "Click 'Get One Answer' or 'Get All Answers' to run before trying to submit."
|
73 |
|
74 |
agent_code = f"https://huggingface.co/spaces/{self.settings.space_id}/tree/main"
|
75 |
submission_data = {
|
|
|
59 |
|
60 |
def _read_answer_file(self, username) -> List[str]:
|
61 |
"""Read the question answer pairs from a user-specific answer file."""
|
62 |
+
file_name = f"answers_{username}.json"
|
63 |
+
with open(file_name, "r") as f:
|
64 |
pairs = [QuestionAnswerPair(**pair) for pair in json.load(f)]
|
65 |
formatted_data = [pair.get_answer() for pair in pairs]
|
66 |
return formatted_data
|
|
|
68 |
def submit_answers(self, username: str) -> str:
|
69 |
"""Submits saved answers to the scoring endpoint and returns the result."""
|
70 |
try:
|
71 |
+
answers_payload = self._read_answer_file(username)
|
72 |
except FileNotFoundError:
|
73 |
+
return "Click 'Get One Answer' or 'Get All Answers' to run agent before trying to submit."
|
74 |
|
75 |
agent_code = f"https://huggingface.co/spaces/{self.settings.space_id}/tree/main"
|
76 |
submission_data = {
|
runner.py
CHANGED
@@ -17,7 +17,8 @@ class Runner():
|
|
17 |
def _save_pairs(self, pairs: list[QuestionAnswerPair], username: str):
|
18 |
"""Write the question answer pairs to a user-specific file."""
|
19 |
answers = [pair.model_dump() for pair in pairs if pair is not None]
|
20 |
-
|
|
|
21 |
json.dump(answers, f, indent=4)
|
22 |
|
23 |
def _enrich_question_text(self, item):
|
|
|
17 |
def _save_pairs(self, pairs: list[QuestionAnswerPair], username: str):
|
18 |
"""Write the question answer pairs to a user-specific file."""
|
19 |
answers = [pair.model_dump() for pair in pairs if pair is not None]
|
20 |
+
file_name = f"answers_{username}.json"
|
21 |
+
with open(file_name, "w") as f:
|
22 |
json.dump(answers, f, indent=4)
|
23 |
|
24 |
def _enrich_question_text(self, item):
|