main: cleanup
This commit is contained in:
parent
5119b3a874
commit
93a8b0081a
@ -81,12 +81,6 @@ def ask_cmd(args: argparse.Namespace, config: dict) -> None:
|
|||||||
"""
|
"""
|
||||||
Handler for the 'ask' command.
|
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)
|
chat, question, tags = create_question_with_hist(args, config)
|
||||||
print_chat_hist(chat, False, args.only_source_code)
|
print_chat_hist(chat, False, args.only_source_code)
|
||||||
otags = args.output_tags or []
|
otags = args.output_tags or []
|
||||||
@ -137,8 +131,8 @@ def create_parser() -> argparse.ArgumentParser:
|
|||||||
# subcommand-parser
|
# subcommand-parser
|
||||||
cmdparser = parser.add_subparsers(dest='command',
|
cmdparser = parser.add_subparsers(dest='command',
|
||||||
title='commands',
|
title='commands',
|
||||||
description='supported commands')
|
description='supported commands',
|
||||||
cmdparser.required = True
|
required=True)
|
||||||
|
|
||||||
# a parent parser for all commands that support tag selection
|
# a parent parser for all commands that support tag selection
|
||||||
tag_parser = argparse.ArgumentParser(add_help=False)
|
tag_parser = argparse.ArgumentParser(add_help=False)
|
||||||
@ -214,9 +208,16 @@ def main() -> int:
|
|||||||
parser = create_parser()
|
parser = create_parser()
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
command = parser.parse_args()
|
command = parser.parse_args()
|
||||||
|
|
||||||
config = read_config(args.config)
|
config = read_config(args.config)
|
||||||
|
|
||||||
|
# modify config according to args
|
||||||
openai_api_key(config['openai']['api_key'])
|
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)
|
command.func(command, config)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user