id
stringlengths
14
16
text
stringlengths
36
2.73k
source
stringlengths
49
117
cfa0069873a2-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
cfa0069873a2-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
cfa0069873a2-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
beb54a9dda33-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
beb54a9dda33-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
beb54a9dda33-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
beb54a9dda33-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
beb54a9dda33-4
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 partition return partition(file=self....
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/unstructured.html
d8814b16415b-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
3a0b01827c54-0
Source code for langchain.document_loaders.gcs_directory """Loading logic for loading documents from an GCS directory.""" from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.document_loaders.gcs_file import GCSFileLoader [docs]cl...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/gcs_directory.html
5bb4bff50760-0
Source code for langchain.document_loaders.conllu """Load CoNLL-U files.""" import csv from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class CoNLLULoader(BaseLoader): """Load CoNLL-U files.""" def __init__(self, file_path: str...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/conllu.html
a0856dfb4c47-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
a0856dfb4c47-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
a0856dfb4c47-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
a0856dfb4c47-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
a0856dfb4c47-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
a0856dfb4c47-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
a0856dfb4c47-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
a0856dfb4c47-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
fcd39ef8d7da-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...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/airtable.html
cfbc5444e971-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
cfbc5444e971-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
6bb22e22e79d-0
Source code for langchain.document_loaders.azure_blob_storage_file """Loading logic for loading documents from an Azure Blob Storage 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_...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/azure_blob_storage_file.html
e97d715c5e64-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
422e8a4a127a-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
422e8a4a127a-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
422e8a4a127a-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
b2a790cad902-0
Source code for langchain.document_loaders.gcs_file """Loading logic for loading documents from a GCS 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 Uns...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/gcs_file.html
7ac23cbec1c8-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
7ac23cbec1c8-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
7f46c4fac07c-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
7f46c4fac07c-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 Jun 11, 2023.
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/mediawikidump.html
322d4766d188-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
322d4766d188-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
322d4766d188-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
ca2d904d5a97-0
Source code for langchain.document_loaders.notion """Loader that loads Notion directory dump.""" from pathlib import Path from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class NotionDirectoryLoader(BaseLoader): """Loader that load...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/notion.html
34ebe26b80f4-0
Source code for langchain.document_loaders.confluence """Load Data from a Confluence Space""" import logging from io import BytesIO from typing import Any, Callable, List, Optional, Union from tenacity import ( before_sleep_log, retry, stop_after_attempt, wait_exponential, ) from langchain.docstore.docu...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
34ebe26b80f4-1
) documents = loader.load(space_key="SPACE",limit=50) :param url: _description_ :type url: str :param api_key: _description_, defaults to None :type api_key: str, optional :param username: _description_, defaults to None :type username: str, optional :param oauth2: _description_,...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
34ebe26b80f4-2
confluence_kwargs: Optional[dict] = None, ): confluence_kwargs = confluence_kwargs or {} errors = ConfluenceLoader.validate_init_args( url, api_key, username, oauth2, token ) if errors: raise ValueError(f"Error(s) while validating input: {errors}") sel...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
34ebe26b80f4-3
if url is None: errors.append("Must provide `base_url`") if (api_key and not username) or (username and not api_key): errors.append( "If one of `api_key` or `username` is provided, " "the other must be as well." ) if (api_key or usernam...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
34ebe26b80f4-4
include_comments: bool = False, limit: Optional[int] = 50, max_pages: Optional[int] = 1000, ocr_languages: Optional[str] = None, ) -> List[Document]: """ :param space_key: Space key retrieved from a confluence URL, defaults to None :type space_key: Optional[str], opti...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
34ebe26b80f4-5
:raises ImportError: _description_ :return: _description_ :rtype: List[Document] """ if not space_key and not page_ids and not label and not cql: raise ValueError( "Must specify at least one among `space_key`, `page_ids`, " "`label`, `cql` para...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
34ebe26b80f4-6
include_attachments, include_comments, ocr_languages, ) if page_ids: for page_id in page_ids: get_page = retry( reraise=True, stop=stop_after_attempt( self.number_of_retries #...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
34ebe26b80f4-7
of pages with each request. We have to manually check if there are more docs based on the length of the returned list of pages, rather than just checking for the presence of a `next` key in the response like this page would have you do: https://developer.atlassian.com/server/confluence/p...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
34ebe26b80f4-8
) [docs] def process_pages( self, pages: List[dict], include_restricted_content: bool, include_attachments: bool, include_comments: bool, ocr_languages: Optional[str] = None, ) -> List[Document]: """Process a list of pages into a list of documents.""" ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
34ebe26b80f4-9
" ", strip=True ) for comment in comments ] text = text + "".join(comment_texts) return Document( page_content=text, metadata={ "title": page["title"], "id": page["id"], "source": self...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
34ebe26b80f4-10
elif media_type == "application/vnd.ms-excel": text = title + self.process_xls(absolute_url) elif media_type == "image/svg+xml": text = title + self.process_svg(absolute_url, ocr_languages) else: continue texts.append(text) retu...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
34ebe26b80f4-11
except ImportError: raise ImportError( "`pytesseract` or `Pillow` package not found, " "please run `pip install pytesseract Pillow`" ) response = self.confluence.request(path=link, absolute=True) text = "" if ( response.status_c...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
34ebe26b80f4-12
or response.content is None ): return text workbook = xlrd.open_workbook(file_contents=response.content) for sheet in workbook.sheets(): text += f"{sheet.name}:\n" for row in range(sheet.nrows): for col in range(sheet.ncols): ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
34ebe26b80f4-13
By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 11, 2023.
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
c3175a3c5f33-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
c3175a3c5f33-1
documents.append(Document(page_content=text, metadata=metadata)) return documents By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 11, 2023.
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/chatgpt.html
baae0d890213-0
Source code for langchain.document_loaders.url_selenium """Loader that uses Selenium to load a page, then uses unstructured to load the html. """ import logging from typing import TYPE_CHECKING, List, Literal, Optional, Union if TYPE_CHECKING: from selenium.webdriver import Chrome, Firefox from langchain.docstore.d...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/url_selenium.html
baae0d890213-1
raise ImportError( "selenium package not found, please install it with " "`pip install selenium`" ) try: import unstructured # noqa:F401 except ImportError: raise ImportError( "unstructured package not found, please ins...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/url_selenium.html
baae0d890213-2
for arg in self.arguments: firefox_options.add_argument(arg) if self.headless: firefox_options.add_argument("--headless") if self.binary_location is not None: firefox_options.binary_location = self.binary_location if self.executable_pat...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/url_selenium.html
fb61da65be09-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
fb61da65be09-1
self.file_path = file_path self.load_single_document = load_single_document [docs] def load(self) -> List[Document]: """Load documents from EverNote export file.""" documents = [ Document( page_content=note["content"], metadata={ ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/evernote.html
fb61da65be09-2
rsc_dict["hash"] = hashlib.md5(rsc_dict[elem.tag]).hexdigest() else: rsc_dict[elem.tag] = elem.text return rsc_dict @staticmethod def _parse_note(note: List, prefix: Optional[str] = None) -> dict: note_dict: Dict[str, Any] = {} resources = [] def add_p...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/evernote.html
fb61da65be09-3
# Without huge_tree set to True, parser may complain about huge text node # Try to recover, because there may be " ", which will cause # "XMLSyntaxError: Entity 'nbsp' not defined" try: from lxml import etree except ImportError as e: logging.error( ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/evernote.html
d294aef3ff24-0
Source code for langchain.document_loaders.twitter """Twitter document loader.""" from __future__ import annotations from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Optional, Sequence, Union from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader if TYPE_CHEC...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/twitter.html
d294aef3ff24-1
user = api.get_user(screen_name=username) docs = self._format_tweets(tweets, user) results.extend(docs) return results def _format_tweets( self, tweets: List[Dict[str, Any]], user_info: dict ) -> Iterable[Document]: """Format tweets into a string.""" for t...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/twitter.html
d294aef3ff24-2
access_token=access_token, access_token_secret=access_token_secret, consumer_key=consumer_key, consumer_secret=consumer_secret, ) return cls( auth_handler=auth, twitter_users=twitter_users, number_tweets=number_tweets, ) By ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/twitter.html
947d77b7e87a-0
Source code for langchain.document_loaders.azlyrics """Loader that loads AZLyrics.""" from typing import List from langchain.docstore.document import Document from langchain.document_loaders.web_base import WebBaseLoader [docs]class AZLyricsLoader(WebBaseLoader): """Loader that loads AZLyrics webpages.""" [docs] ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/azlyrics.html
68c5d2580ba5-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
68c5d2580ba5-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
7c5100ee3692-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
8303d78970b9-0
Source code for langchain.document_loaders.iugu """Loader that fetches data from IUGU""" import json import urllib.request from typing import List, Optional from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.utils import get_from_env, stringify_dict IU...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/iugu.html
8303d78970b9-1
return self._get_resource() By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 11, 2023.
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/iugu.html
f5a2602fee97-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...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/web_base.html
f5a2602fee97-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...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/web_base.html
f5a2602fee97-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 ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/web_base.html
f5a2602fee97-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.""" ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/web_base.html
f5a2602fee97-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...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/web_base.html
812ee41a02cb-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, Sequence, Union from urllib.parse import parse_qs, urlparse from pydantic import root_validator from pyd...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
812ee41a02cb-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
812ee41a02cb-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
812ee41a02cb-3
self.add_video_info = add_video_info self.language = language if isinstance(language, str): self.language = [language] else: self.language = language self.translation = translation self.continue_on_failure = continue_on_failure [docs] @staticmethod ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
812ee41a02cb-4
except TranscriptsDisabled: return [] try: transcript = transcript_list.find_transcript(self.language) except NoTranscriptFound: en_transcript = transcript_list.find_transcript(["en"]) transcript = en_transcript.translate(self.translation) transcri...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
812ee41a02cb-5
To use, you should have the ``googleapiclient,youtube_transcript_api`` python package installed. As the service needs a google_api_client, you first have to initialize the GoogleApiClient. Additionally you have to either provide a channel name or a list of videoids "https://developers.google.com/doc...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
812ee41a02cb-6
"to use the Google Drive loader" ) return build("youtube", "v3", credentials=creds) [docs] @root_validator def validate_channel_or_videoIds_is_set( cls, values: Dict[str, Any] ) -> Dict[str, Any]: """Validate that either folder_id or document_ids is set, but not both.""" ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
812ee41a02cb-7
request = self.youtube_client.search().list( part="id", q=channel_name, type="channel", maxResults=1, # we only need one result since channel names are unique ) response = request.execute() channel_id = response["items"][0]["id"]["channelId"] ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
812ee41a02cb-8
metadata=meta_data, ) ) except (TranscriptsDisabled, NoTranscriptFound) as e: if self.continue_on_failure: logger.error( "Error fetching transscript " + f" {ite...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
d13488dbf3a6-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
d13488dbf3a6-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
d13488dbf3a6-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
d13488dbf3a6-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
d13488dbf3a6-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
1c482ce05450-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
1c482ce05450-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
1c482ce05450-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
1c482ce05450-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
1c482ce05450-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 11, 2023.
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/github.html
4d50e4acbb0c-0
Source code for langchain.document_loaders.mastodon """Mastodon document loader.""" from __future__ import annotations import os from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Optional, Sequence from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader if TYPE...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/mastodon.html
4d50e4acbb0c-1
access_token = access_token or os.environ.get("MASTODON_ACCESS_TOKEN") self.api = mastodon.Mastodon( access_token=access_token, api_base_url=api_base_url ) self.mastodon_accounts = mastodon_accounts self.number_toots = number_toots self.exclude_replies = exclude_repli...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/mastodon.html
a0377a67acd3-0
Source code for langchain.document_loaders.roam """Loader that loads Roam directory dump.""" from pathlib import Path from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class RoamLoader(BaseLoader): """Loader that loads Roam files fr...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/roam.html
345a2e6799cc-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
0915ac30fae9-0
Source code for langchain.document_loaders.word_document """Loader that loads word documents.""" import os import tempfile from abc import ABC from typing import List from urllib.parse import urlparse import requests from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/word_document.html
0915ac30fae9-1
if hasattr(self, "temp_file"): self.temp_file.close() [docs] def load(self) -> List[Document]: """Load given path as single page.""" import docx2txt return [ Document( page_content=docx2txt.process(self.file_path), metadata={"source": se...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/word_document.html
0915ac30fae9-2
f"You are on unstructured version {__unstructured_version__}. " "Partitioning .doc files is only supported in unstructured>=0.4.11. " "Please upgrade the unstructured package and try again." ) if is_doc: from unstructured.partition.doc import partition_doc...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/word_document.html
203b6eb4af45-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