From ce441edd9cee748cce01e17213944c19a9a4c229 Mon Sep 17 00:00:00 2001 From: Harrison Chase Date: Sun, 26 Feb 2023 11:25:16 -0800 Subject: [PATCH] improve docs (#1309) --- .../agents/examples/agent_vectorstore.ipynb | 87 ++++++++++++++++++- 1 file changed, 86 insertions(+), 1 deletion(-) diff --git a/docs/modules/agents/examples/agent_vectorstore.ipynb b/docs/modules/agents/examples/agent_vectorstore.ipynb index 25d7e33d94..3d29f2fdc4 100644 --- a/docs/modules/agents/examples/agent_vectorstore.ipynb +++ b/docs/modules/agents/examples/agent_vectorstore.ipynb @@ -376,10 +376,95 @@ "agent.run(\"Why use ruff over flake8?\")" ] }, + { + "cell_type": "markdown", + "id": "49a0cbbe", + "metadata": {}, + "source": [ + "## Multi-Hop vectorstore reasoning\n", + "\n", + "Because vectorstores are easily usable as tools in agents, it is easy to use answer multi-hop questions that depend on vectorstores using the existing agent framework" + ] + }, + { + "cell_type": "code", + "execution_count": 57, + "id": "d397a233", + "metadata": {}, + "outputs": [], + "source": [ + "tools = [\n", + " Tool(\n", + " name = \"State of Union QA System\",\n", + " func=state_of_union.run,\n", + " description=\"useful for when you need to answer questions about the most recent state of the union address. Input should be a fully formed question, not referencing any obscure pronouns from the conversation before.\"\n", + " ),\n", + " Tool(\n", + " name = \"Ruff QA System\",\n", + " func=ruff.run,\n", + " description=\"useful for when you need to answer questions about ruff (a python linter). Input should be a fully formed question, not referencing any obscure pronouns from the conversation before.\"\n", + " ),\n", + "]" + ] + }, + { + "cell_type": "code", + "execution_count": 58, + "id": "06157240", + "metadata": {}, + "outputs": [], + "source": [ + "# Construct the agent. We will use the default agent type here.\n", + "# See documentation for a full list of options.\n", + "agent = initialize_agent(tools, llm, agent=\"zero-shot-react-description\", verbose=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 59, + "id": "b492b520", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "\n", + "\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n", + "\u001b[32;1m\u001b[1;3m I need to find out what tool ruff uses to run over Jupyter Notebooks, and if the president mentioned it in the state of the union.\n", + "Action: Ruff QA System\n", + "Action Input: What tool does ruff use to run over Jupyter Notebooks?\u001b[0m\n", + "Observation: \u001b[33;1m\u001b[1;3m Ruff is integrated into nbQA, a tool for running linters and code formatters over Jupyter Notebooks. After installing ruff and nbqa, you can run Ruff over a notebook like so: > nbqa ruff Untitled.ipynb\u001b[0m\n", + "Thought:\u001b[32;1m\u001b[1;3m I now need to find out if the president mentioned this tool in the state of the union.\n", + "Action: State of Union QA System\n", + "Action Input: Did the president mention nbQA in the state of the union?\u001b[0m\n", + "Observation: \u001b[36;1m\u001b[1;3m No, the president did not mention nbQA in the state of the union.\u001b[0m\n", + "Thought:\u001b[32;1m\u001b[1;3m I now know the final answer.\n", + "Final Answer: No, the president did not mention nbQA in the state of the union.\u001b[0m\n", + "\n", + "\u001b[1m> Finished chain.\u001b[0m\n" + ] + }, + { + "data": { + "text/plain": [ + "'No, the president did not mention nbQA in the state of the union.'" + ] + }, + "execution_count": 59, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "agent.run(\"What tool does ruff use to run over Jupyter Notebooks? Did the president mention that tool in the state of the union?\")" + ] + }, { "cell_type": "code", "execution_count": null, - "id": "5442de04", + "id": "b3b857d6", "metadata": {}, "outputs": [], "source": []