Skip to content

Commit

Permalink
Update image_parser.py
Browse files Browse the repository at this point in the history
  • Loading branch information
zAlweNy26 authored Nov 26, 2023
1 parent 11dba8b commit 7958c24
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions image_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ def lazy_parse(self, blob: Blob) -> Iterator[Document]:

binary_data = blob.as_bytes()

blob_size = len(binary_data)

if blob_size > 20 * 1000000:
if len(binary_data) > 20 * 1000000:
content = "The image is too large for OpenAI to process."
else:
base64_image = base64.b64encode(binary_data).decode('utf-8')
Expand Down Expand Up @@ -55,4 +53,4 @@ def lazy_parse(self, blob: Blob) -> Iterator[Document]:

content = json["choices"][0]["message"]["content"]

yield Document(page_content=content, metadata={"source": "cat_eyes", "name": blob.path.rsplit('.', 1)[0]})
yield Document(page_content=content, metadata={"source": "cat_eyes", "name": blob.path.rsplit('.', 1)[0]})

0 comments on commit 7958c24

Please sign in to comment.