docs: agent prompt docs (#16105)

This commit is contained in:
Bagatur 2024-01-19 09:19:22 -08:00 committed by GitHub
parent 84bf5787a7
commit 2454fefc53
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 57 additions and 24 deletions

View File

@ -19,10 +19,7 @@ def create_json_chat_agent(
Args:
llm: LLM to use as the agent.
tools: Tools this agent has access to.
prompt: The prompt to use, must have input keys:
`tools`: contains descriptions and arguments for each tool.
`tool_names`: contains all tool names.
`agent_scratchpad`: contains previous agent actions and tool outputs.
prompt: The prompt to use. See Prompt section below for more.
Returns:
A Runnable sequence representing an agent. It takes as input all the same input
@ -58,7 +55,14 @@ def create_json_chat_agent(
}
)
Creating prompt example:
Prompt:
The prompt must have input keys:
* `tools`: contains descriptions and arguments for each tool.
* `tool_names`: contains all tool names.
* `agent_scratchpad`: must be a MessagesPlaceholder. Contains previous agent actions and tool outputs as messages.
Here's an example:
.. code-block:: python

View File

@ -239,8 +239,7 @@ def create_openai_functions_agent(
so either be an OpenAI model that supports that or a wrapper of
a different model that adds in equivalent support.
tools: Tools this agent has access to.
prompt: The prompt to use, must have input key `agent_scratchpad`, which will
contain agent action and tool output messages.
prompt: The prompt to use. See Prompt section below for more.
Returns:
A Runnable sequence representing an agent. It takes as input all the same input
@ -278,7 +277,13 @@ def create_openai_functions_agent(
}
)
Creating prompt example:
Prompt:
The agent prompt must have an `agent_scratchpad` key that is a
``MessagesPlaceholder``. Intermediate agent actions and tool output
messages will be passed in here.
Here's an example:
.. code-block:: python

View File

@ -20,8 +20,8 @@ def create_openai_tools_agent(
Args:
llm: LLM to use as the agent.
tools: Tools this agent has access to.
prompt: The prompt to use, must have input key `agent_scratchpad`, which will
contain agent action and tool output messages.
prompt: The prompt to use. See Prompt section below for more on the expected
input variables.
Returns:
A Runnable sequence representing an agent. It takes as input all the same input
@ -57,7 +57,13 @@ def create_openai_tools_agent(
}
)
Creating prompt example:
Prompt:
The agent prompt must have an `agent_scratchpad` key that is a
``MessagesPlaceholder``. Intermediate agent actions and tool output
messages will be passed in here.
Here's an example:
.. code-block:: python

View File

@ -20,11 +20,7 @@ def create_react_agent(
Args:
llm: LLM to use as the agent.
tools: Tools this agent has access to.
prompt: The prompt to use, must have input keys:
`tools`: contains descriptions and arguments for each tool.
`tool_names`: contains all tool names.
`agent_scratchpad`: contains previous agent actions and tool outputs.
prompt: The prompt to use. See Prompt section below for more.
Returns:
A Runnable sequence representing an agent. It takes as input all the same input
@ -59,7 +55,14 @@ def create_react_agent(
}
)
Creating prompt example:
Prompt:
The prompt must have input keys:
* `tools`: contains descriptions and arguments for each tool.
* `tool_names`: contains all tool names.
* `agent_scratchpad`: contains previous agent actions and tool outputs as a string.
Here's an example:
.. code-block:: python

View File

@ -121,7 +121,12 @@ def create_self_ask_with_search_agent(
agent_executor.invoke({"input": "hi"})
Create prompt example:
Prompt:
The prompt must have input key `agent_scratchpad` which will
contain agent actions and tool outputs as a string.
Here's an example:
.. code-block:: python

View File

@ -158,10 +158,7 @@ def create_structured_chat_agent(
Args:
llm: LLM to use as the agent.
tools: Tools this agent has access to.
prompt: The prompt to use, must have input keys
`tools`: contains descriptions and arguments for each tool.
`tool_names`: contains all tool names.
`agent_scratchpad`: contains previous agent actions and tool outputs.
prompt: The prompt to use. See Prompt section below for more.
Returns:
A Runnable sequence representing an agent. It takes as input all the same input
@ -197,7 +194,14 @@ def create_structured_chat_agent(
}
)
Creating prompt example:
Prompt:
The prompt must have input keys:
* `tools`: contains descriptions and arguments for each tool.
* `tool_names`: contains all tool names.
* `agent_scratchpad`: contains previous agent actions and tool outputs as a string.
Here's an example:
.. code-block:: python

View File

@ -152,7 +152,13 @@ def create_xml_agent(
}
)
Creating prompt example:
Prompt:
The prompt must have input keys:
* `tools`: contains descriptions for each tool.
* `agent_scratchpad`: contains previous agent actions and tool outputs as an XML string.
Here's an example:
.. code-block:: python