Skip to content
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

Use the most advanced gpt-4o to replce deprecating gpt-4-vision-preview #4

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ $ source pdf2md/bin/activate
(pdf2md) $ ./pdf2md.py --help
usage: pdf2md.py [-h] [-c] [--first-page FIRST_PAGE] [--last-page LAST_PAGE] [--dpi DPI] pdf [output]

Script for converting PDF to Markdown via OpenAI's `gpt-4-vision` model.
Script for converting PDF to Markdown via OpenAI's `gpt-4o` model.

positional arguments:
pdf path to input PDF file to convert to Markdown
Expand Down
6 changes: 3 additions & 3 deletions pdf2md.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3

"""Script for converting PDF to Markdown via OpenAI's `gpt-4-vision` model."""
"""Script for converting PDF to Markdown via OpenAI's `gpt-4o` model."""

import backoff
import base64
Expand Down Expand Up @@ -30,7 +30,7 @@ def completions_with_backoff(**kwargs):
return openai.chat.completions.create(**kwargs)

def page_image2md(page_image):
"""Prompt OpenAI `gpt-4-vision-preview` model to generate Markdown text from given PIL.Image"""
"""Prompt OpenAI `gpt-4o` model to generate Markdown text from given PIL.Image"""
# encode image with base64 url encoding in order to pass it to the OpenAI API
with BytesIO() as buffer:
page_image.save(buffer, format=page_image.format)
Expand All @@ -40,7 +40,7 @@ def page_image2md(page_image):
)
# get completions from OpenAI API
response = completions_with_backoff(
model="gpt-4-vision-preview",
model="gpt-4o",
seed=0,
temperature=0.0,
messages=[
Expand Down