This repo contains examples of using LangChain
In particular, all main modules of LangChain are demonstrated in the notebooks.
1_MODEL_IO.ipynb
— Building blocks for interfacing with LLMs and Chat Models, using Prompt Templates and Output Parsers.2_MEMORY.ipynb
— Using Memory buffers or summaries to store information during conversations, since LLMs are stateless.3_CHAINS.ipynb
— Create more complex applications by connecting together multiple LLMs components into a Chain.4_AGENTS.ipynb
— Create Agents that can leverage LLMs to interact with other Tools, from Wikipedia to Wolfram Alpha, from Google Search to Yahoo Finance.5_RETRIEVAL.ipynb
— Implement Retrieval systems for running Question Answering over collections of documents or graph databases like knowledge graphs.
First of all you need to define some variables for the environment that will be used in the notebooks.
We do this with a .env
file, so first copy the provided example .env.example
to .env
and fill in the values.
cp .env.example .env
# And now open ".env" with your favorite editor and fill in the values!
Then, you need to create a virtual environment and install the Python requirements.
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
Finally, if you want to run the Neo4j example (this is completely optional!!) in 5_RETRIEVAL.ipynb
, you need to have a Neo4j instance running.
To do so, you first need to install Docker, make sure that you have the Docker daemon running, and then run the following command.
docker run \
--name neo4j \
-p 7474:7474 -p 7687:7687 \
-d \
-e NEO4J_AUTH=neo4j/pleaseletmein \
-e NEO4J_PLUGINS=\[\"apoc\"\] \
neo4j:latest