id
stringlengths
14
16
text
stringlengths
31
3.14k
source
stringlengths
58
124
6d51a65297c0-0
.md .pdf GPT4All Contents Installation and Setup Usage GPT4All Model File GPT4All# This page covers how to use the GPT4All wrapper within LangChain. The tutorial is divided into two parts: installation and setup, followed by usage with an example. Installation and Setup# Install the Python package with pip install py...
/content/https://python.langchain.com/en/latest/ecosystem/gpt4all.html
6d51a65297c0-1
model = GPT4All(model="./models/gpt4all-model.bin", n_ctx=512, n_threads=8, callback_handler=callback_handler, verbose=True) # Generate text. Tokens are streamed through the callback manager. model("Once upon a time, ") Model File# You can find links to model file downloads in the pyllamacpp repository. For a more deta...
/content/https://python.langchain.com/en/latest/ecosystem/gpt4all.html
8c7ffc1b19d4-0
.md .pdf Deep Lake Contents Why Deep Lake? More Resources Installation and Setup Wrappers VectorStore Deep Lake# This page covers how to use the Deep Lake ecosystem within LangChain. Why Deep Lake?# More than just a (multi-modal) vector store. You can later use the dataset to fine-tune your own LLM models. Not only s...
/content/https://python.langchain.com/en/latest/ecosystem/deeplake.html
23ec41b8d6bd-0
.md .pdf NLPCloud Contents Installation and Setup Wrappers LLM NLPCloud# This page covers how to use the NLPCloud ecosystem within LangChain. It is broken into two parts: installation and setup, and then references to specific NLPCloud wrappers. Installation and Setup# Install the Python SDK with pip install nlpcloud...
/content/https://python.langchain.com/en/latest/ecosystem/nlpcloud.html
2d2e310bc7b1-0
.md .pdf Runhouse Contents Installation and Setup Self-hosted LLMs Self-hosted Embeddings Runhouse# This page covers how to use the Runhouse ecosystem within LangChain. It is broken into three parts: installation and setup, LLMs, and Embeddings. Installation and Setup# Install the Python SDK with pip install runhouse...
/content/https://python.langchain.com/en/latest/ecosystem/runhouse.html
f25abd27ba0b-0
.md .pdf Petals Contents Installation and Setup Wrappers LLM Petals# This page covers how to use the Petals ecosystem within LangChain. It is broken into two parts: installation and setup, and then references to specific Petals wrappers. Installation and Setup# Install with pip install petals Get a Hugging Face api k...
/content/https://python.langchain.com/en/latest/ecosystem/petals.html
f6c9b6029c26-0
.md .pdf Modal Contents Installation and Setup Define your Modal Functions and Webhooks Wrappers LLM Modal# This page covers how to use the Modal ecosystem within LangChain. It is broken into two parts: installation and setup, and then references to specific Modal wrappers. Installation and Setup# Install with pip in...
/content/https://python.langchain.com/en/latest/ecosystem/modal.html
f6c9b6029c26-1
encoded_input = tokenizer(text, return_tensors='pt').input_ids output = model.generate(encoded_input, max_length=50, do_sample=True) return tokenizer.decode(output[0], skip_special_tokens=True) class Item(BaseModel): prompt: str @stub.webhook(method="POST") def get_text(item: Item): return {"prompt": ru...
/content/https://python.langchain.com/en/latest/ecosystem/modal.html
97360f18b820-0
.md .pdf Databerry Contents What is Databerry? Quick start Databerry# This page covers how to use the Databerry within LangChain. What is Databerry?# Databerry is an open source document retrievial platform that helps to connect your personal data with Large Language Models. Quick start# Retrieving documents stored i...
/content/https://python.langchain.com/en/latest/ecosystem/databerry.html
008e67ebdf22-0
.md .pdf GooseAI Contents Installation and Setup Wrappers LLM GooseAI# This page covers how to use the GooseAI ecosystem within LangChain. It is broken into two parts: installation and setup, and then references to specific GooseAI wrappers. Installation and Setup# Install the Python SDK with pip install openai Get y...
/content/https://python.langchain.com/en/latest/ecosystem/gooseai.html
a9d7956f0eaf-0
Source code for langchain.document_transformers """Transform documents""" from typing import Any, Callable, List, Sequence import numpy as np from pydantic import BaseModel, Field from langchain.embeddings.base import Embeddings from langchain.math_utils import cosine_similarity from langchain.schema import BaseDocumen...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_transformers.html
a9d7956f0eaf-1
similarity = np.tril(similarity_fn(embedded_documents, embedded_documents), k=-1) redundant = np.where(similarity > threshold) redundant_stacked = np.column_stack(redundant) redundant_sorted = np.argsort(similarity[redundant])[::-1] included_idxs = set(range(len(embedded_documents))) for first_idx, ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_transformers.html
a9d7956f0eaf-2
"""Filter that drops redundant documents by comparing their embeddings.""" embeddings: Embeddings """Embeddings to use for embedding document contents.""" similarity_fn: Callable = cosine_similarity """Similarity function for comparing documents. Function expected to take as input two matrices (List...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_transformers.html
a9d7956f0eaf-3
) -> Sequence[Document]: raise NotImplementedError By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 26, 2023.
/content/https://python.langchain.com/en/latest/_modules/langchain/document_transformers.html
868f08a4523d-0
Source code for langchain.text_splitter """Functionality for splitting text.""" from __future__ import annotations import copy import logging from abc import ABC, abstractmethod from typing import ( AbstractSet, Any, Callable, Collection, Iterable, List, Literal, Optional, Sequence, ...
/content/https://python.langchain.com/en/latest/_modules/langchain/text_splitter.html
868f08a4523d-1
) -> List[Document]: """Create documents from a list of texts.""" _metadatas = metadatas or [{}] * len(texts) documents = [] for i, text in enumerate(texts): for chunk in self.split_text(text): new_doc = Document( page_content=chunk, metada...
/content/https://python.langchain.com/en/latest/_modules/langchain/text_splitter.html
868f08a4523d-2
> self._chunk_size ): if total > self._chunk_size: logger.warning( f"Created a chunk of size {total}, " f"which is longer than the specified {self._chunk_size}" ) if len(current_doc) > 0: ...
/content/https://python.langchain.com/en/latest/_modules/langchain/text_splitter.html
868f08a4523d-3
try: from transformers import PreTrainedTokenizerBase if not isinstance(tokenizer, PreTrainedTokenizerBase): raise ValueError( "Tokenizer received was not an instance of PreTrainedTokenizerBase" ) def _huggingface_tokenizer_length(t...
/content/https://python.langchain.com/en/latest/_modules/langchain/text_splitter.html
868f08a4523d-4
else: enc = tiktoken.get_encoding(encoding_name) def _tiktoken_encoder(text: str, **kwargs: Any) -> int: return len( enc.encode( text, allowed_special=allowed_special, disallowed_special=disallowed_special, ...
/content/https://python.langchain.com/en/latest/_modules/langchain/text_splitter.html
868f08a4523d-5
# First we naively split the large input into a bunch of smaller ones. if self._separator: splits = text.split(self._separator) else: splits = list(text) return self._merge_splits(splits, self._separator) [docs]class TokenTextSplitter(TextSplitter): """Implementation ...
/content/https://python.langchain.com/en/latest/_modules/langchain/text_splitter.html
868f08a4523d-6
"""Split incoming text and return chunks.""" splits = [] input_ids = self._tokenizer.encode( text, allowed_special=self._allowed_special, disallowed_special=self._disallowed_special, ) start_idx = 0 cur_idx = min(start_idx + self._chunk_size, l...
/content/https://python.langchain.com/en/latest/_modules/langchain/text_splitter.html
868f08a4523d-7
"""Split incoming text and return chunks.""" final_chunks = [] # Get appropriate separator to use separator = self._separators[-1] for _s in self._separators: if _s == "": separator = _s break if _s in text: separato...
/content/https://python.langchain.com/en/latest/_modules/langchain/text_splitter.html
868f08a4523d-8
"""Initialize the NLTK splitter.""" super().__init__(**kwargs) try: from nltk.tokenize import sent_tokenize self._tokenizer = sent_tokenize except ImportError: raise ImportError( "NLTK is not installed, please install it with `pip install nltk`...
/content/https://python.langchain.com/en/latest/_modules/langchain/text_splitter.html
868f08a4523d-9
"""Split incoming text and return chunks.""" splits = (str(s) for s in self._tokenizer(text).sents) return self._merge_splits(splits, self._separator) [docs]class MarkdownTextSplitter(RecursiveCharacterTextSplitter): """Attempts to split the text along Markdown-formatted headings.""" def __init_...
/content/https://python.langchain.com/en/latest/_modules/langchain/text_splitter.html
868f08a4523d-10
def __init__(self, **kwargs: Any): """Initialize a LatexTextSplitter.""" separators = [ # First, try to split along Latex sections "\n\\chapter{", "\n\\section{", "\n\\subsection{", "\n\\subsubsection{", # Now split by environments ...
/content/https://python.langchain.com/en/latest/_modules/langchain/text_splitter.html
868f08a4523d-11
By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 26, 2023.
/content/https://python.langchain.com/en/latest/_modules/langchain/text_splitter.html
bd461319a3c9-0
Source code for langchain.requests """Lightweight wrapper around requests library, with async support.""" from contextlib import asynccontextmanager from typing import Any, AsyncGenerator, Dict, Optional import aiohttp import requests from pydantic import BaseModel, Extra class Requests(BaseModel): """Wrapper aroun...
/content/https://python.langchain.com/en/latest/_modules/langchain/requests.html
bd461319a3c9-1
"""PATCH the URL and return the text.""" return requests.patch(url, json=data, headers=self.headers, **kwargs) def put(self, url: str, data: Dict[str, Any], **kwargs: Any) -> requests.Response: """PUT the URL and return the text.""" return requests.put(url, json=data, headers=self.headers, *...
/content/https://python.langchain.com/en/latest/_modules/langchain/requests.html
bd461319a3c9-2
"""GET the URL and return the text asynchronously.""" async with self._arequest("GET", url, **kwargs) as response: yield response @asynccontextmanager async def apost( self, url: str, data: Dict[str, Any], **kwargs: Any ) -> AsyncGenerator[aiohttp.ClientResponse, None]: "...
/content/https://python.langchain.com/en/latest/_modules/langchain/requests.html
bd461319a3c9-3
self, url: str, **kwargs: Any ) -> AsyncGenerator[aiohttp.ClientResponse, None]: """DELETE the URL and return the text asynchronously.""" async with self._arequest("DELETE", url, **kwargs) as response: yield response [docs]class TextRequestsWrapper(BaseModel): """Lightweight wrapper ...
/content/https://python.langchain.com/en/latest/_modules/langchain/requests.html
bd461319a3c9-4
"""PATCH the URL and return the text.""" return self.requests.patch(url, data, **kwargs).text [docs] def put(self, url: str, data: Dict[str, Any], **kwargs: Any) -> str: """PUT the URL and return the text.""" return self.requests.put(url, data, **kwargs).text [docs] def delete(self, url: s...
/content/https://python.langchain.com/en/latest/_modules/langchain/requests.html
bd461319a3c9-5
"""PATCH the URL and return the text asynchronously.""" async with self.requests.apatch(url, **kwargs) as response: return await response.text() [docs] async def aput(self, url: str, data: Dict[str, Any], **kwargs: Any) -> str: """PUT the URL and return the text asynchronously.""" ...
/content/https://python.langchain.com/en/latest/_modules/langchain/requests.html
bd198f679846-0
Source code for langchain.document_loaders.directory """Loading logic for loading documents from a directory.""" import logging from pathlib import Path from typing import List, Type, Union from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.document_lo...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/directory.html
bd198f679846-1
if loader_kwargs is None: loader_kwargs = {} self.path = path self.glob = glob self.load_hidden = load_hidden self.loader_cls = loader_cls self.loader_kwargs = loader_kwargs self.silent_errors = silent_errors self.recursive = recursive self.sho...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/directory.html
bd198f679846-2
else: raise e finally: if pbar: pbar.update(1) if pbar: pbar.close() return docs By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 26, 2023.
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/directory.html
fee38e5eb450-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 ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/s3_directory.html
c3191335c057-0
Source code for langchain.document_loaders.telegram """Loader that loads Telegram chat json dump.""" 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) -> str: """Combine...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/telegram.html
c3191335c057-1
df_filtered = df_normalized_messages[ (df_normalized_messages.type == "message") & (df_normalized_messages.text.apply(lambda x: type(x) == str)) ] df_filtered = df_filtered[["date", "text", "from"]] text = df_filtered.apply(concatenate_rows, axis=1).str.cat(sep="") ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/telegram.html
b265faca26b1-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...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/rtf.html
bb00a98d53dc-0
Source code for langchain.document_loaders.youtube """Loader that loads YouTube transcript.""" from __future__ import annotations import logging from pathlib import Path from typing import Any, Dict, List, Optional from pydantic import root_validator from pydantic.dataclasses import dataclass from langchain.docstore.do...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
bb00a98d53dc-1
def __post_init__(self) -> None: self.creds = self._load_credentials() [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.""" if not values.get(...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
bb00a98d53dc-2
str(self.service_account_path) ) if self.token_path.exists(): creds = Credentials.from_authorized_user_file(str(self.token_path), SCOPES) if not creds or not creds.valid: if creds and creds.expired and creds.refresh_token: creds.refresh(Request()) ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
bb00a98d53dc-3
return cls(video_id, **kwargs) [docs] def load(self) -> List[Document]: """Load documents.""" try: from youtube_transcript_api import ( NoTranscriptFound, TranscriptsDisabled, YouTubeTranscriptApi, ) except ImportError: ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
bb00a98d53dc-4
- description - thumbnail url, - publish_date - channel_author - and more. """ try: from pytube import YouTube except ImportError: raise ImportError( "Could not import pytube python package. " ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
bb00a98d53dc-5
) loader = GoogleApiYoutubeLoader( google_api_client=google_api_client, channel_name = "CodeAesthetic" ) load.load() """ google_api_client: GoogleApiClient channel_name: Optional[str] = None video_ids: Optional[List[str]] = None add...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
bb00a98d53dc-6
raise ValueError("Must specify either channel_name or video_ids") return values def _get_transcripe_for_video_id(self, video_id: str) -> str: from youtube_transcript_api import NoTranscriptFound, YouTubeTranscriptApi transcript_list = YouTubeTranscriptApi.list_transcripts(video_id) t...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
bb00a98d53dc-7
) response = request.execute() channel_id = response["items"][0]["id"]["channelId"] return channel_id def _get_document_for_channel(self, channel: str, **kwargs: Any) -> List[Document]: try: from youtube_transcript_api import ( NoTranscriptFound, ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
bb00a98d53dc-8
Document( page_content=page_content, metadata=meta_data, ) ) except (TranscriptsDisabled, NoTranscriptFound) as e: if self.continue_on_failure: logger.error( ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
2c0b03d134ac-0
Source code for langchain.document_loaders.hn """Loader that loads HN.""" from typing import Any, List from langchain.docstore.document import Document from langchain.document_loaders.web_base import WebBaseLoader [docs]class HNLoader(WebBaseLoader): """Load Hacker News data from either main page results or the com...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/hn.html
2c0b03d134ac-1
"""Load items from an HN page.""" items = soup.select("tr[class='athing']") documents = [] for lineItem in items: ranking = lineItem.select_one("span[class='rank']").text link = lineItem.find("span", {"class": "titleline"}).find("a").get("href") title = lineIt...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/hn.html
9020247bd152-0
Source code for langchain.document_loaders.pdf """Loader that loads PDF files.""" import os import tempfile from abc import ABC from io import StringIO from typing import Any, List, Optional from urllib.parse import urlparse import requests from langchain.docstore.document import Document from langchain.document_loader...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/pdf.html
9020247bd152-1
# If the file is a web path, download it to a temporary file, and use that if not os.path.isfile(self.file_path) and self._is_valid_url(self.file_path): r = requests.get(self.file_path) if r.status_code != 200: raise ValueError( "Check the url of your ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/pdf.html
9020247bd152-2
[docs]class PyPDFLoader(BasePDFLoader): """Loads a PDF with pypdf and chunks at character level. Loader also stores page numbers in metadatas. """ def __init__(self, file_path: str): """Initialize with file path.""" try: import pypdf # noqa:F401 except ImportError: ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/pdf.html
9020247bd152-3
) super().__init__(file_path) [docs] def load(self) -> List[Document]: """Load file.""" from pdfminer.high_level import extract_text text = extract_text(self.file_path) metadata = {"source": self.file_path} return [Document(page_content=text, metadata=metadata)] [docs]...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/pdf.html
9020247bd152-4
) metadata = {"source": self.file_path} return [Document(page_content=output_string.getvalue(), metadata=metadata)] [docs]class PyMuPDFLoader(BasePDFLoader): """Loader that uses PyMuPDF to load PDF files.""" def __init__(self, file_path: str): """Initialize with file path.""" try...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/pdf.html
395b69c52a4d-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...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/conllu.html
b19da74a4b2a-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.""" ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/markdown.html
892dc74069a0-0
Source code for langchain.document_loaders.image_captions """ Loader that loads image captions By default, the loader utilizes the pre-trained BLIP image captioning model. https://huggingface.co/Salesforce/blip-image-captioning-base """ from typing import Any, List, Tuple, Union import requests from langchain.docstore....
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/image_captions.html
892dc74069a0-1
model = BlipForConditionalGeneration.from_pretrained(self.blip_model) results = [] for path_image in self.image_paths: caption, metadata = self._get_captions_and_metadata( model=model, processor=processor, path_image=path_image ) doc = Document(page_co...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/image_captions.html
f214e903783e-0
Source code for langchain.document_loaders.url """Loader that uses unstructured to load HTML files.""" import logging from typing import Any, List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader logger = logging.getLogger(__name__) [docs]class UnstructuredURLLoade...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/url.html
f214e903783e-1
"The headers parameter is ignored" ) self.urls = urls self.continue_on_failure = continue_on_failure self.headers = headers self.unstructured_kwargs = unstructured_kwargs def __is_headers_available_for_html(self) -> bool: _unstructured_version = self.__version...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/url.html
f214e903783e-2
for url in self.urls: try: if self.__is_non_html_available(): if self.__is_headers_available_for_non_html(): elements = partition( url=url, headers=self.headers, **self.unstructured_kwargs ) ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/url.html
841fbb9d2262-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...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/gcs_file.html
841fbb9d2262-1
# Download the file to a destination blob.download_to_filename(file_path) loader = UnstructuredFileLoader(file_path) return loader.load() By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 26, 2023.
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/gcs_file.html
3415c310527e-0
Source code for langchain.document_loaders.unstructured """Loader that uses unstructured to load files.""" from abc import ABC, abstractmethod from typing import IO, Any, List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader def satisfies_min_unstructured_version(m...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/unstructured.html
3415c310527e-1
raise ValueError( "unstructured package not found, please install it with " "`pip install unstructured`" ) _valid_modes = {"single", "elements"} if mode not in _valid_modes: raise ValueError( f"Got {mode} for `mode`, but should be o...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/unstructured.html
3415c310527e-2
metadata["category"] = element.category docs.append(Document(page_content=str(element), metadata=metadata)) elif self.mode == "single": metadata = self._get_metadata() text = "\n\n".join([str(el) for el in elements]) docs = [Document(page_content=text, metadat...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/unstructured.html
3415c310527e-3
"""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.file, **self.unstructured_kwargs) def _get_metadata(self) -> dict: ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/unstructured.html
807692a7e52a-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...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/college_confidential.html
18a3133cca94-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 def concatenate_rows(date: str, sender: str, text: str) -> str: """Combine message information i...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/whatsapp_chat.html
18a3133cca94-1
metadata = {"source": str(p)} return [Document(page_content=text_content, metadata=metadata)] By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 26, 2023.
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/whatsapp_chat.html
c19df8c53fe7-0
Source code for langchain.document_loaders.bigquery from typing import List, Optional from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class BigQueryLoader(BaseLoader): """Loads a query result from BigQuery into a list of documents. Each document repr...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/bigquery.html
c19df8c53fe7-1
docs: List[Document] = [] page_content_columns = self.page_content_columns metadata_columns = self.metadata_columns if page_content_columns is None: page_content_columns = [column.name for column in query_result.schema] if metadata_columns is None: metadata_column...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/bigquery.html
845348a7b951-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...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/url_selenium.html
845348a7b951-1
import selenium # noqa:F401 except ImportError: raise ValueError( "selenium package not found, please install it with " "`pip install selenium`" ) try: import unstructured # noqa:F401 except ImportError: raise Valu...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/url_selenium.html
845348a7b951-2
from selenium.webdriver.firefox.options import Options as FirefoxOptions firefox_options = FirefoxOptions() if self.headless: firefox_options.add_argument("--headless") if self.executable_path is None: return Firefox(options=firefox_options) ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/url_selenium.html
fdea162983c9-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...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/notebook.html
fdea162983c9-1
output = output[0]["text"] min_output = min(max_output_length, len(output)) return ( f"'{cell_type}' cell: '{source}'\n with " f"output: '{output[:min_output]}'\n\n" ) else: return f"'{cell_type}' cell: '{source}'\n\n" return "" def rem...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/notebook.html
fdea162983c9-2
self.traceback = traceback [docs] def load( self, ) -> List[Document]: """Load documents.""" try: import pandas as pd except ImportError: raise ValueError( "pandas is needed for Notebook Loader, " "please install with `pip in...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/notebook.html
f08f319db552-0
Source code for langchain.document_loaders.apify_dataset """Logic for loading documents from Apify datasets.""" from typing import Any, Callable, Dict, List from pydantic import BaseModel, root_validator from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/apify_dataset.html
f08f319db552-1
"""Validate environment.""" try: from apify_client import ApifyClient values["apify_client"] = ApifyClient() except ImportError: raise ValueError( "Could not import apify-client Python package. " "Please install it with `pip install api...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/apify_dataset.html
3c6c6597410e-0
Source code for langchain.document_loaders.airbyte_json """Loader that loads local airbyte json files.""" import json from typing import Any, List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader def _stringify_value(val: Any) -> str: if isinstance(val, str): ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/airbyte_json.html
3c6c6597410e-1
metadata = {"source": self.file_path} return [Document(page_content=text, metadata=metadata)] By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 26, 2023.
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/airbyte_json.html
f1faa78e8b97-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_...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/email.html
f1faa78e8b97-1
""" def __init__(self, file_path: str): """Initialize with file path.""" self.file_path = file_path if not os.path.isfile(self.file_path): raise ValueError("File path %s is not a valid file" % self.file_path) try: import extract_msg # noqa:F401 except...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/email.html
b188a50c7489-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...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/srt.html
2432384b947b-0
Source code for langchain.document_loaders.epub """Loader that loads EPub files.""" from typing import List from langchain.document_loaders.unstructured import ( UnstructuredFileLoader, satisfies_min_unstructured_version, ) [docs]class UnstructuredEPubLoader(UnstructuredFileLoader): """Loader that uses unst...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/epub.html
bd91598b218d-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....
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/url_playwright.html
bd91598b218d-1
"`pip install unstructured`" ) self.urls = urls self.continue_on_failure = continue_on_failure self.headless = headless self.remove_selectors = remove_selectors [docs] def load(self) -> List[Document]: """Load the specified URLs using Playwright and create Document...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/url_playwright.html
bd91598b218d-2
) else: raise e browser.close() return docs By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 26, 2023.
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/url_playwright.html
f7bed71f591e-0
Source code for langchain.document_loaders.discord """Load from Discord chat dump""" from __future__ import annotations from typing import TYPE_CHECKING, List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader if TYPE_CHECKING: import pandas as pd [docs]class Dis...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/discord.html
0d6985897aed-0
Source code for langchain.document_loaders.hugging_face_dataset """Loader that loads HuggingFace datasets.""" from typing import List, Mapping, Optional, Sequence, Union from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class HuggingFaceDatasetLoader(BaseLoade...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/hugging_face_dataset.html
0d6985897aed-1
keep_in_memory: Whether to copy the dataset in-memory. save_infos: Save the dataset information (checksums/size/splits/...). use_auth_token: Bearer token for remote files on the Datasets Hub. num_proc: Number of processes. """ self.path = path self.page_conten...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/hugging_face_dataset.html
0d6985897aed-2
Document( page_content=row.pop(self.page_content_column), metadata=row, ) for key in dataset.keys() for row in dataset[key] ] return docs By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 26, 20...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/hugging_face_dataset.html
4b9a43ecddd7-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...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/python.html
9ab67f335587-0
Source code for langchain.document_loaders.bilibili import json import re import warnings from typing import List, Tuple import requests from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class BiliBiliLoader(BaseLoader): """Loader that loads bilibili trans...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/bilibili.html
9ab67f335587-1
except AttributeError: 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}) # Get subtitle url subtitle = video_info.pop("subti...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/bilibili.html
85a93ca3ea2a-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...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
85a93ca3ea2a-1
bbrouter: str, load_all_recursively: bool = True, basic_auth: Optional[Tuple[str, str]] = None, cookies: Optional[dict] = None, ): """Initialize with blackboard course url. The BbRouter cookie is required for most blackboard courses. Args: blackboard_cours...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
85a93ca3ea2a-2
Raises: ImportError: If BeautifulSoup4 is not installed. """ try: import bs4 # noqa: F401 except ImportError: raise ImportError( "BeautifulSoup4 is required for BlackboardLoader. " "Please install it with `pip install beautiful...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html