id
stringlengths
14
16
text
stringlengths
4
1.28k
source
stringlengths
54
121
371a0de63670-1
if isinstance(path_images, str): self.image_paths = [path_images] else: self.image_paths = path_images self.blip_processor = blip_processor self.blip_model = blip_model [docs] def load(self) -> List[Document]: """ Load from a list of image files ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/image_captions.html
371a0de63670-2
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
371a0de63670-3
) else: image = Image.open(path_image).convert("RGB") except Exception: raise ValueError(f"Could not get image data for {path_image}") inputs = processor(image, "an image of", return_tensors="pt") output = model.generate(**inputs) caption: str = pr...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/image_captions.html
0104ca9f3fef-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
0104ca9f3fef-1
file_filter: Optional[Callable[[str], bool]] = None, ): self.repo_path = repo_path self.clone_url = clone_url self.branch = branch self.file_filter = file_filter [docs] def load(self) -> List[Document]: try: from git import Blob, Repo # type: ignore ex...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/git.html
0104ca9f3fef-2
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_files = repo.ignore...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/git.html
0104ca9f3fef-3
except UnicodeDecodeError: continue metadata = { "source": rel_file_path, "file_path": rel_file_path, "file_name": item.name, "file_type": file_type, } ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/git.html
1647622f7ae7-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
1647622f7ae7-1
binary_location (Optional[str]): The location of the browser binary. executable_path (Optional[str]): The path to the browser executable. headless (bool): If True, the browser will run in headless mode. arguments [List[str]]: List of arguments to pass to the browser. """ def __init__( ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/url_selenium.html
1647622f7ae7-2
except ImportError: raise ImportError( "selenium package not found, please install it with " "`pip install selenium`" ) try: import unstructured # noqa:F401 except ImportError: raise ImportError( "unstructur...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/url_selenium.html
1647622f7ae7-3
Returns: Union[Chrome, Firefox]: A WebDriver instance for the specified browser. """ if self.browser.lower() == "chrome": from selenium.webdriver import Chrome from selenium.webdriver.chrome.options import Options as ChromeOptions chrome_options = ChromeOp...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/url_selenium.html
1647622f7ae7-4
firefox_options = FirefoxOptions() 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.bin...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/url_selenium.html
1647622f7ae7-5
driver = self._get_driver() for url in self.urls: try: driver.get(url) page_content = driver.page_source elements = partition_html(text=page_content) text = "\n\n".join([str(el) for el in elements]) metadata = {"source":...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/url_selenium.html
a47482d6dab7-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
a47482d6dab7-1
Document. If unspecified, all columns will be written to `page_content`. metadata_columns: The columns to write into the `metadata` of the Document. If unspecified, all columns not added to `page_content` will be written. """ self.query = query self.api_wrapper = api_...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/max_compute.html
a47482d6dab7-2
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 set as the environment variabl...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/max_compute.html
a47482d6dab7-3
page_content_data = { k: v for k, v in row.items() if k in self.page_content_columns } else: page_content_data = row page_content = "\n".join(f"{k}: {v}" for k, v in page_content_data.items()) if self.metadata_columns: ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/max_compute.html
a2e620899152-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
a2e620899152-1
except ImportError: raise ImportError( "pyspark is not installed. " "Please install it with `pip install pyspark`" ) self.spark = ( spark_session if spark_session else SparkSession.builder.getOrCreate() ) if not isinstance(df, D...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/pyspark_dataframe.html
a2e620899152-2
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] estimated_row_size = sys.getsizeof(row) mem_info = psutil.v...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/pyspark_dataframe.html
a2e620899152-3
text = metadata[self.page_content_column] metadata.pop(self.page_content_column) yield Document(page_content=text, metadata=metadata) [docs] def load(self) -> List[Document]: """Load from the dataframe.""" if self.df.count() > self.max_num_rows: logger.warning( ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/pyspark_dataframe.html
b18ba7925d47-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
b18ba7925d47-1
logger = logging.getLogger(__name__) [docs]class DocugamiLoader(BaseLoader, BaseModel): """Loader that loads processed docs from Docugami. To use, you should have the ``lxml`` python package installed. """ api: str = DEFAULT_API_ENDPOINT access_token: Optional[str] = os.environ.get("DOCUGAMI_API_KEY...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html
b18ba7925d47-2
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
b18ba7925d47-3
"Please install it with `pip install lxml`." ) # helpers def _xpath_qname_for_chunk(chunk: Any) -> str: """Get the xpath qname for a chunk.""" qname = f"{chunk.prefix}:{chunk.tag.split('}')[-1]}" parent = chunk.getparent() if parent is not None...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html
b18ba7925d47-4
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 == TABLE_NAME else node.attrib["structure"] ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html
b18ba7925d47-5
"""Get the text of a node.""" return " ".join(node.itertext()).strip() def _has_structural_descendant(node: Any) -> bool: """Check if a node has a structural descendant.""" for child in node: if _is_structural(child) or _has_structural_descendant(child): ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html
b18ba7925d47-6
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(r"\{.*\}", "", node.tag), } if do...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html
b18ba7925d47-7
prev_small_chunk_text = None if _is_heading(node) or len(text) < self.min_chunk_size: # Save headings or other small chunks to be appended to the next chunk prev_small_chunk_text = text else: chunks.append(_create_doc(node, text)) if prev_s...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html
b18ba7925d47-8
url, headers={"Authorization": f"Bearer {self.access_token}"}, ) if response.ok: data = response.json() all_documents.extend(data["documents"]) url = data.get("next", None) else: raise Exception( ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html
b18ba7925d47-9
data={}, ) if response.ok: data = response.json() all_projects.extend(data["projects"]) 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
b18ba7925d47-10
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})" ) per_file_metadata = {} for art...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html
b18ba7925d47-11
data={}, ) if response.ok: try: from lxml import etree except ImportError: raise ImportError( "Could not import lxml python package. " "Please i...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html
b18ba7925d47-12
else: raise Exception( f"Failed to download {artifact_url}/content " + "(status: {response.status_code})" ) return per_file_metadata def _load_chunks_for_document( self, docset_id: str, document: Dict, doc_metada...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html
b18ba7925d47-13
else: raise Exception( f"Failed to download {url} (status: {response.status_code})" ) [docs] def load(self) -> List[Document]: """Load documents.""" chunks: List[Document] = [] if self.access_token and self.docset_id: # remote mode ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/docugami.html
b18ba7925d47-14
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
c1439cca58c4-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
c1439cca58c4-1
"Please install it with `pip install google-cloud-storage`." ) # Initialise a client storage_client = storage.Client(self.project_name) # Create a bucket object for our bucket bucket = storage_client.get_bucket(self.bucket) # Create a blob object from the filepath ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/gcs_file.html
94886d86efe6-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
94886d86efe6-1
"""Initialize with path.""" self.file_path = path [docs] def load(self) -> List[Document]: """Load documents.""" p = Path(self.file_path) with open(p, encoding="utf8") as f: d = json.load(f) text = "".join( concatenate_rows(message) for mess...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/facebook_chat.html
36fcad30e2f3-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
36fcad30e2f3-1
"internal_accounts": "https://app.moderntreasury.com/api/internal_accounts", "external_accounts": "https://app.moderntreasury.com/api/external_accounts", "transactions": "https://app.moderntreasury.com/api/transactions", "ledgers": "https://app.moderntreasury.com/api/ledgers", "ledger_accounts": "https:...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/modern_treasury.html
36fcad30e2f3-2
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
36fcad30e2f3-3
with urllib.request.urlopen(request) as response: json_data = json.loads(response.read().decode()) text = stringify_value(json_data) metadata = {"source": url} return [Document(page_content=text, metadata=metadata)] def _get_resource(self) -> List[Document]: e...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/modern_treasury.html
e02d090dd07c-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
e02d090dd07c-1
) s3 = boto3.client("s3") with tempfile.TemporaryDirectory() as temp_dir: file_path = f"{temp_dir}/{self.key}" os.makedirs(os.path.dirname(file_path), exist_ok=True) s3.download_file(self.bucket, self.key, file_path) loader = UnstructuredFileLoader(file_pa...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/s3_file.html
396108ba147d-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
396108ba147d-1
values, "access_token", "GITHUB_PERSONAL_ACCESS_TOKEN" ) return values @property def headers(self) -> Dict[str, str]: return { "Accept": "application/vnd.github+json", "Authorization": f"Bearer {self.access_token}", } [docs]class GitHubIssuesLoader(BaseGit...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/github.html
396108ba147d-2
"""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 the issue.""" mentioned: Optional[str] = None """Filte...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/github.html
396108ba147d-3
"""The direction to sort the results by. Can be one of: 'asc', 'desc'.""" since: Optional[str] = None """Only show notifications updated after the given time. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.""" @validator("since") def validate_since(cls, v: Optional[str]) -> Optiona...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/github.html
396108ba147d-4
Get issues of a GitHub repository. Returns: A list of Documents with attributes: - page_content - metadata - url - title - creator - created_at - last_update_time ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/github.html
396108ba147d-5
url = response.links["next"]["url"] else: url = None [docs] def load(self) -> List[Document]: """ Get issues of a GitHub repository. Returns: A list of Documents with attributes: - page_content - metadata ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/github.html
396108ba147d-6
"url": issue["html_url"], "title": issue["title"], "creator": issue["user"]["login"], "created_at": issue["created_at"], "comments": issue["comments"], "state": issue["state"], "labels": [label["name"] for label in issue["labels"]], "as...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/github.html
396108ba147d-7
@property def query_params(self) -> str: labels = ",".join(self.labels) if self.labels else self.labels query_params_dict = { "milestone": self.milestone, "state": self.state, "assignee": self.assignee, "creator": self.creator, "mentioned":...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/github.html
396108ba147d-8
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
a1c5531e06a2-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
a1c5531e06a2-1
"""Load all chat messages.""" result = [] for _, row in self.chat_log.iterrows(): user_id = row[self.user_id_col] metadata = row.to_dict() metadata.pop(self.user_id_col) result.append(Document(page_content=user_id, metadata=metadata)) return result
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/discord.html
da4d30de0644-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
da4d30de0644-1
): self.query = query self.page_content_field = page_content_field self.secret = secret self.metadata_fields = metadata_fields [docs] def load(self) -> List[Document]: return list(self.lazy_load()) [docs] def lazy_load(self) -> Iterator[Document]: try: f...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/fauna.html
da4d30de0644-2
if result is not None: 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( ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/fauna.html
eb7663f455a4-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
eb7663f455a4-1
load_max_docs=self.load_max_docs, load_all_available_meta=self.load_all_available_meta, ) docs = arxiv_client.load(self.query) return docs
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/arxiv.html
d387aa4d6136-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
a825d785a87c-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
a825d785a87c-1
project: Optional[str] = None, page_content_columns: Optional[List[str]] = None, metadata_columns: Optional[List[str]] = None, credentials: Optional[Credentials] = None, ): """Initialize BigQuery document loader. Args: query: The query to run in BigQuery. ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/bigquery.html
a825d785a87c-2
""" self.query = query 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 ex...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/bigquery.html
a825d785a87c-3
if metadata_columns is None: metadata_columns = [] for row in query_result: page_content = "\n".join( f"{k}: {v}" for k, v in row.items() if k in page_content_columns ) metadata = {k: v for k, v in row.items() if k in metadata_columns} ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/bigquery.html
5167d9be408c-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
5167d9be408c-1
raise ValueError( "Could not import azure storage blob python package. " "Please install it with `pip install azure-storage-blob`." ) from exc client = BlobClient.from_connection_string( conn_str=self.conn_str, container_name=self.container, blob_name=self...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/azure_blob_storage_file.html
f9dc9c2584c5-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
f9dc9c2584c5-1
page_content_columns: Optional[List[str]] = None, metadata_columns: Optional[List[str]] = None, ): self.query = query self.database = database self.read_only = read_only self.config = config or {} self.page_content_columns = page_content_columns self.metadata_...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/duckdb_loader.html
f9dc9c2584c5-2
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_content_columns if self.metadata_columns is None: metadata_columns = [] ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/duckdb_loader.html
d1903859bbbe-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
f7fe4891e53e-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
f7fe4891e53e-1
self.connection_id = connection_id [docs] def load(self) -> List[Document]: """Load documents.""" psychic_docs = self.psychic.get_documents(self.connector_id, self.connection_id) return [ Document( page_content=doc["content"], metadata={"title": doc...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/psychic.html
23eea75afe70-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
23eea75afe70-1
): """Initialize the loader with an Apify dataset ID and a mapping function. Args: dataset_id (str): The ID of the dataset on the Apify platform. dataset_mapping_function (Callable): A function that takes a single dictionary (an Apify dataset item) and converts it...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/apify_dataset.html
23eea75afe70-2
) 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
6347ff6b9b8c-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
0203c8694f84-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
0203c8694f84-1
) s3 = boto3.resource("s3") bucket = s3.Bucket(self.bucket) docs = [] for obj in bucket.objects.filter(Prefix=self.prefix): loader = S3FileLoader(self.bucket, obj.key) docs.extend(loader.load()) return docs
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/s3_directory.html
4b91829d9f71-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
4b91829d9f71-1
except ImportError: raise ValueError( "unstructured package not found, please install it with " "`pip install unstructured`" ) self._validate_mode(mode) self.mode = mode headers = unstructured_kwargs.pop("headers", {}) if len(header...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/url.html
4b91829d9f71-2
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
4b91829d9f71-3
unstructured_version = tuple([int(x) for x in _unstructured_version.split(".")]) return unstructured_version >= (0, 5, 13) def __is_non_html_available(self) -> bool: _unstructured_version = self.__version.split("-")[0] unstructured_version = tuple([int(x) for x in _unstructured_version.split...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/url.html
4b91829d9f71-4
"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
4b91829d9f71-5
if self.continue_on_failure: logger.error(f"Error fetching or processing {url}, exeption: {e}") continue else: raise e if self.mode == "single": text = "\n\n".join([str(el) for el in elements]) metada...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/url.html
bdef7a48fbfd-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
bdef7a48fbfd-1
client_secret: SecretStr = Field(..., env="O365_CLIENT_SECRET") class Config: env_prefix = "" case_sentive = False env_file = ".env" class _OneDriveTokenStorage(BaseSettings): token_path: FilePath = Field(Path.home() / ".credentials" / "o365_token.txt") class _FileType(str, Enum): DO...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/onedrive.html
bdef7a48fbfd-2
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
bdef7a48fbfd-3
""" try: from O365 import FileSystemTokenBackend except ImportError: raise ImportError( "O365 package not found, please install it with `pip install o365`" ) if self.auth_with_token: token_storage = _OneDriveTokenStorage() ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/onedrive.html
bdef7a48fbfd-4
) 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
bdef7a48fbfd-5
""" subfolder_drive = drive if self.folder_path is None: return subfolder_drive subfolders = [f for f in self.folder_path.split("/") if f != ""] if len(subfolders) == 0: return subfolder_drive items = subfolder_drive.get_items() for subfolder in su...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/onedrive.html
bdef7a48fbfd-6
Args: 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"]) ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/onedrive.html
bdef7a48fbfd-7
""" Loads all supported document files from the specified OneDrive drive based on their object IDs and returns a list of Document objects. Args: drive (Type[Drive]): The OneDrive drive object to load the documents from. Returns: List[Document]:...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/onedrive.html
bdef7a48fbfd-8
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
bdef7a48fbfd-9
docs: List[Document] = [] if not drive: raise ValueError(f"There isn't a drive with id {self.drive_id}.") if self.folder_path: folder = self._get_folder_from_path(drive=drive) docs.extend(self._load_from_folder(folder=folder)) elif self.object_ids: ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/onedrive.html
1d62b8110dcb-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
cf6bacdcfbce-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
cf6bacdcfbce-1
"""Lazy load records.""" from sodapy import Socrata client = Socrata(self.city_id, None) results = client.get(self.dataset_id, limit=self.limit) for record in results: yield Document( page_content=str(record), metadata={ "so...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/open_city_data.html