id
stringlengths
14
16
source
stringlengths
49
117
text
stringlengths
16
2.73k
73756ad1ca35-1
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/sitemap.html
remember when setting this method to also copy metadata["loc"] to metadata["source"] if you are using this field is_local: whether the sitemap is a local file """ if blocksize is not None and blocksize < 1: raise ValueError("Sitemap blocksize should be at least 1"...
73756ad1ca35-2
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/sitemap.html
soup_child = self.scrape_all([loc.text], "xml")[0] els.extend(self.parse_sitemap(soup_child)) return els [docs] def load(self) -> List[Document]: """Load sitemap.""" if self.is_local: try: import bs4 except ImportError: raise...
b986b949e33b-0
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/word_document.html
Source code for langchain.document_loaders.word_document """Loader that loads word documents.""" import os import tempfile from abc import ABC from typing import List from urllib.parse import urlparse import requests from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader...
b986b949e33b-1
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/word_document.html
[docs] def load(self) -> List[Document]: """Load given path as single page.""" import docx2txt return [ Document( page_content=docx2txt.process(self.file_path), metadata={"source": self.file_path}, ) ] @staticmethod def _...
b986b949e33b-2
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/word_document.html
if is_doc: from unstructured.partition.doc import partition_doc return partition_doc(filename=self.file_path, **self.unstructured_kwargs) else: from unstructured.partition.docx import partition_docx return partition_docx(filename=self.file_path, **self.unstructure...
9a8f6e096c01-0
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/pyspark_dataframe.html
Source code for langchain.document_loaders.pyspark_dataframe """Load from a Spark Dataframe object""" import itertools import logging import sys from typing import TYPE_CHECKING, Any, Iterator, List, Optional, Tuple from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader ...
9a8f6e096c01-1
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/pyspark_dataframe.html
import psutil except ImportError as e: raise ImportError( "psutil not installed. Please install it with `pip install psutil`." ) from e row = self.df.limit(1).collect()[0] estimated_row_size = sys.getsizeof(row) mem_info = psutil.virtual_memory() ...
f35fb207c463-0
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/dataframe.html
Source code for langchain.document_loaders.dataframe """Load from Dataframe object""" from typing import Any, List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class DataFrameLoader(BaseLoader): """Load Pandas DataFrames.""" def __init__(self, dat...
1e025c33ab4a-0
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/web_base.html
Source code for langchain.document_loaders.web_base """Web base loader class.""" import asyncio import logging import warnings from typing import Any, Dict, List, Optional, Union import aiohttp import requests from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader logger...
1e025c33ab4a-1
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/web_base.html
self, web_path: Union[str, List[str]], header_template: Optional[dict] = None ): """Initialize with webpage path.""" # TODO: Deprecate web_path in favor of web_paths, and remove this # left like this because there are a number of loaders that expect single # urls if isinstanc...
1e025c33ab4a-2
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/web_base.html
) as response: return await response.text() except aiohttp.ClientConnectionError as e: if i == retries - 1: raise else: logger.warning( f"Error fetching {url} with ...
1e025c33ab4a-3
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/web_base.html
[docs] def scrape_all(self, urls: List[str], parser: Union[str, None] = None) -> List[Any]: """Fetch all urls, then return soups for all results.""" from bs4 import BeautifulSoup results = asyncio.run(self.fetch_all(urls)) final_results = [] for i, result in enumerate(results)...
1e025c33ab4a-4
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/web_base.html
docs.append(Document(page_content=text, metadata=metadata)) return docs [docs] def aload(self) -> List[Document]: """Load text from the urls in web_path async into Documents.""" results = self.scrape_all(self.web_paths) docs = [] for i in range(len(results)): soup ...
22460ca3bdcd-0
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/wikipedia.html
Source code for langchain.document_loaders.wikipedia from typing import List, Optional from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.utilities.wikipedia import WikipediaAPIWrapper [docs]class WikipediaLoader(BaseLoader): """Loads a query resul...
d6c40e9a2df1-0
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/onedrive.html
Source code for langchain.document_loaders.onedrive """Loader that loads data from OneDrive""" from __future__ import annotations import logging import os import tempfile from enum import Enum from pathlib import Path from typing import TYPE_CHECKING, Dict, List, Optional, Type, Union from pydantic import BaseModel, Ba...
d6c40e9a2df1-1
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/onedrive.html
] = "application/vnd.openxmlformats-officedocument.wordprocessingml.document" # noqa: E501 elif file_type.value == "pdf": mime_types_mapping[file_type.value] = "application/pdf" return mime_types_mapping [docs]class OneDriveLoader(BaseLoader, BaseModel): settings: _OneDriveSetti...
d6c40e9a2df1-2
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/onedrive.html
scopes=SCOPES, token_backend=token_backend, **{"raise_http_errors": False}, ) # make the auth account.authenticate() return account def _get_folder_from_path(self, drive: Type[Drive]) -> Union[Folder, Drive]: """ Returns the...
d6c40e9a2df1-3
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/onedrive.html
file_types = _SupportedFileTypes(file_types=["doc", "docx", "pdf"]) file_mime_types = file_types.fetch_mime_types() items = folder.get_items() with tempfile.TemporaryDirectory() as temp_dir: file_path = f"{temp_dir}" os.makedirs(os.path.dirname(file_path), exist_ok=True) ...
d6c40e9a2df1-4
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/onedrive.html
loader = OneDriveFileLoader(file=file) docs.extend(loader.load()) return docs [docs] def load(self) -> List[Document]: """ Loads all supported document files from the specified OneDrive drive a nd returns a list of Document objects. Returns: ...
a2ee2a58a0db-0
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/directory.html
Source code for langchain.document_loaders.directory """Loading logic for loading documents from a directory.""" import concurrent import logging from pathlib import Path from typing import Any, List, Optional, Type, Union from langchain.docstore.document import Document from langchain.document_loaders.base import Base...
a2ee2a58a0db-1
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/directory.html
self.recursive = recursive self.show_progress = show_progress self.use_multithreading = use_multithreading self.max_concurrency = max_concurrency [docs] def load_file( self, item: Path, path: Path, docs: List[Document], pbar: Optional[Any] ) -> None: if item.is_file(): ...
a2ee2a58a0db-2
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/directory.html
max_workers=self.max_concurrency ) as executor: executor.map(lambda i: self.load_file(i, p, docs, pbar), items) else: for i in items: self.load_file(i, p, docs, pbar) if pbar: pbar.close() return docs # By Harrison Chase ...
c124467180e4-0
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/iugu.html
Source code for langchain.document_loaders.iugu """Loader that fetches data from IUGU""" import json import urllib.request from typing import List, Optional from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.utils import get_from_env, stringify_dict IU...
c124467180e4-1
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/iugu.html
© Copyright 2023, Harrison Chase. Last updated on Jun 04, 2023.
ea6d13cd6c7c-0
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/html_bs.html
Source code for langchain.document_loaders.html_bs """Loader that uses bs4 to load HTML files, enriching metadata with page title.""" import logging from typing import Dict, List, Union from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader logger = logging.getLogger(__n...
ea6d13cd6c7c-1
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/html_bs.html
"source": self.file_path, "title": title, } return [Document(page_content=text, metadata=metadata)] By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 04, 2023.
e46604538ce3-0
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/json_loader.html
Source code for langchain.document_loaders.json_loader """Loader that loads data from JSON.""" import json from pathlib import Path from typing import Any, Callable, Dict, List, Optional, Union from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class JSONLoader...
e46604538ce3-1
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/json_loader.html
except ImportError: raise ImportError( "jq package not found, please install it with `pip install jq`" ) self.file_path = Path(file_path).resolve() self._jq_schema = jq.compile(jq_schema) self._content_key = content_key self._metadata_func = metada...
e46604538ce3-2
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/json_loader.html
f"Expected page_content is string, got {type(content)} instead. \ Set `text_content=False` if the desired input for \ `page_content` is not a string" ) # In case the text is None, set it to an empty string elif isinstance(content, str): ret...
d881812ef45f-0
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/weather.html
Source code for langchain.document_loaders.weather """Simple reader that reads weather data from OpenWeatherMap API""" from __future__ import annotations from datetime import datetime from typing import Iterator, List, Optional, Sequence from langchain.docstore.document import Document from langchain.document_loaders.b...
d881812ef45f-1
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/weather.html
© Copyright 2023, Harrison Chase. Last updated on Jun 04, 2023.
a984cfa4d97a-0
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/url.html
Source code for langchain.document_loaders.url """Loader that uses unstructured to load HTML files.""" import logging from typing import Any, List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader logger = logging.getLogger(__name__) [docs]class UnstructuredURLLoade...
a984cfa4d97a-1
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/url.html
_valid_modes = {"single", "elements"} if mode not in _valid_modes: raise ValueError( f"Got {mode} for `mode`, but should be one of `{_valid_modes}`" ) def __is_headers_available_for_html(self) -> bool: _unstructured_version = self.__version.split("-")[0] ...
a984cfa4d97a-2
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/url.html
url=url, headers=self.headers, **self.unstructured_kwargs ) else: elements = partition_html(url=url, **self.unstructured_kwargs) except Exception as e: if self.continue_on_failure: logger.error(f"Error fe...
0298adc1b2fc-0
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/imsdb.html
Source code for langchain.document_loaders.imsdb """Loader that loads IMSDb.""" from typing import List from langchain.docstore.document import Document from langchain.document_loaders.web_base import WebBaseLoader [docs]class IMSDbLoader(WebBaseLoader): """Loader that loads IMSDb webpages.""" [docs] def load(se...
f69860fda16b-0
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/unstructured.html
Source code for langchain.document_loaders.unstructured """Loader that uses unstructured to load files.""" import collections from abc import ABC, abstractmethod from typing import IO, Any, List, Sequence, Union from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader def ...
f69860fda16b-1
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/unstructured.html
"unstructured package not found, please install it with " "`pip install unstructured`" ) _valid_modes = {"single", "elements"} if mode not in _valid_modes: raise ValueError( f"Got {mode} for `mode`, but should be one of `{_valid_modes}`" ...
f69860fda16b-2
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/unstructured.html
return docs [docs]class UnstructuredFileLoader(UnstructuredBaseLoader): """Loader that uses unstructured to load files.""" def __init__( self, file_path: Union[str, List[str]], mode: str = "single", **unstructured_kwargs: Any, ): """Initialize with file path.""" ...
f69860fda16b-3
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/unstructured.html
api_key=api_key, api_url=api_url, **unstructured_kwargs, ) [docs]class UnstructuredAPIFileLoader(UnstructuredFileLoader): """Loader that uses the unstructured web API to load files.""" def __init__( self, file_path: Union[str, List[str]] = "", mode: str = ...
f69860fda16b-4
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/unstructured.html
def _get_elements(self) -> List: from unstructured.partition.auto import partition return partition(file=self.file, **self.unstructured_kwargs) def _get_metadata(self) -> dict: return {} [docs]class UnstructuredAPIFileIOLoader(UnstructuredFileIOLoader): """Loader that uses the unstructur...
1073cc8589c6-0
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/trello.html
Source code for langchain.document_loaders.trello """Loader that loads cards from Trello""" from __future__ import annotations from typing import TYPE_CHECKING, Any, List, Literal, Optional, Tuple from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.util...
1073cc8589c6-1
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/trello.html
self.include_comments = include_comments self.include_checklist = include_checklist self.extra_metadata = extra_metadata self.card_filter = card_filter [docs] @classmethod def from_credentials( cls, board_name: str, *, api_key: Optional[str] = None, ...
1073cc8589c6-2
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/trello.html
client = TrelloClient(api_key=api_key, token=token) return cls(client, board_name, **kwargs) [docs] def load(self) -> List[Document]: """Loads all cards from the specified Trello board. You can filter the cards, metadata and text included by using the optional parameters. ...
1073cc8589c6-3
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/trello.html
text_content += BeautifulSoup(card.description, "lxml").get_text() if self.include_checklist: # Get all the checklist items on the card for checklist in card.checklists: if checklist.items: items = [ f"{item['name']}:{item['stat...
b561ba06237d-0
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/pdf.html
Source code for langchain.document_loaders.pdf """Loader that loads PDF files.""" import json import logging import os import tempfile import time from abc import ABC from io import StringIO from pathlib import Path from typing import Any, Iterator, List, Mapping, Optional from urllib.parse import urlparse import reque...
b561ba06237d-1
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/pdf.html
if not os.path.isfile(self.file_path) and self._is_valid_url(self.file_path): r = requests.get(self.file_path) if r.status_code != 200: raise ValueError( "Check the url of your file; returned status code %s" % r.status_code ...
b561ba06237d-2
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/pdf.html
raise ImportError( "pypdf package not found, please install it with " "`pip install pypdf`" ) self.parser = PyPDFParser() super().__init__(file_path) [docs] def load(self) -> List[Document]: """Load given path as pages.""" return list(self.lazy_load()) [doc...
b561ba06237d-3
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/pdf.html
self.glob = glob self.load_hidden = load_hidden self.recursive = recursive self.silent_errors = silent_errors @staticmethod def _is_visible(path: Path) -> bool: return not any(part.startswith(".") for part in path.parts) [docs] def load(self) -> List[Document]: p = Pat...
b561ba06237d-4
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/pdf.html
) -> Iterator[Document]: """Lazily lod documents.""" blob = Blob.from_path(self.file_path) yield from self.parser.parse(blob) [docs]class PDFMinerPDFasHTMLLoader(BasePDFLoader): """Loader that uses PDFMiner to load PDF files as HTML content.""" def __init__(self, file_path: str): ...
b561ba06237d-5
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/pdf.html
"`pip install pymupdf`" ) super().__init__(file_path) [docs] def load(self, **kwargs: Optional[Any]) -> List[Document]: """Load file.""" parser = PyMuPDFParser(text_kwargs=kwargs) blob = Blob.from_path(self.file_path) return parser.parse(blob) # MathpixPDFLoader im...
b561ba06237d-6
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/pdf.html
return {"options_json": json.dumps(options)} [docs] def send_pdf(self) -> str: with open(self.file_path, "rb") as f: files = {"file": f} response = requests.post( self.url, headers=self.headers, files=files, data=self.data ) response_data = response...
b561ba06237d-7
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/pdf.html
contents = contents.replace("\\section{", "# ").replace("}", "") # replace the "\" slash that Mathpix adds to escape $, %, (, etc. contents = ( contents.replace(r"\$", "$") .replace(r"\%", "%") .replace(r"\(", "(") .replace(r"\)", ")") ) re...
ea9b8d5e3d31-0
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/telegram.html
Source code for langchain.document_loaders.telegram """Loader that loads Telegram chat json dump.""" from __future__ import annotations import asyncio import json from pathlib import Path from typing import TYPE_CHECKING, Dict, List, Optional, Union from langchain.docstore.document import Document from langchain.docume...
ea9b8d5e3d31-1
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/telegram.html
text = [text] page_docs = [Document(page_content=page) for page in text] # Add page numbers as metadata for i, doc in enumerate(page_docs): doc.metadata["page"] = i + 1 # Split pages into chunks doc_chunks = [] for doc in page_docs: text_splitter = RecursiveCharacterTextSplitter(...
ea9b8d5e3d31-2
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/telegram.html
from telethon.sync import TelegramClient data = [] async with TelegramClient(self.username, self.api_id, self.api_hash) as client: async for message in client.iter_messages(self.chat_entity): is_reply = message.reply_to is not None reply_to_id = message.reply_...
ea9b8d5e3d31-3
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/telegram.html
# Find direct replies to the parent message ID direct_replies = reply_data[reply_data["reply_to_id"] == parent_id][ "message.id" ].tolist() # Recursively find replies to the direct replies all_replies = [] for reply_id in direct_replies: ...
ea9b8d5e3d31-4
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/telegram.html
str: A combined string of message texts sorted by date. """ combined_text = "" # Iterate through sorted parent message IDs for parent_id, message_ids in message_threads.items(): # Get the message texts for the message IDs and sort them by date message_texts = ( ...
ea9b8d5e3d31-5
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/telegram.html
Last updated on Jun 04, 2023.
1a8af55e6a92-0
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/obsidian.html
Source code for langchain.document_loaders.obsidian """Loader that loads Obsidian directory dump.""" import re from pathlib import Path from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class ObsidianLoader(BaseLoader): """Loader th...
1a8af55e6a92-1
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/obsidian.html
docs = [] for p in ps: with open(p, encoding=self.encoding) as f: text = f.read() front_matter = self._parse_front_matter(text) text = self._remove_front_matter(text) metadata = { "source": str(p.name), "path": str(p...
6ec600544435-0
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
Source code for langchain.document_loaders.youtube """Loader that loads YouTube transcript.""" from __future__ import annotations import logging from pathlib import Path from typing import Any, Dict, List, Optional from urllib.parse import parse_qs, urlparse from pydantic import root_validator from pydantic.dataclasses...
6ec600544435-1
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
if not values.get("credentials_path") and not values.get( "service_account_path" ): raise ValueError("Must specify either channel_name or video_ids") return values def _load_credentials(self) -> Any: """Load credentials.""" # Adapted from https://developers.go...
6ec600544435-2
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
"m.youtube.com", "youtube.com", "www.youtube.com", "www.youtube-nocookie.com", "vid.plus", } def _parse_video_id(url: str) -> Optional[str]: """Parse a youtube url and return the video id if valid, otherwise None.""" parsed_url = urlparse(url) if parsed_url.scheme not in ALLOWED_SCHEMAS: ...
6ec600544435-3
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
video_id = _parse_video_id(youtube_url) if not video_id: raise ValueError( f"Could not determine the video ID for the URL {youtube_url}" ) return video_id [docs] @classmethod def from_youtube_url(cls, youtube_url: str, **kwargs: Any) -> YoutubeLoader: ...
6ec600544435-4
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
def _get_video_info(self) -> dict: """Get important video information. Components are: - title - description - thumbnail url, - publish_date - channel_author - and more. """ try: from pytube import YouTub...
6ec600544435-5
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
service_account_path=Path("path_to_your_sec_file.json") ) loader = GoogleApiYoutubeLoader( google_api_client=google_api_client, channel_name = "CodeAesthetic" ) load.load() """ google_api_client: GoogleApiClient channel_name: Op...
6ec600544435-6
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
from youtube_transcript_api import NoTranscriptFound, YouTubeTranscriptApi transcript_list = YouTubeTranscriptApi.list_transcripts(video_id) try: transcript = transcript_list.find_transcript([self.captions_language]) except NoTranscriptFound: for available_transcript in t...
6ec600544435-7
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
"`pip install --upgrade " "youtube-transcript-api` " "to use the youtube loader" ) channel_id = self._get_channel_id(channel) request = self.youtube_client.search().list( part="id,snippet", channelId=channel_id, maxResults=5...
6ec600544435-8
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
document_list.extend( [ self._get_document_for_video_id(video_id) for video_id in self.video_ids ] ) else: raise ValueError("Must specify either channel_name or video_ids") return document_list By Harrison Ch...
534cdab5d8ba-0
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/notebook.html
Source code for langchain.document_loaders.notebook """Loader that loads .ipynb notebook files.""" import json from pathlib import Path from typing import Any, List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader def concatenate_cells( cell: dict, include_outp...
534cdab5d8ba-1
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/notebook.html
return "" def remove_newlines(x: Any) -> Any: """Remove recursively newlines, no matter the data structure they are stored in.""" import pandas as pd if isinstance(x, str): return x.replace("\n", "") elif isinstance(x, list): return [remove_newlines(elem) for elem in x] elif isinstan...
534cdab5d8ba-2
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/notebook.html
lambda x: concatenate_cells( x, self.include_outputs, self.max_output_length, self.traceback ), axis=1, ).str.cat(sep=" ") metadata = {"source": str(p)} return [Document(page_content=text, metadata=metadata)] By Harrison Chase © Copyright 2023, ...
a2b06aee11cb-0
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/toml.html
Source code for langchain.document_loaders.toml import json from pathlib import Path from typing import Iterator, List, Union from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class TomlLoader(BaseLoader): """ A TOML document loader that inherits from ...
a2b06aee11cb-1
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/toml.html
Last updated on Jun 04, 2023.
6d46b07fd6fb-0
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
Source code for langchain.document_loaders.blackboard """Loader that loads all documents from a blackboard course.""" import contextlib import re from pathlib import Path from typing import Any, List, Optional, Tuple from urllib.parse import unquote from langchain.docstore.document import Document from langchain.docume...
6d46b07fd6fb-1
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
The BbRouter cookie is required for most blackboard courses. Args: blackboard_course_url: Blackboard course url. bbrouter: BbRouter cookie. load_all_recursively: If True, load all documents recursively. basic_auth: Basic auth credentials. cookies: Cook...
6d46b07fd6fb-2
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
soup_info = self.scrape() self.folder_path = self._get_folder_path(soup_info) relative_paths = self._get_paths(soup_info) documents = [] for path in relative_paths: url = self.base_url + path print(f"Fetching documents from {url}") ...
6d46b07fd6fb-3
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
"""Fetch content from page and return Documents. Args: soup: BeautifulSoup4 soup object. Returns: List of documents. """ attachments = self._get_attachments(soup) self._download_attachments(attachments) documents = self._load_documents() re...
6d46b07fd6fb-4
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
Returns: List of documents. """ # Create the document loader loader = DirectoryLoader( path=self.folder_path, glob="*.pdf", loader_cls=PyPDFLoader # type: ignore ) # Load the documents documents = loader.load() # Return all documents ...
6d46b07fd6fb-5
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
def _parse_filename_from_url(self, url: str) -> str: """Parse the filename from a url. Args: url: Url to parse the filename from. Returns: The filename. Raises: ValueError: If the filename could not be parsed. """ filename_matches = re....
07807f46c474-0
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html
Source code for langchain.document_loaders.docugami """Loader that loads processed documents from Docugami.""" import io import logging import os import re from pathlib import Path from typing import Any, Dict, List, Mapping, Optional, Sequence, Union import requests from pydantic import BaseModel, root_validator from ...
07807f46c474-1
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html
raise ValueError("Cannot specify both file_paths and remote API docset_id") if not values.get("file_paths") and not values.get("docset_id"): raise ValueError("Must specify either file_paths or remote API docset_id") if values.get("docset_id") and not values.get("access_token"): r...
07807f46c474-2
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html
"""Get the structure value for a node.""" structure = ( "table" if node.tag == TABLE_NAME else node.attrib["structure"] if "structure" in node.attrib else None ) return structure def _is_structura...
07807f46c474-3
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html
STRUCTURE_KEY: node.attrib.get("structure", ""), TAG_KEY: re.sub(r"\{.*\}", "", node.tag), } if doc_metadata: metadata.update(doc_metadata) return Document( page_content=text, metadata=metadata, ) # p...
07807f46c474-4
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html
else: raise Exception( f"Failed to download {url} (status: {response.status_code})" ) return all_documents def _project_details_for_docset_id(self, docset_id: str) -> List[Dict]: """Gets all project details for the given docset ID""" url = ...
07807f46c474-5
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html
artifact_name = artifact.get("name") artifact_url = artifact.get("url") artifact_doc = artifact.get("document") if artifact_name == f"{project_id}.xml" and artifact_url and artifact_doc: doc_id = artifact_doc["id"] metadata: Dict = {} #...
07807f46c474-6
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html
url = f"{self.api}/docsets/{docset_id}/documents/{document_id}/dgml" response = requests.request( "GET", url, headers={"Authorization": f"Bearer {self.access_token}"}, data={}, ) if response.ok: return self._parse_dgml(document, respons...
07807f46c474-7
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html
chunks += self._parse_dgml( { DOCUMENT_ID_KEY: path.name, DOCUMENT_NAME_KEY: path.name, }, file.read(), ) return chunks By Harrison Chase © Copyright 202...
d4219426d67b-0
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/notiondb.html
Source code for langchain.document_loaders.notiondb """Notion DB loader for langchain""" from typing import Any, Dict, List, Optional import requests from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader NOTION_BASE_URL = "https://api.notion.com/v1" DATABASE_URL = NOTIO...
d4219426d67b-1
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/notiondb.html
page_ids = self._retrieve_page_ids() return list(self.load_page(page_id) for page_id in page_ids) def _retrieve_page_ids( self, query_dict: Dict[str, Any] = {"page_size": 100} ) -> List[str]: """Get all the pages from a Notion database.""" pages: List[Dict[str, Any]] = [] ...
d4219426d67b-2
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/notiondb.html
elif prop_type == "url": value = prop_data["url"] else: value = None metadata[prop_name.lower()] = value metadata["id"] = page_id return Document(page_content=self._load_blocks(page_id), metadata=metadata) def _load_blocks(self, block_id: str, ...
d4219426d67b-3
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/notiondb.html
res.raise_for_status() return res.json() By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 04, 2023.
2e0489249ff6-0
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/psychic.html
Source code for langchain.document_loaders.psychic """Loader that loads documents from Psychic.dev.""" from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class PsychicLoader(BaseLoader): """Loader that loads documents from Psychic.de...
ee10e87d80f1-0
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/hugging_face_dataset.html
Source code for langchain.document_loaders.hugging_face_dataset """Loader that loads HuggingFace datasets.""" from typing import Iterator, List, Mapping, Optional, Sequence, Union from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class HuggingFaceDatasetLoader...
ee10e87d80f1-1
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/hugging_face_dataset.html
self.data_dir = data_dir self.data_files = data_files self.cache_dir = cache_dir self.keep_in_memory = keep_in_memory self.save_infos = save_infos self.use_auth_token = use_auth_token self.num_proc = num_proc [docs] def lazy_load( self, ) -> Iterator[Docume...
2811712f0721-0
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/tomarkdown.html
Source code for langchain.document_loaders.tomarkdown """Loader that loads HTML to markdown using 2markdown.""" from __future__ import annotations from typing import Iterator, List import requests from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class ToMarkd...
a5fd961b1f4d-0
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/joplin.html
Source code for langchain.document_loaders.joplin import json import urllib from datetime import datetime from typing import Iterator, List, Optional from langchain.document_loaders.base import BaseLoader from langchain.schema import Document from langchain.utils import get_from_env LINK_NOTE_TEMPLATE = "joplin://x-cal...
a5fd961b1f4d-1
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/joplin.html
f"{base_url}/notes/{{id}}/tags?token={access_token}&fields=title" ) def _get_notes(self) -> Iterator[Document]: has_more = True page = 1 while has_more: req_note = urllib.request.Request(self._get_note_url.format(page=page)) with urllib.request.urlopen(req_not...
a5fd961b1f4d-2
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/joplin.html
return datetime.fromtimestamp(date / 1000).strftime("%Y-%m-%d %H:%M:%S") [docs] def lazy_load(self) -> Iterator[Document]: yield from self._get_notes() [docs] def load(self) -> List[Document]: return list(self.lazy_load()) By Harrison Chase © Copyright 2023, Harrison Chase. Las...
39cb87b1200b-0
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/bibtex.html
Source code for langchain.document_loaders.bibtex import logging import re from pathlib import Path from typing import Any, Iterator, List, Mapping, Optional from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.utilities.bibtex import BibtexparserWrapper...