id stringlengths 14 15 | text stringlengths 49 2.47k | source stringlengths 61 166 |
|---|---|---|
316adfeb76b6-2 | """
self.file_path = path
self.include_outputs = include_outputs
self.max_output_length = max_output_length
self.remove_newline = remove_newline
self.traceback = traceback
[docs] def load(
self,
) -> List[Document]:
"""Load documents."""
try:
... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/notebook.html |
09412c415dca-0 | Source code for langchain.document_loaders.imsdb
"""Loads IMSDb."""
from typing import List
from langchain.docstore.document import Document
from langchain.document_loaders.web_base import WebBaseLoader
[docs]class IMSDbLoader(WebBaseLoader):
"""Loads IMSDb webpages."""
[docs] def load(self) -> List[Document]:
... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/imsdb.html |
8b896c2eef90-0 | Source code for langchain.document_loaders.markdown
"""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.
You can run ... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/markdown.html |
8b896c2eef90-1 | f"You are on unstructured version {__unstructured_version__}. "
"Partitioning markdown files is only supported in unstructured>=0.4.16."
)
return partition_md(filename=self.file_path, **self.unstructured_kwargs) | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/markdown.html |
5dd1106a11bf-0 | Source code for langchain.document_loaders.s3_directory
"""Loading logic for loading documents from an AWS 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]cl... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/s3_directory.html |
8b36e58b012a-0 | Source code for langchain.document_loaders.merge
from typing import Iterator, List
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
[docs]class MergedDataLoader(BaseLoader):
"""Merge documents from a list of loaders"""
[docs] def __init__(self, loaders: List... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/merge.html |
2a352d58466b-0 | Source code for langchain.document_loaders.json_loader
"""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(BaseLoader)... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/json_loader.html |
2a352d58466b-1 | string format, default to True.
json_lines (bool): Boolean flag to indicate whether the input is in
JSON Lines format.
"""
try:
import jq # noqa:F401
except ImportError:
raise ImportError(
"jq package not found, please install ... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/json_loader.html |
2a352d58466b-2 | source=str(self.file_path),
seq_num=i,
)
text = self._get_text(sample=sample, metadata=metadata)
docs.append(Document(page_content=text, metadata=metadata))
def _get_text(self, sample: Any, metadata: dict) -> str:
"""Convert sample to string format"""
... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/json_loader.html |
2a352d58466b-3 | if sample.get(self._content_key) is None:
raise ValueError(
f"Expected the jq schema to result in a list of objects (dict) \
with the key `{self._content_key}`"
)
if self._metadata_func is not None:
sample_metadata = self._metadata_func(sam... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/json_loader.html |
c919b36ab884-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.
The Repos... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/git.html |
c919b36ab884-1 | raise ImportError(
"Could not import git python package. "
"Please install it with `pip install GitPython`."
) from ex
if not os.path.exists(self.repo_path) and self.clone_url is None:
raise ValueError(f"Path {self.repo_path} does not exist")
elif ... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/git.html |
c919b36ab884-2 | content = f.read()
file_type = os.path.splitext(item.name)[1]
# loads only text files
try:
text_content = content.decode("utf-8")
except UnicodeDecodeError:
continue
metada... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/git.html |
ead45e2f60c2-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 |
ead45e2f60c2-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 |
110196d329fa-0 | Source code for langchain.document_loaders.nuclia
"""Extract text from any file type."""
import json
import uuid
from typing import List
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
from langchain.tools.nuclia.tool import NucliaUnderstandingAPI
[docs]class Nucl... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/nuclia.html |
b0b2ae45b139-0 | Source code for langchain.document_loaders.airbyte_json
"""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(BaseLoader):
... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/airbyte_json.html |
bd8d180c023e-0 | Source code for langchain.document_loaders.obs_directory
# coding:utf-8
from typing import List, Optional
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
from langchain.document_loaders.obs_file import OBSFileLoader
[docs]class OBSDirectoryLoader(BaseLoader):
... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/obs_directory.html |
bd8d180c023e-1 | Note:
Before using this class, make sure you have registered with OBS and have the necessary credentials. The `ak`, `sk`, and `endpoint` values are mandatory unless `get_token_from_ecs` is True or the bucket policy is public read. `token` is required when using temporary credentials.
Example:
... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/obs_directory.html |
bd8d180c023e-2 | )
if resp.status < 300:
for content in resp.body.contents:
loader = OBSFileLoader(self.bucket, content.key, client=self.client)
docs.extend(loader.load())
if resp.body.is_truncated is True:
mark = resp.body.next_mark... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/obs_directory.html |
22a3fa1d10a4-0 | Source code for langchain.document_loaders.snowflake_loader
from __future__ import annotations
from typing import Any, Dict, Iterator, List, Optional, Tuple
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
[docs]class SnowflakeLoader(BaseLoader):
"""Loads a que... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/snowflake_loader.html |
22a3fa1d10a4-1 | """
self.query = query
self.user = user
self.password = password
self.account = account
self.warehouse = warehouse
self.role = role
self.database = database
self.schema = schema
self.parameters = parameters
self.page_content_columns = (
... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/snowflake_loader.html |
22a3fa1d10a4-2 | ) -> Tuple[List[str], List[str]]:
page_content_columns = (
self.page_content_columns if self.page_content_columns else []
)
metadata_columns = self.metadata_columns if self.metadata_columns else []
if page_content_columns is None and query_result:
page_content_col... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/snowflake_loader.html |
67dfc10387bf-0 | Source code for langchain.document_loaders.etherscan
import os
import re
from typing import Iterator, List
import requests
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
[docs]class EtherscanLoader(BaseLoader):
"""
Load transactions from an account on Eth... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/etherscan.html |
67dfc10387bf-1 | ]:
raise ValueError(f"Invalid filter {filter}")
[docs] def lazy_load(self) -> Iterator[Document]:
"""Lazy load Documents from table."""
result = []
if self.filter == "normal_transaction":
result = self.getNormTx()
elif self.filter == "internal_transaction":
... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/etherscan.html |
67dfc10387bf-2 | if len(items) == 0:
return [Document(page_content="")]
for item in items:
content = str(item)
metadata = {"from": item["from"], "tx_hash": item["hash"], "to": item["to"]}
result.append(Document(page_content=content, metadata=metadata))
print(len(result))
... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/etherscan.html |
67dfc10387bf-3 | for item in items:
content = str(item)
metadata = {"from": item["from"], "tx_hash": item["hash"], "to": item["to"]}
result.append(Document(page_content=content, metadata=metadata))
return result
[docs] def getERC20Tx(self) -> List[Document]:
url = (
f"h... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/etherscan.html |
67dfc10387bf-4 | )
try:
response = requests.get(url)
response.raise_for_status()
except requests.exceptions.RequestException as e:
print("Error occurred while making the request:", e)
items = response.json()["result"]
result = []
if len(items) == 0:
... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/etherscan.html |
56c615275c79-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):
"""Loads Open City data."""
[docs] def __init__(self, city_id: str, datas... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/open_city_data.html |
20470d85f5a2-0 | Source code for langchain.document_loaders.dropbox
"""Loads data from Dropbox."""
# Prerequisites:
# 1. Create a Dropbox app.
# 2. Give the app these scope permissions: `files.metadata.read`
# and `files.content.read`.
# 3. Generate access token: https://www.dropbox.com/developers/apps/create.
# 4. `pip install drop... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/dropbox.html |
20470d85f5a2-1 | if values.get("dropbox_folder_path") is None and not values.get(
"dropbox_file_paths"
):
raise ValueError("Must specify either folder_path or file_paths")
return values
def _create_dropbox_client(self) -> Any:
"""Create a Dropbox client."""
try:
fr... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/dropbox.html |
20470d85f5a2-2 | def _load_file_from_path(self, file_path: str) -> Optional[Document]:
"""Load a file from a Dropbox path."""
dbx = self._create_dropbox_client()
try:
from dropbox import exceptions
except ImportError:
raise ImportError("You must run " "`pip install dropbox")
... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/dropbox.html |
20470d85f5a2-3 | return None
return None
metadata = {
"source": f"dropbox://{file_path}",
"title": os.path.basename(file_path),
}
return Document(page_content=text, metadata=metadata)
def _load_documents_from_paths(self) -> List[Document]:
"""Load documents from a ... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/dropbox.html |
40bcdd6f357e-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 |
f99ac5a7bf5d-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 |
5c72ddb2f619-0 | Source code for langchain.document_loaders.apify_dataset
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 ApifyDatasetLoader(BaseLoader, BaseModel):
"""Loads... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/apify_dataset.html |
5c72ddb2f619-1 | of the Document class.
"""
super().__init__(
dataset_id=dataset_id, dataset_mapping_function=dataset_mapping_function
)
@root_validator()
def validate_environment(cls, values: Dict) -> Dict:
"""Validate environment.
Args:
values: The values to vali... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/apify_dataset.html |
d4ee1560563c-0 | Source code for langchain.document_loaders.email
"""Loads email files."""
import os
from typing import Any, List
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
from langchain.document_loaders.unstructured import (
UnstructuredFileLoader,
satisfies_min_uns... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/email.html |
d4ee1560563c-1 | unstructured_kwargs["attachment_partitioner"] = partition
super().__init__(file_path=file_path, mode=mode, **unstructured_kwargs)
def _get_elements(self) -> List:
from unstructured.file_utils.filetype import FileType, detect_filetype
filetype = detect_filetype(self.file_path)
if file... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/email.html |
d4ee1560563c-2 | import extract_msg
msg = extract_msg.Message(self.file_path)
return [
Document(
page_content=msg.body,
metadata={
"subject": msg.subject,
"sender": msg.sender,
"date": msg.date,
},
... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/email.html |
89716a9ac01c-0 | Source code for langchain.document_loaders.roam
"""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):
"""Loads Roam files from disk."""
[docs] de... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/roam.html |
a36b4384268b-0 | Source code for langchain.document_loaders.async_html
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 BaseLoader
logger = logging.getLog... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/async_html.html |
a36b4384268b-1 | if not headers.get("User-Agent"):
try:
from fake_useragent import UserAgent
headers["User-Agent"] = UserAgent().random
except ImportError:
logger.info(
"fake_useragent not found, using default user agent."
"T... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/async_html.html |
a36b4384268b-2 | raise ValueError("retry count exceeded")
async def _fetch_with_rate_limit(
self, url: str, semaphore: asyncio.Semaphore
) -> str:
async with semaphore:
return await self._fetch(url)
[docs] async def fetch_all(self, urls: List[str]) -> Any:
"""Fetch all urls concurrently wi... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/async_html.html |
0cd8fb526bb8-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 |
0cd8fb526bb8-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 |
f101e8c8735b-0 | Source code for langchain.document_loaders.mediawikidump
"""Load Data from a MediaWiki dump xml."""
import logging
from pathlib import Path
from typing import List, Optional, Sequence, Union
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
logger = logging.getLogge... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/mediawikidump.html |
f101e8c8735b-1 | """
[docs] def __init__(
self,
file_path: Union[str, Path],
encoding: Optional[str] = "utf8",
namespaces: Optional[Sequence[int]] = None,
skip_redirects: Optional[bool] = False,
stop_on_error: Optional[bool] = True,
):
self.file_path = file_path if isinstan... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/mediawikidump.html |
f101e8c8735b-2 | except Exception as e:
logger.error("Parsing error: {}".format(e))
if self.stop_on_error:
raise e
else:
continue
return docs | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/mediawikidump.html |
9412b94a7c68-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://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/notiondb.html |
9412b94a7c68-1 | """Load documents from the Notion database.
Returns:
List[Document]: List of documents.
"""
page_summaries = self._retrieve_page_summaries()
return list(self.load_page(page_summary) for page_summary in page_summaries)
def _retrieve_page_summaries(
self, query_dict... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/notiondb.html |
9412b94a7c68-2 | )
elif prop_type == "multi_select":
value = (
[item["name"] for item in prop_data["multi_select"]]
if prop_data["multi_select"]
else []
)
elif prop_type == "url":
value = prop_data["url"]
... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/notiondb.html |
9412b94a7c68-3 | if "text" in rich_text:
cur_result_text_arr.append(
"\t" * num_tabs + rich_text["text"]["content"]
)
if result["has_children"]:
children_text = self._load_blocks(
result["id"], num_tab... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/notiondb.html |
3118f59513d3-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 |
3118f59513d3-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 |
7837c35bae6f-0 | Source code for langchain.document_loaders.datadog_logs
"""Load Datadog logs."""
from datetime import datetime, timedelta
from typing import List, Optional
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
[docs]class DatadogLogsLoader(BaseLoader):
"""Loads a qu... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/datadog_logs.html |
7837c35bae6f-1 | except ImportError as ex:
raise ImportError(
"Could not import datadog_api_client python package. "
"Please install it with `pip install datadog_api_client`."
) from ex
self.query = query
configuration = Configuration()
configuration.api_ke... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/datadog_logs.html |
7837c35bae6f-2 | from datadog_api_client.v2.api.logs_api import LogsApi
from datadog_api_client.v2.model.logs_list_request import LogsListRequest
from datadog_api_client.v2.model.logs_list_request_page import (
LogsListRequestPage,
)
from datadog_api_client.v2.model.logs_q... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/datadog_logs.html |
547a35837163-0 | Source code for langchain.document_loaders.sitemap
"""Loader that fetches a sitemap and loads those URLs."""
import itertools
import re
from typing import Any, Callable, Generator, Iterable, List, Optional
from langchain.document_loaders.web_base import WebBaseLoader
from langchain.schema import Document
def _default_p... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/sitemap.html |
547a35837163-1 | blocknum: the number of the block that should be loaded - zero indexed.
Default: 0
meta_function: Function to parse bs4.Soup output for metadata
remember when setting this method to also copy metadata["loc"]
to metadata["source"] if you are using this field
... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/sitemap.html |
547a35837163-2 | Returns:
List of dicts.
"""
els = []
for url in soup.find_all("url"):
loc = url.find("loc")
if not loc:
continue
# Strip leading and trailing whitespace and newlines
loc_text = loc.text.strip()
if self.filter... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/sitemap.html |
547a35837163-3 | if blockcount - 1 < self.blocknum:
raise ValueError(
"Selected sitemap does not contain enough blocks for given blocknum"
)
else:
els = elblocks[self.blocknum]
results = self.scrape_all([el["loc"].strip() for el in els if "loc" in e... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/sitemap.html |
35d5ed3f26ee-0 | Source code for langchain.document_loaders.airtable
from typing import Iterator, List
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
[docs]class AirtableLoader(BaseLoader):
"""Loader for Airtable tables."""
[docs] def __init__(self, api_token: str, table_i... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/airtable.html |
3b0ed98ad7ca-0 | Source code for langchain.document_loaders.org_mode
"""Loads Org-Mode files."""
from typing import Any, List
from langchain.document_loaders.unstructured import (
UnstructuredFileLoader,
validate_unstructured_version,
)
[docs]class UnstructuredOrgModeLoader(UnstructuredFileLoader):
"""Loader that uses unstr... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/org_mode.html |
3b0ed98ad7ca-1 | def _get_elements(self) -> List:
from unstructured.partition.org import partition_org
return partition_org(filename=self.file_path, **self.unstructured_kwargs) | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/org_mode.html |
fb4c8ff01667-0 | Source code for langchain.document_loaders.tencent_cos_file
"""Loading logic for loading documents from Tencent Cloud COS file."""
import os
import tempfile
from typing import Any, Iterator, List
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
from langchain.docum... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/tencent_cos_file.html |
fb4c8ff01667-1 | )
loader = UnstructuredFileLoader(file_path)
# UnstructuredFileLoader not implement lazy_load yet
return iter(loader.load()) | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/tencent_cos_file.html |
f0c7527b89f8-0 | Source code for langchain.document_loaders.unstructured
"""Loader that uses unstructured to load files."""
import collections
from abc import ABC, abstractmethod
from typing import IO, Any, Callable, Dict, List, Sequence, Union
from langchain.docstore.document import Document
from langchain.document_loaders.base import... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/unstructured.html |
f0c7527b89f8-1 | **unstructured_kwargs: Any,
):
"""Initialize with file path."""
try:
import unstructured # noqa:F401
except ImportError:
raise ValueError(
"unstructured package not found, please install it with "
"`pip install unstructured`"
... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/unstructured.html |
f0c7527b89f8-2 | # NOTE(MthwRobinson) - the attribute check is for backward compatibility
# with unstructured<0.4.9. The metadata attributed was added in 0.4.9.
if hasattr(element, "metadata"):
metadata.update(element.metadata.to_dict())
if hasattr(element, "category")... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/unstructured.html |
f0c7527b89f8-3 | else:
raise ValueError(f"mode of {self.mode} not supported.")
return docs
[docs]class UnstructuredFileLoader(UnstructuredBaseLoader):
"""Loader that uses Unstructured to load files.
The file loader uses the
unstructured partition function and will automatically detect the file
type. ... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/unstructured.html |
f0c7527b89f8-4 | file_path: Union[str, List[str], None] = None,
file: Union[IO, Sequence[IO], None] = None,
api_url: str = "https://api.unstructured.io/general/v0/general",
api_key: str = "",
**unstructured_kwargs: Any,
) -> List:
"""Retrieves a list of elements from the Unstructured API."""
if isinstance(file, ... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/unstructured.html |
f0c7527b89f8-5 | You can run the loader in one of two modes: "single" and "elements".
If you use "single" mode, the document will be returned as a single
langchain Document object. If you use "elements" mode, the unstructured
library will split the document into elements such as Title and NarrativeText.
You can pass in ... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/unstructured.html |
f0c7527b89f8-6 | return {"source": self.file_path}
def _get_elements(self) -> List:
return get_elements_from_api(
file_path=self.file_path,
api_key=self.api_key,
api_url=self.url,
**self.unstructured_kwargs,
)
[docs]class UnstructuredFileIOLoader(UnstructuredBaseLoader... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/unstructured.html |
f0c7527b89f8-7 | def _get_elements(self) -> List:
from unstructured.partition.auto import partition
return partition(file=self.file, **self.unstructured_kwargs)
def _get_metadata(self) -> dict:
return {}
[docs]class UnstructuredAPIFileIOLoader(UnstructuredFileIOLoader):
"""Loader that uses the Unstructur... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/unstructured.html |
f0c7527b89f8-8 | """
[docs] def __init__(
self,
file: Union[IO, Sequence[IO]],
mode: str = "single",
url: str = "https://api.unstructured.io/general/v0/general",
api_key: str = "",
**unstructured_kwargs: Any,
):
"""Initialize with file path."""
if isinstance(file, c... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/unstructured.html |
653bbae23214-0 | Source code for langchain.document_loaders.trello
"""Loads cards from Trello"""
from __future__ import annotations
from typing import TYPE_CHECKING, Any, List, Literal, Optional, Tuple
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
from langchain.utils import get... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/trello.html |
653bbae23214-1 | self.board_name = board_name
self.include_card_name = include_card_name
self.include_comments = include_comments
self.include_checklist = include_checklist
self.extra_metadata = extra_metadata
self.card_filter = card_filter
[docs] @classmethod
def from_credentials(
... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/trello.html |
653bbae23214-2 | token = token or get_from_env("token", "TRELLO_TOKEN")
client = TrelloClient(api_key=api_key, token=token)
return cls(client, board_name, **kwargs)
[docs] def load(self) -> List[Document]:
"""Loads all cards from the specified Trello board.
You can filter the cards, metadata and text ... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/trello.html |
653bbae23214-3 | if self.include_card_name:
text_content = card.name + "\n"
if card.description.strip():
text_content += BeautifulSoup(card.description, "lxml").get_text()
if self.include_checklist:
# Get all the checklist items on the card
for checklist in card.checklists... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/trello.html |
e58321749527-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 |
112d87a37563-0 | Source code for langchain.document_loaders.excel
"""Loads Microsoft Excel files."""
from typing import Any, List
from langchain.document_loaders.unstructured import (
UnstructuredFileLoader,
validate_unstructured_version,
)
[docs]class UnstructuredExcelLoader(UnstructuredFileLoader):
"""Loader that uses uns... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/excel.html |
112d87a37563-1 | from unstructured.partition.xlsx import partition_xlsx
return partition_xlsx(filename=self.file_path, **self.unstructured_kwargs) | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/excel.html |
b2b3ce9824aa-0 | Source code for langchain.document_loaders.embaas
import base64
import warnings
from typing import Any, Dict, Iterator, List, Optional
import requests
from pydantic import BaseModel, root_validator, validator
from typing_extensions import NotRequired, TypedDict
from langchain.docstore.document import Document
from lang... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/embaas.html |
b2b3ce9824aa-1 | """The instruction to pass to the Embaas document extraction API."""
[docs]class EmbaasDocumentExtractionPayload(EmbaasDocumentExtractionParameters):
"""Payload for the Embaas document extraction API."""
bytes: str
"""The base64 encoded bytes of the document to extract text from."""
[docs]class BaseEmbaasLo... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/embaas.html |
b2b3ce9824aa-2 | loader = EmbaasBlobLoader()
blob = Blob.from_path(path="example.mp3")
documents = loader.parse(blob=blob)
# Custom api parameters (create embeddings automatically)
from langchain.document_loaders.embaas import EmbaasBlobLoader
loader = EmbaasBlobLoader(
... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/embaas.html |
b2b3ce9824aa-3 | bytes=base64_byte_str,
# Workaround for mypy issue: https://github.com/python/mypy/issues/9408
# type: ignore
**self.params,
)
if blob.mimetype is not None and payload.get("mime_type", None) is None:
payload["mime_type"] = blob.mimetype
return payl... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/embaas.html |
b2b3ce9824aa-4 | )
raise
yield from documents
[docs]class EmbaasLoader(BaseEmbaasLoader, BaseLoader):
"""Embaas's document loader.
To use, you should have the
environment variable ``EMBAAS_API_KEY`` set with your API key, or pass
it as a named parameter to the constructor.
Example:
.. cod... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/embaas.html |
b2b3ce9824aa-5 | )
[docs] def lazy_load(self) -> Iterator[Document]:
"""Load the documents from the file path lazily."""
blob = Blob.from_path(path=self.file_path)
assert self.blob_loader is not None
# Should never be None, but mypy doesn't know that.
yield from self.blob_loader.lazy_parse(blo... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/embaas.html |
14748460bad6-0 | Source code for langchain.document_loaders.tencent_cos_directory
"""Loading logic for loading documents from Tencent Cloud COS directory."""
from typing import Any, Iterator, List
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
from langchain.document_loaders.tenc... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/tencent_cos_directory.html |
14748460bad6-1 | for content in contents:
if content["Key"].endswith("/"):
continue
loader = TencentCOSFileLoader(self.conf, self.bucket, content["Key"])
yield loader.load()[0] | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/tencent_cos_directory.html |
68a73dceeec3-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 |
68a73dceeec3-1 | def _get_resource(self) -> List[Document]:
endpoint = IUGU_ENDPOINTS.get(self.resource)
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/iugu.html |
8530aab4d9e1-0 | Source code for langchain.document_loaders.gutenberg
"""Loads .txt web files."""
from typing import List
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
[docs]class GutenbergLoader(BaseLoader):
"""Loader that uses urllib to load .txt web files."""
[docs] de... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/gutenberg.html |
68026ccf838e-0 | Source code for langchain.document_loaders.gcs_file
"""Load documents from a GCS file."""
import os
import tempfile
from typing import Callable, List, Optional
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/gcs_file.html |
68026ccf838e-1 | [docs] def load(self) -> List[Document]:
"""Load documents."""
try:
from google.cloud import storage
except ImportError:
raise ImportError(
"Could not import google-cloud-storage python package. "
"Please install it with `pip install goo... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/gcs_file.html |
80472d4de2f3-0 | Source code for langchain.document_loaders.brave_search
from typing import Iterator, List, Optional
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
from langchain.utilities.brave_search import BraveSearchWrapper
[docs]class BraveSearchLoader(BaseLoader):
"""Lo... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/brave_search.html |
3c065acc05c3-0 | Source code for langchain.document_loaders.mhtml
"""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(__name__)
[docs... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/mhtml.html |
3c065acc05c3-1 | from bs4 import BeautifulSoup
"""Load MHTML document into document objects."""
with open(self.file_path, "r", encoding=self.open_encoding) as f:
message = email.message_from_string(f.read())
parts = message.get_payload()
if type(parts) is not list:
par... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/mhtml.html |
3c23554713b7-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."""
[docs] def __init__(sel... | https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/srt.html |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.