Changes from https://github.com/juk0de/ChatMastermind.git #1
@ -17,7 +17,7 @@ def create_ai(args: argparse.Namespace, config: Config) -> AI: # noqa: 11
|
|||||||
is not found, it uses the first AI in the list.
|
is not found, it uses the first AI in the list.
|
||||||
"""
|
"""
|
||||||
ai_conf: AIConfig
|
ai_conf: AIConfig
|
||||||
if args.AI:
|
if 'AI' in args and args.AI:
|
||||||
try:
|
try:
|
||||||
ai_conf = config.ais[args.AI]
|
ai_conf = config.ais[args.AI]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
@ -32,11 +32,11 @@ def create_ai(args: argparse.Namespace, config: Config) -> AI: # noqa: 11
|
|||||||
|
|
||||||
if ai_conf.name == 'openai':
|
if ai_conf.name == 'openai':
|
||||||
ai = OpenAI(cast(OpenAIConfig, ai_conf))
|
ai = OpenAI(cast(OpenAIConfig, ai_conf))
|
||||||
if args.model:
|
if 'model' in args and args.model:
|
||||||
ai.config.model = args.model
|
ai.config.model = args.model
|
||||||
if args.max_tokens:
|
if 'max_tokens' in args and args.max_tokens:
|
||||||
ai.config.max_tokens = args.max_tokens
|
ai.config.max_tokens = args.max_tokens
|
||||||
if args.temperature:
|
if 'temperature' in args and args.temperature:
|
||||||
ai.config.temperature = args.temperature
|
ai.config.temperature = args.temperature
|
||||||
return ai
|
return ai
|
||||||
else:
|
else:
|
||||||
|
|||||||
@ -62,7 +62,12 @@ class OpenAI(AI):
|
|||||||
"""
|
"""
|
||||||
Return all models supported by this AI.
|
Return all models supported by this AI.
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError
|
ret = []
|
||||||
|
for engine in sorted(openai.Engine.list()['data'], key=lambda x: x['id']):
|
||||||
|
if engine['ready']:
|
||||||
|
ret.append(engine['id'])
|
||||||
|
ret.sort()
|
||||||
|
return ret
|
||||||
|
|
||||||
def print_models(self) -> None:
|
def print_models(self) -> None:
|
||||||
"""
|
"""
|
||||||
|
|||||||
@ -100,6 +100,7 @@ def create_parser() -> argparse.ArgumentParser:
|
|||||||
help="Manage configuration",
|
help="Manage configuration",
|
||||||
aliases=['c'])
|
aliases=['c'])
|
||||||
config_cmd_parser.set_defaults(func=config_cmd)
|
config_cmd_parser.set_defaults(func=config_cmd)
|
||||||
|
config_cmd_parser.add_argument('-A', '--AI', help='AI ID to use')
|
||||||
config_group = config_cmd_parser.add_mutually_exclusive_group(required=True)
|
config_group = config_cmd_parser.add_mutually_exclusive_group(required=True)
|
||||||
config_group.add_argument('-l', '--list-models', help="List all available models",
|
config_group.add_argument('-l', '--list-models', help="List all available models",
|
||||||
action='store_true')
|
action='store_true')
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user