File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed
sdk/openai/azure-openai/samples Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -62,16 +62,17 @@ def images_aoai_quickstart() -> None:
6262 image_path = os .path .join (image_dir , 'generated_image.png' )
6363
6464 # Retrieve the generated image
65- image_url = result .data [0 ].url # extract image URL from response
66- if image_url :
67- generated_image = httpx .get (image_url ).content # download the image
65+ if result .data and len (result .data ) > 0 :
66+ image_url = result .data [0 ].url # extract image URL from response
67+ if image_url :
68+ generated_image = httpx .get (image_url ).content # download the image
6869
69- with open (image_path , "wb" ) as image_file :
70- image_file .write (generated_image )
70+ with open (image_path , "wb" ) as image_file :
71+ image_file .write (generated_image )
7172
72- # Display the image in the default image viewer
73- image = Image .open (image_path )
74- image .show ()
73+ # Display the image in the default image viewer
74+ image = Image .open (image_path )
75+ image .show ()
7576
7677if __name__ == "__main__" :
7778 images_aoai_quickstart ()
You can’t perform that action at this time.
0 commit comments