From c3bb58ed1f6ef1910d506eadb6889488fe981b66 Mon Sep 17 00:00:00 2001 From: MBorne Date: Tue, 16 Jul 2024 18:52:54 +0200 Subject: [PATCH 1/4] chore(open-webui): handle proxy --- open-webui/docker-compose.yaml | 36 ++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/open-webui/docker-compose.yaml b/open-webui/docker-compose.yaml index 4ca6cf1..acea5cc 100644 --- a/open-webui/docker-compose.yaml +++ b/open-webui/docker-compose.yaml @@ -13,15 +13,18 @@ services: # add pipelines - OPENAI_API_BASE_URL=https://api.openai.com/v1;http://pipelines:9099 - OPENAI_API_KEYS=${OPENAI_API_KEY};${PIPELINES_API_KEY} + - HTTP_PROXY + - HTTPS_PROXY + - NO_PROXY=ollama,pipelines,$NO_PROXY volumes: - open-webui:/app/backend/data deploy: - resources: - reservations: - devices: - - driver: nvidia - capabilities: ["gpu"] - count: all + resources: + reservations: + devices: + - driver: nvidia + capabilities: ["gpu"] + count: all labels: - "traefik.enable=true" # https://open-webui.dev.localhost @@ -32,20 +35,27 @@ services: # https://hub.docker.com/r/ollama/ollama ollama: - image: ollama/ollama:latest + image: ollama/ollama:0.2.5 container_name: ollama ports: - 11434:11434 volumes: - ollama:/root/.ollama - ./models:/models:ro + # bypass userns-remap + userns_mode: 'host' + environment: + #- OLLAMA_DEBUG=1 + - HTTP_PROXY + - HTTPS_PROXY + - NO_PROXY=127.0.0.1,localhost,0.0.0.0,ollama,$NO_PROXY deploy: - resources: - reservations: - devices: - - driver: nvidia - capabilities: ["gpu"] - count: all + resources: + reservations: + devices: + - driver: nvidia + capabilities: ["gpu"] + count: all labels: - "traefik.enable=true" # https://ollama.dev.localhost From ebe8b06ddc1115d6ebecd014d30d43cce1562b80 Mon Sep 17 00:00:00 2001 From: MBorne Date: Tue, 16 Jul 2024 18:53:13 +0200 Subject: [PATCH 2/4] chore(open-webui): handle proxy --- open-webui/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/open-webui/README.md b/open-webui/README.md index afe5c25..5f6388a 100644 --- a/open-webui/README.md +++ b/open-webui/README.md @@ -35,7 +35,7 @@ curl http://localhost:11434/api/generate -d '{ To create custom model from [OLLAMA Modelfile](https://github.com/ollama/ollama/tree/main?tab=readme-ov-file#customize-a-prompt), a sample [models/geoassistant](models/geoassistant/README.md) is available : ```bash -docker compose exec ollama +docker compose exec ollama /bin/bash ollama create geoassistant -f /models/geoassistant/Modelfile ollama run geoassistant # Do you know the most visited museums in Paris? From b6fc55ba9064a50027942dea80f1b351ea73049a Mon Sep 17 00:00:00 2001 From: mborne Date: Wed, 17 Jul 2024 10:40:41 +0200 Subject: [PATCH 3/4] chore(llm): split ollama and open-webui --- ollama/.env | 1 + ollama/README.md | 54 +++++++++++ ollama/docker-compose.yaml | 40 ++++++++ open-webui/.env | 1 + open-webui/README.md | 49 ++-------- open-webui/docker-compose.yaml | 35 +------ open-webui/models/geoassistant/Modelfile | 14 --- open-webui/models/geoassistant/README.md | 74 --------------- .../models/geoassistant/paris-museum.geojson | 93 ------------------- 9 files changed, 106 insertions(+), 255 deletions(-) create mode 100644 ollama/.env create mode 100644 ollama/README.md create mode 100644 ollama/docker-compose.yaml delete mode 100644 open-webui/models/geoassistant/Modelfile delete mode 100644 open-webui/models/geoassistant/README.md delete mode 100644 open-webui/models/geoassistant/paris-museum.geojson diff --git a/ollama/.env b/ollama/.env new file mode 100644 index 0000000..7ba4ae7 --- /dev/null +++ b/ollama/.env @@ -0,0 +1 @@ +DEVBOX_HOSTNAME=dev.localhost diff --git a/ollama/README.md b/ollama/README.md new file mode 100644 index 0000000..bae46a6 --- /dev/null +++ b/ollama/README.md @@ -0,0 +1,54 @@ +# ollama + +Containers running [Ollama](https://hub.docker.com/r/ollama/ollama) + +## Usage with docker + +* Ensure that GPU support is enabled in docker (or adapt [docker-compose.yaml](docker-compose.yaml)) : + +```bash +docker run --gpus all nvcr.io/nvidia/k8s/cuda-sample:nbody nbody -gpu -benchmark +``` + +* To use Ollama CLI : + +```bash +# pull models from https://ollama.com/library +docker compose exec ollama ollama pull llama3 +docker compose exec ollama ollama pull gemma2 +# interactive model +docker compose exec ollama ollama run llama3 +``` + +* To use [Ollama API](https://github.com/ollama/ollama/blob/main/docs/api.md#api) : + +```bash +# list models +curl -sS http://localhost:11434/api/tags | jq -r '.models[].name' + +# pull model from https://ollama.com/library +curl http://localhost:11434/api/pull -d '{ + "name": "llama3" +}' + +# use model +curl http://localhost:11434/api/generate -d '{ + "model": "llama3", + "prompt": "Why is the sky blue?" +}' +``` + +* To create **custom model** from [OLLAMA Modelfile](https://github.com/ollama/ollama/tree/main?tab=readme-ov-file#customize-a-prompt), a sample [models/geoassistant](models/geoassistant/README.md) is available : + +```bash +docker compose exec ollama /bin/bash +ollama create geoassistant -f /models/geoassistant/Modelfile +ollama run geoassistant +# Do you know the most visited museums in Paris? +``` + +## Ressources + +* [ollama](https://github.com/ollama/ollama/tree/main?tab=readme-ov-file#ollama) +* [hub.docker.com - ollama/ollama](https://hub.docker.com/r/ollama/ollama) +* [ollama - API](https://github.com/ollama/ollama/blob/main/docs/api.md#api) diff --git a/ollama/docker-compose.yaml b/ollama/docker-compose.yaml new file mode 100644 index 0000000..c4068ab --- /dev/null +++ b/ollama/docker-compose.yaml @@ -0,0 +1,40 @@ +services: + # https://hub.docker.com/r/ollama/ollama + ollama: + image: ollama/ollama:0.2.5 + container_name: ollama + ports: + - 11434:11434 + volumes: + - ollama:/root/.ollama + - ./models:/models:ro + # bypass userns-remap + userns_mode: 'host' + environment: + #- OLLAMA_DEBUG=1 + - HTTP_PROXY + - HTTPS_PROXY + - NO_PROXY=0.0.0.0,ollama,${NO_PROXY:-127.0.0.1,localhost} + deploy: + resources: + reservations: + devices: + - driver: nvidia + capabilities: ["gpu"] + count: all + labels: + - "traefik.enable=true" + # https://ollama.dev.localhost + - "traefik.http.routers.ollama.rule=Host(`ollama.${DEVBOX_HOSTNAME}`)" + - "traefik.http.routers.ollama.service=ollama-service@docker" + - "traefik.http.services.ollama-service.loadbalancer.server.port=11434" + restart: unless-stopped + +volumes: + ollama: + name: ollama + +networks: + default: + name: devbox + external: true diff --git a/open-webui/.env b/open-webui/.env index 122f440..bae30fa 100644 --- a/open-webui/.env +++ b/open-webui/.env @@ -2,3 +2,4 @@ DEVBOX_HOSTNAME=dev.localhost WEBUI_AUTH=False OPENAI_API_KEY= PIPELINES_API_KEY=0p3n-w3bu! +OLLAMA_BASE_URL=http://ollama:11434 diff --git a/open-webui/README.md b/open-webui/README.md index 5f6388a..1b35978 100644 --- a/open-webui/README.md +++ b/open-webui/README.md @@ -1,6 +1,10 @@ # Open WebUI -Containers running [Open WebUI](https://github.com/open-webui/open-webui?tab=readme-ov-file#open-webui-formerly-ollama-webui-) and [ollama](https://hub.docker.com/r/ollama/ollama) to get started with LLM locally. +Container running [Open WebUI](https://github.com/open-webui/open-webui?tab=readme-ov-file#open-webui-formerly-ollama-webui-) for [Ollama](../ollama/README.md). + +## Requirements + +* [ollama](../ollama/README.md) ## Usage with docker @@ -12,49 +16,14 @@ docker run --gpus all nvcr.io/nvidia/k8s/cuda-sample:nbody nbody -gpu -benchmark * Start : `docker compose up -d` * Open https://open-webui.dev.localhost -* To use [ollama API](https://github.com/ollama/ollama/blob/main/docs/api.md#api) : - -```bash -# list models -curl -sS http://localhost:11434/api/tags | jq -r '.models[].name' - -# pull model from https://ollama.com/library -curl http://localhost:11434/api/pull -d '{ - "name": "llama3" -}' - -# use model -curl http://localhost:11434/api/generate -d '{ - "model": "llama3", - "prompt": "Why is the sky blue?" -}' -``` - -## Custom model - -To create custom model from [OLLAMA Modelfile](https://github.com/ollama/ollama/tree/main?tab=readme-ov-file#customize-a-prompt), a sample [models/geoassistant](models/geoassistant/README.md) is available : - -```bash -docker compose exec ollama /bin/bash -ollama create geoassistant -f /models/geoassistant/Modelfile -ollama run geoassistant -# Do you know the most visited museums in Paris? -``` ## Resources * [Open WebUI - Getting Started](https://docs.openwebui.com/getting-started/) * [mborne/toolbox - cuda-toolkit](https://github.com/mborne/toolbox/tree/master/cuda-toolkit#ressources) +* [Pipelines](https://docs.openwebui.com/pipelines) : + * https://docs.openwebui.com/pipelines/#-quick-start-with-docker + * https://ikasten.io/2024/06/03/getting-started-with-openwebui-pipelines/ + * https://raw.githubusercontent.com/open-webui/pipelines/main/examples/filters/function_calling_filter_pipeline.py -[OLLAMA](https://github.com/ollama/ollama) : - -* [ollama](https://github.com/ollama/ollama/tree/main?tab=readme-ov-file#ollama) -* [hub.docker.com - ollama/ollama](https://hub.docker.com/r/ollama/ollama) -* [ollama - API](https://github.com/ollama/ollama/blob/main/docs/api.md#api) - -[Pipelines](https://docs.openwebui.com/pipelines) : - -* https://docs.openwebui.com/pipelines/#-quick-start-with-docker -* https://ikasten.io/2024/06/03/getting-started-with-openwebui-pipelines/ -* https://raw.githubusercontent.com/open-webui/pipelines/main/examples/filters/function_calling_filter_pipeline.py diff --git a/open-webui/docker-compose.yaml b/open-webui/docker-compose.yaml index acea5cc..6686747 100644 --- a/open-webui/docker-compose.yaml +++ b/open-webui/docker-compose.yaml @@ -8,7 +8,7 @@ services: - 3000:8080 environment: - WEBUI_AUTH=False - - OLLAMA_BASE_URL=http://ollama:11434 + - OLLAMA_BASE_URL=${OLLAMA_BASE_URL} - GLOBAL_LOG_LEVEL="DEBUG" # add pipelines - OPENAI_API_BASE_URL=https://api.openai.com/v1;http://pipelines:9099 @@ -33,37 +33,6 @@ services: - "traefik.http.services.open-webui-service.loadbalancer.server.port=8080" restart: unless-stopped - # https://hub.docker.com/r/ollama/ollama - ollama: - image: ollama/ollama:0.2.5 - container_name: ollama - ports: - - 11434:11434 - volumes: - - ollama:/root/.ollama - - ./models:/models:ro - # bypass userns-remap - userns_mode: 'host' - environment: - #- OLLAMA_DEBUG=1 - - HTTP_PROXY - - HTTPS_PROXY - - NO_PROXY=127.0.0.1,localhost,0.0.0.0,ollama,$NO_PROXY - deploy: - resources: - reservations: - devices: - - driver: nvidia - capabilities: ["gpu"] - count: all - labels: - - "traefik.enable=true" - # https://ollama.dev.localhost - - "traefik.http.routers.ollama.rule=Host(`ollama.${DEVBOX_HOSTNAME}`)" - - "traefik.http.routers.ollama.service=ollama-service@docker" - - "traefik.http.services.ollama-service.loadbalancer.server.port=11434" - restart: unless-stopped - # https://docs.openwebui.com/pipelines/#-quick-start-with-docker # https://ikasten.io/2024/06/03/getting-started-with-openwebui-pipelines/ # https://raw.githubusercontent.com/open-webui/pipelines/main/examples/filters/function_calling_filter_pipeline.py @@ -79,8 +48,6 @@ services: restart: unless-stopped volumes: - ollama: - name: ollama open-webui: name: open-webui pipelines: diff --git a/open-webui/models/geoassistant/Modelfile b/open-webui/models/geoassistant/Modelfile deleted file mode 100644 index be3efe2..0000000 --- a/open-webui/models/geoassistant/Modelfile +++ /dev/null @@ -1,14 +0,0 @@ -FROM llama3:latest -PARAMETER temperature 0.8 -SYSTEM """ -You are a model trained to provide information about locations. -If you can't find locations from user message, explain your role. -You will respond with the requested information as a FeatureCollection in GeoJSON format with properties including the type of the location, its name, description, your sources, links and any relevant comments. -Note that : -- You reply using user language -- GeoJSON result must be indented and surrounded by markdown markers (```json ... ```) -- For the geometry, you produce GeoJSON points with the coordinates you found -""" - - - diff --git a/open-webui/models/geoassistant/README.md b/open-webui/models/geoassistant/README.md deleted file mode 100644 index c10e490..0000000 --- a/open-webui/models/geoassistant/README.md +++ /dev/null @@ -1,74 +0,0 @@ -# geoassistant - -## Model - -See [Modelfile](Modelfile) - -## Question - -Do you know the most visited museums in Paris? - -## Answer - -I can provide information about locations! - -Here are the most visited museums in Paris: - -```json -{ - "type": "FeatureCollection", - "features": [ - { - "type": "Feature", - "geometry": {"type": "Point", "coordinates": [2.2931, 48.8647]}, - "properties": { - "name": "The Louvre Museum", - "description": "One of the world's largest and most famous museums, it houses an -impressive collection of art and artifacts from ancient civilizations to the 19th century.", - "sources": ["Wikipedia", "Paris Tourist Office"], - "links": ["https://www.louvre.fr/", -"https://en.parisinfo.com/paris-museum-magazine/louvre-museum"] - } - }, - { - "type": "Feature", - "geometry": {"type": "Point", "coordinates": [2.3319, 48.8678]}, - "properties": { - "name": "Orsay Museum", - "description": "A museum of Impressionist and Post-Impressionist art, featuring works by -Monet, Renoir, Degas, Seurat, and Van Gogh.", - "sources": ["Wikipedia", "Paris Tourist Office"], - "links": ["https://www.musee-orsay.fr/", -"https://en.parisinfo.com/paris-museum-magazine/orangery-museum"] - } - }, - { - "type": "Feature", - "geometry": {"type": "Point", "coordinates": [2.2941, 48.8657]}, - "properties": { - "name": "Rodin Museum", - "description": "A museum dedicated to the works of French sculptor Auguste Rodin, -featuring many of his famous pieces.", - "sources": ["Wikipedia", "Paris Tourist Office"], - "links": ["https://www.musee-rodin.fr/", "https://en.parisinfo.com/paris-museum-magazine -rodin-museum"] - } - }, - { - "type": "Feature", - "geometry": {"type": "Point", "coordinates": [2.3308, 48.8669]}, - "properties": { - "name": "Quai Branly Museum", - "description": "A museum showcasing art and artifacts from Africa, Asia, Oceania, and -the Americas.", - "sources": ["Wikipedia", "Paris Tourist Office"], - "links": ["https://www.quaibranly.fr/", "https://en.parisinfo.com/paris-museum-magazine -quen-braun-ly-museum"] - } - } - ] -} -``` - -Note: The coordinates provided are approximate and represent the general location of each museum -in Paris. diff --git a/open-webui/models/geoassistant/paris-museum.geojson b/open-webui/models/geoassistant/paris-museum.geojson deleted file mode 100644 index 8a67025..0000000 --- a/open-webui/models/geoassistant/paris-museum.geojson +++ /dev/null @@ -1,93 +0,0 @@ -{ - "type": "FeatureCollection", - "features": [ - { - "type": "Feature", - "geometry": { - "type": "Point", - "coordinates": [ - 2.2931, - 48.8647 - ] - }, - "properties": { - "name": "The Louvre Museum", - "description": "One of the world's largest and most famous museums, it houses an impressive collection of art and artifacts from ancient civilizations to the 19th century.", - "sources": [ - "Wikipedia", - "Paris Tourist Office" - ], - "links": [ - "https://www.louvre.fr/", - "https://en.parisinfo.com/paris-museum-magazine/louvre-museum" - ] - } - }, - { - "type": "Feature", - "geometry": { - "type": "Point", - "coordinates": [ - 2.3319, - 48.8678 - ] - }, - "properties": { - "name": "Orsay Museum", - "description": "A museum of Impressionist and Post-Impressionist art, featuring works by Monet, Renoir, Degas, Seurat, and Van Gogh.", - "sources": [ - "Wikipedia", - "Paris Tourist Office" - ], - "links": [ - "https://www.musee-orsay.fr/", - "https://en.parisinfo.com/paris-museum-magazine/orangery-museum" - ] - } - }, - { - "type": "Feature", - "geometry": { - "type": "Point", - "coordinates": [ - 2.2941, - 48.8657 - ] - }, - "properties": { - "name": "Rodin Museum", - "description": "A museum dedicated to the works of French sculptor Auguste Rodin, featuring many of his famous pieces.", - "sources": [ - "Wikipedia", - "Paris Tourist Office" - ], - "links": [ - "https://www.musee-rodin.fr/", - "https://en.parisinfo.com/paris-museum-magazinerodin-museum" - ] - } - }, - { - "type": "Feature", - "geometry": { - "type": "Point", - "coordinates": [ - 2.3308, - 48.8669 - ] - }, - "properties": { - "name": "Quai Branly Museum", - "description": "A museum showcasing art and artifacts from Africa, Asia, Oceania, and the Americas.", - "sources": [ - "Wikipedia", - "Paris Tourist Office" - ], - "links": [ - "https://www.quaibranly.fr/", - "https://en.parisinfo.com/paris-museum-magazinequen-braun-ly-museum" - ] - } - } - ] -} \ No newline at end of file From 29a26a3b136464b5989d6f759d926ae19efe666a Mon Sep 17 00:00:00 2001 From: MBorne Date: Wed, 17 Jul 2024 13:28:58 +0200 Subject: [PATCH 4/4] fix(ollama): add missing models --- ollama/README.md | 1 + ollama/docker-compose.yaml | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/ollama/README.md b/ollama/README.md index bae46a6..eafd14a 100644 --- a/ollama/README.md +++ b/ollama/README.md @@ -52,3 +52,4 @@ ollama run geoassistant * [ollama](https://github.com/ollama/ollama/tree/main?tab=readme-ov-file#ollama) * [hub.docker.com - ollama/ollama](https://hub.docker.com/r/ollama/ollama) * [ollama - API](https://github.com/ollama/ollama/blob/main/docs/api.md#api) +* [mborne/toolbox - cuda-toolkit](https://github.com/mborne/toolbox/tree/master/cuda-toolkit#ressources) diff --git a/ollama/docker-compose.yaml b/ollama/docker-compose.yaml index c4068ab..62f1000 100644 --- a/ollama/docker-compose.yaml +++ b/ollama/docker-compose.yaml @@ -1,15 +1,13 @@ services: # https://hub.docker.com/r/ollama/ollama ollama: - image: ollama/ollama:0.2.5 + image: ollama/ollama:0.2.6 container_name: ollama ports: - 11434:11434 volumes: - ollama:/root/.ollama - ./models:/models:ro - # bypass userns-remap - userns_mode: 'host' environment: #- OLLAMA_DEBUG=1 - HTTP_PROXY