File size: 1,775 Bytes
39b7b6a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import argparse
import os
import subprocess
import sys


def main():
    parser = argparse.ArgumentParser(description="MedRAG Multi-Modal CLI")
    subparsers = parser.add_subparsers(dest="command", required=True)

    # Run subcommand
    run_parser = subparsers.add_parser("run", help="Run the Streamlit application")
    run_parser.add_argument(
        "--port", type=int, default=8501, help="Port to run Streamlit on"
    )

    # Evaluate subcommand
    eval_parser = subparsers.add_parser("evaluate", help="Run evaluation tests")
    eval_parser.add_argument(
        "--test-file",
        default=os.path.join("tests", "evals", "test_assistant_mmlu_anatomy.py"),
        help="Path to test file",
    )
    eval_parser.add_argument(
        "--test-case",
        type=str,
        help="Only run tests which match the given substring expression",
    )
    eval_parser.add_argument(
        "--model-name",
        type=str,
        default="gemini-1.5-flash",
        help="Model name to use for evaluation",
    )

    args = parser.parse_args()

    if args.command == "run":
        subprocess.run(
            [
                sys.executable,
                "-m",
                "streamlit",
                "run",
                "app.py",
                "--server.port",
                str(args.port),
            ]
        )

    elif args.command == "evaluate":
        test_file = (
            args.test_file + "::" + args.test_case if args.test_case else args.test_file
        )
        cmd = [
            sys.executable,
            "-m",
            "pytest",
            "-s",
            test_file,
            "-v",
            f"--model-name={args.model_name}",
        ]
        subprocess.run(cmd)


if __name__ == "__main__":
    main()