id
stringlengths
14
16
text
stringlengths
36
2.73k
source
stringlengths
59
127
d581c3edb575-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...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/telegram.html
d581c3edb575-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 = [] ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/telegram.html
d581c3edb575-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...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/telegram.html
d581c3edb575-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...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/telegram.html
d581c3edb575-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 ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/telegram.html
d581c3edb575-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...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/telegram.html
8f771d392861-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_...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/email.html
8f771d392861-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={ ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/email.html
3a62fcd7b5b2-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): ETH_MAINNET = "eth-mainnet...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/blockchain.html
3a62fcd7b5b2-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...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/blockchain.html
3a62fcd7b5b2-2
tokenId = item["id"]["tokenId"] metadata = { "source": self.contract_address, "blockchain": self.blockchainType, "tokenId": tokenId, } result.append(Document(page_content=content, metadata=metadata)) ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/blockchain.html
3a62fcd7b5b2-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...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/blockchain.html
3354fec44cd5-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....
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/url_playwright.html
3354fec44cd5-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...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/url_playwright.html
fa84cfabe124-0
Source code for langchain.document_loaders.airtable from typing import Iterator, List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class AirtableLoader(BaseLoader): """Loader that loads local airbyte json files.""" def __init__(self, api_token: st...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/airtable.html
f6b10951e906-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...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/googledrive.html
f6b10951e906-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") ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/googledrive.html
f6b10951e906-2
return type_mapping[x] if x in type_mapping else x values["file_types"] = [full_form(file_type) for file_type in file_types] return values @validator("credentials_path") def validate_credentials_path(cls, v: Any, **kwargs: Any) -> Any: """Validate that credentials_path exists.""" ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/googledrive.html
f6b10951e906-3
with open(self.token_path, "w") as token: token.write(creds.to_json()) return creds def _load_sheet_from_id(self, id: str) -> List[Document]: """Load a sheet and all tabs from an ID.""" from googleapiclient.discovery import build creds = self._load_credentials() ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/googledrive.html
f6b10951e906-4
"""Load a document from an ID.""" from io import BytesIO from googleapiclient.discovery import build from googleapiclient.errors import HttpError from googleapiclient.http import MediaIoBaseDownload creds = self._load_credentials() service = build("drive", "v3", credentia...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/googledrive.html
f6b10951e906-5
if file_types: _files = [f for f in files if f["mimeType"] in file_types] # type: ignore else: _files = files returns = [] for file in files: if file["trashed"] and not self.load_trashed_files: continue elif file["mimeType"] == "ap...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/googledrive.html
f6b10951e906-6
else: returns.append(file) 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 ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/googledrive.html
f6b10951e906-7
raise ValueError("file_ids must be set") 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...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/googledrive.html
97781e4af3c5-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...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/pdf.html
97781e4af3c5-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 ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/pdf.html
97781e4af3c5-2
try: import pypdf # noqa:F401 except ImportError: raise ImportError( "pypdf package not found, please install it with " "`pip install pypdf`" ) self.parser = PyPDFParser() super().__init__(file_path) [docs] def load(self) -> List[Document]:...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/pdf.html
97781e4af3c5-3
silent_errors: bool = False, load_hidden: bool = False, recursive: bool = False, ): self.path = path self.glob = glob self.load_hidden = load_hidden self.recursive = recursive self.silent_errors = silent_errors @staticmethod def _is_visible(path: Path)...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/pdf.html
97781e4af3c5-4
[docs] def load(self) -> List[Document]: """Eagerly load the content.""" return list(self.lazy_load()) [docs] def lazy_load( self, ) -> Iterator[Document]: """Lazily lod documents.""" blob = Blob.from_path(self.file_path) yield from self.parser.parse(blob) [docs...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/pdf.html
97781e4af3c5-5
def __init__(self, file_path: str) -> None: """Initialize with file path.""" try: import fitz # noqa:F401 except ImportError: raise ImportError( "`PyMuPDF` package not found, please install it with " "`pip install pymupdf`" ) ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/pdf.html
97781e4af3c5-6
@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 = {"conversion_formats": {self.processed_file_format:...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/pdf.html
97781e4af3c5-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...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/pdf.html
97781e4af3c5-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...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/pdf.html
bc78a7abd052-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 ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/odt.html
a0c0f62a9531-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...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/azure_blob_storage_container.html
1e67f0e1f8dc-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...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/gcs_directory.html
63d39ba651aa-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...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/trello.html
63d39ba651aa-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( ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/trello.html
63d39ba651aa-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 ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/trello.html
63d39ba651aa-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...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/trello.html
710884c5c8cf-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...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/max_compute.html
710884c5c8cf-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...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/max_compute.html
08eb4a8fca13-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...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/dataframe.html
563dfbcd2b5f-0
Source code for langchain.document_loaders.web_base """Web base loader class.""" import asyncio import logging import warnings from typing import Any, Dict, List, Optional, Union import aiohttp import requests from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader logger...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/web_base.html
563dfbcd2b5f-1
"""kwargs for requests""" def __init__( self, web_path: Union[str, List[str]], header_template: Optional[dict] = None ): """Initialize with webpage path.""" # TODO: Deprecate web_path in favor of web_paths, and remove this # left like this because there are a number of loaders th...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/web_base.html
563dfbcd2b5f-2
for i in range(retries): try: async with session.get( url, headers=self.session.headers ) as response: return await response.text() except aiohttp.ClientConnectionError as e: if i ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/web_base.html
563dfbcd2b5f-3
if parser not in valid_parsers: raise ValueError( "`parser` must be one of " + ", ".join(valid_parsers) + "." ) [docs] def scrape_all(self, urls: List[str], parser: Union[str, None] = None) -> List[Any]: """Fetch all urls, then return soups for all results.""" ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/web_base.html
563dfbcd2b5f-4
docs = [] for path in self.web_paths: soup = self._scrape(path) text = soup.get_text() metadata = _build_metadata(soup, path) docs.append(Document(page_content=text, metadata=metadata)) return docs [docs] def aload(self) -> List[Document]: """Lo...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/web_base.html
52bd190295c1-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...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/image.html
b192778a4da7-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 ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/docugami.html
b192778a4da7-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...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/docugami.html
b192778a4da7-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 == ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/docugami.html
b192778a4da7-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...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/docugami.html
b192778a4da7-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...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/docugami.html
b192778a4da7-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}...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/docugami.html
b192778a4da7-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( ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/docugami.html
b192778a4da7-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...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/docugami.html
04abc6aa5dd5-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...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/weather.html
04abc6aa5dd5-1
return list(self.lazy_load()) By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 16, 2023.
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/weather.html
8658a13719a7-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...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/bibtex.html
8658a13719a7-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:...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/bibtex.html
8658a13719a7-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...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/bibtex.html
ee8f5972308d-0
Source code for langchain.document_loaders.chatgpt """Load conversations from ChatGPT data export""" import datetime import json from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader def concatenate_rows(message: dict, title: str) -> str: if ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/chatgpt.html
ee8f5972308d-1
documents.append(Document(page_content=text, metadata=metadata)) return documents By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 16, 2023.
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/chatgpt.html
05de09cfcd15-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...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/figma.html
f12cd240fa70-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...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/url_selenium.html
f12cd240fa70-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...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/url_selenium.html
f12cd240fa70-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...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/url_selenium.html
f4185e5de49b-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...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/html_bs.html
f4185e5de49b-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 Jun 16, 2023.
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/html_bs.html
183b8efc0563-0
Source code for langchain.document_loaders.bilibili import json import re import warnings from typing import List, Tuple import requests from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class BiliBiliLoader(BaseLoader): """Loader that loads bilibili trans...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/bilibili.html
183b8efc0563-1
video_info = sync(v.get_info()) video_info.update({"url": url}) # Get subtitle url subtitle = video_info.pop("subtitle") sub_list = subtitle["list"] if sub_list: sub_url = sub_list[0]["subtitle_url"] result = requests.get(sub_url) raw_sub_title...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/bilibili.html
3afbe1deec7b-0
Source code for langchain.document_loaders.git import os from typing import Callable, List, Optional from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class GitLoader(BaseLoader): """Loads files from a Git repository into a list of documents. Repositor...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/git.html
3afbe1deec7b-1
else: repo = Repo(self.repo_path) repo.git.checkout(self.branch) docs: List[Document] = [] for item in repo.tree().traverse(): if not isinstance(item, Blob): continue file_path = os.path.join(self.repo_path, item.path) ignored_f...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/git.html
6e2090860bf2-0
Source code for langchain.document_loaders.directory """Loading logic for loading documents from a directory.""" import concurrent import logging from pathlib import Path from typing import Any, List, Optional, Type, Union from langchain.docstore.document import Document from langchain.document_loaders.base import Base...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/directory.html
6e2090860bf2-1
self.loader_kwargs = loader_kwargs self.silent_errors = silent_errors self.recursive = recursive self.show_progress = show_progress self.use_multithreading = use_multithreading self.max_concurrency = max_concurrency [docs] def load_file( self, item: Path, path: Path, d...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/directory.html
6e2090860bf2-2
logger.warning(e) else: raise e if self.use_multithreading: with concurrent.futures.ThreadPoolExecutor( max_workers=self.max_concurrency ) as executor: executor.map(lambda i: self.load_file(i, p, docs, pbar), items) ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/directory.html
17cdee2265cf-0
Source code for langchain.document_loaders.arxiv from typing import List, Optional from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.utilities.arxiv import ArxivAPIWrapper [docs]class ArxivLoader(BaseLoader): """Loads a query result from arxiv.org...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/arxiv.html
ee91b571049e-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...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/notiondb.html
ee91b571049e-1
Returns: List[Document]: List of documents. """ page_ids = self._retrieve_page_ids() return list(self.load_page(page_id) for page_id in page_ids) def _retrieve_page_ids( self, query_dict: Dict[str, Any] = {"page_size": 100} ) -> List[str]: """Get all the pages...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/notiondb.html
ee91b571049e-2
[item["name"] for item in prop_data["multi_select"]] if prop_data["multi_select"] else [] ) elif prop_type == "url": value = prop_data["url"] else: value = None metadata[prop_name.lower()] = value...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/notiondb.html
ee91b571049e-3
) -> Any: res = requests.request( method, url, headers=self.headers, json=query_dict, timeout=self.request_timeout_sec, ) res.raise_for_status() return res.json() By Harrison Chase © Copyright 2023, Harrison Chase. ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/notiondb.html
0c72577a0214-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...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/wikipedia.html
e07d49cbeca3-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...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/imsdb.html
38a99617d4ec-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.""" ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/gutenberg.html
8a0d2b241cd9-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...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/word_document.html
8a0d2b241cd9-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...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/word_document.html
8a0d2b241cd9-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...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/document_loaders/word_document.html
945837cd4144-0
Source code for langchain.memory.summary_buffer from typing import Any, Dict, List from pydantic import root_validator from langchain.memory.chat_memory import BaseChatMemory from langchain.memory.summary import SummarizerMixin from langchain.schema import BaseMessage, get_buffer_string [docs]class ConversationSummaryB...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/memory/summary_buffer.html
945837cd4144-1
if expected_keys != set(prompt_variables): raise ValueError( "Got unexpected prompt input variables. The prompt expects " f"{prompt_variables}, but it should have {expected_keys}." ) return values [docs] def save_context(self, inputs: Dict[str, Any], ou...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/memory/summary_buffer.html
b86c4976d853-0
Source code for langchain.memory.kg from typing import Any, Dict, List, Type, Union from pydantic import Field from langchain.base_language import BaseLanguageModel from langchain.chains.llm import LLMChain from langchain.graphs import NetworkxEntityGraph from langchain.graphs.networkx_graph import KnowledgeTriple, get...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/memory/kg.html
b86c4976d853-1
entities = self._get_current_entities(inputs) summary_strings = [] for entity in entities: knowledge = self.kg.get_entity_knowledge(entity) if knowledge: summary = f"On {entity}: {'. '.join(knowledge)}." summary_strings.append(summary) cont...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/memory/kg.html
b86c4976d853-2
human_prefix=self.human_prefix, ai_prefix=self.ai_prefix, ) output = chain.predict( history=buffer_string, input=input_string, ) return get_entities(output) def _get_current_entities(self, inputs: Dict[str, Any]) -> List[str]: """Get the cu...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/memory/kg.html
b86c4976d853-3
[docs] def clear(self) -> None: """Clear memory contents.""" super().clear() self.kg.clear() By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 16, 2023.
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/memory/kg.html
2890634ff7fb-0
Source code for langchain.memory.token_buffer from typing import Any, Dict, List from langchain.base_language import BaseLanguageModel from langchain.memory.chat_memory import BaseChatMemory from langchain.schema import BaseMessage, get_buffer_string [docs]class ConversationTokenBufferMemory(BaseChatMemory): """Buf...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/memory/token_buffer.html
2890634ff7fb-1
if curr_buffer_length > self.max_token_limit: pruned_memory = [] while curr_buffer_length > self.max_token_limit: pruned_memory.append(buffer.pop(0)) curr_buffer_length = self.llm.get_num_tokens_from_messages(buffer) By Harrison Chase © Copyright 2023, ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/memory/token_buffer.html
f754198f078c-0
Source code for langchain.memory.entity import logging from abc import ABC, abstractmethod from itertools import islice from typing import Any, Dict, Iterable, List, Optional from pydantic import BaseModel, Field from langchain.base_language import BaseLanguageModel from langchain.chains.llm import LLMChain from langch...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/memory/entity.html
f754198f078c-1
return self.store.get(key, default) [docs] def set(self, key: str, value: Optional[str]) -> None: self.store[key] = value [docs] def delete(self, key: str) -> None: del self.store[key] [docs] def exists(self, key: str) -> bool: return key in self.store [docs] def clear(self) -> None:...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/memory/entity.html
f754198f078c-2
self.redis_client = redis.Redis.from_url(url=url, decode_responses=True) except redis.exceptions.ConnectionError as error: logger.error(error) self.session_id = session_id self.key_prefix = key_prefix self.ttl = ttl self.recall_ttl = recall_ttl or ttl @property ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/memory/entity.html
f754198f078c-3
iterator = iter(iterable) while batch := list(islice(iterator, batch_size)): yield batch for keybatch in batched( self.redis_client.scan_iter(f"{self.full_key_prefix}:*"), 500 ): self.redis_client.delete(*keybatch) [docs]class SQLiteEntityStore(BaseEnt...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/memory/entity.html
f754198f078c-4
query = f""" SELECT value FROM {self.full_table_name} WHERE key = ? """ cursor = self.conn.execute(query, (key,)) result = cursor.fetchone() if result is not None: value = result[0] return value return default [docs] ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/memory/entity.html