From 80877b01ec56de1f14a80ca6139a332e755f2d2c Mon Sep 17 00:00:00 2001 From: Dmitri Sashchenko Date: Wed, 25 Nov 2026 16:51:56 +0600 Subject: [PATCH] Configure on-prem LLM providers through Helm values --- .helm/templates/00-app-secret.yaml | 7 ++++++ .helm/templates/02-web.yaml | 1 + .helm/templates/04-worker.yaml | 1 + .helm/templates/98-migrate-job.yaml | 1 + .helm/templates/99-update-cluster-job.yaml | 1 + .helm/templates/_envs.tpl | 27 ++++++++++++++++++++++ .helm/templates/_helpers.tpl | 3 +++ .helm/values.yaml | 9 ++++++++ README.md | 23 ++++++++++++++++++ 9 files changed, 73 insertions(+) diff --git a/.helm/templates/00-app-secret.yaml b/.helm/templates/00-app-secret.yaml index db1865a..acfa1d8 100644 --- a/.helm/templates/00-app-secret.yaml +++ b/.helm/templates/00-app-secret.yaml @@ -1,4 +1,5 @@ {{- if not .Values.secrets.existingSecret }} +{{- $llm := .Values.app.ai.llm | default dict }} --- apiVersion: v1 kind: Secret @@ -20,6 +21,12 @@ stringData: livekit-api-secret: {{ .Values.app.livekit.apiSecret | quote }} yandex-client-password: {{ .Values.app.yandex.clientPassword | quote }} yandex-ai-api-key: {{ .Values.app.ai.yandex.apiKey | quote }} + {{- with $llm.apiKey }} + llm-api-key: {{ . | quote }} + {{- end }} + {{- with $llm.embeddingApiKey }} + llm-embedding-api-key: {{ . | quote }} + {{- end }} google-client-secret: {{ .Values.app.integrations.google.clientSecret | quote }} slack-client-secret: {{ .Values.app.slack.clientSecret | quote }} slack-verification-token: {{ .Values.app.slack.verificationToken | quote }} diff --git a/.helm/templates/02-web.yaml b/.helm/templates/02-web.yaml index 7b6c0de..63af789 100644 --- a/.helm/templates/02-web.yaml +++ b/.helm/templates/02-web.yaml @@ -40,6 +40,7 @@ spec: containerPort: 9000 env: {{- include "envs_all" . | indent 12 }} + {{- include "envs_llm" . | indent 12 }} {{- include "envs_nanabush_player_signing" . | indent 12 }} - name: VIDEO_CONVERTER_ENABLED value: {{ .Values.app.videoConverter.enabled | quote }} diff --git a/.helm/templates/04-worker.yaml b/.helm/templates/04-worker.yaml index 8901c90..196124b 100644 --- a/.helm/templates/04-worker.yaml +++ b/.helm/templates/04-worker.yaml @@ -32,6 +32,7 @@ spec: command: ["hrbox-worker"] env: {{- include "envs_all" . | indent 12 }} + {{- include "envs_llm" . | indent 12 }} - name: VIDEO_CONVERTER_ENABLED value: {{ .Values.app.videoConverter.enabled | quote }} {{- include "hrbox.resources" (dict "ctx" . "component" "worker") | indent 10 }} diff --git a/.helm/templates/98-migrate-job.yaml b/.helm/templates/98-migrate-job.yaml index 9d3eb6f..13f39c9 100644 --- a/.helm/templates/98-migrate-job.yaml +++ b/.helm/templates/98-migrate-job.yaml @@ -40,6 +40,7 @@ spec: command: ["php", "yii", "migrate", "--interactive=0"] env: {{- include "envs_all" . | indent 12 }} + {{- include "envs_llm" . | indent 12 }} {{- include "hrbox.resources" (dict "ctx" . "component" "jobs") | indent 10 }} volumes: - name: configs diff --git a/.helm/templates/99-update-cluster-job.yaml b/.helm/templates/99-update-cluster-job.yaml index 360d09d..5b03371 100644 --- a/.helm/templates/99-update-cluster-job.yaml +++ b/.helm/templates/99-update-cluster-job.yaml @@ -27,4 +27,5 @@ spec: command: ["php", "yii", "util/update-cluster"] env: {{- include "envs_all" . | indent 12 }} + {{- include "envs_llm" . | indent 12 }} {{- include "hrbox.resources" (dict "ctx" . "component" "jobs") | indent 10 }} diff --git a/.helm/templates/_envs.tpl b/.helm/templates/_envs.tpl index e694f65..56adb6d 100644 --- a/.helm/templates/_envs.tpl +++ b/.helm/templates/_envs.tpl @@ -314,3 +314,30 @@ - name: OTEL_LOG_LEVEL value: "info" {{- end }} + +{{- define "envs_llm" }} +{{- $llm := .Values.app.ai.llm | default dict }} +{{- $externalSecret := not (empty .Values.secrets.existingSecret) }} +{{- with $llm.baseUri }} +- name: LLM_BASE_URI + value: {{ . | quote }} +{{- end }} +{{- with $llm.chatModel }} +- name: LLM_CHAT_MODEL + value: {{ . | quote }} +{{- end }} +{{- with $llm.embeddingBaseUri }} +- name: LLM_EMBEDDING_BASE_URI + value: {{ . | quote }} +{{- end }} +{{- with $llm.embeddingModel }} +- name: LLM_EMBEDDING_MODEL + value: {{ . | quote }} +{{- end }} +{{- if or $llm.apiKey (and $externalSecret $llm.baseUri) }} +{{- include "hrbox.secretEnv" (dict "ctx" . "env" "LLM_API_KEY" "key" "llm-api-key" "optional" $externalSecret) | nindent 0 }} +{{- end }} +{{- if or $llm.embeddingApiKey (and $externalSecret $llm.embeddingBaseUri) }} +{{- include "hrbox.secretEnv" (dict "ctx" . "env" "LLM_EMBEDDING_API_KEY" "key" "llm-embedding-api-key" "optional" $externalSecret) | nindent 0 }} +{{- end }} +{{- end }} diff --git a/.helm/templates/_helpers.tpl b/.helm/templates/_helpers.tpl index 2d1d224..2596dbd 100644 --- a/.helm/templates/_helpers.tpl +++ b/.helm/templates/_helpers.tpl @@ -74,6 +74,9 @@ imagePullSecrets: secretKeyRef: name: {{ include "hrbox.secretName" .ctx | quote }} key: {{ .key | quote }} + {{- if .optional }} + optional: true + {{- end }} {{- end -}} {{- define "nanabushPlayer.host" -}} diff --git a/.helm/values.yaml b/.helm/values.yaml index 8a64f28..2010452 100644 --- a/.helm/values.yaml +++ b/.helm/values.yaml @@ -446,6 +446,15 @@ app: docsIndexEnabled: "true" semanticIndexEnabled: "true" semanticIndexUseBatch: "true" + llm: + # URL и ключ OpenAI-совместимого API для чата. + baseUri: "" + apiKey: "" + chatModel: "" + # URL и ключ OpenAI-совместимого API для эмбеддингов. + embeddingBaseUri: "" + embeddingApiKey: "" + embeddingModel: "" yandex: folderId: "" apiKey: "" diff --git a/README.md b/README.md index d8c11ef..469e13b 100644 --- a/README.md +++ b/README.md @@ -171,6 +171,8 @@ kubectl -n hrbox exec -it deploy/hrbox-worker -- \ | `livekit-api-secret` | `app.livekit.apiSecret` | | `yandex-client-password` | `app.yandex.clientPassword` | | `yandex-ai-api-key` | `app.ai.yandex.apiKey` | +| `llm-api-key` | `app.ai.llm.apiKey` (если API требует ключ для чата) | +| `llm-embedding-api-key` | `app.ai.llm.embeddingApiKey` (если API требует ключ для эмбеддингов) | | `google-client-secret` | `app.integrations.google.clientSecret` | | `slack-client-secret` | `app.slack.clientSecret` | | `slack-verification-token` | `app.slack.verificationToken` | @@ -283,6 +285,27 @@ app: effect: NoSchedule ``` +### OpenAI-совместимый API + +Для чата и эмбеддингов можно указать свой API в `app.ai.llm`: + +```yaml +app: + ai: + llm: + baseUri: "https://example-endpoint.cc/v1/" + apiKey: "" + chatModel: "model/large" + embeddingBaseUri: "https://example-endpoint.cc/v1/" + embeddingApiKey: "" + embeddingModel: "model/embedding" +``` + +Если URL пуст, HRBox обращается к HRBox Hub. Если имя модели пустое, HRBox +использует модель по умолчанию. Для API с авторизацией укажите ключ в +`apiKey` / `embeddingApiKey` или добавьте его в Secret, указанный в +`secrets.existingSecret`. + ### Трассировка ```yaml -- 2.54.0