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

Integrated PDF capabilities #158

Merged
merged 2 commits into from
Jan 30, 2024
Merged
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
8 changes: 7 additions & 1 deletion neogpt/utils/read_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from PIL import Image
from io import BytesIO
from langchain.schema import HumanMessage

from langchain_community.document_loaders import PDFMinerLoader


def read_file(user_input):
Expand All @@ -19,6 +19,12 @@ def read_file(user_input):
content = f.read()
user_input = user_input.replace(file_path, content)

elif extension.lower() in ["pdf"]:
with open(file_path, "rb") as f:
loader = PDFMinerLoader(f)
content = loader.extract_text()
user_input = user_input.replace(file_path, content)

# elif extension.lower() in ["jpg", "jpeg", "png"]:
# with open(file_path, "rb") as f:
# content = f.read()
Expand Down