xcke / generative_ai_with_langchain

Build large language model (LLM) apps with Python, ChatGPT and other models. This is the companion repository for the book on generative AI with LangChain.

Home Page:https://amzn.to/3D5ZhGu

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Generative AI with LangChain

Create generative AI apps with LangChain.

Environment

You can install your local environment with conda (recommended) or pip. The environment configurations for conda and pip are provided. Please note that if you choose pip as you installation tool, you might need additional tweaking.

If you have any problems with the environment, please raise an issue, where you show the error you got. If you feel confident, please go ahead and create a pull request.

For pip and poetry, make sure you install pandoc in your system. On MacOS use brew:

brew install pandoc

On Ubuntu or Debian linux, use apt:

sudo apt-get install pandoc

On Windows, you can use an installer.

Conda

This is the recommended method for installing dependencies. Please make sure you have anaconda installed.

First create the environment for the book that contains all the dependencies:

conda env create --file langchain_ai.yaml --force

The conda environment is called langchain_ai. You can activate it as follows:

conda activate langchain_ai 

Pip

Pip is the default dependency management tool in Python. With pip, you should be able to install all the libraries from the requirements file:

pip install -r requirements.txt

Docker

There's a docker file for the environment as well. It uses the docker environment and starts an ipython notebook. To use it, first build it, and then run it:

docker build -t new_image .
docker run -it new_image

You should be able to find the notebook in your browser at http://localhost:8080.

Poetry

Make sure you have poetry installed. On Linux and MacOS, you should be able to use the requirements file:

poetry install

This should take the pyproject.toml file and install all dependencies.

Code validation

To run the code validation in ruff, please run

ruff check .

Contributing

If you find anything amiss with the notebooks or dependencies, please feel free to create a pull request.

If you want to change the conda dependency specification (the yaml file), you can test it like this:

conda env create --file langchain_ai.yaml --force

You can update the pip requirements like this:

pip freeze > requirements.txt

Please make sure that you keep these two ways of maintaining dependencies in sync.

Then make sure, you test the notebooks in the new environment to see that they run.

About

Build large language model (LLM) apps with Python, ChatGPT and other models. This is the companion repository for the book on generative AI with LangChain.

https://amzn.to/3D5ZhGu


Languages

Language:Jupyter Notebook 91.4%Language:Python 7.8%Language:HTML 0.8%Language:Dockerfile 0.1%