id stringlengths 14 16 | text stringlengths 31 2.41k | source stringlengths 54 121 |
|---|---|---|
444f45e2bac4-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/notebook.html |
87189c6eb31d-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/gitbook.html |
87189c6eb31d-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/gitbook.html |
f492ec639bad-0 | Source code for langchain.document_loaders.web_base
"""Web base loader class."""
import asyncio
import logging
import warnings
from typing import Any, Dict, Iterator, List, Optional, Union
import aiohttp
import requests
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoa... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/web_base.html |
f492ec639bad-1 | requests_kwargs: Dict[str, Any] = {}
"""kwargs for requests"""
bs_get_text_kwargs: Dict[str, Any] = {}
"""kwargs for beatifulsoup4 get_text"""
def __init__(
self,
web_path: Union[str, List[str]],
header_template: Optional[dict] = None,
verify: Optional[bool] = True,
)... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/web_base.html |
f492ec639bad-2 | return self.web_paths[0]
async def _fetch(
self, url: str, retries: int = 3, cooldown: int = 2, backoff: float = 1.5
) -> str:
# For SiteMap SSL verification
if not self.requests_kwargs.get("verify", True):
connector = aiohttp.TCPConnector(ssl=False)
else:
... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/web_base.html |
f492ec639bad-3 | from tqdm.asyncio import tqdm_asyncio
return await tqdm_asyncio.gather(
*tasks, desc="Fetching pages", ascii=True, mininterval=1
)
except ImportError:
warnings.warn("For better logging of progress, `pip install tqdm`")
return await asyncio.gather(*... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/web_base.html |
f492ec639bad-4 | else:
parser = self.default_parser
self._check_parser(parser)
html_doc = self.session.get(url, verify=self.verify, **self.requests_kwargs)
html_doc.encoding = html_doc.apparent_encoding
return BeautifulSoup(html_doc.text, parser)
[docs] def scrape(self, parser: Union[s... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/web_base.html |
83ee2e20ef7e-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/bilibili.html |
83ee2e20ef7e-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/bilibili.html |
85082a986da9-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 |
85082a986da9-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 |
1a286cdadc1f-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 |
1a286cdadc1f-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 |
29717bd3a3ef-0 | Source code for langchain.document_loaders.dataframe
"""Load from Dataframe object"""
from typing import Any, Iterator, List
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
[docs]class DataFrameLoader(BaseLoader):
"""Load Pandas DataFrames."""
def __init__... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/dataframe.html |
1e0b2795e38e-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 |
1e0b2795e38e-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 |
1e0b2795e38e-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 |
fa40451b96ee-0 | Source code for langchain.document_loaders.onedrive_file
from __future__ import annotations
import tempfile
from typing import TYPE_CHECKING, List
from pydantic import BaseModel, Field
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
from langchain.document_loaders... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/onedrive_file.html |
dbf7075633e6-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/googledrive.html |
dbf7075633e6-1 | # results in pydantic validation errors
file_loader_cls: Any = None
file_loader_kwargs: Dict["str", Any] = {}
@root_validator
def validate_inputs(cls, values: Dict[str, Any]) -> Dict[str, Any]:
"""Validate that either folder_id or document_ids is set, but not both."""
if values.get("fold... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/googledrive.html |
dbf7075633e6-2 | if file_type not in allowed_types:
raise ValueError(
f"Given file type {file_type} is not supported. "
f"Supported values are: {short_names}; and "
f"their full-form names: {full_names}"
)
# repla... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/googledrive.html |
dbf7075633e6-3 | )
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())
elif "GOOGLE_APPLICATION_CREDENTIAL... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/googledrive.html |
dbf7075633e6-4 | metadata = {
"source": (
f"https://docs.google.com/spreadsheets/d/{id}/"
f"edit?gid={sheet['properties']['sheetId']}"
),
"title": f"{spreadsheet['properties']['title']} - {sheet_name}",
"row":... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/googledrive.html |
dbf7075633e6-5 | text = fh.getvalue().decode("utf-8")
metadata = {
"source": f"https://docs.google.com/document/d/{id}/edit",
"title": f"{file.get('name')}",
}
return Document(page_content=text, metadata=metadata)
def _load_documents_from_folder(
self, folder_id: str, *, file_... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/googledrive.html |
dbf7075633e6-6 | else:
pass
return returns
def _fetch_files_recursive(
self, service: Any, folder_id: str
) -> List[Dict[str, Union[str, List[str]]]]:
"""Fetch all files and subfolders recursively."""
results = (
service.files()
.list(
q=f"'... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/googledrive.html |
dbf7075633e6-7 | file = service.files().get(fileId=id, supportsAllDrives=True).execute()
request = service.files().get_media(fileId=id)
fh = BytesIO()
downloader = MediaIoBaseDownload(fh, request)
done = False
while done is False:
status, done = downloader.next_chunk()
if self... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/googledrive.html |
dbf7075633e6-8 | )
elif self.document_ids:
return self._load_documents_from_ids()
else:
return self._load_file_from_ids() | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/googledrive.html |
c5aecdbfd1a3-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 |
f12bc11e9511-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 |
f12bc11e9511-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 |
10eb13830637-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 |
10eb13830637-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 |
a34d55a22a53-0 | Source code for langchain.document_loaders.url_selenium
"""Loader that uses Selenium to load a page, then uses unstructured to load the html.
"""
import logging
from typing import TYPE_CHECKING, List, Literal, Optional, Union
if TYPE_CHECKING:
from selenium.webdriver import Chrome, Firefox
from langchain.docstore.d... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/url_selenium.html |
a34d55a22a53-1 | raise ImportError(
"selenium package not found, please install it with "
"`pip install selenium`"
)
try:
import unstructured # noqa:F401
except ImportError:
raise ImportError(
"unstructured package not found, please ins... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/url_selenium.html |
a34d55a22a53-2 | for arg in self.arguments:
firefox_options.add_argument(arg)
if self.headless:
firefox_options.add_argument("--headless")
if self.binary_location is not None:
firefox_options.binary_location = self.binary_location
if self.executable_pat... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/url_selenium.html |
7267a68914fd-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 |
7267a68914fd-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 |
e6f6f2428701-0 | Source code for langchain.document_loaders.pyspark_dataframe
"""Load from a Spark Dataframe object"""
import itertools
import logging
import sys
from typing import TYPE_CHECKING, Any, Iterator, List, Optional, Tuple
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/pyspark_dataframe.html |
e6f6f2428701-1 | """Gets the amount of "feasible" rows for the DataFrame"""
try:
import psutil
except ImportError as e:
raise ImportError(
"psutil not installed. Please install it with `pip install psutil`."
) from e
row = self.df.limit(1).collect()[0]
... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/pyspark_dataframe.html |
82ff5f80227b-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html |
82ff5f80227b-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html |
82ff5f80227b-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html |
82ff5f80227b-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html |
82ff5f80227b-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html |
82ff5f80227b-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html |
82ff5f80227b-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html |
82ff5f80227b-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html |
2e737ea03e05-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/gcs_file.html |
cd544fe23019-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/facebook_chat.html |
f334071fc0b4-0 | Source code for langchain.document_loaders.modern_treasury
"""Loader that fetches data from Modern Treasury"""
import json
import urllib.request
from base64 import b64encode
from typing import List, Optional
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
from lan... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/modern_treasury.html |
f334071fc0b4-1 | def __init__(
self,
resource: str,
organization_id: Optional[str] = None,
api_key: Optional[str] = None,
) -> None:
self.resource = resource
organization_id = organization_id or get_from_env(
"organization_id", "MODERN_TREASURY_ORGANIZATION_ID"
)
... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/modern_treasury.html |
a9e8ce7c334f-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/s3_file.html |
2e59c0de8151-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 |
2e59c0de8151-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 |
2e59c0de8151-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 |
2e59c0de8151-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 |
2e59c0de8151-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 |
d51fcbd3e856-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/discord.html |
d9d7d3588634-0 | Source code for langchain.document_loaders.fauna
from typing import Iterator, List, Optional, Sequence
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
[docs]class FaunaLoader(BaseLoader):
"""FaunaDB Loader.
Attributes:
query (str): The FQL query st... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/fauna.html |
d9d7d3588634-1 | document_dict = dict(result.items())
page_content = ""
for key, value in document_dict.items():
if key == self.page_content_field:
page_content = value
document: Document = Document(
page_content=page_content... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/fauna.html |
817cbeceb3b8-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 |
afe4f4ed5581-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... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/python.html |
e32be1752e69-0 | Source code for langchain.document_loaders.bigquery
from __future__ import annotations
from typing import TYPE_CHECKING, List, Optional
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
if TYPE_CHECKING:
from google.auth.credentials import Credentials
[docs]clas... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/bigquery.html |
e32be1752e69-1 | self.project = project
self.page_content_columns = page_content_columns
self.metadata_columns = metadata_columns
self.credentials = credentials
[docs] def load(self) -> List[Document]:
try:
from google.cloud import bigquery
except ImportError as ex:
rai... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/bigquery.html |
b88583d666e1-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 |
0d1fa9938cde-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/duckdb_loader.html |
0d1fa9938cde-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/duckdb_loader.html |
4505a4fd5c8e-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 |
9c2d37c0fdfb-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/psychic.html |
d046423717b9-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/apify_dataset.html |
d046423717b9-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)) | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/apify_dataset.html |
fc8cee230c82-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 |
10a17fd68edb-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/s3_directory.html |
6cdec0e774bd-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... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/url.html |
6cdec0e774bd-1 | self.unstructured_kwargs = unstructured_kwargs
self.show_progress_bar = show_progress_bar
def _validate_mode(self, mode: str) -> None:
_valid_modes = {"single", "elements"}
if mode not in _valid_modes:
raise ValueError(
f"Got {mode} for `mode`, but should be one o... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/url.html |
6cdec0e774bd-2 | "Please install with 'pip install tqdm' or set "
"show_progress_bar=False."
) from e
urls = tqdm(self.urls)
else:
urls = self.urls
for url in urls:
try:
if self.__is_non_html_available():
if self.... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/url.html |
568ac3726a88-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 |
568ac3726a88-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 |
568ac3726a88-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 |
568ac3726a88-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 |
568ac3726a88-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 |
c9c1e3e38c8b-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 |
a96c1c8796b3-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 |
4833404ceccd-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 |
4833404ceccd-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 |
4833404ceccd-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 |
5a75d765fbba-0 | Source code for langchain.document_loaders.twitter
"""Twitter document loader."""
from __future__ import annotations
from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Optional, Sequence, Union
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
if TYPE_CHEC... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/twitter.html |
5a75d765fbba-1 | user = api.get_user(screen_name=username)
docs = self._format_tweets(tweets, user)
results.extend(docs)
return results
def _format_tweets(
self, tweets: List[Dict[str, Any]], user_info: dict
) -> Iterable[Document]:
"""Format tweets into a string."""
for t... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/twitter.html |
5a75d765fbba-2 | access_token=access_token,
access_token_secret=access_token_secret,
consumer_key=consumer_key,
consumer_secret=consumer_secret,
)
return cls(
auth_handler=auth,
twitter_users=twitter_users,
number_tweets=number_tweets,
) | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/twitter.html |
537abde9f427-0 | Source code for langchain.document_loaders.iugu
"""Loader that fetches data from IUGU"""
import json
import urllib.request
from typing import List, Optional
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
from langchain.utils import get_from_env, stringify_dict
IU... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/iugu.html |
537abde9f427-1 | [docs] def load(self) -> List[Document]:
return self._get_resource() | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/iugu.html |
e5f959ed2e0c-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 |
e5f959ed2e0c-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 |
e5f959ed2e0c-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 |
86337f7d84e8-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 |
6440543c7b56-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/markdown.html |
5ec96b707831-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/stripe.html |
5ec96b707831-1 | if endpoint is None:
return []
return self._make_request(endpoint)
[docs] def load(self) -> List[Document]:
return self._get_resource() | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/stripe.html |
fcfde8a0f140-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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.