-
Notifications
You must be signed in to change notification settings - Fork 287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when testing code example for megaparsevision with Claude 3.5 Sonnet #172
Comments
Anthropic requires images to be in JPEG. Make this change in: MegaParse/libs/megaparse/src/megaparse/parser/megaparse_vision.py Lines 71 to 89 in 32101e9
def process_file(self, file_path: str, image_format: str = "JPEG") -> List[str]:
"""
Process a PDF file and convert its pages to base64 encoded images.
:param file_path: Path to the PDF file
:param image_format: Format to save the images (default: JPEG)
:return: List of base64 encoded images
"""
try:
images = convert_from_path(file_path)
images_base64 = []
for image in images:
buffered = BytesIO()
image.save(buffered, format=image_format)
image_base64 = base64.b64encode(buffered.getvalue()).decode("utf-8")
images_base64.append(image_base64)
return images_base64
except Exception as e:
raise ValueError(f"Error processing PDF file: {str(e)}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I was testing the megaparsevision code and I used Claude 3.5 sonnet and it spit out this error
Here is the code itself:
The text was updated successfully, but these errors were encountered: