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..eafd14a --- /dev/null +++ b/ollama/README.md @@ -0,0 +1,55 @@ +# 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) +* [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 new file mode 100644 index 0000000..62f1000 --- /dev/null +++ b/ollama/docker-compose.yaml @@ -0,0 +1,38 @@ +services: + # https://hub.docker.com/r/ollama/ollama + ollama: + image: ollama/ollama:0.2.6 + container_name: ollama + ports: + - 11434:11434 + volumes: + - ollama:/root/.ollama + - ./models:/models:ro + 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 afe5c25..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 -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 4ca6cf1..6686747 100644 --- a/open-webui/docker-compose.yaml +++ b/open-webui/docker-compose.yaml @@ -8,20 +8,23 @@ 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 - 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 @@ -30,30 +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:latest - container_name: ollama - ports: - - 11434:11434 - volumes: - - ollama:/root/.ollama - - ./models:/models:ro - 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 @@ -69,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