From d0a1c71eda958fceb874a1debaefc2a21c94fc5f Mon Sep 17 00:00:00 2001 From: Ahmed Hathout Date: Mon, 1 Jan 2024 21:38:33 +0000 Subject: [PATCH] Langchain: Fix quickstart doc code not working (#15352) The quickstart doc is missing a few but very simple things that without them, the code does not work. This PR fixes that by - Adding commands to install `tiktoken` and `langchainhub` - Adds a comma between 2 parameters for one of the methods --- docs/docs/get_started/quickstart.mdx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/docs/get_started/quickstart.mdx b/docs/docs/get_started/quickstart.mdx index 509b1fe6b4..8524795061 100644 --- a/docs/docs/get_started/quickstart.mdx +++ b/docs/docs/get_started/quickstart.mdx @@ -223,6 +223,7 @@ First we need to install the required packages for that: ```shell pip install docarray +pip install tiktoken ``` Then we can build our index: @@ -313,7 +314,7 @@ from langchain_core.prompts import MessagesPlaceholder prompt = ChatPromptTemplate.from_messages([ MessagesPlaceholder(variable_name="chat_history"), - ("user", "{input}") + ("user", "{input}"), ("user", "Given the above conversation, generate a search query to look up in order to get information relevant to the conversation") ]) retriever_chain = create_history_aware_retriever(llm, retriever, prompt) @@ -403,6 +404,13 @@ tools = [retriever_tool, search] Now that we have the tools, we can create an agent to use them. We will go over this pretty quickly - for a deeper dive into what exactly is going on, check out the [Agent's Getting Started documentation](/docs/modules/agents) +Install langchain hub first +```bash +pip install langchainhub +``` + +Now we can use it to get a predefined prompt + ```python from langchain.chat_models import ChatOpenAI from langchain import hub