-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.py
More file actions
41 lines (28 loc) · 1.07 KB
/
cli.py
File metadata and controls
41 lines (28 loc) · 1.07 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
import os
import sys
from core.dataset_loader import load_dataset
from core.agent_loader import load_agent
from evaluator import evaluate
import json
from pathlib import Path
from datetime import datetime
def main():
if len(sys.argv) != 3:
print("Usage:")
print("python cli.py <agent_file.py> <dataset.json>")
sys.exit(1)
agent_file = sys.argv[1]
dataset_file = sys.argv[2]
document_text, documentId, samples = load_dataset(dataset_file)
run_agent = load_agent(agent_file)
scores = evaluate(documentId, document_text, samples, run_agent)
print("\n===== Evaluation Results =====\n")
current_datetime = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
results_path = Path("results", f"results-{Path(agent_file).stem}-{Path(dataset_file).stem}-{current_datetime}.json")
# Ensure the results directory exists
os.makedirs(results_path.parent, exist_ok=True)
with open(results_path, "w") as f:
json.dump(scores, f, indent=2)
print(f"\nResults saved to {results_path}")
if __name__ == "__main__":
main()