Skip to content

Commit

Permalink
added multiple images in vision
Browse files Browse the repository at this point in the history
  • Loading branch information
Jayr Castro authored and Jayr Castro committed Apr 23, 2024
1 parent ba86f30 commit 13bc285
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions serverless_openai/apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,26 @@ def vision_longimage(
temperature: Optional[float] = 1,
max_tokens: Optional[int] = 1024,
) -> OpenAIResults:

if isinstance(messages.image, list):
img_b64_list = []
for img in messages.image:
if 'data:image/jpeg;base64' in img:
image_np = b64_to_np(img)
else:
image_np = urlimage_to_np(img)
img_b64_list.extend(crop_image(image_np))

if isinstance(messages.image, str):
elif isinstance(messages.image, str):
if 'data:image/jpeg;base64' in messages.image:
image_np = b64_to_np(messages.image)
else:
image_np = urlimage_to_np(messages.image)
img_b64_list = crop_image(image_np)
elif isinstance(messages.image, np.ndarray):
image_np = messages.image
img_b64_list = crop_image(image_np)
img_b64_list = crop_image(image_np)

newm = [
{
"role": messages.role,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import setup, find_packages

VERSION = '1.3.3'
VERSION = '1.3.4'
DESCRIPTION = "A package for using Openai in serverless environment"
LONG_DESCRIPTION = 'A package for using Openai with scraping and etc. in serverless application such as AWS Lambda and GCP Cloud Function'

Expand Down

0 comments on commit 13bc285

Please sign in to comment.