aboutsummaryrefslogtreecommitdiff
path: root/src/gpt_chat_cli/main.py
blob: 77d2708849b3c5c87b9dc093b130b51b69abc2eb (plain)
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
def main():
    # defer other imports until autocomplete has finished
    from .argparsing import parse_raw_args_or_complete

    raw_args = parse_raw_args_or_complete()

    # post process and validate
    from .argvalidation import (
        Arguments,
        post_process_raw_args
    )

    args = post_process_raw_args( raw_args )

    # populate key
    import openai

    openai.api_key = args.openai_key

    # execute relevant command
    from .cmd import (
        version,
        list_models,
        interactive,
        singleton,
    )

    if args.version:
        version()
    elif args.list_models:
        list_models()
    elif args.interactive:
        interactive(args)
    else:
        singleton(args)

if __name__ == "__main__":
    main()