Skip to content

Commit 15bb12f

Browse files
committed
add verbose option for debugging
1 parent 03ec950 commit 15bb12f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

apps/1_call_azure_openai_chat/query_image.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import argparse
22
import base64
3+
import logging
34
from os import getenv
45

56
from dotenv import load_dotenv
@@ -15,10 +16,17 @@ def init_args() -> argparse.Namespace:
1516
parser.add_argument("-f", "--file")
1617
parser.add_argument("-s", "--system", default="You are a professional image analyst. Describe the image.")
1718
parser.add_argument("-p", "--prompt", default="Please describe the content of the image")
19+
parser.add_argument("-v", "--verbose", action="store_true")
1820
return parser.parse_args()
1921

2022

2123
if __name__ == "__main__":
24+
args = init_args()
25+
26+
# Set verbose mode
27+
if args.verbose:
28+
logging.basicConfig(level=logging.DEBUG)
29+
2230
# Parse .env file and set environment variables
2331
load_dotenv()
2432

@@ -29,8 +37,6 @@ def init_args() -> argparse.Namespace:
2937
azure_endpoint=getenv("AZURE_OPENAI_ENDPOINT"),
3038
)
3139

32-
args = init_args()
33-
3440
# Read image file and encode it to base64
3541
try:
3642
with open(args.file, "rb") as f:

0 commit comments

Comments
 (0)