diff --git a/helm-charts/common/guardrails-usvc/README.md b/helm-charts/common/guardrails-usvc/README.md index 0cf3b565..969fb2a4 100644 --- a/helm-charts/common/guardrails-usvc/README.md +++ b/helm-charts/common/guardrails-usvc/README.md @@ -47,11 +47,10 @@ curl http://localhost:9090/v1/guardrails \ ## Values -| Key | Type | Default | Description | -| ------------------------------- | ------ | ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| global.HUGGINGFACEHUB_API_TOKEN | string | `""` | Your own Hugging Face API token | -| global.modelUseHostPath | string | `"/mnt/opea-models"` | Cached models directory, tgi will not download if the model is cached here. The host path "modelUseHostPath" will be mounted to container as /data directory | -| image.repository | string | `"opea/guardrails-usvc"` | | -| service.port | string | `"9090"` | | -| SAFETY_GUARD_ENDPOINT | string | `""` | LLM endpoint | -| SAFETY_GUARD_MODEL_ID | string | `"meta-llama/Meta-Llama-Guard-2-8B"` | Model ID for the underlying LLM service is using | +| Key | Type | Default | Description | +| ------------------------------- | ------ | ------------------------------------ | ------------------------------------------------ | +| global.HUGGINGFACEHUB_API_TOKEN | string | `""` | Your own Hugging Face API token | +| image.repository | string | `"opea/guardrails-usvc"` | | +| service.port | string | `"9090"` | | +| SAFETY_GUARD_ENDPOINT | string | `""` | LLM endpoint | +| SAFETY_GUARD_MODEL_ID | string | `"meta-llama/Meta-Llama-Guard-2-8B"` | Model ID for the underlying LLM service is using | diff --git a/helm-charts/common/speecht5/templates/configmap.yaml b/helm-charts/common/speecht5/templates/configmap.yaml index d488542f..c153143f 100644 --- a/helm-charts/common/speecht5/templates/configmap.yaml +++ b/helm-charts/common/speecht5/templates/configmap.yaml @@ -18,3 +18,4 @@ data: HF_ENDPOINT: {{ .Values.global.HF_ENDPOINT | quote}} {{- end }} HUGGINGFACE_HUB_CACHE: "/data" + HF_TOKEN: {{ .Values.global.HUGGINGFACEHUB_API_TOKEN | quote}} diff --git a/helm-charts/common/speecht5/templates/deployment.yaml b/helm-charts/common/speecht5/templates/deployment.yaml index 6b5976b8..db5b9cd1 100644 --- a/helm-charts/common/speecht5/templates/deployment.yaml +++ b/helm-charts/common/speecht5/templates/deployment.yaml @@ -27,6 +27,32 @@ spec: {{- end }} securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} + {{- if not (hasPrefix "/data/" .Values.TTS_MODEL_PATH) }} + initContainers: + - name: model-downloader + envFrom: + - configMapRef: + name: {{ include "speecht5.fullname" . }}-config + securityContext: + {{- if .Values.global.modelUseHostPath }} + {} + {{- else }} + {{- toYaml .Values.securityContext | nindent 12 }} + {{- end }} + image: huggingface/downloader:0.17.3 + command: ['sh', '-c'] + args: + - | + huggingface-cli download --cache-dir /data --token $(HF_TOKEN) {{ .Values.TTS_MODEL_PATH | quote }}; + huggingface-cli download --cache-dir /data --token $(HF_TOKEN) {{ .Values.VOCODER_MODEL| quote }}; + {{- if .Values.global.modelUseHostPath }} + chown -R 1000 /data/models--{{ replace "/" "--" .Values.TTS_MODEL_PATH }}; + chown -R 1000 /data/models--{{ replace "/" "--" .Values.VOCODER_MODEL }} + {{- end }} + volumeMounts: + - mountPath: /data + name: model-volume + {{- end }} containers: - name: {{ .Release.Name }} envFrom: diff --git a/helm-charts/common/speecht5/values.yaml b/helm-charts/common/speecht5/values.yaml index 96a8e452..34822ae4 100644 --- a/helm-charts/common/speecht5/values.yaml +++ b/helm-charts/common/speecht5/values.yaml @@ -8,7 +8,7 @@ replicaCount: 1 TTS_MODEL_PATH: "microsoft/speecht5_tts" -# VOCODE_MODEL: "microsoft/speecht5_hifigan" +VOCODER_MODEL: "microsoft/speecht5_hifigan" image: repository: opea/speecht5 @@ -85,6 +85,7 @@ global: http_proxy: "" https_proxy: "" no_proxy: "" + HUGGINGFACEHUB_API_TOKEN: "insert-your-huggingface-token-here" # Choose where to save your downloaded models # Set modelUseHostPath for local directory, this is good for one node test. Example: diff --git a/helm-charts/common/tei/templates/configmap.yaml b/helm-charts/common/tei/templates/configmap.yaml index 6b40613a..7f7c2530 100644 --- a/helm-charts/common/tei/templates/configmap.yaml +++ b/helm-charts/common/tei/templates/configmap.yaml @@ -32,3 +32,4 @@ data: {{- if .Values.MAX_WARMUP_SEQUENCE_LENGTH }} MAX_WARMUP_SEQUENCE_LENGTH: {{ .Values.MAX_WARMUP_SEQUENCE_LENGTH | quote }} {{- end }} + HF_TOKEN: {{ .Values.global.HUGGINGFACEHUB_API_TOKEN | quote}} diff --git a/helm-charts/common/tei/templates/deployment.yaml b/helm-charts/common/tei/templates/deployment.yaml index 442847df..44ca7987 100644 --- a/helm-charts/common/tei/templates/deployment.yaml +++ b/helm-charts/common/tei/templates/deployment.yaml @@ -30,6 +30,30 @@ spec: {{- end }} securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} + {{- if not (hasPrefix "/data/" .Values.EMBEDDING_MODEL_ID) }} + initContainers: + - name: model-downloader + envFrom: + - configMapRef: + name: {{ include "tei.fullname" . }}-config + securityContext: + {{- if .Values.global.modelUseHostPath }} + {} + {{- else }} + {{- toYaml .Values.securityContext | nindent 12 }} + {{- end }} + image: huggingface/downloader:0.17.3 + command: ['huggingface-cli', 'download'] + args: + - "--cache-dir" + - "/data" + - "--token" + - $(HF_TOKEN) + - $(MODEL_ID) + volumeMounts: + - mountPath: /data + name: model-volume + {{- end }} containers: - name: {{ .Chart.Name }} envFrom: diff --git a/helm-charts/common/tei/values.yaml b/helm-charts/common/tei/values.yaml index 44460a35..88f9651b 100644 --- a/helm-charts/common/tei/values.yaml +++ b/helm-charts/common/tei/values.yaml @@ -99,6 +99,7 @@ global: http_proxy: "" https_proxy: "" no_proxy: "" + HUGGINGFACEHUB_API_TOKEN: "insert-your-huggingface-token-here" # Choose where to save your downloaded models # Set modelUseHostPath for local directory, this is good for one node test. Example: diff --git a/helm-charts/common/teirerank/templates/configmap.yaml b/helm-charts/common/teirerank/templates/configmap.yaml index f8c25bc0..e1a047eb 100644 --- a/helm-charts/common/teirerank/templates/configmap.yaml +++ b/helm-charts/common/teirerank/templates/configmap.yaml @@ -32,3 +32,4 @@ data: {{- if .Values.MAX_WARMUP_SEQUENCE_LENGTH }} MAX_WARMUP_SEQUENCE_LENGTH: {{ .Values.MAX_WARMUP_SEQUENCE_LENGTH | quote }} {{- end }} + HF_TOKEN: {{ .Values.global.HUGGINGFACEHUB_API_TOKEN | quote}} diff --git a/helm-charts/common/teirerank/templates/deployment.yaml b/helm-charts/common/teirerank/templates/deployment.yaml index 2d0ec999..b1546e64 100644 --- a/helm-charts/common/teirerank/templates/deployment.yaml +++ b/helm-charts/common/teirerank/templates/deployment.yaml @@ -30,6 +30,30 @@ spec: {{- end }} securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} + {{- if not (hasPrefix "/data/" .Values.RERANK_MODEL_ID) }} + initContainers: + - name: model-downloader + envFrom: + - configMapRef: + name: {{ include "teirerank.fullname" . }}-config + securityContext: + {{- if .Values.global.modelUseHostPath }} + {} + {{- else }} + {{- toYaml .Values.securityContext | nindent 12 }} + {{- end }} + image: huggingface/downloader:0.17.3 + command: ['huggingface-cli', 'download'] + args: + - "--cache-dir" + - "/data" + - "--token" + - $(HF_TOKEN) + - $(MODEL_ID) + volumeMounts: + - mountPath: /data + name: model-volume + {{- end }} containers: - name: {{ .Chart.Name }} envFrom: diff --git a/helm-charts/common/teirerank/values.yaml b/helm-charts/common/teirerank/values.yaml index 4d0dedf2..63b1efeb 100644 --- a/helm-charts/common/teirerank/values.yaml +++ b/helm-charts/common/teirerank/values.yaml @@ -99,6 +99,7 @@ global: http_proxy: "" https_proxy: "" no_proxy: "" + HUGGINGFACEHUB_API_TOKEN: "insert-your-huggingface-token-here" # Choose where to save your downloaded models # Set modelUseHostPath for local directory, this is good for one node test. Example: diff --git a/helm-charts/common/tgi/templates/deployment.yaml b/helm-charts/common/tgi/templates/deployment.yaml index 04436e61..57f5b219 100644 --- a/helm-charts/common/tgi/templates/deployment.yaml +++ b/helm-charts/common/tgi/templates/deployment.yaml @@ -30,6 +30,30 @@ spec: {{- end }} securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} + {{- if not (hasPrefix "/data/" .Values.LLM_MODEL_ID) }} + initContainers: + - name: model-downloader + envFrom: + - configMapRef: + name: {{ include "tgi.fullname" . }}-config + securityContext: + {{- if .Values.global.modelUseHostPath }} + {} + {{- else }} + {{- toYaml .Values.securityContext | nindent 12 }} + {{- end }} + image: huggingface/downloader:0.17.3 + command: ['huggingface-cli', 'download'] + args: + - "--cache-dir" + - "/data" + - "--token" + - $(HF_TOKEN) + - $(MODEL_ID) + volumeMounts: + - mountPath: /data + name: model-volume + {{- end }} containers: - name: {{ .Chart.Name }} envFrom: diff --git a/helm-charts/common/vllm/templates/deployment.yaml b/helm-charts/common/vllm/templates/deployment.yaml index 66b5e372..5783ad8f 100644 --- a/helm-charts/common/vllm/templates/deployment.yaml +++ b/helm-charts/common/vllm/templates/deployment.yaml @@ -27,6 +27,30 @@ spec: {{- end }} securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} + {{- if not (hasPrefix "/data/" .Values.LLM_MODEL_ID) }} + initContainers: + - name: model-downloader + envFrom: + - configMapRef: + name: {{ include "vllm.fullname" . }}-config + securityContext: + {{- if .Values.global.modelUseHostPath }} + {} + {{- else }} + {{- toYaml .Values.securityContext | nindent 12 }} + {{- end }} + image: huggingface/downloader:0.17.3 + command: ['huggingface-cli', 'download'] + args: + - "--cache-dir" + - "/data" + - "--token" + - $(HF_TOKEN) + - {{ .Values.LLM_MODEL_ID | quote }} + volumeMounts: + - mountPath: /data + name: model-volume + {{- end }} containers: - name: {{ .Chart.Name }} envFrom: diff --git a/helm-charts/common/whisper/templates/configmap.yaml b/helm-charts/common/whisper/templates/configmap.yaml index 2e27dea5..39ab3db4 100644 --- a/helm-charts/common/whisper/templates/configmap.yaml +++ b/helm-charts/common/whisper/templates/configmap.yaml @@ -18,3 +18,4 @@ data: HF_ENDPOINT: {{ .Values.global.HF_ENDPOINT | quote}} {{- end }} HUGGINGFACE_HUB_CACHE: "/data" + HF_TOKEN: {{ .Values.global.HUGGINGFACEHUB_API_TOKEN | quote}} diff --git a/helm-charts/common/whisper/templates/deployment.yaml b/helm-charts/common/whisper/templates/deployment.yaml index c5d79899..c72653e1 100644 --- a/helm-charts/common/whisper/templates/deployment.yaml +++ b/helm-charts/common/whisper/templates/deployment.yaml @@ -27,6 +27,30 @@ spec: {{- end }} securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} + {{- if not (hasPrefix "/data/" .Values.ASR_MODEL_PATH) }} + initContainers: + - name: model-downloader + envFrom: + - configMapRef: + name: {{ include "whisper.fullname" . }}-config + securityContext: + {{- if .Values.global.modelUseHostPath }} + {} + {{- else }} + {{- toYaml .Values.securityContext | nindent 12 }} + {{- end }} + image: huggingface/downloader:0.17.3 + command: ['sh', '-c'] + args: + - | + huggingface-cli download --cache-dir /data --token $(HF_TOKEN) {{ .Values.ASR_MODEL_PATH | quote }}; + {{- if .Values.global.modelUseHostPath }} + chown -R 1000 /data/models--{{ replace "/" "--" .Values.ASR_MODEL_PATH }} + {{- end }} + volumeMounts: + - mountPath: /data + name: model-volume + {{- end }} containers: - name: {{ .Release.Name }} envFrom: diff --git a/helm-charts/common/whisper/values.yaml b/helm-charts/common/whisper/values.yaml index c368fe66..e3c62897 100644 --- a/helm-charts/common/whisper/values.yaml +++ b/helm-charts/common/whisper/values.yaml @@ -84,6 +84,7 @@ global: http_proxy: "" https_proxy: "" no_proxy: "" + HUGGINGFACEHUB_API_TOKEN: "insert-your-huggingface-token-here" # Choose where to save your downloaded models # Set modelUseHostPath for local directory, this is good for one node test. Example: