mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-09 13:00:34 +00:00
fix path (#1168)
This commit is contained in:
parent
e8f224fd3a
commit
37dd34bea5
@ -1,6 +1,7 @@
|
|||||||
"""Loader that loads online PDF files."""
|
"""Loader that loads online PDF files."""
|
||||||
|
|
||||||
import tempfile
|
import tempfile
|
||||||
|
from pathlib import Path
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
@ -21,9 +22,9 @@ class OnlinePDFLoader(BaseLoader):
|
|||||||
"""Load documents."""
|
"""Load documents."""
|
||||||
r = requests.get(self.web_path)
|
r = requests.get(self.web_path)
|
||||||
with tempfile.TemporaryDirectory() as temp_dir:
|
with tempfile.TemporaryDirectory() as temp_dir:
|
||||||
file_path = f"{temp_dir}/online_file.pdf"
|
file_path = Path(temp_dir) / "online_file.pdf"
|
||||||
file = open(file_path, "wb")
|
file = open(file_path, "wb")
|
||||||
file.write(r.content)
|
file.write(r.content)
|
||||||
file.close()
|
file.close()
|
||||||
loader = UnstructuredPDFLoader(file_path)
|
loader = UnstructuredPDFLoader(str(file_path))
|
||||||
return loader.load()
|
return loader.load()
|
||||||
|
Loading…
Reference in New Issue
Block a user