Add action -L to list all available models

This commit is contained in:
Oleksandr Kozachuk 2023-08-05 16:04:25 +02:00
parent ca3a53e68b
commit caf5244d52
2 changed files with 15 additions and 1 deletions

View File

@ -5,6 +5,17 @@ def openai_api_key(api_key: str) -> None:
openai.api_key = api_key
def display_models() -> None:
not_ready = []
for engine in sorted(openai.Engine.list()['data'], key=lambda x: x['id']):
if engine['ready']:
print(engine['id'])
else:
not_ready.append(engine['id'])
if len(not_ready) > 0:
print('\nNot ready: ' + ', '.join(not_ready))
def ai(chat: list[dict[str, str]],
config: dict,
number: int

View File

@ -9,7 +9,7 @@ import argparse
import pathlib
from .utils import terminal_width, process_tags, display_chat, display_source_code, display_tags_frequency
from .storage import save_answers, create_chat, get_tags, get_tags_unique, read_file, dump_data
from .api_client import ai, openai_api_key
from .api_client import ai, openai_api_key, display_models
from itertools import zip_longest
@ -97,6 +97,7 @@ def create_parser() -> argparse.ArgumentParser:
group.add_argument('-D', '--chat-dump', help="Print chat history as Python structure", action='store_true')
group.add_argument('-d', '--chat', help="Print chat history as readable text", action='store_true')
group.add_argument('-l', '--list-tags', help="List all tags and their frequency", action='store_true')
group.add_argument('-L', '--list-models', help="List all available models", action='store_true')
parser.add_argument('-c', '--config', help='Config file name.', default=default_config)
parser.add_argument('-m', '--max-tokens', help='Max tokens to use', type=int)
parser.add_argument('-T', '--temperature', help='Temperature to use', type=float)
@ -149,6 +150,8 @@ def main() -> int:
process_and_display_chat(args, config)
elif args.list_tags:
process_and_display_tags(args, config)
elif args.list_models:
display_models()
return 0