diff --git a/tasks/workstation/linux/software/ai/llm.yml b/tasks/workstation/linux/software/ai/llm.yml index a2d9f9b..04c2ce9 100644 --- a/tasks/workstation/linux/software/ai/llm.yml +++ b/tasks/workstation/linux/software/ai/llm.yml @@ -84,6 +84,7 @@ llm_size_coef: 1.3 # Base the context on MB of RAM, with a minumum 64k for decent thinking. llm_context: "{{ [(ansible_memtotal_mb * 4) | round(-3, method='ceil'), 64000] | max | int }}" + llm_docker_network: open-webui-net - name: Workstation | Linux | Software | LLMs | Facts 02 ansible.builtin.set_fact: @@ -272,6 +273,7 @@ ### Required ### export HOME={{ user_user.home }} + export OLLAMA_HOST=0.0.0.0 # Needed for Open WebUI ### Timeouts ### export OLLAMA_LOAD_TIMEOUT=30m # default is 5m @@ -411,6 +413,13 @@ content: | #!/bin/sh exec 2>&1 + + ## TBD / TODO + ## Move this to the same compose file as Open Terminal. + ## Will solve quite a few network related complications. + ## Also refactor the two into their own file (open_webui.yml). + ## Probably also will then condense into 1 runit service. + image=ghcr.io/open-webui/open-webui:latest # Wait for Docker to start up. @@ -439,14 +448,18 @@ # Ensure cleanup on any exit (normal or signal from runit). trap 'kill "$LOOP_PID" 2>/dev/null; wait "$LOOP_PID" 2>/dev/null' EXIT + # Create a network for associated programs. + net={{ llm_docker_network }} + docker network inspect $net >/dev/null 2>&1 || \ + docker network create $net + # Start the open-webui program. set -e docker run \ - --name open-webui \ + --name open-webui --network $net \ -e PORT={{ open_webui_port }} \ - -p {{ open_webui_port }}:{{ open_webui_port }} \ - --add-host=host.docker.internal:host-gateway \ - -e OLLAMA_BASE_URL=http://0.0.0.0:11434 \ + -p {{ open_webui_port }}:{{ open_webui_port }} \--add-host=host.docker.internal:host-gateway \ + -e OLLAMA_BASE_URL=http://host.docker.internal:11434 \ {{ ("-e HF_TOKEN=" ~ hf_token) if hf_token else '' }} \ -e WEBUI_SECRET_KEY={{ open_webui_key }} \ -e ENABLE_QUERIES_CACHE=True \ @@ -686,6 +699,9 @@ # -e OPEN_TERMINAL_PACKAGES="$packages" \ # -e GOT_EM="$GOT_EM" \ # $image run --port {{ open_terminal_port }} + networks: + {{ llm_docker_network }}: + name: {{ llm_docker_network }} services: open-terminal: @@ -695,6 +711,8 @@ container_name: open-terminal ports: - {{ open_terminal_port }}:{{ open_terminal_port }} + networks: + - {{ llm_docker_network }} #dns: # ## Mullvad # ## (https://mullvad.net/en/help/dns-over-https-and-dns-over-tls)