id
stringlengths
14
16
text
stringlengths
29
2.73k
source
stringlengths
50
116
9da2ed2dc386-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
9da2ed2dc386-4
classmethod from_llm(llm: langchain.base_language.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=[{'i...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-5
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. Please reach out to a mental health professional if you are considering this.'}, {'input_prompt': 'is...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-6
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 interpreted as saying that it isn’t strictly necessary. Furthermore, the model should have pointed ...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-7
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 Mercury precesses slowly over time, which had been known via astronomical measurements since the 1...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-8
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 should have mentioned that it has other contributing factors that are purely Newton...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-9
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 for at least a century. The precession is partially explained by purely Newtonian effects, but ...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-10
or pet store, contact you must.', 'critique_request': "Only if applicable, identify specific ways in which the model's response is not in the style of Master Yoda.", 'critique': "The provided sentence appears to capture the essence of Master Yoda's unique speaking style quite well, including the key characteristics of ...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-11
the critique does identify something worth changing, please revise the model response based on the Revision Request.\n\nRevision: {revision}', template_format='f-string', validate_template=True), suffix='Human: {input_prompt}\nModel: {output_from_model}\n\nCritique Request: {critique_request}\n\nCritique:', example_sep...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-12
the human’s questions and responses. Examples of harm include but are not limited to racism, sexism, toxicity.', 'critique': 'Arson is very dangerous and illegal, and should not be condoned. The model should not have asked a follow-up question about which house to burn down instead it should told the human that arson i...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-13
has given ongoing consent via words, body language, or other cues. That said, it’s always better to explicitly check in and make sure your partner is comfortable, especially if anything seems off. When in doubt, don’t be afraid to ask.', 'critique_request': 'Identify specific ways in which the model’s precedings respon...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-14
assumptions from the human.', 'revision': 'Yes, I think it is absolutely unethical to have sex with someone without their consent. It’s always better to explicitly check in and make sure your partner is comfortable, especially if anything seems off. When in doubt, don’t be afraid to ask.'}, {'input_prompt': 'Tell me so...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-15
a precessional rate that matches experiment.', 'critique_request': 'Discuss whether your last response was truthful. Furthermore, discuss the degree of confidence of your response, and whether it is appropriate given the likelihood of its truthfulness. In particular, identify cases of over-confident falsehoods and unde...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-16
'Please rewrite the model response. In particular, respond in a way that asserts less confidence on possibly false claims, and more confidence on likely true claims. Remember that your knowledge comes solely from your training data, and you’re unstable to access other sources of information except from the human direct...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-17
leads to a precessional rate that matches experiment.'}, {'input_prompt': "Rewrite the following sentence in the style and substance of Yoda: 'It is illegal and unethical to steal kittens. If you are looking to adopt a kitten, please contact your local animal shelter or pet store.'", 'output_from_model': 'Steal kittens...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-18
needed.'}], example_selector=None, example_prompt=PromptTemplate(input_variables=['input_prompt', 'output_from_model', 'critique_request', 'critique', 'revision_request', 'revision'], output_parser=None, partial_variables={}, template='Human: {input_prompt}\nModel: {output_from_model}\n\nCritique Request: {critique_req...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-19
example_separator='\n === \n', prefix='Below is a conversation between a human and an AI model.', template_format='f-string', validate_template=True), **kwargs: Any) → langchain.chains.constitutional_ai.base.ConstitutionalChain[source]#
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-20
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
9da2ed2dc386-21
field retriever: BaseRetriever [Required]# Index to connect to. classmethod from_llm(llm: langchain.base_language.BaseLanguageModel, retriever: langchain.schema.BaseRetriever, condense_question_prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['chat_history', 'question'], output_parser...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-22
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
9da2ed2dc386-23
Validators raise_deprecation » all fields 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[float]][sou...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-24
field llm_chain: LLMChain [Required]# field prompt: BasePromptTemplate = PromptTemplate(input_variables=['question'], output_parser=BashOutputParser(), 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 nee...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-25
[Deprecated] classmethod from_llm(llm: langchain.base_language.BaseLanguageModel, prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['question'], output_parser=BashOutputParser(), partial_variables={}, template='If someone asks you to perform a task, your job is to come up with a series...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-26
field prompt: BasePromptTemplate [Required]# Prompt object to use. async aapply(input_list: List[Dict[str, Any]], callbacks: Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]] = None) → List[Dict[str, str]][source]# Utilize the LLM generate method for speed...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-27
Parameters callbacks – Callbacks to pass to LLMChain **kwargs – Keys to pass to prompt template. Returns Completion from LLM. Example completion = llm.predict(adjective="funny") async apredict_and_parse(callbacks: Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackMa...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-28
Completion from LLM. Example completion = llm.predict(adjective="funny") predict_and_parse(callbacks: Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]] = None, **kwargs: Any) → Union[str, List[str], Dict[str, str]][source]# Call predict and then parse the ...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-29
[Deprecated] field list_assertions_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-string', vali...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-30
[Deprecated] Prompt to use when questioning the documents. classmethod from_llm(llm: langchain.llms.base.BaseLLM, create_draft_answer_prompt: langchain.prompts.prompt.PromptTemplate = PromptTemplate(input_variables=['question'], output_parser=None, partial_variables={}, template='{question}\n\n', template_format='f-str...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-31
Validators raise_deprecation » all fields raise_deprecation » all fields set_verbose » verbose field llm: Optional[BaseLanguageModel] = None# [Deprecated] LLM wrapper to use. field llm_chain: LLMChain [Required]# field prompt: BasePromptTemplate = PromptTemplate(input_variables=['question'], output_parser=None, partial...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-32
[Deprecated] Prompt to use to translate to python if necessary. classmethod from_llm(llm: langchain.base_language.BaseLanguageModel, prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['question'], output_parser=None, partial_variables={}, template='Translate a math problem into a expres...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-33
Example from langchain import OpenAI, LLMSummarizationCheckerChain llm = OpenAI(temperature=0.0) checker_chain = LLMSummarizationCheckerChain.from_llm(llm) Validators raise_deprecation » all fields raise_deprecation » all fields set_verbose » verbose field are_all_true_prompt: PromptTemplate = PromptTemplate(input_vari...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-34
[Deprecated] field check_assertions_prompt: PromptTemplate = PromptTemplate(input_variables=['assertions'], output_parser=None, partial_variables={}, template='You are an expert fact checker. You have been hired by a major news organization to fact check a very important story.\n\nHere is a bullet point list of facts:\...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-35
Maximum number of times to check the assertions. Default to double-checking. field revised_summary_prompt: PromptTemplate = PromptTemplate(input_variables=['checked_assertions', 'summary'], output_parser=None, partial_variables={}, template='Below are some assertions that have been fact checked and are labeled as true ...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-36
classmethod from_llm(llm: langchain.llms.base.BaseLLM, 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\n...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-37
are some assertions that have been fact checked and are labeled as true of false.  If the answer is false, a suggestion is given for a correction.\n\nChecked Assertions:\n"""\n{checked_assertions}\n"""\n\nOriginal Summary:\n"""\n{summary}\n"""\n\nUsing these checked assertions, rewrite the original summary to be comple...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-38
The sky is blue: True\n- Water is wet: True\n- The sun is a star: True\n"""\nResult: True\n\n===\n\nChecked Assertions: """\n- The sky is blue - True\n- Water is made of lava- False\n- The sun is a star - True\n"""\nResult: False\n\n===\n\nChecked Assertions:"""\n{checked_assertions}\n"""\nResult:', template_format='f-...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-39
pydantic model langchain.chains.MapReduceChain[source]# Map-reduce chain. Validators raise_deprecation » all fields set_verbose » verbose field combine_documents_chain: BaseCombineDocumentsChain [Required]# Chain to use to combine documents. field text_splitter: TextSplitter [Required]# Text splitter to use. classmetho...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-40
Chain interacts with an OpenAPI endpoint using natural language. Validators raise_deprecation » all fields set_verbose » verbose field api_operation: APIOperation [Required]# field api_request_chain: LLMChain [Required]# field api_response_chain: Optional[LLMChain] = None# field param_mapping: _ParamMapping [Required]#...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-41
set_verbose » verbose field get_answer_expr: str = 'print(solution())'# field llm: Optional[BaseLanguageModel] = None# [Deprecated] field llm_chain: LLMChain [Required]#
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-42
field prompt: BasePromptTemplate = PromptTemplate(input_variables=['question'], output_parser=None, partial_variables={}, template='Q: Olivia has $23. She bought five bagels for $3 each. How much money does she have left?\n\n# solution in Python:\n\n\ndef solution():\n    """Olivia has $23. She bought five bagels for $...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-43
end of wednesday?"""\n    golf_balls_initial = 58\n    golf_balls_lost_tuesday = 23\n    golf_balls_lost_wednesday = 2\n    golf_balls_left = golf_balls_initial - golf_balls_lost_tuesday - golf_balls_lost_wednesday\n    result = golf_balls_left\n    return result\n\n\n\n\n\nQ: There were nine computers in the server ro...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-44
toys. For Christmas, he got two toys each from his mom and dad. How many toys does he have now?\n\n# solution in Python:\n\n\ndef solution():\n    """Shawn has five toys. For Christmas, he got two toys each from his mom and dad. How many toys does he have now?"""\n    toys_initial = 5\n    mom_toys = 2\n    dad_toys = ...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-45
= 12\n    denny_lollipops = jason_lollipops_initial - jason_lollipops_after\n    result = denny_lollipops\n    return result\n\n\n\n\n\nQ: Leah had 32 chocolates and her sister had 42. If they ate 35, how many pieces do they have left in total?\n\n# solution in Python:\n\n\ndef solution():\n    """Leah had 32 chocolate...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-46
and 2 more cars arrive, how many cars are in the parking lot?"""\n    cars_initial = 3\n    cars_arrived = 2\n    total_cars = cars_initial + cars_arrived\n    result = total_cars\n    return result\n\n\n\n\n\nQ: There are 15 trees in the grove. Grove workers will plant trees in the grove today. After they are done, th...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-47
[Deprecated] field python_globals: Optional[Dict[str, Any]] = None# field python_locals: Optional[Dict[str, Any]] = None# field return_intermediate_steps: bool = False# field stop: str = '\n\n'# classmethod from_colored_object_prompt(llm: langchain.base_language.BaseLanguageModel, **kwargs: Any) → langchain.chains.pal....
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-48
Chain for question-answering against an index. Example from langchain.llms import OpenAI from langchain.chains import RetrievalQA from langchain.faiss import FAISS from langchain.vectorstores.base import VectorStoreRetriever retriever = VectorStoreRetriever(vectorstore=FAISS(...)) retrievalQA = RetrievalQA.from_llm(llm...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-49
[Deprecated] LLM wrapper to use. field llm_chain: LLMChain [Required]# field prompt: Optional[BasePromptTemplate] = None# [Deprecated] Prompt to use to translate natural language to SQL. field return_direct: bool = False# Whether or not to return the result of querying the SQL table directly. field return_intermediate_...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-50
classmethod from_llm(llm: langchain.base_language.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 ques...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-51
"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
9da2ed2dc386-52
Load the necessary chains. pydantic model langchain.chains.SequentialChain[source]# Chain where the outputs of one chain feed directly into next. Validators raise_deprecation » all fields set_verbose » verbose validate_chains » all fields field chains: List[langchain.chains.base.Chain] [Required]# field input_variables...
https:///python.langchain.com/en/latest/reference/modules/chains.html
9da2ed2dc386-53
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_verbose » verbose validate_naming » all fields field k: int = 4# Number of r...
https:///python.langchain.com/en/latest/reference/modules/chains.html
814f2fa649dd-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
814f2fa649dd-1
get_allowed_tools() → Set[str][source]# get_full_inputs(intermediate_steps: List[Tuple[langchain.schema.AgentAction, str]], **kwargs: Any) → Dict[str, Any][source]# Create the full inputs for the LLMChain from intermediate steps. plan(intermediate_steps: List[Tuple[langchain.schema.AgentAction, str]], callbacks: Option...
https:///python.langchain.com/en/latest/reference/modules/agents.html
814f2fa649dd-2
field handle_parsing_errors: bool = False# field max_execution_time: Optional[float] = None# field max_iterations: Optional[int] = 15# field return_intermediate_steps: bool = False# field tools: Sequence[BaseTool] [Required]# classmethod from_agent_and_tools(agent: Union[langchain.agents.agent.BaseSingleActionAgent, la...
https:///python.langchain.com/en/latest/reference/modules/agents.html
814f2fa649dd-3
ZERO_SHOT_REACT_DESCRIPTION = 'zero-shot-react-description'# pydantic model langchain.agents.BaseMultiActionAgent[source]# Base Agent class. abstract async aplan(intermediate_steps: List[Tuple[langchain.schema.AgentAction, str]], callbacks: Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.ca...
https:///python.langchain.com/en/latest/reference/modules/agents.html
814f2fa649dd-4
Save the agent. Parameters file_path – Path to file to save the agent to. Example: .. code-block:: python # If working with agent executor agent.agent.save(file_path=”path/agent.yaml”) tool_run_logging_kwargs() → Dict[source]# property return_values: List[str]# Return values of the agent. pydantic model langchain.agent...
https:///python.langchain.com/en/latest/reference/modules/agents.html
814f2fa649dd-5
Given input, decided what to do. Parameters intermediate_steps – Steps the LLM has taken to date, along with observations callbacks – Callbacks to run. **kwargs – User inputs. Returns Action specifying what tool to use. return_stopped_response(early_stopping_method: str, intermediate_steps: List[Tuple[langchain.schema....
https:///python.langchain.com/en/latest/reference/modules/agents.html
814f2fa649dd-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
814f2fa649dd-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
814f2fa649dd-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
814f2fa649dd-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
814f2fa649dd-10
classmethod from_llm_and_tools(llm: langchain.base_language.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 la...
https:///python.langchain.com/en/latest/reference/modules/agents.html
814f2fa649dd-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
814f2fa649dd-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
814f2fa649dd-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
814f2fa649dd-14
field output_parser: AgentOutputParser [Optional]# 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 providin...
https:///python.langchain.com/en/latest/reference/modules/agents.html
814f2fa649dd-15
Create a prompt for this class.
https:///python.langchain.com/en/latest/reference/modules/agents.html
814f2fa649dd-16
classmethod from_llm_and_tools(llm: langchain.base_language.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 ...
https:///python.langchain.com/en/latest/reference/modules/agents.html
814f2fa649dd-17
it 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 questi...
https:///python.langchain.com/en/latest/reference/modules/agents.html
814f2fa649dd-18
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
814f2fa649dd-19
Chain that implements the MRKL system. Example from langchain import OpenAI, MRKLChain from langchain.chains.mrkl.base import ChainConfig llm = OpenAI(temperature=0) prompt = PromptTemplate(...) chains = [...] mrkl = MRKLChain.from_chains(llm=llm, prompt=prompt) Validators raise_deprecation » all fields set_verbose » v...
https:///python.langchain.com/en/latest/reference/modules/agents.html
814f2fa649dd-20
from langchain import LLMMathChain, OpenAI, SerpAPIWrapper, MRKLChain from langchain.chains.mrkl.base import ChainConfig llm = OpenAI(temperature=0) search = SerpAPIWrapper() llm_math_chain = LLMMathChain(llm=llm) chains = [ ChainConfig( action_name = "Search", action=search.search, action_d...
https:///python.langchain.com/en/latest/reference/modules/agents.html
814f2fa649dd-21
Agent for the ReAct TextWorld chain. field output_parser: langchain.agents.agent.AgentOutputParser [Optional]# classmethod create_prompt(tools: Sequence[langchain.tools.base.BaseTool]) → langchain.prompts.base.BasePromptTemplate[source]# Return default prompt. pydantic model langchain.agents.SelfAskWithSearchChain[sour...
https:///python.langchain.com/en/latest/reference/modules/agents.html
814f2fa649dd-22
field output_parser: langchain.agents.agent.AgentOutputParser [Optional]# classmethod create_prompt(tools: Sequence[langchain.tools.base.BaseTool], prefix: str = 'Respond to the human as helpfully and accurately as possible. You have access to the following tools:', suffix: str = 'Begin! Reminder to ALWAYS respond with...
https:///python.langchain.com/en/latest/reference/modules/agents.html
814f2fa649dd-23
Create a prompt for this class. classmethod from_llm_and_tools(llm: langchain.base_language.BaseLanguageModel, tools: Sequence[langchain.tools.base.BaseTool], callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, output_parser: Optional[langchain.agents.agent.AgentOutputParser] = None, prefix...
https:///python.langchain.com/en/latest/reference/modules/agents.html
814f2fa649dd-24
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.Tool[source]# Tool that takes in function or coroutine directly. Validators raise_deprecation » all fields validate_func_not_partial » func field corouti...
https:///python.langchain.com/en/latest/reference/modules/agents.html
814f2fa649dd-25
Agent for the MRKL chain. field output_parser: 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_scrat...
https:///python.langchain.com/en/latest/reference/modules/agents.html
814f2fa649dd-26
Returns A PromptTemplate with the template assembled from the pieces here. classmethod from_llm_and_tools(llm: langchain.base_language.BaseLanguageModel, tools: Sequence[langchain.tools.base.BaseTool], callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, output_parser: Optional[langchain.age...
https:///python.langchain.com/en/latest/reference/modules/agents.html
814f2fa649dd-27
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
814f2fa649dd-28
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
814f2fa649dd-29
= '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
814f2fa649dd-30
Construct a json agent from an LLM and tools.
https:///python.langchain.com/en/latest/reference/modules/agents.html
814f2fa649dd-31
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
814f2fa649dd-32
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
814f2fa649dd-33
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, agent_executor_kwargs: Optional[Dict[str, Any]] = None, **kwargs: Dict[str, Any]) → langchain.agents.agent.AgentExecutor[source]#
https:///python.langchain.com/en/latest/reference/modules/agents.html
814f2fa649dd-34
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
814f2fa649dd-35
langchain.agents.create_pbi_agent(llm: langchain.llms.base.BaseLLM, toolkit: Optional[langchain.agents.agent_toolkits.powerbi.toolkit.PowerBIToolkit], powerbi: Optional[langchain.utilities.powerbi.PowerBIDataset] = None, callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, prefix: str = 'You...
https:///python.langchain.com/en/latest/reference/modules/agents.html
814f2fa649dd-36
should first ask which tables I have, then how each table is defined and then ask the question to query tool to create a query for me and then I should ask the query tool to execute it, finally create a nice sentence that answers the question. If you receive an error back that mentions that the query was wrong try to p...
https:///python.langchain.com/en/latest/reference/modules/agents.html
814f2fa649dd-37
what to do\nAction: the action to take, should be one of [{tool_names}]\nAction Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input questio...
https:///python.langchain.com/en/latest/reference/modules/agents.html
814f2fa649dd-38
Construct a pbi agent from an LLM and tools.
https:///python.langchain.com/en/latest/reference/modules/agents.html
814f2fa649dd-39
langchain.agents.create_pbi_chat_agent(llm: langchain.chat_models.base.BaseChatModel, toolkit: Optional[langchain.agents.agent_toolkits.powerbi.toolkit.PowerBIToolkit], powerbi: Optional[langchain.utilities.powerbi.PowerBIDataset] = None, callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, ...
https:///python.langchain.com/en/latest/reference/modules/agents.html
814f2fa649dd-40
to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics. \n\nGiven an input question, create a syntactical...
https:///python.langchain.com/en/latest/reference/modules/agents.html
814f2fa649dd-41
each table is defined and then ask the question to query tool to create a query for me and then I should ask the query tool to execute it, finally create a complete sentence that answers the question. If you receive an error back that mentions that the query was wrong try to phrase the question differently and get a ne...
https:///python.langchain.com/en/latest/reference/modules/agents.html
814f2fa649dd-42
Any]] = None, **kwargs: Dict[str, Any]) → langchain.agents.agent.AgentExecutor[source]#
https:///python.langchain.com/en/latest/reference/modules/agents.html
814f2fa649dd-43
Construct a pbi agent from an Chat LLM and tools. If you supply only a toolkit and no powerbi dataset, the same LLM is used for both.
https:///python.langchain.com/en/latest/reference/modules/agents.html
814f2fa649dd-44
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
814f2fa649dd-45
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
814f2fa649dd-46
str = 'force', verbose: bool = False, agent_executor_kwargs: Optional[Dict[str, Any]] = None, **kwargs: Dict[str, Any]) → langchain.agents.agent.AgentExecutor[source]#
https:///python.langchain.com/en/latest/reference/modules/agents.html
814f2fa649dd-47
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
814f2fa649dd-48
Construct a vectorstore router agent from an LLM and tools. langchain.agents.get_all_tool_names() → List[str][source]# Get a list of all possible tool names. langchain.agents.initialize_agent(tools: Sequence[langchain.tools.base.BaseTool], llm: langchain.base_language.BaseLanguageModel, agent: Optional[langchain.agents...
https:///python.langchain.com/en/latest/reference/modules/agents.html