From 5b0a1a343cdd2020633f54ce497d37200101ba51 Mon Sep 17 00:00:00 2001 From: Daniel McKnight Date: Fri, 20 Dec 2024 09:17:02 -0800 Subject: [PATCH 1/2] Update charts to include `brainforge-llm-service` Update configuration to support `brainforge-llm-service` Update CLI to include brainforge configuration --- neon_diana_utils/configuration.py | 30 ++++++++- .../backend/diana-backend/Chart.yaml | 2 +- .../backend/mq-services/Chart.yaml | 6 +- .../backend/mq-services/values.yaml | 3 + .../mq/brainforge-llm-service/.helmignore | 23 +++++++ .../mq/brainforge-llm-service/Chart.yaml | 12 ++++ .../templates/_helpers.tpl | 62 +++++++++++++++++++ .../templates/deployment.yaml | 1 + .../templates/service.yaml | 1 + .../mq/brainforge-llm-service/values.yaml | 12 ++++ .../templates/backend/values.yaml | 2 + .../templates/mq_user_mapping.yml | 2 + .../templates/rmq_backend_config.yml | 16 +++++ 13 files changed, 168 insertions(+), 4 deletions(-) create mode 100644 neon_diana_utils/helm_charts/mq/brainforge-llm-service/.helmignore create mode 100644 neon_diana_utils/helm_charts/mq/brainforge-llm-service/Chart.yaml create mode 100644 neon_diana_utils/helm_charts/mq/brainforge-llm-service/templates/_helpers.tpl create mode 100644 neon_diana_utils/helm_charts/mq/brainforge-llm-service/templates/deployment.yaml create mode 100644 neon_diana_utils/helm_charts/mq/brainforge-llm-service/templates/service.yaml create mode 100644 neon_diana_utils/helm_charts/mq/brainforge-llm-service/values.yaml diff --git a/neon_diana_utils/configuration.py b/neon_diana_utils/configuration.py index b434f423..18aa7672 100644 --- a/neon_diana_utils/configuration.py +++ b/neon_diana_utils/configuration.py @@ -171,6 +171,27 @@ def make_keys_config(write_config: bool, config_confirmed = \ click.confirm("Is this configuration correct?") + brainforge_config = {"clients": {}} + if click.confirm("Configure BrainForge LLMs?"): + hosts_complete = False + while not hosts_complete: + name = click.prompt("vLLM Endpoint Name", type=str) + url = click.prompt("vLLM URL", type=str) + key = click.prompt("vLLM API key", type=str) + client_config = {name: {"api_url": url, "api_key": key}} + click.echo(pformat(client_config)) + if click.confirm("Is this configuration correct?"): + brainforge_config["clients"][name] = client_config[name] + if not click.confirm("Add another client?"): + hosts_complete = True + confirmed = False + while not confirmed: + hf_token = click.prompt("HuggingFace Token", type=str) + brainforge_config['hf_token'] = hf_token + click.echo(brainforge_config) + if click.confirm("Is this configuration correct?"): + confirmed = True + chatgpt_config = dict() if click.confirm("Configure ChatGPT LLM?"): config_confirmed = False @@ -371,7 +392,8 @@ def make_keys_config(write_config: bool, "aggregators": { "sentry": sentry_sdk_config, } - } + }, + "brainforge_llm_service": brainforge_config } if write_config: click.echo(f"Writing configuration to {output_file}") @@ -649,6 +671,7 @@ def _get_unconfigured_mq_backend_services(config: dict) -> Set[str]: config_to_service = {'api_services': 'neon-api-proxy', 'keys.emails': 'neon-email-proxy', 'keys.track_my_brands': 'neon-brands-service', + 'brainforge_llm_service': 'brainforge-llm-service', 'LLM_CHAT_GPT': 'neon-llm-chatgpt', 'LLM_VLLM': 'neon-llm-vllm', 'LLM_FASTCHAT': 'neon-llm-fastchat', @@ -747,7 +770,8 @@ def configure_backend(username: str = None, else: # Define a default value so secret can be generated encoded_token = get_github_encoded_auth("", "") - to_disable = ['neon-brands-service', 'neon-script-parser'] + to_disable = ['neon-brands-service', 'neon-script-parser', + 'brainforge-llm-service'] disabled_mq_services += to_disable confirmed = False email = '' @@ -805,6 +829,8 @@ def configure_backend(username: str = None, diana_config = join(output_path, "xdg", "config", "neon", "diana.yaml") else: raise RuntimeError(f"{orchestrator} is not yet supported") + + # Generate configuration for required core services try: # Generate RabbitMQ config username = username or click.prompt("RabbitMQ Admin Username", type=str) diff --git a/neon_diana_utils/helm_charts/backend/diana-backend/Chart.yaml b/neon_diana_utils/helm_charts/backend/diana-backend/Chart.yaml index 556d6a28..4a8d0977 100644 --- a/neon_diana_utils/helm_charts/backend/diana-backend/Chart.yaml +++ b/neon_diana_utils/helm_charts/backend/diana-backend/Chart.yaml @@ -35,5 +35,5 @@ dependencies: version: 0.0.15 repository: file://../http-services - name: diana-mq - version: 0.0.19 + version: 0.0.20 repository: file://../mq-services \ No newline at end of file diff --git a/neon_diana_utils/helm_charts/backend/mq-services/Chart.yaml b/neon_diana_utils/helm_charts/backend/mq-services/Chart.yaml index 0b77cefa..4b6d66f6 100644 --- a/neon_diana_utils/helm_charts/backend/mq-services/Chart.yaml +++ b/neon_diana_utils/helm_charts/backend/mq-services/Chart.yaml @@ -3,7 +3,7 @@ name: diana-mq description: Deploy DIANA MQ Services type: application -version: 0.0.19 +version: 0.0.20 appVersion: "1.0.1a31" dependencies: - name: neon-api-proxy @@ -30,6 +30,10 @@ dependencies: alias: neon-users-service version: 0.0.1 repository: file://../../mq/neon-users-service + - name: brainforge-llm-service + alias: brainforge-llm-service + version: 0.0.1 + repository: file://../../mq/brainforge-llm-service - name: neon-llm-chatgpt alias: neon-llm-chatgpt version: 0.0.7 diff --git a/neon_diana_utils/helm_charts/backend/mq-services/values.yaml b/neon_diana_utils/helm_charts/backend/mq-services/values.yaml index edd9b5be..4b6accc6 100644 --- a/neon_diana_utils/helm_charts/backend/mq-services/values.yaml +++ b/neon_diana_utils/helm_charts/backend/mq-services/values.yaml @@ -18,6 +18,9 @@ neon-script-parser: neon-users-service: image: tag: *tag +brainforge-llm-service: + image: + tag: *tag neon-llm-chatgpt: image: tag: *tag diff --git a/neon_diana_utils/helm_charts/mq/brainforge-llm-service/.helmignore b/neon_diana_utils/helm_charts/mq/brainforge-llm-service/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/neon_diana_utils/helm_charts/mq/brainforge-llm-service/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/neon_diana_utils/helm_charts/mq/brainforge-llm-service/Chart.yaml b/neon_diana_utils/helm_charts/mq/brainforge-llm-service/Chart.yaml new file mode 100644 index 00000000..f70b05c5 --- /dev/null +++ b/neon_diana_utils/helm_charts/mq/brainforge-llm-service/Chart.yaml @@ -0,0 +1,12 @@ +apiVersion: v2 +name: brainforge-llm-service +description: Deploy a Brainforge LLM Backend Service + +type: application +version: 0.0.1 +appVersion: "1.0.1a29" + +dependencies: + - name: base-mq + version: 0.0.10 + repository: file://../../base/base-mq \ No newline at end of file diff --git a/neon_diana_utils/helm_charts/mq/brainforge-llm-service/templates/_helpers.tpl b/neon_diana_utils/helm_charts/mq/brainforge-llm-service/templates/_helpers.tpl new file mode 100644 index 00000000..d95515b6 --- /dev/null +++ b/neon_diana_utils/helm_charts/mq/brainforge-llm-service/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "brainforge-llm-service.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "brainforge-llm-service.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "brainforge-llm-service.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "brainforge-llm-service.labels" -}} +helm.sh/chart: {{ include "brainforge-llm-service.chart" . }} +{{ include "brainforge-llm-service.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "brainforge-llm-service.selectorLabels" -}} +app.kubernetes.io/name: {{ include "brainforge-llm-service.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "brainforge-llm-service.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "brainforge-llm-service.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/neon_diana_utils/helm_charts/mq/brainforge-llm-service/templates/deployment.yaml b/neon_diana_utils/helm_charts/mq/brainforge-llm-service/templates/deployment.yaml new file mode 100644 index 00000000..41547ae7 --- /dev/null +++ b/neon_diana_utils/helm_charts/mq/brainforge-llm-service/templates/deployment.yaml @@ -0,0 +1 @@ +{{- include "base-mq.deployment" .}} \ No newline at end of file diff --git a/neon_diana_utils/helm_charts/mq/brainforge-llm-service/templates/service.yaml b/neon_diana_utils/helm_charts/mq/brainforge-llm-service/templates/service.yaml new file mode 100644 index 00000000..80730915 --- /dev/null +++ b/neon_diana_utils/helm_charts/mq/brainforge-llm-service/templates/service.yaml @@ -0,0 +1 @@ +{{- include "base-mq.service" .}} \ No newline at end of file diff --git a/neon_diana_utils/helm_charts/mq/brainforge-llm-service/values.yaml b/neon_diana_utils/helm_charts/mq/brainforge-llm-service/values.yaml new file mode 100644 index 00000000..1ae10e7c --- /dev/null +++ b/neon_diana_utils/helm_charts/mq/brainforge-llm-service/values.yaml @@ -0,0 +1,12 @@ +serviceName: backend-mq-brainforge-llm +replicaCount: 1 +configSecret: diana-config +image: + pullSecret: github-auth + repository: ghcr.io/neongeckocom/brainforge-llm-service + pullPolicy: Always + tag: dev +resources: + requests: + memory: "500Mi" + cpu: "1.0" diff --git a/neon_diana_utils/templates/backend/values.yaml b/neon_diana_utils/templates/backend/values.yaml index 404cb863..a1950f88 100644 --- a/neon_diana_utils/templates/backend/values.yaml +++ b/neon_diana_utils/templates/backend/values.yaml @@ -25,5 +25,7 @@ backend: image: {} neon-users-service: image: {} + brainforge-llm-service: + image: {} letsencrypt: server: https://acme-v02.api.letsencrypt.org/directory diff --git a/neon_diana_utils/templates/mq_user_mapping.yml b/neon_diana_utils/templates/mq_user_mapping.yml index 1acf890f..83320c21 100644 --- a/neon_diana_utils/templates/mq_user_mapping.yml +++ b/neon_diana_utils/templates/mq_user_mapping.yml @@ -29,6 +29,8 @@ neon_core: - chat_api_proxy chat_observer: - chat_observer +brainforge_llm_service: + - brainforge_llm_service neon_llm_submind: - neon_llm_submind neon_bot_submind: diff --git a/neon_diana_utils/templates/rmq_backend_config.yml b/neon_diana_utils/templates/rmq_backend_config.yml index 65195929..2da4f707 100644 --- a/neon_diana_utils/templates/rmq_backend_config.yml +++ b/neon_diana_utils/templates/rmq_backend_config.yml @@ -93,6 +93,11 @@ users: password: tags: - chatbots + - name: "brainforge_llm_service" + password: + tags: + - backend + - llm vhosts: - name: "/neon_emails" - name: "/neon_api" @@ -105,6 +110,7 @@ vhosts: - name: "/neon_chat_api" - name: "/chatbots" - name: "/neon_users" + - name: "/brainforge" permissions: - user: "neon_core" vhost: "/neon_chat_api" @@ -258,3 +264,13 @@ permissions: configure: ".*" write: ".*" read: ".*" + - user: "neon_api_utils" + vhost: "/brainforge" + configure: "./*" + write: "./*" + read: "./*" + - user: "brainforge_llm_service" + vhost: "/brainforge" + configure: "./*" + write: "./*" + read: "./*" \ No newline at end of file From 731544e376fa4df7585fee68f35388d7196b2bf2 Mon Sep 17 00:00:00 2001 From: Daniel McKnight Date: Mon, 23 Dec 2024 15:46:03 -0800 Subject: [PATCH 2/2] Update backend deployment version to include all changes --- neon_diana_utils/helm_charts/backend/diana-backend/Chart.yaml | 2 +- neon_diana_utils/templates/backend/Chart.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/neon_diana_utils/helm_charts/backend/diana-backend/Chart.yaml b/neon_diana_utils/helm_charts/backend/diana-backend/Chart.yaml index 4a8d0977..3919101c 100644 --- a/neon_diana_utils/helm_charts/backend/diana-backend/Chart.yaml +++ b/neon_diana_utils/helm_charts/backend/diana-backend/Chart.yaml @@ -15,7 +15,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.1.30 +version: 0.1.31 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/neon_diana_utils/templates/backend/Chart.yaml b/neon_diana_utils/templates/backend/Chart.yaml index 5f8241a8..4a230fb7 100644 --- a/neon_diana_utils/templates/backend/Chart.yaml +++ b/neon_diana_utils/templates/backend/Chart.yaml @@ -8,5 +8,5 @@ appVersion: "1.0.1a5" dependencies: - name: backend - version: 0.1.30 + version: 0.1.31 repository: https://neongeckocom.github.io/neon-diana-utils \ No newline at end of file