id
stringlengths
14
16
text
stringlengths
44
2.73k
source
stringlengths
49
115
f60d51e2772a-1
self._id_key = id_key self._text_key = text_key [docs] def add_texts( self, texts: Iterable[str], metadatas: Optional[List[dict]] = None, ids: Optional[List[str]] = None, **kwargs: Any, ) -> List[str]: """Turn texts into embedding and add it to the database...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/lancedb.html
f60d51e2772a-2
""" embedding = self._embedding.embed_query(query) docs = self._connection.search(embedding).limit(k).to_df() return [ Document( page_content=row[self._text_key], metadata=row[docs.columns != self._text_key], ) for _, row in doc...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/lancedb.html
8018e2a6d584-0
Source code for langchain.vectorstores.atlas """Wrapper around Atlas by Nomic.""" from __future__ import annotations import logging import uuid from typing import Any, Iterable, List, Optional, Type import numpy as np from langchain.docstore.document import Document from langchain.embeddings.base import Embeddings from...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/atlas.html
8018e2a6d584-1
is_public (bool): Whether your project is publicly accessible. True by default. reset_project_if_exists (bool): Whether to reset this project if it already exists. Default False. Generally userful during development and testing. """ try: ...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/atlas.html
8018e2a6d584-2
metadatas (Optional[List[dict]], optional): Optional list of metadatas. ids (Optional[List[str]]): An optional list of ids. refresh(bool): Whether or not to refresh indices with the updated data. Default True. Returns: List[str]: List of IDs of the added texts...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/atlas.html
8018e2a6d584-3
else: if metadatas is None: data = [ {"text": text, AtlasDB._ATLAS_DEFAULT_ID_FIELD: ids[i]} for i, text in enumerate(texts) ] else: for i, text in enumerate(texts): metadatas[i]["text"] =...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/atlas.html
8018e2a6d584-4
""" if self._embedding_function is None: raise NotImplementedError( "AtlasDB requires an embedding_function for text similarity search!" ) _embedding = self._embedding_function.embed_documents([query])[0] embedding = np.array(_embedding).reshape(1, -1) ...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/atlas.html
8018e2a6d584-5
ids (Optional[List[str]]): Optional list of document IDs. If None, ids will be auto created description (str): A description for your project. is_public (bool): Whether your project is publicly accessible. True by default. reset_project_if_exists (bool...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/atlas.html
8018e2a6d584-6
ids: Optional[List[str]] = None, name: Optional[str] = None, api_key: Optional[str] = None, persist_directory: Optional[str] = None, description: str = "A description for your project", is_public: bool = True, reset_project_if_exists: bool = False, index_kwargs: O...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/atlas.html
8018e2a6d584-7
return cls.from_texts( name=name, api_key=api_key, texts=texts, embedding=embedding, metadatas=metadatas, ids=ids, description=description, is_public=is_public, reset_project_if_exists=reset_project_if_exists, ...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/atlas.html
7d9702e234ad-0
Source code for langchain.vectorstores.opensearch_vector_search """Wrapper around OpenSearch vector database.""" from __future__ import annotations import uuid from typing import Any, Dict, Iterable, List, Optional from langchain.docstore.document import Document from langchain.embeddings.base import Embeddings from la...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/opensearch_vector_search.html
7d9702e234ad-1
try: opensearch = _import_opensearch() client = opensearch(opensearch_url, **kwargs) except ValueError as e: raise ValueError( f"OpenSearch client string provided is not in proper format. " f"Got error: {e} " ) return client def _validate_embeddings_and_bu...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/opensearch_vector_search.html
7d9702e234ad-2
request = { "_op_type": "index", "_index": index_name, vector_field: embeddings[i], text_field: text, "metadata": metadata, "_id": _id, } requests.append(request) ids.append(_id) bulk(client, requests) client.indices...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/opensearch_vector_search.html
7d9702e234ad-3
"parameters": {"ef_construction": ef_construction, "m": m}, }, } } }, } def _default_approximate_search_query( query_vector: List[float], size: int = 4, k: int = 4, vector_field: str = "vector_field", ) -> Dict: """For Approximate k-NN Sear...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/opensearch_vector_search.html
7d9702e234ad-4
query_vector, size, k, vector_field ) search_query["query"]["knn"][vector_field]["filter"] = lucene_filter return search_query def _default_script_query( query_vector: List[float], space_type: str = "l2", pre_filter: Dict = MATCH_ALL_QUERY, vector_field: str = "vector_field", ) -> Dict: ...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/opensearch_vector_search.html
7d9702e234ad-5
vector_field: str = "vector_field", ) -> Dict: """For Painless Scripting Search, this is the default query.""" source = __get_painless_scripting_source(space_type, query_vector) return { "query": { "script_score": { "query": pre_filter, "script": { ...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/opensearch_vector_search.html
7d9702e234ad-6
bulk_size: int = 500, **kwargs: Any, ) -> List[str]: """Run more texts through the embeddings and add to the vectorstore. Args: texts: Iterable of strings to add to the vectorstore. metadatas: Optional list of metadatas associated with the texts. bulk_size...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/opensearch_vector_search.html
7d9702e234ad-7
texts, metadatas, vector_field, text_field, mapping, ) [docs] def similarity_search( self, query: str, k: int = 4, **kwargs: Any ) -> List[Document]: """Return docs most similar to query. By default supports Approximate Search. ...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/opensearch_vector_search.html
7d9702e234ad-8
search_type: "script_scoring"; default: "approximate_search" space_type: "l2", "l1", "linf", "cosinesimil", "innerproduct", "hammingbit"; default: "l2" pre_filter: script_score query to pre-filter documents before identifying nearest neighbors; default: {"match_all": {}} ...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/opensearch_vector_search.html
7d9702e234ad-9
"is invalid" ) if boolean_filter != {}: search_query = _approximate_search_query_with_boolean_filter( embedding, boolean_filter, size, k, vector_field, subquery_clause ) elif lucene_filter != {}: search_query = _...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/opensearch_vector_search.html
7d9702e234ad-10
for hit in hits ] return documents [docs] @classmethod def from_texts( cls, texts: List[str], embedding: Embeddings, metadatas: Optional[List[dict]] = None, bulk_size: int = 500, **kwargs: Any, ) -> OpenSearchVectorSearch: """Construct O...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/opensearch_vector_search.html
7d9702e234ad-11
ef_construction: Size of the dynamic list used during k-NN graph creation. Higher values lead to more accurate graph but slower indexing speed; default: 512 m: Number of bidirectional links created for each new element. Large impact on memory consumption. Between 2 and 10...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/opensearch_vector_search.html
7d9702e234ad-12
if is_appx_search: engine = _get_kwargs_value(kwargs, "engine", "nmslib") space_type = _get_kwargs_value(kwargs, "space_type", "l2") ef_search = _get_kwargs_value(kwargs, "ef_search", 512) ef_construction = _get_kwargs_value(kwargs, "ef_construction", 512) m =...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/opensearch_vector_search.html
1c013a9ce4d2-0
Source code for langchain.vectorstores.qdrant """Wrapper around Qdrant vector database.""" from __future__ import annotations import uuid from hashlib import md5 from operator import itemgetter from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Type, Union from langchain.docstore.document import D...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
1c013a9ce4d2-1
if not isinstance(client, qdrant_client.QdrantClient): raise ValueError( f"client should be an instance of qdrant_client.QdrantClient, " f"got {type(client)}" ) self.client: qdrant_client.QdrantClient = client self.collection_name = collection_name...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
1c013a9ce4d2-2
k: int = 4, filter: Optional[MetadataFilter] = None, **kwargs: Any, ) -> List[Document]: """Return docs most similar to query. Args: query: Text to look up documents similar to. k: Number of Documents to return. Defaults to 4. filter: Filter by met...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
1c013a9ce4d2-3
self, query: str, k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, **kwargs: Any, ) -> List[Document]: """Return docs selected using the maximal marginal relevance. Maximal marginal relevance optimizes for similarity to query AND diversity amon...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
1c013a9ce4d2-4
embedding: Embeddings, metadatas: Optional[List[dict]] = None, location: Optional[str] = None, url: Optional[str] = None, port: Optional[int] = 6333, grpc_port: int = 6334, prefer_grpc: bool = False, https: Optional[bool] = None, api_key: Optional[str] = N...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
1c013a9ce4d2-5
grpc_port: Port of the gRPC interface. Default: 6334 prefer_grpc: If true - use gPRC interface whenever possible in custom methods. Default: False https: If true - use HTTPS(SSL) protocol. Default: None api_key: API key for authentication in Qdrant Clo...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
1c013a9ce4d2-6
2. Initializes the Qdrant database as an in-memory docstore by default (and overridable to a remote docstore) 3. Adds the text embeddings to the Qdrant database This is intended to be a quick way to get started. Example: .. code-block:: python from ...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
1c013a9ce4d2-7
), ) # Now generate the embeddings for all the texts embeddings = embedding.embed_documents(texts) client.upsert( collection_name=collection_name, points=rest.Batch.construct( ids=[md5(text.encode("utf-8")).hexdigest() for text in texts], ...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
1c013a9ce4d2-8
metadata_payload_key: str, ) -> Document: return Document( page_content=scored_point.payload.get(content_payload_key), metadata=scored_point.payload.get(metadata_payload_key) or {}, ) def _qdrant_filter_from_dict(self, filter: Optional[MetadataFilter]) -> Any: if ...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
17f93c1e05ef-0
Source code for langchain.document_loaders.evernote """Load documents from Evernote. https://gist.github.com/foxmask/7b29c43a161e001ff04afdb2f181e31c """ import hashlib from base64 import b64decode from time import strptime from typing import Any, Dict, List from langchain.docstore.document import Document from langcha...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/evernote.html
17f93c1e05ef-1
else: note_dict[elem.tag] = elem.text note_dict["resource"] = resources return note_dict def _parse_note_xml(xml_file: str) -> str: """Parse Evernote xml.""" # Without huge_tree set to True, parser may complain about huge text node # Try to recover, because there may be " ", which w...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/evernote.html
c19a0bb25641-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/notion.html
05336f7adec2-0
Source code for langchain.document_loaders.markdown """Loader that loads Markdown files.""" from typing import List from langchain.document_loaders.unstructured import UnstructuredFileLoader [docs]class UnstructuredMarkdownLoader(UnstructuredFileLoader): """Loader that uses unstructured to load markdown files.""" ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/markdown.html
39508037cfde-0
Source code for langchain.document_loaders.text from typing import List, Optional from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class TextLoader(BaseLoader): """Load text files.""" def __init__(self, file_path: str, encoding: Optional[str] = None):...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/text.html
9d608f3ebe7c-0
Source code for langchain.document_loaders.arxiv from typing import List, Optional from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.utilities.arxiv import ArxivAPIWrapper [docs]class ArxivLoader(BaseLoader): """Loads a query result from arxiv.org...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/arxiv.html
e16babed833e-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/azure_blob_storage_file.html
abebceab4031-0
Source code for langchain.document_loaders.whatsapp_chat import re from pathlib import Path from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader def concatenate_rows(date: str, sender: str, text: str) -> str: """Combine message information i...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/whatsapp_chat.html
ff548d8eebc5-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/python.html
1f4c171cac80-0
Source code for langchain.document_loaders.gcs_file """Loading logic for loading documents from a GCS file.""" import os import tempfile from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.document_loaders.unstructured import Uns...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/gcs_file.html
d5849b59431c-0
Source code for langchain.document_loaders.airbyte_json """Loader that loads local airbyte json files.""" import json from typing import Any, List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader def _stringify_value(val: Any) -> str: if isinstance(val, str): ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/airbyte_json.html
e8c7533d7d1f-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/url.html
e8c7533d7d1f-1
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 of `{_valid_modes}`" ) def __is_headers_available_for_html(self) -> bool: _unst...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/url.html
e8c7533d7d1f-2
elements = partition(url=url, **self.unstructured_kwargs) else: if self.__is_headers_available_for_html(): elements = partition_html( url=url, headers=self.headers, **self.unstructured_kwargs ) ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/url.html
3847bc66b708-0
Source code for langchain.document_loaders.sitemap """Loader that fetches a sitemap and loads those URLs.""" import re from typing import Any, Callable, List, Optional from langchain.document_loaders.web_base import WebBaseLoader from langchain.schema import Document def _default_parsing_function(content: Any) -> str: ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/sitemap.html
3847bc66b708-1
re.match(r, loc.text) for r in self.filter_urls ): continue els.append( { tag: prop.text for tag in ["loc", "lastmod", "changefreq", "priority"] if (prop := url.find(tag)) } ) ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/sitemap.html
94fdca5c0fea-0
Source code for langchain.document_loaders.csv_loader from csv import DictReader from typing import Dict, List, Optional from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class CSVLoader(BaseLoader): """Loads a CSV file into a list of documents. Each d...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/csv_loader.html
94fdca5c0fea-1
with open(self.file_path, newline="", encoding=self.encoding) as csvfile: csv = DictReader(csvfile, **self.csv_args) # type: ignore for i, row in enumerate(csv): content = "\n".join(f"{k.strip()}: {v.strip()}" for k, v in row.items()) if self.source_column is not...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/csv_loader.html
cedbe13aa256-0
Source code for langchain.document_loaders.dataframe """Load from Dataframe object""" from typing import Any, List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class DataFrameLoader(BaseLoader): """Load Pandas DataFrames.""" def __init__(self, dat...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/dataframe.html
f3cd578f9989-0
Source code for langchain.document_loaders.apify_dataset """Logic for loading documents from Apify datasets.""" from typing import Any, Callable, Dict, List from pydantic import BaseModel, root_validator from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/apify_dataset.html
f3cd578f9989-1
) return values [docs] def load(self) -> List[Document]: """Load documents.""" dataset_items = self.apify_client.dataset(self.dataset_id).list_items().items return list(map(self.dataset_mapping_function, dataset_items)) By Harrison Chase © Copyright 2023, Harrison Chase. ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/apify_dataset.html
759af0d3e7d8-0
Source code for langchain.document_loaders.unstructured """Loader that uses unstructured to load files.""" from abc import ABC, abstractmethod from typing import IO, Any, List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader def satisfies_min_unstructured_version(m...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/unstructured.html
759af0d3e7d8-1
) self.mode = mode if not satisfies_min_unstructured_version("0.5.4"): if "strategy" in unstructured_kwargs: unstructured_kwargs.pop("strategy") self.unstructured_kwargs = unstructured_kwargs @abstractmethod def _get_elements(self) -> List: """Get elem...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/unstructured.html
759af0d3e7d8-2
): """Initialize with file path.""" self.file_path = file_path super().__init__(mode=mode, **unstructured_kwargs) def _get_elements(self) -> List: from unstructured.partition.auto import partition return partition(filename=self.file_path, **self.unstructured_kwargs) def _...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/unstructured.html
a2050ad13397-0
Source code for langchain.document_loaders.obsidian """Loader that loads Obsidian directory dump.""" import re from pathlib import Path from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class ObsidianLoader(BaseLoader): """Loader th...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/obsidian.html
a2050ad13397-1
"""Load documents.""" ps = list(Path(self.file_path).glob("**/*.md")) docs = [] for p in ps: with open(p, encoding=self.encoding) as f: text = f.read() front_matter = self._parse_front_matter(text) text = self._remove_front_matter(text) ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/obsidian.html
ce9083fff54f-0
Source code for langchain.document_loaders.discord """Load from Discord chat dump""" from __future__ import annotations from typing import TYPE_CHECKING, List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader if TYPE_CHECKING: import pandas as pd [docs]class Dis...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/discord.html
c9ab401eb059-0
Source code for langchain.document_loaders.telegram """Loader that loads Telegram chat json dump.""" 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) -> str: """Combine...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/telegram.html
c9ab401eb059-1
metadata = {"source": str(p)} return [Document(page_content=text, metadata=metadata)] By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 28, 2023.
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/telegram.html
942dd9cedf04-0
Source code for langchain.document_loaders.powerpoint """Loader that loads powerpoint files.""" import os from typing import List from langchain.document_loaders.unstructured import UnstructuredFileLoader [docs]class UnstructuredPowerPointLoader(UnstructuredFileLoader): """Loader that uses unstructured to load powe...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/powerpoint.html
942dd9cedf04-1
return partition_pptx(filename=self.file_path, **self.unstructured_kwargs) By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 28, 2023.
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/powerpoint.html
1e9823940722-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 from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class ReadTheDocsLoader(B...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/readthedocs.html
1e9823940722-1
text = text[0].get_text() else: text = "" return "\n".join([t for t in text.split("\n") if t]) docs = [] for p in Path(self.file_path).rglob("*"): if p.is_dir(): continue with open(p, encoding=self.encoding, errors=self.erro...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/readthedocs.html
f6ebf3e5e386-0
Source code for langchain.document_loaders.roam """Loader that loads Roam directory dump.""" from pathlib import Path from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class RoamLoader(BaseLoader): """Loader that loads Roam files fr...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/roam.html
456aab56c934-0
Source code for langchain.document_loaders.image_captions """ Loader that loads image captions By default, the loader utilizes the pre-trained BLIP image captioning model. https://huggingface.co/Salesforce/blip-image-captioning-base """ from typing import Any, List, Tuple, Union import requests from langchain.docstore....
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/image_captions.html
456aab56c934-1
model=model, processor=processor, path_image=path_image ) doc = Document(page_content=caption, metadata=metadata) results.append(doc) return results def _get_captions_and_metadata( self, model: Any, processor: Any, path_image: str ) -> Tuple[str, dict]: ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/image_captions.html
b0d9f3504d21-0
Source code for langchain.document_loaders.s3_directory """Loading logic for loading documents from an s3 directory.""" from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.document_loaders.s3_file import S3FileLoader [docs]class ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/s3_directory.html
5a158bbe62c4-0
Source code for langchain.document_loaders.rtf """Loader that loads rich text files.""" from typing import Any, List from langchain.document_loaders.unstructured import ( UnstructuredFileLoader, satisfies_min_unstructured_version, ) [docs]class UnstructuredRTFLoader(UnstructuredFileLoader): """Loader that u...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/rtf.html
7f6e9ceb48ad-0
Source code for langchain.document_loaders.blackboard """Loader that loads all documents from a blackboard course.""" import contextlib import re from pathlib import Path from typing import Any, List, Optional, Tuple from urllib.parse import unquote from langchain.docstore.document import Document from langchain.docume...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
7f6e9ceb48ad-1
): """Initialize with blackboard course url. The BbRouter cookie is required for most blackboard courses. Args: blackboard_course_url: Blackboard course url. bbrouter: BbRouter cookie. load_all_recursively: If True, load all documents recursively. ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
7f6e9ceb48ad-2
"""Load data into document objects. Returns: List of documents. """ if self.load_all_recursively: soup_info = self.scrape() self.folder_path = self._get_folder_path(soup_info) relative_paths = self._get_paths(soup_info) documents = [] ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
7f6e9ceb48ad-3
) # Get the folder path folder_path = Path(".") / course_name_clean return str(folder_path) def _get_documents(self, soup: Any) -> List[Document]: """Fetch content from page and return Documents. Args: soup: BeautifulSoup4 soup object. Returns: ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
7f6e9ceb48ad-4
Path(self.folder_path).mkdir(parents=True, exist_ok=True) # Download all attachments for attachment in attachments: self.download(attachment) def _load_documents(self) -> List[Document]: """Load all documents in the folder. Returns: List of documents. ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
7f6e9ceb48ad-5
"""Parse the filename from a url. Args: url: Url to parse the filename from. Returns: The filename. """ if (url_path := Path(url)) and url_path.suffix == ".pdf": return url_path.name else: return self._parse_filename_from_url(url) ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
7f6e9ceb48ad-6
By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 28, 2023.
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
67a542012787-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/diffbot.html
67a542012787-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/diffbot.html
6de138ff9ec1-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/url_selenium.html
6de138ff9ec1-1
raise ValueError( "unstructured package not found, please install it with " "`pip install unstructured`" ) self.urls = urls self.continue_on_failure = continue_on_failure self.browser = browser self.executable_path = executable_path sel...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/url_selenium.html
6de138ff9ec1-2
"""Load the specified URLs using Selenium and create Document instances. Returns: List[Document]: A list of Document instances with loaded content. """ from unstructured.partition.html import partition_html docs: List[Document] = list() driver = self._get_driver() ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/url_selenium.html
23f014420cd3-0
Source code for langchain.document_loaders.email """Loader that loads email files.""" import os from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.document_loaders.unstructured import ( UnstructuredFileLoader, satisfies_...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/email.html
23f014420cd3-1
"`pip install extract_msg`" ) [docs] def load(self) -> List[Document]: """Load data into document objects.""" import extract_msg msg = extract_msg.Message(self.file_path) return [ Document( page_content=msg.body, metadata={ ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/email.html
de329f50aedb-0
Source code for langchain.document_loaders.azure_blob_storage_container """Loading logic for loading documents from an Azure Blob Storage container.""" from typing import List from langchain.docstore.document import Document from langchain.document_loaders.azure_blob_storage_file import ( AzureBlobStorageFileLoader...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/azure_blob_storage_container.html
b111c74f66f9-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/html.html
82559b1a43bd-0
Source code for langchain.document_loaders.confluence """Load Data from a Confluence Space""" import logging from typing import Any, Callable, List, Optional, Union from tenacity import ( before_sleep_log, retry, stop_after_attempt, wait_exponential, ) from langchain.docstore.document import Document fr...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
82559b1a43bd-1
:param url: _description_ :type url: str :param api_key: _description_, defaults to None :type api_key: str, optional :param username: _description_, defaults to None :type username: str, optional :param oauth2: _description_, defaults to {} :type oauth2: dict, optional :param cloud: _de...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
82559b1a43bd-2
if errors: raise ValueError(f"Error(s) while validating input: {errors}") self.base_url = url self.number_of_retries = number_of_retries self.min_retry_seconds = min_retry_seconds self.max_retry_seconds = max_retry_seconds try: from atlassian import Conflu...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
82559b1a43bd-3
"`username` and provide a value for `oauth2`" ) if oauth2 and oauth2.keys() != [ "access_token", "access_token_secret", "consumer_key", "key_cert", ]: errors.append( "You have either ommited require keys or added ext...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
82559b1a43bd-4
:param include_comments: defaults to False :type include_comments: bool, optional :param limit: Maximum number of pages to retrieve per request, defaults to 50 :type limit: int, optional :param max_pages: Maximum number of pages to retrieve in total, defaults 1000 :type max_pages...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
82559b1a43bd-5
max_pages=max_pages, expand="body.storage.value", ) for page in pages: doc = self.process_page(page, include_attachments, include_comments) docs.append(doc) if page_ids: for page_id in page_ids: get_page = retry(...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
82559b1a43bd-6
of pages with each request. We have to manually check if there are more docs based on the length of the returned list of pages, rather than just checking for the presence of a `next` key in the response like this page would have you do: https://developer.atlassian.com/server/confluence/p...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
82559b1a43bd-7
" `pip install beautifulsoup4`" ) if include_attachments: attachment_texts = self.process_attachment(page["id"]) else: attachment_texts = [] text = BeautifulSoup( page["body"]["storage"]["value"], "lxml" ).get_text() + "".join(attachment_te...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
82559b1a43bd-8
title = attachment["title"] if media_type == "application/pdf": text = title + self.process_pdf(absolute_url) elif ( media_type == "image/png" or media_type == "image/jpg" or media_type == "image/jpeg" ): ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
82559b1a43bd-9
except ValueError: return text for i, image in enumerate(images): image_text = pytesseract.image_to_string(image) text += f"Page {i + 1}:\n{image_text}\n\n" return text [docs] def process_image(self, link: str) -> str: try: from io import BytesI...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
82559b1a43bd-10
): return text file_data = BytesIO(response.content) return docx2txt.process(file_data) [docs] def process_xls(self, link: str) -> str: try: import xlrd # noqa: F401 except ImportError: raise ImportError("`xlrd` package not found, please run `pip i...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
82559b1a43bd-11
) response = self.confluence.request(path=link, absolute=True) text = "" if ( response.status_code != 200 or response.content == b"" or response.content is None ): return text drawing = svg2rlg(BytesIO(response.content)) img...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
5a4b2526934d-0
Source code for langchain.document_loaders.imsdb """Loader that loads IMSDb.""" from typing import List from langchain.docstore.document import Document from langchain.document_loaders.web_base import WebBaseLoader [docs]class IMSDbLoader(WebBaseLoader): """Loader that loads IMSDb webpages.""" [docs] def load(se...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/imsdb.html
a6cd8d7b5856-0
Source code for langchain.document_loaders.image """Loader that loads image files.""" from typing import List from langchain.document_loaders.unstructured import UnstructuredFileLoader [docs]class UnstructuredImageLoader(UnstructuredFileLoader): """Loader that uses unstructured to load image files, such as PNGs and...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/image.html