id
stringlengths
14
15
text
stringlengths
35
2.51k
source
stringlengths
61
154
da024386350d-0
langchain.agents.load_tools.load_huggingface_tool¶ langchain.agents.load_tools.load_huggingface_tool(task_or_repo_id: str, model_repo_id: Optional[str] = None, token: Optional[str] = None, remote: bool = False, **kwargs: Any) → BaseTool[source]¶ Loads a tool from the HuggingFace Hub. Parameters task_or_repo_id – Task or model repo id. model_repo_id – Optional model repo id. token – Optional token. remote – Optional remote. Defaults to False. **kwargs – Returns A tool.
https://api.python.langchain.com/en/latest/agents/langchain.agents.load_tools.load_huggingface_tool.html
c4012aa76216-0
langchain.agents.agent_types.AgentType¶ class langchain.agents.agent_types.AgentType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶ Bases: str, Enum Enumerator with the Agent types. Methods __init__(*args, **kwds) capitalize() Return a capitalized version of the string. casefold() Return a version of the string suitable for caseless comparisons. center(width[, fillchar]) Return a centered string of length width. count(sub[, start[, end]]) Return the number of non-overlapping occurrences of substring sub in string S[start:end]. encode([encoding, errors]) Encode the string using the codec registered for encoding. endswith(suffix[, start[, end]]) Return True if S ends with the specified suffix, False otherwise. expandtabs([tabsize]) Return a copy where all tab characters are expanded using spaces. find(sub[, start[, end]]) Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. format(*args, **kwargs) Return a formatted version of S, using substitutions from args and kwargs. format_map(mapping) Return a formatted version of S, using substitutions from mapping. index(sub[, start[, end]]) Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. isalnum() Return True if the string is an alpha-numeric string, False otherwise. isalpha() Return True if the string is an alphabetic string, False otherwise. isascii() Return True if all characters in the string are ASCII, False otherwise. isdecimal() Return True if the string is a decimal string, False otherwise. isdigit()
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_types.AgentType.html
c4012aa76216-1
Return True if the string is a decimal string, False otherwise. isdigit() Return True if the string is a digit string, False otherwise. isidentifier() Return True if the string is a valid Python identifier, False otherwise. islower() Return True if the string is a lowercase string, False otherwise. isnumeric() Return True if the string is a numeric string, False otherwise. isprintable() Return True if the string is printable, False otherwise. isspace() Return True if the string is a whitespace string, False otherwise. istitle() Return True if the string is a title-cased string, False otherwise. isupper() Return True if the string is an uppercase string, False otherwise. join(iterable, /) Concatenate any number of strings. ljust(width[, fillchar]) Return a left-justified string of length width. lower() Return a copy of the string converted to lowercase. lstrip([chars]) Return a copy of the string with leading whitespace removed. maketrans Return a translation table usable for str.translate(). partition(sep, /) Partition the string into three parts using the given separator. removeprefix(prefix, /) Return a str with the given prefix string removed if present. removesuffix(suffix, /) Return a str with the given suffix string removed if present. replace(old, new[, count]) Return a copy with all occurrences of substring old replaced by new. rfind(sub[, start[, end]]) Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. rindex(sub[, start[, end]]) Return the highest index in S where substring sub is found, such that sub is contained within S[start:end].
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_types.AgentType.html
c4012aa76216-2
rjust(width[, fillchar]) Return a right-justified string of length width. rpartition(sep, /) Partition the string into three parts using the given separator. rsplit([sep, maxsplit]) Return a list of the substrings in the string, using sep as the separator string. rstrip([chars]) Return a copy of the string with trailing whitespace removed. split([sep, maxsplit]) Return a list of the substrings in the string, using sep as the separator string. splitlines([keepends]) Return a list of the lines in the string, breaking at line boundaries. startswith(prefix[, start[, end]]) Return True if S starts with the specified prefix, False otherwise. strip([chars]) Return a copy of the string with leading and trailing whitespace removed. swapcase() Convert uppercase characters to lowercase and lowercase characters to uppercase. title() Return a version of the string where each word is titlecased. translate(table, /) Replace each character in the string using the given translation table. upper() Return a copy of the string converted to uppercase. zfill(width, /) Pad a numeric string with zeros on the left, to fill a field of the given width. Attributes ZERO_SHOT_REACT_DESCRIPTION REACT_DOCSTORE SELF_ASK_WITH_SEARCH CONVERSATIONAL_REACT_DESCRIPTION CHAT_ZERO_SHOT_REACT_DESCRIPTION CHAT_CONVERSATIONAL_REACT_DESCRIPTION STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION OPENAI_FUNCTIONS OPENAI_MULTI_FUNCTIONS capitalize()¶ Return a capitalized version of the string. More specifically, make the first character have upper case and the rest lower case. casefold()¶ Return a version of the string suitable for caseless comparisons. center(width, fillchar=' ', /)¶
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_types.AgentType.html
c4012aa76216-3
center(width, fillchar=' ', /)¶ Return a centered string of length width. Padding is done using the specified fill character (default is a space). count(sub[, start[, end]]) → int¶ Return the number of non-overlapping occurrences of substring sub in string S[start:end]. Optional arguments start and end are interpreted as in slice notation. encode(encoding='utf-8', errors='strict')¶ Encode the string using the codec registered for encoding. encodingThe encoding in which to encode the string. errorsThe error handling scheme to use for encoding errors. The default is ‘strict’ meaning that encoding errors raise a UnicodeEncodeError. Other possible values are ‘ignore’, ‘replace’ and ‘xmlcharrefreplace’ as well as any other name registered with codecs.register_error that can handle UnicodeEncodeErrors. endswith(suffix[, start[, end]]) → bool¶ Return True if S ends with the specified suffix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. suffix can also be a tuple of strings to try. expandtabs(tabsize=8)¶ Return a copy where all tab characters are expanded using spaces. If tabsize is not given, a tab size of 8 characters is assumed. find(sub[, start[, end]]) → int¶ Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation. Return -1 on failure. format(*args, **kwargs) → str¶ Return a formatted version of S, using substitutions from args and kwargs. The substitutions are identified by braces (‘{’ and ‘}’). format_map(mapping) → str¶
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_types.AgentType.html
c4012aa76216-4
format_map(mapping) → str¶ Return a formatted version of S, using substitutions from mapping. The substitutions are identified by braces (‘{’ and ‘}’). index(sub[, start[, end]]) → int¶ Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation. Raises ValueError when the substring is not found. isalnum()¶ Return True if the string is an alpha-numeric string, False otherwise. A string is alpha-numeric if all characters in the string are alpha-numeric and there is at least one character in the string. isalpha()¶ Return True if the string is an alphabetic string, False otherwise. A string is alphabetic if all characters in the string are alphabetic and there is at least one character in the string. isascii()¶ Return True if all characters in the string are ASCII, False otherwise. ASCII characters have code points in the range U+0000-U+007F. Empty string is ASCII too. isdecimal()¶ Return True if the string is a decimal string, False otherwise. A string is a decimal string if all characters in the string are decimal and there is at least one character in the string. isdigit()¶ Return True if the string is a digit string, False otherwise. A string is a digit string if all characters in the string are digits and there is at least one character in the string. isidentifier()¶ Return True if the string is a valid Python identifier, False otherwise. Call keyword.iskeyword(s) to test whether string s is a reserved identifier, such as “def” or “class”. islower()¶ Return True if the string is a lowercase string, False otherwise.
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_types.AgentType.html
c4012aa76216-5
islower()¶ Return True if the string is a lowercase string, False otherwise. A string is lowercase if all cased characters in the string are lowercase and there is at least one cased character in the string. isnumeric()¶ Return True if the string is a numeric string, False otherwise. A string is numeric if all characters in the string are numeric and there is at least one character in the string. isprintable()¶ Return True if the string is printable, False otherwise. A string is printable if all of its characters are considered printable in repr() or if it is empty. isspace()¶ Return True if the string is a whitespace string, False otherwise. A string is whitespace if all characters in the string are whitespace and there is at least one character in the string. istitle()¶ Return True if the string is a title-cased string, False otherwise. In a title-cased string, upper- and title-case characters may only follow uncased characters and lowercase characters only cased ones. isupper()¶ Return True if the string is an uppercase string, False otherwise. A string is uppercase if all cased characters in the string are uppercase and there is at least one cased character in the string. join(iterable, /)¶ Concatenate any number of strings. The string whose method is called is inserted in between each given string. The result is returned as a new string. Example: ‘.’.join([‘ab’, ‘pq’, ‘rs’]) -> ‘ab.pq.rs’ ljust(width, fillchar=' ', /)¶ Return a left-justified string of length width. Padding is done using the specified fill character (default is a space). lower()¶ Return a copy of the string converted to lowercase.
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_types.AgentType.html
c4012aa76216-6
lower()¶ Return a copy of the string converted to lowercase. lstrip(chars=None, /)¶ Return a copy of the string with leading whitespace removed. If chars is given and not None, remove characters in chars instead. static maketrans()¶ Return a translation table usable for str.translate(). If there is only one argument, it must be a dictionary mapping Unicode ordinals (integers) or characters to Unicode ordinals, strings or None. Character keys will be then converted to ordinals. If there are two arguments, they must be strings of equal length, and in the resulting dictionary, each character in x will be mapped to the character at the same position in y. If there is a third argument, it must be a string, whose characters will be mapped to None in the result. partition(sep, /)¶ Partition the string into three parts using the given separator. This will search for the separator in the string. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it. If the separator is not found, returns a 3-tuple containing the original string and two empty strings. removeprefix(prefix, /)¶ Return a str with the given prefix string removed if present. If the string starts with the prefix string, return string[len(prefix):]. Otherwise, return a copy of the original string. removesuffix(suffix, /)¶ Return a str with the given suffix string removed if present. If the string ends with the suffix string and that suffix is not empty, return string[:-len(suffix)]. Otherwise, return a copy of the original string. replace(old, new, count=- 1, /)¶ Return a copy with all occurrences of substring old replaced by new.
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_types.AgentType.html
c4012aa76216-7
Return a copy with all occurrences of substring old replaced by new. countMaximum number of occurrences to replace. -1 (the default value) means replace all occurrences. If the optional argument count is given, only the first count occurrences are replaced. rfind(sub[, start[, end]]) → int¶ Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation. Return -1 on failure. rindex(sub[, start[, end]]) → int¶ Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation. Raises ValueError when the substring is not found. rjust(width, fillchar=' ', /)¶ Return a right-justified string of length width. Padding is done using the specified fill character (default is a space). rpartition(sep, /)¶ Partition the string into three parts using the given separator. This will search for the separator in the string, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it. If the separator is not found, returns a 3-tuple containing two empty strings and the original string. rsplit(sep=None, maxsplit=- 1)¶ Return a list of the substrings in the string, using sep as the separator string. sepThe separator used to split the string. When set to None (the default value), will split on any whitespace character (including \n \r \t \f and spaces) and will discard empty strings from the result. maxsplitMaximum number of splits (starting from the left).
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_types.AgentType.html
c4012aa76216-8
empty strings from the result. maxsplitMaximum number of splits (starting from the left). -1 (the default value) means no limit. Splitting starts at the end of the string and works to the front. rstrip(chars=None, /)¶ Return a copy of the string with trailing whitespace removed. If chars is given and not None, remove characters in chars instead. split(sep=None, maxsplit=- 1)¶ Return a list of the substrings in the string, using sep as the separator string. sepThe separator used to split the string. When set to None (the default value), will split on any whitespace character (including \n \r \t \f and spaces) and will discard empty strings from the result. maxsplitMaximum number of splits (starting from the left). -1 (the default value) means no limit. Note, str.split() is mainly useful for data that has been intentionally delimited. With natural text that includes punctuation, consider using the regular expression module. splitlines(keepends=False)¶ Return a list of the lines in the string, breaking at line boundaries. Line breaks are not included in the resulting list unless keepends is given and true. startswith(prefix[, start[, end]]) → bool¶ Return True if S starts with the specified prefix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. prefix can also be a tuple of strings to try. strip(chars=None, /)¶ Return a copy of the string with leading and trailing whitespace removed. If chars is given and not None, remove characters in chars instead. swapcase()¶ Convert uppercase characters to lowercase and lowercase characters to uppercase. title()¶
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_types.AgentType.html
c4012aa76216-9
Convert uppercase characters to lowercase and lowercase characters to uppercase. title()¶ Return a version of the string where each word is titlecased. More specifically, words start with uppercased characters and all remaining cased characters have lower case. translate(table, /)¶ Replace each character in the string using the given translation table. tableTranslation table, which must be a mapping of Unicode ordinals to Unicode ordinals, strings, or None. The table must implement lookup/indexing via __getitem__, for instance a dictionary or list. If this operation raises LookupError, the character is left untouched. Characters mapped to None are deleted. upper()¶ Return a copy of the string converted to uppercase. zfill(width, /)¶ Pad a numeric string with zeros on the left, to fill a field of the given width. The string is never truncated. CHAT_CONVERSATIONAL_REACT_DESCRIPTION = 'chat-conversational-react-description'¶ CHAT_ZERO_SHOT_REACT_DESCRIPTION = 'chat-zero-shot-react-description'¶ CONVERSATIONAL_REACT_DESCRIPTION = 'conversational-react-description'¶ OPENAI_FUNCTIONS = 'openai-functions'¶ OPENAI_MULTI_FUNCTIONS = 'openai-multi-functions'¶ REACT_DOCSTORE = 'react-docstore'¶ SELF_ASK_WITH_SEARCH = 'self-ask-with-search'¶ STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION = 'structured-chat-zero-shot-react-description'¶ ZERO_SHOT_REACT_DESCRIPTION = 'zero-shot-react-description'¶
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_types.AgentType.html
b96e0a8491c7-0
langchain.agents.agent_toolkits.openapi.planner.RequestsDeleteToolWithParsing¶ class langchain.agents.agent_toolkits.openapi.planner.RequestsDeleteToolWithParsing(*, name: str = 'requests_delete', description: str = 'ONLY USE THIS TOOL WHEN THE USER HAS SPECIFICALLY REQUESTED TO DELETE CONTENT FROM A WEBSITE.\nInput to the tool should be a json string with 2 keys: "url", and "output_instructions".\nThe value of "url" should be a string.\nThe value of "output_instructions" should be instructions on what information to extract from the response, for example the id(s) for a resource(s) that the DELETE request creates.\nAlways use double quotes for strings in the json string.\nONLY USE THIS TOOL IF THE USER HAS SPECIFICALLY REQUESTED TO DELETE SOMETHING.', args_schema: Optional[Type[BaseModel]] = None, return_direct: bool = False, verbose: bool = False, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, callback_manager: Optional[BaseCallbackManager] = None, handle_tool_error: Optional[Union[bool, str, Callable[[ToolException], str]]] = False, requests_wrapper: TextRequestsWrapper, response_length: Optional[int] = 5000, llm_chain: LLMChain = None)[source]¶ Bases: BaseRequestsTool, BaseTool Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input data cannot be parsed to form a valid model. param args_schema: Optional[Type[BaseModel]] = None¶ Pydantic model class to validate and parse the tool’s input arguments. param callback_manager: Optional[BaseCallbackManager] = None¶ Deprecated. Please use callbacks instead. param callbacks: Callbacks = None¶ Callbacks to be called during tool execution.
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_toolkits.openapi.planner.RequestsDeleteToolWithParsing.html
b96e0a8491c7-1
param callbacks: Callbacks = None¶ Callbacks to be called during tool execution. param description: str = 'ONLY USE THIS TOOL WHEN THE USER HAS SPECIFICALLY REQUESTED TO DELETE CONTENT FROM A WEBSITE.\nInput to the tool should be a json string with 2 keys: "url", and "output_instructions".\nThe value of "url" should be a string.\nThe value of "output_instructions" should be instructions on what information to extract from the response, for example the id(s) for a resource(s) that the DELETE request creates.\nAlways use double quotes for strings in the json string.\nONLY USE THIS TOOL IF THE USER HAS SPECIFICALLY REQUESTED TO DELETE SOMETHING.'¶ Used to tell the model how/when/why to use the tool. You can provide few-shot examples as a part of the description. param handle_tool_error: Optional[Union[bool, str, Callable[[ToolException], str]]] = False¶ Handle the content of the ToolException thrown. param llm_chain: langchain.chains.llm.LLMChain [Optional]¶ param name: str = 'requests_delete'¶ The unique name of the tool that clearly communicates its purpose. param requests_wrapper: TextRequestsWrapper [Required]¶ param response_length: Optional[int] = 5000¶ param return_direct: bool = False¶ Whether to return the tool’s output directly. Setting this to True means that after the tool is called, the AgentExecutor will stop looping. param verbose: bool = False¶ Whether to log the tool’s progress. __call__(tool_input: str, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None) → str¶ Make tool callable.
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_toolkits.openapi.planner.RequestsDeleteToolWithParsing.html
b96e0a8491c7-2
Make tool callable. async arun(tool_input: Union[str, Dict], verbose: Optional[bool] = None, start_color: Optional[str] = 'green', color: Optional[str] = 'green', callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, **kwargs: Any) → Any¶ Run the tool asynchronously. validator raise_deprecation  »  all fields¶ Raise deprecation warning if callback_manager is used. run(tool_input: Union[str, Dict], verbose: Optional[bool] = None, start_color: Optional[str] = 'green', color: Optional[str] = 'green', callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, **kwargs: Any) → Any¶ Run the tool. property args: dict¶ property is_single_input: bool¶ Whether the tool only accepts a single input. model Config¶ Bases: object Configuration for this pydantic object. arbitrary_types_allowed = True¶ extra = 'forbid'¶
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_toolkits.openapi.planner.RequestsDeleteToolWithParsing.html
e38045a85a11-0
langchain.agents.mrkl.output_parser.MRKLOutputParser¶ class langchain.agents.mrkl.output_parser.MRKLOutputParser[source]¶ Bases: AgentOutputParser Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input data cannot be parsed to form a valid model. dict(**kwargs: Any) → Dict¶ Return dictionary representation of output parser. get_format_instructions() → str[source]¶ Instructions on how the LLM output should be formatted. parse(text: str) → Union[AgentAction, AgentFinish][source]¶ Parse text into agent action/finish. parse_result(result: List[Generation]) → T¶ Parse LLM Result. parse_with_prompt(completion: str, prompt: PromptValue) → Any¶ Optional method to parse the output of an LLM call with a prompt. The prompt is largely provided in the event the OutputParser wants to retry or fix the output in some way, and needs information from the prompt to do so. Parameters completion – output of language model prompt – prompt value Returns structured output to_json() → Union[SerializedConstructor, SerializedNotImplemented]¶ to_json_not_implemented() → SerializedNotImplemented¶ property lc_attributes: Dict¶ Return a list of attribute names that should be included in the serialized kwargs. These attributes must be accepted by the constructor. property lc_namespace: List[str]¶ Return the namespace of the langchain object. eg. [“langchain”, “llms”, “openai”] property lc_secrets: Dict[str, str]¶ Return a map of constructor argument names to secret ids. eg. {“openai_api_key”: “OPENAI_API_KEY”} property lc_serializable: bool¶
https://api.python.langchain.com/en/latest/agents/langchain.agents.mrkl.output_parser.MRKLOutputParser.html
e38045a85a11-1
property lc_serializable: bool¶ Return whether or not the class is serializable. model Config¶ Bases: object extra = 'ignore'¶
https://api.python.langchain.com/en/latest/agents/langchain.agents.mrkl.output_parser.MRKLOutputParser.html
0fd2cd68ba92-0
langchain.agents.openai_functions_multi_agent.base.OpenAIMultiFunctionsAgent¶ class langchain.agents.openai_functions_multi_agent.base.OpenAIMultiFunctionsAgent(*, llm: BaseLanguageModel, tools: Sequence[BaseTool], prompt: BasePromptTemplate)[source]¶ Bases: BaseMultiActionAgent An Agent driven by OpenAIs function powered API. Parameters llm – This should be an instance of ChatOpenAI, specifically a model that supports using functions. tools – The tools this agent has access to. prompt – The prompt for this agent, should support agent_scratchpad as one of the variables. For an easy way to construct this prompt, use OpenAIFunctionsAgent.create_prompt(…) Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input data cannot be parsed to form a valid model. param llm: langchain.base_language.BaseLanguageModel [Required]¶ param prompt: langchain.prompts.base.BasePromptTemplate [Required]¶ param tools: Sequence[langchain.tools.base.BaseTool] [Required]¶ async aplan(intermediate_steps: List[Tuple[AgentAction, str]], callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, **kwargs: Any) → Union[List[AgentAction], AgentFinish][source]¶ 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. classmethod create_prompt(system_message: Optional[SystemMessage] = SystemMessage(content='You are a helpful AI assistant.', additional_kwargs={}), extra_prompt_messages: Optional[List[BaseMessagePromptTemplate]] = None) → BasePromptTemplate[source]¶ Create prompt for this agent. Parameters
https://api.python.langchain.com/en/latest/agents/langchain.agents.openai_functions_multi_agent.base.OpenAIMultiFunctionsAgent.html
0fd2cd68ba92-1
Create prompt for this agent. Parameters system_message – Message to use as the system message that will be the first in the prompt. extra_prompt_messages – Prompt messages that will be placed between the system message and the new human input. Returns A prompt template to pass into this agent. dict(**kwargs: Any) → Dict¶ Return dictionary representation of agent. classmethod from_llm_and_tools(llm: BaseLanguageModel, tools: Sequence[BaseTool], callback_manager: Optional[BaseCallbackManager] = None, extra_prompt_messages: Optional[List[BaseMessagePromptTemplate]] = None, system_message: Optional[SystemMessage] = SystemMessage(content='You are a helpful AI assistant.', additional_kwargs={}), **kwargs: Any) → BaseMultiActionAgent[source]¶ Construct an agent from an LLM and tools. get_allowed_tools() → List[str][source]¶ Get allowed tools. plan(intermediate_steps: List[Tuple[AgentAction, str]], callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, **kwargs: Any) → Union[List[AgentAction], AgentFinish][source]¶ 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. return_stopped_response(early_stopping_method: str, intermediate_steps: List[Tuple[AgentAction, str]], **kwargs: Any) → AgentFinish¶ Return response when agent has been stopped due to max iterations. save(file_path: Union[Path, str]) → None¶ 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”)
https://api.python.langchain.com/en/latest/agents/langchain.agents.openai_functions_multi_agent.base.OpenAIMultiFunctionsAgent.html
0fd2cd68ba92-2
# If working with agent executor agent.agent.save(file_path=”path/agent.yaml”) tool_run_logging_kwargs() → Dict¶ validator validate_llm  »  all fields[source]¶ validator validate_prompt  »  all fields[source]¶ property functions: List[dict]¶ property input_keys: List[str]¶ Get input keys. Input refers to user input here. property return_values: List[str]¶ Return values of the agent.
https://api.python.langchain.com/en/latest/agents/langchain.agents.openai_functions_multi_agent.base.OpenAIMultiFunctionsAgent.html
16ae84f9a807-0
langchain.agents.agent_toolkits.nla.tool.NLATool¶ class langchain.agents.agent_toolkits.nla.tool.NLATool(name: str, func: Callable, description: str, *, args_schema: Optional[Type[BaseModel]] = None, return_direct: bool = False, verbose: bool = False, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, callback_manager: Optional[BaseCallbackManager] = None, handle_tool_error: Optional[Union[bool, str, Callable[[ToolException], str]]] = False, coroutine: Optional[Callable[[...], Awaitable[str]]] = None)[source]¶ Bases: Tool Natural Language API Tool. Initialize tool. param args_schema: Optional[Type[BaseModel]] = None¶ Pydantic model class to validate and parse the tool’s input arguments. param callback_manager: Optional[BaseCallbackManager] = None¶ Deprecated. Please use callbacks instead. param callbacks: Callbacks = None¶ Callbacks to be called during tool execution. param coroutine: Optional[Callable[..., Awaitable[str]]] = None¶ The asynchronous version of the function. param description: str = ''¶ Used to tell the model how/when/why to use the tool. You can provide few-shot examples as a part of the description. param func: Callable[..., str] [Required]¶ The function to run when the tool is called. param handle_tool_error: Optional[Union[bool, str, Callable[[ToolException], str]]] = False¶ Handle the content of the ToolException thrown. param name: str [Required]¶ The unique name of the tool that clearly communicates its purpose. param return_direct: bool = False¶ Whether to return the tool’s output directly. Setting this to True means
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_toolkits.nla.tool.NLATool.html
16ae84f9a807-1
Whether to return the tool’s output directly. Setting this to True means that after the tool is called, the AgentExecutor will stop looping. param verbose: bool = False¶ Whether to log the tool’s progress. __call__(tool_input: str, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None) → str¶ Make tool callable. async arun(tool_input: Union[str, Dict], verbose: Optional[bool] = None, start_color: Optional[str] = 'green', color: Optional[str] = 'green', callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, **kwargs: Any) → Any¶ Run the tool asynchronously. classmethod from_function(func: Callable, name: str, description: str, return_direct: bool = False, args_schema: Optional[Type[BaseModel]] = None, **kwargs: Any) → Tool¶ Initialize tool from a function. classmethod from_llm_and_method(llm: BaseLanguageModel, path: str, method: str, spec: OpenAPISpec, requests: Optional[Requests] = None, verbose: bool = False, return_intermediate_steps: bool = False, **kwargs: Any) → NLATool[source]¶ Instantiate the tool from the specified path and method. classmethod from_open_api_endpoint_chain(chain: OpenAPIEndpointChain, api_title: str) → NLATool[source]¶ Convert an endpoint chain to an API endpoint tool. validator raise_deprecation  »  all fields¶ Raise deprecation warning if callback_manager is used.
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_toolkits.nla.tool.NLATool.html
16ae84f9a807-2
Raise deprecation warning if callback_manager is used. run(tool_input: Union[str, Dict], verbose: Optional[bool] = None, start_color: Optional[str] = 'green', color: Optional[str] = 'green', callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, **kwargs: Any) → Any¶ Run the tool. property args: dict¶ The tool’s input arguments. property is_single_input: bool¶ Whether the tool only accepts a single input. model Config¶ Bases: object Configuration for this pydantic object. arbitrary_types_allowed = True¶ extra = 'forbid'¶
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_toolkits.nla.tool.NLATool.html
2b8bd42f6847-0
langchain.agents.openai_functions_agent.base.OpenAIFunctionsAgent¶ class langchain.agents.openai_functions_agent.base.OpenAIFunctionsAgent(*, llm: BaseLanguageModel, tools: Sequence[BaseTool], prompt: BasePromptTemplate)[source]¶ Bases: BaseSingleActionAgent An Agent driven by OpenAIs function powered API. Parameters llm – This should be an instance of ChatOpenAI, specifically a model that supports using functions. tools – The tools this agent has access to. prompt – The prompt for this agent, should support agent_scratchpad as one of the variables. For an easy way to construct this prompt, use OpenAIFunctionsAgent.create_prompt(…) Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input data cannot be parsed to form a valid model. param llm: langchain.base_language.BaseLanguageModel [Required]¶ param prompt: langchain.prompts.base.BasePromptTemplate [Required]¶ param tools: Sequence[langchain.tools.base.BaseTool] [Required]¶ async aplan(intermediate_steps: List[Tuple[AgentAction, str]], callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, **kwargs: Any) → Union[AgentAction, AgentFinish][source]¶ 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. classmethod create_prompt(system_message: Optional[SystemMessage] = SystemMessage(content='You are a helpful AI assistant.', additional_kwargs={}), extra_prompt_messages: Optional[List[BaseMessagePromptTemplate]] = None) → BasePromptTemplate[source]¶ Create prompt for this agent. Parameters
https://api.python.langchain.com/en/latest/agents/langchain.agents.openai_functions_agent.base.OpenAIFunctionsAgent.html
2b8bd42f6847-1
Create prompt for this agent. Parameters system_message – Message to use as the system message that will be the first in the prompt. extra_prompt_messages – Prompt messages that will be placed between the system message and the new human input. Returns A prompt template to pass into this agent. dict(**kwargs: Any) → Dict¶ Return dictionary representation of agent. classmethod from_llm_and_tools(llm: BaseLanguageModel, tools: Sequence[BaseTool], callback_manager: Optional[BaseCallbackManager] = None, extra_prompt_messages: Optional[List[BaseMessagePromptTemplate]] = None, system_message: Optional[SystemMessage] = SystemMessage(content='You are a helpful AI assistant.', additional_kwargs={}), **kwargs: Any) → BaseSingleActionAgent[source]¶ Construct an agent from an LLM and tools. get_allowed_tools() → List[str][source]¶ Get allowed tools. plan(intermediate_steps: List[Tuple[AgentAction, str]], callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, **kwargs: Any) → Union[AgentAction, AgentFinish][source]¶ 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. return_stopped_response(early_stopping_method: str, intermediate_steps: List[Tuple[AgentAction, str]], **kwargs: Any) → AgentFinish¶ Return response when agent has been stopped due to max iterations. save(file_path: Union[Path, str]) → None¶ 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”)
https://api.python.langchain.com/en/latest/agents/langchain.agents.openai_functions_agent.base.OpenAIFunctionsAgent.html
2b8bd42f6847-2
# If working with agent executor agent.agent.save(file_path=”path/agent.yaml”) tool_run_logging_kwargs() → Dict¶ validator validate_llm  »  all fields[source]¶ validator validate_prompt  »  all fields[source]¶ property functions: List[dict]¶ property input_keys: List[str]¶ Get input keys. Input refers to user input here. property return_values: List[str]¶ Return values of the agent.
https://api.python.langchain.com/en/latest/agents/langchain.agents.openai_functions_agent.base.OpenAIFunctionsAgent.html
e0cc51bf1e05-0
langchain.agents.agent_toolkits.openapi.toolkit.OpenAPIToolkit¶ class langchain.agents.agent_toolkits.openapi.toolkit.OpenAPIToolkit(*, json_agent: AgentExecutor, requests_wrapper: TextRequestsWrapper)[source]¶ Bases: BaseToolkit Toolkit for interacting with a OpenAPI api. Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input data cannot be parsed to form a valid model. param json_agent: langchain.agents.agent.AgentExecutor [Required]¶ param requests_wrapper: langchain.requests.TextRequestsWrapper [Required]¶ classmethod from_llm(llm: BaseLanguageModel, json_spec: JsonSpec, requests_wrapper: TextRequestsWrapper, **kwargs: Any) → OpenAPIToolkit[source]¶ Create json agent from llm, then initialize. get_tools() → List[BaseTool][source]¶ Get the tools in the toolkit.
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_toolkits.openapi.toolkit.OpenAPIToolkit.html
ee2e4baab2bf-0
langchain.agents.agent_toolkits.gmail.toolkit.GmailToolkit¶ class langchain.agents.agent_toolkits.gmail.toolkit.GmailToolkit(*, api_resource: Resource = None)[source]¶ Bases: BaseToolkit Toolkit for interacting with Gmail. Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input data cannot be parsed to form a valid model. param api_resource: Resource [Optional]¶ get_tools() → List[BaseTool][source]¶ Get the tools in the toolkit. model Config[source]¶ Bases: object Pydantic config. arbitrary_types_allowed = True¶
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_toolkits.gmail.toolkit.GmailToolkit.html
594d8ef9a937-0
langchain.agents.chat.base.ChatAgent¶ class langchain.agents.chat.base.ChatAgent(*, llm_chain: LLMChain, output_parser: AgentOutputParser = None, allowed_tools: Optional[List[str]] = None)[source]¶ Bases: Agent Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input data cannot be parsed to form a valid model. param allowed_tools: Optional[List[str]] = None¶ param llm_chain: langchain.chains.llm.LLMChain [Required]¶ param output_parser: langchain.agents.agent.AgentOutputParser [Optional]¶ async aplan(intermediate_steps: List[Tuple[AgentAction, str]], callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, **kwargs: Any) → Union[AgentAction, AgentFinish]¶ 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.
https://api.python.langchain.com/en/latest/agents/langchain.agents.chat.base.ChatAgent.html
594d8ef9a937-1
**kwargs – User inputs. Returns Action specifying what tool to use. classmethod create_prompt(tools: Sequence[BaseTool], system_message_prefix: str = 'Answer the following questions as best you can. You have access to the following tools:', system_message_suffix: str = 'Begin! Reminder to always use the exact characters `Final Answer` when responding.', human_message: str = '{input}\n\n{agent_scratchpad}', format_instructions: str = 'The way you use the tools is by specifying a json blob.\nSpecifically, this json should have a `action` key (with the name of the tool to use) and a `action_input` key (with the input to the tool going here).\n\nThe only values that should be in the "action" field are: {tool_names}\n\nThe $JSON_BLOB should only contain a SINGLE action, do NOT return a list of multiple actions. Here is an example of a valid $JSON_BLOB:\n\n```\n{{{{\n  "action": $TOOL_NAME,\n  "action_input": $INPUT\n}}}}\n```\n\nALWAYS use the following format:\n\nQuestion: the input question you must answer\nThought: you should always think about what to do\nAction:\n```\n$JSON_BLOB\n```\nObservation: the result of the action\n... (this Thought/Action/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input question', input_variables: Optional[List[str]] = None) → BasePromptTemplate[source]¶ Create a prompt for this class. dict(**kwargs: Any) → Dict¶ Return dictionary representation of agent.
https://api.python.langchain.com/en/latest/agents/langchain.agents.chat.base.ChatAgent.html
594d8ef9a937-2
dict(**kwargs: Any) → Dict¶ Return dictionary representation of agent. classmethod from_llm_and_tools(llm: BaseLanguageModel, tools: Sequence[BaseTool], callback_manager: Optional[BaseCallbackManager] = None, output_parser: Optional[AgentOutputParser] = None, system_message_prefix: str = 'Answer the following questions as best you can. You have access to the following tools:', system_message_suffix: str = 'Begin! Reminder to always use the exact characters `Final Answer` when responding.', human_message: str = '{input}\n\n{agent_scratchpad}', format_instructions: str = 'The way you use the tools is by specifying a json blob.\nSpecifically, this json should have a `action` key (with the name of the tool to use) and a `action_input` key (with the input to the tool going here).\n\nThe only values that should be in the "action" field are: {tool_names}\n\nThe $JSON_BLOB should only contain a SINGLE action, do NOT return a list of multiple actions. Here is an example of a valid $JSON_BLOB:\n\n```\n{{{{\n  "action": $TOOL_NAME,\n  "action_input": $INPUT\n}}}}\n```\n\nALWAYS use the following format:\n\nQuestion: the input question you must answer\nThought: you should always think about what to do\nAction:\n```\n$JSON_BLOB\n```\nObservation: the result of the action\n... (this Thought/Action/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input question', input_variables: Optional[List[str]] = None, **kwargs: Any) → Agent[source]¶ Construct an agent from an LLM and tools.
https://api.python.langchain.com/en/latest/agents/langchain.agents.chat.base.ChatAgent.html
594d8ef9a937-3
Construct an agent from an LLM and tools. get_allowed_tools() → Optional[List[str]]¶ get_full_inputs(intermediate_steps: List[Tuple[AgentAction, str]], **kwargs: Any) → Dict[str, Any]¶ Create the full inputs for the LLMChain from intermediate steps. plan(intermediate_steps: List[Tuple[AgentAction, str]], callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, **kwargs: Any) → Union[AgentAction, AgentFinish]¶ 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[AgentAction, str]], **kwargs: Any) → AgentFinish¶ Return response when agent has been stopped due to max iterations. save(file_path: Union[Path, str]) → None¶ 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¶ validator validate_prompt  »  all fields¶ Validate that prompt matches format. property llm_prefix: str¶ Prefix to append the llm call with. property observation_prefix: str¶ Prefix to append the observation with. property return_values: List[str]¶ Return values of the agent.
https://api.python.langchain.com/en/latest/agents/langchain.agents.chat.base.ChatAgent.html
583696efc504-0
langchain.agents.agent_toolkits.azure_cognitive_services.toolkit.AzureCognitiveServicesToolkit¶ class langchain.agents.agent_toolkits.azure_cognitive_services.toolkit.AzureCognitiveServicesToolkit[source]¶ Bases: BaseToolkit Toolkit for Azure Cognitive Services. Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input data cannot be parsed to form a valid model. get_tools() → List[BaseTool][source]¶ Get the tools in the toolkit.
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_toolkits.azure_cognitive_services.toolkit.AzureCognitiveServicesToolkit.html
e152fcb6b7ba-0
langchain.agents.structured_chat.base.StructuredChatAgent¶ class langchain.agents.structured_chat.base.StructuredChatAgent(*, llm_chain: LLMChain, output_parser: AgentOutputParser = None, allowed_tools: Optional[List[str]] = None)[source]¶ Bases: Agent Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input data cannot be parsed to form a valid model. param allowed_tools: Optional[List[str]] = None¶ param llm_chain: langchain.chains.llm.LLMChain [Required]¶ param output_parser: langchain.agents.agent.AgentOutputParser [Optional]¶ async aplan(intermediate_steps: List[Tuple[AgentAction, str]], callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, **kwargs: Any) → Union[AgentAction, AgentFinish]¶ 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.
https://api.python.langchain.com/en/latest/agents/langchain.agents.structured_chat.base.StructuredChatAgent.html
e152fcb6b7ba-1
**kwargs – User inputs. Returns Action specifying what tool to use. classmethod create_prompt(tools: Sequence[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 a valid json blob of a single action. Use tools if necessary. Respond directly if appropriate. Format is Action:```$JSON_BLOB```then Observation:.\nThought:', human_message_template: str = '{input}\n\n{agent_scratchpad}', format_instructions: str = 'Use a json blob to specify a tool by providing an action key (tool name) and an action_input key (tool input).\n\nValid "action" values: "Final Answer" or {tool_names}\n\nProvide only ONE action per $JSON_BLOB, as shown:\n\n```\n{{{{\n  "action": $TOOL_NAME,\n  "action_input": $INPUT\n}}}}\n```\n\nFollow this format:\n\nQuestion: input question to answer\nThought: consider previous and subsequent steps\nAction:\n```\n$JSON_BLOB\n```\nObservation: action result\n... (repeat Thought/Action/Observation N times)\nThought: I know what to respond\nAction:\n```\n{{{{\n  "action": "Final Answer",\n  "action_input": "Final response to human"\n}}}}\n```', input_variables: Optional[List[str]] = None, memory_prompts: Optional[List[BasePromptTemplate]] = None) → BasePromptTemplate[source]¶ Create a prompt for this class. dict(**kwargs: Any) → Dict¶ Return dictionary representation of agent.
https://api.python.langchain.com/en/latest/agents/langchain.agents.structured_chat.base.StructuredChatAgent.html
e152fcb6b7ba-2
dict(**kwargs: Any) → Dict¶ Return dictionary representation of agent. classmethod from_llm_and_tools(llm: BaseLanguageModel, tools: Sequence[BaseTool], callback_manager: Optional[BaseCallbackManager] = None, output_parser: Optional[AgentOutputParser] = None, 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 a valid json blob of a single action. Use tools if necessary. Respond directly if appropriate. Format is Action:```$JSON_BLOB```then Observation:.\nThought:', human_message_template: str = '{input}\n\n{agent_scratchpad}', format_instructions: str = 'Use a json blob to specify a tool by providing an action key (tool name) and an action_input key (tool input).\n\nValid "action" values: "Final Answer" or {tool_names}\n\nProvide only ONE action per $JSON_BLOB, as shown:\n\n```\n{{{{\n  "action": $TOOL_NAME,\n  "action_input": $INPUT\n}}}}\n```\n\nFollow this format:\n\nQuestion: input question to answer\nThought: consider previous and subsequent steps\nAction:\n```\n$JSON_BLOB\n```\nObservation: action result\n... (repeat Thought/Action/Observation N times)\nThought: I know what to respond\nAction:\n```\n{{{{\n  "action": "Final Answer",\n  "action_input": "Final response to human"\n}}}}\n```', input_variables: Optional[List[str]] = None, memory_prompts: Optional[List[BasePromptTemplate]] = None, **kwargs: Any) → Agent[source]¶ Construct an agent from an LLM and tools.
https://api.python.langchain.com/en/latest/agents/langchain.agents.structured_chat.base.StructuredChatAgent.html
e152fcb6b7ba-3
Construct an agent from an LLM and tools. get_allowed_tools() → Optional[List[str]]¶ get_full_inputs(intermediate_steps: List[Tuple[AgentAction, str]], **kwargs: Any) → Dict[str, Any]¶ Create the full inputs for the LLMChain from intermediate steps. plan(intermediate_steps: List[Tuple[AgentAction, str]], callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, **kwargs: Any) → Union[AgentAction, AgentFinish]¶ 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[AgentAction, str]], **kwargs: Any) → AgentFinish¶ Return response when agent has been stopped due to max iterations. save(file_path: Union[Path, str]) → None¶ 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¶ validator validate_prompt  »  all fields¶ Validate that prompt matches format. property llm_prefix: str¶ Prefix to append the llm call with. property observation_prefix: str¶ Prefix to append the observation with. property return_values: List[str]¶ Return values of the agent.
https://api.python.langchain.com/en/latest/agents/langchain.agents.structured_chat.base.StructuredChatAgent.html
4c6cbae0c36a-0
langchain.agents.react.base.ReActChain¶ class langchain.agents.react.base.ReActChain(llm: BaseLanguageModel, docstore: Docstore, *, memory: Optional[BaseMemory] = None, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, callback_manager: Optional[BaseCallbackManager] = None, verbose: bool = None, tags: Optional[List[str]] = None, agent: Union[BaseSingleActionAgent, BaseMultiActionAgent], tools: Sequence[BaseTool], return_intermediate_steps: bool = False, max_iterations: Optional[int] = 15, max_execution_time: Optional[float] = None, early_stopping_method: str = 'force', handle_parsing_errors: Union[bool, str, Callable[[OutputParserException], str]] = False)[source]¶ Bases: AgentExecutor Chain that implements the ReAct paper. Example from langchain import ReActChain, OpenAI react = ReAct(llm=OpenAI()) Initialize with the LLM and a docstore. param agent: Union[BaseSingleActionAgent, BaseMultiActionAgent] [Required]¶ The agent to run for creating a plan and determining actions to take at each step of the execution loop. param callback_manager: Optional[BaseCallbackManager] = None¶ Deprecated, use callbacks instead. param callbacks: Callbacks = None¶ Optional list of callback handlers (or callback manager). Defaults to None. Callback handlers are called throughout the lifecycle of a call to a chain, starting with on_chain_start, ending with on_chain_end or on_chain_error. Each custom chain can optionally call additional callback methods, see Callback docs for full details. param early_stopping_method: str = 'force'¶ The method to use for early stopping if the agent never
https://api.python.langchain.com/en/latest/agents/langchain.agents.react.base.ReActChain.html
4c6cbae0c36a-1
The method to use for early stopping if the agent never returns AgentFinish. Either ‘force’ or ‘generate’. “force” returns a string saying that it stopped because it met atime or iteration limit. “generate” calls the agent’s LLM Chain one final time to generatea final answer based on the previous steps. param handle_parsing_errors: Union[bool, str, Callable[[OutputParserException], str]] = False¶ How to handle errors raised by the agent’s output parser.Defaults to False, which raises the error. sIf true, the error will be sent back to the LLM as an observation. If a string, the string itself will be sent to the LLM as an observation. If a callable function, the function will be called with the exception as an argument, and the result of that function will be passed to the agentas an observation. param max_execution_time: Optional[float] = None¶ The maximum amount of wall clock time to spend in the execution loop. param max_iterations: Optional[int] = 15¶ The maximum number of steps to take before ending the execution loop. Setting to ‘None’ could lead to an infinite loop. param memory: Optional[BaseMemory] = None¶ Optional memory object. Defaults to None. Memory is a class that gets called at the start and at the end of every chain. At the start, memory loads variables and passes them along in the chain. At the end, it saves any returned variables. There are many different types of memory - please see memory docs for the full catalog. param return_intermediate_steps: bool = False¶ Whether to return the agent’s trajectory of intermediate steps at the end in addition to the final output. param tags: Optional[List[str]] = None¶ Optional list of tags associated with the chain. Defaults to None
https://api.python.langchain.com/en/latest/agents/langchain.agents.react.base.ReActChain.html
4c6cbae0c36a-2
Optional list of tags associated with the chain. Defaults to None These tags will be associated with each call to this chain, and passed as arguments to the handlers defined in callbacks. You can use these to eg identify a specific instance of a chain with its use case. param tools: Sequence[BaseTool] [Required]¶ The valid tools the agent can call. param verbose: bool [Optional]¶ Whether or not run in verbose mode. In verbose mode, some intermediate logs will be printed to the console. Defaults to langchain.verbose value. __call__(inputs: Union[Dict[str, Any], Any], return_only_outputs: bool = False, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, *, tags: Optional[List[str]] = None, include_run_info: bool = False) → Dict[str, Any]¶ Run the logic of this chain and add to output if desired. Parameters inputs – Dictionary of inputs, or single input if chain expects only one param. return_only_outputs – boolean for whether to return only outputs in the response. If True, only new keys generated by this chain will be returned. If False, both input keys and new keys generated by this chain will be returned. Defaults to False. callbacks – Callbacks to use for this chain run. If not provided, will use the callbacks provided to the chain. include_run_info – Whether to include run info in the response. Defaults to False. async acall(inputs: Union[Dict[str, Any], Any], return_only_outputs: bool = False, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, *, tags: Optional[List[str]] = None, include_run_info: bool = False) → Dict[str, Any]¶ Run the logic of this chain and add to output if desired. Parameters
https://api.python.langchain.com/en/latest/agents/langchain.agents.react.base.ReActChain.html
4c6cbae0c36a-3
Run the logic of this chain and add to output if desired. Parameters inputs – Dictionary of inputs, or single input if chain expects only one param. return_only_outputs – boolean for whether to return only outputs in the response. If True, only new keys generated by this chain will be returned. If False, both input keys and new keys generated by this chain will be returned. Defaults to False. callbacks – Callbacks to use for this chain run. If not provided, will use the callbacks provided to the chain. include_run_info – Whether to include run info in the response. Defaults to False. apply(input_list: List[Dict[str, Any]], callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None) → List[Dict[str, str]]¶ Call the chain on all inputs in the list. async arun(*args: Any, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, tags: Optional[List[str]] = None, **kwargs: Any) → str¶ Run the chain as text in, text out or multiple variables, text out. dict(**kwargs: Any) → Dict¶ Return dictionary representation of chain. classmethod from_agent_and_tools(agent: Union[BaseSingleActionAgent, BaseMultiActionAgent], tools: Sequence[BaseTool], callback_manager: Optional[BaseCallbackManager] = None, **kwargs: Any) → AgentExecutor¶ Create from agent and tools. lookup_tool(name: str) → BaseTool¶ Lookup tool by name. prep_inputs(inputs: Union[Dict[str, Any], Any]) → Dict[str, str]¶ Validate and prep inputs. prep_outputs(inputs: Dict[str, str], outputs: Dict[str, str], return_only_outputs: bool = False) → Dict[str, str]¶ Validate and prep outputs.
https://api.python.langchain.com/en/latest/agents/langchain.agents.react.base.ReActChain.html
4c6cbae0c36a-4
Validate and prep outputs. validator raise_deprecation  »  all fields¶ Raise deprecation warning if callback_manager is used. run(*args: Any, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, tags: Optional[List[str]] = None, **kwargs: Any) → str¶ Run the chain as text in, text out or multiple variables, text out. save(file_path: Union[Path, str]) → None¶ Raise error - saving not supported for Agent Executors. save_agent(file_path: Union[Path, str]) → None¶ Save the underlying agent. validator set_verbose  »  verbose¶ If verbose is None, set it. This allows users to pass in None as verbose to access the global setting. to_json() → Union[SerializedConstructor, SerializedNotImplemented]¶ to_json_not_implemented() → SerializedNotImplemented¶ validator validate_return_direct_tool  »  all fields¶ Validate that tools are compatible with agent. validator validate_tools  »  all fields¶ Validate that tools are compatible with agent. property lc_attributes: Dict¶ Return a list of attribute names that should be included in the serialized kwargs. These attributes must be accepted by the constructor. property lc_namespace: List[str]¶ Return the namespace of the langchain object. eg. [“langchain”, “llms”, “openai”] property lc_secrets: Dict[str, str]¶ Return a map of constructor argument names to secret ids. eg. {“openai_api_key”: “OPENAI_API_KEY”} property lc_serializable: bool¶ Return whether or not the class is serializable. model Config¶ Bases: object Configuration for this pydantic object. arbitrary_types_allowed = True¶
https://api.python.langchain.com/en/latest/agents/langchain.agents.react.base.ReActChain.html
e9e68fb63747-0
langchain.agents.agent.BaseSingleActionAgent¶ class langchain.agents.agent.BaseSingleActionAgent[source]¶ Bases: BaseModel Base Agent class. Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input data cannot be parsed to form a valid model. abstract async aplan(intermediate_steps: List[Tuple[AgentAction, str]], callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, **kwargs: Any) → Union[AgentAction, AgentFinish][source]¶ 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. dict(**kwargs: Any) → Dict[source]¶ Return dictionary representation of agent. classmethod from_llm_and_tools(llm: BaseLanguageModel, tools: Sequence[BaseTool], callback_manager: Optional[BaseCallbackManager] = None, **kwargs: Any) → BaseSingleActionAgent[source]¶ get_allowed_tools() → Optional[List[str]][source]¶ abstract plan(intermediate_steps: List[Tuple[AgentAction, str]], callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, **kwargs: Any) → Union[AgentAction, AgentFinish][source]¶ 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[AgentAction, str]], **kwargs: Any) → AgentFinish[source]¶
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent.BaseSingleActionAgent.html
e9e68fb63747-1
Return response when agent has been stopped due to max iterations. save(file_path: Union[Path, str]) → None[source]¶ 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.
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent.BaseSingleActionAgent.html
c398c910b030-0
langchain.agents.agent_toolkits.openapi.planner.create_openapi_agent¶ langchain.agents.agent_toolkits.openapi.planner.create_openapi_agent(api_spec: ReducedOpenAPISpec, requests_wrapper: TextRequestsWrapper, llm: BaseLanguageModel, shared_memory: Optional[ReadOnlySharedMemory] = None, callback_manager: Optional[BaseCallbackManager] = None, verbose: bool = True, agent_executor_kwargs: Optional[Dict[str, Any]] = None, **kwargs: Dict[str, Any]) → AgentExecutor[source]¶ Instantiate API planner and controller for a given spec. Inject credentials via requests_wrapper. We use a top-level “orchestrator” agent to invoke the planner and controller, rather than a top-level planner that invokes a controller with its plan. This is to keep the planner simple.
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_toolkits.openapi.planner.create_openapi_agent.html
823b43cce2d6-0
langchain.agents.agent_toolkits.json.toolkit.JsonToolkit¶ class langchain.agents.agent_toolkits.json.toolkit.JsonToolkit(*, spec: JsonSpec)[source]¶ Bases: BaseToolkit Toolkit for interacting with a JSON spec. Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input data cannot be parsed to form a valid model. param spec: langchain.tools.json.tool.JsonSpec [Required]¶ get_tools() → List[BaseTool][source]¶ Get the tools in the toolkit.
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_toolkits.json.toolkit.JsonToolkit.html
3a9d4e97c5da-0
langchain.agents.loading.load_agent_from_config¶ langchain.agents.loading.load_agent_from_config(config: dict, llm: Optional[BaseLanguageModel] = None, tools: Optional[List[Tool]] = None, **kwargs: Any) → Union[BaseSingleActionAgent, BaseMultiActionAgent][source]¶ Load agent from Config Dict.
https://api.python.langchain.com/en/latest/agents/langchain.agents.loading.load_agent_from_config.html
0ec4cf217bb3-0
langchain.agents.mrkl.base.ZeroShotAgent¶ class langchain.agents.mrkl.base.ZeroShotAgent(*, llm_chain: LLMChain, output_parser: AgentOutputParser = None, allowed_tools: Optional[List[str]] = None)[source]¶ Bases: Agent Agent for the MRKL chain. Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input data cannot be parsed to form a valid model. param allowed_tools: Optional[List[str]] = None¶ param llm_chain: langchain.chains.llm.LLMChain [Required]¶ param output_parser: langchain.agents.agent.AgentOutputParser [Optional]¶ async aplan(intermediate_steps: List[Tuple[AgentAction, str]], callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, **kwargs: Any) → Union[AgentAction, AgentFinish]¶ 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.
https://api.python.langchain.com/en/latest/agents/langchain.agents.mrkl.base.ZeroShotAgent.html
0ec4cf217bb3-1
**kwargs – User inputs. Returns Action specifying what tool to use. classmethod create_prompt(tools: Sequence[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_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, 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: Optional[List[str]] = None) → PromptTemplate[source]¶ 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. input_variables – List of input variables the final prompt will expect. Returns A PromptTemplate with the template assembled from the pieces here. dict(**kwargs: Any) → Dict¶ Return dictionary representation of agent.
https://api.python.langchain.com/en/latest/agents/langchain.agents.mrkl.base.ZeroShotAgent.html
0ec4cf217bb3-2
dict(**kwargs: Any) → Dict¶ Return dictionary representation of agent. classmethod from_llm_and_tools(llm: BaseLanguageModel, tools: Sequence[BaseTool], callback_manager: Optional[BaseCallbackManager] = None, output_parser: Optional[AgentOutputParser] = None, 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_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, 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: Optional[List[str]] = None, **kwargs: Any) → Agent[source]¶ Construct an agent from an LLM and tools. get_allowed_tools() → Optional[List[str]]¶ get_full_inputs(intermediate_steps: List[Tuple[AgentAction, str]], **kwargs: Any) → Dict[str, Any]¶ Create the full inputs for the LLMChain from intermediate steps. plan(intermediate_steps: List[Tuple[AgentAction, str]], callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, **kwargs: Any) → Union[AgentAction, AgentFinish]¶ 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.
https://api.python.langchain.com/en/latest/agents/langchain.agents.mrkl.base.ZeroShotAgent.html
0ec4cf217bb3-3
**kwargs – User inputs. Returns Action specifying what tool to use. return_stopped_response(early_stopping_method: str, intermediate_steps: List[Tuple[AgentAction, str]], **kwargs: Any) → AgentFinish¶ Return response when agent has been stopped due to max iterations. save(file_path: Union[Path, str]) → None¶ 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¶ validator validate_prompt  »  all fields¶ Validate that prompt matches format. property llm_prefix: str¶ Prefix to append the llm call with. property observation_prefix: str¶ Prefix to append the observation with. property return_values: List[str]¶ Return values of the agent.
https://api.python.langchain.com/en/latest/agents/langchain.agents.mrkl.base.ZeroShotAgent.html
5c97df78aed8-0
langchain.agents.agent_toolkits.base.BaseToolkit¶ class langchain.agents.agent_toolkits.base.BaseToolkit[source]¶ Bases: BaseModel Class responsible for defining a collection of related tools. Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input data cannot be parsed to form a valid model. abstract get_tools() → List[BaseTool][source]¶ Get the tools in the toolkit.
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_toolkits.base.BaseToolkit.html
84c6a0c448f5-0
langchain.agents.load_tools.get_all_tool_names¶ langchain.agents.load_tools.get_all_tool_names() → List[str][source]¶ Get a list of all possible tool names.
https://api.python.langchain.com/en/latest/agents/langchain.agents.load_tools.get_all_tool_names.html
506029133c5b-0
langchain.agents.agent_toolkits.sql.toolkit.SQLDatabaseToolkit¶ class langchain.agents.agent_toolkits.sql.toolkit.SQLDatabaseToolkit(*, db: SQLDatabase, llm: BaseLanguageModel)[source]¶ Bases: BaseToolkit Toolkit for interacting with SQL databases. Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input data cannot be parsed to form a valid model. param db: langchain.sql_database.SQLDatabase [Required]¶ param llm: langchain.base_language.BaseLanguageModel [Required]¶ get_tools() → List[BaseTool][source]¶ Get the tools in the toolkit. property dialect: str¶ Return string representation of dialect to use. model Config[source]¶ Bases: object Configuration for this pydantic object. arbitrary_types_allowed = True¶
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_toolkits.sql.toolkit.SQLDatabaseToolkit.html
c09bb7399563-0
langchain.agents.agent_toolkits.office365.toolkit.O365Toolkit¶ class langchain.agents.agent_toolkits.office365.toolkit.O365Toolkit(*, account: Account = None)[source]¶ Bases: BaseToolkit Toolkit for interacting with Office365. Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input data cannot be parsed to form a valid model. param account: Account [Optional]¶ get_tools() → List[BaseTool][source]¶ Get the tools in the toolkit. model Config[source]¶ Bases: object Pydantic config. arbitrary_types_allowed = True¶
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_toolkits.office365.toolkit.O365Toolkit.html
3d42dc1cb198-0
langchain.agents.agent_toolkits.openapi.base.create_openapi_agent¶
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_toolkits.openapi.base.create_openapi_agent.html
3d42dc1cb198-1
langchain.agents.agent_toolkits.openapi.base.create_openapi_agent(llm: BaseLanguageModel, toolkit: OpenAPIToolkit, callback_manager: Optional[BaseCallbackManager] = None, prefix: str = "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: str = 'Begin!\n\nQuestion: {input}\nThought: I should explore the spec to find the base url for the API.\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, should be one of [{tool_names}]\nAction Input: the input to the action\nObservation: the result of
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_toolkits.openapi.base.create_openapi_agent.html
3d42dc1cb198-2
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: Optional[List[str]] = 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]) → AgentExecutor[source]¶
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_toolkits.openapi.base.create_openapi_agent.html
3d42dc1cb198-3
Construct a json agent from an LLM and tools.
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_toolkits.openapi.base.create_openapi_agent.html
1807ee6c2696-0
langchain.agents.agent_toolkits.vectorstore.toolkit.VectorStoreInfo¶ class langchain.agents.agent_toolkits.vectorstore.toolkit.VectorStoreInfo(*, vectorstore: VectorStore, name: str, description: str)[source]¶ Bases: BaseModel Information about a vectorstore. Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input data cannot be parsed to form a valid model. param description: str [Required]¶ param name: str [Required]¶ param vectorstore: langchain.vectorstores.base.VectorStore [Required]¶ model Config[source]¶ Bases: object Configuration for this pydantic object. arbitrary_types_allowed = True¶
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_toolkits.vectorstore.toolkit.VectorStoreInfo.html
c6463cc51058-0
langchain.agents.agent.AgentExecutor¶ class langchain.agents.agent.AgentExecutor(*, memory: Optional[BaseMemory] = None, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, callback_manager: Optional[BaseCallbackManager] = None, verbose: bool = None, tags: Optional[List[str]] = None, agent: Union[BaseSingleActionAgent, BaseMultiActionAgent], tools: Sequence[BaseTool], return_intermediate_steps: bool = False, max_iterations: Optional[int] = 15, max_execution_time: Optional[float] = None, early_stopping_method: str = 'force', handle_parsing_errors: Union[bool, str, Callable[[OutputParserException], str]] = False)[source]¶ Bases: Chain Consists of an agent using tools. Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input data cannot be parsed to form a valid model. param agent: Union[BaseSingleActionAgent, BaseMultiActionAgent] [Required]¶ The agent to run for creating a plan and determining actions to take at each step of the execution loop. param callback_manager: Optional[BaseCallbackManager] = None¶ Deprecated, use callbacks instead. param callbacks: Callbacks = None¶ Optional list of callback handlers (or callback manager). Defaults to None. Callback handlers are called throughout the lifecycle of a call to a chain, starting with on_chain_start, ending with on_chain_end or on_chain_error. Each custom chain can optionally call additional callback methods, see Callback docs for full details. param early_stopping_method: str = 'force'¶ The method to use for early stopping if the agent never returns AgentFinish. Either ‘force’ or ‘generate’.
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent.AgentExecutor.html
c6463cc51058-1
returns AgentFinish. Either ‘force’ or ‘generate’. “force” returns a string saying that it stopped because it met atime or iteration limit. “generate” calls the agent’s LLM Chain one final time to generatea final answer based on the previous steps. param handle_parsing_errors: Union[bool, str, Callable[[OutputParserException], str]] = False¶ How to handle errors raised by the agent’s output parser.Defaults to False, which raises the error. sIf true, the error will be sent back to the LLM as an observation. If a string, the string itself will be sent to the LLM as an observation. If a callable function, the function will be called with the exception as an argument, and the result of that function will be passed to the agentas an observation. param max_execution_time: Optional[float] = None¶ The maximum amount of wall clock time to spend in the execution loop. param max_iterations: Optional[int] = 15¶ The maximum number of steps to take before ending the execution loop. Setting to ‘None’ could lead to an infinite loop. param memory: Optional[BaseMemory] = None¶ Optional memory object. Defaults to None. Memory is a class that gets called at the start and at the end of every chain. At the start, memory loads variables and passes them along in the chain. At the end, it saves any returned variables. There are many different types of memory - please see memory docs for the full catalog. param return_intermediate_steps: bool = False¶ Whether to return the agent’s trajectory of intermediate steps at the end in addition to the final output. param tags: Optional[List[str]] = None¶ Optional list of tags associated with the chain. Defaults to None
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent.AgentExecutor.html
c6463cc51058-2
Optional list of tags associated with the chain. Defaults to None These tags will be associated with each call to this chain, and passed as arguments to the handlers defined in callbacks. You can use these to eg identify a specific instance of a chain with its use case. param tools: Sequence[BaseTool] [Required]¶ The valid tools the agent can call. param verbose: bool [Optional]¶ Whether or not run in verbose mode. In verbose mode, some intermediate logs will be printed to the console. Defaults to langchain.verbose value. __call__(inputs: Union[Dict[str, Any], Any], return_only_outputs: bool = False, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, *, tags: Optional[List[str]] = None, include_run_info: bool = False) → Dict[str, Any]¶ Run the logic of this chain and add to output if desired. Parameters inputs – Dictionary of inputs, or single input if chain expects only one param. return_only_outputs – boolean for whether to return only outputs in the response. If True, only new keys generated by this chain will be returned. If False, both input keys and new keys generated by this chain will be returned. Defaults to False. callbacks – Callbacks to use for this chain run. If not provided, will use the callbacks provided to the chain. include_run_info – Whether to include run info in the response. Defaults to False. async acall(inputs: Union[Dict[str, Any], Any], return_only_outputs: bool = False, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, *, tags: Optional[List[str]] = None, include_run_info: bool = False) → Dict[str, Any]¶ Run the logic of this chain and add to output if desired. Parameters
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent.AgentExecutor.html
c6463cc51058-3
Run the logic of this chain and add to output if desired. Parameters inputs – Dictionary of inputs, or single input if chain expects only one param. return_only_outputs – boolean for whether to return only outputs in the response. If True, only new keys generated by this chain will be returned. If False, both input keys and new keys generated by this chain will be returned. Defaults to False. callbacks – Callbacks to use for this chain run. If not provided, will use the callbacks provided to the chain. include_run_info – Whether to include run info in the response. Defaults to False. apply(input_list: List[Dict[str, Any]], callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None) → List[Dict[str, str]]¶ Call the chain on all inputs in the list. async arun(*args: Any, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, tags: Optional[List[str]] = None, **kwargs: Any) → str¶ Run the chain as text in, text out or multiple variables, text out. dict(**kwargs: Any) → Dict¶ Return dictionary representation of chain. classmethod from_agent_and_tools(agent: Union[BaseSingleActionAgent, BaseMultiActionAgent], tools: Sequence[BaseTool], callback_manager: Optional[BaseCallbackManager] = None, **kwargs: Any) → AgentExecutor[source]¶ Create from agent and tools. lookup_tool(name: str) → BaseTool[source]¶ Lookup tool by name. prep_inputs(inputs: Union[Dict[str, Any], Any]) → Dict[str, str]¶ Validate and prep inputs. prep_outputs(inputs: Dict[str, str], outputs: Dict[str, str], return_only_outputs: bool = False) → Dict[str, str]¶
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent.AgentExecutor.html
c6463cc51058-4
Validate and prep outputs. validator raise_deprecation  »  all fields¶ Raise deprecation warning if callback_manager is used. run(*args: Any, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, tags: Optional[List[str]] = None, **kwargs: Any) → str¶ Run the chain as text in, text out or multiple variables, text out. save(file_path: Union[Path, str]) → None[source]¶ Raise error - saving not supported for Agent Executors. save_agent(file_path: Union[Path, str]) → None[source]¶ Save the underlying agent. validator set_verbose  »  verbose¶ If verbose is None, set it. This allows users to pass in None as verbose to access the global setting. to_json() → Union[SerializedConstructor, SerializedNotImplemented]¶ to_json_not_implemented() → SerializedNotImplemented¶ validator validate_return_direct_tool  »  all fields[source]¶ Validate that tools are compatible with agent. validator validate_tools  »  all fields[source]¶ Validate that tools are compatible with agent. property lc_attributes: Dict¶ Return a list of attribute names that should be included in the serialized kwargs. These attributes must be accepted by the constructor. property lc_namespace: List[str]¶ Return the namespace of the langchain object. eg. [“langchain”, “llms”, “openai”] property lc_secrets: Dict[str, str]¶ Return a map of constructor argument names to secret ids. eg. {“openai_api_key”: “OPENAI_API_KEY”} property lc_serializable: bool¶ Return whether or not the class is serializable. model Config¶ Bases: object Configuration for this pydantic object. arbitrary_types_allowed = True¶
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent.AgentExecutor.html
3e8f2586d2ce-0
langchain.agents.loading.load_agent¶ langchain.agents.loading.load_agent(path: Union[str, Path], **kwargs: Any) → Union[BaseSingleActionAgent, BaseMultiActionAgent][source]¶ Unified method for loading a agent from LangChainHub or local fs.
https://api.python.langchain.com/en/latest/agents/langchain.agents.loading.load_agent.html
75614decb725-0
langchain.agents.agent_toolkits.powerbi.chat_base.create_pbi_chat_agent¶
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_toolkits.powerbi.chat_base.create_pbi_chat_agent.html
75614decb725-1
langchain.agents.agent_toolkits.powerbi.chat_base.create_pbi_chat_agent(llm: BaseChatModel, toolkit: Optional[PowerBIToolkit], powerbi: Optional[PowerBIDataset] = None, callback_manager: Optional[BaseCallbackManager] = None, output_parser: Optional[AgentOutputParser] = None, prefix: str = '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: str = "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: Optional[str] = None, input_variables: Optional[List[str]] =
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_toolkits.powerbi.chat_base.create_pbi_chat_agent.html
75614decb725-2
examples: Optional[str] = None, input_variables: Optional[List[str]] = None, memory: Optional[BaseChatMemory] = None, top_k: int = 10, verbose: bool = False, agent_executor_kwargs: Optional[Dict[str, Any]] = None, **kwargs: Dict[str, Any]) → AgentExecutor[source]¶
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_toolkits.powerbi.chat_base.create_pbi_chat_agent.html
75614decb725-3
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://api.python.langchain.com/en/latest/agents/langchain.agents.agent_toolkits.powerbi.chat_base.create_pbi_chat_agent.html
0bc42337da5b-0
langchain.agents.agent_toolkits.spark_sql.toolkit.SparkSQLToolkit¶ class langchain.agents.agent_toolkits.spark_sql.toolkit.SparkSQLToolkit(*, db: SparkSQL, llm: BaseLanguageModel)[source]¶ Bases: BaseToolkit Toolkit for interacting with Spark SQL. Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input data cannot be parsed to form a valid model. param db: langchain.utilities.spark_sql.SparkSQL [Required]¶ param llm: langchain.base_language.BaseLanguageModel [Required]¶ get_tools() → List[BaseTool][source]¶ Get the tools in the toolkit. model Config[source]¶ Bases: object Configuration for this pydantic object. arbitrary_types_allowed = True¶
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_toolkits.spark_sql.toolkit.SparkSQLToolkit.html
e4d60ef36c03-0
langchain.agents.conversational.base.ConversationalAgent¶ class langchain.agents.conversational.base.ConversationalAgent(*, llm_chain: LLMChain, output_parser: AgentOutputParser = None, allowed_tools: Optional[List[str]] = None, ai_prefix: str = 'AI')[source]¶ Bases: Agent An agent designed to hold a conversation in addition to using tools. Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input data cannot be parsed to form a valid model. param ai_prefix: str = 'AI'¶ param allowed_tools: Optional[List[str]] = None¶ param llm_chain: langchain.chains.llm.LLMChain [Required]¶ param output_parser: langchain.agents.agent.AgentOutputParser [Optional]¶ async aplan(intermediate_steps: List[Tuple[AgentAction, str]], callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, **kwargs: Any) → Union[AgentAction, AgentFinish]¶ 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.
https://api.python.langchain.com/en/latest/agents/langchain.agents.conversational.base.ConversationalAgent.html
e4d60ef36c03-1
classmethod create_prompt(tools: Sequence[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 topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.\n\nAssistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge 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\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 just want to have a conversation about a particular topic, Assistant is here to assist.\n\nTOOLS:\n------\n\nAssistant has access to the following tools:', suffix: str = 'Begin!\n\nPrevious conversation history:\n{chat_history}\n\nNew input: {input}\n{agent_scratchpad}', format_instructions: str = 'To use a tool, please use the following format:\n\n```\nThought: Do I need to use a tool? Yes\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```\n\nWhen you have a response to say to the Human, or if you do not need to use a tool, you MUST use the
https://api.python.langchain.com/en/latest/agents/langchain.agents.conversational.base.ConversationalAgent.html
e4d60ef36c03-2
say to the Human, or if you do not need to use a tool, you MUST use 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) → PromptTemplate[source]¶
https://api.python.langchain.com/en/latest/agents/langchain.agents.conversational.base.ConversationalAgent.html
e4d60ef36c03-3
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 human output. input_variables – List of input variables the final prompt will expect. Returns A PromptTemplate with the template assembled from the pieces here. dict(**kwargs: Any) → Dict¶ Return dictionary representation of agent.
https://api.python.langchain.com/en/latest/agents/langchain.agents.conversational.base.ConversationalAgent.html
e4d60ef36c03-4
classmethod from_llm_and_tools(llm: BaseLanguageModel, tools: Sequence[BaseTool], callback_manager: Optional[BaseCallbackManager] = None, output_parser: Optional[AgentOutputParser] = None, 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 topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.\n\nAssistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge 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\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 just want to have a conversation about a particular topic, Assistant is here to assist.\n\nTOOLS:\n------\n\nAssistant has access to the following tools:', suffix: str = 'Begin!\n\nPrevious conversation history:\n{chat_history}\n\nNew input: {input}\n{agent_scratchpad}', format_instructions: str = 'To use a tool, please use the following format:\n\n```\nThought: Do I need to use a tool? Yes\nAction: the action to take, should be one of [{tool_names}]\nAction Input: the input to the action\nObservation: the result of the
https://api.python.langchain.com/en/latest/agents/langchain.agents.conversational.base.ConversationalAgent.html
e4d60ef36c03-5
Input: the input to the action\nObservation: the result of the action\n```\n\nWhen you have a response to say to the Human, or if you do not need to use a tool, you MUST use 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) → Agent[source]¶
https://api.python.langchain.com/en/latest/agents/langchain.agents.conversational.base.ConversationalAgent.html
e4d60ef36c03-6
Construct an agent from an LLM and tools. get_allowed_tools() → Optional[List[str]]¶ get_full_inputs(intermediate_steps: List[Tuple[AgentAction, str]], **kwargs: Any) → Dict[str, Any]¶ Create the full inputs for the LLMChain from intermediate steps. plan(intermediate_steps: List[Tuple[AgentAction, str]], callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, **kwargs: Any) → Union[AgentAction, AgentFinish]¶ 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[AgentAction, str]], **kwargs: Any) → AgentFinish¶ Return response when agent has been stopped due to max iterations. save(file_path: Union[Path, str]) → None¶ 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¶ validator validate_prompt  »  all fields¶ Validate that prompt matches format. property llm_prefix: str¶ Prefix to append the llm call with. property observation_prefix: str¶ Prefix to append the observation with. property return_values: List[str]¶ Return values of the agent.
https://api.python.langchain.com/en/latest/agents/langchain.agents.conversational.base.ConversationalAgent.html
d455fd75da8f-0
langchain.agents.agent_toolkits.pandas.base.create_pandas_dataframe_agent¶ langchain.agents.agent_toolkits.pandas.base.create_pandas_dataframe_agent(llm: BaseLanguageModel, df: Any, agent_type: AgentType = AgentType.ZERO_SHOT_REACT_DESCRIPTION, callback_manager: Optional[BaseCallbackManager] = None, prefix: Optional[str] = None, suffix: Optional[str] = None, input_variables: Optional[List[str]] = None, verbose: bool = False, return_intermediate_steps: bool = False, max_iterations: Optional[int] = 15, max_execution_time: Optional[float] = None, early_stopping_method: str = 'force', agent_executor_kwargs: Optional[Dict[str, Any]] = None, include_df_in_prompt: Optional[bool] = True, **kwargs: Dict[str, Any]) → AgentExecutor[source]¶ Construct a pandas agent from an LLM and dataframe.
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_toolkits.pandas.base.create_pandas_dataframe_agent.html
20def99d4375-0
langchain.agents.conversational_chat.output_parser.ConvoOutputParser¶ class langchain.agents.conversational_chat.output_parser.ConvoOutputParser[source]¶ Bases: AgentOutputParser Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input data cannot be parsed to form a valid model. dict(**kwargs: Any) → Dict¶ Return dictionary representation of output parser. get_format_instructions() → str[source]¶ Instructions on how the LLM output should be formatted. parse(text: str) → Union[AgentAction, AgentFinish][source]¶ Parse text into agent action/finish. parse_result(result: List[Generation]) → T¶ Parse LLM Result. parse_with_prompt(completion: str, prompt: PromptValue) → Any¶ Optional method to parse the output of an LLM call with a prompt. The prompt is largely provided in the event the OutputParser wants to retry or fix the output in some way, and needs information from the prompt to do so. Parameters completion – output of language model prompt – prompt value Returns structured output to_json() → Union[SerializedConstructor, SerializedNotImplemented]¶ to_json_not_implemented() → SerializedNotImplemented¶ property lc_attributes: Dict¶ Return a list of attribute names that should be included in the serialized kwargs. These attributes must be accepted by the constructor. property lc_namespace: List[str]¶ Return the namespace of the langchain object. eg. [“langchain”, “llms”, “openai”] property lc_secrets: Dict[str, str]¶ Return a map of constructor argument names to secret ids. eg. {“openai_api_key”: “OPENAI_API_KEY”} property lc_serializable: bool¶ Return whether or not the class is serializable.
https://api.python.langchain.com/en/latest/agents/langchain.agents.conversational_chat.output_parser.ConvoOutputParser.html
20def99d4375-1
property lc_serializable: bool¶ Return whether or not the class is serializable. model Config¶ Bases: object extra = 'ignore'¶
https://api.python.langchain.com/en/latest/agents/langchain.agents.conversational_chat.output_parser.ConvoOutputParser.html
92e37645131b-0
langchain.agents.initialize.initialize_agent¶ langchain.agents.initialize.initialize_agent(tools: Sequence[BaseTool], llm: BaseLanguageModel, agent: Optional[AgentType] = None, callback_manager: Optional[BaseCallbackManager] = None, agent_path: Optional[str] = None, agent_kwargs: Optional[dict] = None, *, tags: Optional[Sequence[str]] = None, **kwargs: Any) → AgentExecutor[source]¶ Load an agent executor given tools and LLM. Parameters tools – List of tools this agent has access to. llm – Language model to use as the agent. agent – Agent type to use. If None and agent_path is also None, will default to AgentType.ZERO_SHOT_REACT_DESCRIPTION. callback_manager – CallbackManager to use. Global callback manager is used if not provided. Defaults to None. agent_path – Path to serialized agent to use. agent_kwargs – Additional key word arguments to pass to the underlying agent tags – Tags to apply to the traced runs. **kwargs – Additional key word arguments passed to the agent executor Returns An agent executor
https://api.python.langchain.com/en/latest/agents/langchain.agents.initialize.initialize_agent.html
5614c193e33e-0
langchain.agents.react.base.ReActTextWorldAgent¶ class langchain.agents.react.base.ReActTextWorldAgent(*, llm_chain: LLMChain, output_parser: AgentOutputParser = None, allowed_tools: Optional[List[str]] = None)[source]¶ Bases: ReActDocstoreAgent Agent for the ReAct TextWorld chain. Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input data cannot be parsed to form a valid model. param allowed_tools: Optional[List[str]] = None¶ param llm_chain: LLMChain [Required]¶ param output_parser: langchain.agents.agent.AgentOutputParser [Optional]¶ async aplan(intermediate_steps: List[Tuple[AgentAction, str]], callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, **kwargs: Any) → Union[AgentAction, AgentFinish]¶ 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. classmethod create_prompt(tools: Sequence[BaseTool]) → BasePromptTemplate[source]¶ Return default prompt. dict(**kwargs: Any) → Dict¶ Return dictionary representation of agent. classmethod from_llm_and_tools(llm: BaseLanguageModel, tools: Sequence[BaseTool], callback_manager: Optional[BaseCallbackManager] = None, output_parser: Optional[AgentOutputParser] = None, **kwargs: Any) → Agent¶ Construct an agent from an LLM and tools. get_allowed_tools() → Optional[List[str]]¶ get_full_inputs(intermediate_steps: List[Tuple[AgentAction, str]], **kwargs: Any) → Dict[str, Any]¶
https://api.python.langchain.com/en/latest/agents/langchain.agents.react.base.ReActTextWorldAgent.html
5614c193e33e-1
Create the full inputs for the LLMChain from intermediate steps. plan(intermediate_steps: List[Tuple[AgentAction, str]], callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, **kwargs: Any) → Union[AgentAction, AgentFinish]¶ 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[AgentAction, str]], **kwargs: Any) → AgentFinish¶ Return response when agent has been stopped due to max iterations. save(file_path: Union[Path, str]) → None¶ 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¶ validator validate_prompt  »  all fields¶ Validate that prompt matches format. property llm_prefix: str¶ Prefix to append the LLM call with. property observation_prefix: str¶ Prefix to append the observation with. property return_values: List[str]¶ Return values of the agent.
https://api.python.langchain.com/en/latest/agents/langchain.agents.react.base.ReActTextWorldAgent.html
e1457e8e778c-0
langchain.agents.agent_toolkits.openapi.toolkit.RequestsToolkit¶ class langchain.agents.agent_toolkits.openapi.toolkit.RequestsToolkit(*, requests_wrapper: TextRequestsWrapper)[source]¶ Bases: BaseToolkit Toolkit for making requests. Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input data cannot be parsed to form a valid model. param requests_wrapper: langchain.requests.TextRequestsWrapper [Required]¶ get_tools() → List[BaseTool][source]¶ Return a list of tools.
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_toolkits.openapi.toolkit.RequestsToolkit.html
ae7d3536e8ea-0
langchain.agents.agent_toolkits.openapi.planner.RequestsGetToolWithParsing¶ class langchain.agents.agent_toolkits.openapi.planner.RequestsGetToolWithParsing(*, name: str = 'requests_get', description: str = 'Use this to GET content from a website.\nInput to the tool should be a json string with 3 keys: "url", "params" and "output_instructions".\nThe value of "url" should be a string. \nThe value of "params" should be a dict of the needed and available parameters from the OpenAPI spec related to the endpoint. \nIf parameters are not needed, or not available, leave it empty.\nThe value of "output_instructions" should be instructions on what information to extract from the response, \nfor example the id(s) for a resource(s) that the GET request fetches.\n', args_schema: Optional[Type[BaseModel]] = None, return_direct: bool = False, verbose: bool = False, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, callback_manager: Optional[BaseCallbackManager] = None, handle_tool_error: Optional[Union[bool, str, Callable[[ToolException], str]]] = False, requests_wrapper: TextRequestsWrapper, response_length: Optional[int] = 5000, llm_chain: LLMChain = None)[source]¶ Bases: BaseRequestsTool, BaseTool Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input data cannot be parsed to form a valid model. param args_schema: Optional[Type[BaseModel]] = None¶ Pydantic model class to validate and parse the tool’s input arguments. param callback_manager: Optional[BaseCallbackManager] = None¶ Deprecated. Please use callbacks instead. param callbacks: Callbacks = None¶
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_toolkits.openapi.planner.RequestsGetToolWithParsing.html
ae7d3536e8ea-1
Deprecated. Please use callbacks instead. param callbacks: Callbacks = None¶ Callbacks to be called during tool execution. param description: str = 'Use this to GET content from a website.\nInput to the tool should be a json string with 3 keys: "url", "params" and "output_instructions".\nThe value of "url" should be a string. \nThe value of "params" should be a dict of the needed and available parameters from the OpenAPI spec related to the endpoint. \nIf parameters are not needed, or not available, leave it empty.\nThe value of "output_instructions" should be instructions on what information to extract from the response, \nfor example the id(s) for a resource(s) that the GET request fetches.\n'¶ Used to tell the model how/when/why to use the tool. You can provide few-shot examples as a part of the description. param handle_tool_error: Optional[Union[bool, str, Callable[[ToolException], str]]] = False¶ Handle the content of the ToolException thrown. param llm_chain: langchain.chains.llm.LLMChain [Optional]¶ param name: str = 'requests_get'¶ The unique name of the tool that clearly communicates its purpose. param requests_wrapper: TextRequestsWrapper [Required]¶ param response_length: Optional[int] = 5000¶ param return_direct: bool = False¶ Whether to return the tool’s output directly. Setting this to True means that after the tool is called, the AgentExecutor will stop looping. param verbose: bool = False¶ Whether to log the tool’s progress. __call__(tool_input: str, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None) → str¶ Make tool callable.
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_toolkits.openapi.planner.RequestsGetToolWithParsing.html
ae7d3536e8ea-2
Make tool callable. async arun(tool_input: Union[str, Dict], verbose: Optional[bool] = None, start_color: Optional[str] = 'green', color: Optional[str] = 'green', callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, **kwargs: Any) → Any¶ Run the tool asynchronously. validator raise_deprecation  »  all fields¶ Raise deprecation warning if callback_manager is used. run(tool_input: Union[str, Dict], verbose: Optional[bool] = None, start_color: Optional[str] = 'green', color: Optional[str] = 'green', callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, **kwargs: Any) → Any¶ Run the tool. property args: dict¶ property is_single_input: bool¶ Whether the tool only accepts a single input. model Config¶ Bases: object Configuration for this pydantic object. arbitrary_types_allowed = True¶ extra = 'forbid'¶
https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_toolkits.openapi.planner.RequestsGetToolWithParsing.html
d20c76a2fb42-0
langchain.math_utils.cosine_similarity¶ langchain.math_utils.cosine_similarity(X: Union[List[List[float]], List[ndarray], ndarray], Y: Union[List[List[float]], List[ndarray], ndarray]) → ndarray[source]¶ Row-wise cosine similarity between two equal-width matrices.
https://api.python.langchain.com/en/latest/math_utils/langchain.math_utils.cosine_similarity.html
692ce8f9f48c-0
langchain.math_utils.cosine_similarity_top_k¶ langchain.math_utils.cosine_similarity_top_k(X: Union[List[List[float]], List[ndarray], ndarray], Y: Union[List[List[float]], List[ndarray], ndarray], top_k: Optional[int] = 5, score_threshold: Optional[float] = None) → Tuple[List[Tuple[int, int]], List[float]][source]¶ Row-wise cosine similarity with optional top-k and score threshold filtering. Parameters X – Matrix. Y – Matrix, same width as X. top_k – Max number of results to return. score_threshold – Minimum cosine similarity of results. Returns Tuple of two lists. First contains two-tuples of indices (X_idx, Y_idx),second contains corresponding cosine similarities.
https://api.python.langchain.com/en/latest/math_utils/langchain.math_utils.cosine_similarity_top_k.html
f56963fc17e4-0
langchain.graphs.networkx_graph.parse_triples¶ langchain.graphs.networkx_graph.parse_triples(knowledge_str: str) → List[KnowledgeTriple][source]¶ Parse knowledge triples from the knowledge string.
https://api.python.langchain.com/en/latest/graphs/langchain.graphs.networkx_graph.parse_triples.html
afee68401d88-0
langchain.graphs.networkx_graph.get_entities¶ langchain.graphs.networkx_graph.get_entities(entity_str: str) → List[str][source]¶ Extract entities from entity string.
https://api.python.langchain.com/en/latest/graphs/langchain.graphs.networkx_graph.get_entities.html
cb8be65c4575-0
langchain.graphs.networkx_graph.KnowledgeTriple¶ class langchain.graphs.networkx_graph.KnowledgeTriple(subject: str, predicate: str, object_: str)[source]¶ Bases: NamedTuple A triple in the graph. Create new instance of KnowledgeTriple(subject, predicate, object_) Methods __init__() count(value, /) Return number of occurrences of value. from_string(triple_string) Create a KnowledgeTriple from a string. index(value[, start, stop]) Return first index of value. Attributes object_ Alias for field number 2 predicate Alias for field number 1 subject Alias for field number 0 count(value, /)¶ Return number of occurrences of value. classmethod from_string(triple_string: str) → KnowledgeTriple[source]¶ Create a KnowledgeTriple from a string. index(value, start=0, stop=9223372036854775807, /)¶ Return first index of value. Raises ValueError if the value is not present. object_: str¶ Alias for field number 2 predicate: str¶ Alias for field number 1 subject: str¶ Alias for field number 0
https://api.python.langchain.com/en/latest/graphs/langchain.graphs.networkx_graph.KnowledgeTriple.html
1ea0cf163399-0
langchain.formatting.StrictFormatter¶ class langchain.formatting.StrictFormatter[source]¶ Bases: Formatter A subclass of formatter that checks for extra keys. Methods __init__() check_unused_args(used_args, args, kwargs) Check to see if extra parameters are passed. convert_field(value, conversion) format(format_string, /, *args, **kwargs) format_field(value, format_spec) get_field(field_name, args, kwargs) get_value(key, args, kwargs) parse(format_string) validate_input_variables(format_string, ...) vformat(format_string, args, kwargs) Check that no arguments are provided. check_unused_args(used_args: Sequence[Union[int, str]], args: Sequence, kwargs: Mapping[str, Any]) → None[source]¶ Check to see if extra parameters are passed. convert_field(value, conversion)¶ format(format_string, /, *args, **kwargs)¶ format_field(value, format_spec)¶ get_field(field_name, args, kwargs)¶ get_value(key, args, kwargs)¶ parse(format_string)¶ validate_input_variables(format_string: str, input_variables: List[str]) → None[source]¶ vformat(format_string: str, args: Sequence, kwargs: Mapping[str, Any]) → str[source]¶ Check that no arguments are provided.
https://api.python.langchain.com/en/latest/formatting/langchain.formatting.StrictFormatter.html
c48fab993cdb-0
All modules for which code is available langchain.agents.agent langchain.agents.agent_toolkits.azure_cognitive_services.toolkit langchain.agents.agent_toolkits.base langchain.agents.agent_toolkits.csv.base langchain.agents.agent_toolkits.file_management.toolkit langchain.agents.agent_toolkits.gmail.toolkit langchain.agents.agent_toolkits.jira.toolkit langchain.agents.agent_toolkits.json.base langchain.agents.agent_toolkits.json.toolkit langchain.agents.agent_toolkits.nla.tool langchain.agents.agent_toolkits.nla.toolkit langchain.agents.agent_toolkits.office365.toolkit langchain.agents.agent_toolkits.openapi.base langchain.agents.agent_toolkits.openapi.planner langchain.agents.agent_toolkits.openapi.spec langchain.agents.agent_toolkits.openapi.toolkit langchain.agents.agent_toolkits.pandas.base langchain.agents.agent_toolkits.playwright.toolkit langchain.agents.agent_toolkits.powerbi.base langchain.agents.agent_toolkits.powerbi.chat_base langchain.agents.agent_toolkits.powerbi.toolkit langchain.agents.agent_toolkits.python.base langchain.agents.agent_toolkits.spark.base langchain.agents.agent_toolkits.spark_sql.base langchain.agents.agent_toolkits.spark_sql.toolkit langchain.agents.agent_toolkits.sql.base langchain.agents.agent_toolkits.sql.toolkit langchain.agents.agent_toolkits.vectorstore.base langchain.agents.agent_toolkits.vectorstore.toolkit langchain.agents.agent_toolkits.zapier.toolkit langchain.agents.agent_types langchain.agents.chat.base langchain.agents.chat.output_parser langchain.agents.conversational.base langchain.agents.conversational.output_parser langchain.agents.conversational_chat.base langchain.agents.conversational_chat.output_parser
https://api.python.langchain.com/en/latest/_modules/index.html
c48fab993cdb-1
langchain.agents.conversational_chat.output_parser langchain.agents.initialize langchain.agents.load_tools langchain.agents.loading langchain.agents.mrkl.base langchain.agents.mrkl.output_parser langchain.agents.openai_functions_agent.base langchain.agents.openai_functions_multi_agent.base langchain.agents.react.base langchain.agents.react.output_parser langchain.agents.schema langchain.agents.self_ask_with_search.base langchain.agents.self_ask_with_search.output_parser langchain.agents.structured_chat.base langchain.agents.structured_chat.output_parser langchain.agents.tools langchain.agents.utils langchain.base_language langchain.cache langchain.callbacks.aim_callback langchain.callbacks.argilla_callback langchain.callbacks.arize_callback langchain.callbacks.arthur_callback langchain.callbacks.base langchain.callbacks.clearml_callback langchain.callbacks.comet_ml_callback langchain.callbacks.file langchain.callbacks.flyte_callback langchain.callbacks.human langchain.callbacks.infino_callback langchain.callbacks.manager langchain.callbacks.mlflow_callback langchain.callbacks.openai_info langchain.callbacks.promptlayer_callback langchain.callbacks.stdout langchain.callbacks.streaming_aiter langchain.callbacks.streaming_aiter_final_only langchain.callbacks.streaming_stdout langchain.callbacks.streaming_stdout_final_only langchain.callbacks.streamlit.__init__ langchain.callbacks.streamlit.mutable_expander langchain.callbacks.streamlit.streamlit_callback_handler langchain.callbacks.tracers.base langchain.callbacks.tracers.evaluation langchain.callbacks.tracers.langchain langchain.callbacks.tracers.langchain_v1 langchain.callbacks.tracers.run_collector langchain.callbacks.tracers.schemas langchain.callbacks.tracers.stdout langchain.callbacks.tracers.wandb langchain.callbacks.utils langchain.callbacks.wandb_callback
https://api.python.langchain.com/en/latest/_modules/index.html
c48fab993cdb-2
langchain.callbacks.utils langchain.callbacks.wandb_callback langchain.callbacks.whylabs_callback langchain.chains.api.base langchain.chains.api.openapi.chain langchain.chains.api.openapi.requests_chain langchain.chains.api.openapi.response_chain langchain.chains.base langchain.chains.combine_documents.base langchain.chains.combine_documents.map_reduce langchain.chains.combine_documents.map_rerank langchain.chains.combine_documents.refine langchain.chains.combine_documents.stuff langchain.chains.constitutional_ai.base langchain.chains.constitutional_ai.models langchain.chains.conversation.base langchain.chains.conversational_retrieval.base langchain.chains.flare.base langchain.chains.flare.prompts langchain.chains.graph_qa.base langchain.chains.graph_qa.cypher langchain.chains.graph_qa.kuzu langchain.chains.graph_qa.nebulagraph langchain.chains.hyde.base langchain.chains.llm langchain.chains.llm_bash.base langchain.chains.llm_bash.prompt langchain.chains.llm_checker.base langchain.chains.llm_math.base langchain.chains.llm_requests langchain.chains.llm_summarization_checker.base langchain.chains.loading langchain.chains.mapreduce langchain.chains.moderation langchain.chains.natbot.base langchain.chains.natbot.crawler langchain.chains.openai_functions.citation_fuzzy_match langchain.chains.openai_functions.extraction langchain.chains.openai_functions.openapi langchain.chains.openai_functions.qa_with_structure langchain.chains.openai_functions.tagging langchain.chains.openai_functions.utils langchain.chains.pal.base langchain.chains.prompt_selector
https://api.python.langchain.com/en/latest/_modules/index.html
c48fab993cdb-3
langchain.chains.pal.base langchain.chains.prompt_selector langchain.chains.qa_generation.base langchain.chains.qa_with_sources.base langchain.chains.qa_with_sources.loading langchain.chains.qa_with_sources.retrieval langchain.chains.qa_with_sources.vector_db langchain.chains.query_constructor.base langchain.chains.query_constructor.ir langchain.chains.query_constructor.parser langchain.chains.query_constructor.schema langchain.chains.question_answering.__init__ langchain.chains.retrieval_qa.base langchain.chains.router.base langchain.chains.router.embedding_router langchain.chains.router.llm_router langchain.chains.router.multi_prompt langchain.chains.router.multi_retrieval_qa langchain.chains.sequential langchain.chains.sql_database.base langchain.chains.summarize.__init__ langchain.chains.transform langchain.chat_models.anthropic langchain.chat_models.azure_openai langchain.chat_models.base langchain.chat_models.fake langchain.chat_models.google_palm langchain.chat_models.openai langchain.chat_models.promptlayer_openai langchain.chat_models.vertexai langchain.client.runner_utils langchain.docstore.arbitrary_fn langchain.docstore.base langchain.docstore.in_memory langchain.docstore.wikipedia langchain.document_loaders.acreom langchain.document_loaders.airbyte_json langchain.document_loaders.airtable langchain.document_loaders.apify_dataset langchain.document_loaders.arxiv langchain.document_loaders.azlyrics langchain.document_loaders.azure_blob_storage_container langchain.document_loaders.azure_blob_storage_file langchain.document_loaders.base langchain.document_loaders.bibtex langchain.document_loaders.bigquery langchain.document_loaders.bilibili
https://api.python.langchain.com/en/latest/_modules/index.html
c48fab993cdb-4
langchain.document_loaders.bigquery langchain.document_loaders.bilibili langchain.document_loaders.blackboard langchain.document_loaders.blob_loaders.file_system langchain.document_loaders.blob_loaders.schema langchain.document_loaders.blob_loaders.youtube_audio langchain.document_loaders.blockchain langchain.document_loaders.chatgpt langchain.document_loaders.college_confidential langchain.document_loaders.confluence langchain.document_loaders.conllu langchain.document_loaders.csv_loader langchain.document_loaders.dataframe langchain.document_loaders.diffbot langchain.document_loaders.directory langchain.document_loaders.discord langchain.document_loaders.docugami langchain.document_loaders.duckdb_loader langchain.document_loaders.email langchain.document_loaders.embaas langchain.document_loaders.epub langchain.document_loaders.evernote langchain.document_loaders.excel langchain.document_loaders.facebook_chat langchain.document_loaders.fauna langchain.document_loaders.figma langchain.document_loaders.gcs_directory langchain.document_loaders.gcs_file langchain.document_loaders.generic langchain.document_loaders.git langchain.document_loaders.gitbook langchain.document_loaders.github langchain.document_loaders.googledrive langchain.document_loaders.gutenberg langchain.document_loaders.helpers langchain.document_loaders.hn langchain.document_loaders.html langchain.document_loaders.html_bs langchain.document_loaders.hugging_face_dataset langchain.document_loaders.ifixit langchain.document_loaders.image langchain.document_loaders.image_captions langchain.document_loaders.imsdb langchain.document_loaders.iugu langchain.document_loaders.joplin langchain.document_loaders.json_loader langchain.document_loaders.larksuite
https://api.python.langchain.com/en/latest/_modules/index.html
c48fab993cdb-5
langchain.document_loaders.json_loader langchain.document_loaders.larksuite langchain.document_loaders.markdown langchain.document_loaders.mastodon langchain.document_loaders.max_compute langchain.document_loaders.mediawikidump langchain.document_loaders.merge langchain.document_loaders.mhtml langchain.document_loaders.modern_treasury langchain.document_loaders.notebook langchain.document_loaders.notion langchain.document_loaders.notiondb langchain.document_loaders.obsidian langchain.document_loaders.odt langchain.document_loaders.onedrive langchain.document_loaders.onedrive_file langchain.document_loaders.open_city_data langchain.document_loaders.org_mode langchain.document_loaders.parsers.audio langchain.document_loaders.parsers.generic langchain.document_loaders.parsers.grobid langchain.document_loaders.parsers.html.bs4 langchain.document_loaders.parsers.language.code_segmenter langchain.document_loaders.parsers.language.javascript langchain.document_loaders.parsers.language.language_parser langchain.document_loaders.parsers.language.python langchain.document_loaders.parsers.pdf langchain.document_loaders.parsers.registry langchain.document_loaders.parsers.txt langchain.document_loaders.pdf langchain.document_loaders.powerpoint langchain.document_loaders.psychic langchain.document_loaders.pyspark_dataframe langchain.document_loaders.python langchain.document_loaders.readthedocs langchain.document_loaders.recursive_url_loader langchain.document_loaders.reddit langchain.document_loaders.roam langchain.document_loaders.rst langchain.document_loaders.rtf langchain.document_loaders.s3_directory langchain.document_loaders.s3_file langchain.document_loaders.sitemap langchain.document_loaders.slack_directory langchain.document_loaders.snowflake_loader
https://api.python.langchain.com/en/latest/_modules/index.html
c48fab993cdb-6
langchain.document_loaders.slack_directory langchain.document_loaders.snowflake_loader langchain.document_loaders.spreedly langchain.document_loaders.srt langchain.document_loaders.stripe langchain.document_loaders.telegram langchain.document_loaders.tencent_cos_directory langchain.document_loaders.tencent_cos_file langchain.document_loaders.text langchain.document_loaders.tomarkdown langchain.document_loaders.toml langchain.document_loaders.trello langchain.document_loaders.twitter langchain.document_loaders.unstructured langchain.document_loaders.url langchain.document_loaders.url_playwright langchain.document_loaders.url_selenium langchain.document_loaders.weather langchain.document_loaders.web_base langchain.document_loaders.whatsapp_chat langchain.document_loaders.wikipedia langchain.document_loaders.word_document langchain.document_loaders.xml langchain.document_loaders.youtube langchain.document_transformers langchain.embeddings.aleph_alpha langchain.embeddings.base langchain.embeddings.bedrock langchain.embeddings.cohere langchain.embeddings.dashscope langchain.embeddings.deepinfra langchain.embeddings.elasticsearch langchain.embeddings.embaas langchain.embeddings.fake langchain.embeddings.google_palm langchain.embeddings.huggingface langchain.embeddings.huggingface_hub langchain.embeddings.jina langchain.embeddings.llamacpp langchain.embeddings.minimax langchain.embeddings.modelscope_hub langchain.embeddings.mosaicml langchain.embeddings.octoai_embeddings langchain.embeddings.openai langchain.embeddings.sagemaker_endpoint langchain.embeddings.self_hosted langchain.embeddings.self_hosted_hugging_face langchain.embeddings.tensorflow_hub langchain.embeddings.vertexai langchain.env
https://api.python.langchain.com/en/latest/_modules/index.html