From 15bb12f47c6994cb50516b926ac1e0f11411f874 Mon Sep 17 00:00:00 2001 From: ks6088ts Date: Wed, 28 Aug 2024 15:33:38 +0900 Subject: [PATCH 1/2] add verbose option for debugging --- apps/1_call_azure_openai_chat/query_image.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/1_call_azure_openai_chat/query_image.py b/apps/1_call_azure_openai_chat/query_image.py index 6c8d041..cf08024 100644 --- a/apps/1_call_azure_openai_chat/query_image.py +++ b/apps/1_call_azure_openai_chat/query_image.py @@ -1,5 +1,6 @@ import argparse import base64 +import logging from os import getenv from dotenv import load_dotenv @@ -15,10 +16,17 @@ def init_args() -> argparse.Namespace: parser.add_argument("-f", "--file") parser.add_argument("-s", "--system", default="You are a professional image analyst. Describe the image.") parser.add_argument("-p", "--prompt", default="Please describe the content of the image") + parser.add_argument("-v", "--verbose", action="store_true") return parser.parse_args() if __name__ == "__main__": + args = init_args() + + # Set verbose mode + if args.verbose: + logging.basicConfig(level=logging.DEBUG) + # Parse .env file and set environment variables load_dotenv() @@ -29,8 +37,6 @@ def init_args() -> argparse.Namespace: azure_endpoint=getenv("AZURE_OPENAI_ENDPOINT"), ) - args = init_args() - # Read image file and encode it to base64 try: with open(args.file, "rb") as f: From 73ef1a45e1a6fb3f4644a9fae039befaf782bd03 Mon Sep 17 00:00:00 2001 From: ks6088ts Date: Wed, 28 Aug 2024 15:53:37 +0900 Subject: [PATCH 2/2] fix text content type --- apps/1_call_azure_openai_chat/query_image.py | 2 +- apps/99_streamlit_examples/pages/2_Image_Q&A.py | 2 +- apps/99_streamlit_examples/pages/3_Camera_Q&A.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/1_call_azure_openai_chat/query_image.py b/apps/1_call_azure_openai_chat/query_image.py index cf08024..82afe4f 100644 --- a/apps/1_call_azure_openai_chat/query_image.py +++ b/apps/1_call_azure_openai_chat/query_image.py @@ -62,7 +62,7 @@ def init_args() -> argparse.Namespace: }, { "type": "text", - "content": args.prompt, + "text": args.prompt, }, ], }, diff --git a/apps/99_streamlit_examples/pages/2_Image_Q&A.py b/apps/99_streamlit_examples/pages/2_Image_Q&A.py index 442be89..72f4b92 100644 --- a/apps/99_streamlit_examples/pages/2_Image_Q&A.py +++ b/apps/99_streamlit_examples/pages/2_Image_Q&A.py @@ -91,7 +91,7 @@ def is_configured(): }, { "type": "text", - "content": question, + "text": question, }, ], }, diff --git a/apps/99_streamlit_examples/pages/3_Camera_Q&A.py b/apps/99_streamlit_examples/pages/3_Camera_Q&A.py index 05b2c77..5ce87cf 100644 --- a/apps/99_streamlit_examples/pages/3_Camera_Q&A.py +++ b/apps/99_streamlit_examples/pages/3_Camera_Q&A.py @@ -81,7 +81,7 @@ def is_configured(): }, { "type": "text", - "content": question, + "text": question, }, ], },