diff --git a/chatmastermind/main.py b/chatmastermind/main.py index 9c8c3c5..b1db2d6 100755 --- a/chatmastermind/main.py +++ b/chatmastermind/main.py @@ -81,12 +81,6 @@ def ask_cmd(args: argparse.Namespace, config: dict) -> None: """ Handler for the 'ask' command. """ - if args.max_tokens: - config['openai']['max_tokens'] = args.max_tokens - if args.temperature: - config['openai']['temperature'] = args.temperature - if args.model: - config['openai']['model'] = args.model chat, question, tags = create_question_with_hist(args, config) print_chat_hist(chat, False, args.only_source_code) otags = args.output_tags or [] @@ -137,8 +131,8 @@ def create_parser() -> argparse.ArgumentParser: # subcommand-parser cmdparser = parser.add_subparsers(dest='command', title='commands', - description='supported commands') - cmdparser.required = True + description='supported commands', + required=True) # a parent parser for all commands that support tag selection tag_parser = argparse.ArgumentParser(add_help=False) @@ -214,9 +208,16 @@ def main() -> int: parser = create_parser() args = parser.parse_args() command = parser.parse_args() - config = read_config(args.config) + + # modify config according to args openai_api_key(config['openai']['api_key']) + if args.max_tokens: + config['openai']['max_tokens'] = args.max_tokens + if args.temperature: + config['openai']['temperature'] = args.temperature + if args.model: + config['openai']['model'] = args.model command.func(command, config)