id stringlengths 14 15 | text stringlengths 35 2.51k | source stringlengths 61 154 |
|---|---|---|
c33ab562d371-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
[docs]def concatenate_cells(
cell: dict, includ... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/notebook.html |
c33ab562d371-1 | )
else:
return f"'{cell_type}' cell: '{source}'\n\n"
return ""
[docs]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, li... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/notebook.html |
c33ab562d371-2 | filtered_data = data[["cell_type", "source", "outputs"]]
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
... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/notebook.html |
aeffdd606780-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/image_captions.html |
aeffdd606780-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/image_captions.html |
0f0d5f604f10-0 | Source code for langchain.document_loaders.excel
"""Loader that loads Microsoft Excel files."""
from typing import Any, List
from langchain.document_loaders.unstructured import (
UnstructuredFileLoader,
validate_unstructured_version,
)
[docs]class UnstructuredExcelLoader(UnstructuredFileLoader):
"""Loader t... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/excel.html |
1f82cc630a5c-0 | Source code for langchain.document_loaders.srt
"""Loader for .srt (subtitle) files."""
from typing import List
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
[docs]class SRTLoader(BaseLoader):
"""Loader for .srt (subtitle) files."""
def __init__(self, fil... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/srt.html |
b58f1a1db2f3-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/azlyrics.html |
26d081d42563-0 | Source code for langchain.document_loaders.imsdb
"""Loader that loads IMSDb."""
from typing import List
from langchain.docstore.document import Document
from langchain.document_loaders.web_base import WebBaseLoader
[docs]class IMSDbLoader(WebBaseLoader):
"""Loader that loads IMSDb webpages."""
[docs] def load(se... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/imsdb.html |
8aed709a1a95-0 | Source code for langchain.document_loaders.azure_blob_storage_file
"""Loading logic for loading documents from an Azure Blob Storage file."""
import os
import tempfile
from typing import List
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
from langchain.document_... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/azure_blob_storage_file.html |
68ddcace28e2-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/azure_blob_storage_container.html |
db19e3cce227-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... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/hn.html |
db19e3cce227-1 | title = lineItem.find("span", {"class": "titleline"}).text.strip()
metadata = {
"source": self.web_path,
"title": title,
"link": link,
"ranking": ranking,
}
documents.append(
Document(
... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/hn.html |
a0c643dda175-0 | Source code for langchain.document_loaders.readthedocs
"""Loader that loads ReadTheDocs documentation directory dump."""
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 ReadT... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/readthedocs.html |
a0c643dda175-1 | from bs4 import BeautifulSoup
except ImportError:
raise ImportError(
"Could not import python packages. "
"Please install it with `pip install beautifulsoup4`. "
)
try:
_ = BeautifulSoup(
"<html><body>Parser builder libr... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/readthedocs.html |
a0c643dda175-2 | if text is not None:
break
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 |
d7ef28caa549-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/arxiv.html |
8c84e294c480-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/bibtex.html |
8c84e294c480-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/bibtex.html |
8c84e294c480-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/bibtex.html |
4071e9d50bbe-0 | Source code for langchain.document_loaders.obsidian
"""Loader that loads Obsidian directory dump."""
import re
from pathlib import Path
from typing import List
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
[docs]class ObsidianLoader(BaseLoader):
"""Loader th... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/obsidian.html |
4071e9d50bbe-1 | 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)
metadata = {
... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/obsidian.html |
11d8f6ed9ded-0 | Source code for langchain.document_loaders.github
from abc import ABC
from datetime import datetime
from typing import Dict, Iterator, List, Literal, Optional, Union
import requests
from pydantic import BaseModel, root_validator, validator
from langchain.docstore.document import Document
from langchain.document_loaders... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/github.html |
11d8f6ed9ded-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 |
11d8f6ed9ded-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 |
11d8f6ed9ded-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 |
11d8f6ed9ded-4 | return query_params
@property
def url(self) -> str:
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 |
a38dc147fe28-0 | Source code for langchain.document_loaders.url_playwright
"""Loader that uses Playwright to load a page, then uses unstructured to load the html.
"""
import logging
from typing import List, Optional
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
logger = logging.... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/url_playwright.html |
a38dc147fe28-1 | [docs] def load(self) -> List[Document]:
"""Load the specified URLs using Playwright and create Document instances.
Returns:
List[Document]: A list of Document instances with loaded content.
"""
from playwright.sync_api import sync_playwright
from unstructured.part... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/url_playwright.html |
886cbfe2564e-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/joplin.html |
886cbfe2564e-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/joplin.html |
886cbfe2564e-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()) | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/joplin.html |
83f0d79b476c-0 | Source code for langchain.document_loaders.wikipedia
from typing import List, Optional
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
from langchain.utilities.wikipedia import WikipediaAPIWrapper
[docs]class WikipediaLoader(BaseLoader):
"""Loads a query resul... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/wikipedia.html |
83f0d79b476c-1 | Loads the query result from Wikipedia into a list of Documents.
Returns:
List[Document]: A list of Document objects representing the loaded
Wikipedia pages.
"""
client = WikipediaAPIWrapper(
lang=self.lang,
top_k_results=self.load_max_docs,
... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/wikipedia.html |
976d1da5433f-0 | Source code for langchain.document_loaders.onedrive
"""Loader that loads data from OneDrive"""
from __future__ import annotations
import logging
import os
import tempfile
from enum import Enum
from pathlib import Path
from typing import TYPE_CHECKING, Dict, List, Optional, Type, Union
from pydantic import BaseModel, Ba... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/onedrive.html |
976d1da5433f-1 | mime_types_mapping[
file_type.value
] = "application/vnd.openxmlformats-officedocument.wordprocessingml.document" # noqa: E501
elif file_type.value == "pdf":
mime_types_mapping[file_type.value] = "application/pdf"
return mime_types_mapping
[docs]c... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/onedrive.html |
976d1da5433f-2 | )
account = Account(
credentials=(
self.settings.client_id,
self.settings.client_secret.get_secret_value(),
),
scopes=SCOPES,
token_backend=token_backend,
**{"raise_http_errors": False},
... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/onedrive.html |
976d1da5433f-3 | folder (Type[Folder]): The folder object to load the documents from.
Returns:
List[Document]: A list of Document objects representing
the loaded documents.
"""
docs = []
file_types = _SupportedFileTypes(file_types=["doc", "docx", "pdf"])
file_mime_types = ... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/onedrive.html |
976d1da5433f-4 | logging.warning(
"There isn't a file with "
f"object_id {object_id} in drive {drive}."
)
continue
if file.is_file:
if file.mime_type in list(file_mime_types.values()):
load... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/onedrive.html |
dd895abc9fee-0 | Source code for langchain.document_loaders.rst
"""Loader that loads RST files."""
from typing import Any, List
from langchain.document_loaders.unstructured import (
UnstructuredFileLoader,
validate_unstructured_version,
)
[docs]class UnstructuredRSTLoader(UnstructuredFileLoader):
"""Loader that uses unstruc... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/rst.html |
b5d5f4de4c2a-0 | Source code for langchain.document_loaders.diffbot
"""Loader that uses Diffbot to load webpages in text format."""
import logging
from typing import Any, List
import requests
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
logger = logging.getLogger(__name__)
[doc... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/diffbot.html |
b5d5f4de4c2a-1 | text = data["objects"][0]["text"] if "objects" in data else ""
metadata = {"source": url}
docs.append(Document(page_content=text, metadata=metadata))
except Exception as e:
if self.continue_on_failure:
logger.error(f"Error fetching or proce... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/diffbot.html |
c9cde57fc875-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/rtf.html |
4fd2ef9be7d5-0 | Source code for langchain.document_loaders.email
"""Loader that loads email files."""
import os
from typing import List
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
from langchain.document_loaders.unstructured import (
UnstructuredFileLoader,
satisfies_... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/email.html |
4fd2ef9be7d5-1 | "`pip install extract_msg`"
)
[docs] def load(self) -> List[Document]:
"""Load data into document objects."""
import extract_msg
msg = extract_msg.Message(self.file_path)
return [
Document(
page_content=msg.body,
metadata={
... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/email.html |
6ff14a1a07af-0 | Source code for langchain.document_loaders.html
"""Loader that uses unstructured to load HTML files."""
from typing import List
from langchain.document_loaders.unstructured import UnstructuredFileLoader
[docs]class UnstructuredHTMLLoader(UnstructuredFileLoader):
"""Loader that uses unstructured to load HTML files."... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/html.html |
980a829fe0e3-0 | Source code for langchain.document_loaders.org_mode
"""Loader that loads Org-Mode files."""
from typing import Any, List
from langchain.document_loaders.unstructured import (
UnstructuredFileLoader,
validate_unstructured_version,
)
[docs]class UnstructuredOrgModeLoader(UnstructuredFileLoader):
"""Loader tha... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/org_mode.html |
0c1b58b8a68c-0 | Source code for langchain.document_loaders.max_compute
from __future__ import annotations
from typing import Any, Iterator, List, Optional, Sequence
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
from langchain.utilities.max_compute import MaxComputeAPIWrapper
[d... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/max_compute.html |
0c1b58b8a68c-1 | given parameters.
Args:
query: SQL query to execute.
endpoint: MaxCompute endpoint.
project: A project is a basic organizational unit of MaxCompute, which is
similar to a database.
access_id: MaxCompute access ID. Should be passed in directly or se... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/max_compute.html |
110c23792f35-0 | Source code for langchain.document_loaders.weather
"""Simple reader that reads weather data from OpenWeatherMap API"""
from __future__ import annotations
from datetime import datetime
from typing import Iterator, List, Optional, Sequence
from langchain.docstore.document import Document
from langchain.document_loaders.b... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/weather.html |
d6a939732827-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/roam.html |
07a96cf9ea04-0 | Source code for langchain.document_loaders.csv_loader
import csv
from typing import Any, Dict, List, Optional
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
from langchain.document_loaders.unstructured import (
UnstructuredFileLoader,
validate_unstructure... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/csv_loader.html |
07a96cf9ea04-1 | with open(self.file_path, newline="", encoding=self.encoding) as csvfile:
csv_reader = csv.DictReader(csvfile, **self.csv_args) # type: ignore
for i, row in enumerate(csv_reader):
content = "\n".join(f"{k.strip()}: {v.strip()}" for k, v in row.items())
try:
... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/csv_loader.html |
7dfc5328d360-0 | Source code for langchain.document_loaders.json_loader
"""Loader that loads data from JSON."""
import json
from pathlib import Path
from typing import Any, Callable, Dict, List, Optional, Union
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
[docs]class JSONLoader... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/json_loader.html |
7dfc5328d360-1 | """
try:
import jq # noqa:F401
except ImportError:
raise ImportError(
"jq package not found, please install it with `pip install jq`"
)
self.file_path = Path(file_path).resolve()
self._jq_schema = jq.compile(jq_schema)
self._co... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/json_loader.html |
7dfc5328d360-2 | else:
content = sample
if self._text_content and not isinstance(content, str):
raise ValueError(
f"Expected page_content is string, got {type(content)} instead. \
Set `text_content=False` if the desired input for \
`page_content` is... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/json_loader.html |
5dd96960553f-0 | Source code for langchain.document_loaders.figma
"""Loader that loads Figma files json dump."""
import json
import urllib.request
from typing import Any, List
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
from langchain.utils import stringify_dict
[docs]class Fi... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/figma.html |
db5534312ee2-0 | Source code for langchain.document_loaders.open_city_data
from typing import Iterator, List
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
[docs]class OpenCityDataLoader(BaseLoader):
"""Loader that loads Open city data."""
def __init__(self, city_id: str,... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/open_city_data.html |
04936c49ea27-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/spreedly.html |
04936c49ea27-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/spreedly.html |
1346b9b2c78e-0 | Source code for langchain.document_loaders.mhtml
"""Loader to load MHTML files, enriching metadata with page title."""
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(__nam... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/mhtml.html |
1346b9b2c78e-1 | for part in parts:
if part.get_content_type() == "text/html":
html = part.get_payload(decode=True).decode()
soup = BeautifulSoup(html, **self.bs_kwargs)
text = soup.get_text(self.get_text_separator)
if soup.title:
... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/mhtml.html |
f7fe4dfd9d52-0 | Source code for langchain.document_loaders.image
"""Loader that loads image files."""
from typing import List
from langchain.document_loaders.unstructured import UnstructuredFileLoader
[docs]class UnstructuredImageLoader(UnstructuredFileLoader):
"""Loader that uses unstructured to load image files, such as PNGs and... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/image.html |
fd79a6d5d7bd-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
[docs]def concatenate_rows(row: d... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/facebook_chat.html |
f9534f846850-0 | Source code for langchain.document_loaders.notion
"""Loader that loads Notion directory dump."""
from pathlib import Path
from typing import List
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
[docs]class NotionDirectoryLoader(BaseLoader):
"""Loader that load... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/notion.html |
aa6a0daf8057-0 | Source code for langchain.document_loaders.reddit
"""Reddit document loader."""
from __future__ import annotations
from typing import TYPE_CHECKING, Iterable, List, Optional, Sequence
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
if TYPE_CHECKING:
import pra... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/reddit.html |
aa6a0daf8057-1 | if self.mode == "subreddit":
for search_query in self.search_queries:
for category in self.categories:
docs = self._subreddit_posts_loader(
search_query=search_query, category=category, reddit=reddit
)
result... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/reddit.html |
aa6a0daf8057-2 | method = getattr(user.submissions, category)
cat_posts = method(limit=self.number_posts)
"""Format reddit posts into a string."""
for post in cat_posts:
metadata = {
"post_subreddit": post.subreddit_name_prefixed,
"post_category": category,
... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/reddit.html |
00d3d2559258-0 | Source code for langchain.document_loaders.directory
"""Loading logic for loading documents from a directory."""
import concurrent
import logging
from pathlib import Path
from typing import Any, List, Optional, Type, Union
from langchain.docstore.document import Document
from langchain.document_loaders.base import Base... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/directory.html |
00d3d2559258-1 | self.loader_kwargs = loader_kwargs
self.silent_errors = silent_errors
self.recursive = recursive
self.show_progress = show_progress
self.use_multithreading = use_multithreading
self.max_concurrency = max_concurrency
[docs] def load_file(
self, item: Path, path: Path, d... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/directory.html |
00d3d2559258-2 | logger.warning(e)
else:
raise e
if self.use_multithreading:
with concurrent.futures.ThreadPoolExecutor(
max_workers=self.max_concurrency
) as executor:
executor.map(lambda i: self.load_file(i, p, docs, pbar), items)
... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/directory.html |
c08570cb9afa-0 | Source code for langchain.document_loaders.text
import logging
from typing import List, Optional
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
from langchain.document_loaders.helpers import detect_file_encodings
logger = logging.getLogger(__name__)
[docs]class T... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/text.html |
c08570cb9afa-1 | except Exception as e:
raise RuntimeError(f"Error loading {self.file_path}") from e
metadata = {"source": self.file_path}
return [Document(page_content=text, metadata=metadata)] | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/text.html |
e83a36211900-0 | Source code for langchain.document_loaders.confluence
"""Load Data from a Confluence Space"""
import logging
from enum import Enum
from io import BytesIO
from typing import Any, Callable, Dict, List, Optional, Union
from tenacity import (
before_sleep_log,
retry,
stop_after_attempt,
wait_exponential,
)
... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html |
e83a36211900-1 | SVG, Word and Excel.
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 ... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html |
e83a36211900-2 | :type min_retry_seconds: Optional[int], optional
:param max_retry_seconds: defaults to 10
:type max_retry_seconds: Optional[int], optional
:param confluence_kwargs: additional kwargs to initialize confluence with
:type confluence_kwargs: dict, optional
:raises ValueError: Errors while validating in... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html |
e83a36211900-3 | url=url, oauth2=oauth2, cloud=cloud, **confluence_kwargs
)
elif token:
self.confluence = Confluence(
url=url, token=token, cloud=cloud, **confluence_kwargs
)
else:
self.confluence = Confluence(
url=url,
usern... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html |
e83a36211900-4 | "keys to the oauth2 dictionary. key values should be "
"`['access_token', 'access_token_secret', 'consumer_key', 'key_cert']`"
)
if token and (api_key or username or oauth2):
errors.append(
"Cannot provide a value for `token` and a value for `api_key`, "
... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html |
e83a36211900-5 | :type include_restricted_content: bool, optional
:param include_archived_content: Whether to include archived content,
defaults to False
:type include_archived_content: bool, optional
:param include_attachments: defaults to False
:type include_att... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html |
e83a36211900-6 | expand=content_format.value,
)
docs += self.process_pages(
pages,
include_restricted_content,
include_attachments,
include_comments,
content_format,
ocr_languages,
)
if label:
... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html |
e83a36211900-7 | )(self.confluence.get_page_by_id)
page = get_page(page_id=page_id, expand=content_format.value)
if not include_restricted_content and not self.is_public_page(page):
continue
doc = self.process_page(
page,
include... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html |
e83a36211900-8 | 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/pagination-in-the-rest-api/
:param retrieval_method: Function us... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html |
e83a36211900-9 | pages: List[dict],
include_restricted_content: bool,
include_attachments: bool,
include_comments: bool,
content_format: ContentFormat,
ocr_languages: Optional[str] = None,
) -> List[Document]:
"""Process a list of pages into a list of documents."""
docs = []
... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html |
e83a36211900-10 | BeautifulSoup(comment["body"]["view"]["value"], "lxml").get_text(
" ", strip=True
)
for comment in comments
]
text = text + "".join(comment_texts)
return Document(
page_content=text,
metadata={
"t... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html |
e83a36211900-11 | ".wordprocessingml.document"
):
text = title + self.process_doc(absolute_url)
elif media_type == "application/vnd.ms-excel":
text = title + self.process_xls(absolute_url)
elif media_type == "image/svg+xml":
text = title + self.process_s... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html |
e83a36211900-12 | try:
import pytesseract # noqa: F401
from PIL import Image # noqa: F401
except ImportError:
raise ImportError(
"`pytesseract` or `Pillow` package not found, "
"please run `pip install pytesseract Pillow`"
)
response = self... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html |
e83a36211900-13 | text = ""
if (
response.status_code != 200
or response.content == b""
or response.content is None
):
return text
workbook = xlrd.open_workbook(file_contents=response.content)
for sheet in workbook.sheets():
text += f"{sheet.name... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html |
e83a36211900-14 | img_data.seek(0)
image = Image.open(img_data)
return pytesseract.image_to_string(image, lang=ocr_languages) | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html |
1e2f27bf4d4f-0 | Source code for langchain.document_loaders.airbyte_json
"""Loader that loads local airbyte json files."""
import json
from typing import List
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
from langchain.utils import stringify_dict
[docs]class AirbyteJSONLoader(B... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/airbyte_json.html |
8e37a95f7b35-0 | Source code for langchain.document_loaders.git
import os
from typing import Callable, List, Optional
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
[docs]class GitLoader(BaseLoader):
"""Loads files from a Git repository into a list of documents.
Repositor... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/git.html |
8e37a95f7b35-1 | else:
repo = Repo(self.repo_path)
repo.git.checkout(self.branch)
docs: List[Document] = []
for item in repo.tree().traverse():
if not isinstance(item, Blob):
continue
file_path = os.path.join(self.repo_path, item.path)
ignored_f... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/git.html |
1fdf466dcde4-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html |
1fdf466dcde4-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html |
1fdf466dcde4-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html |
1fdf466dcde4-3 | # Get the folder path
folder_path = Path(".") / course_name_clean
return str(folder_path)
def _get_documents(self, soup: Any) -> List[Document]:
"""Fetch content from page and return Documents.
Args:
soup: BeautifulSoup4 soup object.
Returns:
List of d... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html |
1fdf466dcde4-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html |
1fdf466dcde4-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html |
159ac61bed59-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/ifixit.html |
159ac61bed59-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/ifixit.html |
159ac61bed59-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/ifixit.html |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.