id
stringlengths
14
16
text
stringlengths
29
2.73k
source
stringlengths
50
116
f032db217422-3
"`username` and provide a value for `oauth2`" ) if oauth2 and oauth2.keys() != [ "access_token", "access_token_secret", "consumer_key", "key_cert", ]: errors.append( "You have either ommited require keys or added ext...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
f032db217422-4
:type include_restricted_content: bool, optional :param include_archived_content: Whether to include archived content, defaults to False :type include_archived_content: bool, optional :param include_attachments: defaults to False :type include_att...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
f032db217422-5
expand="body.storage.value", ) docs += self.process_pages( pages, include_restricted_content, include_attachments, include_comments ) if cql: pages = self.paginate_request( self.confluence.cql, cql=cql, ...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
f032db217422-6
doesn't match the limit value. If `limit` is >100 confluence seems to cap the response to 100. Also, due to the Atlassian Python package, we don't get the "next" values from the "_links" key because they only return the value from the results key. So here, the pagination starts from 0 a...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
f032db217422-7
break docs.extend(batch) return docs[:max_pages] [docs] def is_public_page(self, page: dict) -> bool: """Check if a page is publicly accessible.""" restrictions = self.confluence.get_all_restrictions_for_content(page["id"]) return ( page["status"] == "current" ...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
f032db217422-8
).get_text() + "".join(attachment_texts) if include_comments: comments = self.confluence.get_page_comments( page["id"], expand="body.view.value", depth="all" )["results"] comment_texts = [ BeautifulSoup(comment["body"]["view"]["value"], "lxml")...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
f032db217422-9
or media_type == "image/jpeg" ): text = title + self.process_image(absolute_url) elif ( media_type == "application/vnd.openxmlformats-officedocument" ".wordprocessingml.document" ): text = title + self.process_doc(absolu...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
f032db217422-10
return text [docs] def process_image(self, link: str) -> str: try: from io import BytesIO # noqa: F401 import pytesseract # noqa: F401 from PIL import Image # noqa: F401 except ImportError: raise ImportError( "`pytesseract` or `Pillow...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
f032db217422-11
try: import xlrd # noqa: F401 except ImportError: raise ImportError("`xlrd` package not found, please run `pip install xlrd`") response = self.confluence.request(path=link, absolute=True) text = "" if ( response.status_code != 200 or respo...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
f032db217422-12
or response.content is None ): return text drawing = svg2rlg(BytesIO(response.content)) img_data = BytesIO() renderPM.drawToFile(drawing, img_data, fmt="PNG") img_data.seek(0) image = Image.open(img_data) return pytesseract.image_to_string(image) By Ha...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
8afab1da9074-0
Source code for langchain.document_loaders.slack_directory """Loader for documents from a Slack export.""" import json import zipfile from pathlib import Path from typing import Dict, List, Optional from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class Slack...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/slack_directory.html
8afab1da9074-1
channel_name = Path(channel_path).parent.name if not channel_name: continue if channel_path.endswith(".json"): messages = self._read_json(zip_file, channel_path) for message in messages: document = self._...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/slack_directory.html
8afab1da9074-2
"timestamp": timestamp, "user": user, } def _get_message_source(self, channel_name: str, user: str, timestamp: str) -> str: """ Get the message source as a string. Args: channel_name (str): The name of the channel the message belongs to. user (str)...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/slack_directory.html
798601b71a28-0
Source code for langchain.document_loaders.hn """Loader that loads HN.""" from typing import Any, List from langchain.docstore.document import Document from langchain.document_loaders.web_base import WebBaseLoader [docs]class HNLoader(WebBaseLoader): """Load Hacker News data from either main page results or the com...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/hn.html
798601b71a28-1
title = lineItem.find("span", {"class": "titleline"}).text.strip() metadata = { "source": self.web_path, "title": title, "link": link, "ranking": ranking, } documents.append( Document( ...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/hn.html
25d9437138e8-0
Source code for langchain.document_loaders.gutenberg """Loader that loads .txt web files.""" from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class GutenbergLoader(BaseLoader): """Loader that uses urllib to load .txt web files.""" ...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/gutenberg.html
80971ce9f6b7-0
Source code for langchain.document_loaders.email """Loader that loads email files.""" import os from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.document_loaders.unstructured import ( UnstructuredFileLoader, satisfies_...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/email.html
80971ce9f6b7-1
"`pip install extract_msg`" ) [docs] def load(self) -> List[Document]: """Load data into document objects.""" import extract_msg msg = extract_msg.Message(self.file_path) return [ Document( page_content=msg.body, metadata={ ...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/email.html
eafd9d9a092a-0
Source code for langchain.document_loaders.sitemap """Loader that fetches a sitemap and loads those URLs.""" import itertools import re from typing import Any, Callable, Generator, Iterable, List, Optional from langchain.document_loaders.web_base import WebBaseLoader from langchain.schema import Document def _default_p...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/sitemap.html
eafd9d9a092a-1
try: import lxml # noqa:F401 except ImportError: raise ValueError( "lxml package not found, please install it with " "`pip install lxml`" ) super().__init__(web_path) self.filter_urls = filter_urls self.parsing_function = parsing_funct...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/sitemap.html
eafd9d9a092a-2
if blockcount - 1 < self.blocknum: raise ValueError( "Selected sitemap does not contain enough blocks for given blocknum" ) else: els = elblocks[self.blocknum] results = self.scrape_all([el["loc"].strip() for el in els if "loc" in e...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/sitemap.html
c24058515e50-0
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...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/word_document.html
c24058515e50-1
if hasattr(self, "temp_file"): self.temp_file.close() [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": se...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/word_document.html
c24058515e50-2
"Please upgrade the unstructured package and try again." ) 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_doc...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/word_document.html
7086187965f7-0
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...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/dataframe.html
8ab90711b035-0
Source code for langchain.document_loaders.web_base """Web base loader class.""" import asyncio import logging import warnings from typing import Any, List, Optional, Union import aiohttp import requests from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader logger = log...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/web_base.html
8ab90711b035-1
): """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 isinstance(web_path, str): self.web_paths = [web_path] elif isinstance(...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/web_base.html
8ab90711b035-2
if i == retries - 1: raise else: logger.warning( f"Error fetching {url} with attempt " f"{i + 1}/{retries}: {e}. Retrying..." ) await asyncio.sleep(...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/web_base.html
8ab90711b035-3
"""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): url = urls[i] if parser is None: if url.endswith(".xml"): ...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/web_base.html
8ab90711b035-4
"""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 = results[i] text = soup.get_text() metadata = _build_metadata(soup, self.web_paths[i]) docs.appe...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/web_base.html
fefcbd086303-0
Source code for langchain.document_loaders.directory """Loading logic for loading documents from a directory.""" import logging from pathlib import Path from typing import List, Type, Union from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.document_lo...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/directory.html
fefcbd086303-1
[docs] def load(self) -> List[Document]: """Load documents.""" p = Path(self.path) docs = [] items = list(p.rglob(self.glob) if self.recursive else p.glob(self.glob)) pbar = None if self.show_progress: try: from tqdm import tqdm ...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/directory.html
78d9f2ab08a7-0
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...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/html_bs.html
78d9f2ab08a7-1
title = "" metadata: Dict[str, Union[str, None]] = { "source": self.file_path, "title": title, } return [Document(page_content=text, metadata=metadata)] By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 02, 2023.
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/html_bs.html
4b4a7aff76a8-0
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...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/url.html
4b4a7aff76a8-1
def _validate_mode(self, mode: str) -> None: _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: _unst...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/url.html
4b4a7aff76a8-2
elements = partition(url=url, **self.unstructured_kwargs) else: if self.__is_headers_available_for_html(): elements = partition_html( url=url, headers=self.headers, **self.unstructured_kwargs ) ...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/url.html
eeaabd6e36c5-0
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...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/imsdb.html
a34fba458f5c-0
Source code for langchain.document_loaders.unstructured """Loader that uses unstructured to load files.""" from abc import ABC, abstractmethod from typing import IO, Any, List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader def satisfies_min_unstructured_version(m...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/unstructured.html
a34fba458f5c-1
) self.mode = mode if not satisfies_min_unstructured_version("0.5.4"): if "strategy" in unstructured_kwargs: unstructured_kwargs.pop("strategy") self.unstructured_kwargs = unstructured_kwargs @abstractmethod def _get_elements(self) -> List: """Get elem...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/unstructured.html
a34fba458f5c-2
): """Initialize with file path.""" self.file_path = file_path super().__init__(mode=mode, **unstructured_kwargs) def _get_elements(self) -> List: from unstructured.partition.auto import partition return partition(filename=self.file_path, **self.unstructured_kwargs) def _...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/unstructured.html
a34fba458f5c-3
"""Loader that uses unstructured to load file IO objects.""" def __init__(self, file: IO, mode: str = "single", **unstructured_kwargs: Any): """Initialize with file path.""" self.file = file super().__init__(mode=mode, **unstructured_kwargs) def _get_elements(self) -> List: from ...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/unstructured.html
a34fba458f5c-4
By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 02, 2023.
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/unstructured.html
75ad3122b50d-0
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, List, Optional from urllib.parse import urlparse import requests from langchain....
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/pdf.html
75ad3122b50d-1
% r.status_code ) self.web_path = self.file_path self.temp_file = tempfile.NamedTemporaryFile() self.temp_file.write(r.content) self.file_path = self.temp_file.name elif not os.path.isfile(self.file_path): raise ValueError("File path %s...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/pdf.html
75ad3122b50d-2
"""Load given path as pages.""" import pypdf with open(self.file_path, "rb") as pdf_file_obj: pdf_reader = pypdf.PdfReader(pdf_file_obj) return [ Document( page_content=page.extract_text(), metadata={"source": self.file_path...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/pdf.html
75ad3122b50d-3
docs.extend(sub_docs) except Exception as e: if self.silent_errors: logger.warning(e) else: raise e return docs [docs]class PDFMinerLoader(BasePDFLoader): """Loader that uses PDFMiner ...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/pdf.html
75ad3122b50d-4
from pdfminer.utils import open_filename output_string = StringIO() with open_filename(self.file_path, "rb") as fp: extract_text_to_fp( fp, # type: ignore[arg-type] output_string, codec="", laparams=LAParams(), ...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/pdf.html
75ad3122b50d-5
}, ), ) for page in doc ] # MathpixPDFLoader implementation taken largely from Daniel Gross's: # https://gist.github.com/danielgross/3ab4104e14faccc12b49200843adab21 [docs]class MathpixPDFLoader(BasePDFLoader): def __init__( self, file_path: str, ...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/pdf.html
75ad3122b50d-6
files = {"file": f} response = requests.post( self.url, headers=self.headers, files=files, data=self.data ) response_data = response.json() if "pdf_id" in response_data: pdf_id = response_data["pdf_id"] return pdf_id else: ...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/pdf.html
75ad3122b50d-7
# replace the "\" slash that Mathpix adds to escape $, %, (, etc. contents = ( contents.replace("\$", "$") .replace("\%", "%") .replace("\(", "(") .replace("\)", ")") ) return contents [docs] def load(self) -> List[Document]: pdf_id = se...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/pdf.html
ad76163df799-0
Source code for langchain.document_loaders.telegram """Loader that loads Telegram chat json dump.""" import json from pathlib import Path from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader def concatenate_rows(row: dict) -> str: """Combine...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/telegram.html
ad76163df799-1
metadata = {"source": str(p)} return [Document(page_content=text, metadata=metadata)] By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 02, 2023.
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/telegram.html
fe60d542ade6-0
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...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/obsidian.html
fe60d542ade6-1
"""Load documents.""" ps = list(Path(self.file_path).glob("**/*.md")) 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) ...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/obsidian.html
242a0e3f3233-0
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 pydantic import root_validator from pydantic.dataclasses import dataclass from langchain.docstore.do...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
242a0e3f3233-1
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...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
242a0e3f3233-2
"""Loader that loads Youtube transcripts.""" def __init__( self, video_id: str, add_video_info: bool = False, language: str = "en", continue_on_failure: bool = False, ): """Initialize with YouTube video ID.""" self.video_id = video_id self.add_vide...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
242a0e3f3233-3
en_transcript = transcript_list.find_transcript(["en"]) transcript = en_transcript.translate(self.language) transcript_pieces = transcript.fetch() transcript = " ".join([t["text"].strip(" ") for t in transcript_pieces]) return [Document(page_content=transcript, metadata=metadata)] ...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
242a0e3f3233-4
.. code-block:: python from langchain.document_loaders import GoogleApiClient from langchain.document_loaders import GoogleApiYoutubeLoader google_api_client = GoogleApiClient( service_account_path=Path("path_to_your_sec_file.json") ) loader = ...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
242a0e3f3233-5
if not values.get("channel_name") and not values.get("video_ids"): raise ValueError("Must specify either channel_name or video_ids") return values def _get_transcripe_for_video_id(self, video_id: str) -> str: from youtube_transcript_api import NoTranscriptFound, YouTubeTranscriptApi ...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
242a0e3f3233-6
channel_id = response["items"][0]["id"]["channelId"] return channel_id def _get_document_for_channel(self, channel: str, **kwargs: Any) -> List[Document]: try: from youtube_transcript_api import ( NoTranscriptFound, TranscriptsDisabled, ) ...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
242a0e3f3233-7
) else: raise e pass request = self.youtube_client.search().list_next(request, response) return video_ids [docs] def load(self) -> List[Document]: """Load documents.""" document_list = [] if self.channel_name:...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
1d6a198fef9c-0
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...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/notebook.html
1d6a198fef9c-1
return f"'{cell_type}' cell: '{source}'\n\n" 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 [remov...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/notebook.html
1d6a198fef9c-2
if self.remove_newline: filtered_data = filtered_data.applymap(remove_newlines) text = filtered_data.apply( lambda x: concatenate_cells( x, self.include_outputs, self.max_output_length, self.traceback ), axis=1, ).str.cat(sep=" ") m...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/notebook.html
58657450dbdf-0
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...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
58657450dbdf-1
): """Initialize with blackboard course url. 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. ...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
58657450dbdf-2
"""Load data into document objects. Returns: List of documents. """ if self.load_all_recursively: soup_info = self.scrape() self.folder_path = self._get_folder_path(soup_info) relative_paths = self._get_paths(soup_info) documents = [] ...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
58657450dbdf-3
) # Get the folder path folder_path = Path(".") / course_name_clean return str(folder_path) def _get_documents(self, soup: Any) -> List[Document]: """Fetch content from page and return Documents. Args: soup: BeautifulSoup4 soup object. Returns: ...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
58657450dbdf-4
Path(self.folder_path).mkdir(parents=True, exist_ok=True) # Download all attachments for attachment in attachments: self.download(attachment) def _load_documents(self) -> List[Document]: """Load all documents in the folder. Returns: List of documents. ...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
58657450dbdf-5
"""Parse the filename from a url. Args: url: Url to parse the filename from. Returns: The filename. """ if (url_path := Path(url)) and url_path.suffix == ".pdf": return url_path.name else: return self._parse_filename_from_url(url) ...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
58657450dbdf-6
By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 02, 2023.
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
ddfa42e7796c-0
Source code for langchain.document_loaders.notiondb """Notion DB loader for langchain""" from typing import Any, Dict, List 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 = NOTION_BASE_URL...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/notiondb.html
ddfa42e7796c-1
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]] = [] while True: data = self._request( DATABASE_URL.format(database_id=self.database_i...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/notiondb.html
ddfa42e7796c-2
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, num_tabs: int = 0) -> str: """Read a block and its children.""" result_lines_arr: List[str] = [] cur_...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/notiondb.html
ddfa42e7796c-3
By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 02, 2023.
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/notiondb.html
6369f67f1059-0
Source code for langchain.document_loaders.hugging_face_dataset """Loader that loads HuggingFace datasets.""" from typing import List, Mapping, Optional, Sequence, Union from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class HuggingFaceDatasetLoader(BaseLoade...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/hugging_face_dataset.html
6369f67f1059-1
self.page_content_column = page_content_column self.name = name 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...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/hugging_face_dataset.html
5d4cc46ca0a9-0
Source code for langchain.document_loaders.image_captions """ Loader that loads image captions By default, the loader utilizes the pre-trained BLIP image captioning model. https://huggingface.co/Salesforce/blip-image-captioning-base """ from typing import Any, List, Tuple, Union import requests from langchain.docstore....
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/image_captions.html
5d4cc46ca0a9-1
model=model, processor=processor, path_image=path_image ) doc = Document(page_content=caption, metadata=metadata) results.append(doc) return results def _get_captions_and_metadata( self, model: Any, processor: Any, path_image: str ) -> Tuple[str, dict]: ...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/image_captions.html
662c5f5d577b-0
Source code for langchain.document_loaders.csv_loader import csv from typing import Dict, List, Optional from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class CSVLoader(BaseLoader): """Loads a CSV file into a list of documents. Each document represen...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/csv_loader.html
662c5f5d577b-1
with open(self.file_path, newline="", encoding=self.encoding) as csvfile: csv_reader = csv.DictReader(csvfile, **self.csv_args) # type: ignore for i, row in enumerate(csv_reader): content = "\n".join(f"{k.strip()}: {v.strip()}" for k, v in row.items()) try: ...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/csv_loader.html
089369140aeb-0
Source code for langchain.document_loaders.s3_file """Loading logic for loading documents from an s3 file.""" import os import tempfile from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.document_loaders.unstructured import Unst...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/s3_file.html
cef15981059e-0
Source code for langchain.document_loaders.googledrive """Loader that loads data from Google Drive.""" # Prerequisites: # 1. Create a Google Cloud project # 2. Enable the Google Drive API: # https://console.cloud.google.com/flows/enableapi?apiid=drive.googleapis.com # 3. Authorize credentials for desktop app: # htt...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/googledrive.html
cef15981059e-1
if values.get("folder_id") and ( values.get("document_ids") or values.get("file_ids") ): raise ValueError( "Cannot specify both folder_id and document_ids nor " "folder_id and file_ids" ) if ( not values.get("folder_id") ...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/googledrive.html
cef15981059e-2
if not creds or not creds.valid: if creds and creds.expired and creds.refresh_token: creds.refresh(Request()) else: flow = InstalledAppFlow.from_client_secrets_file( str(self.credentials_path), SCOPES ) creds = f...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/googledrive.html
cef15981059e-3
title = header[j].strip() if len(header) > j else "" content.append(f"{title}: {v.strip()}") page_content = "\n".join(content) documents.append(Document(page_content=page_content, metadata=metadata)) return documents def _load_document_from_id(self, id: st...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/googledrive.html
cef15981059e-4
from googleapiclient.discovery import build creds = self._load_credentials() service = build("drive", "v3", credentials=creds) files = self._fetch_files_recursive(service, folder_id) returns = [] for file in files: if file["mimeType"] == "application/vnd.google-apps.d...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/googledrive.html
cef15981059e-5
return returns def _load_documents_from_ids(self) -> List[Document]: """Load documents from a list of IDs.""" if not self.document_ids: raise ValueError("document_ids must be set") return [self._load_document_from_id(doc_id) for doc_id in self.document_ids] def _load_file_fro...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/googledrive.html
cef15981059e-6
docs = [] for file_id in self.file_ids: docs.extend(self._load_file_from_id(file_id)) return docs [docs] def load(self) -> List[Document]: """Load documents.""" if self.folder_id: return self._load_documents_from_folder(self.folder_id) elif self.documen...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/googledrive.html
00b4bc780a5d-0
Source code for langchain.document_loaders.markdown """Loader that loads Markdown files.""" from typing import List from langchain.document_loaders.unstructured import UnstructuredFileLoader [docs]class UnstructuredMarkdownLoader(UnstructuredFileLoader): """Loader that uses unstructured to load markdown files.""" ...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/markdown.html
113accc6c70f-0
Source code for langchain.document_loaders.apify_dataset """Logic for loading documents from Apify datasets.""" from typing import Any, Callable, Dict, List from pydantic import BaseModel, root_validator from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class ...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/apify_dataset.html
113accc6c70f-1
) return values [docs] def load(self) -> List[Document]: """Load documents.""" dataset_items = self.apify_client.dataset(self.dataset_id).list_items().items return list(map(self.dataset_mapping_function, dataset_items)) By Harrison Chase © Copyright 2023, Harrison Chase. ...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/apify_dataset.html
39e3d930b27a-0
Source code for langchain.document_loaders.facebook_chat """Loader that loads Facebook chat json dump.""" import datetime import json from pathlib import Path from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader def concatenate_rows(row: dict) -...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/facebook_chat.html
39e3d930b27a-1
df_filtered = df_filtered[["timestamp_ms", "content", "sender_name"]] text = df_filtered.apply(concatenate_rows, axis=1).str.cat(sep="") metadata = {"source": str(p)} return [Document(page_content=text, metadata=metadata)] By Harrison Chase © Copyright 2023, Harrison Chase. L...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/facebook_chat.html
f17d9d9dbbc4-0
Source code for langchain.document_loaders.gitbook """Loader that loads GitBook.""" from typing import Any, List, Optional from urllib.parse import urljoin, urlparse from langchain.docstore.document import Document from langchain.document_loaders.web_base import WebBaseLoader [docs]class GitbookLoader(WebBaseLoader): ...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/gitbook.html
f17d9d9dbbc4-1
[docs] def load(self) -> List[Document]: """Fetch text from one single GitBook page.""" if self.load_all_paths: soup_info = self.scrape() relative_paths = self._get_paths(soup_info) documents = [] for path in relative_paths: url = urljoi...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/gitbook.html
f2096437ad5b-0
Source code for langchain.document_loaders.blockchain import os import re from enum import Enum from typing import List import requests from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader class BlockchainType(Enum): ETH_MAINNET = "eth-mainnet" ETH_GOERLI = "et...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/blockchain.html
f2096437ad5b-1
self.startToken = startToken if not self.api_key: raise ValueError("Alchemy API key not provided.") if not re.match(r"^0x[a-fA-F0-9]{40}$", self.contract_address): raise ValueError(f"Invalid contract address {self.contract_address}") [docs] def load(self) -> List[Document]: ...
https:///python.langchain.com/en/latest/_modules/langchain/document_loaders/blockchain.html