id
stringlengths
14
16
text
stringlengths
36
2.73k
source
stringlengths
49
117
961c25351698-94
Tigris (class in langchain.vectorstores) time (langchain.utilities.DuckDuckGoSearchAPIWrapper attribute) to_typescript() (langchain.tools.APIOperation method) token (langchain.llms.PredictionGuard attribute) (langchain.utilities.PowerBIDataset attribute) token_path (langchain.document_loaders.GoogleApiClient attribute)...
https://python.langchain.com/en/latest/genindex.html
961c25351698-95
(langchain.llms.LlamaCpp attribute) (langchain.llms.NLPCloud attribute) (langchain.llms.Petals attribute) (langchain.llms.VertexAI attribute) (langchain.retrievers.ChatGPTPluginRetriever attribute) (langchain.retrievers.DataberryRetriever attribute) (langchain.retrievers.PineconeHybridSearchRetriever attribute) top_k_d...
https://python.langchain.com/en/latest/genindex.html
961c25351698-96
(langchain.text_splitter.TextSplitter method) transform_input_fn (langchain.llms.Databricks attribute) transform_output_fn (langchain.llms.Databricks attribute) transformers (langchain.retrievers.document_compressors.DocumentCompressorPipeline attribute) TrelloLoader (class in langchain.document_loaders) truncate (lang...
https://python.langchain.com/en/latest/genindex.html
961c25351698-97
UnstructuredODTLoader (class in langchain.document_loaders) UnstructuredPDFLoader (class in langchain.document_loaders) UnstructuredPowerPointLoader (class in langchain.document_loaders) UnstructuredRTFLoader (class in langchain.document_loaders) UnstructuredURLLoader (class in langchain.document_loaders) UnstructuredW...
https://python.langchain.com/en/latest/genindex.html
961c25351698-98
(langchain.llms.HuggingFaceTextGenInference class method) (langchain.llms.HumanInputLLM class method) (langchain.llms.LlamaCpp class method) (langchain.llms.Modal class method) (langchain.llms.MosaicML class method) (langchain.llms.NLPCloud class method) (langchain.llms.OpenAI class method) (langchain.llms.OpenAIChat c...
https://python.langchain.com/en/latest/genindex.html
961c25351698-99
use_mlock (langchain.embeddings.LlamaCppEmbeddings attribute) (langchain.llms.GPT4All attribute) (langchain.llms.LlamaCpp attribute) use_mmap (langchain.llms.LlamaCpp attribute) use_multiplicative_presence_penalty (langchain.llms.AlephAlpha attribute) use_query_checker (langchain.chains.SQLDatabaseChain attribute) user...
https://python.langchain.com/en/latest/genindex.html
961c25351698-100
(langchain.llms.AlephAlpha attribute) (langchain.llms.Anthropic attribute) (langchain.llms.Anyscale attribute) (langchain.llms.Aviary attribute) (langchain.llms.AzureOpenAI attribute) (langchain.llms.Banana attribute) (langchain.llms.Baseten attribute) (langchain.llms.Beam attribute) (langchain.llms.Bedrock attribute) ...
https://python.langchain.com/en/latest/genindex.html
961c25351698-101
(langchain.llms.SelfHostedHuggingFaceLLM attribute) (langchain.llms.SelfHostedPipeline attribute) (langchain.llms.StochasticAI attribute) (langchain.llms.VertexAI attribute) (langchain.llms.Writer attribute) (langchain.retrievers.SelfQueryRetriever attribute) (langchain.tools.BaseTool attribute) (langchain.tools.Tool a...
https://python.langchain.com/en/latest/genindex.html
961c25351698-102
Z zapier_description (langchain.tools.ZapierNLARunAction attribute) ZepRetriever (class in langchain.retrievers) ZERO_SHOT_REACT_DESCRIPTION (langchain.agents.AgentType attribute) Zilliz (class in langchain.vectorstores) By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 11, 202...
https://python.langchain.com/en/latest/genindex.html
a1bc0fa44abd-0
.rst .pdf Welcome to LangChain Contents Getting Started Modules Use Cases Reference Docs Ecosystem Additional Resources Welcome to LangChain# LangChain is a framework for developing applications powered by language models. We believe that the most powerful and differentiated applications will not only call out to a l...
https://python.langchain.com/en/latest/index.html
a1bc0fa44abd-1
Agents: An agent is a Chain in which an LLM, given a high-level directive and a set of tools, repeatedly decides an action, executes the action and observes the outcome until the high-level directive is complete. Callbacks: Callbacks let you log and stream the intermediate steps of any chain, making it easy to observe,...
https://python.langchain.com/en/latest/index.html
a1bc0fa44abd-2
Reference Docs# Full documentation on all methods, classes, installation methods, and integration setups for LangChain. LangChain Installation Reference Documentation Ecosystem# LangChain integrates a lot of different LLMs, systems, and products. From the other side, many systems and products depend on LangChain. It cr...
https://python.langchain.com/en/latest/index.html
a1bc0fa44abd-3
By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 11, 2023.
https://python.langchain.com/en/latest/index.html
bc75ce6b3dde-0
.rst .pdf Integrations Contents Integrations by Module Dependencies All Integrations Integrations# LangChain integrates with many LLMs, systems, and products. Integrations by Module# Integrations grouped by the core LangChain module they map to: LLM Providers Chat Model Providers Text Embedding Model Providers Docume...
https://python.langchain.com/en/latest/integrations.html
bc75ce6b3dde-1
Llama.cpp MediaWikiDump Metal Microsoft OneDrive Microsoft PowerPoint Microsoft Word Milvus MLflow Modal Modern Treasury Momento MyScale NLPCloud Notion DB Obsidian OpenAI OpenSearch OpenWeatherMap Petals PGVector Pinecone PipelineAI Prediction Guard PromptLayer Psychic Qdrant Ray Serve Rebuff Reddit Redis Replicate Ro...
https://python.langchain.com/en/latest/integrations.html
af52fc0a2ee1-0
.md .pdf Dependents Dependents# Dependents stats for hwchase17/langchain [update: 2023-06-05; only dependent repositories with Stars > 100] Repository Stars openai/openai-cookbook 38024 LAION-AI/Open-Assistant 33609 microsoft/TaskMatrix 33136 hpcaitech/ColossalAI 30032 imartinez/privateGPT 28094 reworkd/AgentGPT 23430 ...
https://python.langchain.com/en/latest/dependents.html
af52fc0a2ee1-1
3545 gkamradt/langchain-tutorials 3404 mmabrouk/chatgpt-wrapper 3303 postgresml/postgresml 3052 marqo-ai/marqo 3014 MineDojo/Voyager 2945 PrefectHQ/marvin 2761 project-baize/baize-chatbot 2673 hwchase17/chat-langchain 2589 whitead/paper-qa 2572 Azure-Samples/azure-search-openai-demo 2366 GerevAI/gerev 2330 OpenGVLab/In...
https://python.langchain.com/en/latest/dependents.html
af52fc0a2ee1-2
thomas-yanxin/LangChain-ChatGLM-Webui 1182 ttengwang/Caption-Anything 1137 jina-ai/dev-gpt 1135 greshake/llm-security 1086 keephq/keep 1063 juncongmoo/chatllama 1037 richardyc/Chrome-GPT 1035 visual-openllm/visual-openllm 997 mmz-001/knowledge_gpt 995 jina-ai/langchain-serve 949 irgolic/AutoPR 936 microsoft/X-Decoder 9...
https://python.langchain.com/en/latest/dependents.html
af52fc0a2ee1-3
496 microsoft/PodcastCopilot 492 debanjum/khoj 485 akshata29/chatpdf 485 langchain-ai/langchain-aiplugin 462 jina-ai/agentchain 460 alexanderatallah/window.ai 457 yeagerai/yeagerai-agent 451 mckaywrigley/repo-chat 446 michaelthwan/searchGPT 446 mpaepper/content-chatbot 441 freddyaboulton/gradio-tools 439 ruoccofabrizio...
https://python.langchain.com/en/latest/dependents.html
af52fc0a2ee1-4
267 Anil-matcha/Website-to-Chatbot 266 Cheems-Seminar/grounded-segment-any-parts 260 sullivan-sean/chat-langchainjs 248 bborn/howdoi.ai 245 daveebbelaar/langchain-experiments 240 MagnivOrg/prompt-layer-library 237 ur-whitelab/exmol 234 conceptofmind/toolformer 234 recalign/RecAlign 226 OpenBMB/AgentVerse 220 alvarosevi...
https://python.langchain.com/en/latest/dependents.html
af52fc0a2ee1-5
148 chakkaradeep/pyCodeAGI 145 ccurme/yolopandas 145 shamspias/customizable-gpt-chatbot 144 realminchoi/babyagi-ui 143 PradipNichite/Youtube-Tutorials 140 gustavz/DataChad 140 Klingefjord/chatgpt-telegram 140 Jaseci-Labs/jaseci 139 handrew/browserpilot 137 jmpaz/promptlib 137 SamPink/dev-gpt 135 menloparklab/langchain-...
https://python.langchain.com/en/latest/dependents.html
af52fc0a2ee1-6
111 aurelio-labs/arxiv-bot 110 fixie-ai/fixie-examples 108 miaoshouai/miaoshouai-assistant 105 flurb18/AgentOoba 103 solana-labs/chatgpt-plugin 102 Significant-Gravitas/Auto-GPT-Benchmarks 102 kaarthik108/snowChat 100 Generated by github-dependents-info github-dependents-info --repo hwchase17/langchain --markdownfile d...
https://python.langchain.com/en/latest/dependents.html
46379634f13f-0
Source code for langchain.requests """Lightweight wrapper around requests library, with async support.""" from contextlib import asynccontextmanager from typing import Any, AsyncGenerator, Dict, Optional import aiohttp import requests from pydantic import BaseModel, Extra class Requests(BaseModel): """Wrapper aroun...
https://python.langchain.com/en/latest/_modules/langchain/requests.html
46379634f13f-1
def delete(self, url: str, **kwargs: Any) -> requests.Response: """DELETE the URL and return the text.""" return requests.delete(url, headers=self.headers, **kwargs) @asynccontextmanager async def _arequest( self, method: str, url: str, **kwargs: Any ) -> AsyncGenerator[aiohttp.Clien...
https://python.langchain.com/en/latest/_modules/langchain/requests.html
46379634f13f-2
"""PATCH the URL and return the text asynchronously.""" async with self._arequest("PATCH", url, **kwargs) as response: yield response @asynccontextmanager async def aput( self, url: str, data: Dict[str, Any], **kwargs: Any ) -> AsyncGenerator[aiohttp.ClientResponse, None]: ...
https://python.langchain.com/en/latest/_modules/langchain/requests.html
46379634f13f-3
"""POST to the URL and return the text.""" return self.requests.post(url, data, **kwargs).text [docs] def patch(self, url: str, data: Dict[str, Any], **kwargs: Any) -> str: """PATCH the URL and return the text.""" return self.requests.patch(url, data, **kwargs).text [docs] def put(self, ur...
https://python.langchain.com/en/latest/_modules/langchain/requests.html
46379634f13f-4
"""PUT the URL and return the text asynchronously.""" async with self.requests.aput(url, **kwargs) as response: return await response.text() [docs] async def adelete(self, url: str, **kwargs: Any) -> str: """DELETE the URL and return the text asynchronously.""" async with self.req...
https://python.langchain.com/en/latest/_modules/langchain/requests.html
e990308dc849-0
Source code for langchain.text_splitter """Functionality for splitting text.""" from __future__ import annotations import copy import logging import re from abc import ABC, abstractmethod from dataclasses import dataclass from enum import Enum from typing import ( AbstractSet, Any, Callable, Collection,...
https://python.langchain.com/en/latest/_modules/langchain/text_splitter.html
e990308dc849-1
chunk_overlap: int = 200, length_function: Callable[[str], int] = len, keep_separator: bool = False, add_start_index: bool = False, ) -> None: """Create a new TextSplitter. Args: chunk_size: Maximum size of chunks to return chunk_overlap: Overlap in ch...
https://python.langchain.com/en/latest/_modules/langchain/text_splitter.html
e990308dc849-2
metadata["start_index"] = index new_doc = Document(page_content=chunk, metadata=metadata) documents.append(new_doc) return documents [docs] def split_documents(self, documents: Iterable[Document]) -> List[Document]: """Split documents.""" texts, metadatas = [],...
https://python.langchain.com/en/latest/_modules/langchain/text_splitter.html
e990308dc849-3
docs.append(doc) # Keep on popping if: # - we have a larger chunk than in the chunk overlap # - or if we still have any chunks and the length is long while total > self._chunk_overlap or ( total + _len + (separator_l...
https://python.langchain.com/en/latest/_modules/langchain/text_splitter.html
e990308dc849-4
def from_tiktoken_encoder( cls: Type[TS], encoding_name: str = "gpt2", model_name: Optional[str] = None, allowed_special: Union[Literal["all"], AbstractSet[str]] = set(), disallowed_special: Union[Literal["all"], Collection[str]] = "all", **kwargs: Any, ) -> TS: ...
https://python.langchain.com/en/latest/_modules/langchain/text_splitter.html
e990308dc849-5
return self.split_documents(list(documents)) [docs] async def atransform_documents( self, documents: Sequence[Document], **kwargs: Any ) -> Sequence[Document]: """Asynchronously transform a sequence of documents by splitting them.""" raise NotImplementedError [docs]class CharacterTextSpli...
https://python.langchain.com/en/latest/_modules/langchain/text_splitter.html
e990308dc849-6
chunk_ids = input_ids[start_idx:cur_idx] while start_idx < len(input_ids): splits.append(tokenizer.decode(chunk_ids)) start_idx += tokenizer.tokens_per_chunk - tokenizer.chunk_overlap cur_idx = min(start_idx + tokenizer.tokens_per_chunk, len(input_ids)) chunk_ids = input_ids[start_id...
https://python.langchain.com/en/latest/_modules/langchain/text_splitter.html
e990308dc849-7
allowed_special=self._allowed_special, disallowed_special=self._disallowed_special, ) tokenizer = Tokenizer( chunk_overlap=self._chunk_overlap, tokens_per_chunk=self._chunk_size, decode=self._tokenizer.decode, encode=_encode, ) ...
https://python.langchain.com/en/latest/_modules/langchain/text_splitter.html
e990308dc849-8
else: self.tokens_per_chunk = tokens_per_chunk if self.tokens_per_chunk > self.maximum_tokens_per_chunk: raise ValueError( f"The token limit of the models '{self.model_name}'" f" is: {self.maximum_tokens_per_chunk}." f" Argument tokens_per_...
https://python.langchain.com/en/latest/_modules/langchain/text_splitter.html
e990308dc849-9
RUBY = "ruby" RUST = "rust" SCALA = "scala" SWIFT = "swift" MARKDOWN = "markdown" LATEX = "latex" HTML = "html" [docs]class RecursiveCharacterTextSplitter(TextSplitter): """Implementation of splitting text that looks at characters. Recursively tries to split by different characters to fi...
https://python.langchain.com/en/latest/_modules/langchain/text_splitter.html
e990308dc849-10
_good_splits.append(s) else: if _good_splits: merged_text = self._merge_splits(_good_splits, _separator) final_chunks.extend(merged_text) _good_splits = [] if not new_separators: final_chunks.appe...
https://python.langchain.com/en/latest/_modules/langchain/text_splitter.html
e990308dc849-11
elif language == Language.GO: return [ # Split along function definitions "\nfunc ", "\nvar ", "\nconst ", "\ntype ", # Split along control flow statements "\nif ", "\nfor ", ...
https://python.langchain.com/en/latest/_modules/langchain/text_splitter.html
e990308dc849-12
"\nfunction ", # Split along class definitions "\nclass ", # Split along control flow statements "\nif ", "\nforeach ", "\nwhile ", "\ndo ", "\nswitch ", "\ncase ", ...
https://python.langchain.com/en/latest/_modules/langchain/text_splitter.html
e990308dc849-13
"", ] elif language == Language.RUBY: return [ # Split along method definitions "\ndef ", "\nclass ", # Split along control flow statements "\nif ", "\nunless ", "\nwhile ", ...
https://python.langchain.com/en/latest/_modules/langchain/text_splitter.html
e990308dc849-14
"\nfunc ", # Split along class definitions "\nclass ", "\nstruct ", "\nenum ", # Split along control flow statements "\nif ", "\nfor ", "\nwhile ", "\ndo ", "\n...
https://python.langchain.com/en/latest/_modules/langchain/text_splitter.html
e990308dc849-15
"\n\\\begin{quote}", "\n\\\begin{quotation}", "\n\\\begin{verse}", "\n\\\begin{verbatim}", ## Now split by math environments "\n\\\begin{align}", "$$", "$", # Now split by the normal type of l...
https://python.langchain.com/en/latest/_modules/langchain/text_splitter.html
e990308dc849-16
self._tokenizer = sent_tokenize except ImportError: raise ImportError( "NLTK is not installed, please install it with `pip install nltk`." ) self._separator = separator [docs] def split_text(self, text: str) -> List[str]: """Split incoming text and retu...
https://python.langchain.com/en/latest/_modules/langchain/text_splitter.html
e990308dc849-17
"""Initialize a PythonCodeTextSplitter.""" separators = self.get_separators_for_language(Language.PYTHON) super().__init__(separators=separators, **kwargs) [docs]class MarkdownTextSplitter(RecursiveCharacterTextSplitter): """Attempts to split the text along Markdown-formatted headings.""" def __...
https://python.langchain.com/en/latest/_modules/langchain/text_splitter.html
e98f17c4398f-0
Source code for langchain.document_transformers """Transform documents""" from typing import Any, Callable, List, Sequence import numpy as np from pydantic import BaseModel, Field from langchain.embeddings.base import Embeddings from langchain.math_utils import cosine_similarity from langchain.schema import BaseDocumen...
https://python.langchain.com/en/latest/_modules/langchain/document_transformers.html
e98f17c4398f-1
for first_idx, second_idx in redundant_stacked[redundant_sorted]: if first_idx in included_idxs and second_idx in included_idxs: # Default to dropping the second document of any highly similar pair. included_idxs.remove(second_idx) return list(sorted(included_idxs)) def _get_embeddin...
https://python.langchain.com/en/latest/_modules/langchain/document_transformers.html
e98f17c4398f-2
"""Filter down documents.""" stateful_documents = get_stateful_documents(documents) embedded_documents = _get_embeddings_from_stateful_docs( self.embeddings, stateful_documents ) included_idxs = _filter_similar_embeddings( embedded_documents, self.similarity_fn, s...
https://python.langchain.com/en/latest/_modules/langchain/document_transformers.html
e52585dff09b-0
Source code for langchain.output_parsers.retry from __future__ import annotations from typing import TypeVar from langchain.base_language import BaseLanguageModel from langchain.chains.llm import LLMChain from langchain.prompts.base import BasePromptTemplate from langchain.prompts.prompt import PromptTemplate from lang...
https://python.langchain.com/en/latest/_modules/langchain/output_parsers/retry.html
e52585dff09b-1
chain = LLMChain(llm=llm, prompt=prompt) return cls(parser=parser, retry_chain=chain) [docs] def parse_with_prompt(self, completion: str, prompt_value: PromptValue) -> T: try: parsed_completion = self.parser.parse(completion) except OutputParserException: new_completio...
https://python.langchain.com/en/latest/_modules/langchain/output_parsers/retry.html
e52585dff09b-2
) -> RetryWithErrorOutputParser[T]: chain = LLMChain(llm=llm, prompt=prompt) return cls(parser=parser, retry_chain=chain) [docs] def parse_with_prompt(self, completion: str, prompt_value: PromptValue) -> T: try: parsed_completion = self.parser.parse(completion) except Outp...
https://python.langchain.com/en/latest/_modules/langchain/output_parsers/retry.html
ca6a23bf3350-0
Source code for langchain.output_parsers.pydantic import json import re from typing import Type, TypeVar from pydantic import BaseModel, ValidationError from langchain.output_parsers.format_instructions import PYDANTIC_FORMAT_INSTRUCTIONS from langchain.schema import BaseOutputParser, OutputParserException T = TypeVar(...
https://python.langchain.com/en/latest/_modules/langchain/output_parsers/pydantic.html
ca6a23bf3350-1
@property def _type(self) -> str: return "pydantic" By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 11, 2023.
https://python.langchain.com/en/latest/_modules/langchain/output_parsers/pydantic.html
5370a30a3424-0
Source code for langchain.output_parsers.rail_parser from __future__ import annotations from typing import Any, Dict from langchain.schema import BaseOutputParser [docs]class GuardrailsOutputParser(BaseOutputParser): guard: Any @property def _type(self) -> str: return "guardrails" [docs] @classme...
https://python.langchain.com/en/latest/_modules/langchain/output_parsers/rail_parser.html
8b82b3f2757f-0
Source code for langchain.output_parsers.regex from __future__ import annotations import re from typing import Dict, List, Optional from langchain.schema import BaseOutputParser [docs]class RegexParser(BaseOutputParser): """Class to parse the output into a dictionary.""" regex: str output_keys: List[str] ...
https://python.langchain.com/en/latest/_modules/langchain/output_parsers/regex.html
ea7943981c46-0
Source code for langchain.output_parsers.datetime import random from datetime import datetime, timedelta from typing import List from langchain.schema import BaseOutputParser, OutputParserException from langchain.utils import comma_list def _generate_random_datetime_strings( pattern: str, n: int = 3, start_...
https://python.langchain.com/en/latest/_modules/langchain/output_parsers/datetime.html
ea7943981c46-1
) from e @property def _type(self) -> str: return "datetime" By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 11, 2023.
https://python.langchain.com/en/latest/_modules/langchain/output_parsers/datetime.html
0d268a24a711-0
Source code for langchain.output_parsers.list from __future__ import annotations from abc import abstractmethod from typing import List from langchain.schema import BaseOutputParser [docs]class ListOutputParser(BaseOutputParser): """Class to parse the output of an LLM call to a list.""" @property def _type(...
https://python.langchain.com/en/latest/_modules/langchain/output_parsers/list.html
5359cc1d3772-0
Source code for langchain.output_parsers.structured from __future__ import annotations from typing import Any, List from pydantic import BaseModel from langchain.output_parsers.format_instructions import STRUCTURED_FORMAT_INSTRUCTIONS from langchain.output_parsers.json import parse_and_check_json_markdown from langchai...
https://python.langchain.com/en/latest/_modules/langchain/output_parsers/structured.html
b8734bee59e7-0
Source code for langchain.output_parsers.regex_dict from __future__ import annotations import re from typing import Dict, Optional from langchain.schema import BaseOutputParser [docs]class RegexDictParser(BaseOutputParser): """Class to parse the output into a dictionary.""" regex_pattern: str = r"{}:\s?([^.'\n'...
https://python.langchain.com/en/latest/_modules/langchain/output_parsers/regex_dict.html
35eec0c5b588-0
Source code for langchain.output_parsers.fix from __future__ import annotations from typing import TypeVar from langchain.base_language import BaseLanguageModel from langchain.chains.llm import LLMChain from langchain.output_parsers.prompts import NAIVE_FIX_PROMPT from langchain.prompts.base import BasePromptTemplate f...
https://python.langchain.com/en/latest/_modules/langchain/output_parsers/fix.html
af0860406392-0
Source code for langchain.embeddings.llamacpp """Wrapper around llama.cpp embedding models.""" from typing import Any, Dict, List, Optional from pydantic import BaseModel, Extra, Field, root_validator from langchain.embeddings.base import Embeddings [docs]class LlamaCppEmbeddings(BaseModel, Embeddings): """Wrapper ...
https://python.langchain.com/en/latest/_modules/langchain/embeddings/llamacpp.html
af0860406392-1
use_mlock: bool = Field(False, alias="use_mlock") """Force system to keep model in RAM.""" n_threads: Optional[int] = Field(None, alias="n_threads") """Number of threads to use. If None, the number of threads is automatically determined.""" n_batch: Optional[int] = Field(8, alias="n_batch") """...
https://python.langchain.com/en/latest/_modules/langchain/embeddings/llamacpp.html
af0860406392-2
raise ModuleNotFoundError( "Could not import llama-cpp-python library. " "Please install the llama-cpp-python library to " "use this embedding model: pip install llama-cpp-python" ) except Exception as e: raise ValueError( f...
https://python.langchain.com/en/latest/_modules/langchain/embeddings/llamacpp.html
b6ecaf2575c8-0
Source code for langchain.embeddings.tensorflow_hub """Wrapper around TensorflowHub embedding models.""" from typing import Any, List from pydantic import BaseModel, Extra from langchain.embeddings.base import Embeddings DEFAULT_MODEL_URL = "https://tfhub.dev/google/universal-sentence-encoder-multilingual/3" [docs]clas...
https://python.langchain.com/en/latest/_modules/langchain/embeddings/tensorflow_hub.html
b6ecaf2575c8-1
"""Compute doc embeddings using a TensorflowHub embedding model. Args: texts: The list of texts to embed. Returns: List of embeddings, one for each text. """ texts = list(map(lambda x: x.replace("\n", " "), texts)) embeddings = self.embed(texts).numpy() ...
https://python.langchain.com/en/latest/_modules/langchain/embeddings/tensorflow_hub.html
7b11115d5237-0
Source code for langchain.embeddings.elasticsearch from __future__ import annotations from typing import TYPE_CHECKING, List, Optional from langchain.utils import get_from_env if TYPE_CHECKING: from elasticsearch import Elasticsearch from elasticsearch.client import MlClient from langchain.embeddings.base impor...
https://python.langchain.com/en/latest/_modules/langchain/embeddings/elasticsearch.html
7b11115d5237-1
es_user: Optional[str] = None, es_password: Optional[str] = None, input_field: str = "text_field", ) -> ElasticsearchEmbeddings: """Instantiate embeddings from Elasticsearch credentials. Args: model_id (str): The model_id of the model deployed in the Elasticsearch ...
https://python.langchain.com/en/latest/_modules/langchain/embeddings/elasticsearch.html
7b11115d5237-2
from elasticsearch.client import MlClient except ImportError: raise ImportError( "elasticsearch package not found, please install with 'pip install " "elasticsearch'" ) es_cloud_id = es_cloud_id or get_from_env("es_cloud_id", "ES_CLOUD_ID") ...
https://python.langchain.com/en/latest/_modules/langchain/embeddings/elasticsearch.html
7b11115d5237-3
Example: .. code-block:: python from elasticsearch import Elasticsearch from langchain.embeddings import ElasticsearchEmbeddings # Define the model ID and input field name (if different from default) model_id = "your_model_id" #...
https://python.langchain.com/en/latest/_modules/langchain/embeddings/elasticsearch.html
7b11115d5237-4
list. """ response = self.client.infer_trained_model( model_id=self.model_id, docs=[{self.input_field: text} for text in texts] ) embeddings = [doc["predicted_value"] for doc in response["inference_results"]] return embeddings [docs] def embed_documents(self, texts...
https://python.langchain.com/en/latest/_modules/langchain/embeddings/elasticsearch.html
47e5eeb4b1e9-0
Source code for langchain.embeddings.bedrock import json import os from typing import Any, Dict, List, Optional from pydantic import BaseModel, Extra, root_validator from langchain.embeddings.base import Embeddings [docs]class BedrockEmbeddings(BaseModel, Embeddings): """Embeddings provider to invoke Bedrock embedd...
https://python.langchain.com/en/latest/_modules/langchain/embeddings/bedrock.html
47e5eeb4b1e9-1
If not specified, the default credential profile or, if on an EC2 instance, credentials from IMDS will be used. See: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html """ model_id: str = "amazon.titan-e1t-medium" """Id of the model to call, e.g., amazon.titan-e1t-medium,...
https://python.langchain.com/en/latest/_modules/langchain/embeddings/bedrock.html
47e5eeb4b1e9-2
"profile name are valid." ) from e return values def _embedding_func(self, text: str) -> List[float]: """Call out to Bedrock embedding endpoint.""" # replace newlines, which can negatively affect performance. text = text.replace(os.linesep, " ") _model_kwargs = se...
https://python.langchain.com/en/latest/_modules/langchain/embeddings/bedrock.html
47e5eeb4b1e9-3
[docs] def embed_query(self, text: str) -> List[float]: """Compute query embeddings using a Bedrock model. Args: text: The text to embed. Returns: Embeddings for the text. """ return self._embedding_func(text) By Harrison Chase © Copyright 20...
https://python.langchain.com/en/latest/_modules/langchain/embeddings/bedrock.html
38c1e1d83a2e-0
Source code for langchain.embeddings.self_hosted_hugging_face """Wrapper around HuggingFace embedding models for self-hosted remote hardware.""" import importlib import logging from typing import Any, Callable, List, Optional from langchain.embeddings.self_hosted import SelfHostedEmbeddings DEFAULT_MODEL_NAME = "senten...
https://python.langchain.com/en/latest/_modules/langchain/embeddings/self_hosted_hugging_face.html
38c1e1d83a2e-1
if device < 0 and cuda_device_count > 0: logger.warning( "Device has %d GPUs available. " "Provide device={deviceId} to `from_model_id` to use available" "GPUs for execution. deviceId is -1 for CPU and " "can be a positive integer associated wi...
https://python.langchain.com/en/latest/_modules/langchain/embeddings/self_hosted_hugging_face.html
38c1e1d83a2e-2
model_load_fn: Callable = load_embedding_model """Function to load the model remotely on the server.""" load_fn_kwargs: Optional[dict] = None """Key word arguments to pass to the model load function.""" inference_fn: Callable = _embed_documents """Inference function to extract the embeddings.""" ...
https://python.langchain.com/en/latest/_modules/langchain/embeddings/self_hosted_hugging_face.html
38c1e1d83a2e-3
model_name=model_name, hardware=gpu) """ model_id: str = DEFAULT_INSTRUCT_MODEL """Model name to use.""" embed_instruction: str = DEFAULT_EMBED_INSTRUCTION """Instruction to use for embedding documents.""" query_instruction: str = DEFAULT_QUERY_INSTRUCTION """Instruction to use for embedding...
https://python.langchain.com/en/latest/_modules/langchain/embeddings/self_hosted_hugging_face.html
38c1e1d83a2e-4
Returns: Embeddings for the text. """ instruction_pair = [self.query_instruction, text] embedding = self.client(self.pipeline_ref, [instruction_pair])[0] return embedding.tolist() By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 11, ...
https://python.langchain.com/en/latest/_modules/langchain/embeddings/self_hosted_hugging_face.html
64ef7e8ab507-0
Source code for langchain.embeddings.huggingface_hub """Wrapper around HuggingFace Hub embedding models.""" from typing import Any, Dict, List, Optional from pydantic import BaseModel, Extra, root_validator from langchain.embeddings.base import Embeddings from langchain.utils import get_from_dict_or_env DEFAULT_REPO_ID...
https://python.langchain.com/en/latest/_modules/langchain/embeddings/huggingface_hub.html
64ef7e8ab507-1
@root_validator() def validate_environment(cls, values: Dict) -> Dict: """Validate that api key and python package exists in environment.""" huggingfacehub_api_token = get_from_dict_or_env( values, "huggingfacehub_api_token", "HUGGINGFACEHUB_API_TOKEN" ) try: ...
https://python.langchain.com/en/latest/_modules/langchain/embeddings/huggingface_hub.html
64ef7e8ab507-2
texts = [text.replace("\n", " ") for text in texts] _model_kwargs = self.model_kwargs or {} responses = self.client(inputs=texts, params=_model_kwargs) return responses [docs] def embed_query(self, text: str) -> List[float]: """Call out to HuggingFaceHub's embedding endpoint for embed...
https://python.langchain.com/en/latest/_modules/langchain/embeddings/huggingface_hub.html
094599aa4c01-0
Source code for langchain.embeddings.aleph_alpha from typing import Any, Dict, List, Optional from pydantic import BaseModel, root_validator from langchain.embeddings.base import Embeddings from langchain.utils import get_from_dict_or_env [docs]class AlephAlphaAsymmetricSemanticEmbedding(BaseModel, Embeddings): """...
https://python.langchain.com/en/latest/_modules/langchain/embeddings/aleph_alpha.html
094599aa4c01-1
"""Attention control parameters only apply to those tokens that have explicitly been set in the request.""" control_log_additive: Optional[bool] = True """Apply controls on prompt items by adding the log(control_factor) to attention scores.""" aleph_alpha_api_key: Optional[str] = None """API k...
https://python.langchain.com/en/latest/_modules/langchain/embeddings/aleph_alpha.html
094599aa4c01-2
document_params = { "prompt": Prompt.from_text(text), "representation": SemanticRepresentation.Document, "compress_to_size": self.compress_to_size, "normalize": self.normalize, "contextual_control_threshold": self.contextual_control_thresho...
https://python.langchain.com/en/latest/_modules/langchain/embeddings/aleph_alpha.html
094599aa4c01-3
request=symmetric_request, model=self.model ) return symmetric_response.embedding [docs]class AlephAlphaSymmetricSemanticEmbedding(AlephAlphaAsymmetricSemanticEmbedding): """The symmetric version of the Aleph Alpha's semantic embeddings. The main difference is that here, both the documents and ...
https://python.langchain.com/en/latest/_modules/langchain/embeddings/aleph_alpha.html
094599aa4c01-4
"""Call out to Aleph Alpha's Document endpoint. Args: texts: The list of texts to embed. Returns: List of embeddings, one for each text. """ document_embeddings = [] for text in texts: document_embeddings.append(self._embed(text)) retur...
https://python.langchain.com/en/latest/_modules/langchain/embeddings/aleph_alpha.html
eedc1f895dcc-0
Source code for langchain.embeddings.fake from typing import List import numpy as np from pydantic import BaseModel from langchain.embeddings.base import Embeddings [docs]class FakeEmbeddings(Embeddings, BaseModel): size: int def _get_embedding(self) -> List[float]: return list(np.random.normal(size=sel...
https://python.langchain.com/en/latest/_modules/langchain/embeddings/fake.html
1533f89840fa-0
Source code for langchain.embeddings.cohere """Wrapper around Cohere embedding models.""" from typing import Any, Dict, List, Optional from pydantic import BaseModel, Extra, root_validator from langchain.embeddings.base import Embeddings from langchain.utils import get_from_dict_or_env [docs]class CohereEmbeddings(Base...
https://python.langchain.com/en/latest/_modules/langchain/embeddings/cohere.html
1533f89840fa-1
except ImportError: raise ValueError( "Could not import cohere python package. " "Please install it with `pip install cohere`." ) return values [docs] def embed_documents(self, texts: List[str]) -> List[List[float]]: """Call out to Cohere's embe...
https://python.langchain.com/en/latest/_modules/langchain/embeddings/cohere.html
00bc5482a026-0
Source code for langchain.embeddings.modelscope_hub """Wrapper around ModelScopeHub embedding models.""" from typing import Any, List from pydantic import BaseModel, Extra from langchain.embeddings.base import Embeddings [docs]class ModelScopeEmbeddings(BaseModel, Embeddings): """Wrapper around modelscope_hub embed...
https://python.langchain.com/en/latest/_modules/langchain/embeddings/modelscope_hub.html
00bc5482a026-1
texts = list(map(lambda x: x.replace("\n", " "), texts)) inputs = {"source_sentence": texts} embeddings = self.embed(input=inputs)["text_embedding"] return embeddings.tolist() [docs] def embed_query(self, text: str) -> List[float]: """Compute query embeddings using a modelscope embedd...
https://python.langchain.com/en/latest/_modules/langchain/embeddings/modelscope_hub.html
682a003d0ef2-0
Source code for langchain.embeddings.huggingface """Wrapper around HuggingFace embedding models.""" from typing import Any, Dict, List, Optional from pydantic import BaseModel, Extra, Field from langchain.embeddings.base import Embeddings DEFAULT_MODEL_NAME = "sentence-transformers/all-mpnet-base-v2" DEFAULT_INSTRUCT_M...
https://python.langchain.com/en/latest/_modules/langchain/embeddings/huggingface.html
682a003d0ef2-1
"""Key word arguments to pass when calling the `encode` method of the model.""" def __init__(self, **kwargs: Any): """Initialize the sentence_transformer.""" super().__init__(**kwargs) try: import sentence_transformers except ImportError as exc: raise ImportEr...
https://python.langchain.com/en/latest/_modules/langchain/embeddings/huggingface.html
682a003d0ef2-2
To use, you should have the ``sentence_transformers`` and ``InstructorEmbedding`` python packages installed. Example: .. code-block:: python from langchain.embeddings import HuggingFaceInstructEmbeddings model_name = "hkunlp/instructor-large" model_kwargs = {'device':...
https://python.langchain.com/en/latest/_modules/langchain/embeddings/huggingface.html
682a003d0ef2-3
raise ValueError("Dependencies for InstructorEmbedding not found.") from e class Config: """Configuration for this pydantic object.""" extra = Extra.forbid [docs] def embed_documents(self, texts: List[str]) -> List[List[float]]: """Compute doc embeddings using a HuggingFace instruct model...
https://python.langchain.com/en/latest/_modules/langchain/embeddings/huggingface.html
efe14e94b84b-0
Source code for langchain.embeddings.deepinfra from typing import Any, Dict, List, Mapping, Optional import requests from pydantic import BaseModel, Extra, root_validator from langchain.embeddings.base import Embeddings from langchain.utils import get_from_dict_or_env DEFAULT_MODEL_ID = "sentence-transformers/clip-ViT-...
https://python.langchain.com/en/latest/_modules/langchain/embeddings/deepinfra.html
efe14e94b84b-1
model_kwargs: Optional[dict] = None """Other model keyword args""" deepinfra_api_token: Optional[str] = None class Config: """Configuration for this pydantic object.""" extra = Extra.forbid @root_validator() def validate_environment(cls, values: Dict) -> Dict: """Validate tha...
https://python.langchain.com/en/latest/_modules/langchain/embeddings/deepinfra.html
efe14e94b84b-2
try: t = res.json() embeddings = t["embeddings"] except requests.exceptions.JSONDecodeError as e: raise ValueError( f"Error raised by inference API: {e}.\nResponse: {res.text}" ) return embeddings [docs] def embed_documents(self, texts: ...
https://python.langchain.com/en/latest/_modules/langchain/embeddings/deepinfra.html