Agent Toolkits
Agent toolkits.
langchain.agents.agent_toolkits.create_json_agent(llm, toolkit, callback_manager=None, prefix='You are an agent designed to interact with JSON.\nYour goal is to return a final answer by interacting with the JSON.\nYou have access to the following tools which help you learn more about the JSON you are interacting with.\nOnly use the below tools. Only use the information returned by the below tools to construct your final answer.\nDo not make up any information that is not contained in the JSON.\nYour input to the tools should be in the form of `data["key"][0]` where `data` is the JSON blob you are interacting with, and the syntax used is Python. \nYou should only use keys that you know for a fact exist. You must validate that a key exists by seeing it previously when calling `json_spec_list_keys`. \nIf you have not seen a key in one of those responses, you 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 begin your interaction with the `json_spec_list_keys` tool with input "data" to see what keys exist in the JSON.\n\nNote that sometimes the value at a given path is large. In this case, you will get an error "Value is a large dictionary, should explore its keys directly".\nIn this case, you should ALWAYS follow up by using the `json_spec_list_keys` tool to see what keys exist at that path.\nDo not simply refer the user to the JSON or a section of the JSON, as this is not a valid answer. Keep digging until you find the answer and explicitly return it.\n', suffix='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='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, 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 question', input_variables=None, verbose=False, agent_executor_kwargs=None, **kwargs)[source]
Construct a json agent from an LLM and tools.
Parameters
llm (langchain.base_language.BaseLanguageModel) – 
toolkit (langchain.agents.agent_toolkits.json.toolkit.JsonToolkit) – 
callback_manager (Optional[langchain.callbacks.base.BaseCallbackManager]) – 
prefix (str) – 
suffix (str) – 
format_instructions (str) – 
input_variables (Optional[List[str]]) – 
verbose (bool) – 
agent_executor_kwargs (Optional[Dict[str, Any]]) – 
kwargs (Dict[str, Any]) – 
Return type
langchain.agents.agent.AgentExecutor
langchain.agents.agent_toolkits.create_sql_agent(llm, toolkit, agent_type=AgentType.ZERO_SHOT_REACT_DESCRIPTION, callback_manager=None, prefix='You are an agent designed to interact with a SQL database.\nGiven an input question, create a syntactically correct {dialect} query to run, then look at the results of the query and return the answer.\nUnless the user specifies a specific number of examples they wish to obtain, always limit your query to at most {top_k} results.\nYou can order the results by a relevant column to return the most interesting examples in the database.\nNever query for all the columns from a specific table, only ask for the relevant columns given the question.\nYou have access to tools for interacting with the database.\nOnly use the below tools. Only use the information returned by the below tools to construct your final answer.\nYou MUST double check your query before executing it. If you get an error while executing a query, 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=None, format_instructions='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, 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 question', input_variables=None, top_k=10, max_iterations=15, max_execution_time=None, early_stopping_method='force', verbose=False, agent_executor_kwargs=None, **kwargs)[source]
Construct a sql agent from an LLM and tools.
Parameters
llm (langchain.base_language.BaseLanguageModel) – 
toolkit (langchain.agents.agent_toolkits.sql.toolkit.SQLDatabaseToolkit) – 
agent_type (langchain.agents.agent_types.AgentType) – 
callback_manager (Optional[langchain.callbacks.base.BaseCallbackManager]) – 
prefix (str) – 
suffix (Optional[str]) – 
format_instructions (str) – 
input_variables (Optional[List[str]]) – 
top_k (int) – 
max_iterations (Optional[int]) – 
max_execution_time (Optional[float]) – 
early_stopping_method (str) – 
verbose (bool) – 
agent_executor_kwargs (Optional[Dict[str, Any]]) – 
kwargs (Dict[str, Any]) – 
Return type
langchain.agents.agent.AgentExecutor
langchain.agents.agent_toolkits.create_openapi_agent(llm, toolkit, callback_manager=None, prefix="You are an agent designed to answer questions by making web requests to an API given the openapi spec.\n\nIf the question does not seem related to the API, return I don't know. Do not make up an answer.\nOnly use information provided by the tools to construct your response.\n\nFirst, find the base URL needed to make the request.\n\nSecond, find the relevant paths needed to answer the question. Take note that, sometimes, you might need to make more than one request to more than one path to answer the question.\n\nThird, find the required parameters needed to make the request. For GET requests, these are usually URL parameters and for POST requests, these are request body parameters.\n\nFourth, make the requests needed to answer the question. Ensure that you are sending the correct parameters to the request by checking 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 actually exists in the spec.\n", suffix='Begin!\n\nQuestion: {input}\nThought: I should explore the spec to find the base url for the API.\n{agent_scratchpad}', format_instructions='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, 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 question', input_variables=None, max_iterations=15, max_execution_time=None, early_stopping_method='force', verbose=False, return_intermediate_steps=False, agent_executor_kwargs=None, **kwargs)[source]
Construct a json agent from an LLM and tools.
Parameters
llm (langchain.base_language.BaseLanguageModel) – 
toolkit (langchain.agents.agent_toolkits.openapi.toolkit.OpenAPIToolkit) – 
callback_manager (Optional[langchain.callbacks.base.BaseCallbackManager]) – 
prefix (str) – 
suffix (str) – 
format_instructions (str) – 
input_variables (Optional[List[str]]) – 
max_iterations (Optional[int]) – 
max_execution_time (Optional[float]) – 
early_stopping_method (str) – 
verbose (bool) – 
return_intermediate_steps (bool) – 
agent_executor_kwargs (Optional[Dict[str, Any]]) – 
kwargs (Dict[str, Any]) – 
Return type
langchain.agents.agent.AgentExecutor
langchain.agents.agent_toolkits.create_pbi_agent(llm, toolkit, powerbi=None, callback_manager=None, prefix='You are an agent designed to help users interact with a PowerBI Dataset.\n\nAgent has access to a tool that can write a query based on the question and then run those against PowerBI, Microsofts business intelligence tool. The questions from the users should be interpreted as related to the dataset that is available and not general questions about the world. If the question does not seem related to the dataset, just return "This does not appear to be part of this dataset." as the answer.\n\nGiven an input question, ask to run the questions against the dataset, then look at the results and return the answer, the answer should be a complete sentence that answers the question, if multiple rows are asked find a way to write that in a easily readable format for a human, also make sure to represent numbers in readable ways, like 1M instead of 1000000. Unless the user specifies a specific number of examples they wish to obtain, always limit your query to at most {top_k} results.\n', suffix='Begin!\n\nQuestion: {input}\nThought: I can first ask which tables I have, then how each table is defined and then ask the query tool the question I need, and finally create a nice sentence that answers the question.\n{agent_scratchpad}', format_instructions='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, 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 question', examples=None, input_variables=None, top_k=10, verbose=False, agent_executor_kwargs=None, **kwargs)[source]
Construct a pbi agent from an LLM and tools.
Parameters
llm (langchain.base_language.BaseLanguageModel) – 
toolkit (Optional[langchain.agents.agent_toolkits.powerbi.toolkit.PowerBIToolkit]) – 
powerbi (Optional[langchain.utilities.powerbi.PowerBIDataset]) – 
callback_manager (Optional[langchain.callbacks.base.BaseCallbackManager]) – 
prefix (str) – 
suffix (str) – 
format_instructions (str) – 
examples (Optional[str]) – 
input_variables (Optional[List[str]]) – 
top_k (int) – 
verbose (bool) – 
agent_executor_kwargs (Optional[Dict[str, Any]]) – 
kwargs (Dict[str, Any]) – 
Return type
langchain.agents.agent.AgentExecutor
langchain.agents.agent_toolkits.create_pbi_chat_agent(llm, toolkit, powerbi=None, callback_manager=None, output_parser=None, prefix='Assistant is a large language model built to help users interact with a PowerBI Dataset.\n\nAssistant has access to a tool that can write a query based on the question and then run those against PowerBI, Microsofts business intelligence tool. The questions from the users should be interpreted as related to the dataset that is available and not general questions about the world. If the question does not seem related to the dataset, just return "This does not appear to be part of this dataset." as the answer.\n\nGiven an input question, ask to run the questions against the dataset, then look at the results and return the answer, the answer should be a complete sentence that answers the question, if multiple rows are asked find a way to write that in a easily readable format for a human, also make sure to represent numbers in readable ways, like 1M instead of 1000000. Unless the user specifies a specific number of examples they wish to obtain, always limit your query to at most {top_k} results.\n', suffix="TOOLS\n------\nAssistant can ask the user to use tools to look up information that may be helpful in answering the users original question. The tools the human can use are:\n\n{{tools}}\n\n{format_instructions}\n\nUSER'S INPUT\n--------------------\nHere is the user's input (remember to respond with a markdown code snippet of a json blob with a single action, and NOTHING else):\n\n{{{{input}}}}\n", examples=None, input_variables=None, memory=None, top_k=10, verbose=False, agent_executor_kwargs=None, **kwargs)[source]
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.
Parameters
llm (langchain.chat_models.base.BaseChatModel) – 
toolkit (Optional[langchain.agents.agent_toolkits.powerbi.toolkit.PowerBIToolkit]) – 
powerbi (Optional[langchain.utilities.powerbi.PowerBIDataset]) – 
callback_manager (Optional[langchain.callbacks.base.BaseCallbackManager]) – 
output_parser (Optional[langchain.agents.agent.AgentOutputParser]) – 
prefix (str) – 
suffix (str) – 
examples (Optional[str]) – 
input_variables (Optional[List[str]]) – 
memory (Optional[langchain.memory.chat_memory.BaseChatMemory]) – 
top_k (int) – 
verbose (bool) – 
agent_executor_kwargs (Optional[Dict[str, Any]]) – 
kwargs (Dict[str, Any]) – 
Return type
langchain.agents.agent.AgentExecutor
langchain.agents.agent_toolkits.create_python_agent(llm, tool, agent_type=AgentType.ZERO_SHOT_REACT_DESCRIPTION, callback_manager=None, verbose=False, prefix='You are an agent designed to write and execute python code to answer questions.\nYou have access to a python REPL, which you can use to execute python code.\nIf you get an error, debug your code and try again.\nOnly use the output of your code to answer the question. \nYou might know the answer without running any code, but you should still run the code to get the answer.\nIf it does not seem like you can write code to answer the question, just return "I don\'t know" as the answer.\n', agent_executor_kwargs=None, **kwargs)[source]
Construct a python agent from an LLM and tool.
Parameters
llm (langchain.base_language.BaseLanguageModel) – 
tool (langchain.tools.python.tool.PythonREPLTool) – 
agent_type (langchain.agents.agent_types.AgentType) – 
callback_manager (Optional[langchain.callbacks.base.BaseCallbackManager]) – 
verbose (bool) – 
prefix (str) – 
agent_executor_kwargs (Optional[Dict[str, Any]]) – 
kwargs (Dict[str, Any]) – 
Return type
langchain.agents.agent.AgentExecutor
langchain.agents.agent_toolkits.create_vectorstore_agent(llm, toolkit, callback_manager=None, prefix='You are an agent designed to answer questions about sets of documents.\nYou have access to tools for interacting with the documents, and the inputs to the tools are questions.\nSometimes, you will be asked to provide sources for your questions, in which case you should use the appropriate tool to do so.\nIf the question does not seem relevant to any of the tools provided, just return "I don\'t know" as the answer.\n', verbose=False, agent_executor_kwargs=None, **kwargs)[source]
Construct a vectorstore agent from an LLM and tools.
Parameters
llm (langchain.base_language.BaseLanguageModel) – 
toolkit (langchain.agents.agent_toolkits.vectorstore.toolkit.VectorStoreToolkit) – 
callback_manager (Optional[langchain.callbacks.base.BaseCallbackManager]) – 
prefix (str) – 
verbose (bool) – 
agent_executor_kwargs (Optional[Dict[str, Any]]) – 
kwargs (Dict[str, Any]) – 
Return type
langchain.agents.agent.AgentExecutor
class langchain.agents.agent_toolkits.JsonToolkit(*, spec)[source]
Bases: langchain.agents.agent_toolkits.base.BaseToolkit
Toolkit for interacting with a JSON spec.
Parameters
spec (langchain.tools.json.tool.JsonSpec) – 
Return type
None
attribute spec: langchain.tools.json.tool.JsonSpec [Required]
get_tools()[source]
Get the tools in the toolkit.
Return type
List[langchain.tools.base.BaseTool]
class langchain.agents.agent_toolkits.SQLDatabaseToolkit(*, db, llm)[source]
Bases: langchain.agents.agent_toolkits.base.BaseToolkit
Toolkit for interacting with SQL databases.
Parameters
db (langchain.sql_database.SQLDatabase) – 
llm (langchain.base_language.BaseLanguageModel) – 
Return type
None
attribute db: langchain.sql_database.SQLDatabase [Required]
attribute llm: langchain.base_language.BaseLanguageModel [Required]
get_tools()[source]
Get the tools in the toolkit.
Return type
List[langchain.tools.base.BaseTool]
property dialect: str
Return string representation of dialect to use.
class langchain.agents.agent_toolkits.SparkSQLToolkit(*, db, llm)[source]
Bases: langchain.agents.agent_toolkits.base.BaseToolkit
Toolkit for interacting with Spark SQL.
Parameters
db (langchain.utilities.spark_sql.SparkSQL) – 
llm (langchain.base_language.BaseLanguageModel) – 
Return type
None
attribute db: langchain.utilities.spark_sql.SparkSQL [Required]
attribute llm: langchain.base_language.BaseLanguageModel [Required]
get_tools()[source]
Get the tools in the toolkit.
Return type
List[langchain.tools.base.BaseTool]
class langchain.agents.agent_toolkits.NLAToolkit(*, nla_tools)[source]
Bases: langchain.agents.agent_toolkits.base.BaseToolkit
Natural Language API Toolkit Definition.
Parameters
nla_tools (Sequence[langchain.agents.agent_toolkits.nla.tool.NLATool]) – 
Return type
None
attribute nla_tools: Sequence[langchain.agents.agent_toolkits.nla.tool.NLATool] [Required]
List of API Endpoint Tools.
classmethod from_llm_and_ai_plugin(llm, ai_plugin, requests=None, verbose=False, **kwargs)[source]
Instantiate the toolkit from an OpenAPI Spec URL
Parameters
llm (langchain.base_language.BaseLanguageModel) – 
ai_plugin (langchain.tools.plugin.AIPlugin) – 
requests (Optional[langchain.requests.Requests]) – 
verbose (bool) – 
kwargs (Any) – 
Return type
langchain.agents.agent_toolkits.nla.toolkit.NLAToolkit
classmethod from_llm_and_ai_plugin_url(llm, ai_plugin_url, requests=None, verbose=False, **kwargs)[source]
Instantiate the toolkit from an OpenAPI Spec URL
Parameters
llm (langchain.base_language.BaseLanguageModel) – 
ai_plugin_url (str) – 
requests (Optional[langchain.requests.Requests]) – 
verbose (bool) – 
kwargs (Any) – 
Return type
langchain.agents.agent_toolkits.nla.toolkit.NLAToolkit
classmethod from_llm_and_spec(llm, spec, requests=None, verbose=False, **kwargs)[source]
Instantiate the toolkit by creating tools for each operation.
Parameters
llm (langchain.base_language.BaseLanguageModel) – 
spec (langchain.utilities.openapi.OpenAPISpec) – 
requests (Optional[langchain.requests.Requests]) – 
verbose (bool) – 
kwargs (Any) – 
Return type
langchain.agents.agent_toolkits.nla.toolkit.NLAToolkit
classmethod from_llm_and_url(llm, open_api_url, requests=None, verbose=False, **kwargs)[source]
Instantiate the toolkit from an OpenAPI Spec URL
Parameters
llm (langchain.base_language.BaseLanguageModel) – 
open_api_url (str) – 
requests (Optional[langchain.requests.Requests]) – 
verbose (bool) – 
kwargs (Any) – 
Return type
langchain.agents.agent_toolkits.nla.toolkit.NLAToolkit
get_tools()[source]
Get the tools for all the API operations.
Return type
List[langchain.tools.base.BaseTool]
class langchain.agents.agent_toolkits.PowerBIToolkit(*, powerbi, llm, examples=None, max_iterations=5, callback_manager=None)[source]
Bases: langchain.agents.agent_toolkits.base.BaseToolkit
Toolkit for interacting with PowerBI dataset.
Parameters
powerbi (langchain.utilities.powerbi.PowerBIDataset) – 
llm (langchain.base_language.BaseLanguageModel) – 
examples (Optional[str]) – 
max_iterations (int) – 
callback_manager (Optional[langchain.callbacks.base.BaseCallbackManager]) – 
Return type
None
attribute callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None
attribute examples: Optional[str] = None
attribute llm: langchain.base_language.BaseLanguageModel [Required]
attribute max_iterations: int = 5
attribute powerbi: langchain.utilities.powerbi.PowerBIDataset [Required]
get_tools()[source]
Get the tools in the toolkit.
Return type
List[langchain.tools.base.BaseTool]
class langchain.agents.agent_toolkits.OpenAPIToolkit(*, json_agent, requests_wrapper)[source]
Bases: langchain.agents.agent_toolkits.base.BaseToolkit
Toolkit for interacting with a OpenAPI api.
Parameters
json_agent (langchain.agents.agent.AgentExecutor) – 
requests_wrapper (langchain.requests.TextRequestsWrapper) – 
Return type
None
attribute json_agent: langchain.agents.agent.AgentExecutor [Required]
attribute requests_wrapper: langchain.requests.TextRequestsWrapper [Required]
classmethod from_llm(llm, json_spec, requests_wrapper, **kwargs)[source]
Create json agent from llm, then initialize.
Parameters
llm (langchain.base_language.BaseLanguageModel) – 
json_spec (langchain.tools.json.tool.JsonSpec) – 
requests_wrapper (langchain.requests.TextRequestsWrapper) – 
kwargs (Any) – 
Return type
langchain.agents.agent_toolkits.openapi.toolkit.OpenAPIToolkit
get_tools()[source]
Get the tools in the toolkit.
Return type
List[langchain.tools.base.BaseTool]
class langchain.agents.agent_toolkits.VectorStoreToolkit(*, vectorstore_info, llm=None)[source]
Bases: langchain.agents.agent_toolkits.base.BaseToolkit
Toolkit for interacting with a vector store.
Parameters
vectorstore_info (langchain.agents.agent_toolkits.vectorstore.toolkit.VectorStoreInfo) – 
llm (langchain.base_language.BaseLanguageModel) – 
Return type
None
attribute llm: langchain.base_language.BaseLanguageModel [Optional]
attribute vectorstore_info: langchain.agents.agent_toolkits.vectorstore.toolkit.VectorStoreInfo [Required]
get_tools()[source]
Get the tools in the toolkit.
Return type
List[langchain.tools.base.BaseTool]
langchain.agents.agent_toolkits.create_vectorstore_router_agent(llm, toolkit, callback_manager=None, prefix='You are an agent designed to answer questions.\nYou have access to tools for interacting with different sources, and the inputs to the tools are questions.\nYour main task is to decide which of the tools is relevant for answering question at hand.\nFor complex questions, you can break the question down into sub questions and use tools to answers the sub questions.\n', verbose=False, agent_executor_kwargs=None, **kwargs)[source]
Construct a vectorstore router agent from an LLM and tools.
Parameters
llm (langchain.base_language.BaseLanguageModel) – 
toolkit (langchain.agents.agent_toolkits.vectorstore.toolkit.VectorStoreRouterToolkit) – 
callback_manager (Optional[langchain.callbacks.base.BaseCallbackManager]) – 
prefix (str) – 
verbose (bool) – 
agent_executor_kwargs (Optional[Dict[str, Any]]) – 
kwargs (Dict[str, Any]) – 
Return type
langchain.agents.agent.AgentExecutor
class langchain.agents.agent_toolkits.VectorStoreInfo(*, vectorstore, name, description)[source]
Bases: pydantic.main.BaseModel
Information about a vectorstore.
Parameters
vectorstore (langchain.vectorstores.base.VectorStore) – 
name (str) – 
description (str) – 
Return type
None
attribute description: str [Required]
attribute name: str [Required]
attribute vectorstore: langchain.vectorstores.base.VectorStore [Required]
class langchain.agents.agent_toolkits.VectorStoreRouterToolkit(*, vectorstores, llm=None)[source]
Bases: langchain.agents.agent_toolkits.base.BaseToolkit
Toolkit for routing between vector stores.
Parameters
vectorstores (List[langchain.agents.agent_toolkits.vectorstore.toolkit.VectorStoreInfo]) – 
llm (langchain.base_language.BaseLanguageModel) – 
Return type
None
attribute llm: langchain.base_language.BaseLanguageModel [Optional]
attribute vectorstores: List[langchain.agents.agent_toolkits.vectorstore.toolkit.VectorStoreInfo] [Required]
get_tools()[source]
Get the tools in the toolkit.
Return type
List[langchain.tools.base.BaseTool]
langchain.agents.agent_toolkits.create_pandas_dataframe_agent(llm, df, agent_type=AgentType.ZERO_SHOT_REACT_DESCRIPTION, callback_manager=None, prefix=None, suffix=None, input_variables=None, verbose=False, return_intermediate_steps=False, max_iterations=15, max_execution_time=None, early_stopping_method='force', agent_executor_kwargs=None, include_df_in_prompt=True, **kwargs)[source]
Construct a pandas agent from an LLM and dataframe.
Parameters
llm (langchain.base_language.BaseLanguageModel) – 
df (Any) – 
agent_type (langchain.agents.agent_types.AgentType) – 
callback_manager (Optional[langchain.callbacks.base.BaseCallbackManager]) – 
prefix (Optional[str]) – 
suffix (Optional[str]) – 
input_variables (Optional[List[str]]) – 
verbose (bool) – 
return_intermediate_steps (bool) – 
max_iterations (Optional[int]) – 
max_execution_time (Optional[float]) – 
early_stopping_method (str) – 
agent_executor_kwargs (Optional[Dict[str, Any]]) – 
include_df_in_prompt (Optional[bool]) – 
kwargs (Dict[str, Any]) – 
Return type
langchain.agents.agent.AgentExecutor
langchain.agents.agent_toolkits.create_spark_dataframe_agent(llm, df, callback_manager=None, prefix='\nYou are working with a spark dataframe in Python. The name of the dataframe is `df`.\nYou should use the tools below to answer the question posed of you:', suffix='\nThis is the result of `print(df.first())`:\n{df}\n\nBegin!\nQuestion: {input}\n{agent_scratchpad}', input_variables=None, verbose=False, return_intermediate_steps=False, max_iterations=15, max_execution_time=None, early_stopping_method='force', agent_executor_kwargs=None, **kwargs)[source]
Construct a spark agent from an LLM and dataframe.
Parameters
llm (langchain.llms.base.BaseLLM) – 
df (Any) – 
callback_manager (Optional[langchain.callbacks.base.BaseCallbackManager]) – 
prefix (str) – 
suffix (str) – 
input_variables (Optional[List[str]]) – 
verbose (bool) – 
return_intermediate_steps (bool) – 
max_iterations (Optional[int]) – 
max_execution_time (Optional[float]) – 
early_stopping_method (str) – 
agent_executor_kwargs (Optional[Dict[str, Any]]) – 
kwargs (Dict[str, Any]) – 
Return type
langchain.agents.agent.AgentExecutor
langchain.agents.agent_toolkits.create_spark_sql_agent(llm, toolkit, callback_manager=None, prefix='You are an agent designed to interact with Spark SQL.\nGiven an input question, create a syntactically correct Spark SQL query to run, then look at the results of the query and return the answer.\nUnless the user specifies a specific number of examples they wish to obtain, always limit your query to at most {top_k} results.\nYou can order the results by a relevant column to return the most interesting examples in the database.\nNever query for all the columns from a specific table, only ask for the relevant columns given the question.\nYou have access to tools for interacting with the database.\nOnly use the below tools. Only use the information returned by the below tools to construct your final answer.\nYou MUST double check your query before executing it. If you get an error while executing a query, 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='Begin!\n\nQuestion: {input}\nThought: I should look at the tables in the database to see what I can query.\n{agent_scratchpad}', format_instructions='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, 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 question', input_variables=None, top_k=10, max_iterations=15, max_execution_time=None, early_stopping_method='force', verbose=False, agent_executor_kwargs=None, **kwargs)[source]
Construct a sql agent from an LLM and tools.
Parameters
llm (langchain.base_language.BaseLanguageModel) – 
toolkit (langchain.agents.agent_toolkits.spark_sql.toolkit.SparkSQLToolkit) – 
callback_manager (Optional[langchain.callbacks.base.BaseCallbackManager]) – 
prefix (str) – 
suffix (str) – 
format_instructions (str) – 
input_variables (Optional[List[str]]) – 
top_k (int) – 
max_iterations (Optional[int]) – 
max_execution_time (Optional[float]) – 
early_stopping_method (str) – 
verbose (bool) – 
agent_executor_kwargs (Optional[Dict[str, Any]]) – 
kwargs (Dict[str, Any]) – 
Return type
langchain.agents.agent.AgentExecutor
langchain.agents.agent_toolkits.create_csv_agent(llm, path, pandas_kwargs=None, **kwargs)[source]
Create csv agent by loading to a dataframe and using pandas agent.
Parameters
llm (langchain.base_language.BaseLanguageModel) – 
path (Union[str, List[str]]) – 
pandas_kwargs (Optional[dict]) – 
kwargs (Any) – 
Return type
langchain.agents.agent.AgentExecutor
class langchain.agents.agent_toolkits.ZapierToolkit(*, tools=[])[source]
Bases: langchain.agents.agent_toolkits.base.BaseToolkit
Zapier Toolkit.
Parameters
tools (List[langchain.tools.base.BaseTool]) – 
Return type
None
attribute tools: List[langchain.tools.base.BaseTool] = []
classmethod from_zapier_nla_wrapper(zapier_nla_wrapper)[source]
Create a toolkit from a ZapierNLAWrapper.
Parameters
zapier_nla_wrapper (langchain.utilities.zapier.ZapierNLAWrapper) – 
Return type
langchain.agents.agent_toolkits.zapier.toolkit.ZapierToolkit
get_tools()[source]
Get the tools in the toolkit.
Return type
List[langchain.tools.base.BaseTool]
class langchain.agents.agent_toolkits.GmailToolkit(*, api_resource=None)[source]
Bases: langchain.agents.agent_toolkits.base.BaseToolkit
Toolkit for interacting with Gmail.
Parameters
api_resource (Resource) – 
Return type
None
attribute api_resource: Resource [Optional]
get_tools()[source]
Get the tools in the toolkit.
Return type
List[langchain.tools.base.BaseTool]
class langchain.agents.agent_toolkits.JiraToolkit(*, tools=[])[source]
Bases: langchain.agents.agent_toolkits.base.BaseToolkit
Jira Toolkit.
Parameters
tools (List[langchain.tools.base.BaseTool]) – 
Return type
None
attribute tools: List[langchain.tools.base.BaseTool] = []
classmethod from_jira_api_wrapper(jira_api_wrapper)[source]
Parameters
jira_api_wrapper (langchain.utilities.jira.JiraAPIWrapper) – 
Return type
langchain.agents.agent_toolkits.jira.toolkit.JiraToolkit
get_tools()[source]
Get the tools in the toolkit.
Return type
List[langchain.tools.base.BaseTool]
class langchain.agents.agent_toolkits.FileManagementToolkit(*, root_dir=None, selected_tools=None)[source]
Bases: langchain.agents.agent_toolkits.base.BaseToolkit
Toolkit for interacting with a Local Files.
Parameters
root_dir (Optional[str]) – 
selected_tools (Optional[List[str]]) – 
Return type
None
attribute root_dir: Optional[str] = None
If specified, all file operations are made relative to root_dir.
attribute selected_tools: Optional[List[str]] = None
If provided, only provide the selected tools. Defaults to all.
get_tools()[source]
Get the tools in the toolkit.
Return type
List[langchain.tools.base.BaseTool]
class langchain.agents.agent_toolkits.PlayWrightBrowserToolkit(*, sync_browser=None, async_browser=None)[source]
Bases: langchain.agents.agent_toolkits.base.BaseToolkit
Toolkit for web browser tools.
Parameters
sync_browser (Optional['SyncBrowser']) – 
async_browser (Optional['AsyncBrowser']) – 
Return type
None
attribute async_browser: Optional['AsyncBrowser'] = None
attribute sync_browser: Optional['SyncBrowser'] = None
classmethod from_browser(sync_browser=None, async_browser=None)[source]
Instantiate the toolkit.
Parameters
sync_browser (Optional[SyncBrowser]) – 
async_browser (Optional[AsyncBrowser]) – 
Return type
PlayWrightBrowserToolkit
get_tools()[source]
Get the tools in the toolkit.
Return type
List[langchain.tools.base.BaseTool]
class langchain.agents.agent_toolkits.AzureCognitiveServicesToolkit[source]
Bases: langchain.agents.agent_toolkits.base.BaseToolkit
Toolkit for Azure Cognitive Services.
Return type
None
get_tools()[source]
Get the tools in the toolkit.
Return type
List[langchain.tools.base.BaseTool]