diff --git a/tasks/workstation/linux/software/llm.yml b/tasks/workstation/linux/software/llm.yml index 42807a4..dd5a5af 100644 --- a/tasks/workstation/linux/software/llm.yml +++ b/tasks/workstation/linux/software/llm.yml @@ -443,7 +443,7 @@ {{ ("-e HF_TOKEN=" ~ hf_token) if hf_token else '' }} \ -e WEBUI_SECRET_KEY={{ open_webui_key }} \ -v open-webui:/app/backend/data \ - ghcr.io/open-webui/open-webui:main + ghcr.io/open-webui/open-webui:latest # Unsure why this was not working on Artix with runit. # exec curl 0.0.0.0:8080/health gave a successful response. @@ -511,6 +511,14 @@ owner: "{{ user }}" mode: "0755" + - name: Workstation | Linux | Software | LLMs | runit | open-terminal | Dir | AI-Sandbox + ansible.builtin.file: + dest: "{{ user_user.home }}/AI-Sandbox" + state: directory + owner: "{{ user }}" + group: "{{ user }}" + mode: "0755" + - name: Workstation | Linux | Software | LLMs | runit | open-terminal | Script | Run ansible.builtin.copy: dest: /etc/sv/open-terminal/run @@ -535,16 +543,20 @@ echo "RUN: Container already deleted." # Start the open-terminal program. + # https://github.com/open-webui/open-terminal#configuration set -e exec docker run \ --pull=always \ --name open-terminal \ - --network=host -p {{ open_terminal_port }}:8000 \ - -v open-terminal:/home/user \ - -v {{ user_user.home }}/Code:/home/user/Code \ + --network=host --port {{ open_terminal_port }} \ + -v {{ user_user.home }}/AI-Sandbox:{{ user_user.home }} \ + -v {{ user_user.home }}/Code:{{ user_user.home }}/Code \ + -e OPEN_TERMINAL_FILE_BROWSER_ROOT={{ user_user.home }} \ -e OPEN_TERMINAL_API_KEY={{ open_terminal_key }} \ - ghcr.io/open-webui/open-terminal + ghcr.io/open-webui/open-terminal:latest + + # -p {{ open_terminal_port }}:8000 mode: "0755" - name: Workstation | Linux | Software | LLMs | runit | open-terminal | Script | Finish @@ -744,17 +756,17 @@ path: "{{ user_user.home }}/{{ item }}" marker: "# {mark} ANSIBLE MANAGED BLOCK | ollama | Manual Script" content: | - function list_llms() { + function ollama_llms() { {% for llm in llm_installs %} echo "{{ llm.model }}" {% endfor %} } - function pull_llms() { + function ollama_pull() { echo "Manually Pulling Models" - for model in `list_llms`; do + for model in `ollama_llms`; do echo -e "\n\n Starting 'ollama pull $model' \n\n" ollama pull $model status=$? @@ -763,9 +775,9 @@ echo "Done!!" } - alias pull-llms="pull_llms " - alias pull-models="pull_llms " - alias pull-ai="pull_llms " + alias pull-llms="ollama_pull " + alias pull-models="ollama_pull " + alias pull-ai="ollama_pull " function ollama_stop() { for model in `ollama ps | tail -n +2 | awk '{print $1}'`; do @@ -805,7 +817,7 @@ alias show-models="ollama_models " alias list-models="ollama_models " - function ollama_purge { + function ollama_purge() { echo "TBD: Purge all models not in llm_installs." } alias ollama-purge="ollama_purge " @@ -827,6 +839,39 @@ alias restart-llm="restart_ai " alias restart-llms="restart_ai " alias restart-models="restart_ai " + + function ollama_sizes() { + echo " Stopping all ollama usage..." + sudo sv restart ollama + + echo -e "\n Checking model disk and RAM sizes...\n" + echo "| Model Name | HDD (ls) | RAM (ps) |" + echo "| +---- | --+ | --+ |" + for model in `ollama ls | grep -v NAME | awk '{print $1}'`; do + echo -n "| $model" + #ollama run $model "" --format json >/dev/null 2>&1 + #set -x + curl -s http://localhost:11434/api/generate \ + -d '{"model":"'$model'","prompt":"","stream":false,"keep_alive":1}' \ + >/dev/null 2>&1 + set +x + + hdd="`ollama ls | grep $model | awk '{print $3 $4}'`" + echo -n " | $hdd" + ram="`ollama ps | grep $model | awk '{print $3 $4}'`" + echo -n " | $ram" + + ollama stop $model >/dev/null 2>&1 + while ollama ps | grep $model; do + sleep 1 + done + echo " |" + done + + echo "Done!!" + } + alias ollama-sizes="ollama_sizes " + alias model-sizes="ollama_sizes " state: present create: false backup: true