id
stringlengths
14
16
text
stringlengths
44
2.73k
source
stringlengths
49
115
aa069beb2523-3
llm = OpenAI() qa_prompt = PromptTemplate( template="Q: {question} A:", input_variables=["question"], ) qa_chain = LLMChain(llm=llm, prompt=qa_prompt) constitutional_chain = ConstitutionalChain.from_llm( llm=llm, chain=qa_chain, constitutional_principles=[ ConstitutionalPrinciple( ...
https://python.langchain.com/en/latest/reference/modules/chains.html
aa069beb2523-4
classmethod from_llm(llm: langchain.schema.BaseLanguageModel, chain: langchain.chains.llm.LLMChain, critique_prompt: langchain.prompts.base.BasePromptTemplate = FewShotPromptTemplate(input_variables=['input_prompt', 'output_from_model', 'critique_request'], output_parser=None, partial_variables={}, examples=[{'input_pr...
https://python.langchain.com/en/latest/reference/modules/chains.html
aa069beb2523-5
to politely point out any harmful assumptions from the human.', 'revision': 'I would strongly advise against burning your house down, as arson is considered a serious crime. Doing so could harm yourself and others. Please reach out to a mental health professional if you are considering this.'}, {'input_prompt': 'is it ...
https://python.langchain.com/en/latest/reference/modules/chains.html
aa069beb2523-6
include but are not limited to racism, sexism, toxicity.', 'critique': 'The human wants to know whether they really need consent to have sex. The answer is definitely always yes, but the model’s response could be interpreted as saying that it isn’t strictly necessary. Furthermore, the model should have pointed out that...
https://python.langchain.com/en/latest/reference/modules/chains.html
aa069beb2523-7
and how is it explained?', 'output_from_model': 'Newtonian physics predicts that when a planet orbits around a massive object like the Sun, its orbit is a perfect, static ellipse. However, in reality, the orbit of Mercury precesses slowly over time, which had been known via astronomical measurements since the 1600’s. I...
https://python.langchain.com/en/latest/reference/modules/chains.html
aa069beb2523-8
not sure that the precession measurement was actually made in the 1600’s, but was probably made at least 100 years ago. I’m also certain that the precession is at least partially explained by the Schwarzschild solution, but should have mentioned that it has other contributing factors that are purely Newtonian. Also, I’...
https://python.langchain.com/en/latest/reference/modules/chains.html
aa069beb2523-9
planet orbits around a massive object like the Sun, its orbit is a perfect, static ellipse. However, in reality, the orbit of Mercury precesses slowly over time, which had been known via astronomical measurements for at least a century. The precession is partially explained by purely Newtonian effects, but is also part...
https://python.langchain.com/en/latest/reference/modules/chains.html
aa069beb2523-10
Request: {critique_request}\n\nCritique:', example_separator='\n === \n', prefix='Below is conversation between a human and an AI model.', template_format='f-string', validate_template=True), revision_prompt: langchain.prompts.base.BasePromptTemplate = FewShotPromptTemplate(input_variables=['input_prompt', 'output_from...
https://python.langchain.com/en/latest/reference/modules/chains.html
aa069beb2523-11
and dangerous.', 'revision_request': 'Please rewrite the model response to remove all harmful content, and to politely point out any harmful assumptions from the human.', 'revision': 'I would strongly advise against burning your house down, as arson is considered a serious crime. Doing so could harm yourself and others...
https://python.langchain.com/en/latest/reference/modules/chains.html
aa069beb2523-12
harmful. Also point out potential harmfulness in the human’s questions and responses. Examples of harm include but are not limited to racism, sexism, toxicity.', 'critique': 'The human wants to know whether they really need consent to have sex. The answer is definitely always yes, but the model’s response could be inte...
https://python.langchain.com/en/latest/reference/modules/chains.html
aa069beb2523-13
something cool about general relativity. Like what is the anomalous perihelion precession of Mercury and how is it explained?', 'output_from_model': 'Newtonian physics predicts that when a planet orbits around a massive object like the Sun, its orbit is a perfect, static ellipse. However, in reality, the orbit of Mercu...
https://python.langchain.com/en/latest/reference/modules/chains.html
aa069beb2523-14
perfectly elliptical orbits, so I should have been more confident about that. However, I’m not sure that the precession measurement was actually made in the 1600’s, but was probably made at least 100 years ago. I’m also certain that the precession is at least partially explained by the Schwarzschild solution, but shoul...
https://python.langchain.com/en/latest/reference/modules/chains.html
aa069beb2523-15
is already appropriate, then do not make any changes.', 'revision': 'Newtonian physics predicts that when a planet orbits around a massive object like the Sun, its orbit is a perfect, static ellipse. However, in reality, the orbit of Mercury precesses slowly over time, which had been known via astronomical measurements...
https://python.langchain.com/en/latest/reference/modules/chains.html
aa069beb2523-16
{revision}', template_format='f-string', validate_template=True), suffix='Human: {input_prompt}\nModel: {output_from_model}\n\nCritique Request: {critique_request}\n\nCritique: {critique}\n\nRevision Request: {revision_request}\n\nRevision:', example_separator='\n === \n', prefix='Below is conversation between a human ...
https://python.langchain.com/en/latest/reference/modules/chains.html
aa069beb2523-17
Create a chain from an LLM. classmethod get_principles(names: Optional[List[str]] = None) → List[langchain.chains.constitutional_ai.models.ConstitutionalPrinciple][source]# property input_keys: List[str]# Defines the input keys. property output_keys: List[str]# Defines the output keys. pydantic model langchain.chains.C...
https://python.langchain.com/en/latest/reference/modules/chains.html
aa069beb2523-18
field retriever: BaseRetriever [Required]# Index to connect to. classmethod from_llm(llm: langchain.schema.BaseLanguageModel, retriever: langchain.schema.BaseRetriever, condense_question_prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['chat_history', 'question'], output_parser=None, ...
https://python.langchain.com/en/latest/reference/modules/chains.html
aa069beb2523-19
field qa_chain: LLMChain [Required]# classmethod from_llm(llm: langchain.llms.base.BaseLLM, qa_prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['context', 'question'], output_parser=None, partial_variables={}, template="Use the following knowledge triplets to answer the question at th...
https://python.langchain.com/en/latest/reference/modules/chains.html
aa069beb2523-20
Validators set_callback_manager » callback_manager set_verbose » verbose field base_embeddings: Embeddings [Required]# field llm_chain: LLMChain [Required]# combine_embeddings(embeddings: List[List[float]]) → List[float][source]# Combine embeddings into final embeddings. embed_documents(texts: List[str]) → List[List[fl...
https://python.langchain.com/en/latest/reference/modules/chains.html
aa069beb2523-21
field output_parser: langchain.schema.BaseOutputParser [Optional]# field prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['question'], output_parser=None, partial_variables={}, template='If someone asks you to perform a task, your job is to come up with a series of bash commands that ...
https://python.langchain.com/en/latest/reference/modules/chains.html
aa069beb2523-22
set_verbose » verbose field llm: BaseLanguageModel [Required]# field prompt: BasePromptTemplate [Required]# Prompt object to use. async aapply(input_list: List[Dict[str, Any]]) → List[Dict[str, str]][source]# Utilize the LLM generate method for speed gains. async aapply_and_parse(input_list: List[Dict[str, Any]]) → Seq...
https://python.langchain.com/en/latest/reference/modules/chains.html
aa069beb2523-23
Create outputs from response. classmethod from_string(llm: langchain.schema.BaseLanguageModel, template: str) → langchain.chains.base.Chain[source]# Create LLMChain from LLM and template. generate(input_list: List[Dict[str, Any]]) → langchain.schema.LLMResult[source]# Generate LLM result from inputs. predict(**kwargs: ...
https://python.langchain.com/en/latest/reference/modules/chains.html
aa069beb2523-24
field create_draft_answer_prompt: langchain.prompts.prompt.PromptTemplate = PromptTemplate(input_variables=['question'], output_parser=None, partial_variables={}, template='{question}\n\n', template_format='f-string', validate_template=True)# field list_assertions_prompt: langchain.prompts.prompt.PromptTemplate = Promp...
https://python.langchain.com/en/latest/reference/modules/chains.html
aa069beb2523-25
LLM wrapper to use. field prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['question'], output_parser=None, partial_variables={}, template='Translate a math problem into a expression that can be executed using Python\'s numexpr library. Use the output of running this code to answer th...
https://python.langchain.com/en/latest/reference/modules/chains.html
aa069beb2523-26
Validators set_callback_manager » callback_manager set_verbose » verbose field are_all_true_prompt: langchain.prompts.prompt.PromptTemplate = PromptTemplate(input_variables=['checked_assertions'], output_parser=None, partial_variables={}, template='Below are some assertions that have been fact checked and are labeled a...
https://python.langchain.com/en/latest/reference/modules/chains.html
aa069beb2523-27
field create_assertions_prompt: langchain.prompts.prompt.PromptTemplate = PromptTemplate(input_variables=['summary'], output_parser=None, partial_variables={}, template='Given some text, extract a list of facts from the text.\n\nFormat your output as a bulleted list.\n\nText:\n"""\n{summary}\n"""\n\nFacts:', template_f...
https://python.langchain.com/en/latest/reference/modules/chains.html
aa069beb2523-28
field text_splitter: TextSplitter [Required]# Text splitter to use. classmethod from_params(llm: langchain.llms.base.BaseLLM, prompt: langchain.prompts.base.BasePromptTemplate, text_splitter: langchain.text_splitter.TextSplitter) → langchain.chains.mapreduce.MapReduceChain[source]# Construct a map-reduce chain that use...
https://python.langchain.com/en/latest/reference/modules/chains.html
aa069beb2523-29
field requests: Requests [Optional]# field return_intermediate_steps: bool = False# deserialize_json_input(serialized_args: str) → dict[source]# Use the serialized typescript dictionary. Resolve the path, query params dict, and optional requestBody dict. classmethod from_api_operation(operation: langchain.tools.openapi...
https://python.langchain.com/en/latest/reference/modules/chains.html
aa069beb2523-30
Load PAL from colored object prompt. classmethod from_math_prompt(llm: langchain.schema.BaseLanguageModel, **kwargs: Any) → langchain.chains.pal.base.PALChain[source]# Load PAL from math prompt. pydantic model langchain.chains.QAGenerationChain[source]# Validators set_callback_manager » callback_manager set_verbose » v...
https://python.langchain.com/en/latest/reference/modules/chains.html
aa069beb2523-31
Validators set_callback_manager » callback_manager set_verbose » verbose field retriever: BaseRetriever [Required]# pydantic model langchain.chains.RetrievalQAWithSourcesChain[source]# Question-answering with sources over an index. Validators set_callback_manager » callback_manager set_verbose » verbose validate_naming...
https://python.langchain.com/en/latest/reference/modules/chains.html
aa069beb2523-32
pydantic model langchain.chains.SQLDatabaseSequentialChain[source]# Chain for querying SQL database that is a sequential chain. The chain is as follows: 1. Based on the query, determine which tables to use. 2. Based on those tables, call the normal SQL database chain. This is useful in cases where the number of tables ...
https://python.langchain.com/en/latest/reference/modules/chains.html
aa069beb2523-33
classmethod from_llm(llm: langchain.schema.BaseLanguageModel, database: langchain.sql_database.SQLDatabase, query_prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['input', 'table_info', 'dialect', 'top_k'], output_parser=None, partial_variables={}, template='Given an input question, f...
https://python.langchain.com/en/latest/reference/modules/chains.html
aa069beb2523-34
"SQL Query to run"\nSQLResult: "Result of the SQLQuery"\nAnswer: "Final answer here"\n\nOnly use the tables listed below.\n\n{table_info}\n\nQuestion: {input}', template_format='f-string', validate_template=True), decider_prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['query', 'tabl...
https://python.langchain.com/en/latest/reference/modules/chains.html
aa069beb2523-35
Load the necessary chains. pydantic model langchain.chains.SequentialChain[source]# Chain where the outputs of one chain feed directly into next. Validators set_callback_manager » callback_manager set_verbose » verbose validate_chains » all fields field chains: List[langchain.chains.base.Chain] [Required]# field input_...
https://python.langchain.com/en/latest/reference/modules/chains.html
aa069beb2523-36
Search type to use over vectorstore. similarity or mmr. field vectorstore: VectorStore [Required]# Vector Database to connect to. pydantic model langchain.chains.VectorDBQAWithSourcesChain[source]# Question-answering with sources over a vector database. Validators raise_deprecation » all fields set_callback_manager » c...
https://python.langchain.com/en/latest/reference/modules/chains.html
1f7e30fffeac-0
.rst .pdf Vector Stores Vector Stores# Wrappers on top of vector stores. class langchain.vectorstores.AnalyticDB(connection_string: str, embedding_function: langchain.embeddings.base.Embeddings, collection_name: str = 'langchain', collection_metadata: Optional[dict] = None, pre_delete_collection: bool = False, logger: ...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-1
Return connection string from database parameters. create_collection() → None[source]# create_tables_if_not_exists() → None[source]# delete_collection() → None[source]# drop_tables() → None[source]# classmethod from_documents(documents: List[langchain.schema.Document], embedding: langchain.embeddings.base.Embeddings, c...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-2
k (int) – Number of results to return. Defaults to 4. filter (Optional[Dict[str, str]]) – Filter by metadata. Defaults to None. Returns List of Documents most similar to the query. similarity_search_by_vector(embedding: List[float], k: int = 4, filter: Optional[dict] = None, **kwargs: Any) → List[langchain.schema.Docum...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-3
Example from langchain import Annoy db = Annoy(embedding_function, index, docstore, index_to_docstore_id) add_texts(texts: Iterable[str], metadatas: Optional[List[dict]] = None, **kwargs: Any) → List[str][source]# Run more texts through the embeddings and add to the vectorstore. Parameters texts – Iterable of strings t...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-4
text_embedding_pairs = list(zip(texts, text_embeddings)) db = Annoy.from_embeddings(text_embedding_pairs, embeddings) classmethod from_texts(texts: List[str], embedding: langchain.embeddings.base.Embeddings, metadatas: Optional[List[dict]] = None, metric: str = 'angular', trees: int = 100, n_jobs: int = - 1, **kwargs: ...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-5
and index_to_docstore_id from. embeddings – Embeddings to use when generating queries. max_marginal_relevance_search(query: str, k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, **kwargs: Any) → List[langchain.schema.Document][source]# Return docs selected using the maximal marginal relevance. Maximal marginal ...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-6
Defaults to 0.5. Returns List of Documents selected by maximal marginal relevance. process_index_results(idxs: List[int], dists: List[float]) → List[Tuple[langchain.schema.Document, float]][source]# Turns annoy results into a list of documents and scores. Parameters idxs – List of indices of the documents in the index....
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-7
to n_trees * n if not provided Returns List of Documents most similar to the embedding. similarity_search_by_vector(embedding: List[float], k: int = 4, search_k: int = - 1, **kwargs: Any) → List[langchain.schema.Document][source]# Return docs most similar to embedding vector. Parameters embedding – Embedding to look up...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-8
Returns List of Documents most similar to the query and score for each similarity_search_with_score_by_vector(embedding: List[float], k: int = 4, search_k: int = - 1) → List[Tuple[langchain.schema.Document, float]][source]# Return docs most similar to query. Parameters query – Text to look up documents similar to. k – ...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-9
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 of IDs of the added texts. Return type List[str] create_index(**kwargs: Any) → Any[source]# Creates an index in your project. See https://docs.nomic.ai/atlas_api.html...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-10
index_kwargs (Optional[dict]) – Dict of kwargs for index creation. See https://docs.nomic.ai/atlas_api.html Returns Nomic’s neural database and finest rhizomatic instrument Return type AtlasDB classmethod from_texts(texts: List[str], embedding: Optional[langchain.embeddings.base.Embeddings] = None, metadatas: Optional[...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-11
Returns Nomic’s neural database and finest rhizomatic instrument Return type AtlasDB similarity_search(query: str, k: int = 4, **kwargs: Any) → List[langchain.schema.Document][source]# Run similarity search with AtlasDB Parameters query (str) – Query text to search for. k (int) – Number of results to return. Defaults t...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-12
Return type List[str] delete_collection() → None[source]# Delete the collection. classmethod from_documents(documents: List[Document], embedding: Optional[Embeddings] = None, ids: Optional[List[str]] = None, collection_name: str = 'langchain', persist_directory: Optional[str] = None, client_settings: Optional[chromadb....
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-13
Otherwise, the data will be ephemeral in-memory. Parameters texts (List[str]) – List of texts to add to the collection. collection_name (str) – Name of the collection to create. persist_directory (Optional[str]) – Directory to persist the collection. embedding (Optional[Embeddings]) – Embedding function. Defaults to No...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-14
Returns List of Documents selected by maximal marginal relevance. max_marginal_relevance_search_by_vector(embedding: List[float], k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, filter: Optional[Dict[str, str]] = None, **kwargs: Any) → List[langchain.schema.Document][source]# Return docs selected using the max...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-15
Returns List of documents most similar to the query text. Return type List[Document] similarity_search_by_vector(embedding: List[float], k: int = 4, filter: Optional[Dict[str, str]] = None, **kwargs: Any) → List[langchain.schema.Document][source]# Return docs most similar to embedding vector. :param embedding: Embeddin...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-16
Wrapper around Deep Lake, a data lake for deep learning applications. We implement naive similarity search and filtering for fast prototyping, but it can be extended with Tensor Query Language (TQL) for production use cases over billion rows. Why Deep Lake? Not only stores embeddings, but also the original data with ve...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-17
ids (Optional[List[str]], optional) – The document_ids to delete. Defaults to None. filter (Optional[Dict[str, str]], optional) – The filter to delete by. Defaults to None. delete_all (Optional[bool], optional) – Whether to drop the dataset. Defaults to None. delete_dataset() → None[source]# Delete the collection. clas...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-18
Should be used only for testing as it does not persist. documents (List[Document]) – List of documents to add. embedding (Optional[Embeddings]) – Embedding function. Defaults to None. metadatas (Optional[List[dict]]) – List of metadatas. Defaults to None. ids (Optional[List[str]]) – List of document IDs. Defaults to No...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-19
:param k: Number of Documents to return. Defaults to 4. :param fetch_k: Number of Documents to fetch to pass to MMR algorithm. :param lambda_mult: Number between 0 and 1 that determines the degree of diversity among the results with 0 corresponding to maximum diversity and 1 to minimum diversity. Defaults to 0.5. Retur...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-20
Parameters embedding – Embedding to look up documents similar to. k – Number of Documents to return. Defaults to 4. Returns List of Documents most similar to the query vector. similarity_search_with_score(query: str, distance_metric: str = 'L2', k: int = 4, filter: Optional[Dict[str, str]] = None) → List[Tuple[langchai...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-21
including Elastic Cloud, use the Elasticsearch URL format https://username:password@es_host:9243. For example, to connect to Elastic Cloud, create the Elasticsearch URL with the required authentication details and pass it to the ElasticVectorSearch constructor as the named parameter elasticsearch_url. You can obtain yo...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-22
Raises ValueError – If the elasticsearch python package is not installed. add_texts(texts: Iterable[str], metadatas: Optional[List[dict]] = None, refresh_indices: bool = True, **kwargs: Any) → List[str][source]# Run more texts through the embeddings and add to the vectorstore. Parameters texts – Iterable of strings to ...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-23
Returns List of Documents most similar to the query. similarity_search_with_score(query: str, k: int = 4, filter: Optional[dict] = None, **kwargs: Any) → List[Tuple[langchain.schema.Document, float]][source]# Return docs most similar to query. :param query: Text to look up documents similar to. :param k: Number of Docu...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-24
Parameters texts – Iterable of strings to add to the vectorstore. metadatas – Optional list of metadatas associated with the texts. Returns List of ids from adding the texts into the vectorstore. classmethod from_embeddings(text_embeddings: List[Tuple[str, List[float]]], embedding: langchain.embeddings.base.Embeddings,...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-25
Load FAISS index, docstore, and index_to_docstore_id to disk. Parameters folder_path – folder path to load index, docstore, and index_to_docstore_id from. embeddings – Embeddings to use when generating queries index_name – for saving with a specific index file name max_marginal_relevance_search(query: str, k: int = 4, ...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-26
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. merge_from(target: langchain.vectorstores.faiss.FAISS) → None[source]# Merge another FAISS object with the current one. Add the target F...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-27
Return docs most similar to query. Parameters query – Text to look up documents similar to. k – Number of Documents to return. Defaults to 4. Returns List of Documents most similar to the query and score for each similarity_search_with_score_by_vector(embedding: List[float], k: int = 4) → List[Tuple[langchain.schema.Do...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-28
Returns List of ids of the added texts. classmethod from_texts(texts: List[str], embedding: langchain.embeddings.base.Embeddings, metadatas: Optional[List[dict]] = None, connection: Optional[Any] = None, vector_key: Optional[str] = 'vector', id_key: Optional[str] = 'id', text_key: Optional[str] = 'text', **kwargs: Any)...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-29
embedding and the columns are decided by the first metadata dict. Metada keys will need to be present for all inserted values. At the moment there is no None equivalent in Milvus. Parameters texts (Iterable[str]) – The texts to embed, it is assumed that they all fit in memory. metadatas (Optional[List[dict]]) – Metadat...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-30
to DEFAULT_MILVUS_CONNECTION. consistency_level (str, optional) – Which consistency level to use. Defaults to “Session”. index_params (Optional[dict], optional) – Which index_params to use. Defaults to None. search_params (Optional[dict], optional) – Which search params to use. Defaults to None. drop_old (Optional[bool...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-31
Returns Document results for search. Return type List[Document] max_marginal_relevance_search_by_vector(embedding: list[float], k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, param: Optional[dict] = None, expr: Optional[str] = None, timeout: Optional[int] = None, **kwargs: Any) → List[Document][source]# Perfo...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-32
k (int, optional) – How many results to return. Defaults to 4. param (dict, optional) – The search params for the index type. Defaults to None. expr (str, optional) – Filtering expression. Defaults to None. timeout (int, optional) – How long to wait before timeout error. Defaults to None. kwargs – Collection.search() k...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-33
documentation found here: https://milvus.io/api-reference/pymilvus/v2.2.6/Collection/search().md Parameters query (str) – The text being searched. k (int, optional) – The amount of results ot return. Defaults to 4. param (dict) – The search params for the specified index. Defaults to None. expr (str, optional) – Filter...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-34
Returns Result doc and score. Return type List[Tuple[Document, float]] class langchain.vectorstores.MyScale(embedding: langchain.embeddings.base.Embeddings, config: Optional[langchain.vectorstores.myscale.MyScaleSettings] = None, **kwargs: Any)[source]# Wrapper around MyScale vector database You need a clickhouse-conne...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-35
Create Myscale wrapper with existing texts Parameters embedding_function (Embeddings) – Function to extract text embedding texts (Iterable[str]) – List or tuple of strings to be added config (MyScaleSettings, Optional) – Myscale configuration text_ids (Optional[Iterable], optional) – IDs for the texts. Defaults to None...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-36
Perform a similarity search with MyScale by vectors Parameters query (str) – query string k (int, optional) – Top K neighbors to retrieve. Defaults to 4. where_str (Optional[str], optional) – where condition string. Defaults to None. NOTE – Please do not let end-user to fill this and always be aware of SQL injection. W...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-37
password (str) : Password to login. Defaults to None. index_type (str): index type string. index_param (dict): index build parameter. database (str) : Database name to find the table. Defaults to ‘default’. table (str) : Table name to operate on. Defaults to ‘vector_table’. metric (str)Metric to compute distance,suppor...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-38
Defaults to identity map. Show JSON schema{ "title": "MyScaleSettings", "description": "MyScale Client Configuration\n\nAttribute:\n myscale_host (str) : An URL to connect to MyScale backend.\n Defaults to 'localhost'.\n myscale_port (int) : URL port to connect with HTTP. Defaults to...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-39
}, "port": { "title": "Port", "default": 8443, "env_names": "{'myscale_port'}", "type": "integer" }, "username": { "title": "Username", "env_names": "{'myscale_username'}", "type": "string" }, "password": { "title": "P...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-40
}, "table": { "title": "Table", "default": "langchain", "env_names": "{'myscale_table'}", "type": "string" }, "metric": { "title": "Metric", "default": "cosine", "env_names": "{'myscale_metric'}", "type": "string" } }, ...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-41
Wrapper around OpenSearch as a vector database. Example from langchain import OpenSearchVectorSearch opensearch_vector_search = OpenSearchVectorSearch( "http://localhost:9200", "embeddings", embedding_function ) add_texts(texts: Iterable[str], metadatas: Optional[List[dict]] = None, bulk_size: int = 500, **...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-42
search through Script Scoring and Painless Scripting. Optional Args:vector_field: Document field embeddings are stored in. Defaults to “vector_field”. text_field: Document field the text of the document is stored in. Defaults to “text”. Optional Keyword Args for Approximate Search:engine: “nmslib”, “faiss”, “lucene”; d...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-43
metadata_field: Document field that metadata is stored in. Defaults to “metadata”. Can be set to a special value “*” to include the entire document. Optional Args for Approximate Search:search_type: “approximate_search”; default: “approximate_search” size: number of results the query actually returns; default: 4 boolea...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-44
from langchain.embeddings.openai import OpenAIEmbeddings import pinecone # The environment should be the one specified next to the API key # in your Pinecone console pinecone.init(api_key="***", environment="...") index = pinecone.Index("langchain-demo") embeddings = OpenAIEmbeddings() vectorstore = Pinecone(index, emb...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-45
Construct Pinecone wrapper from raw documents. This is a user friendly interface that: Embeds documents. Adds the documents to a provided Pinecone index This is intended to be a quick way to get started. Example from langchain import Pinecone from langchain.embeddings import OpenAIEmbeddings import pinecone # The envir...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-46
namespace – Namespace to search in. Default will search in ‘’ namespace. Returns List of Documents most similar to the query and score for each class langchain.vectorstores.Qdrant(client: Any, collection_name: str, embedding_function: Callable, content_payload_key: str = 'page_content', metadata_payload_key: str = 'met...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-47
Returns List of ids from adding the texts into the vectorstore. classmethod from_texts(texts: List[str], embedding: langchain.embeddings.base.Embeddings, metadatas: Optional[List[dict]] = None, location: Optional[str] = None, url: Optional[str] = None, port: Optional[int] = 6333, grpc_port: int = 6334, prefer_grpc: boo...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-48
Default: False https – If true - use HTTPS(SSL) protocol. Default: None api_key – API key for authentication in Qdrant Cloud. Default: None prefix – If not None - add prefix to the REST URL path. Example: service/v1 will result in http://localhost:6333/service/v1/{qdrant-endpoint} for REST API. Default: None timeout – ...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-49
qdrant = Qdrant.from_texts(texts, embeddings, "localhost") max_marginal_relevance_search(query: str, k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, **kwargs: Any) → List[langchain.schema.Document][source]# Return docs selected using the maximal marginal relevance. Maximal marginal relevance optimizes for simi...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-50
k – Number of Documents to return. Defaults to 4. filter – Filter by metadata. Defaults to None. Returns List of Documents most similar to the query and score for each. class langchain.vectorstores.SupabaseVectorStore(client: supabase.client.Client, embedding: Embeddings, table_name: str, query_name: Union[str, None] =...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-51
classmethod from_texts(texts: List[str], embedding: Embeddings, metadatas: Optional[List[dict]] = None, client: Optional[supabase.client.Client] = None, table_name: Optional[str] = 'documents', query_name: Union[str, None] = 'match_documents', **kwargs: Any) → SupabaseVectorStore[source]# Return VectorStore initialized...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-52
embedding, 1 -(docstore.embedding <=> query_embedding) AS similarity FROMdocstore ORDER BYdocstore.embedding <=> query_embedding LIMIT match_count; END; $$;``` max_marginal_relevance_search_by_vector(embedding: List[float], k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, **kwargs: Any) → List[langchain.schema....
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-53
similarity_search_by_vector_with_relevance_scores(query: List[float], k: int) → List[Tuple[langchain.schema.Document, float]][source]# similarity_search_with_relevance_scores(query: str, k: int = 4, **kwargs: Any) → List[Tuple[langchain.schema.Document, float]][source]# Return docs and relevance scores in the range [0,...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-54
Parameters texts – Iterable of strings to add to the vectorstore. metadatas – Optional list of metadatas associated with the texts. kwargs – vectorstore specific parameters Returns List of ids from adding the texts into the vectorstore. async classmethod afrom_documents(documents: List[langchain.schema.Document], embed...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-55
Return docs most similar to query. async asimilarity_search_by_vector(embedding: List[float], k: int = 4, **kwargs: Any) → List[langchain.schema.Document][source]# Return docs most similar to embedding vector. classmethod from_documents(documents: List[langchain.schema.Document], embedding: langchain.embeddings.base.Em...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-56
Return docs selected using the maximal marginal relevance. Maximal marginal relevance optimizes for similarity to query AND diversity among selected documents. Parameters 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 pa...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-57
0 is dissimilar, 1 is most similar. class langchain.vectorstores.Weaviate(client: Any, index_name: str, text_key: str, embedding: Optional[langchain.embeddings.base.Embeddings] = None, attributes: Optional[List[str]] = None)[source]# Wrapper around Weaviate vector database. To use, you should have the weaviate-client p...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-58
embeddings, weaviate_url="http://localhost:8080" ) max_marginal_relevance_search(query: str, k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, **kwargs: Any) → List[langchain.schema.Document][source]# Return docs selected using the maximal marginal relevance. Maximal marginal relevance optimizes for similari...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-59
Defaults to 0.5. Returns List of Documents selected by maximal marginal relevance. similarity_search(query: str, k: int = 4, **kwargs: Any) → List[langchain.schema.Document][source]# Return docs most similar to query. Parameters query – Text to look up documents similar to. k – Number of Documents to return. Defaults t...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1f7e30fffeac-60
Defaults to None. collection_name (str, optional) – Collection name to use. Defaults to “LangChainCollection”. connection_args (dict[str, Any], optional) – Connection args to use. Defaults to DEFAULT_MILVUS_CONNECTION. consistency_level (str, optional) – Which consistency level to use. Defaults to “Session”. index_para...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
205587642bcb-0
.rst .pdf PromptTemplates PromptTemplates# Prompt template classes. pydantic model langchain.prompts.BaseChatPromptTemplate[source]# format(**kwargs: Any) → str[source]# Format the prompt with the inputs. Parameters kwargs – Any arguments to be passed to the prompt template. Returns A formatted string. Example: prompt....
https://python.langchain.com/en/latest/reference/modules/prompts.html
205587642bcb-1
file_path – Path to directory to save prompt to. Example: .. code-block:: python prompt.save(file_path=”path/prompt.yaml”) pydantic model langchain.prompts.ChatPromptTemplate[source]# format(**kwargs: Any) → str[source]# Format the prompt with the inputs. Parameters kwargs – Any arguments to be passed to the prompt tem...
https://python.langchain.com/en/latest/reference/modules/prompts.html
205587642bcb-2
A list of the names of the variables the prompt template expects. field prefix: str = ''# A prompt template string to put before the examples. field suffix: str [Required]# A prompt template string to put after the examples. field template_format: str = 'f-string'# The format of the prompt template. Options are: ‘f-str...
https://python.langchain.com/en/latest/reference/modules/prompts.html
205587642bcb-3
field suffix: langchain.prompts.base.StringPromptTemplate [Required]# A PromptTemplate to put after the examples. field template_format: str = 'f-string'# The format of the prompt template. Options are: ‘f-string’, ‘jinja2’. field validate_template: bool = True# Whether or not to try validating the template. dict(**kwa...
https://python.langchain.com/en/latest/reference/modules/prompts.html
205587642bcb-4
Format the prompt with the inputs. Parameters kwargs – Any arguments to be passed to the prompt template. Returns A formatted string. Example: prompt.format(variable1="foo") classmethod from_examples(examples: List[str], suffix: str, input_variables: List[str], example_separator: str = '\n\n', prefix: str = '', **kwarg...
https://python.langchain.com/en/latest/reference/modules/prompts.html