Add action -L to list all available models
This commit is contained in:
parent
ca3a53e68b
commit
caf5244d52
@ -5,6 +5,17 @@ def openai_api_key(api_key: str) -> None:
|
|||||||
openai.api_key = api_key
|
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]],
|
def ai(chat: list[dict[str, str]],
|
||||||
config: dict,
|
config: dict,
|
||||||
number: int
|
number: int
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import argparse
|
|||||||
import pathlib
|
import pathlib
|
||||||
from .utils import terminal_width, process_tags, display_chat, display_source_code, display_tags_frequency
|
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 .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
|
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-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('-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-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('-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('-m', '--max-tokens', help='Max tokens to use', type=int)
|
||||||
parser.add_argument('-T', '--temperature', help='Temperature to use', type=float)
|
parser.add_argument('-T', '--temperature', help='Temperature to use', type=float)
|
||||||
@ -149,6 +150,8 @@ def main() -> int:
|
|||||||
process_and_display_chat(args, config)
|
process_and_display_chat(args, config)
|
||||||
elif args.list_tags:
|
elif args.list_tags:
|
||||||
process_and_display_tags(args, config)
|
process_and_display_tags(args, config)
|
||||||
|
elif args.list_models:
|
||||||
|
display_models()
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user