Skip to content

Commit

Permalink
add support for --version param
Browse files Browse the repository at this point in the history
  • Loading branch information
cdemers committed Oct 20, 2023
1 parent 88eb7c4 commit ba4de9f
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions question.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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.")

0 comments on commit ba4de9f

Please sign in to comment.