Skip to content

Commit

Permalink
Merge branch 'opea-project:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Yugar-1 authored Nov 6, 2024
2 parents 265aa48 + c476fde commit 97c6774
Show file tree
Hide file tree
Showing 77 changed files with 2,361 additions and 29 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/pr-chart-validate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ concurrency:
cancel-in-progress: true

env:
CHARTS_DIR: "helm-charts"
CHARTS_DIRS: "helm-charts,helm-charts/common"

jobs:
charts-validate:
Expand All @@ -45,12 +45,12 @@ jobs:
- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed=$(ct list-changed --chart-dirs ${{ env.CHARTS_DIR }} --target-branch ${{ github.event.repository.default_branch }})
changed=$(ct list-changed --chart-dirs ${{ env.CHARTS_DIRS }} --target-branch ${{ github.event.repository.default_branch }})
if [[ -n "$changed" ]]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Run chart-testing (lint)
if: steps.list-changed.outputs.changed == 'true'
run: |
helm-charts/update_dependency.sh
ct lint --check-version-increment=false --validate-maintainers=false --chart-dirs ${{ env.CHARTS_DIR }} --target-branch ${{ github.event.repository.default_branch }}
ct lint --check-version-increment=false --validate-maintainers=false --chart-dirs ${{ env.CHARTS_DIRS }} --target-branch ${{ github.event.repository.default_branch }}
20 changes: 20 additions & 0 deletions .github/workflows/scripts/e2e/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

saved_errexit=False

function turnoff_and_save_errexit() {
if [[ "$-" =~ e ]]; then
saved_errexit=True
set +e
fi
}


function resume_errexit() {
if [ "$saved_errexit" = "True" ]; then
saved_errexit=False
set -e
fi
}


function wait_until_pod_ready() {
echo "Waiting for the $1 to be ready..."
max_retries=60
Expand Down Expand Up @@ -53,6 +71,7 @@ function wait_until_all_pod_ready() {
namespace=$1
timeout=$2

turnoff_and_save_errexit
echo "Wait for all pods in NS $namespace to be ready..."
pods=$(kubectl get pods -n $namespace --no-headers | grep -v "Terminating" | awk '{print $1}')
# Loop through each pod
Expand All @@ -68,6 +87,7 @@ function wait_until_all_pod_ready() {
exit 1
fi
done
resume_errexit
}

function check_gmc_status() {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
23 changes: 23 additions & 0 deletions helm-charts/audioqna/.helmignore
Original file line number Diff line number Diff line change
@@ -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/
33 changes: 33 additions & 0 deletions helm-charts/audioqna/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

apiVersion: v2
name: audioqna
description: The Helm chart to deploy AudioQnA
type: application
dependencies:
- name: asr
version: 1.0.0
repository: "file://../common/asr"
- name: whisper
version: 1.0.0
repository: "file://../common/whisper"
- name: tts
version: 1.0.0
repository: "file://../common/tts"
- name: speecht5
version: 1.0.0
repository: "file://../common/speecht5"
- name: tgi
version: 1.0.0
repository: "file://../common/tgi"
- name: llm-uservice
version: 1.0.0
repository: "file://../common/llm-uservice"
# Uncomment the following to enable UI when the UI image is ready on DockerHub
# - name: ui
# version: 1.0.0
# repository: "file://../common/ui"
# alias: audioqna-ui
version: 1.1.0
appVersion: "1.1"
60 changes: 60 additions & 0 deletions helm-charts/audioqna/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# AudioQnA

Helm chart for deploying AudioQnA service.

AudioQnA depends on the following micro services:

- [asr](../common/asr/README.md)
- [whisper](../common/whisper/README.md)
- [llm-uservice](../common/llm-uservice/README.md)
- [tgi](../common/tgi/README.md)
- [tts](../common/tts/README.md)
- [speecht5](../common/speecht5/README.md)

## Installing the Chart

To install the chart, run the following:

```console
cd GenAIInfra/helm-charts/
./update_dependency.sh
helm dependency update audioqna
export HFTOKEN="insert-your-huggingface-token-here"
export MODELDIR="/mnt/opea-models"
export MODELNAME="Intel/neural-chat-7b-v3-3"
# To run on Xeon
helm install audioqna audioqna --set global.HUGGINGFACEHUB_API_TOKEN=${HFTOKEN} --set global.modelUseHostPath=${MODELDIR} --set tgi.LLM_MODEL_ID=${MODELNAME}
# To run on Gaudi
#helm install audioqna audioqna --set global.HUGGINGFACEHUB_API_TOKEN=${HFTOKEN} --set global.modelUseHostPath=${MODELDIR} --set tgi.LLM_MODEL_ID=${MODELNAME} -f audioqna/gaudi-values.yaml
```

### IMPORTANT NOTE

1. Make sure your `MODELDIR` exists on the node where your workload is schedueled so you can cache the downloaded model for next time use. Otherwise, set `global.modelUseHostPath` to 'null' if you don't want to cache the model.

## Verify

To verify the installation, run the command `kubectl get pod` to make sure all pods are running.

Test the AudioQnA megaservice by recording a .wav file, encoding the file into the base64 format, and then sending the base64 string to the megaservice endpoint. The megaservice will return a spoken response as a base64 string. To listen to the response, decode the base64 string and save it as a .wav file.

### Verify the workload through curl command

Then run the command `kubectl port-forward svc/audioqna 3008:3008` to expose the service for access.

Open another terminal and run the following command to verify the service if working:

```console
curl http://localhost:3008/v1/audioqna \
-X POST \
-d '{"audio": "UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA", "max_tokens":64}' \
-H 'Content-Type: application/json' | sed 's/^"//;s/"$//' | base64 -d > output.wav
```

## Values

| Key | Type | Default | Description |
| ---------------- | ------ | --------------------------- | ------------------------------------------------------------------------ |
| image.repository | string | `"opea/audioqna"` | |
| service.port | string | `"3008"` | |
| tgi.LLM_MODEL_ID | string | `Intel/neural-chat-7b-v3-3` | Models id from https://huggingface.co/, or predownloaded model directory |
1 change: 1 addition & 0 deletions helm-charts/audioqna/ci-gaudi-values.yaml
1 change: 1 addition & 0 deletions helm-charts/audioqna/ci-values.yaml
43 changes: 43 additions & 0 deletions helm-charts/audioqna/gaudi-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

tgi:
accelDevice: "gaudi"
image:
repository: ghcr.io/huggingface/tgi-gaudi
tag: "2.0.5"
resources:
limits:
habana.ai/gaudi: 1
MAX_INPUT_LENGTH: "1024"
MAX_TOTAL_TOKENS: "2048"
CUDA_GRAPHS: ""
livenessProbe:
initialDelaySeconds: 5
periodSeconds: 5
timeoutSeconds: 1
readinessProbe:
initialDelaySeconds: 5
periodSeconds: 5
timeoutSeconds: 1
startupProbe:
initialDelaySeconds: 5
periodSeconds: 5
timeoutSeconds: 1
failureThreshold: 120

whisper:
image:
repository: opea/whisper-gaudi
tag: "latest"
resources:
limits:
habana.ai/gaudi: 1

speecht5:
image:
repository: opea/speecht5-gaudi
tag: "latest"
resources:
limits:
habana.ai/gaudi: 1
62 changes: 62 additions & 0 deletions helm-charts/audioqna/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "audioqna.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 "audioqna.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 "audioqna.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "audioqna.labels" -}}
helm.sh/chart: {{ include "audioqna.chart" . }}
{{ include "audioqna.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "audioqna.selectorLabels" -}}
app.kubernetes.io/name: {{ include "audioqna.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "audioqna.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "audioqna.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
85 changes: 85 additions & 0 deletions helm-charts/audioqna/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "audioqna.fullname" . }}
labels:
{{- include "audioqna.labels" . | nindent 4 }}
app: {{ include "audioqna.fullname" . }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "audioqna.selectorLabels" . | nindent 6 }}
app: {{ include "audioqna.fullname" . }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "audioqna.selectorLabels" . | nindent 8 }}
app: {{ include "audioqna.fullname" . }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Release.Name }}
env:
- name: LLM_SERVICE_HOST_IP
value: {{ include "llm-uservice.fullname" (index .Subcharts "llm-uservice") }}
- name: LLM_SERVICE_PORT
value: {{ index .Values "llm-uservice" "service" "port" | quote }}
- name: ASR_SERVICE_HOST_IP
value: {{ include "asr.fullname" (index .Subcharts "asr") }}
- name: ASR_SERVICE_PORT
value: {{ index .Values "asr" "service" "port" | quote }}
- name: TTS_SERVICE_HOST_IP
value: {{ include "tts.fullname" (index .Subcharts "tts") }}
- name: TTS_SERVICE_PORT
value: {{ index .Values "tts" "service" "port" | quote }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
volumeMounts:
- mountPath: /tmp
name: tmp
ports:
- name: audioqna
containerPort: {{ .Values.port }}
protocol: TCP
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumes:
- name: tmp
emptyDir: {}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.evenly_distributed }}
topologySpreadConstraints:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: ScheduleAnyway
labelSelector:
matchLabels:
{{- include "audioqna.selectorLabels" . | nindent 14 }}
app: {{ include "audioqna.fullname" . }}
{{- end }}
Loading

0 comments on commit 97c6774

Please sign in to comment.