id
stringlengths
14
16
text
stringlengths
31
2.41k
source
stringlengths
53
121
9a1d2e553f93-1
metadata = { "document_id": self.document_id, "revision_id": metadata_json["data"]["document"]["revision_id"], "title": metadata_json["data"]["document"]["title"], } yield Document(page_content=text, metadata=metadata) [docs] def load(self) -> List[Document]: ...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/larksuite.html
caf184e16aa9-0
Source code for langchain.document_loaders.url_playwright """Loader that uses Playwright to load a page, then uses unstructured to load the html. """ import logging from typing import List, Optional from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader logger = logging....
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/url_playwright.html
caf184e16aa9-1
[docs] def load(self) -> List[Document]: """Load the specified URLs using Playwright and create Document instances. Returns: List[Document]: A list of Document instances with loaded content. """ from playwright.sync_api import sync_playwright from unstructured.part...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/url_playwright.html
aafca4d814ae-0
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...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/joplin.html
aafca4d814ae-1
) self._get_tag_url = ( 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)) ...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/joplin.html
aafca4d814ae-2
def _convert_date(self, date: int) -> str: 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())
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/joplin.html
e4de0e1c367c-0
Source code for langchain.document_loaders.gcs_directory """Loading logic for loading documents from an GCS directory.""" from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.document_loaders.gcs_file import GCSFileLoader [docs]cl...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/gcs_directory.html
7a6ff5df4fbd-0
Source code for langchain.document_loaders.azure_blob_storage_container """Loading logic for loading documents from an Azure Blob Storage container.""" from typing import List from langchain.docstore.document import Document from langchain.document_loaders.azure_blob_storage_file import ( AzureBlobStorageFileLoader...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/azure_blob_storage_container.html
7b8a794f62ff-0
Source code for langchain.document_loaders.url_selenium """Loader that uses Selenium to load a page, then uses unstructured to load the html. """ import logging from typing import TYPE_CHECKING, List, Literal, Optional, Union if TYPE_CHECKING: from selenium.webdriver import Chrome, Firefox from langchain.docstore.d...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/url_selenium.html
7b8a794f62ff-1
raise ImportError( "selenium package not found, please install it with " "`pip install selenium`" ) try: import unstructured # noqa:F401 except ImportError: raise ImportError( "unstructured package not found, please ins...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/url_selenium.html
7b8a794f62ff-2
for arg in self.arguments: firefox_options.add_argument(arg) if self.headless: firefox_options.add_argument("--headless") if self.binary_location is not None: firefox_options.binary_location = self.binary_location if self.executable_pat...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/url_selenium.html
94cf29987b3d-0
Source code for langchain.document_loaders.snowflake_loader from __future__ import annotations from typing import Any, Dict, Iterator, List, Optional, Tuple from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class SnowflakeLoader(BaseLoader): """Loads a que...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/snowflake_loader.html
94cf29987b3d-1
self.password = password self.account = account self.warehouse = warehouse self.role = role self.database = database self.schema = schema self.parameters = parameters self.page_content_columns = ( page_content_columns if page_content_columns is not Non...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/snowflake_loader.html
94cf29987b3d-2
) -> Tuple[List[str], List[str]]: page_content_columns = ( self.page_content_columns if self.page_content_columns else [] ) metadata_columns = self.metadata_columns if self.metadata_columns else [] if page_content_columns is None and query_result: page_content_col...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/snowflake_loader.html
9e4d21fa36c4-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://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/image_captions.html
9e4d21fa36c4-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://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/image_captions.html
32161a964dc7-0
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...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/wikipedia.html
32161a964dc7-1
Loads the query result from Wikipedia into a list of Documents. Returns: List[Document]: A list of Document objects representing the loaded Wikipedia pages. """ client = WikipediaAPIWrapper( lang=self.lang, top_k_results=self.load_max_docs, ...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/wikipedia.html
979cf654867e-0
Source code for langchain.document_loaders.ifixit """Loader that loads iFixit data.""" from typing import List, Optional import requests from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.document_loaders.web_base import WebBaseLoader IFIXIT_BASE_URL =...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/ifixit.html
979cf654867e-1
"""Teardowns are just guides by a different name""" self.page_type = pieces[0] if pieces[0] != "Teardown" else "Guide" if self.page_type == "Guide" or self.page_type == "Answers": self.id = pieces[2] else: self.id = pieces[1] self.web_path = web_path [docs] def...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/ifixit.html
979cf654867e-2
self, url_override: Optional[str] = None ) -> List[Document]: loader = WebBaseLoader(self.web_path if url_override is None else url_override) soup = loader.scrape() output = [] title = soup.find("h1", "post-title").text output.append("# " + title) output.append(soup.s...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/ifixit.html
979cf654867e-3
data = res.json() text = "\n".join( [ data[key] for key in ["title", "description", "contents_raw"] if key in data ] ).strip() metadata = {"source": self.web_path, "title": data["title"]} documents.append(Document(pa...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/ifixit.html
979cf654867e-4
else: for part in data["parts"]: doc_parts.append("\n - " + part["text"]) for row in data["steps"]: doc_parts.append( "\n\n## " + ( row["title"] if row["title"] != "" else "Step {}...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/ifixit.html
e28d6ab03ca3-0
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 ...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/docugami.html
e28d6ab03ca3-1
if values.get("file_paths") and values.get("docset_id"): 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 valu...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/docugami.html
e28d6ab03ca3-2
ancestor_chain = chunk.xpath("ancestor-or-self::*") return "/" + "/".join(_xpath_qname_for_chunk(x) for x in ancestor_chain) def _structure_value(node: Any) -> str: """Get the structure value for a node.""" structure = ( "table" if node.tag == ...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/docugami.html
e28d6ab03ca3-3
"""Create a Document from a node and text.""" metadata = { XPATH_KEY: _xpath_for_chunk(node), DOCUMENT_ID_KEY: document["id"], DOCUMENT_NAME_KEY: document["name"], STRUCTURE_KEY: node.attrib.get("structure", ""), TAG_KEY: re.sub...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/docugami.html
e28d6ab03ca3-4
while url: response = requests.get( url, headers={"Authorization": f"Bearer {self.access_token}"}, ) if response.ok: data = response.json() all_documents.extend(data["documents"]) url = data.get("next", N...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/docugami.html
e28d6ab03ca3-5
data={}, ) if response.ok: data = response.json() all_artifacts.extend(data["artifacts"]) url = data.get("next", None) else: raise Exception( f"Failed to download {url} (status: {response.status_code}...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/docugami.html
e28d6ab03ca3-6
per_file_metadata[doc_id] = metadata else: raise Exception( f"Failed to download {artifact_url}/content " + "(status: {response.status_code})" ) return per_file_metadata def _load_chunks_for_document( ...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/docugami.html
e28d6ab03ca3-7
for project in _project_details: metadata = self._metadata_for_project(project) combined_project_metadata.update(metadata) for doc in _document_details: doc_metadata = combined_project_metadata.get(doc["id"]) chunks += self._load_chunks...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/docugami.html
f144e413b84f-0
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, Dict, List, Sequence, Union from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoade...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/unstructured.html
f144e413b84f-1
import unstructured # noqa:F401 except ImportError: raise ValueError( "unstructured package not found, please install it with " "`pip install unstructured`" ) _valid_modes = {"single", "elements", "paged"} if mode not in _valid_modes: ...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/unstructured.html
f144e413b84f-2
for idx, element in enumerate(elements): metadata = self._get_metadata() if hasattr(element, "metadata"): metadata.update(element.metadata.to_dict()) page_number = metadata.get("page_number", 1) # Check if this page_number already exist...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/unstructured.html
f144e413b84f-3
def _get_elements(self) -> List: from unstructured.partition.auto import partition return partition(filename=self.file_path, **self.unstructured_kwargs) def _get_metadata(self) -> dict: return {"source": self.file_path} def get_elements_from_api( file_path: Union[str, List[str], None] = ...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/unstructured.html
f144e413b84f-4
url: str = "https://api.unstructured.io/general/v0/general", api_key: str = "", **unstructured_kwargs: Any, ): """Initialize with file path.""" if isinstance(file_path, str): validate_unstructured_version(min_unstructured_version="0.6.2") else: validat...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/unstructured.html
f144e413b84f-5
def __init__( self, file: Union[IO, Sequence[IO]], mode: str = "single", url: str = "https://api.unstructured.io/general/v0/general", api_key: str = "", **unstructured_kwargs: Any, ): """Initialize with file path.""" if isinstance(file, collections.abc...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/unstructured.html
2b4097ffc8b9-0
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...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/telegram.html
2b4097ffc8b9-1
if isinstance(text, str): # Take a single string as one page 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 = [] ...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/telegram.html
2b4097ffc8b9-2
[docs] async def fetch_data_from_telegram(self) -> None: """Fetch data from Telegram API and save it as a JSON file.""" from telethon.sync import TelegramClient data = [] async with TelegramClient(self.username, self.api_id, self.api_hash) as client: async for message in c...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/telegram.html
2b4097ffc8b9-3
Args: parent_id (int): The parent message ID. reply_data (pd.DataFrame): A DataFrame containing reply messages. Returns: list: A list of message IDs that are replies to the parent message ID. """ # Find direct replies to the parent mess...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/telegram.html
2b4097ffc8b9-4
message_threads (dict): A dictionary where the key is the parent message \ ID and the value is a list of message IDs in ascending order. data (pd.DataFrame): A DataFrame containing the conversation data: - message.sender_id - text - date ...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/telegram.html
2b4097ffc8b9-5
please install with `pip install pandas` """ ) normalized_messages = pd.json_normalize(d) df = pd.DataFrame(normalized_messages) message_threads = self._get_message_threads(df) combined_texts = self._combine_message_texts(message_threads, df) return te...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/telegram.html
3c8c047bba59-0
Source code for langchain.document_loaders.rtf """Loader that loads rich text files.""" from typing import Any, List from langchain.document_loaders.unstructured import ( UnstructuredFileLoader, satisfies_min_unstructured_version, ) [docs]class UnstructuredRTFLoader(UnstructuredFileLoader): """Loader that u...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/rtf.html
f0d0c60ff536-0
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...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/bibtex.html
f0d0c60ff536-1
import fitz parent_dir = Path(self.file_path).parent # regex is useful for Zotero flavor bibtex files file_names = self.file_regex.findall(entry.get("file", "")) if not file_names: return None texts: List[str] = [] for file_name in file_names: try:...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/bibtex.html
f0d0c60ff536-2
yield doc [docs] def load(self) -> List[Document]: """Load bibtex file documents from the given bibtex file path. See https://bibtexparser.readthedocs.io/en/master/ Args: file_path: the path to the bibtex file Returns: a list of documents with the document.page...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/bibtex.html
993ddeb0a25c-0
Source code for langchain.document_loaders.python import tokenize from langchain.document_loaders.text import TextLoader [docs]class PythonLoader(TextLoader): """ Load Python files, respecting any non-default encoding if specified. """ def __init__(self, file_path: str): with open(file_path, "rb...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/python.html
be284d89e80b-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://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/imsdb.html
a95a386e2c60-0
Source code for langchain.document_loaders.bigquery from __future__ import annotations from typing import TYPE_CHECKING, List, Optional from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader if TYPE_CHECKING: from google.auth.credentials import Credentials [docs]clas...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/bigquery.html
a95a386e2c60-1
self.project = project self.page_content_columns = page_content_columns self.metadata_columns = metadata_columns self.credentials = credentials [docs] def load(self) -> List[Document]: try: from google.cloud import bigquery except ImportError as ex: rai...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/bigquery.html
00fa709a83cb-0
Source code for langchain.document_loaders.tencent_cos_directory """Loading logic for loading documents from Tencent Cloud COS directory.""" from typing import Any, Iterator, List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.document_loaders.tenc...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/tencent_cos_directory.html
00fa709a83cb-1
for content in contents: if content["Key"].endswith("/"): continue loader = TencentCOSFileLoader(self.conf, self.bucket, content["Key"]) yield loader.load()[0]
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/tencent_cos_directory.html
e8cd77322917-0
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...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/tomarkdown.html
a26cb2f7b3ce-0
Source code for langchain.document_loaders.org_mode """Loader that loads Org-Mode files.""" from typing import Any, List from langchain.document_loaders.unstructured import ( UnstructuredFileLoader, validate_unstructured_version, ) [docs]class UnstructuredOrgModeLoader(UnstructuredFileLoader): """Loader tha...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/org_mode.html
e1712dd18747-0
Source code for langchain.document_loaders.embaas import base64 import warnings from typing import Any, Dict, Iterator, List, Optional import requests from pydantic import BaseModel, root_validator, validator from typing_extensions import NotRequired, TypedDict from langchain.docstore.document import Document from lang...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/embaas.html
e1712dd18747-1
"""The instruction to pass to the Embaas document extraction API.""" class EmbaasDocumentExtractionPayload(EmbaasDocumentExtractionParameters): """Payload for the Embaas document extraction API.""" bytes: str """The base64 encoded bytes of the document to extract text from.""" class BaseEmbaasLoader(BaseMod...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/embaas.html
e1712dd18747-2
# Custom api parameters (create embeddings automatically) from langchain.document_loaders.embaas import EmbaasBlobLoader loader = EmbaasBlobLoader( params={ "should_embed": True, "model": "e5-large-v2", "chunk_size": 256...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/embaas.html
e1712dd18747-3
payload["mime_type"] = blob.mimetype return payload def _handle_request( self, payload: EmbaasDocumentExtractionPayload ) -> List[Document]: """Sends a request to the embaas API and handles the response.""" headers = { "Authorization": f"Bearer {self.embaas_api_key}",...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/embaas.html
e1712dd18747-4
it as a named parameter to the constructor. Example: .. code-block:: python # Default parsing from langchain.document_loaders.embaas import EmbaasLoader loader = EmbaasLoader(file_path="example.mp3") documents = loader.load() # Custom api parameter...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/embaas.html
e1712dd18747-5
yield from self.blob_loader.lazy_parse(blob=blob) [docs] def load(self) -> List[Document]: return list(self.lazy_load()) [docs] def load_and_split( self, text_splitter: Optional[TextSplitter] = None ) -> List[Document]: if self.params.get("should_embed", False): warnings.wa...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/embaas.html
ea200a1c0fac-0
Source code for langchain.document_loaders.csv_loader import csv from typing import Any, Dict, List, Optional from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.document_loaders.unstructured import ( UnstructuredFileLoader, validate_unstructure...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/csv_loader.html
ea200a1c0fac-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://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/csv_loader.html
5a8db107902d-0
Source code for langchain.document_loaders.evernote """Load documents from Evernote. https://gist.github.com/foxmask/7b29c43a161e001ff04afdb2f181e31c """ import hashlib import logging from base64 import b64decode from time import strptime from typing import Any, Dict, Iterator, List, Optional from langchain.docstore.do...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/evernote.html
5a8db107902d-1
self.file_path = file_path self.load_single_document = load_single_document [docs] def load(self) -> List[Document]: """Load documents from EverNote export file.""" documents = [ Document( page_content=note["content"], metadata={ ...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/evernote.html
5a8db107902d-2
rsc_dict["hash"] = hashlib.md5(rsc_dict[elem.tag]).hexdigest() else: rsc_dict[elem.tag] = elem.text return rsc_dict @staticmethod def _parse_note(note: List, prefix: Optional[str] = None) -> dict: note_dict: Dict[str, Any] = {} resources = [] def add_p...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/evernote.html
5a8db107902d-3
# Without huge_tree set to True, parser may complain about huge text node # Try to recover, because there may be " ", which will cause # "XMLSyntaxError: Entity 'nbsp' not defined" try: from lxml import etree except ImportError as e: logging.error( ...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/evernote.html
c448481ccdfc-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://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/slack_directory.html
c448481ccdfc-1
if not channel_name: continue if channel_path.endswith(".json"): messages = self._read_json(zip_file, channel_path) for message in messages: document = self._convert_message_to_document( messa...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/slack_directory.html
c448481ccdfc-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://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/slack_directory.html
503e59428ab1-0
Source code for langchain.document_loaders.mediawikidump """Load Data from a MediaWiki dump xml.""" from typing import List, Optional from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class MWDumpLoader(BaseLoader): """ Load MediaWiki dump from XML fil...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/mediawikidump.html
503e59428ab1-1
) metadata = {"source": page.title} docs.append(Document(page_content=text, metadata=metadata)) return docs
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/mediawikidump.html
e388a7eba3da-0
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 ...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/pyspark_dataframe.html
e388a7eba3da-1
"""Gets the amount of "feasible" rows for the DataFrame""" try: 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] ...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/pyspark_dataframe.html
2cc51adad95c-0
Source code for langchain.document_loaders.text import logging from typing import List, Optional from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.document_loaders.helpers import detect_file_encodings logger = logging.getLogger(__name__) [docs]class T...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/text.html
2cc51adad95c-1
except Exception as e: raise RuntimeError(f"Error loading {self.file_path}") from e metadata = {"source": self.file_path} return [Document(page_content=text, metadata=metadata)]
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/text.html
4a161a0c809e-0
Source code for langchain.document_loaders.rst """Loader that loads RST files.""" from typing import Any, List from langchain.document_loaders.unstructured import ( UnstructuredFileLoader, validate_unstructured_version, ) [docs]class UnstructuredRSTLoader(UnstructuredFileLoader): """Loader that uses unstruc...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/rst.html
44b83eea280e-0
Source code for langchain.document_loaders.max_compute from __future__ import annotations from typing import Any, Iterator, List, Optional, Sequence from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.utilities.max_compute import MaxComputeAPIWrapper [d...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/max_compute.html
44b83eea280e-1
given parameters. Args: query: SQL query to execute. endpoint: MaxCompute endpoint. project: A project is a basic organizational unit of MaxCompute, which is similar to a database. access_id: MaxCompute access ID. Should be passed in directly or se...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/max_compute.html
d5a59d191c9d-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://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/sitemap.html
d5a59d191c9d-1
meta_function: Function to parse bs4.Soup output for metadata 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 blocks...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/sitemap.html
d5a59d191c9d-2
if (prop := url.find(tag)) } ) for sitemap in soup.find_all("sitemap"): loc = sitemap.find("loc") if not loc: continue soup_child = self.scrape_all([loc.text], "xml")[0] els.extend(self.parse_sitemap(soup_child)) ...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/sitemap.html
c7363dba0acb-0
Source code for langchain.document_loaders.open_city_data from typing import Iterator, List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class OpenCityDataLoader(BaseLoader): """Loader that loads Open city data.""" def __init__(self, city_id: str,...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/open_city_data.html
be79b95c6e75-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, Iterator, List, Mapping, Optional from urllib.parse import urlparse import reque...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/pdf.html
be79b95c6e75-1
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 ...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/pdf.html
be79b95c6e75-2
""" def __init__(self, file_path: str) -> None: """Initialize with file path.""" try: import pypdf # noqa:F401 except ImportError: raise ImportError( "pypdf package not found, please install it with " "`pip install pypdf`" ) self.p...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/pdf.html
be79b95c6e75-3
""" def __init__( self, path: str, glob: str = "**/[!.]*.pdf", silent_errors: bool = False, load_hidden: bool = False, recursive: bool = False, ): self.path = path self.glob = glob self.load_hidden = load_hidden self.recursive = rec...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/pdf.html
be79b95c6e75-4
"`pip install pdfminer.six`" ) super().__init__(file_path) self.parser = PDFMinerParser() [docs] def load(self) -> List[Document]: """Eagerly load the content.""" return list(self.lazy_load()) [docs] def lazy_load( self, ) -> Iterator[Document]: """L...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/pdf.html
be79b95c6e75-5
[docs]class PyMuPDFLoader(BasePDFLoader): """Loader that uses PyMuPDF to load PDF files.""" def __init__(self, file_path: str) -> None: """Initialize with file path.""" try: import fitz # noqa:F401 except ImportError: raise ImportError( "`PyMuPDF`...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/pdf.html
be79b95c6e75-6
self.should_clean_pdf = should_clean_pdf @property def headers(self) -> dict: return {"app_id": self.mathpix_api_id, "app_key": self.mathpix_api_key} @property def url(self) -> str: return "https://api.mathpix.com/v3/pdf" @property def data(self) -> dict: options = {"conv...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/pdf.html
be79b95c6e75-7
self.wait_for_processing(pdf_id) url = f"{self.url}/{pdf_id}.{self.processed_file_format}" response = requests.get(url, headers=self.headers) return response.content.decode("utf-8") [docs] def clean_pdf(self, contents: str) -> str: contents = "\n".join( [line for line in c...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/pdf.html
be79b95c6e75-8
"`pip install pdfplumber`" ) super().__init__(file_path) self.text_kwargs = text_kwargs or {} [docs] def load(self) -> List[Document]: """Load file.""" parser = PDFPlumberParser(text_kwargs=self.text_kwargs) blob = Blob.from_path(self.file_path) return pars...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/pdf.html
93a284c8c711-0
Source code for langchain.document_loaders.notion """Loader that loads Notion directory dump.""" from pathlib import Path from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class NotionDirectoryLoader(BaseLoader): """Loader that load...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/notion.html
b87b57f834f0-0
Source code for langchain.document_loaders.blockchain import os import re import time from enum import Enum from typing import List, Optional import requests from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader class BlockchainType(Enum): """Enumerator of the suppo...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/blockchain.html
b87b57f834f0-1
""" def __init__( self, contract_address: str, blockchainType: BlockchainType = BlockchainType.ETH_MAINNET, api_key: str = "docs-demo", startToken: str = "", get_all_tokens: bool = False, max_execution_time: Optional[int] = None, ): self.contract_a...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/blockchain.html
b87b57f834f0-2
tokenId = item["id"]["tokenId"] metadata = { "source": self.contract_address, "blockchain": self.blockchainType, "tokenId": tokenId, } result.append(Document(page_content=content, metadata=metadata)) ...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/blockchain.html
b87b57f834f0-3
elif value_type == "hex_0xbf": return "0xbf" + format(result, "0" + str(len(tokenId) - 4) + "x") else: return str(result) # A smart contract can use different formats for the tokenId @staticmethod def _detect_value_type(tokenId: str) -> str: if isinstance(tokenId, int...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/blockchain.html
a956ae3c2c32-0
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...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/trello.html
a956ae3c2c32-1
self.board_name = board_name self.include_card_name = include_card_name 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( ...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/trello.html
a956ae3c2c32-2
token = token or get_from_env("token", "TRELLO_TOKEN") 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 ...
https://api.python.langchain.com/en/stable/_modules/langchain/document_loaders/trello.html