id
stringlengths
14
16
text
stringlengths
29
2.73k
source
stringlengths
49
117
7eed0c96734d-6
if not values.get("channel_name") and not values.get("video_ids"): raise ValueError("Must specify either channel_name or video_ids") return values def _get_transcripe_for_video_id(self, video_id: str) -> str: from youtube_transcript_api import NoTranscriptFound, YouTubeTranscriptApi ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
7eed0c96734d-7
return channel_id def _get_document_for_channel(self, channel: str, **kwargs: Any) -> List[Document]: try: from youtube_transcript_api import ( NoTranscriptFound, TranscriptsDisabled, ) except ImportError: raise ImportError( ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
7eed0c96734d-8
) else: raise e pass request = self.youtube_client.search().list_next(request, response) return video_ids [docs] def load(self) -> List[Document]: """Load documents.""" document_list = [] if self.channel_name:...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
e292a1253c88-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
e292a1253c88-1
if not os.path.isfile(self.file_path) and self._is_valid_url(self.file_path): r = requests.get(self.file_path) if r.status_code != 200: raise ValueError( "Check the url of your file; returned status code %s" % r.status_code ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/pdf.html
e292a1253c88-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]:...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/pdf.html
e292a1253c88-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
e292a1253c88-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
e292a1253c88-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`" ) ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/pdf.html
e292a1253c88-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:...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/pdf.html
e292a1253c88-7
self.wait_for_processing(pdf_id) url = f"{self.url}/{pdf_id}.{self.processed_file_format}" response = requests.get(url, headers=self.headers) return response.content.decode("utf-8") [docs] def clean_pdf(self, contents: str) -> str: contents = "\n".join( [line for line in c...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/pdf.html
e292a1253c88-8
"`pip install pdfplumber`" ) super().__init__(file_path) self.text_kwargs = text_kwargs or {} [docs] def load(self) -> List[Document]: """Load file.""" parser = PDFPlumberParser(text_kwargs=self.text_kwargs) blob = Blob.from_path(self.file_path) return pars...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/pdf.html
414bafef352b-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
414bafef352b-1
return list(self.lazy_load()) By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/weather.html
c11304cf6e5f-0
Source code for langchain.document_loaders.github from abc import ABC from datetime import datetime from typing import Dict, Iterator, List, Literal, Optional, Union import requests from pydantic import BaseModel, root_validator, validator from langchain.docstore.document import Document from langchain.document_loaders...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/github.html
c11304cf6e5f-1
state: Optional[Literal["open", "closed", "all"]] = None """Filter on issue state. Can be one of: 'open', 'closed', 'all'.""" assignee: Optional[str] = None """Filter on assigned user. Pass 'none' for no user and '*' for any user.""" creator: Optional[str] = None """Filter on the user that created t...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/github.html
c11304cf6e5f-2
[docs] def lazy_load(self) -> Iterator[Document]: """ Get issues of a GitHub repository. Returns: A list of Documents with attributes: - page_content - metadata - url - title - creator ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/github.html
c11304cf6e5f-3
"""Create Document objects from a list of GitHub issues.""" metadata = { "url": issue["html_url"], "title": issue["title"], "creator": issue["user"]["login"], "created_at": issue["created_at"], "comments": issue["comments"], "state": issue[...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/github.html
c11304cf6e5f-4
return query_params @property def url(self) -> str: return f"https://api.github.com/repos/{self.repo}/issues?{self.query_params}" By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/github.html
66b940e04256-0
Source code for langchain.document_loaders.slack_directory """Loader for documents from a Slack export.""" import json import zipfile from pathlib import Path from typing import Dict, List, Optional from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class Slack...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/slack_directory.html
66b940e04256-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/slack_directory.html
66b940e04256-2
"timestamp": timestamp, "user": user, } def _get_message_source(self, channel_name: str, user: str, timestamp: str) -> str: """ Get the message source as a string. Args: channel_name (str): The name of the channel the message belongs to. user (str)...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/slack_directory.html
330f447a99e1-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
330f447a99e1-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
330f447a99e1-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
330f447a99e1-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
330f447a99e1-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
330f447a99e1-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
330f447a99e1-6
By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
ff58e4ee2199-0
Source code for langchain.document_loaders.pyspark_dataframe """Load from a Spark Dataframe object""" import itertools import logging import sys from typing import TYPE_CHECKING, Any, Iterator, List, Optional, Tuple from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/pyspark_dataframe.html
ff58e4ee2199-1
"""Gets the amount of "feasible" rows for the DataFrame""" try: import psutil except ImportError as e: raise ImportError( "psutil not installed. Please install it with `pip install psutil`." ) from e row = self.df.limit(1).collect()[0] ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/pyspark_dataframe.html
078a59eb0ef8-0
Source code for langchain.document_loaders.email """Loader that loads email files.""" import os from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.document_loaders.unstructured import ( UnstructuredFileLoader, satisfies_...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/email.html
078a59eb0ef8-1
"`pip install extract_msg`" ) [docs] def load(self) -> List[Document]: """Load data into document objects.""" import extract_msg msg = extract_msg.Message(self.file_path) return [ Document( page_content=msg.body, metadata={ ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/email.html
62ddb839903c-0
Source code for langchain.document_loaders.reddit """Reddit document loader.""" from __future__ import annotations from typing import TYPE_CHECKING, Iterable, List, Optional, Sequence from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader if TYPE_CHECKING: import pra...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/reddit.html
62ddb839903c-1
if self.mode == "subreddit": for search_query in self.search_queries: for category in self.categories: docs = self._subreddit_posts_loader( search_query=search_query, category=category, reddit=reddit ) result...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/reddit.html
62ddb839903c-2
method = getattr(user.submissions, category) cat_posts = method(limit=self.number_posts) """Format reddit posts into a string.""" for post in cat_posts: metadata = { "post_subreddit": post.subreddit_name_prefixed, "post_category": category, ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/reddit.html
acc076ada135-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
acc076ada135-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
acc076ada135-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
acc076ada135-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
acc076ada135-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/telegram.html
acc076ada135-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
2451384e29ec-0
Source code for langchain.document_loaders.ifixit """Loader that loads iFixit data.""" from typing import List, Optional import requests from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.document_loaders.web_base import WebBaseLoader IFIXIT_BASE_URL =...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/ifixit.html
2451384e29ec-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/ifixit.html
2451384e29ec-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/ifixit.html
2451384e29ec-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/ifixit.html
2451384e29ec-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/ifixit.html
9644441dddad-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
9644441dddad-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
d8d42becfa56-0
Source code for langchain.document_loaders.college_confidential """Loader that loads College Confidential.""" from typing import List from langchain.docstore.document import Document from langchain.document_loaders.web_base import WebBaseLoader [docs]class CollegeConfidentialLoader(WebBaseLoader): """Loader that lo...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/college_confidential.html
2efab12f5a80-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 ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/chatgpt.html
2efab12f5a80-1
documents.append(Document(page_content=text, metadata=metadata)) return documents By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/chatgpt.html
b6cbc4b05ddf-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...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/arxiv.html
a354a4e259ce-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
a354a4e259ce-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
a354a4e259ce-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
d5ffff8fdbfa-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...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/directory.html
d5ffff8fdbfa-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...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/directory.html
d5ffff8fdbfa-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) ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/directory.html
95c9ca3dce48-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/text.html
95c9ca3dce48-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)] By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/text.html
c97e8b637e32-0
Source code for langchain.document_loaders.bigquery from __future__ import annotations from typing import TYPE_CHECKING, List, Optional from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader if TYPE_CHECKING: from google.auth.credentials import Credentials [docs]clas...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/bigquery.html
c97e8b637e32-1
self.project = project self.page_content_columns = page_content_columns self.metadata_columns = metadata_columns self.credentials = credentials [docs] def load(self) -> List[Document]: try: from google.cloud import bigquery except ImportError as ex: rai...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/bigquery.html
792885822571-0
Source code for langchain.document_loaders.url_playwright """Loader that uses Playwright to load a page, then uses unstructured to load the html. """ import logging from typing import List, Optional from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader logger = logging....
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/url_playwright.html
792885822571-1
[docs] def load(self) -> List[Document]: """Load the specified URLs using Playwright and create Document instances. Returns: List[Document]: A list of Document instances with loaded content. """ from playwright.sync_api import sync_playwright from unstructured.part...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/url_playwright.html
9179ef4b678f-0
Source code for langchain.document_loaders.python import tokenize from langchain.document_loaders.text import TextLoader [docs]class PythonLoader(TextLoader): """ Load Python files, respecting any non-default encoding if specified. """ def __init__(self, file_path: str): with open(file_path, "rb...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/python.html
aef3f5f0be2b-0
Source code for langchain.document_loaders.html_bs """Loader that uses bs4 to load HTML files, enriching metadata with page title.""" import logging from typing import Dict, List, Union from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader logger = logging.getLogger(__n...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/html_bs.html
aef3f5f0be2b-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 02, 2023.
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/html_bs.html
556b063c33f4-0
Source code for langchain.document_loaders.s3_directory """Loading logic for loading documents from an s3 directory.""" from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.document_loaders.s3_file import S3FileLoader [docs]class ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/s3_directory.html
15ef92c9a993-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
15ef92c9a993-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
15ef92c9a993-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
15ef92c9a993-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
15ef92c9a993-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
15ef92c9a993-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
15ef92c9a993-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
15ef92c9a993-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
b188e93eb15a-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
b188e93eb15a-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
b188e93eb15a-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
b188e93eb15a-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
b188e93eb15a-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
b188e93eb15a-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
b188e93eb15a-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
b188e93eb15a-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
920ef659fa46-0
Source code for langchain.document_loaders.max_compute from __future__ import annotations from typing import Any, Iterator, List, Optional, Sequence from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.utilities.max_compute import MaxComputeAPIWrapper [d...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/max_compute.html
920ef659fa46-1
given parameters. Args: query: SQL query to execute. endpoint: MaxCompute endpoint. project: A project is a basic organizational unit of MaxCompute, which is similar to a database. access_id: MaxCompute access ID. Should be passed in directly or se...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/max_compute.html
7e749ae513a5-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
1091fb82d239-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/srt.html
698d8c6b58a8-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
88425836ec5c-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
88425836ec5c-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
88425836ec5c-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
db546258580c-0
Source code for langchain.document_loaders.onedrive """Loader that loads data from OneDrive""" from __future__ import annotations import logging import os import tempfile from enum import Enum from pathlib import Path from typing import TYPE_CHECKING, Dict, List, Optional, Type, Union from pydantic import BaseModel, Ba...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/onedrive.html
db546258580c-1
mime_types_mapping[ file_type.value ] = "application/vnd.openxmlformats-officedocument.wordprocessingml.document" # noqa: E501 elif file_type.value == "pdf": mime_types_mapping[file_type.value] = "application/pdf" return mime_types_mapping [docs]c...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/onedrive.html
db546258580c-2
) account = Account( credentials=( self.settings.client_id, self.settings.client_secret.get_secret_value(), ), scopes=SCOPES, token_backend=token_backend, **{"raise_http_errors": False}, ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/onedrive.html
db546258580c-3
folder (Type[Folder]): The folder object to load the documents from. Returns: List[Document]: A list of Document objects representing the loaded documents. """ docs = [] file_types = _SupportedFileTypes(file_types=["doc", "docx", "pdf"]) file_mime_types = ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/onedrive.html
db546258580c-4
logging.warning( "There isn't a file with " f"object_id {object_id} in drive {drive}." ) continue if file.is_file: if file.mime_type in list(file_mime_types.values()): load...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/onedrive.html
eb6213d7d4dd-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
bc94e8ce763f-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/evernote.html