From ad8c347088bc8e20f62725a89dfcb5ed93372d30 Mon Sep 17 00:00:00 2001 From: Tine Kondo Date: Wed, 26 Jun 2024 21:33:21 +0200 Subject: [PATCH] fix: add missing installation of `langchain-community` package in some steps, fix some imports (#4) --- steps/02-langchain-solution/solution.ipynb | 17 +++++++++++++++-- .../03-langchain-chain-solution/solution.ipynb | 6 +++--- .../solution.ipynb | 6 +++--- steps/05-langchain-llms-solution/solution.ipynb | 4 ++-- .../solution.ipynb | 2 +- 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/steps/02-langchain-solution/solution.ipynb b/steps/02-langchain-solution/solution.ipynb index 866ce5b..75ff981 100644 --- a/steps/02-langchain-solution/solution.ipynb +++ b/steps/02-langchain-solution/solution.ipynb @@ -24,7 +24,20 @@ }, "outputs": [], "source": [ - "pip install langchain" + "pip install langchain # contains core tools for building llm applications, chaining LLMs, prompt management, output parsers, etc\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "vscode": { + "languageId": "shellscript" + } + }, + "outputs": [], + "source": [ + "pip install langchain-community # contains community-contributed extensions and utilities for LangChain, like Ollama, OpenAI LLMs, etc" ] }, { @@ -41,7 +54,7 @@ "outputs": [], "source": [ "# Use ollama to connect local llm\n", - "from langchain_community.llms import Ollama" + "from langchain_community.llms.ollama import Ollama" ] }, { diff --git a/steps/03-langchain-chain-solution/solution.ipynb b/steps/03-langchain-chain-solution/solution.ipynb index 8f838e5..5cfe4c5 100644 --- a/steps/03-langchain-chain-solution/solution.ipynb +++ b/steps/03-langchain-chain-solution/solution.ipynb @@ -24,7 +24,7 @@ }, "outputs": [], "source": [ - "pip install langchain" + "pip install langchain langchain-community" ] }, { @@ -40,7 +40,7 @@ "metadata": {}, "outputs": [], "source": [ - "from langchain_community.llms import Ollama\n", + "from langchain_community.llms.ollama import Ollama\n", "# pour le prompt de chat\n", "from langchain_core.prompts import PromptTemplate\n", "# pour le parser de sortie\n", @@ -177,7 +177,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.0" + "version": "3.12.4" } }, "nbformat": 4, diff --git a/steps/04-langchain-retrieval-solution/solution.ipynb b/steps/04-langchain-retrieval-solution/solution.ipynb index c786150..49dd3fd 100644 --- a/steps/04-langchain-retrieval-solution/solution.ipynb +++ b/steps/04-langchain-retrieval-solution/solution.ipynb @@ -24,7 +24,7 @@ }, "outputs": [], "source": [ - "pip install langchain faiss-cpu beautifulsoup4" + "pip install langchain langchain-community faiss-cpu beautifulsoup4" ] }, { @@ -46,9 +46,9 @@ "from langchain.text_splitter import RecursiveCharacterTextSplitter\n", "from langchain.chains.combine_documents import create_stuff_documents_chain\n", "from langchain_core.prompts import ChatPromptTemplate\n", - "from langchain_community.llms import Ollama\n", + "from langchain_community.llms.ollama import Ollama\n", "from langchain_core.documents import Document\n", - "from langchain.chains import create_retrieval_chain" + "from langchain.chains.retrieval import create_retrieval_chain" ] }, { diff --git a/steps/05-langchain-llms-solution/solution.ipynb b/steps/05-langchain-llms-solution/solution.ipynb index a0df8f6..678ecda 100644 --- a/steps/05-langchain-llms-solution/solution.ipynb +++ b/steps/05-langchain-llms-solution/solution.ipynb @@ -24,7 +24,7 @@ }, "outputs": [], "source": [ - "pip install langchain" + "pip install langchain langchain-community" ] }, { @@ -40,7 +40,7 @@ "metadata": {}, "outputs": [], "source": [ - "from langchain_community.llms import Ollama\n", + "from langchain_community.llms.ollama import Ollama\n", "from langchain_core.prompts import PromptTemplate\n", "from langchain_core.output_parsers import StrOutputParser\n", "from langchain.callbacks.base import BaseCallbackHandler" diff --git a/steps/06-langchain-assistant-solution/solution.ipynb b/steps/06-langchain-assistant-solution/solution.ipynb index c4f7542..c3c96e3 100644 --- a/steps/06-langchain-assistant-solution/solution.ipynb +++ b/steps/06-langchain-assistant-solution/solution.ipynb @@ -24,7 +24,7 @@ }, "outputs": [], "source": [ - "pip install langchain wikipedia faiss-cpu chromadb" + "pip install langchain langchain-community wikipedia faiss-cpu chromadb" ] }, {