The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
Add documentation for custom prompts for Agents (#631) (#640)
Harrison Chase95720adff5cd
diff --git a/docs/modules/agents/examples/custom_agent.ipynb b/docs/modules/agents/examples/custom_agent.ipynbindex 3b7bcb8bac..780f2b2805 100644--- a/docs/modules/agents/examples/custom_agent.ipynb+++ b/docs/modules/agents/examples/custom_agent.ipynb@@ -133,6 +133,17 @@"print(prompt.template)"]},+ {+ "attachments": {},+ "cell_type": "markdown",+ "id": "5e028e6d",+ "metadata": {},+ "source": [+ "Note that we are able to feed agents a self-defined prompt template, i.e. not restricted to the prompt generated by the `create_prompt` function, assuming it meets the agent's requirements. \n",+ "\n",+ "For example, for `ZeroShotAgent`, we will need to ensure that it meets the following requirements. There should a string starting with \"Action:\" and a following string starting with \"Action Input:\", and both should be separated by a newline.\n"+ ]+ },{"cell_type": "code","execution_count": 16,@@ -350,7 +361,7 @@],"metadata": {"kernelspec": {- "display_name": "Python 3.9.0 64-bit ('llm-env')",+ "display_name": "Python 3","language": "python","name": "python3"},@@ -364,11 +375,11 @@"name": "python","nbconvert_exporter": "python","pygments_lexer": "ipython3",- "version": "3.9.0"+ "version": "3.8.12 (default, Feb 15 2022, 17:41:09) \n[Clang 12.0.5 (clang-1205.0.22.11)]"},"vscode": {"interpreter": {- "hash": "b1677b440931f40d89ef8be7bf03acb108ce003de0ac9b18e8d43753ea2e7103"+ "hash": "18784188d7ecd866c0586ac068b02361a6896dc3a29b64f5cc957f09c590acef"}}},diff --git a/langchain/agents/mrkl/base.py b/langchain/agents/mrkl/base.pyindex 2a7e264c9b..76af6dc7e5 100644--- a/langchain/agents/mrkl/base.py+++ b/langchain/agents/mrkl/base.py@@ -28,7 +28,13 @@ class ChainConfig(NamedTuple):def get_action_and_input(llm_output: str) -> Tuple[str, str]:- """Parse out the action and input from the LLM output."""+ """Parse out the action and input from the LLM output.++ Note: if you're specifying a custom prompt for the ZeroShotAgent,+ you will need to ensure that it meets the following Regex requirements.+ The string starting with "Action:" and the following string starting+ with "Action Input:" should be separated by a newline.+ """if FINAL_ANSWER_ACTION in llm_output:return "Final Answer", llm_output.split(FINAL_ANSWER_ACTION)[-1].strip()regex = r"Action: (.*?)\nAction Input: (.*)"