id
stringlengths
14
16
text
stringlengths
31
2.41k
source
stringlengths
54
121
fcfde8a0f140-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/latest/_modules/langchain/document_loaders/ifixit.html
fcfde8a0f140-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/latest/_modules/langchain/document_loaders/ifixit.html
fcfde8a0f140-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/latest/_modules/langchain/document_loaders/ifixit.html
fcfde8a0f140-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/latest/_modules/langchain/document_loaders/ifixit.html
ae2eb36c2be0-0
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...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/notiondb.html
ae2eb36c2be0-1
Returns: List[Document]: List of documents. """ page_summaries = self._retrieve_page_summaries() return list(self.load_page(page_summary) for page_summary in page_summaries) def _retrieve_page_summaries( self, query_dict: Dict[str, Any] = {"page_size": 100} ) -> List[...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/notiondb.html
ae2eb36c2be0-2
if prop_data["multi_select"] else [] ) elif prop_type == "url": value = prop_data["url"] else: value = None metadata[prop_name.lower()] = value metadata["id"] = page_id return Document(page_content=se...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/notiondb.html
ae2eb36c2be0-3
method, url, headers=self.headers, json=query_dict, timeout=self.request_timeout_sec, ) res.raise_for_status() return res.json()
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/notiondb.html
c8f7da67fc6d-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/latest/_modules/langchain/document_loaders/bibtex.html
c8f7da67fc6d-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/latest/_modules/langchain/document_loaders/bibtex.html
c8f7da67fc6d-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/latest/_modules/langchain/document_loaders/bibtex.html
b6925eca9356-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/latest/_modules/langchain/document_loaders/slack_directory.html
b6925eca9356-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/latest/_modules/langchain/document_loaders/slack_directory.html
b6925eca9356-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/latest/_modules/langchain/document_loaders/slack_directory.html
0acdd6746fe6-0
Source code for langchain.document_loaders.merge from typing import Iterator, List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class MergedDataLoader(BaseLoader): """Merge documents from a list of loaders""" def __init__(self, loaders: List): ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/merge.html
7a924bfd1512-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/hn.html
7a924bfd1512-1
title = lineItem.find("span", {"class": "titleline"}).text.strip() metadata = { "source": self.web_path, "title": title, "link": link, "ranking": ranking, } documents.append( Document( ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/hn.html
5ca661859303-0
Source code for langchain.document_loaders.figma """Loader that loads Figma files json dump.""" import json import urllib.request from typing import Any, List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.utils import stringify_dict [docs]class Fi...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/figma.html
0e143cc51f04-0
Source code for langchain.document_loaders.roam """Loader that loads Roam 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 RoamLoader(BaseLoader): """Loader that loads Roam files fr...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/roam.html
df9a292c4399-0
Source code for langchain.document_loaders.mhtml """Loader to load MHTML files, enriching metadata with page title.""" import email import logging from typing import Dict, List, Union from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader logger = logging.getLogger(__nam...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/mhtml.html
df9a292c4399-1
for part in parts: if part.get_content_type() == "text/html": html = part.get_payload(decode=True).decode() soup = BeautifulSoup(html, **self.bs_kwargs) text = soup.get_text(self.get_text_separator) if soup.title: ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/mhtml.html
c2d5ef2d9ec7-0
Source code for langchain.document_loaders.xml """Loader that loads Microsoft Excel files.""" from typing import Any, List from langchain.document_loaders.unstructured import ( UnstructuredFileLoader, validate_unstructured_version, ) [docs]class UnstructuredXMLLoader(UnstructuredFileLoader): """Loader that ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/xml.html
92717962b784-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/obsidian.html
92717962b784-1
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) metadata = { ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/obsidian.html
440541b06ee7-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/latest/_modules/langchain/document_loaders/mediawikidump.html
440541b06ee7-1
) metadata = {"source": page.title} docs.append(Document(page_content=text, metadata=metadata)) return docs
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/mediawikidump.html
dad6210c516d-0
Source code for langchain.document_loaders.recursive_url_loader from typing import Iterator, List, Optional, Set from urllib.parse import urlparse import requests from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class RecursiveUrlLoader(BaseLoader): """Lo...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/recursive_url_loader.html
dad6210c516d-1
): return visited # Get all links that are relative to the root of the website response = requests.get(url) soup = BeautifulSoup(response.text, "html.parser") all_links = [link.get("href") for link in soup.find_all("a")] # Extract only the links that are children of t...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/recursive_url_loader.html
625be12af986-0
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...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/json_loader.html
625be12af986-1
""" try: import jq # noqa:F401 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._co...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/json_loader.html
625be12af986-2
else: content = sample if self._text_content and not isinstance(content, str): raise ValueError( f"Expected page_content is string, got {type(content)} instead. \ Set `text_content=False` if the desired input for \ `page_content` is...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/json_loader.html
c547f90d1241-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/latest/_modules/langchain/document_loaders/trello.html
c547f90d1241-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/latest/_modules/langchain/document_loaders/trello.html
c547f90d1241-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/latest/_modules/langchain/document_loaders/trello.html
c547f90d1241-3
if self.include_card_name: text_content = card.name + "\n" if card.description.strip(): 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...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/trello.html
820c8299cc3e-0
Source code for langchain.document_loaders.acreom """Loader that loads acreom vault from a directory.""" import re from pathlib import Path from typing import Iterator, List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class AcreomLoader(BaseLoader): ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/acreom.html
820c8299cc3e-1
# do not contribute to the context of current document content = re.sub("\s*-\s\[\s\]\s.*|\s*\[\s\]\s.*", "", content) # rm tasks content = re.sub("#", "", content) # rm hashtags content = re.sub("\[\[.*?\]\]", "", content) # rm doclinks return content [docs] def lazy_load(self) ->...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/acreom.html
0af6b49d5fe4-0
Source code for langchain.document_loaders.image """Loader that loads image files.""" from typing import List from langchain.document_loaders.unstructured import UnstructuredFileLoader [docs]class UnstructuredImageLoader(UnstructuredFileLoader): """Loader that uses unstructured to load image files, such as PNGs and...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/image.html
a1de7427e821-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/latest/_modules/langchain/document_loaders/wikipedia.html
a1de7427e821-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/latest/_modules/langchain/document_loaders/wikipedia.html
1e093ab90d92-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/latest/_modules/langchain/document_loaders/imsdb.html
9d81001d45da-0
Source code for langchain.document_loaders.excel """Loader that loads Microsoft Excel files.""" from typing import Any, List from langchain.document_loaders.unstructured import ( UnstructuredFileLoader, validate_unstructured_version, ) [docs]class UnstructuredExcelLoader(UnstructuredFileLoader): """Loader t...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/excel.html
69146a6772ce-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/latest/_modules/langchain/document_loaders/unstructured.html
69146a6772ce-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/latest/_modules/langchain/document_loaders/unstructured.html
69146a6772ce-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/latest/_modules/langchain/document_loaders/unstructured.html
69146a6772ce-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/latest/_modules/langchain/document_loaders/unstructured.html
69146a6772ce-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/latest/_modules/langchain/document_loaders/unstructured.html
69146a6772ce-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/latest/_modules/langchain/document_loaders/unstructured.html
6bc8c31c0d34-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/word_document.html
6bc8c31c0d34-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/word_document.html
6bc8c31c0d34-2
f"You are on unstructured version {__unstructured_version__}. " "Partitioning .doc files is only supported in unstructured>=0.4.11. " "Please upgrade the unstructured package and try again." ) if is_doc: from unstructured.partition.doc import partition_doc...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/word_document.html
c0e9bf9fe826-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/latest/_modules/langchain/document_loaders/blockchain.html
c0e9bf9fe826-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/latest/_modules/langchain/document_loaders/blockchain.html
c0e9bf9fe826-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/latest/_modules/langchain/document_loaders/blockchain.html
c0e9bf9fe826-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/latest/_modules/langchain/document_loaders/blockchain.html
bf58acc39c58-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/latest/_modules/langchain/document_loaders/evernote.html
bf58acc39c58-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/latest/_modules/langchain/document_loaders/evernote.html
bf58acc39c58-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/latest/_modules/langchain/document_loaders/evernote.html
bf58acc39c58-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/latest/_modules/langchain/document_loaders/evernote.html
917f8d9273ad-0
Source code for langchain.document_loaders.srt """Loader for .srt (subtitle) files.""" from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class SRTLoader(BaseLoader): """Loader for .srt (subtitle) files.""" def __init__(self, fil...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/srt.html
30c7d8afd28c-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/gutenberg.html
beb2987a23b1-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/latest/_modules/langchain/document_loaders/sitemap.html
beb2987a23b1-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/latest/_modules/langchain/document_loaders/sitemap.html
beb2987a23b1-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/latest/_modules/langchain/document_loaders/sitemap.html
55434ff79ce7-0
Source code for langchain.document_loaders.confluence """Load Data from a Confluence Space""" import logging from enum import Enum from io import BytesIO from typing import Any, Callable, Dict, List, Optional, Union from tenacity import ( before_sleep_log, retry, stop_after_attempt, wait_exponential, ) ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
55434ff79ce7-1
Confluence API supports difference format of page content. The storage format is the raw XML representation for storage. The view format is the HTML representation for viewing with macros are rendered as though it is viewed by users. You can pass a enum `content_format` argument to `load()` to specify the c...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
55434ff79ce7-2
:type min_retry_seconds: Optional[int], optional :param max_retry_seconds: defaults to 10 :type max_retry_seconds: Optional[int], optional :param confluence_kwargs: additional kwargs to initialize confluence with :type confluence_kwargs: dict, optional :raises ValueError: Errors while validating in...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
55434ff79ce7-3
url=url, oauth2=oauth2, cloud=cloud, **confluence_kwargs ) elif token: self.confluence = Confluence( url=url, token=token, cloud=cloud, **confluence_kwargs ) else: self.confluence = Confluence( url=url, usern...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
55434ff79ce7-4
"keys to the oauth2 dictionary. key values should be " "`['access_token', 'access_token_secret', 'consumer_key', 'key_cert']`" ) if token and (api_key or username or oauth2): errors.append( "Cannot provide a value for `token` and a value for `api_key`, " ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
55434ff79ce7-5
: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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
55434ff79ce7-6
expand=content_format.value, ) docs += self.process_pages( pages, include_restricted_content, include_attachments, include_comments, content_format, ocr_languages, ) if label: ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
55434ff79ce7-7
)(self.confluence.get_page_by_id) page = get_page(page_id=page_id, expand=content_format.value) if not include_restricted_content and not self.is_public_page(page): continue doc = self.process_page( page, include...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
55434ff79ce7-8
are more docs based on the length of the returned list of pages, rather than just checking for the presence of a `next` key in the response like this page would have you do: https://developer.atlassian.com/server/confluence/pagination-in-the-rest-api/ :param retrieval_method: Function us...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
55434ff79ce7-9
pages: List[dict], include_restricted_content: bool, include_attachments: bool, include_comments: bool, content_format: ContentFormat, ocr_languages: Optional[str] = None, ) -> List[Document]: """Process a list of pages into a list of documents.""" docs = [] ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
55434ff79ce7-10
BeautifulSoup(comment["body"]["view"]["value"], "lxml").get_text( " ", strip=True ) for comment in comments ] text = text + "".join(comment_texts) return Document( page_content=text, metadata={ "t...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
55434ff79ce7-11
".wordprocessingml.document" ): text = title + self.process_doc(absolute_url) elif media_type == "application/vnd.ms-excel": text = title + self.process_xls(absolute_url) elif media_type == "image/svg+xml": text = title + self.process_s...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
55434ff79ce7-12
try: import pytesseract # noqa: F401 from PIL import Image # noqa: F401 except ImportError: raise ImportError( "`pytesseract` or `Pillow` package not found, " "please run `pip install pytesseract Pillow`" ) response = self...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
55434ff79ce7-13
text = "" if ( response.status_code != 200 or response.content == b"" or response.content is None ): return text workbook = xlrd.open_workbook(file_contents=response.content) for sheet in workbook.sheets(): text += f"{sheet.name...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
55434ff79ce7-14
img_data.seek(0) image = Image.open(img_data) return pytesseract.image_to_string(image, lang=ocr_languages)
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
54310919df4e-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/latest/_modules/langchain/document_loaders/text.html
54310919df4e-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/latest/_modules/langchain/document_loaders/text.html
bd990968fac8-0
Source code for langchain.document_loaders.azlyrics """Loader that loads AZLyrics.""" from typing import List from langchain.docstore.document import Document from langchain.document_loaders.web_base import WebBaseLoader [docs]class AZLyricsLoader(WebBaseLoader): """Loader that loads AZLyrics webpages.""" [docs] ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/azlyrics.html
adb4340c51cd-0
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...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/weather.html
cd5252feced9-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/email.html
cd5252feced9-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/email.html
86997a45354c-0
Source code for langchain.document_loaders.odt """Loader that loads Open Office ODT files.""" from typing import Any, List from langchain.document_loaders.unstructured import ( UnstructuredFileLoader, validate_unstructured_version, ) [docs]class UnstructuredODTLoader(UnstructuredFileLoader): """Loader that ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/odt.html
b3e8401aa746-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
b3e8401aa746-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
b3e8401aa746-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
b3e8401aa746-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: List of d...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
b3e8401aa746-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
b3e8401aa746-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
690e48bb411b-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/latest/_modules/langchain/document_loaders/telegram.html
690e48bb411b-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/latest/_modules/langchain/document_loaders/telegram.html
690e48bb411b-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/latest/_modules/langchain/document_loaders/telegram.html
690e48bb411b-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/latest/_modules/langchain/document_loaders/telegram.html
690e48bb411b-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/latest/_modules/langchain/document_loaders/telegram.html
690e48bb411b-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/latest/_modules/langchain/document_loaders/telegram.html
5c4d318f409e-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/latest/_modules/langchain/document_loaders/embaas.html
5c4d318f409e-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/latest/_modules/langchain/document_loaders/embaas.html