id
stringlengths
14
16
text
stringlengths
29
2.73k
source
stringlengths
49
117
bc94e8ce763f-1
self.file_path = file_path self.load_single_document = load_single_document [docs] def load(self) -> List[Document]: """Load documents from EverNote export file.""" documents = [ Document( page_content=note["content"], metadata={ ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/evernote.html
bc94e8ce763f-2
rsc_dict["hash"] = hashlib.md5(rsc_dict[elem.tag]).hexdigest() else: rsc_dict[elem.tag] = elem.text return rsc_dict @staticmethod def _parse_note(note: List, prefix: Optional[str] = None) -> dict: note_dict: Dict[str, Any] = {} resources = [] def add_p...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/evernote.html
bc94e8ce763f-3
# Without huge_tree set to True, parser may complain about huge text node # Try to recover, because there may be " ", which will cause # "XMLSyntaxError: Entity 'nbsp' not defined" try: from lxml import etree except ImportError as e: logging.error( ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/evernote.html
12afd2394ce0-0
Source code for langchain.document_loaders.trello """Loader that 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.util...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/trello.html
12afd2394ce0-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/trello.html
12afd2394ce0-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/trello.html
12afd2394ce0-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/trello.html
f4b92cfe94af-0
Source code for langchain.document_loaders.conllu """Load CoNLL-U files.""" import csv from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class CoNLLULoader(BaseLoader): """Load CoNLL-U files.""" def __init__(self, file_path: str...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/conllu.html
c92a133ad81b-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
a4dd65d54e2e-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/git.html
a4dd65d54e2e-1
else: repo = Repo(self.repo_path) repo.git.checkout(self.branch) docs: List[Document] = [] for item in repo.tree().traverse(): if not isinstance(item, Blob): continue file_path = os.path.join(self.repo_path, item.path) ignored_f...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/git.html
92a77b071c55-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
92a77b071c55-1
text_content += concatenate_rows(date, sender, text) metadata = {"source": str(p)} return [Document(page_content=text_content, metadata=metadata)] By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/whatsapp_chat.html
8c63ec1a8bcb-0
Source code for langchain.document_loaders.confluence """Load Data from a Confluence Space""" import logging from io import BytesIO from typing import Any, Callable, List, Optional, Union from tenacity import ( before_sleep_log, retry, stop_after_attempt, wait_exponential, ) from langchain.docstore.docu...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
8c63ec1a8bcb-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
8c63ec1a8bcb-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
8c63ec1a8bcb-3
errors.append( "Cannot provide a value for `api_key` and/or " "`username` and provide a value for `oauth2`" ) if oauth2 and oauth2.keys() != [ "access_token", "access_token_secret", "consumer_key", "key_cert", ]:...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
8c63ec1a8bcb-4
:type cql: Optional[str], optional :param include_restricted_content: defaults to False :type include_restricted_content: bool, optional :param include_archived_content: Whether to include archived content, defaults to False :type include_archived...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
8c63ec1a8bcb-5
label=label, limit=limit, max_pages=max_pages, ) ids_by_label = [page["id"] for page in pages] if page_ids: page_ids = list(set(page_ids + ids_by_label)) else: page_ids = list(set(ids_by_label)) if cq...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
8c63ec1a8bcb-6
"""Paginate the various methods to retrieve groups of pages. Unfortunately, due to page size, sometimes the Confluence API doesn't match the limit value. If `limit` is >100 confluence seems to cap the response to 100. Also, due to the Atlassian Python package, we don't get the "next" va...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
8c63ec1a8bcb-7
if not batch: break docs.extend(batch) return docs[:max_pages] [docs] def is_public_page(self, page: dict) -> bool: """Check if a page is publicly accessible.""" restrictions = self.confluence.get_all_restrictions_for_content(page["id"]) return ( ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
8c63ec1a8bcb-8
).get_text() + "".join(attachment_texts) if include_comments: comments = self.confluence.get_page_comments( page["id"], expand="body.view.value", depth="all" )["results"] comment_texts = [ BeautifulSoup(comment["body"]["view"]["value"], "lxml")...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
8c63ec1a8bcb-9
elif ( media_type == "application/vnd.openxmlformats-officedocument" ".wordprocessingml.document" ): text = title + self.process_doc(absolute_url) elif media_type == "application/vnd.ms-excel": text = title + self.process_xls(absolu...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
8c63ec1a8bcb-10
except ImportError: raise ImportError( "`pytesseract` or `Pillow` package not found, " "please run `pip install pytesseract Pillow`" ) response = self.confluence.request(path=link, absolute=True) text = "" if ( response.status_c...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
8c63ec1a8bcb-11
or response.content is None ): return text workbook = xlrd.open_workbook(file_contents=response.content) for sheet in workbook.sheets(): text += f"{sheet.name}:\n" for row in range(sheet.nrows): for col in range(sheet.ncols): ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
cb7c385224f0-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://python.langchain.com/en/latest/_modules/langchain/document_loaders/wikipedia.html
28d414493e2b-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
28d414493e2b-1
raise ImportError( "selenium package not found, please install it with " "`pip install selenium`" ) try: import unstructured # noqa:F401 except ImportError: raise ImportError( "unstructured package not found, please ins...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/url_selenium.html
28d414493e2b-2
for arg in self.arguments: firefox_options.add_argument(arg) if self.headless: firefox_options.add_argument("--headless") if self.binary_location is not None: firefox_options.binary_location = self.binary_location if self.executable_pat...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/url_selenium.html
078a1c242499-0
Source code for langchain.document_loaders.blockchain import os import re import time from enum import Enum from typing import List, Optional import requests from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader class BlockchainType(Enum): ETH_MAINNET = "eth-mainnet...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blockchain.html
078a1c242499-1
""" def __init__( self, contract_address: str, blockchainType: BlockchainType = BlockchainType.ETH_MAINNET, api_key: str = "docs-demo", startToken: str = "", get_all_tokens: bool = False, max_execution_time: Optional[int] = None, ): self.contract_a...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blockchain.html
078a1c242499-2
tokenId = item["id"]["tokenId"] metadata = { "source": self.contract_address, "blockchain": self.blockchainType, "tokenId": tokenId, } result.append(Document(page_content=content, metadata=metadata)) ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blockchain.html
078a1c242499-3
elif value_type == "hex_0xbf": return "0xbf" + format(result, "0" + str(len(tokenId) - 4) + "x") else: return str(result) # A smart contract can use different formats for the tokenId @staticmethod def _detect_value_type(tokenId: str) -> str: if isinstance(tokenId, int...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blockchain.html
9f66eeabecad-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
c7434f5d0dda-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
3b17076c8fe3-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
3b17076c8fe3-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
af7a0982dd54-0
Source code for langchain.document_loaders.epub """Loader that loads EPub files.""" from typing import List from langchain.document_loaders.unstructured import ( UnstructuredFileLoader, satisfies_min_unstructured_version, ) [docs]class UnstructuredEPubLoader(UnstructuredFileLoader): """Loader that uses unst...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/epub.html
a6ef5190831a-0
Source code for langchain.document_loaders.mastodon """Mastodon document loader.""" from __future__ import annotations import os from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Optional, Sequence from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader if TYPE...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/mastodon.html
a6ef5190831a-1
access_token = access_token or os.environ.get("MASTODON_ACCESS_TOKEN") self.api = mastodon.Mastodon( access_token=access_token, api_base_url=api_base_url ) self.mastodon_accounts = mastodon_accounts self.number_toots = number_toots self.exclude_replies = exclude_repli...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/mastodon.html
8c6989dd304b-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
05516020851d-0
Source code for langchain.document_loaders.csv_loader import csv 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 document represen...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/csv_loader.html
05516020851d-1
for i, row in enumerate(csv_reader): content = "\n".join(f"{k.strip()}: {v.strip()}" for k, v in row.items()) try: source = ( row[self.source_column] if self.source_column is not None else self.fi...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/csv_loader.html
f7a942fc2eb2-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
f7a942fc2eb2-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
f7a942fc2eb2-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
75cef2a8b367-0
Source code for langchain.document_loaders.readthedocs """Loader that loads ReadTheDocs documentation directory dump.""" from pathlib import Path from typing import Any, List, Optional, Tuple, Union from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class ReadT...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/readthedocs.html
75cef2a8b367-1
from bs4 import BeautifulSoup except ImportError: raise ImportError( "Could not import python packages. " "Please install it with `pip install beautifulsoup4`. " ) try: _ = BeautifulSoup( "<html><body>Parser builder libr...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/readthedocs.html
75cef2a8b367-2
if text is not None: break if text is not None: text = text.get_text() else: text = "" # trim empty lines return "\n".join([t for t in text.split("\n") if t]) By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on J...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/readthedocs.html
40a06eb74f99-0
Source code for langchain.document_loaders.odt """Loader that loads Open Office ODT files.""" from typing import Any, List from langchain.document_loaders.unstructured import ( UnstructuredFileLoader, validate_unstructured_version, ) [docs]class UnstructuredODTLoader(UnstructuredFileLoader): """Loader that ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/odt.html
43acafc5e794-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
b2096a22ad2f-0
Source code for langchain.document_loaders.stripe """Loader that fetches data from Stripe""" import json import urllib.request from typing import List, Optional from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.utils import get_from_env, stringify_dic...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/stripe.html
b2096a22ad2f-1
if endpoint is None: return [] return self._make_request(endpoint) [docs] def load(self) -> List[Document]: return self._get_resource() By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/stripe.html
660ac79b673f-0
Source code for langchain.document_loaders.gcs_directory """Loading logic for loading documents from an GCS directory.""" from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.document_loaders.gcs_file import GCSFileLoader [docs]cl...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/gcs_directory.html
bbe7acea464b-0
Source code for langchain.document_loaders.toml import json from pathlib import Path from typing import Iterator, List, Union from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class TomlLoader(BaseLoader): """ A TOML document loader that inherits from ...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/toml.html
bbe7acea464b-1
By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/toml.html
1c176c4fb836-0
Source code for langchain.document_loaders.word_document """Loader that loads word documents.""" import os import tempfile from abc import ABC from typing import List from urllib.parse import urlparse import requests from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/word_document.html
1c176c4fb836-1
if hasattr(self, "temp_file"): self.temp_file.close() [docs] def load(self) -> List[Document]: """Load given path as single page.""" import docx2txt return [ Document( page_content=docx2txt.process(self.file_path), metadata={"source": se...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/word_document.html
1c176c4fb836-2
f"You are on unstructured version {__unstructured_version__}. " "Partitioning .doc files is only supported in unstructured>=0.4.11. " "Please upgrade the unstructured package and try again." ) if is_doc: from unstructured.partition.doc import partition_doc...
https://python.langchain.com/en/latest/_modules/langchain/document_loaders/word_document.html
d76983dfd49b-0
Source code for langchain.vectorstores.weaviate """Wrapper around weaviate vector database.""" from __future__ import annotations import datetime from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Type from uuid import uuid4 import numpy as np from langchain.docstore.document import Document from ...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/weaviate.html
d76983dfd49b-1
if weaviate_api_key is not None else None ) client = weaviate.Client(weaviate_url, auth_client_secret=auth) return client def _default_score_normalizer(val: float) -> float: return 1 - 1 / (1 + np.exp(val)) def _json_serializable(value: Any) -> Any: if isinstance(value, datetime.datetime): ...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/weaviate.html
d76983dfd49b-2
) if not isinstance(client, weaviate.Client): raise ValueError( f"client should be an instance of weaviate.Client, got {type(client)}" ) self._client = client self._index_name = index_name self._embedding = embedding self._text_key = text_k...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/weaviate.html
d76983dfd49b-3
class_name=self._index_name, uuid=_id, vector=vector, ) ids.append(_id) return ids [docs] def similarity_search( self, query: str, k: int = 4, **kwargs: Any ) -> List[Document]: """Return docs most similar to query. ...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/weaviate.html
d76983dfd49b-4
if kwargs.get("where_filter"): query_obj = query_obj.with_where(kwargs.get("where_filter")) if kwargs.get("additional"): query_obj = query_obj.with_additional(kwargs.get("additional")) result = query_obj.with_near_text(content).with_limit(k).do() if "errors" in result: ...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/weaviate.html
d76983dfd49b-5
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 among selected documents. Args...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/weaviate.html
d76983dfd49b-6
among selected documents. Args: embedding: Embedding to look up documents similar to. k: Number of Documents to return. Defaults to 4. fetch_k: Number of Documents to fetch to pass to MMR algorithm. lambda_mult: Number between 0 and 1 that determines the degree ...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/weaviate.html
d76983dfd49b-7
if self._embedding is None: raise ValueError( "_embedding cannot be None for similarity_search_with_score" ) content: Dict[str, Any] = {"concepts": [query]} if kwargs.get("search_distance"): content["certainty"] = kwargs.get("search_distance") ...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/weaviate.html
d76983dfd49b-8
0 is dissimilar, 1 is most similar. """ if self._relevance_score_fn is None: raise ValueError( "relevance_score_fn must be provided to" " Weaviate constructor to normalize scores" ) docs_and_scores = self.similarity_search_with_score(query,...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/weaviate.html
d76983dfd49b-9
embeddings = embedding.embed_documents(texts) if embedding else None text_key = "text" schema = _default_schema(index_name) attributes = list(metadatas[0].keys()) if metadatas else None # check whether the index already exists if not client.schema.contains(schema): cl...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/weaviate.html
d76983dfd49b-10
text_key, embedding=embedding, attributes=attributes, relevance_score_fn=relevance_score_fn, by_text=by_text, ) By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/weaviate.html
a7c8267d464c-0
Source code for langchain.vectorstores.annoy """Wrapper around Annoy vector database.""" from __future__ import annotations import os import pickle import uuid from configparser import ConfigParser from pathlib import Path from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple import numpy as np from l...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/annoy.html
a7c8267d464c-1
): """Initialize with necessary components.""" self.embedding_function = embedding_function self.index = index self.metric = metric self.docstore = docstore self.index_to_docstore_id = index_to_docstore_id [docs] def add_texts( self, texts: Iterable[str...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/annoy.html
a7c8267d464c-2
Args: query: Text to look up documents similar to. k: Number of Documents to return. Defaults to 4. search_k: inspect up to search_k nodes which defaults to n_trees * n if not provided Returns: List of Documents most similar to the query and score ...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/annoy.html
a7c8267d464c-3
k: Number of Documents to return. Defaults to 4. search_k: inspect up to search_k nodes which defaults to n_trees * n if not provided Returns: List of Documents most similar to the query and score for each """ embedding = self.embedding_function(query) ...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/annoy.html
a7c8267d464c-4
Returns: List of Documents most similar to the embedding. """ docs_and_scores = self.similarity_search_with_score_by_index( docstore_index, k, search_k ) return [doc for doc, _ in docs_and_scores] [docs] def similarity_search( self, query: str, k: int =...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/annoy.html
a7c8267d464c-5
of diversity among the results with 0 corresponding to maximum diversity and 1 to minimum diversity. Defaults to 0.5. Returns: List of Documents selected by maximal marginal relevance. """ idxs = self.index.get_nns_by_vector( ...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/annoy.html
a7c8267d464c-6
k: Number of Documents to return. Defaults to 4. fetch_k: Number of Documents to fetch to pass to MMR algorithm. lambda_mult: Number between 0 and 1 that determines the degree of diversity among the results with 0 corresponding to maximum diversity...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/annoy.html
a7c8267d464c-7
documents = [] for i, text in enumerate(texts): metadata = metadatas[i] if metadatas else {} documents.append(Document(page_content=text, metadata=metadata)) index_to_id = {i: str(uuid.uuid4()) for i in range(len(documents))} docstore = InMemoryDocstore( {inde...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/annoy.html
a7c8267d464c-8
from langchain.embeddings import OpenAIEmbeddings embeddings = OpenAIEmbeddings() index = Annoy.from_texts(texts, embeddings) """ embeddings = embedding.embed_documents(texts) return cls.__from( texts, embeddings, embedding, metadatas, metric, trees, n...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/annoy.html
a7c8267d464c-9
text_embedding_pairs = list(zip(texts, text_embeddings)) db = Annoy.from_embeddings(text_embedding_pairs, embeddings) """ texts = [t[0] for t in text_embeddings] embeddings = [t[1] for t in text_embeddings] return cls.__from( texts, embeddings, embedding, meta...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/annoy.html
a7c8267d464c-10
Args: folder_path: folder path to load index, docstore, and index_to_docstore_id from. embeddings: Embeddings to use when generating queries. """ path = Path(folder_path) # load index separately since it is not picklable annoy = dependable_annoy_im...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/annoy.html
774ef480a8fa-0
Source code for langchain.vectorstores.zilliz from __future__ import annotations import logging from typing import Any, List, Optional from langchain.embeddings.base import Embeddings from langchain.vectorstores.milvus import Milvus logger = logging.getLogger(__name__) [docs]class Zilliz(Milvus): def _create_index(...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/zilliz.html
774ef480a8fa-1
"Failed to create an index on collection: %s", self.collection_name ) raise e [docs] @classmethod def from_texts( cls, texts: List[str], embedding: Embeddings, metadatas: Optional[List[dict]] = None, collection_name: str = "LangChainCollecti...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/zilliz.html
774ef480a8fa-2
""" vector_db = cls( embedding_function=embedding, collection_name=collection_name, connection_args=connection_args, consistency_level=consistency_level, index_params=index_params, search_params=search_params, drop_old=drop_old,...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/zilliz.html
5d4e4a2e4ed9-0
Source code for langchain.vectorstores.qdrant """Wrapper around Qdrant vector database.""" from __future__ import annotations import uuid import warnings from hashlib import md5 from itertools import islice from operator import itemgetter from typing import ( TYPE_CHECKING, Any, Callable, Dict, Iter...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
5d4e4a2e4ed9-1
metadata_payload_key: str = METADATA_KEY, embedding_function: Optional[Callable] = None, # deprecated ): """Initialize with necessary components.""" try: import qdrant_client except ImportError: raise ValueError( "Could not import qdrant-clien...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
5d4e4a2e4ed9-2
"Using `embeddings` as `embedding_function` which is deprecated" ) self._embeddings_function = embeddings self.embeddings = None def _embed_query(self, query: str) -> List[float]: """Embed query text. Used to provide backward compatibility with `embedding_function...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
5d4e4a2e4ed9-3
[docs] def add_texts( self, texts: Iterable[str], metadatas: Optional[List[dict]] = None, batch_size: int = 64, **kwargs: Any, ) -> List[str]: """Run more texts through the embeddings and add to the vectorstore. Args: texts: Iterable of strings ...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
5d4e4a2e4ed9-4
**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 metadata. Defaults to None. Returns: List of Documen...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
5d4e4a2e4ed9-5
limit=k, ) return [ ( self._document_from_scored_point( result, self.content_payload_key, self.metadata_payload_key ), result.score, ) for result in results ] [docs] def max_marginal_releva...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
5d4e4a2e4ed9-6
) return [ self._document_from_scored_point( results[i], self.content_payload_key, self.metadata_payload_key ) for i in mmr_selected ] [docs] @classmethod def from_texts( cls: Type[Qdrant], texts: List[str], embedding: Em...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
5d4e4a2e4ed9-7
If `str` - use it as a `url` parameter. If `None` - fallback to relying on `host` and `port` parameters. url: either host or str of "Optional[scheme], host, Optional[port], Optional[prefix]". Default: `None` port: Port of the REST API interface. Default: 6333 ...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
5d4e4a2e4ed9-8
Default: "page_content" metadata_payload_key: A payload key used to store the metadata of the document. Default: "metadata" **kwargs: Additional arguments passed directly into REST client initialization This is a user-friendly interface tha...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
5d4e4a2e4ed9-9
api_key=api_key, prefix=prefix, timeout=timeout, host=host, path=path, **kwargs, ) client.recreate_collection( collection_name=collection_name, vectors_config=rest.VectorParams( size=vector_size, ...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
5d4e4a2e4ed9-10
payloads = [] for i, text in enumerate(texts): if text is None: raise ValueError( "At least one of the texts is None. Please remove it before " "calling .from_texts or .add_texts on Qdrant instance." ) metadata = met...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
5d4e4a2e4ed9-11
) return out def _qdrant_filter_from_dict( self, filter: Optional[DictFilter] ) -> Optional[rest.Filter]: from qdrant_client.http import models as rest if not filter: return None return rest.Filter( must=[ condition ...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
364279978df9-0
Source code for langchain.vectorstores.elastic_vector_search """Wrapper around Elasticsearch vector database.""" from __future__ import annotations import uuid from abc import ABC from typing import Any, Dict, Iterable, List, Optional, Tuple from langchain.docstore.document import Document from langchain.embeddings.bas...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/elastic_vector_search.html
364279978df9-1
# and attributes. [docs]class ElasticVectorSearch(VectorStore, ABC): """Wrapper around Elasticsearch as a vector database. To connect to an Elasticsearch instance that does not require login credentials, pass the Elasticsearch URL and index name along with the embedding object to the constructor. Ex...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/elastic_vector_search.html
364279978df9-2
Example: .. code-block:: python from langchain import ElasticVectorSearch from langchain.embeddings import OpenAIEmbeddings embedding = OpenAIEmbeddings() elastic_host = "cluster_id.region_id.gcp.cloud.es.io" elasticsearch_url = f"https://username:pass...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/elastic_vector_search.html
364279978df9-3
except ValueError as e: raise ValueError( f"Your elasticsearch client string is mis-formatted. Got error: {e} " ) [docs] def add_texts( self, texts: Iterable[str], metadatas: Optional[List[dict]] = None, refresh_indices: bool = True, **k...
https://python.langchain.com/en/latest/_modules/langchain/vectorstores/elastic_vector_search.html