id
stringlengths
14
15
text
stringlengths
44
2.47k
source
stringlengths
61
181
50bfdee85d1c-2
if len(doppelgangers) > 1: idx_of_self = doppelgangers.index(chunk) qname = f"{qname}[{idx_of_self + 1}]" return qname def _xpath_for_chunk(chunk: Any) -> str: """Get the xpath for a chunk.""" ancestor_chain = chunk.xpath("ancestor-or-s...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html
50bfdee85d1c-3
"""Get the leaf structural nodes of a node.""" if _is_structural(node) and not _has_structural_descendant(node): return [node] else: leaf_nodes = [] for child in node: leaf_nodes.extend(_leaf_structural_nodes(child)) ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html
50bfdee85d1c-4
if prev_small_chunk_text and len(chunks) > 0: # small chunk at the end left over, just append to last chunk chunks[-1].page_content += " " + prev_small_chunk_text return chunks def _document_details_for_docset_id(self, docset_id: str) -> List[Dict]: """Gets all document detai...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html
50bfdee85d1c-5
) return all_projects def _metadata_for_project(self, project: Dict) -> Dict: """Gets project metadata for all files""" project_id = project.get("id") url = f"{self.api}/projects/{project_id}/artifacts/latest" all_artifacts = [] while url: response = reque...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html
50bfdee85d1c-6
artifact_root = artifact_tree.getroot() ns = artifact_root.nsmap entries = artifact_root.xpath("//pr:Entry", namespaces=ns) for entry in entries: heading = entry.xpath("./pr:Heading", namespaces=ns)[0].text value...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html
50bfdee85d1c-7
if self.document_ids: _document_details = [ d for d in _document_details if d["id"] in self.document_ids ] _project_details = self._project_details_for_docset_id(self.docset_id) combined_project_metadata = {} if _project_details: ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html
7b4a4e1d51d6-0
Source code for langchain.document_loaders.word_document """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 from langch...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/word_document.html
7b4a4e1d51d6-1
if hasattr(self, "temp_file"): self.temp_file.close() [docs] def load(self) -> List[Document]: """Load given path as single page.""" import docx2txt return [ Document( page_content=docx2txt.process(self.file_path), metadata={"source": se...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/word_document.html
7b4a4e1d51d6-2
from unstructured.file_utils.filetype import FileType, detect_filetype unstructured_version = tuple( [int(x) for x in __unstructured_version__.split(".")] ) # NOTE(MthwRobinson) - magic will raise an import error if the libmagic # system dependency isn't installed. If it's no...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/word_document.html
0547b0cf08bd-0
Source code for langchain.document_loaders.telegram 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.document_loaders.base import BaseLoader from langchain....
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/telegram.html
0547b0cf08bd-1
if isinstance(text, str): # Take a single string as one page text = [text] page_docs = [Document(page_content=page) for page in text] # Add page numbers as metadata for i, doc in enumerate(page_docs): doc.metadata["page"] = i + 1 # Split pages into chunks doc_chunks = [] ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/telegram.html
0547b0cf08bd-2
api_hash: The API hash. username: The username. file_path: The file path to save the data to. Defaults to "telegram_data.json". """ self.chat_entity = chat_entity self.api_id = api_id self.api_hash = api_hash self.username = username ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/telegram.html
0547b0cf08bd-3
Returns: dict: A dictionary where the key is the parent message ID and \ the value is a list of message IDs in ascending order. """ def find_replies(parent_id: int, reply_data: pd.DataFrame) -> List[int]: """ Recursively find all replies to a given par...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/telegram.html
0547b0cf08bd-4
} return message_threads def _combine_message_texts( self, message_threads: Dict[int, List[int]], data: pd.DataFrame ) -> str: """ Combine the message texts for each parent message ID based \ on the list of message threads. Args: message_threads (d...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/telegram.html
0547b0cf08bd-5
""" ) p = Path(self.file_path) with open(p, encoding="utf8") as f: d = json.load(f) try: import pandas as pd except ImportError: raise ImportError( """`pandas` package not found. please install with `pip...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/telegram.html
2d6c7fb010ce-0
Source code for langchain.document_loaders.cube_semantic import json import logging import time from typing import List import requests from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader logger = logging.getLogger(__name__) [docs]class CubeSemanticLoader(BaseLoader):...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/cube_semantic.html
2d6c7fb010ce-1
self.dimension_values_retry_delay = dimension_values_retry_delay def _get_dimension_values(self, dimension_name: str) -> List[str]: """Makes a call to Cube's REST API load endpoint to retrieve values for dimensions. These values can be used to achieve a more accurate filtering. """ ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/cube_semantic.html
2d6c7fb010ce-2
"""Makes a call to Cube's REST API metadata endpoint. Returns: A list of documents with attributes: - page_content=column_title + column_description - metadata - table_name - column_name - column_data_type ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/cube_semantic.html
2d6c7fb010ce-3
dimension_values = [] item_name = str(item.get("name")) item_type = str(item.get("type")) if ( self.load_dimension_values and column_member_type == "dimension" and item_type == "string" ): ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/cube_semantic.html
af4d347aea9c-0
Source code for langchain.document_loaders.college_confidential from typing import List from langchain.docstore.document import Document from langchain.document_loaders.web_base import WebBaseLoader [docs]class CollegeConfidentialLoader(WebBaseLoader): """Load `College Confidential` webpages.""" [docs] def load(...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/college_confidential.html
e27eb5bd8d27-0
Source code for langchain.document_loaders.brave_search from typing import Iterator, List, Optional from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.utilities.brave_search import BraveSearchWrapper [docs]class BraveSearchLoader(BaseLoader): """Lo...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/brave_search.html
8de685d1a167-0
Source code for langchain.document_loaders.facebook_chat 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 [docs]def concatenate_rows(row: dict) -> str: """Combine message information i...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/facebook_chat.html
19529b0b8ced-0
Source code for langchain.document_loaders.s3_file from __future__ import annotations import os import tempfile from typing import TYPE_CHECKING, List, Optional, Union from langchain.document_loaders.unstructured import UnstructuredBaseLoader if TYPE_CHECKING: import botocore [docs]class S3FileLoader(UnstructuredBa...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/s3_file.html
19529b0b8ced-1
Note that not all services support non-ssl connections. :param verify: Whether or not to verify SSL certificates. By default SSL certificates are verified. You can provide the following values: * False - do not validate SSL certificates. SSL will still be used...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/s3_file.html
19529b0b8ced-2
is specified in the client config, its value will take precedence over environment variables and configuration values, but not over a value passed explicitly to the method. If a default config object is set on the session, the config object used when creating the client w...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/s3_file.html
19529b0b8ced-3
os.makedirs(os.path.dirname(file_path), exist_ok=True) s3.download_file(self.bucket, self.key, file_path) return partition(filename=file_path) def _get_metadata(self) -> dict: return {"source": f"s3://{self.bucket}/{self.key}"}
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/s3_file.html
f9341e2582d4-0
Source code for langchain.document_loaders.conllu 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.""" [docs] def __init__(self, file_path: str): """Init...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/conllu.html
9e0c1be44106-0
Source code for langchain.document_loaders.mhtml import email import logging from typing import Dict, List, Union from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader logger = logging.getLogger(__name__) [docs]class MHTMLLoader(BaseLoader): """Parse `MHTML` files w...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/mhtml.html
9e0c1be44106-1
with open(self.file_path, "r", encoding=self.open_encoding) as f: message = email.message_from_string(f.read()) parts = message.get_payload() if not isinstance(parts, list): parts = [message] for part in parts: if part.get_content_type() ==...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/mhtml.html
8b55ca975f51-0
Source code for langchain.document_loaders.obs_file # coding:utf-8 import os import tempfile from typing import Any, List, Optional from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.document_loaders.unstructured import UnstructuredFileLoader [docs]cla...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/obs_file.html
8b55ca975f51-1
- "get_token_from_ecs" (bool, optional): Whether to retrieve the security token from ECS. Defaults to False if not provided. If set to True, `ak`, `sk`, and `token` will be ignored. Raises: ValueError: If the `esdk-obs-python` package is not installed. TypeError: If the provided `client`...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/obs_file.html
8b55ca975f51-2
from obs import ObsClient except ImportError: raise ImportError( "Could not import esdk-obs-python python package. " "Please install it with `pip install esdk-obs-python`." ) if not client: if not endpoint: raise ValueEr...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/obs_file.html
cc6a9d1da908-0
Source code for langchain.document_loaders.base """Abstract interface for document loader implementations.""" from abc import ABC, abstractmethod from typing import Iterator, List, Optional from langchain.document_loaders.blob_loaders import Blob from langchain.schema import Document from langchain.text_splitter import...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/base.html
cc6a9d1da908-1
# implemented in all the existing subclasses. [docs] def lazy_load( self, ) -> Iterator[Document]: """A lazy loader for Documents.""" raise NotImplementedError( f"{self.__class__.__name__} does not implement lazy_load()" ) [docs]class BaseBlobParser(ABC): ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/base.html
a71056960835-0
Source code for langchain.document_loaders.fauna from typing import Iterator, List, Optional, Sequence from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class FaunaLoader(BaseLoader): """Load from `FaunaDB`. Attributes: query (str): The FQL que...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/fauna.html
a71056960835-1
document_dict = dict(result.items()) page_content = "" for key, value in document_dict.items(): if key == self.page_content_field: page_content = value document: Document = Document( page_content=page_content...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/fauna.html
cd5da643c3e9-0
Source code for langchain.document_loaders.readthedocs from pathlib import Path from typing import Any, List, Optional, Tuple, Union from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class ReadTheDocsLoader(BaseLoader): """Load `ReadTheDocs` documentation ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/readthedocs.html
cd5da643c3e9-1
except ImportError: raise ImportError( "Could not import python packages. " "Please install it with `pip install beautifulsoup4`. " ) try: _ = BeautifulSoup( "<html><body>Parser builder library test.</body></html>", **kwargs ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/readthedocs.html
cd5da643c3e9-2
if text is not None: text = text.get_text() else: text = "" # trim empty lines return "\n".join([t for t in text.split("\n") if t])
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/readthedocs.html
d6022fad3e93-0
Source code for langchain.document_loaders.html from typing import List from langchain.document_loaders.unstructured import UnstructuredFileLoader [docs]class UnstructuredHTMLLoader(UnstructuredFileLoader): """Load `HTML` files using `Unstructured`. You can run the loader in one of two modes: "single" and "elem...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/html.html
5eba5abead52-0
Source code for langchain.document_loaders.blackboard 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.document_loaders.directory import DirectoryLoader from langchain.docum...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
5eba5abead52-1
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. basic_auth: Basic auth credentials. cookies: Cook...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
5eba5abead52-2
except ImportError: raise ImportError( "BeautifulSoup4 is required for BlackboardLoader. " "Please install it with `pip install beautifulsoup4`." ) [docs] def load(self) -> List[Document]: """Load data into Document objects. Returns: ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
5eba5abead52-3
.replace("/", "_") .replace(":", "_") .replace(",", "_") .replace("?", "_") .replace("'", "_") .replace("!", "_") .replace('"', "_") ) # Get the folder path folder_path = Path(".") / course_name_clean return str(fold...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
5eba5abead52-4
attachments.append(href) return attachments def _download_attachments(self, attachments: List[str]) -> None: """Download all attachments. Args: attachments: List of attachments. """ # Make sure the folder exists Path(self.folder_path).mkdir(parents=True, e...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
5eba5abead52-5
filename = self.parse_filename(response.url) # Write the file to disk with open(Path(self.folder_path) / filename, "wb") as f: f.write(response.content) [docs] def parse_filename(self, url: str) -> str: """Parse the filename from an url. Args: url: Url to parse...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
5eba5abead52-6
" HERE>_1&content_id=_<YOUR CONTENT ID HERE>_1&mode=reset", "<YOUR BBROUTER COOKIE HERE>", load_all_recursively=True, ) documents = loader.load() print(f"Loaded {len(documents)} pages of PDFs from {loader.web_path}")
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
398d66bda4ba-0
Source code for langchain.document_loaders.bilibili import json import re import warnings from typing import List, Tuple import requests from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class BiliBiliLoader(BaseLoader): """Load `BiliBili` video transcript...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/bilibili.html
398d66bda4ba-1
raise ValueError(f"{url} is not bilibili url.") else: raise ValueError(f"{url} is not bilibili url.") video_info = sync(v.get_info()) video_info.update({"url": url}) sub = sync(v.get_subtitle(video_info["cid"])) # Get subtitle url sub_list = sub["subti...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/bilibili.html
e512927f4040-0
Source code for langchain.document_loaders.googledrive # 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: # https://developers.google.com/drive/api/quickstart/...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/googledrive.html
e512927f4040-1
"""Whether to load recursively. Only applies when folder_id is given.""" file_types: Optional[Sequence[str]] = None """The file types to load. Only applies when folder_id is given.""" load_trashed_files: bool = False """Whether to load trashed files. Only applies when folder_id is given.""" # NOTE(M...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/googledrive.html
e512927f4040-2
type_mapping = { "document": "application/vnd.google-apps.document", "sheet": "application/vnd.google-apps.spreadsheet", "pdf": "application/pdf", } allowed_types = list(type_mapping.keys()) + list(type_mapping.values()) short_names = "...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/googledrive.html
e512927f4040-3
from google_auth_oauthlib.flow import InstalledAppFlow except ImportError: raise ImportError( "You must run " "`pip install --upgrade " "google-api-python-client google-auth-httplib2 " "google-auth-oauthlib` " "to use th...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/googledrive.html
e512927f4040-4
sheets = spreadsheet.get("sheets", []) documents = [] for sheet in sheets: sheet_name = sheet["properties"]["title"] result = ( sheets_service.spreadsheets() .values() .get(spreadsheetId=id, range=sheet_name) .execut...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/googledrive.html
e512927f4040-5
.execute() ) request = service.files().export_media(fileId=id, mimeType="text/plain") fh = BytesIO() downloader = MediaIoBaseDownload(fh, request) done = False try: while done is False: status, done = downloader.next_chunk() except Http...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/googledrive.html
e512927f4040-6
continue elif file["mimeType"] == "application/vnd.google-apps.document": returns.append(self._load_document_from_id(file["id"])) # type: ignore elif file["mimeType"] == "application/vnd.google-apps.spreadsheet": returns.extend(self._load_sheet_from_id(file["id"]...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/googledrive.html
e512927f4040-7
if not self.document_ids: raise ValueError("document_ids must be set") return [self._load_document_from_id(doc_id) for doc_id in self.document_ids] def _load_file_from_id(self, id: str) -> List[Document]: """Load a file from an ID.""" from io import BytesIO from googleapi...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/googledrive.html
e512927f4040-8
] def _load_file_from_ids(self) -> List[Document]: """Load files from a list of IDs.""" if not self.file_ids: 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 [do...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/googledrive.html
b4161427fcfa-0
Source code for langchain.document_loaders.confluence import logging from enum import Enum from io import BytesIO from typing import Any, Callable, Dict, List, Optional, Union import requests from tenacity import ( before_sleep_log, retry, stop_after_attempt, wait_exponential, ) from langchain.docstore....
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
b4161427fcfa-1
Confluence API supports difference format of page content. The storage format is the raw XML representation for storage. The view format is the HTML representation for viewing with macros are rendered as though it is viewed by users. You can pass a enum `content_format` argument to `load()` to specify the c...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
b4161427fcfa-2
:param oauth2: _description_, defaults to {} :type oauth2: dict, optional :param token: _description_, defaults to None :type token: str, optional :param cloud: _description_, defaults to True :type cloud: bool, optional :param number_of_retries: How many times to retry, defaults to 3 :type ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
b4161427fcfa-3
oauth2=oauth2, token=token, ) if errors: raise ValueError(f"Error(s) while validating input: {errors}") try: from atlassian import Confluence # noqa: F401 except ImportError: raise ImportError( "`atlassian` package not foun...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
b4161427fcfa-4
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." ) non_null_creds = list(...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
b4161427fcfa-5
include_archived_content: bool = False, include_attachments: bool = False, include_comments: bool = False, content_format: ContentFormat = ContentFormat.STORAGE, limit: Optional[int] = 50, max_pages: Optional[int] = 1000, ocr_languages: Optional[str] = None, keep_...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
b4161427fcfa-6
:type content_format: ContentFormat :param limit: Maximum number of pages to retrieve per request, defaults to 50 :type limit: int, optional :param max_pages: Maximum number of pages to retrieve in total, defaults 1000 :type max_pages: int, optional :param ocr_languages: The lang...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
b4161427fcfa-7
include_comments, content_format, ocr_languages=ocr_languages, keep_markdown_format=keep_markdown_format, keep_newlines=keep_newlines, ) if label: pages = self.paginate_request( self.confluence.get_all_pages_...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
b4161427fcfa-8
)(self.confluence.get_page_by_id) page = get_page( page_id=page_id, expand=f"{content_format.value},version" ) if not include_restricted_content and not self.is_public_page(page): continue doc = self.process_page( ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
b4161427fcfa-9
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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
b4161427fcfa-10
) [docs] def process_pages( self, pages: List[dict], include_restricted_content: bool, include_attachments: bool, include_comments: bool, content_format: ContentFormat, ocr_languages: Optional[str] = None, keep_markdown_format: Optional[bool] = False, ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
b4161427fcfa-11
except ImportError: raise ImportError( "`beautifulsoup4` package not found, please run " "`pip install beautifulsoup4`" ) if include_attachments: attachment_texts = self.process_attachment(page["id"], ocr_languages) else...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
b4161427fcfa-12
return Document( page_content=text, metadata=metadata, ) [docs] def process_attachment( self, page_id: str, ocr_languages: Optional[str] = None, ) -> List[str]: try: from PIL import Image # noqa: F401 except ImportError: ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
b4161427fcfa-13
texts.append(text) return texts [docs] def process_pdf( self, link: str, ocr_languages: Optional[str] = None, ) -> str: try: import pytesseract # noqa: F401 from pdf2image import convert_from_bytes # noqa: F401 except ImportError: ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
b4161427fcfa-14
text = "" if ( response.status_code != 200 or response.content == b"" or response.content is None ): return text try: image = Image.open(BytesIO(response.content)) except OSError: return text return pytessera...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
b4161427fcfa-15
): return text filename = os.path.basename(link) # Getting the whole content of the url after filename, # Example: ".csv?version=2&modificationDate=1631800010678&cacheVersion=1&api=v2" file_extension = os.path.splitext(filename)[1] if file_extension.startswith( ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
b4161427fcfa-16
"please run `pip install pytesseract Pillow reportlab svglib`" ) response = self.confluence.request(path=link, absolute=True) text = "" if ( response.status_code != 200 or response.content == b"" or response.content is None ): r...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
4f566ccc33b2-0
Source code for langchain.document_loaders.whatsapp_chat import re from pathlib import Path from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]def concatenate_rows(date: str, sender: str, text: str) -> str: """Combine message informa...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/whatsapp_chat.html
4f566ccc33b2-1
) if result: date, sender, text = result.groups() if text not in ignore_lines: text_content += concatenate_rows(date, sender, text) metadata = {"source": str(p)} return [Document(page_content=text_content, metadata=metadata)]
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/whatsapp_chat.html
eb4b8f310bf5-0
Source code for langchain.document_loaders.stripe 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 STRIPE_ENDPOINTS = { "balance_transac...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/stripe.html
eb4b8f310bf5-1
return [Document(page_content=text, metadata=metadata)] def _get_resource(self) -> List[Document]: endpoint = STRIPE_ENDPOINTS.get(self.resource) if endpoint is None: return [] return self._make_request(endpoint) [docs] def load(self) -> List[Document]: return self._ge...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/stripe.html
0b6e8349e3b8-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 langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.pydantic_v1 import ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/github.html
0b6e8349e3b8-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/github.html
0b6e8349e3b8-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/github.html
0b6e8349e3b8-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/github.html
0b6e8349e3b8-4
return query_params @property def url(self) -> str: """Create URL for GitHub API.""" return f"https://api.github.com/repos/{self.repo}/issues?{self.query_params}"
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/github.html
c87b0c68f7b1-0
Source code for langchain.document_loaders.dropbox # Prerequisites: # 1. Create a Dropbox app. # 2. Give the app these scope permissions: `files.metadata.read` # and `files.content.read`. # 3. Generate access token: https://www.dropbox.com/developers/apps/create. # 4. `pip install dropbox` (requires `pip install uns...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/dropbox.html
c87b0c68f7b1-1
if values.get("dropbox_folder_path") is None and not values.get( "dropbox_file_paths" ): raise ValueError("Must specify either folder_path or file_paths") return values def _create_dropbox_client(self) -> Any: """Create a Dropbox client.""" try: fr...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/dropbox.html
c87b0c68f7b1-2
def _load_file_from_path(self, file_path: str) -> Optional[Document]: """Load a file from a Dropbox path.""" dbx = self._create_dropbox_client() try: from dropbox import exceptions except ImportError: raise ImportError("You must run " "`pip install dropbox") ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/dropbox.html
c87b0c68f7b1-3
return None return None metadata = { "source": f"dropbox://{file_path}", "title": os.path.basename(file_path), } return Document(page_content=text, metadata=metadata) def _load_documents_from_paths(self) -> List[Document]: """Load documents from a ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/dropbox.html
cf7bc085624d-0
Source code for langchain.document_loaders.news """Loader that uses unstructured to load HTML files.""" import logging from typing import Any, Iterator, List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader logger = logging.getLogger(__name__) [docs]class NewsURLLo...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/news.html
cf7bc085624d-1
) -> None: """Initialize with file path.""" try: import newspaper # noqa:F401 self.__version = newspaper.__version__ except ImportError: raise ImportError( "newspaper package not found, please install it with " "`pip install ne...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/news.html
cf7bc085624d-2
continue else: raise e metadata = { "title": getattr(article, "title", ""), "link": getattr(article, "url", getattr(article, "canonical_link", "")), "authors": getattr(article, "authors", []), "language": get...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/news.html
35dae2f00630-0
Source code for langchain.document_loaders.sharepoint """Loader that loads data from Sharepoint Document Library""" from __future__ import annotations from typing import Iterator, List, Optional, Sequence from langchain.docstore.document import Document from langchain.document_loaders.base_o365 import ( O365BaseLoa...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/sharepoint.html
35dae2f00630-1
raise ValueError(f"There isn't a Drive with id {self.document_library_id}.") blob_parser = get_parser("default") if self.folder_path: target_folder = drive.get_item_by_path(self.folder_path) if not isinstance(target_folder, Folder): raise ValueError(f"There isn't ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/sharepoint.html
37b2b2445bde-0
Source code for langchain.document_loaders.pyspark_dataframe 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 logger = logging.getLogger(__file__) if T...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/pyspark_dataframe.html
37b2b2445bde-1
self.fraction_of_memory = fraction_of_memory self.num_rows, self.max_num_rows = self.get_num_rows() self.rdd_df = self.df.rdd.map(list) self.column_names = self.df.columns [docs] def get_num_rows(self) -> Tuple[int, int]: """Gets the number of "feasible" rows for the DataFrame""" ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/pyspark_dataframe.html
37b2b2445bde-2
) lazy_load_iterator = self.lazy_load() return list(itertools.islice(lazy_load_iterator, self.num_rows))
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/pyspark_dataframe.html
cf5a805f6ac5-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 [docs]class BlockchainType(Enum): """Enumerator of the...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/blockchain.html
cf5a805f6ac5-1
""" [docs] 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, ): """ ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/blockchain.html
cf5a805f6ac5-2
f"&startToken={current_start_token}" ) response = requests.get(url) if response.status_code != 200: raise ValueError( f"Request failed with status code {response.status_code}" ) items = response.json()["nfts"] ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/blockchain.html
cf5a805f6ac5-3
else: value_int = int(tokenId) result = value_int + 1 if value_type == "hex_0x": return "0x" + format(result, "0" + str(len(tokenId) - 2) + "x") elif value_type == "hex_0xbf": return "0xbf" + format(result, "0" + str(len(tokenId) - 4) + "x") else: ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/blockchain.html