|
| 1 | +import click |
| 2 | + |
| 3 | + |
| 4 | +from modelplane.runways.annotator import annotate |
| 5 | +from modelplane.runways.responder import respond |
| 6 | +from modelplane.utils.env import load_from_dotenv |
| 7 | + |
| 8 | + |
| 9 | +@click.group(name="modelplane") |
| 10 | +def cli(): |
| 11 | + pass |
| 12 | + |
| 13 | + |
| 14 | +@cli.command(name="get-sut-responses") |
| 15 | +@click.option( |
| 16 | + "--sut_id", |
| 17 | + type=str, |
| 18 | + required=True, |
| 19 | + help="The SUT UID to use.", |
| 20 | +) |
| 21 | +@click.option( |
| 22 | + "--prompts", |
| 23 | + type=str, |
| 24 | + required=True, |
| 25 | + help="The path to the input prompts file.", |
| 26 | +) |
| 27 | +@click.option( |
| 28 | + "--experiment", |
| 29 | + type=str, |
| 30 | + required=True, |
| 31 | + help="The experiment name to use. If the experiment does not exist, it will be created.", |
| 32 | +) |
| 33 | +@click.option( |
| 34 | + "--cache_dir", |
| 35 | + type=str, |
| 36 | + default=None, |
| 37 | + help="The cache directory. Defaults to None. Local directory used to cache LLM responses.", |
| 38 | +) |
| 39 | +@click.option( |
| 40 | + "--n_jobs", |
| 41 | + type=int, |
| 42 | + default=1, |
| 43 | + help="The number of jobs to run in parallel. Defaults to 1.", |
| 44 | +) |
| 45 | +@load_from_dotenv |
| 46 | +def get_sut_responses( |
| 47 | + sut_id: str, |
| 48 | + prompts: str, |
| 49 | + experiment: str, |
| 50 | + cache_dir: str | None = None, |
| 51 | + n_jobs: int = 1, |
| 52 | +): |
| 53 | + """ |
| 54 | + Run the pipeline to get responses from SUTs. |
| 55 | + """ |
| 56 | + return respond( |
| 57 | + sut_id=sut_id, |
| 58 | + prompts=prompts, |
| 59 | + experiment=experiment, |
| 60 | + cache_dir=cache_dir, |
| 61 | + n_jobs=n_jobs, |
| 62 | + ) |
| 63 | + |
| 64 | + |
| 65 | +@cli.command(name="annotate") |
| 66 | +@click.option( |
| 67 | + "--annotator_id", |
| 68 | + type=str, |
| 69 | + required=True, |
| 70 | + help="The SUT UID to use.", |
| 71 | +) |
| 72 | +@click.option( |
| 73 | + "--experiment", |
| 74 | + type=str, |
| 75 | + required=True, |
| 76 | + help="The experiment name to use. If the experiment does not exist, it will be created.", |
| 77 | +) |
| 78 | +@click.option( |
| 79 | + "--response_run_id", |
| 80 | + type=str, |
| 81 | + required=True, |
| 82 | + help="The run ID corresponding to the responses to annotate.", |
| 83 | +) |
| 84 | +@click.option( |
| 85 | + "--overwrite", |
| 86 | + is_flag=True, |
| 87 | + default=False, |
| 88 | + help="Use the response_run_id to save annotation artifact. Any existing annotation artifact will be overwritten. If not set, a new run will be created.", |
| 89 | +) |
| 90 | +@click.option( |
| 91 | + "--cache_dir", |
| 92 | + type=str, |
| 93 | + default=None, |
| 94 | + help="The cache directory. Defaults to None. Local directory used to cache LLM responses.", |
| 95 | +) |
| 96 | +@click.option( |
| 97 | + "--n_jobs", |
| 98 | + type=int, |
| 99 | + default=1, |
| 100 | + help="The number of jobs to run in parallel. Defaults to 1.", |
| 101 | +) |
| 102 | +@load_from_dotenv |
| 103 | +def get_annotations( |
| 104 | + annotator_id: str, |
| 105 | + experiment: str, |
| 106 | + response_run_id: str, |
| 107 | + overwrite: bool = False, |
| 108 | + cache_dir: str | None = None, |
| 109 | + n_jobs: int = 1, |
| 110 | +): |
| 111 | + return annotate( |
| 112 | + annotator_id=annotator_id, |
| 113 | + experiment=experiment, |
| 114 | + response_run_id=response_run_id, |
| 115 | + overwrite=overwrite, |
| 116 | + cache_dir=cache_dir, |
| 117 | + n_jobs=n_jobs, |
| 118 | + ) |
| 119 | + |
| 120 | + |
| 121 | +if __name__ == "__main__": |
| 122 | + cli() |
0 commit comments