Jafner.net/docker-llm-amd/ollama/sync-modelfiles

23 lines
764 B
Plaintext
Raw Normal View History

2024-06-04 12:42:14 -07:00
#!/bin/bash
# THIS SCRIPT DOES NOT WORK RIGHT NOW
# The script is fine, it just needs the modelfiles to be written with reference
# to the models folder relative to the host system, rather than inside the
# container. We're using ./modelfiles/.loadmodels.sh instead right now.
2024-06-04 12:42:14 -07:00
modelfiles="$(ls ./modelfiles/)"
2024-06-04 12:42:14 -07:00
models="$(ollama list | tr -s ' ' | cut -f 1 | tail -n +2)"
for model in $(echo "$models"); do
if ! [[ $modelfiles == *"$model"* ]]; then
echo -n "Running: '"
echo "ollama rm \"$model\"'"
ollama rm "$model"
fi
done
cd ./modelfiles
for modelfile in ./*; do
2024-06-04 12:42:14 -07:00
echo -n "Running: '"
echo "ollama create \"$(basename $modelfile)\" -f \"$modelfile\"'"
ollama create "$(basename $modelfile)" -f "$modelfile"
done