(fix) missing PIL import

This commit is contained in:
Ishaan Jaff 2024-04-20 08:26:08 -07:00
parent ad05cce8b7
commit 200f58c1e7

View file

@ -1122,12 +1122,6 @@ def _gemini_vision_convert_messages(messages: list):
Returns: Returns:
tuple: A tuple containing the prompt (a string) and the processed images (a list of objects representing the images). tuple: A tuple containing the prompt (a string) and the processed images (a list of objects representing the images).
""" """
try:
from PIL import Image
except:
raise Exception(
"gemini image conversion failed please run `pip install Pillow`"
)
try: try:
# given messages for gpt-4 vision, convert them for gemini # given messages for gpt-4 vision, convert them for gemini
@ -1154,6 +1148,12 @@ def _gemini_vision_convert_messages(messages: list):
image = _load_image_from_url(img) image = _load_image_from_url(img)
processed_images.append(image) processed_images.append(image)
else: else:
try:
from PIL import Image
except:
raise Exception(
"gemini image conversion failed please run `pip install Pillow`"
)
# Case 2: Image filepath (e.g. temp.jpeg) given # Case 2: Image filepath (e.g. temp.jpeg) given
image = Image.open(img) image = Image.open(img)
processed_images.append(image) processed_images.append(image)