unified the way comment evaluation and refinement

are handled
This commit is contained in:
Karma Riuk
2025-05-18 22:19:13 +02:00
parent 77b64843ac
commit ad20b03dd8
4 changed files with 46 additions and 44 deletions

View File

@ -56,7 +56,7 @@ class Subject:
def notifyComplete(self, results: dict):
self.status = Status.COMPLETE
for observer in self.observers:
observer.updateComplete(results)
observer.updateComplete({"type": self.type, "results": results})
self.results = results
# TODO: maybe save results to disk here?

View File

@ -12,7 +12,11 @@ REFERENCE_MAP = Dataset.from_json(
ARCHIVES_ROOT = str(get_project_path('../data/archives'))
def evaluate_comments(answers: dict[str, str], percent_cb):
def evaluate_comments(
answers: dict[str, str],
percent_cb: Callable[[float], None] = lambda _: None,
complete_cb: Callable[[dict], None] = lambda _: None,
):
total = len(answers)
results = {}
for i, (id_, gen) in enumerate(answers.items(), 1):
@ -33,6 +37,8 @@ def evaluate_comments(answers: dict[str, str], percent_cb):
'proposed_comment': gen,
}
percent_cb(int(i / total * 100))
complete_cb(results)
return results