From 5b0f64f8eb72cc5853521b01975641e726c4a4fc Mon Sep 17 00:00:00 2001 From: Tine Kondo Date: Wed, 26 Jun 2024 11:50:54 +0200 Subject: [PATCH 1/2] chore: add `devcontainer` support to ease the setup of the dev workstation with `python`, `ollama`, etc When opening the project in `VSCode` or `IntellJ`, provided user has Docker installed and the **[DevContainer(https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)]** This will automatically: - Install Python 3 - Create the Venv `.source.venv` and print instructions to activate it - (VSCodde) Automatically setup the Python Interpreter from the venv - (VSCode) Install the `Jupyter` extension and enabled `Python` support - Download and Start `Ollama Server` - Pull some LLMs (`llama2` by defaut) --- .devcontainer/devcontainer.json | 55 ++++++++++++++++++++++++++++++ .devcontainer/postCreateCommand.sh | 26 ++++++++++++++ .devcontainer/postStartCommand.sh | 22 ++++++++++++ .gitignore | 3 +- 4 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 .devcontainer/devcontainer.json create mode 100755 .devcontainer/postCreateCommand.sh create mode 100755 .devcontainer/postStartCommand.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..f96cd7e --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,55 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node +{ + "name": "SFEIR School LangChain", + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "image": "mcr.microsoft.com/devcontainers/typescript-node:1-20-bullseye", + "features": { + "ghcr.io/devcontainers/features/common-utils:2": { + "installZsh": true, + "installOhMyZsh": true, + "installOhMyZshConfig": true, + "upgradePackages": true, + "username": "automatic", + "userUid": "automatic", + "userGid": "automatic" + }, + "ghcr.io/devcontainers/features/python:1": { + "installTools": true, + "installJupyterlab": true, + "version": "3.12" + } + }, + + // 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": [], + + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "./.devcontainer/postCreateCommand.sh", + + // Use 'postCreateCommand' to run commands after the container is started. + "postStartCommand": "./.devcontainer/postStartCommand.sh", + + // Configure tool-specific properties. + "customizations": { + "vscode": { + "extensions": [ + "mhutchie.git-graph", + "anweber.reveal-button", + "ms-python.python", + "ms-python.debugpy", + "ms-toolsai.jupyter" + ], + "settings":{ + "python.pythonPath": "./.school.venv/bin/python", + "debug.javascript.autoAttachFilter": "onlyWithFlag" + } + } + } + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} diff --git a/.devcontainer/postCreateCommand.sh b/.devcontainer/postCreateCommand.sh new file mode 100755 index 0000000..15b2dba --- /dev/null +++ b/.devcontainer/postCreateCommand.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +# Installing Node Modules +#npm ci + +# Installing Ollama + +echo "⬇️ Downloading and Installing Ollama Server..." +curl https://ollama.ai/install.sh | sh + +# Create the virtual environment (if missing) +if [ ! -f .school.venv/bin/activate ]; then + echo "➕ Creating the virtual environment (.school.venv)..." + virtualenv .school.venv +fi + +echo "✅ Setup done" + +# Activate the virtual environment for this terminal session +echo "" +echo "Please don't forget to run the following command in your terminal..." +echo "⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️" +echo "source .school.venv/bin/activate" +echo "⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️" +echo "...(to activate the virtual env) before installing Python dependencies!" +echo "" \ No newline at end of file diff --git a/.devcontainer/postStartCommand.sh b/.devcontainer/postStartCommand.sh new file mode 100755 index 0000000..eaffc59 --- /dev/null +++ b/.devcontainer/postStartCommand.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# Starting Ollama Server +echo "🏃🏿‍♂️ Starting Ollama Server..." +ollama serve & + +echo "⬇️ Pulling LLMs..." +ollama pull llama2 +#ollama pull mistral +#ollama pull codellama + +echo "✅ Local LLMs Setup done!" + + +# Activate the virtual environment for this terminal session +echo "" +echo "Please don't forget to run the following command in your terminal..." +echo "⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️" +echo "source .school.venv/bin/activate" +echo "⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️" +echo "...(to activate the virtual env) before installing Python dependencies!" +echo "" \ No newline at end of file diff --git a/.gitignore b/.gitignore index b36fdc6..6590be7 100644 --- a/.gitignore +++ b/.gitignore @@ -69,4 +69,5 @@ typings/ #Dev docs/test.html -.venv* \ No newline at end of file +.venv* +.school.venv \ No newline at end of file From 0a470fe8d157154359bb96f34652c0ded0a27748 Mon Sep 17 00:00:00 2001 From: Tine Kondo Date: Wed, 26 Jun 2024 12:47:00 +0000 Subject: [PATCH 2/2] fix: add missing installation of `langchain-community` package in some steps --- steps/02-langchain-solution/solution.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/steps/02-langchain-solution/solution.ipynb b/steps/02-langchain-solution/solution.ipynb index 75ff981..80c206b 100644 --- a/steps/02-langchain-solution/solution.ipynb +++ b/steps/02-langchain-solution/solution.ipynb @@ -107,7 +107,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.0" + "version": "3.12.4" } }, "nbformat": 4,