From ba4de9fcd4be3db9a1addd0e26976f52a67e2f65 Mon Sep 17 00:00:00 2001 From: Charle Demers Date: Thu, 19 Oct 2023 22:33:23 -0400 Subject: [PATCH] add support for --version param --- question.py | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/question.py b/question.py index 11c7b7d..9f1809c 100755 --- a/question.py +++ b/question.py @@ -20,6 +20,9 @@ openai.api_key = api_key +# App version +APP_VERSION = "0.7.0" + def call_openai_api(question): try: MODEL = "gpt-4-0613" @@ -43,16 +46,21 @@ def call_openai_api(question): exit(1) # Get user input from command line argument - question = sys.argv[1] - logging.info(f"Received input: {question}") - - # Call OpenAI API - response = call_openai_api(question) + arg = sys.argv[1] - # Output response or failure message - if response: - markdown_response = Markdown(response) - rprint("Assistant says:", markdown_response) + if arg == "--version": + print(f"App version: {APP_VERSION}") + exit(0) else: - print("Failed to get a response.") + logging.info(f"Received input: {arg}") + + # Call OpenAI API + response = call_openai_api(arg) + + # Output response or failure message + if response: + markdown_response = Markdown(response) + rprint("Assistant says:", markdown_response) + else: + print("Failed to get a response.")