From 439e935ec583eb7641152c32798898024859e939 Mon Sep 17 00:00:00 2001 From: flu0r1ne Date: Fri, 5 May 2023 01:50:56 -0500 Subject: Add stdin as a input source for the inital prompt --- src/gpt_chat_cli/gcli.py | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'src/gpt_chat_cli/gcli.py') diff --git a/src/gpt_chat_cli/gcli.py b/src/gpt_chat_cli/gcli.py index dcd7c8b..f0b754e 100644 --- a/src/gpt_chat_cli/gcli.py +++ b/src/gpt_chat_cli/gcli.py @@ -20,8 +20,10 @@ from .argparsing import ( Arguments, DisplayArguments, CompletionArguments, + DebugArguments, ) +from .version import VERSION from .color import get_color_codes ########################### @@ -132,17 +134,28 @@ def print_streamed_response( def main(): args = parse_args() + if args.version: + print(f'version {VERSION}') + sys.exit(0) + completion_args = args.completion_args + COLOR_CODE = get_color_codes(no_color = not args.display_args.color) - if args.debug_args: - debug_args : DebugArguments = args.debug_args + debug_args : DebugArguments = args.debug_args - if debug_args.save_response_to_file: - save_response_and_arguments(args) - return - elif debug_args.load_response_from_file: - completion_args, completion = load_response_and_arguments(args) + if debug_args.save_response_to_file: + save_response_and_arguments(args) + return + elif debug_args.load_response_from_file: + completion_args, completion = load_response_and_arguments(args) else: + if args.completion_args.message is None: + if sys.stdin.isatty(): + print(f'GPT Chat CLI {VERSION}') + print(f'[{COLOR_CODE.WHITE}#{COLOR_CODE.RESET}]', end=' ', flush=True) + + completion_args.message = sys.stdin.read() + completion = create_chat_completion_from_args(completion_args) print_streamed_response( -- cgit v1.2.3