id
stringlengths
14
16
text
stringlengths
36
2.73k
source
stringlengths
49
117
71399267f5a8-1
"""Load documents.""" ps = list(Path(self.file_path).glob("**/*.md")) docs = [] for p in ps: with open(p, encoding=self.encoding) as f: text = f.read() front_matter = self._parse_front_matter(text) text = self._remove_front_matter(text) ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/obsidian.html
5a3b3df2013f-0
Source code for langchain.document_loaders.youtube """Loader that loads YouTube transcript.""" from __future__ import annotations import logging from pathlib import Path from typing import Any, Dict, List, Optional from urllib.parse import parse_qs, urlparse from pydantic import root_validator from pydantic.dataclasses...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
5a3b3df2013f-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
5a3b3df2013f-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
5a3b3df2013f-3
self.continue_on_failure = continue_on_failure [docs] @staticmethod def extract_video_id(youtube_url: str) -> str: """Extract video id from common YT urls.""" video_id = _parse_video_id(youtube_url) if not video_id: raise ValueError( f"Could not determine the v...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
5a3b3df2013f-4
transcript = en_transcript.translate(self.language) transcript_pieces = transcript.fetch() transcript = " ".join([t["text"].strip(" ") for t in transcript_pieces]) return [Document(page_content=transcript, metadata=metadata)] def _get_video_info(self) -> dict: """Get important video ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
5a3b3df2013f-5
from langchain.document_loaders import GoogleApiYoutubeLoader google_api_client = GoogleApiClient( service_account_path=Path("path_to_your_sec_file.json") ) loader = GoogleApiYoutubeLoader( google_api_client=google_api_client, channel_n...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
5a3b3df2013f-6
raise ValueError("Must specify either channel_name or video_ids") return values def _get_transcripe_for_video_id(self, video_id: str) -> str: from youtube_transcript_api import NoTranscriptFound, YouTubeTranscriptApi transcript_list = YouTubeTranscriptApi.list_transcripts(video_id) t...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
5a3b3df2013f-7
try: from youtube_transcript_api import ( NoTranscriptFound, TranscriptsDisabled, ) except ImportError: raise ImportError( "You must run" "`pip install --upgrade " "youtube-transcript-api` " ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
5a3b3df2013f-8
return video_ids [docs] def load(self) -> List[Document]: """Load documents.""" document_list = [] if self.channel_name: document_list.extend(self._get_document_for_channel(self.channel_name)) elif self.video_ids: document_list.extend( [ ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/youtube.html
d0a882a0fe35-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
d0a882a0fe35-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
d0a882a0fe35-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
8d8ab572ef57-0
Source code for langchain.document_loaders.toml import json from pathlib import Path from typing import Iterator, List, Union from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class TomlLoader(BaseLoader): """ A TOML document loader that inherits from ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/toml.html
8d8ab572ef57-1
By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 25, 2023.
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/toml.html
9431c73706d0-0
Source code for langchain.document_loaders.blackboard """Loader that loads all documents from a blackboard course.""" import contextlib import re from pathlib import Path from typing import Any, List, Optional, Tuple from urllib.parse import unquote from langchain.docstore.document import Document from langchain.docume...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
9431c73706d0-1
): """Initialize with blackboard course url. The BbRouter cookie is required for most blackboard courses. Args: blackboard_course_url: Blackboard course url. bbrouter: BbRouter cookie. load_all_recursively: If True, load all documents recursively. ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
9431c73706d0-2
"""Load data into document objects. Returns: List of documents. """ if self.load_all_recursively: soup_info = self.scrape() self.folder_path = self._get_folder_path(soup_info) relative_paths = self._get_paths(soup_info) documents = [] ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
9431c73706d0-3
) # Get the folder path folder_path = Path(".") / course_name_clean return str(folder_path) def _get_documents(self, soup: Any) -> List[Document]: """Fetch content from page and return Documents. Args: soup: BeautifulSoup4 soup object. Returns: ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
9431c73706d0-4
Path(self.folder_path).mkdir(parents=True, exist_ok=True) # Download all attachments for attachment in attachments: self.download(attachment) def _load_documents(self) -> List[Document]: """Load all documents in the folder. Returns: List of documents. ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
9431c73706d0-5
"""Parse the filename from a url. Args: url: Url to parse the filename from. Returns: The filename. """ if (url_path := Path(url)) and url_path.suffix == ".pdf": return url_path.name else: return self._parse_filename_from_url(url) ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
9431c73706d0-6
By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 25, 2023.
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
20770aedc9e7-0
Source code for langchain.document_loaders.docugami """Loader that loads processed documents from Docugami.""" import io import logging import os import re from pathlib import Path from typing import Any, Dict, List, Mapping, Optional, Sequence, Union import requests from pydantic import BaseModel, root_validator from ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html
20770aedc9e7-1
if values.get("file_paths") and values.get("docset_id"): raise ValueError("Cannot specify both file_paths and remote API docset_id") if not values.get("file_paths") and not values.get("docset_id"): raise ValueError("Must specify either file_paths or remote API docset_id") if valu...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html
20770aedc9e7-2
ancestor_chain = chunk.xpath("ancestor-or-self::*") return "/" + "/".join(_xpath_qname_for_chunk(x) for x in ancestor_chain) def _structure_value(node: Any) -> str: """Get the structure value for a node.""" structure = ( "table" if node.tag == ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html
20770aedc9e7-3
"""Create a Document from a node and text.""" metadata = { XPATH_KEY: _xpath_for_chunk(node), DOCUMENT_ID_KEY: document["id"], DOCUMENT_NAME_KEY: document["name"], STRUCTURE_KEY: node.attrib.get("structure", ""), TAG_KEY: re.sub...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html
20770aedc9e7-4
while url: response = requests.get( url, headers={"Authorization": f"Bearer {self.access_token}"}, ) if response.ok: data = response.json() all_documents.extend(data["documents"]) url = data.get("next", N...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html
20770aedc9e7-5
data={}, ) if response.ok: data = response.json() all_artifacts.extend(data["artifacts"]) url = data.get("next", None) else: raise Exception( f"Failed to download {url} (status: {response.status_code}...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html
20770aedc9e7-6
per_file_metadata[doc_id] = metadata else: raise Exception( f"Failed to download {artifact_url}/content " + "(status: {response.status_code})" ) return per_file_metadata def _load_chunks_for_document( ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html
20770aedc9e7-7
for project in _project_details: metadata = self._metadata_for_project(project) combined_project_metadata.update(metadata) for doc in _document_details: doc_metadata = combined_project_metadata.get(doc["id"]) chunks += self._load_chunks...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html
71e194625d5f-0
Source code for langchain.document_loaders.notiondb """Notion DB loader for langchain""" from typing import Any, Dict, List, Optional import requests from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader NOTION_BASE_URL = "https://api.notion.com/v1" DATABASE_URL = NOTIO...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/notiondb.html
71e194625d5f-1
Returns: List[Document]: List of documents. """ page_ids = self._retrieve_page_ids() return list(self.load_page(page_id) for page_id in page_ids) def _retrieve_page_ids( self, query_dict: Dict[str, Any] = {"page_size": 100} ) -> List[str]: """Get all the pages...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/notiondb.html
71e194625d5f-2
value = ( [item["name"] for item in prop_data["multi_select"]] if prop_data["multi_select"] else [] ) elif prop_type == "url": value = prop_data["url"] else: value = None metad...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/notiondb.html
71e194625d5f-3
) -> Any: res = requests.request( method, url, headers=self.headers, json=query_dict, timeout=self.request_timeout_sec, ) res.raise_for_status() return res.json() By Harrison Chase © Copyright 2023, Harrison Chase. ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/notiondb.html
0baeea5d10bc-0
Source code for langchain.document_loaders.psychic """Loader that loads documents from Psychic.dev.""" from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class PsychicLoader(BaseLoader): """Loader that loads documents from Psychic.de...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/psychic.html
bbb51e91970d-0
Source code for langchain.document_loaders.hugging_face_dataset """Loader that loads HuggingFace datasets.""" from typing import Iterator, List, Mapping, Optional, Sequence, Union from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class HuggingFaceDatasetLoader...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/hugging_face_dataset.html
bbb51e91970d-1
self.page_content_column = page_content_column self.name = name self.data_dir = data_dir self.data_files = data_files self.cache_dir = cache_dir self.keep_in_memory = keep_in_memory self.save_infos = save_infos self.use_auth_token = use_auth_token self.num...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/hugging_face_dataset.html
0c46e1b4b01e-0
Source code for langchain.document_loaders.tomarkdown """Loader that loads HTML to markdown using 2markdown.""" from __future__ import annotations from typing import Iterator, List import requests from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class ToMarkd...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/tomarkdown.html
7d9103215d2c-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
7d9103215d2c-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
7d9103215d2c-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
483fae5cd434-0
Source code for langchain.document_loaders.bibtex import logging import re from pathlib import Path from typing import Any, Iterator, List, Mapping, Optional from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.utilities.bibtex import BibtexparserWrapper...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/bibtex.html
483fae5cd434-1
import fitz parent_dir = Path(self.file_path).parent # regex is useful for Zotero flavor bibtex files file_names = self.file_regex.findall(entry.get("file", "")) if not file_names: return None texts: List[str] = [] for file_name in file_names: try:...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/bibtex.html
483fae5cd434-2
yield doc [docs] def load(self) -> List[Document]: """Load bibtex file documents from the given bibtex file path. See https://bibtexparser.readthedocs.io/en/master/ Args: file_path: the path to the bibtex file Returns: a list of documents with the document.page...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/bibtex.html
a9cc7fa3f109-0
Source code for langchain.document_loaders.image_captions """ Loader that loads image captions By default, the loader utilizes the pre-trained BLIP image captioning model. https://huggingface.co/Salesforce/blip-image-captioning-base """ from typing import Any, List, Tuple, Union import requests from langchain.docstore....
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/image_captions.html
a9cc7fa3f109-1
model=model, processor=processor, path_image=path_image ) doc = Document(page_content=caption, metadata=metadata) results.append(doc) return results def _get_captions_and_metadata( self, model: Any, processor: Any, path_image: str ) -> Tuple[str, dict]: ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/image_captions.html
e42429de7c0c-0
Source code for langchain.document_loaders.csv_loader import csv from typing import Dict, List, Optional from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class CSVLoader(BaseLoader): """Loads a CSV file into a list of documents. Each document represen...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/csv_loader.html
e42429de7c0c-1
for i, row in enumerate(csv_reader): content = "\n".join(f"{k.strip()}: {v.strip()}" for k, v in row.items()) try: source = ( row[self.source_column] if self.source_column is not None else self.fi...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/csv_loader.html
762858a68193-0
Source code for langchain.document_loaders.s3_file """Loading logic for loading documents from an s3 file.""" import os import tempfile from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.document_loaders.unstructured import Unst...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/s3_file.html
3ab14b83dc38-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
3ab14b83dc38-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
3ab14b83dc38-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
3ab14b83dc38-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
3ab14b83dc38-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
3ab14b83dc38-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
3ab14b83dc38-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
3ab14b83dc38-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
a2fd57d4bb43-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
bd055446736b-0
Source code for langchain.document_loaders.apify_dataset """Logic for loading documents from Apify datasets.""" from typing import Any, Callable, Dict, List from pydantic import BaseModel, root_validator from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/apify_dataset.html
bd055446736b-1
) return values [docs] def load(self) -> List[Document]: """Load documents.""" dataset_items = self.apify_client.dataset(self.dataset_id).list_items().items return list(map(self.dataset_mapping_function, dataset_items)) By Harrison Chase © Copyright 2023, Harrison Chase. ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/apify_dataset.html
04f56057a9b1-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
04f56057a9b1-1
) metadata = {"source": page.title} docs.append(Document(page_content=text, metadata=metadata)) return docs By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 25, 2023.
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/mediawikidump.html
67165a04205a-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
6fac6c720e7d-0
Source code for langchain.document_loaders.gitbook """Loader that loads GitBook.""" from typing import Any, List, Optional from urllib.parse import urljoin, urlparse from langchain.docstore.document import Document from langchain.document_loaders.web_base import WebBaseLoader [docs]class GitbookLoader(WebBaseLoader): ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/gitbook.html
6fac6c720e7d-1
[docs] def load(self) -> List[Document]: """Fetch text from one single GitBook page.""" if self.load_all_paths: soup_info = self.scrape() relative_paths = self._get_paths(soup_info) documents = [] for path in relative_paths: url = urljoi...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/gitbook.html
b0045ff32776-0
Source code for langchain.document_loaders.blockchain import os import re import time from enum import Enum from typing import List, Optional import requests from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader class BlockchainType(Enum): ETH_MAINNET = "eth-mainnet...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blockchain.html
b0045ff32776-1
""" def __init__( self, contract_address: str, blockchainType: BlockchainType = BlockchainType.ETH_MAINNET, api_key: str = "docs-demo", startToken: str = "", get_all_tokens: bool = False, max_execution_time: Optional[int] = None, ): self.contract_a...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blockchain.html
b0045ff32776-2
tokenId = item["id"]["tokenId"] metadata = { "source": self.contract_address, "blockchain": self.blockchainType, "tokenId": tokenId, } result.append(Document(page_content=content, metadata=metadata)) ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blockchain.html
b0045ff32776-3
else: return str(result) # A smart contract can use different formats for the tokenId @staticmethod def _detect_value_type(tokenId: str) -> str: if isinstance(tokenId, int): return "int" elif tokenId.startswith("0x"): return "hex_0x" elif tokenId.s...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blockchain.html
0a714e6fe228-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
0a714e6fe228-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
2c8348c3a584-0
Source code for langchain.document_loaders.discord """Load from Discord chat dump""" from __future__ import annotations from typing import TYPE_CHECKING, List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader if TYPE_CHECKING: import pandas as pd [docs]class Dis...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/discord.html
b4fa35393cc8-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
0e23db456679-0
Source code for langchain.document_loaders.s3_directory """Loading logic for loading documents from an s3 directory.""" from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.document_loaders.s3_file import S3FileLoader [docs]class ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/s3_directory.html
cf42f3c0567f-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...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/bilibili.html
cf42f3c0567f-1
video_info = sync(v.get_info()) video_info.update({"url": url}) # Get subtitle url subtitle = video_info.pop("subtitle") sub_list = subtitle["list"] if sub_list: sub_url = sub_list[0]["subtitle_url"] result = requests.get(sub_url) raw_sub_title...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/bilibili.html
8690d50e3444-0
Source code for langchain.document_loaders.arxiv from typing import List, Optional from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.utilities.arxiv import ArxivAPIWrapper [docs]class ArxivLoader(BaseLoader): """Loads a query result from arxiv.org...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/arxiv.html
8587847efa06-0
Source code for langchain.document_loaders.odt """Loader that loads Open Office ODT files.""" from typing import Any, List from langchain.document_loaders.unstructured import ( UnstructuredFileLoader, validate_unstructured_version, ) [docs]class UnstructuredODTLoader(UnstructuredFileLoader): """Loader that ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/odt.html
89f2268ea404-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
cda2a3493643-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...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/whatsapp_chat.html
cda2a3493643-1
text_content += concatenate_rows(date, sender, text) metadata = {"source": str(p)} return [Document(page_content=text_content, metadata=metadata)] By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 25, 2023.
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/whatsapp_chat.html
9eba02874626-0
Source code for langchain.document_loaders.stripe """Loader that fetches data from 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_dic...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/stripe.html
9eba02874626-1
if endpoint is None: return [] return self._make_request(endpoint) [docs] def load(self) -> List[Document]: return self._get_resource() By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 25, 2023.
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/stripe.html
0fad0c685406-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
2b162ca078b5-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
4579c86fec72-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
98329631951e-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
bec474582dc3-0
Source code for langchain.document_loaders.ifixit """Loader that loads iFixit data.""" from typing import List, Optional import requests from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.document_loaders.web_base import WebBaseLoader IFIXIT_BASE_URL =...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/ifixit.html
bec474582dc3-1
"""Teardowns are just guides by a different name""" self.page_type = pieces[0] if pieces[0] != "Teardown" else "Guide" if self.page_type == "Guide" or self.page_type == "Answers": self.id = pieces[2] else: self.id = pieces[1] self.web_path = web_path [docs] def...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/ifixit.html
bec474582dc3-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
bec474582dc3-3
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(page_content=text, metadata=...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/ifixit.html
bec474582dc3-4
doc_parts.append("\n - " + part["text"]) for row in data["steps"]: doc_parts.append( "\n\n## " + ( row["title"] if row["title"] != "" else "Step {}".format(row["orderby"]) ) ) ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/ifixit.html
7a42238f791d-0
Source code for langchain.document_loaders.azure_blob_storage_container """Loading logic for loading documents from an Azure Blob Storage container.""" from typing import List from langchain.docstore.document import Document from langchain.document_loaders.azure_blob_storage_file import ( AzureBlobStorageFileLoader...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/azure_blob_storage_container.html
2eccfb8e4898-0
Source code for langchain.document_loaders.duckdb_loader from typing import Dict, List, Optional, cast from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class DuckDBLoader(BaseLoader): """Loads a query result from DuckDB into a list of documents. Each ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/duckdb_loader.html
2eccfb8e4898-1
results = query_result.fetchall() description = cast(list, query_result.description) field_names = [c[0] for c in description] if self.page_content_columns is None: page_content_columns = field_names else: page_content_columns = self.page_c...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/duckdb_loader.html
2b739bc802f0-0
Source code for langchain.llms.huggingface_hub """Wrapper around HuggingFace APIs.""" from typing import Any, Dict, List, Mapping, Optional from pydantic import Extra, root_validator from langchain.callbacks.manager import CallbackManagerForLLMRun from langchain.llms.base import LLM from langchain.llms.utils import enf...
https://python.langchain.com/en/latest/_modules/langchain/llms/huggingface_hub.html
2b739bc802f0-1
"""Configuration for this pydantic object.""" extra = Extra.forbid @root_validator() def validate_environment(cls, values: Dict) -> Dict: """Validate that api key and python package exists in environment.""" huggingfacehub_api_token = get_from_dict_or_env( values, "huggingfac...
https://python.langchain.com/en/latest/_modules/langchain/llms/huggingface_hub.html
2b739bc802f0-2
self, prompt: str, stop: Optional[List[str]] = None, run_manager: Optional[CallbackManagerForLLMRun] = None, ) -> str: """Call out to HuggingFace Hub's inference endpoint. Args: prompt: The prompt to pass into the model. stop: Optional list of stop wor...
https://python.langchain.com/en/latest/_modules/langchain/llms/huggingface_hub.html
662083bd521f-0
Source code for langchain.llms.self_hosted """Run model inference on self-hosted remote hardware.""" import importlib.util import logging import pickle from typing import Any, Callable, List, Mapping, Optional from pydantic import Extra from langchain.callbacks.manager import CallbackManagerForLLMRun from langchain.llm...
https://python.langchain.com/en/latest/_modules/langchain/llms/self_hosted.html
662083bd521f-1
) if device < 0 and cuda_device_count > 0: logger.warning( "Device has %d GPUs available. " "Provide device={deviceId} to `from_model_id` to use available" "GPUs for execution. deviceId is -1 for CPU and " "can be a positive integer ass...
https://python.langchain.com/en/latest/_modules/langchain/llms/self_hosted.html