Skip to content

The agent engineering platform.

Visual Studio Code/Github Codespaces Dev Containers (#4035) (#4122)

Zander Chaseac0a9d02bd6a
diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile
new file mode 100644
index 0000000000..4c5d56bd2c
--- /dev/null
+++ b/.devcontainer/Dockerfile
@@ -0,0 +1,42 @@
+# This is a Dockerfile for Developer Container
+
+# Use the Python base image
+ARG VARIANT="3.11-bullseye"
+FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT} AS langchain-dev-base
+
+USER vscode
+
+# Define the version of Poetry to install (default is 1.4.2)
+# Define the directory of python virtual environment
+ARG PYTHON_VIRTUALENV_HOME=/home/vscode/langchain-py-env \
+ POETRY_VERSION=1.4.2
+
+ENV POETRY_VIRTUALENVS_IN_PROJECT=false \
+ POETRY_NO_INTERACTION=true
+
+# Create a Python virtual environment for Poetry and install it
+RUN python3 -m venv ${PYTHON_VIRTUALENV_HOME} && \
+ $PYTHON_VIRTUALENV_HOME/bin/pip install --upgrade pip && \
+ $PYTHON_VIRTUALENV_HOME/bin/pip install poetry==${POETRY_VERSION}
+
+ENV PATH="$PYTHON_VIRTUALENV_HOME/bin:$PATH" \
+ VIRTUAL_ENV=$PYTHON_VIRTUALENV_HOME
+
+# Setup for bash
+RUN poetry completions bash >> /home/vscode/.bash_completion && \
+ echo "export PATH=$PYTHON_VIRTUALENV_HOME/bin:$PATH" >> ~/.bashrc
+
+# Set the working directory for the app
+WORKDIR /workspaces/langchain
+
+# Use a multi-stage build to install dependencies
+FROM langchain-dev-base AS langchain-dev-dependencies
+
+ARG PYTHON_VIRTUALENV_HOME
+
+# Copy only the dependency files for installation
+COPY pyproject.toml poetry.lock poetry.toml ./
+
+# Install the Poetry dependencies (this layer will be cached as long as the dependencies don't change)
+RUN poetry install --no-interaction --no-ansi --with dev,test,docs
+
diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
new file mode 100644
index 0000000000..b3e3efb513
--- /dev/null
+++ b/.devcontainer/devcontainer.json
@@ -0,0 +1,33 @@
+// For format details, see https://aka.ms/devcontainer.json. For config options, see the
+// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile
+{
+ "dockerComposeFile": "./docker-compose.yaml",
+ "service": "langchain",
+ "workspaceFolder": "/workspaces/langchain",
+ "name": "langchain",
+ "customizations": {
+ "vscode": {
+ "extensions": [
+ "ms-python.python"
+ ],
+ "settings": {
+ "python.defaultInterpreterPath": "/home/vscode/langchain-py-env/bin/python3.11"
+ }
+ }
+
+ },
+
+ // Features to add to the dev container. More info: https://containers.dev/features.
+ "features": {},
+
+ // Use 'forwardPorts' to make a list of ports inside the container available locally.
+ // "forwardPorts": [],
+
+ // Uncomment the next line to run commands after the container is created.
+ // "postCreateCommand": "cat /etc/os-release",
+
+ // Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
+ // "remoteUser": "devcontainer"
+ "remoteUser": "vscode",
+ "overrideCommand": true
+}
diff --git a/.devcontainer/docker-compose.yaml b/.devcontainer/docker-compose.yaml
new file mode 100644
index 0000000000..824b7e7843
--- /dev/null
+++ b/.devcontainer/docker-compose.yaml
@@ -0,0 +1,31 @@
+version: '3'
+services:
+ langchain:
+ build:
+ dockerfile: .devcontainer/Dockerfile
+ context: ../
+ volumes:
+ - ../:/workspaces/langchain
+ networks:
+ - langchain-network
+ # environment:
+ # MONGO_ROOT_USERNAME: root
+ # MONGO_ROOT_PASSWORD: example123
+ # depends_on:
+ # - mongo
+ # mongo:
+ # image: mongo
+ # restart: unless-stopped
+ # environment:
+ # MONGO_INITDB_ROOT_USERNAME: root
+ # MONGO_INITDB_ROOT_PASSWORD: example123
+ # ports:
+ # - "27017:27017"
+ # networks:
+ # - langchain-network
+
+networks:
+ langchain-network:
+ driver: bridge
+
+
diff --git a/README.md b/README.md
index f7251f5d9a..bf14363970 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,8 @@
⚡ Building applications with LLMs through composability ⚡
-[![lint](https://github.com/hwchase17/langchain/actions/workflows/lint.yml/badge.svg)](https://github.com/hwchase17/langchain/actions/workflows/lint.yml) [![test](https://github.com/hwchase17/langchain/actions/workflows/test.yml/badge.svg)](https://github.com/hwchase17/langchain/actions/workflows/test.yml) [![linkcheck](https://github.com/hwchase17/langchain/actions/workflows/linkcheck.yml/badge.svg)](https://github.com/hwchase17/langchain/actions/workflows/linkcheck.yml) [![Downloads](https://static.pepy.tech/badge/langchain/month)](https://pepy.tech/project/langchain) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Twitter](https://img.shields.io/twitter/url/https/twitter.com/langchainai.svg?style=social&label=Follow%20%40LangChainAI)](https://twitter.com/langchainai) [![](https://dcbadge.vercel.app/api/server/6adMQxSpJS?compact=true&style=flat)](https://discord.gg/6adMQxSpJS)
+[![lint](https://github.com/hwchase17/langchain/actions/workflows/lint.yml/badge.svg)](https://github.com/hwchase17/langchain/actions/workflows/lint.yml) [![test](https://github.com/hwchase17/langchain/actions/workflows/test.yml/badge.svg)](https://github.com/hwchase17/langchain/actions/workflows/test.yml) [![linkcheck](https://github.com/hwchase17/langchain/actions/workflows/linkcheck.yml/badge.svg)](https://github.com/hwchase17/langchain/actions/workflows/linkcheck.yml) [![Downloads](https://static.pepy.tech/badge/langchain/month)](https://pepy.tech/project/langchain) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Twitter](https://img.shields.io/twitter/url/https/twitter.com/langchainai.svg?style=social&label=Follow%20%40LangChainAI)](https://twitter.com/langchainai) [![](https://dcbadge.vercel.app/api/server/6adMQxSpJS?compact=true&style=flat)](https://discord.gg/6adMQxSpJS) [![Open in Dev Containers](https://img.shields.io/static/v1?label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/hwchase17/langchain) [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/hwchase17/langchain)
+
Looking for the JS/TS version? Check out [LangChain.js](https://github.com/hwchase17/langchainjs).