()
| 203 | |
| 204 | |
| 205 | def parse_args() -> argparse.Namespace: |
| 206 | parser = argparse.ArgumentParser( |
| 207 | description=DESCRIPTION, formatter_class=argparse.RawTextHelpFormatter |
| 208 | ) |
| 209 | subparsers = parser.add_subparsers( |
| 210 | dest="verb", required=True, help="action to perform" |
| 211 | ) |
| 212 | |
| 213 | # dump subcommand |
| 214 | parser_dump = subparsers.add_parser("dump", help="dump logits from an endpoint") |
| 215 | parser_dump.add_argument( |
| 216 | "output", type=Path, help="output path for dumped logits (.log)" |
| 217 | ) |
| 218 | parser_dump.add_argument( |
| 219 | "endpoint", type=str, help="OAI-compat /completions endpoint" |
| 220 | ) |
| 221 | parser_dump.add_argument( |
| 222 | "--api-key", |
| 223 | type=str, |
| 224 | default=None, |
| 225 | help="API key for authentication (if required)", |
| 226 | ) |
| 227 | parser_dump.add_argument( |
| 228 | "--file", |
| 229 | type=Path, |
| 230 | default=None, |
| 231 | help="File containing prompt to use instead of the default", |
| 232 | ) |
| 233 | parser_dump.add_argument( |
| 234 | "--pattern", |
| 235 | type=str, |
| 236 | default="10,1000,10,4000,10", |
| 237 | help="Pattern n_get,n_skip,... where n_get is number of words to get and n_skip is number of words to skip (num of words, NOT num of tokens)", |
| 238 | ) |
| 239 | |
| 240 | # compare subcommand |
| 241 | parser_compare = subparsers.add_parser( |
| 242 | "compare", help="compare two dumped logits files" |
| 243 | ) |
| 244 | parser_compare.add_argument("input1", type=Path, help="first input file (.log)") |
| 245 | parser_compare.add_argument("input2", type=Path, help="second input file (.log)") |
| 246 | parser_compare.add_argument( |
| 247 | "output", type=Path, help="output path for comparison report (.md)" |
| 248 | ) |
| 249 | |
| 250 | try: |
| 251 | return parser.parse_args() |
| 252 | except Exception as e: |
| 253 | parser.print_help() |
| 254 | raise e |
| 255 | |
| 256 | |
| 257 | def main(): |
no test coverage detected