id
stringlengths
14
16
text
stringlengths
36
2.73k
source
stringlengths
49
117
f173e22b9d71-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/weather.html
f173e22b9d71-1
return list(self.lazy_load()) By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/weather.html
32a5a7b90ff5-0
Source code for langchain.document_loaders.url """Loader that uses unstructured to load HTML files.""" import logging from typing import Any, List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader logger = logging.getLogger(__name__) [docs]class UnstructuredURLLoade...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/url.html
32a5a7b90ff5-1
def _validate_mode(self, mode: str) -> None: _valid_modes = {"single", "elements"} if mode not in _valid_modes: raise ValueError( f"Got {mode} for `mode`, but should be one of `{_valid_modes}`" ) def __is_headers_available_for_html(self) -> bool: _unst...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/url.html
32a5a7b90ff5-2
elements = partition(url=url, **self.unstructured_kwargs) else: if self.__is_headers_available_for_html(): elements = partition_html( url=url, headers=self.headers, **self.unstructured_kwargs ) ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/url.html
a492a9cbd5da-0
Source code for langchain.document_loaders.imsdb """Loader that loads IMSDb.""" from typing import List from langchain.docstore.document import Document from langchain.document_loaders.web_base import WebBaseLoader [docs]class IMSDbLoader(WebBaseLoader): """Loader that loads IMSDb webpages.""" [docs] def load(se...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/imsdb.html
9b5254dcd7de-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, List, Sequence, Union from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader def ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/unstructured.html
9b5254dcd7de-1
import unstructured # noqa:F401 except ImportError: raise ValueError( "unstructured package not found, please install it with " "`pip install unstructured`" ) _valid_modes = {"single", "elements"} if mode not in _valid_modes: r...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/unstructured.html
9b5254dcd7de-2
docs = [Document(page_content=text, metadata=metadata)] else: raise ValueError(f"mode of {self.mode} not supported.") return docs [docs]class UnstructuredFileLoader(UnstructuredBaseLoader): """Loader that uses unstructured to load files.""" def __init__( self, file_pa...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/unstructured.html
9b5254dcd7de-3
elements.extend(_elements) return elements else: from unstructured.partition.api import partition_via_api return partition_via_api( filename=file_path, file=file, api_key=api_key, api_url=api_url, **unstructured_kwargs, ) [d...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/unstructured.html
9b5254dcd7de-4
file: Union[IO, Sequence[IO]], mode: str = "single", **unstructured_kwargs: Any, ): """Initialize with file path.""" self.file = file super().__init__(mode=mode, **unstructured_kwargs) def _get_elements(self) -> List: from unstructured.partition.auto import partit...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/unstructured.html
8c03a645e58c-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/pdf.html
8c03a645e58c-1
# If the file is a web path, download it to a temporary file, and use that 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 ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/pdf.html
8c03a645e58c-2
"""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.parser = PyPDFParser() super().__init__(file_path) [d...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/pdf.html
8c03a645e58c-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)...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/pdf.html
8c03a645e58c-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...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/pdf.html
8c03a645e58c-5
"""Initialize with file path.""" try: import fitz # noqa:F401 except ImportError: raise ImportError( "`PyMuPDF` package not found, please install it with " "`pip install pymupdf`" ) super().__init__(file_path) [docs] def loa...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/pdf.html
8c03a645e58c-6
@property def url(self) -> str: return "https://api.mathpix.com/v3/pdf" @property def data(self) -> dict: options = {"conversion_formats": {self.processed_file_format: True}} return {"options_json": json.dumps(options)} [docs] def send_pdf(self) -> str: with open(self.file...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/pdf.html
8c03a645e58c-7
return response.content.decode("utf-8") [docs] def clean_pdf(self, contents: str) -> str: contents = "\n".join( [line for line in contents.split("\n") if not line.startswith("![]")] ) # replace \section{Title} with # Title contents = contents.replace("\\section{", "# ").re...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/pdf.html
8c03a645e58c-8
[docs] def load(self) -> List[Document]: """Load file.""" parser = PDFPlumberParser(text_kwargs=self.text_kwargs) blob = Blob.from_path(self.file_path) return parser.parse(blob) By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/pdf.html
4ed32202637b-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/telegram.html
4ed32202637b-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/telegram.html
4ed32202637b-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/telegram.html
4ed32202637b-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/telegram.html
4ed32202637b-4
Args: 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 ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/telegram.html
4ed32202637b-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/telegram.html
bb417ffb0d43-0
Source code for langchain.document_loaders.obsidian """Loader that loads Obsidian directory dump.""" import re from pathlib import Path from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class ObsidianLoader(BaseLoader): """Loader th...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/obsidian.html
bb417ffb0d43-1
"""Load documents.""" ps = list(Path(self.file_path).glob("**/*.md")) docs = [] for p in ps: with open(p, encoding=self.encoding) as f: text = f.read() front_matter = self._parse_front_matter(text) text = self._remove_front_matter(text) ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/obsidian.html
54a1d9d617fe-0
Source code for langchain.document_loaders.youtube """Loader that loads YouTube transcript.""" from __future__ import annotations import logging from pathlib import Path from typing import Any, Dict, List, Optional from urllib.parse import parse_qs, urlparse from pydantic import root_validator from pydantic.dataclasses...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
54a1d9d617fe-1
"""Validate that either folder_id or document_ids is set, but not both.""" if not values.get("credentials_path") and not values.get( "service_account_path" ): raise ValueError("Must specify either channel_name or video_ids") return values def _load_credentials(self) -...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
54a1d9d617fe-2
token.write(creds.to_json()) return creds ALLOWED_SCHEMAS = {"http", "https"} ALLOWED_NETLOCK = { "youtu.be", "m.youtube.com", "youtube.com", "www.youtube.com", "www.youtube-nocookie.com", "vid.plus", } def _parse_video_id(url: str) -> Optional[str]: """Parse a youtube url and return...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
54a1d9d617fe-3
self.continue_on_failure = continue_on_failure [docs] @staticmethod def extract_video_id(youtube_url: str) -> str: """Extract video id from common YT urls.""" video_id = _parse_video_id(youtube_url) if not video_id: raise ValueError( f"Could not determine the v...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
54a1d9d617fe-4
transcript = en_transcript.translate(self.language) transcript_pieces = transcript.fetch() transcript = " ".join([t["text"].strip(" ") for t in transcript_pieces]) return [Document(page_content=transcript, metadata=metadata)] def _get_video_info(self) -> dict: """Get important video ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
54a1d9d617fe-5
from langchain.document_loaders import GoogleApiYoutubeLoader google_api_client = GoogleApiClient( service_account_path=Path("path_to_your_sec_file.json") ) loader = GoogleApiYoutubeLoader( google_api_client=google_api_client, channel_n...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
54a1d9d617fe-6
raise ValueError("Must specify either channel_name or video_ids") return values def _get_transcripe_for_video_id(self, video_id: str) -> str: from youtube_transcript_api import NoTranscriptFound, YouTubeTranscriptApi transcript_list = YouTubeTranscriptApi.list_transcripts(video_id) t...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
54a1d9d617fe-7
try: from youtube_transcript_api import ( NoTranscriptFound, TranscriptsDisabled, ) except ImportError: raise ImportError( "You must run" "`pip install --upgrade " "youtube-transcript-api` " ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
54a1d9d617fe-8
return video_ids [docs] def load(self) -> List[Document]: """Load documents.""" document_list = [] if self.channel_name: document_list.extend(self._get_document_for_channel(self.channel_name)) elif self.video_ids: document_list.extend( [ ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
8bae184a36b4-0
Source code for langchain.document_loaders.notebook """Loader that loads .ipynb notebook files.""" import json from pathlib import Path from typing import Any, List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader def concatenate_cells( cell: dict, include_outp...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/notebook.html
8bae184a36b4-1
return f"'{cell_type}' cell: '{source}'\n\n" return "" def remove_newlines(x: Any) -> Any: """Remove recursively newlines, no matter the data structure they are stored in.""" import pandas as pd if isinstance(x, str): return x.replace("\n", "") elif isinstance(x, list): return [remov...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/notebook.html
8bae184a36b4-2
if self.remove_newline: filtered_data = filtered_data.applymap(remove_newlines) text = filtered_data.apply( lambda x: concatenate_cells( x, self.include_outputs, self.max_output_length, self.traceback ), axis=1, ).str.cat(sep=" ") m...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/notebook.html
d43afad5744e-0
Source code for langchain.document_loaders.toml import json from pathlib import Path from typing import Iterator, List, Union from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class TomlLoader(BaseLoader): """ A TOML document loader that inherits from ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/toml.html
d43afad5744e-1
By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/toml.html
dac75b22da35-0
Source code for langchain.document_loaders.blackboard """Loader that loads all documents from a blackboard course.""" import contextlib import re from pathlib import Path from typing import Any, List, Optional, Tuple from urllib.parse import unquote from langchain.docstore.document import Document from langchain.docume...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
dac75b22da35-1
): """Initialize with blackboard course url. The BbRouter cookie is required for most blackboard courses. Args: blackboard_course_url: Blackboard course url. bbrouter: BbRouter cookie. load_all_recursively: If True, load all documents recursively. ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
dac75b22da35-2
"""Load data into document objects. Returns: List of documents. """ if self.load_all_recursively: soup_info = self.scrape() self.folder_path = self._get_folder_path(soup_info) relative_paths = self._get_paths(soup_info) documents = [] ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
dac75b22da35-3
) # Get the folder path folder_path = Path(".") / course_name_clean return str(folder_path) def _get_documents(self, soup: Any) -> List[Document]: """Fetch content from page and return Documents. Args: soup: BeautifulSoup4 soup object. Returns: ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
dac75b22da35-4
Path(self.folder_path).mkdir(parents=True, exist_ok=True) # Download all attachments for attachment in attachments: self.download(attachment) def _load_documents(self) -> List[Document]: """Load all documents in the folder. Returns: List of documents. ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
dac75b22da35-5
"""Parse the filename from a url. Args: url: Url to parse the filename from. Returns: The filename. """ if (url_path := Path(url)) and url_path.suffix == ".pdf": return url_path.name else: return self._parse_filename_from_url(url) ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
dac75b22da35-6
By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
710652d52fef-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html
710652d52fef-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html
710652d52fef-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html
710652d52fef-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html
710652d52fef-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html
710652d52fef-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html
710652d52fef-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html
710652d52fef-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html
fed1c8b2cdc4-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/notiondb.html
fed1c8b2cdc4-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...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/notiondb.html
fed1c8b2cdc4-2
value = ( [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 metad...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/notiondb.html
fed1c8b2cdc4-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. ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/notiondb.html
5c5bbcdbf5bc-0
Source code for langchain.document_loaders.psychic """Loader that loads documents from Psychic.dev.""" from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class PsychicLoader(BaseLoader): """Loader that loads documents from Psychic.de...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/psychic.html
13ece31996fa-0
Source code for langchain.document_loaders.hugging_face_dataset """Loader that loads HuggingFace datasets.""" from typing import Iterator, List, Mapping, Optional, Sequence, Union from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class HuggingFaceDatasetLoader...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/hugging_face_dataset.html
13ece31996fa-1
self.page_content_column = page_content_column self.name = name self.data_dir = data_dir self.data_files = data_files self.cache_dir = cache_dir self.keep_in_memory = keep_in_memory self.save_infos = save_infos self.use_auth_token = use_auth_token self.num...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/hugging_face_dataset.html
6a84847abad4-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/tomarkdown.html
966d41b5afcd-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/joplin.html
966d41b5afcd-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/joplin.html
966d41b5afcd-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()) By Harrison Chase ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/joplin.html
eaab2942c85d-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/bibtex.html
eaab2942c85d-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/bibtex.html
eaab2942c85d-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/bibtex.html
f0026e0012bc-0
Source code for langchain.document_loaders.image_captions """ Loader that loads image captions By default, the loader utilizes the pre-trained BLIP image captioning model. https://huggingface.co/Salesforce/blip-image-captioning-base """ from typing import Any, List, Tuple, Union import requests from langchain.docstore....
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/image_captions.html
f0026e0012bc-1
model=model, processor=processor, path_image=path_image ) doc = Document(page_content=caption, metadata=metadata) results.append(doc) return results def _get_captions_and_metadata( self, model: Any, processor: Any, path_image: str ) -> Tuple[str, dict]: ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/image_captions.html
1575dcbc1979-0
Source code for langchain.document_loaders.csv_loader import csv from typing import Dict, List, Optional from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class CSVLoader(BaseLoader): """Loads a CSV file into a list of documents. Each document represen...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/csv_loader.html
1575dcbc1979-1
for i, row in enumerate(csv_reader): content = "\n".join(f"{k.strip()}: {v.strip()}" for k, v in row.items()) try: source = ( row[self.source_column] if self.source_column is not None else self.fi...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/csv_loader.html
62c9947a67a9-0
Source code for langchain.document_loaders.s3_file """Loading logic for loading documents from an s3 file.""" import os import tempfile from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.document_loaders.unstructured import Unst...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/s3_file.html
64715f0371e7-0
Source code for langchain.document_loaders.googledrive """Loader that loads data from Google Drive.""" # Prerequisites: # 1. Create a Google Cloud project # 2. Enable the Google Drive API: # https://console.cloud.google.com/flows/enableapi?apiid=drive.googleapis.com # 3. Authorize credentials for desktop app: # htt...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/googledrive.html
64715f0371e7-1
if values.get("folder_id") and ( values.get("document_ids") or values.get("file_ids") ): raise ValueError( "Cannot specify both folder_id and document_ids nor " "folder_id and file_ids" ) if ( not values.get("folder_id") ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/googledrive.html
64715f0371e7-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.""" ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/googledrive.html
64715f0371e7-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() ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/googledrive.html
64715f0371e7-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...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/googledrive.html
64715f0371e7-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...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/googledrive.html
64715f0371e7-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 ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/googledrive.html
64715f0371e7-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...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/googledrive.html
f38cd52d2fba-0
Source code for langchain.document_loaders.markdown """Loader that loads Markdown files.""" from typing import List from langchain.document_loaders.unstructured import UnstructuredFileLoader [docs]class UnstructuredMarkdownLoader(UnstructuredFileLoader): """Loader that uses unstructured to load markdown files.""" ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/markdown.html
d71f0193fb3d-0
Source code for langchain.document_loaders.apify_dataset """Logic for loading documents from Apify datasets.""" from typing import Any, Callable, Dict, List from pydantic import BaseModel, root_validator from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/apify_dataset.html
d71f0193fb3d-1
) return values [docs] def load(self) -> List[Document]: """Load documents.""" dataset_items = self.apify_client.dataset(self.dataset_id).list_items().items return list(map(self.dataset_mapping_function, dataset_items)) By Harrison Chase © Copyright 2023, Harrison Chase. ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/apify_dataset.html
4dd025cf2608-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/mediawikidump.html
4dd025cf2608-1
) metadata = {"source": page.title} docs.append(Document(page_content=text, metadata=metadata)) return docs By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/mediawikidump.html
3f4afed598b6-0
Source code for langchain.document_loaders.facebook_chat """Loader that loads Facebook chat json dump.""" import datetime import json from pathlib import Path from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader def concatenate_rows(row: dict) -...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/facebook_chat.html
1c3cb10466cd-0
Source code for langchain.document_loaders.gitbook """Loader that loads GitBook.""" from typing import Any, List, Optional from urllib.parse import urljoin, urlparse from langchain.docstore.document import Document from langchain.document_loaders.web_base import WebBaseLoader [docs]class GitbookLoader(WebBaseLoader): ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/gitbook.html
1c3cb10466cd-1
[docs] def load(self) -> List[Document]: """Fetch text from one single GitBook page.""" if self.load_all_paths: soup_info = self.scrape() relative_paths = self._get_paths(soup_info) documents = [] for path in relative_paths: url = urljoi...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/gitbook.html
dd07500e49fc-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...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blockchain.html
dd07500e49fc-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/blockchain.html
dd07500e49fc-2
tokenId = item["id"]["tokenId"] metadata = { "source": self.contract_address, "blockchain": self.blockchainType, "tokenId": tokenId, } result.append(Document(page_content=content, metadata=metadata)) ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blockchain.html
dd07500e49fc-3
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): return "int" elif tokenId.startswith("0x"): return "hex_0x" elif tokenId.s...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blockchain.html
11580efbb79c-0
Source code for langchain.document_loaders.spreedly """Loader that fetches data from Spreedly API.""" import json import urllib.request from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.utils import stringify_dict SPREEDLY_ENDP...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/spreedly.html
11580efbb79c-1
text = stringify_dict(json_data) metadata = {"source": url} return [Document(page_content=text, metadata=metadata)] def _get_resource(self) -> List[Document]: endpoint = SPREEDLY_ENDPOINTS.get(self.resource) if endpoint is None: return [] return self._make...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/spreedly.html
a913c59732a6-0
Source code for langchain.document_loaders.discord """Load from Discord chat dump""" from __future__ import annotations from typing import TYPE_CHECKING, List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader if TYPE_CHECKING: import pandas as pd [docs]class Dis...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/discord.html
f82655826747-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/rtf.html