id
stringlengths
14
16
text
stringlengths
45
2.73k
source
stringlengths
49
114
79e856615526-21
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, metadatas: Optional[List[dict]] = None, **kwargs: Any) → langchain.vectorstores.faiss.FAISS[source]# Construct FAISS wrapper from r...
https://python.langchain.com/en/latest/reference/modules/vectorstore.html
79e856615526-22
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/vectorstore.html
79e856615526-23
Parameters target – FAISS object you wish to merge into the current one Returns None. save_local(folder_path: str, index_name: str = 'index') → None[source]# Save FAISS index, docstore, and index_to_docstore_id to disk. Parameters folder_path – folder path to save index, docstore, and index_to_docstore_id to. index_nam...
https://python.langchain.com/en/latest/reference/modules/vectorstore.html
79e856615526-24
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 class langchain.vectorstores.Milvus(embedding_function: langchain.embeddings.base.Embeddings, connection_ar...
https://python.langchain.com/en/latest/reference/modules/vectorstore.html
79e856615526-25
Parameters texts (List[str]) – Text to insert. embedding (Embeddings) – Embedding function to use. metadatas (Optional[List[dict]], optional) – Dict metatadata. Defaults to None. Returns The Milvus vector store. Return type VectorStore max_marginal_relevance_search(query: str, k: int = 4, fetch_k: int = 20, param: Opti...
https://python.langchain.com/en/latest/reference/modules/vectorstore.html
79e856615526-26
to None. Returns Document results for search. Return type List[Document] similarity_search(query: str, k: int = 4, param: Optional[dict] = None, expr: Optional[str] = None, partition_names: Optional[List[str]] = None, round_decimal: int = - 1, timeout: Optional[int] = None, **kwargs: Any) → List[langchain.schema.Docume...
https://python.langchain.com/en/latest/reference/modules/vectorstore.html
79e856615526-27
param (dict, optional) – The search params for the specified index. Defaults to None. expr (str, optional) – Filtering expression. Defaults to None. partition_names (List[str], optional) – Partitions to search through. Defaults to None. round_decimal (int, optional) – Round the resulting distance. Defaults to -1. timeo...
https://python.langchain.com/en/latest/reference/modules/vectorstore.html
79e856615526-28
text_field: Document field the text of the document is stored in. Defaults to “text”. classmethod from_texts(texts: List[str], embedding: langchain.embeddings.base.Embeddings, metadatas: Optional[List[dict]] = None, bulk_size: int = 500, **kwargs: Any) → langchain.vectorstores.opensearch_vector_search.OpenSearchVectorS...
https://python.langchain.com/en/latest/reference/modules/vectorstore.html
79e856615526-29
default: 512 m: Number of bidirectional links created for each new element. Large impact on memory consumption. Between 2 and 100; default: 16 Keyword Args for Script Scoring or Painless Scripting:is_appx_search: False similarity_search(query: str, k: int = 4, **kwargs: Any) → List[langchain.schema.Document][source]# R...
https://python.langchain.com/en/latest/reference/modules/vectorstore.html
79e856615526-30
“hammingbit”; default: “l2” pre_filter: script_score query to pre-filter documents before identifying nearest neighbors; default: {“match_all”: {}} Optional Args for Painless Scripting Search:search_type: “painless_scripting”; default: “approximate_search” space_type: “l2Squared”, “l1Norm”, “cosineSimilarity”; default:...
https://python.langchain.com/en/latest/reference/modules/vectorstore.html
79e856615526-31
namespace – Optional pinecone namespace to add the texts to. Returns List of ids from adding the texts into the vectorstore. classmethod from_existing_index(index_name: str, embedding: langchain.embeddings.base.Embeddings, text_key: str = 'text', namespace: Optional[str] = None) → langchain.vectorstores.pinecone.Pineco...
https://python.langchain.com/en/latest/reference/modules/vectorstore.html
79e856615526-32
Parameters query – Text to look up documents similar to. k – Number of Documents to return. Defaults to 4. filter – Dictionary of argument(s) to filter on metadata namespace – Namespace to search in. Default will search in ‘’ namespace. Returns List of Documents most similar to the query and score for each similarity_s...
https://python.langchain.com/en/latest/reference/modules/vectorstore.html
79e856615526-33
Run more texts through the embeddings and add to the vectorstore. 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_texts(texts: List[str], embedding: langch...
https://python.langchain.com/en/latest/reference/modules/vectorstore.html
79e856615526-34
port – Port of the REST API interface. Default: 6333 grpc_port – Port of the gRPC interface. Default: 6334 prefer_grpc – If true - use gPRC interface whenever possible in custom methods. Default: False https – If true - use HTTPS(SSL) protocol. Default: None api_key – API key for authentication in Qdrant Cloud. Default...
https://python.langchain.com/en/latest/reference/modules/vectorstore.html
79e856615526-35
This is intended to be a quick way to get started. Example from langchain import Qdrant from langchain.embeddings import OpenAIEmbeddings embeddings = OpenAIEmbeddings() qdrant = Qdrant.from_texts(texts, embeddings, "localhost") max_marginal_relevance_search(query: str, k: int = 4, fetch_k: int = 20, **kwargs: Any) → L...
https://python.langchain.com/en/latest/reference/modules/vectorstore.html
79e856615526-36
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] = None)[source]# VectorStore for a Supabase postgre...
https://python.langchain.com/en/latest/reference/modules/vectorstore.html
79e856615526-37
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/vectorstore.html
79e856615526-38
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, **kwargs: Any) → List[langchain.schema.Document][source]# Return docs selected using the maximal marginal relevance. Maximal marginal relevance opt...
https://python.langchain.com/en/latest/reference/modules/vectorstore.html
79e856615526-39
Return docs and relevance scores in the range [0, 1]. 0 is dissimilar, 1 is most similar. table_name: str# class langchain.vectorstores.VectorStore[source]# Interface for vector stores. async aadd_documents(documents: List[langchain.schema.Document], **kwargs: Any) → List[str][source]# Run more documents through the em...
https://python.langchain.com/en/latest/reference/modules/vectorstore.html
79e856615526-40
Return VectorStore initialized from documents and embeddings. async classmethod afrom_texts(texts: List[str], embedding: langchain.embeddings.base.Embeddings, metadatas: Optional[List[dict]] = None, **kwargs: Any) → langchain.vectorstores.base.VST[source]# Return VectorStore initialized from texts and embeddings. async...
https://python.langchain.com/en/latest/reference/modules/vectorstore.html
79e856615526-41
Return VectorStore initialized from texts and embeddings. max_marginal_relevance_search(query: str, k: int = 4, fetch_k: int = 20, **kwargs: Any) → List[langchain.schema.Document][source]# Return docs selected using the maximal marginal relevance. Maximal marginal relevance optimizes for similarity to query AND diversi...
https://python.langchain.com/en/latest/reference/modules/vectorstore.html
79e856615526-42
Returns List of Documents most similar to the query vector. 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, 1]. 0 is dissimilar, 1 is most similar. class langchain.vectorstores.Weavi...
https://python.langchain.com/en/latest/reference/modules/vectorstore.html
79e856615526-43
from langchain.embeddings import OpenAIEmbeddings embeddings = OpenAIEmbeddings() weaviate = Weaviate.from_texts( texts, embeddings, weaviate_url="http://localhost:8080" ) max_marginal_relevance_search(query: str, k: int = 4, fetch_k: int = 20, **kwargs: Any) → List[langchain.schema.Document][source]# Retur...
https://python.langchain.com/en/latest/reference/modules/vectorstore.html
3c17d3dd911f-0
.rst .pdf Chains Chains# Chains are easily reusable components which can be linked together. pydantic model langchain.chains.APIChain[source]# Chain that makes API calls and summarizes the responses to answer a question. Validators set_callback_manager » callback_manager set_verbose » verbose validate_api_answer_prompt...
https://python.langchain.com/en/latest/reference/modules/chains.html
3c17d3dd911f-1
field requests_wrapper: TextRequestsWrapper [Required]# classmethod from_llm_and_api_docs(llm: langchain.schema.BaseLanguageModel, api_docs: str, headers: Optional[dict] = None, api_url_prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['api_docs', 'question'], output_parser=None, parti...
https://python.langchain.com/en/latest/reference/modules/chains.html
3c17d3dd911f-2
pydantic model langchain.chains.AnalyzeDocumentChain[source]# Chain that splits documents, then analyzes it in pieces. Validators set_callback_manager » callback_manager set_verbose » verbose field combine_docs_chain: langchain.chains.combine_documents.base.BaseCombineDocumentsChain [Required]# field text_splitter: lan...
https://python.langchain.com/en/latest/reference/modules/chains.html
3c17d3dd911f-3
qa_prompt = PromptTemplate( template="Q: {question} A:", input_variables=["question"], ) qa_chain = LLMChain(llm=OpenAI(), prompt=qa_prompt) constitutional_chain = ConstitutionalChain.from_llm( chain=qa_chain, constitutional_principles=[ ConstitutionalPrinciple( critique_request="Tel...
https://python.langchain.com/en/latest/reference/modules/chains.html
3c17d3dd911f-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
3c17d3dd911f-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
3c17d3dd911f-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
3c17d3dd911f-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
3c17d3dd911f-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
3c17d3dd911f-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
3c17d3dd911f-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
3c17d3dd911f-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
3c17d3dd911f-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
3c17d3dd911f-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
3c17d3dd911f-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
3c17d3dd911f-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
3c17d3dd911f-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
3c17d3dd911f-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
3c17d3dd911f-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
3c17d3dd911f-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
3c17d3dd911f-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
3c17d3dd911f-21
LLM wrapper to use. 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 will perform the task. There is no need to put ...
https://python.langchain.com/en/latest/reference/modules/chains.html
3c17d3dd911f-22
Utilize the LLM generate method for speed gains. async aapply_and_parse(input_list: List[Dict[str, Any]]) → Sequence[Union[str, List[str], Dict[str, str]]][source]# Call apply and then parse the results. async agenerate(input_list: List[Dict[str, Any]]) → langchain.schema.LLMResult[source]# Generate LLM result from inp...
https://python.langchain.com/en/latest/reference/modules/chains.html
3c17d3dd911f-23
Generate LLM result from inputs. predict(**kwargs: Any) → str[source]# Format prompt with kwargs and pass to LLM. Parameters **kwargs – Keys to pass to prompt template. Returns Completion from LLM. Example completion = llm.predict(adjective="funny") predict_and_parse(**kwargs: Any) → Union[str, List[str], Dict[str, str...
https://python.langchain.com/en/latest/reference/modules/chains.html
3c17d3dd911f-24
field list_assertions_prompt: langchain.prompts.prompt.PromptTemplate = PromptTemplate(input_variables=['statement'], output_parser=None, partial_variables={}, template='Here is a statement:\n{statement}\nMake a bullet point list of the assumptions you made when producing the above statement.\n\n', template_format='f-s...
https://python.langchain.com/en/latest/reference/modules/chains.html
3c17d3dd911f-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
3c17d3dd911f-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
3c17d3dd911f-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
3c17d3dd911f-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
3c17d3dd911f-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
3c17d3dd911f-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
3c17d3dd911f-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
3c17d3dd911f-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
3c17d3dd911f-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
3c17d3dd911f-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
3c17d3dd911f-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
3c17d3dd911f-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
9c4a218da040-0
.rst .pdf Agents Agents# Interface for agents. pydantic model langchain.agents.Agent[source]# Class responsible for calling the language model and deciding the action. This is driven by an LLMChain. The prompt in the LLMChain MUST include a variable called “agent_scratchpad” where the agent can put its intermediary wor...
https://python.langchain.com/en/latest/reference/modules/agents.html
9c4a218da040-1
Create the full inputs for the LLMChain from intermediate steps. plan(intermediate_steps: List[Tuple[langchain.schema.AgentAction, str]], **kwargs: Any) → Union[langchain.schema.AgentAction, langchain.schema.AgentFinish][source]# Given input, decided what to do. Parameters intermediate_steps – Steps the LLM has taken t...
https://python.langchain.com/en/latest/reference/modules/agents.html
9c4a218da040-2
field tools: Sequence[BaseTool] [Required]# classmethod from_agent_and_tools(agent: Union[langchain.agents.agent.BaseSingleActionAgent, langchain.agents.agent.BaseMultiActionAgent], tools: Sequence[langchain.tools.base.BaseTool], callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, **kwargs:...
https://python.langchain.com/en/latest/reference/modules/agents.html
9c4a218da040-3
Given input, decided what to do. Parameters intermediate_steps – Steps the LLM has taken to date, along with observations **kwargs – User inputs. Returns Actions specifying what tool to use. dict(**kwargs: Any) → Dict[source]# Return dictionary representation of agent. get_allowed_tools() → Optional[List[str]][source]#...
https://python.langchain.com/en/latest/reference/modules/agents.html
9c4a218da040-4
Given input, decided what to do. Parameters intermediate_steps – Steps the LLM has taken to date, along with observations **kwargs – User inputs. Returns Action specifying what tool to use. dict(**kwargs: Any) → Dict[source]# Return dictionary representation of agent. classmethod from_llm_and_tools(llm: langchain.schem...
https://python.langchain.com/en/latest/reference/modules/agents.html
9c4a218da040-5
pydantic model langchain.agents.ConversationalAgent[source]# An agent designed to hold a conversation in addition to using tools. field ai_prefix: str = 'AI'# field output_parser: langchain.agents.agent.AgentOutputParser [Optional]#
https://python.langchain.com/en/latest/reference/modules/agents.html
9c4a218da040-6
classmethod create_prompt(tools: Sequence[langchain.tools.base.BaseTool], prefix: str = 'Assistant is a large language model trained by OpenAI.\n\nAssistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of ...
https://python.langchain.com/en/latest/reference/modules/agents.html
9c4a218da040-7
powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist.\n\nTOOLS:\n------\n\nAssistant has access to the follo...
https://python.langchain.com/en/latest/reference/modules/agents.html
9c4a218da040-8
'AI', human_prefix: str = 'Human', input_variables: Optional[List[str]] = None) → langchain.prompts.prompt.PromptTemplate[source]#
https://python.langchain.com/en/latest/reference/modules/agents.html
9c4a218da040-9
Create prompt in the style of the zero shot agent. Parameters tools – List of tools the agent will have access to, used to format the prompt. prefix – String to put before the list of tools. suffix – String to put after the list of tools. ai_prefix – String to use before AI output. human_prefix – String to use before h...
https://python.langchain.com/en/latest/reference/modules/agents.html
9c4a218da040-10
classmethod from_llm_and_tools(llm: langchain.schema.BaseLanguageModel, tools: Sequence[langchain.tools.base.BaseTool], callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, output_parser: Optional[langchain.agents.agent.AgentOutputParser] = None, prefix: str = 'Assistant is a large language ...
https://python.langchain.com/en/latest/reference/modules/agents.html
9c4a218da040-11
receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.\n\nOverall, Assistant is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or...
https://python.langchain.com/en/latest/reference/modules/agents.html
9c4a218da040-12
the format:\n\n```\nThought: Do I need to use a tool? No\n{ai_prefix}: [your response here]\n```', ai_prefix: str = 'AI', human_prefix: str = 'Human', input_variables: Optional[List[str]] = None, **kwargs: Any) → langchain.agents.agent.Agent[source]#
https://python.langchain.com/en/latest/reference/modules/agents.html
9c4a218da040-13
Construct an agent from an LLM and tools. property llm_prefix: str# Prefix to append the llm call with. property observation_prefix: str# Prefix to append the observation with. pydantic model langchain.agents.ConversationalChatAgent[source]# An agent designed to hold a conversation in addition to using tools. field out...
https://python.langchain.com/en/latest/reference/modules/agents.html
9c4a218da040-14
classmethod create_prompt(tools: Sequence[langchain.tools.base.BaseTool], system_message: str = 'Assistant is a large language model trained by OpenAI.\n\nAssistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide r...
https://python.langchain.com/en/latest/reference/modules/agents.html
9c4a218da040-15
classmethod from_llm_and_tools(llm: langchain.schema.BaseLanguageModel, tools: Sequence[langchain.tools.base.BaseTool], callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, output_parser: Optional[langchain.agents.agent.AgentOutputParser] = None, system_message: str = 'Assistant is a large l...
https://python.langchain.com/en/latest/reference/modules/agents.html
9c4a218da040-16
receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.\n\nOverall, Assistant is a powerful system that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question ...
https://python.langchain.com/en/latest/reference/modules/agents.html
9c4a218da040-17
Construct an agent from an LLM and tools. property llm_prefix: str# Prefix to append the llm call with. property observation_prefix: str# Prefix to append the observation with. pydantic model langchain.agents.LLMSingleActionAgent[source]# field llm_chain: langchain.chains.llm.LLMChain [Required]# field output_parser: l...
https://python.langchain.com/en/latest/reference/modules/agents.html
9c4a218da040-18
Validators set_callback_manager » callback_manager set_verbose » verbose validate_return_direct_tool » all fields validate_tools » all fields field agent: Union[BaseSingleActionAgent, BaseMultiActionAgent] [Required]# field callback_manager: BaseCallbackManager [Optional]# field early_stopping_method: str = 'force'# fi...
https://python.langchain.com/en/latest/reference/modules/agents.html
9c4a218da040-19
action_name="Calculator", action=llm_math_chain.run, action_description="useful for doing math" ) ] mrkl = MRKLChain.from_chains(llm, chains) pydantic model langchain.agents.ReActChain[source]# Chain that implements the ReAct paper. Example from langchain import ReActChain, OpenAI react = ReAct(llm=...
https://python.langchain.com/en/latest/reference/modules/agents.html
9c4a218da040-20
Validators set_callback_manager » callback_manager set_verbose » verbose validate_return_direct_tool » all fields validate_tools » all fields field agent: Union[BaseSingleActionAgent, BaseMultiActionAgent] [Required]# field callback_manager: BaseCallbackManager [Optional]# field early_stopping_method: str = 'force'# fi...
https://python.langchain.com/en/latest/reference/modules/agents.html
9c4a218da040-21
field output_parser: langchain.agents.agent.AgentOutputParser [Optional]# classmethod create_prompt(tools: Sequence[langchain.tools.base.BaseTool], prefix: str = 'Answer the following questions as best you can. You have access to the following tools:', suffix: str = 'Begin!\n\nQuestion: {input}\nThought:{agent_scratchp...
https://python.langchain.com/en/latest/reference/modules/agents.html
9c4a218da040-22
Returns A PromptTemplate with the template assembled from the pieces here. classmethod from_llm_and_tools(llm: langchain.schema.BaseLanguageModel, tools: Sequence[langchain.tools.base.BaseTool], callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, output_parser: Optional[langchain.agents.age...
https://python.langchain.com/en/latest/reference/modules/agents.html
9c4a218da040-23
langchain.agents.create_json_agent(llm: langchain.llms.base.BaseLLM, toolkit: langchain.agents.agent_toolkits.json.toolkit.JsonToolkit, callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, prefix: str = 'You are an agent designed to interact with JSON.\nYour goal is to return a final answer ...
https://python.langchain.com/en/latest/reference/modules/agents.html
9c4a218da040-24
cannot use it.\nYou should only add one key at a time to the path. You cannot add multiple keys at once.\nIf you encounter a "KeyError", go back to the previous key, look at the available keys, and try again.\n\nIf the question does not seem to be related to the JSON, just return "I don\'t know" as the answer.\nAlways ...
https://python.langchain.com/en/latest/reference/modules/agents.html
9c4a218da040-25
= 'Begin!"\n\nQuestion: {input}\nThought: I should look at the keys that exist in data to see what I have access to\n{agent_scratchpad}', format_instructions: str = 'Use the following format:\n\nQuestion: the input question you must answer\nThought: you should always think about what to do\nAction: the action to take, ...
https://python.langchain.com/en/latest/reference/modules/agents.html
9c4a218da040-26
Construct a json agent from an LLM and tools.
https://python.langchain.com/en/latest/reference/modules/agents.html
9c4a218da040-27
langchain.agents.create_openapi_agent(llm: langchain.llms.base.BaseLLM, toolkit: langchain.agents.agent_toolkits.openapi.toolkit.OpenAPIToolkit, callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, prefix: str = "You are an agent designed to answer questions by making web requests to an API ...
https://python.langchain.com/en/latest/reference/modules/agents.html
9c4a218da040-28
which parameters are required. For parameters with a fixed set of values, please use the spec to look at which values are allowed.\n\nUse the exact parameter names as listed in the spec, do not make up any names or abbreviate the names of parameters.\nIf you get a not found error, ensure that you are using a path that ...
https://python.langchain.com/en/latest/reference/modules/agents.html
9c4a218da040-29
None, max_iterations: Optional[int] = 15, max_execution_time: Optional[float] = None, early_stopping_method: str = 'force', verbose: bool = False, return_intermediate_steps: bool = False, **kwargs: Any) → langchain.agents.agent.AgentExecutor[source]#
https://python.langchain.com/en/latest/reference/modules/agents.html
9c4a218da040-30
Construct a json agent from an LLM and tools. langchain.agents.create_pandas_dataframe_agent(llm: langchain.llms.base.BaseLLM, df: Any, callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, prefix: str = '\nYou are working with a pandas dataframe in Python. The name of the dataframe is `df`.\...
https://python.langchain.com/en/latest/reference/modules/agents.html
9c4a218da040-31
langchain.agents.create_sql_agent(llm: langchain.llms.base.BaseLLM, toolkit: langchain.agents.agent_toolkits.sql.toolkit.SQLDatabaseToolkit, callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, prefix: str = 'You are an agent designed to interact with a SQL database.\nGiven an input question...
https://python.langchain.com/en/latest/reference/modules/agents.html
9c4a218da040-32
rewrite the query and try again.\n\nDO NOT make any DML statements (INSERT, UPDATE, DELETE, DROP etc.) to the database.\n\nIf the question does not seem related to the database, just return "I don\'t know" as the answer.\n', suffix: str = 'Begin!\n\nQuestion: {input}\nThought: I should look at the tables in the databas...
https://python.langchain.com/en/latest/reference/modules/agents.html
9c4a218da040-33
str = 'force', verbose: bool = False, **kwargs: Any) → langchain.agents.agent.AgentExecutor[source]#
https://python.langchain.com/en/latest/reference/modules/agents.html
9c4a218da040-34
Construct a sql agent from an LLM and tools. langchain.agents.create_vectorstore_agent(llm: langchain.llms.base.BaseLLM, toolkit: langchain.agents.agent_toolkits.vectorstore.toolkit.VectorStoreToolkit, callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, prefix: str = 'You are an agent desig...
https://python.langchain.com/en/latest/reference/modules/agents.html
9c4a218da040-35
Get a list of all possible tool names. langchain.agents.initialize_agent(tools: Sequence[langchain.tools.base.BaseTool], llm: langchain.schema.BaseLanguageModel, agent: Optional[langchain.agents.agent_types.AgentType] = None, callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, agent_path: O...
https://python.langchain.com/en/latest/reference/modules/agents.html
9c4a218da040-36
llm – Optional language model, may be needed to initialize certain tools. callback_manager – Optional callback manager. If not provided, default global callback manager will be used. Returns List of tools. langchain.agents.tool(*args: Union[str, Callable], return_direct: bool = False, args_schema: Optional[Type[pydanti...
https://python.langchain.com/en/latest/reference/modules/agents.html
c0587b89c087-0
.rst .pdf Python REPL Python REPL# For backwards compatibility. pydantic model langchain.python.PythonREPL[source]# Simulates a standalone Python REPL. field globals: Optional[Dict] [Optional] (alias '_globals')# field locals: Optional[Dict] [Optional] (alias '_locals')# run(command: str) → str[source]# Run command wit...
https://python.langchain.com/en/latest/reference/modules/python.html
cc47f48085d0-0
.rst .pdf Embeddings Embeddings# Wrappers around embedding modules. pydantic model langchain.embeddings.AlephAlphaAsymmetricSemanticEmbedding[source]# Wrapper for Aleph Alpha’s Asymmetric Embeddings AA provides you with an endpoint to embed a document and a query. The models were optimized to make the embeddings of doc...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
cc47f48085d0-1
Parameters texts – The list of texts to embed. Returns List of embeddings, one for each text. embed_query(text: str) → List[float][source]# Call out to Aleph Alpha’s asymmetric, query embedding endpoint :param text: The text to embed. Returns Embeddings for the text. pydantic model langchain.embeddings.AlephAlphaSymmet...
https://python.langchain.com/en/latest/reference/modules/embeddings.html