The folowing instructions are for the demo directory meant to showcase live examples in class. For the main deployment example on Render, see the DEPLOYMENT README.
Before you begin, ensure you have met the following requirements:
- Docker Desktop (recommended for local setup)
- Python 3.11.0 or greater (local setup with virtual environment)
- Copy the sample environment file:
cp .env.sample .env
- Edit the
.envfile:OPENAI_API_KEY=your-openai-key LANGCHAIN_API_KEY=your-langchain-key LANGCHAIN_TRACING_V2=true LANGCHAIN_PROJECT=class_8
- In the CLI,
cdinto thedemodirectory. You MUST follow this step before proceeding to access the correctDockerfile/docker-compose.yml. - Look at the
docker-compose.ymlandDockerfilefile to understand the different services they are managing/running. - Start the Python servers in
in_class_examplesin their respective directories (each command runs its separate server container, and is run from thedemodirectory):docker compose up agent docker compose up chat - Start Jupyter to run the corresponding
.ipynbfiles you may create:docker compose up jupyter - Run any
.pyfiles you may create in thedemodirectory in this manner:docker compose run --rm main python <the_py_file>
You can use the provided run.sh script for easier execution. Make sure you are in the demo directory when running the script.
Make sure to make the script executable with chmod +x run.sh in the CLI before using:
./run.sh agent #(starts the agent server)
./run.sh chat #(starts the chat server)
./run.sh jupyter #(starts the jupyter notebook server)
./run.sh <your_new_py_file> #(runs other .py files)If you prefer to run the examples locally:
- Ensure you have Python 3.11.0 or higher installed.
- Clone the repository:
git clone [repository-url] cd [repository-name] - Set up the virtual environment:
python3 -m venv .venv source .venv/bin/activate # On Windows use `.venv\Scripts\activate` pip install -r requirements.txt
- Configure environment variables as described in the Setup section.
- Export your
.envvariables to the system (LangChain will handle this for you "under the hood" in the.ipynbfiles, but this is included for reference): Linux / Mac / Bashexport $(grep -v '^#' .env | xargs)
- Run the notebooks:
run the `.ipynb` files in VSCode (it will prompt you to allow the installation of ipykernel: do so) or another IDE that supports notebooks.
Reach out to the learning assistants in the course Slack channel.