Skip to content

Commit

Permalink
Add custom models
Browse files Browse the repository at this point in the history
  • Loading branch information
Veraticus committed Apr 5, 2024
1 parent 47da6b8 commit de4d298
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 5 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Release Charts

on:
push:
branches:
- main

jobs:
release:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Install Helm
uses: azure/setup-helm@v3

- name: Run chart-releaser
uses: helm/chart-releaser-action@v1.6.0
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
4 changes: 2 additions & 2 deletions templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Create the name of the service account to use
{{- end }}

{{/*
Create the model list
Create the included model list
*/}}
{{- define "ollama.modelList" -}}
{{- $modelList := default list}}
Expand All @@ -74,4 +74,4 @@ Create the model list
{{- end}}
{{- $modelList = $modelList | uniq}}
{{- default (join " " $modelList) -}}
{{- end -}}
{{- end -}}
20 changes: 17 additions & 3 deletions templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,25 @@ spec:
successThreshold: {{ .Values.readinessProbe.successThreshold }}
failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
{{- end }}
{{- if or .Values.ollama.models .Values.ollama.defaultModel }}
{{- if or .Values.ollama.models .Values.ollama.defaultModel .Values.ollama.customModels }}
lifecycle:
postStart:
exec:
command: [ "/bin/sh", "-c", "{{- printf "echo %s | xargs -n1 /bin/ollama pull %s" (include "ollama.modelList" .) (ternary "--insecure" "" .Values.ollama.insecure)}}" ]
command:
- "/bin/sh"
- "-c"
- >
apt-get update && apt-get install wget -y
mkdir -p /models
{{- if or .Values.ollama.models .Values.ollama.defaultModel }}
{{ printf "echo %s | xargs -n1 /bin/ollama pull %s" (include "ollama.modelList" .) (ternary "--insecure" "" .Values.ollama.insecure)}}
{{- end }}
{{- range $m := .Values.ollama.customModels }}
{{- $filename := splitList "/" $m.url | last }}
wget --no-verbose --show-progress --progress=dot:mega -O /models/{{ $filename }} {{ $m.url }}
echo "FROM /models/{{ $filename }}" > /models/Modelfile-{{ $filename }}
/bin/ollama create {{ $m.name }} -f Modelfile-{{ $filename }}
{{- end }}
{{- end }}
volumes:
- name: ollama-data
Expand Down Expand Up @@ -140,4 +154,4 @@ spec:
{{- with .Values.tolerations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
{{- end }}
10 changes: 10 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ ollama:
# - mistral
models: {}

# -- List of custom models to pull and install at container startup
# Similar to the above, the more you have, the longer the container will take to start
# This expects a dictionary with the keys "name" (for the name to import the
# model as inside Ollama) and "uri" (which is the location where the custom
# model's gguf file is located, probably huggingface somewhere)
# customModels:
# - name: ggml-gritlm-7b:q4_0
# url: https://huggingface.co/dranger003/GritLM-7B-GGUF/resolve/main/ggml-gritlm-7b-q4_k.gguf
customModels: {}

# -- Add insecure flag for pulling at container startup
insecure: false

Expand Down

0 comments on commit de4d298

Please sign in to comment.