Skip to content

Commit

Permalink
Change overrideConfig passing method
Browse files Browse the repository at this point in the history
  • Loading branch information
lakinduakash committed Nov 5, 2024
1 parent eccb0c2 commit 86fae3c
Show file tree
Hide file tree
Showing 7 changed files with 250 additions and 149 deletions.
62 changes: 17 additions & 45 deletions helm/h2ogpt-chart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ A Helm chart for h2oGPT

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| agents.additionalConfig | object | `{}` | You can pass additional config here if overrideConfig does not have it. |
| agents.agent_workers | int | `5` | |
| agents.autoscaling.enabled | bool | `false` | |
| agents.autoscaling.maxReplicas | int | `2` | |
| agents.autoscaling.minReplicas | int | `1` | |
Expand All @@ -24,26 +26,8 @@ A Helm chart for h2oGPT
| agents.initImage.pullPolicy | string | `nil` | |
| agents.initImage.repository | string | `nil` | |
| agents.initImage.tag | string | `nil` | |
| agents.nodeSelector | string | `nil` | |
| agents.overrideConfig.agent_workers | int | `5` | |
| agents.overrideConfig.concurrency_count | int | `100` | |
| agents.overrideConfig.embedding_gpu_id | string | `"cpu"` | |
| agents.overrideConfig.enable_stt | bool | `false` | |
| agents.overrideConfig.enable_transcriptions | bool | `false` | |
| agents.overrideConfig.enable_tts | bool | `false` | |
| agents.overrideConfig.enforce_h2ogpt_api_key | bool | `true` | |
| agents.overrideConfig.enforce_h2ogpt_ui_key | bool | `false` | |
| agents.overrideConfig.hf_embedding_model | string | `"fake"` | |
| agents.overrideConfig.metadata_in_context | string | `""` | |
| agents.overrideConfig.num_async | int | `10` | |
| agents.overrideConfig.rotate_align_resize_image | bool | `false` | |
| agents.overrideConfig.score_model | string | `"None"` | |
| agents.overrideConfig.share | bool | `false` | |
| agents.overrideConfig.top_k_docs_max_show | int | `100` | |
| agents.overrideConfig.visible_hosts_tab | bool | `false` | |
| agents.overrideConfig.visible_login_tab | bool | `false` | |
| agents.overrideConfig.visible_models_tab | bool | `false` | |
| agents.overrideConfig.visible_system_tab | bool | `false` | |
| agents.nodeSelector | object | `{}` | Node selector for the agents pods. |
| agents.overrideConfig | object | `{}` | Supported configs are commented. If you don't pass any value, keep {} |
| agents.podAffinity | string | `nil` | Set hostname and zone to true for pod affinity rules based on hostname and zone. |
| agents.podAnnotations | object | `{}` | |
| agents.podLabels | object | `{}` | |
Expand All @@ -52,7 +36,9 @@ A Helm chart for h2oGPT
| agents.podSecurityContext.runAsNonRoot | bool | `true` | |
| agents.podSecurityContext.runAsUser | string | `nil` | |
| agents.replicaCount | int | `1` | |
| agents.resources.limits."nvidia.com/gpu" | int | `1` | |
| agents.resources.limits.memory | string | `"64Gi"` | |
| agents.resources.requests."nvidia.com/gpu" | int | `1` | |
| agents.resources.requests.memory | string | `"32Gi"` | |
| agents.securityContext.allowPrivilegeEscalation | bool | `false` | |
| agents.securityContext.capabilities.drop[0] | string | `"ALL"` | |
Expand All @@ -64,7 +50,7 @@ A Helm chart for h2oGPT
| agents.storage.class | string | `nil` | |
| agents.storage.size | string | `"128Gi"` | |
| agents.storage.useEphemeral | bool | `true` | |
| agents.tolerations | string | `nil` | |
| agents.tolerations | list | `[]` | Node taints to tolerate by the agents pods. |
| agents.updateStrategy.type | string | `"RollingUpdate"` | |
| caCertificates | string | `""` | CA certs |
| fullnameOverride | string | `""` | |
Expand All @@ -74,8 +60,9 @@ A Helm chart for h2oGPT
| global.visionModels.enabled | bool | `false` | Enable vision models |
| global.visionModels.rotateAlignResizeImage | bool | `false` | |
| global.visionModels.visibleModels | list | `[]` | Visible vision models, the vision model itslef needs to be set via modeLock or base_model. Ex: visibleModels: ['OpenGVLab/InternVL-Chat-V1-5'] |
| h2ogpt.agents | object | `{"agent_workers":5,"enabled":false}` | Enable agents |
| h2ogpt.agents.enabled | bool | `false` | Run agents with h2oGPT container |
| h2ogpt.additionalConfig | object | `{}` | You can pass additional config here if overrideConfig does not have it. |
| h2ogpt.agents | object | `{"agent_workers":5,"enabled":true}` | Enable agents |
| h2ogpt.agents.enabled | bool | `true` | Run agents with h2oGPT container |
| h2ogpt.enabled | bool | `true` | Enable h2oGPT |
| h2ogpt.env | object | `{}` | |
| h2ogpt.extraVolumeMounts | list | `[]` | Extra volume mounts |
Expand All @@ -87,27 +74,10 @@ A Helm chart for h2oGPT
| h2ogpt.initImage.pullPolicy | string | `nil` | |
| h2ogpt.initImage.repository | string | `nil` | |
| h2ogpt.initImage.tag | string | `nil` | |
| h2ogpt.nodeSelector | string | `nil` | |
| h2ogpt.overrideConfig.concurrency_count | int | `100` | |
| h2ogpt.overrideConfig.embedding_gpu_id | string | `"cpu"` | |
| h2ogpt.overrideConfig.enable_stt | bool | `false` | |
| h2ogpt.overrideConfig.enable_transcriptions | bool | `false` | |
| h2ogpt.overrideConfig.enable_tts | bool | `false` | |
| h2ogpt.overrideConfig.enforce_h2ogpt_api_key | bool | `true` | |
| h2ogpt.overrideConfig.enforce_h2ogpt_ui_key | bool | `false` | |
| h2ogpt.overrideConfig.hf_embedding_model | string | `"fake"` | |
| h2ogpt.overrideConfig.metadata_in_context | string | `""` | |
| h2ogpt.overrideConfig.num_async | int | `10` | |
| h2ogpt.overrideConfig.openai_server | bool | `true` | |
| h2ogpt.overrideConfig.openai_workers | int | `5` | |
| h2ogpt.overrideConfig.rotate_align_resize_image | bool | `false` | |
| h2ogpt.overrideConfig.score_model | string | `"None"` | |
| h2ogpt.overrideConfig.share | bool | `false` | |
| h2ogpt.overrideConfig.top_k_docs_max_show | int | `100` | |
| h2ogpt.overrideConfig.visible_hosts_tab | bool | `false` | |
| h2ogpt.overrideConfig.visible_login_tab | bool | `false` | |
| h2ogpt.overrideConfig.visible_models_tab | bool | `false` | |
| h2ogpt.overrideConfig.visible_system_tab | bool | `false` | |
| h2ogpt.nodeSelector | object | `{}` | Node selector for the h2ogpt pods. |
| h2ogpt.openai.enabled | bool | `true` | |
| h2ogpt.openai.openai_workers | int | `5` | |
| h2ogpt.overrideConfig | object | `{}` | Supported configs are commented. If you don't pass any value, keep {} |
| h2ogpt.podAffinity | string | `nil` | Set hostname and zone to true for pod affinity rules based on hostname and zone. |
| h2ogpt.podAnnotations | object | `{}` | |
| h2ogpt.podLabels | object | `{}` | |
Expand All @@ -116,7 +86,9 @@ A Helm chart for h2oGPT
| h2ogpt.podSecurityContext.runAsNonRoot | bool | `true` | |
| h2ogpt.podSecurityContext.runAsUser | string | `nil` | |
| h2ogpt.replicaCount | int | `1` | |
| h2ogpt.resources.limits."nvidia.com/gpu" | int | `0` | |
| h2ogpt.resources.limits.memory | string | `"64Gi"` | |
| h2ogpt.resources.requests."nvidia.com/gpu" | int | `0` | |
| h2ogpt.resources.requests.memory | string | `"32Gi"` | |
| h2ogpt.securityContext.allowPrivilegeEscalation | bool | `false` | |
| h2ogpt.securityContext.capabilities.drop[0] | string | `"ALL"` | |
Expand All @@ -131,7 +103,7 @@ A Helm chart for h2oGPT
| h2ogpt.storage.class | string | `nil` | |
| h2ogpt.storage.size | string | `"128Gi"` | |
| h2ogpt.storage.useEphemeral | bool | `true` | |
| h2ogpt.tolerations | string | `nil` | |
| h2ogpt.tolerations | list | `[]` | Node taints to tolerate by the h2ogpt pods. |
| h2ogpt.updateStrategy.type | string | `"RollingUpdate"` | |
| nameOverride | string | `""` | |
| namespaceOverride | string | `""` | |
Expand Down
129 changes: 116 additions & 13 deletions helm/h2ogpt-chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -70,26 +70,129 @@ Create the name of the service account to use
{{- end }}

{{/*
Configs for agents server
Config for h2oGPT
*/}}

{{- define "agents.overrideConfig" -}}
agent_server: True
agent_port: "5004"
{{- define "h2ogpt.config" -}}
{{- with .Values.h2ogpt }}
verbose: {{ default "True" .overrideConfig.verbose }}
{{- if .overrideConfig.heap_app_id }}
heap_app_id: {{ .overrideConfig.heap_app_id }}
{{- end }}
num_async: {{ default 10 .overrideConfig.num_async }}
save_dir: {{ default "/docker_logs" .overrideConfig.save_dir }}
score_model: {{ default "None" .overrideConfig.score_model }}
share: {{ default "False" .overrideConfig.share }}
enforce_h2ogpt_api_key: {{ default "False" .overrideConfig.enforce_h2ogpt_api_key }}
enforce_h2ogpt_ui_key: {{ default "False" .overrideConfig.enforce_h2ogpt_ui_key }}
{{- if .overrideConfig.h2ogpt_api_keys }}
h2ogpt_api_keys: {{ .overrideConfig.h2ogpt_api_keys }}
{{- end }}
{{- if .overrideConfig.use_auth_token }}
use_auth_token: {{ .overrideConfig.use_auth_token }}
{{- end }}
visible_models: {{ default "['meta-llama/Meta-Llama-3.1-8B-Instruct']" .overrideConfig.visible_models }}
visible_vision_models: {{ default "['mistralai/Pixtral-12B-2409']" .overrideConfig.visible_vision_models }}
top_k_docs_max_show: {{ default 100 .overrideConfig.top_k_docs_max_show }}
{{- if .overrideConfig.admin_pass }}
admin_pass: {{ .overrideConfig.admin_pass }}
{{- end }}
{{- if .openai.enabled }}
openai_server: "True"
openai_port: 5000
openai_workers: {{ default 5 .openai.openai_workers }}
{{- end }}
{{- if .agents.enabled }}
agent_server: "True"
agent_port: 5004
agent_workers: {{ .agents.agent_workers }}
{{- end }}
function_server: {{ default "True" .overrideConfig.function_server }}
function_port: 5002
function_server_workers: {{ default 1 .overrideConfig.function_server_workers }}
multiple_workers_gunicorn: {{ default "True" .overrideConfig.multiple_workers_gunicorn }}
llava_model: {{ default "openai:mistralai/Pixtral-12B-2409" .overrideConfig.llava_model }}
enable_llava: {{ default "True" .overrideConfig.enable_llava }}
{{- if ge (int (index .resources.requests "nvidia.com/gpu") ) (int 1) }}
enable_tts: {{ default "False" .overrideConfig.enable_tts }}
enable_stt: {{ default "True" .overrideConfig.enable_stt }}
enable_transcriptions: {{ default "True" .overrideConfig.enable_transcriptions }}
asr_model: {{ default "distil-whisper/distil-large-v3" .overrideConfig.asr_model }}
pre_load_embedding_model: {{ default "True" .overrideConfig.pre_load_embedding_model }}
pre_load_image_audio_models: {{ default "True" .overrideConfig.pre_load_image_audio_models }}
cut_distance: {{ default 10000 .overrideConfig.cut_distance }}
hf_embedding_model: {{ default "BAAI/bge-large-en-v1.5" .overrideConfig.hf_embedding_model }}
enable_captions: {{ default "False" .overrideConfig.enable_captions }}
enable_doctr: {{ default "True" .overrideConfig.enable_doctr }}
{{- else }}
enable_tts: {{ default "False" .overrideConfig.enable_tts }}
enable_stt: {{ default "False" .overrideConfig.enable_stt }}
enable_transcriptions: {{ default "False" .overrideConfig.enable_transcriptions }}
embedding_gpu_id: {{ default "cpu" .overrideConfig.embedding_gpu_id }}
hf_embedding_model: {{ default "fake" .overrideConfig.hf_embedding_model }}
pre_load_embedding_model: {{ default "False" .overrideConfig.pre_load_embedding_model }}
pre_load_image_audio_models: {{ default "False" .overrideConfig.pre_load_image_audio_models }}
enable_captions: {{ default "False" .overrideConfig.enable_captions }}
enable_doctr: {{ default "False" .overrideConfig.enable_doctr }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Configs for agents with h2ogpt
Config for agents
*/}}

{{- define "h2ogpt.overrideConfig" -}}
{{- if .Values.h2ogpt.agents.enabled }}
agent_server: True
agent_port: "5004"
multiple_workers_gunicorn: True
agent_workers: {{ .Values.h2ogpt.agents.agent_workers}}
{{- define "agents.config" -}}
{{- with .Values.agents }}
verbose: {{ default "True" .overrideConfig.verbose }}
{{- if .overrideConfig.heap_app_id }}
heap_app_id: {{ .overrideConfig.heap_app_id }}
{{- end }}
num_async: {{ default 10 .overrideConfig.num_async }}
save_dir: {{ default "/docker_logs" .overrideConfig.save_dir }}
score_model: {{ default "None" .overrideConfig.score_model }}
share: {{ default "False" .overrideConfig.share }}
enforce_h2ogpt_api_key: {{ default "False" .overrideConfig.enforce_h2ogpt_api_key }}
enforce_h2ogpt_ui_key: {{ default "False" .overrideConfig.enforce_h2ogpt_ui_key }}
{{- if .overrideConfig.h2ogpt_api_keys }}
h2ogpt_api_keys: {{ .overrideConfig.h2ogpt_api_keys }}
{{- end }}
{{- if .overrideConfig.use_auth_token }}
use_auth_token: {{ .overrideConfig.use_auth_token }}
{{- end }}
visible_models: {{ default "['meta-llama/Meta-Llama-3.1-8B-Instruct']" .overrideConfig.visible_models }}
visible_vision_models: {{ default "['mistralai/Pixtral-12B-2409']" .overrideConfig.visible_vision_models }}
top_k_docs_max_show: {{ default 100 .overrideConfig.top_k_docs_max_show }}
{{- if .overrideConfig.admin_pass }}
admin_pass: {{ .overrideConfig.admin_pass }}
{{- end }}
agent_server: "True"
agent_port: 5004
agent_workers: {{ default 5 .agent_workers }}
multiple_workers_gunicorn: {{ default "True" .overrideConfig.multiple_workers_gunicorn }}
llava_model: {{ default "openai:mistralai/Pixtral-12B-2409" .overrideConfig.llava_model }}
enable_llava: {{ default "True" .overrideConfig.enable_llava }}
{{- if ge (int (index .resources.requests "nvidia.com/gpu") ) (int 1) }}
enable_tts: {{ default "False" .overrideConfig.enable_tts }}
enable_stt: {{ default "True" .overrideConfig.enable_stt }}
enable_transcriptions: {{ default "True" .overrideConfig.enable_transcriptions }}
asr_model: {{ default "distil-whisper/distil-large-v3" .overrideConfig.asr_model }}
pre_load_embedding_model: {{ default "True" .overrideConfig.pre_load_embedding_model }}
pre_load_image_audio_models: {{ default "True" .overrideConfig.pre_load_image_audio_models }}
cut_distance: {{ default 10000 .overrideConfig.cut_distance }}
hf_embedding_model: {{ default "BAAI/bge-large-en-v1.5" .overrideConfig.hf_embedding_model }}
enable_captions: {{ default "False" .overrideConfig.enable_captions }}
enable_doctr: {{ default "True" .overrideConfig.enable_doctr }}
{{- else }}
agents_server: False
enable_tts: {{ default "False" .overrideConfig.enable_tts }}
enable_stt: {{ default "False" .overrideConfig.enable_stt }}
enable_transcriptions: {{ default "False" .overrideConfig.enable_transcriptions }}
embedding_gpu_id: {{ default "cpu" .overrideConfig.embedding_gpu_id }}
hf_embedding_model: {{ default "fake" .overrideConfig.hf_embedding_model }}
pre_load_embedding_model: {{ default "False" .overrideConfig.pre_load_embedding_model }}
pre_load_image_audio_models: {{ default "False" .overrideConfig.pre_load_image_audio_models }}
enable_captions: {{ default "False" .overrideConfig.enable_captions }}
enable_doctr: {{ default "False" .overrideConfig.enable_doctr }}
{{- end }}

{{- end }}
{{- end }}
18 changes: 14 additions & 4 deletions helm/h2ogpt-chart/templates/agents-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,20 @@ metadata:
labels:
{{- include "h2ogpt.labels" . | nindent 4 }}
data:
{{- range $key, $value := ( include "agents.overrideConfig" . | fromYaml ) }}
{{ printf "H2OGPT_%s" $key | upper }}: {{ $value | quote }}
{{- range $key, $value := ( include "agents.config" . | fromYaml ) }}
{{- /* convert boolean value to cli compatiblity */}}
{{- if or ( eq "true" ( $value | toString )) ( eq "false" ( $value | toString )) }}
{{ printf "H2OGPT_%s" $key | upper }}: {{ $value | quote | title }}
{{- else }}
{{ printf "H2OGPT_%s" $key | upper }}: {{ $value | quote }}
{{- end }}
{{- end }}
{{- range $key, $value := .Values.agents.overrideConfig }}
{{ printf "H2OGPT_%s" $key | upper }}: {{ $value | quote }}
{{- range $key, $value := ( .Values.agents.additionalConfig ) }}
{{- /* convert boolean value to cli compatiblity */}}
{{- if or ( eq "true" ( $value | toString )) ( eq "false" ( $value | toString )) }}
{{ printf "H2OGPT_%s" $key | upper }}: {{ $value | quote | title }}
{{- else }}
{{ printf "H2OGPT_%s" $key | upper }}: {{ $value | quote }}
{{- end }}
{{- end }}
{{- end }}
18 changes: 14 additions & 4 deletions helm/h2ogpt-chart/templates/h2ogpt-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,20 @@ metadata:
labels:
{{- include "h2ogpt.labels" . | nindent 4 }}
data:
{{- range $key, $value := ( include "h2ogpt.overrideConfig" . | fromYaml ) }}
{{ printf "H2OGPT_%s" $key | upper }}: {{ $value | quote }}
{{- range $key, $value := ( include "h2ogpt.config" . | fromYaml ) }}
{{- /* convert boolean value to cli compatiblity */}}
{{- if or ( eq "true" ($value | toString)) ( eq "false" ($value | toString)) }}
{{ printf "H2OGPT_%s" $key | upper }}: {{ $value | quote | title }}
{{- else }}
{{ printf "H2OGPT_%s" $key | upper }}: {{ $value | quote }}
{{- end }}
{{- end }}
{{- range $key, $value := .Values.h2ogpt.overrideConfig }}
{{ printf "H2OGPT_%s" $key | upper }}: {{ $value | quote }}
{{- range $key, $value := ( .Values.h2ogpt.additionalConfig ) }}
{{- /* convert boolean value to cli compatiblity */}}
{{- if or ( eq "true" ($value | toString)) ( eq "false" ($value | toString)) }}
{{ printf "H2OGPT_%s" $key | upper }}: {{ $value | quote | title }}
{{- else }}
{{ printf "H2OGPT_%s" $key | upper }}: {{ $value | quote }}
{{- end }}
{{- end }}
{{- end }}
2 changes: 1 addition & 1 deletion helm/h2ogpt-chart/templates/h2ogpt-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ spec:
- name: http
containerPort: 7860
protocol: TCP
{{- if .Values.h2ogpt.overrideConfig.openai_server }}
{{- if .Values.h2ogpt.openai.enabled }}
- name: openai
containerPort: 5000
protocol: TCP
Expand Down
2 changes: 1 addition & 1 deletion helm/h2ogpt-chart/templates/h2ogpt-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
protocol: TCP
port: {{ .Values.h2ogpt.service.webPort }}
targetPort: 7860
{{- if .Values.h2ogpt.overrideConfig.openai_server }}
{{- if .Values.h2ogpt.openai.enabled }}
- name: openai
protocol: TCP
port: {{ .Values.h2ogpt.service.openaiPort }}
Expand Down
Loading

0 comments on commit 86fae3c

Please sign in to comment.