From 386d6d604caad11a0180991084925da5c4e558db Mon Sep 17 00:00:00 2001 From: Lianhao Lu Date: Wed, 15 Jan 2025 15:02:38 +0800 Subject: [PATCH] Adapt rerank/web-retriever to latest changes (#682) Signed-off-by: Lianhao Lu --- helm-charts/common/reranking-usvc/.helmignore | 2 + helm-charts/common/reranking-usvc/README.md | 13 +++--- .../reranking-usvc/templates/configmap.yaml | 9 ++++ .../reranking-usvc/templates/deployment.yaml | 2 +- .../templates/tests/test-pod.yaml | 4 ++ helm-charts/common/reranking-usvc/values.yaml | 41 +++++++++---------- helm-charts/common/web-retriever/.helmignore | 2 + .../web-retriever/templates/deployment.yaml | 2 +- helm-charts/common/web-retriever/values.yaml | 31 +++++--------- 9 files changed, 56 insertions(+), 50 deletions(-) diff --git a/helm-charts/common/reranking-usvc/.helmignore b/helm-charts/common/reranking-usvc/.helmignore index 0e8a0eb36..d2c43a2ac 100644 --- a/helm-charts/common/reranking-usvc/.helmignore +++ b/helm-charts/common/reranking-usvc/.helmignore @@ -21,3 +21,5 @@ .idea/ *.tmproj .vscode/ +# CI values +ci*-values.yaml diff --git a/helm-charts/common/reranking-usvc/README.md b/helm-charts/common/reranking-usvc/README.md index bf77f7f3c..ae7bd321f 100644 --- a/helm-charts/common/reranking-usvc/README.md +++ b/helm-charts/common/reranking-usvc/README.md @@ -44,9 +44,10 @@ curl http://localhost:8000/v1/reranking \ ## Values -| Key | Type | Default | Description | -| ---------------------- | ------ | ---------------------- | ----------- | -| image.repository | string | `"opea/reranking-tgi"` | | -| TEI_RERANKING_ENDPOINT | string | `""` | | -| service.port | string | `"8000"` | | -| global.monitoring | bool | `false` | | +| Key | Type | Default | Description | +| ---------------------- | ------ | ---------------------- | -------------------------------------------------- | +| image.repository | string | `"opea/reranking-tgi"` | | +| RERANK_BACKEND | string | `"TEI"` | backend engine to use, one of "TEI", "VideoRerank" | +| TEI_RERANKING_ENDPOINT | string | `""` | | +| service.port | string | `"8000"` | | +| global.monitoring | bool | `false` | | diff --git a/helm-charts/common/reranking-usvc/templates/configmap.yaml b/helm-charts/common/reranking-usvc/templates/configmap.yaml index 69b1fcd91..121b53c5a 100644 --- a/helm-charts/common/reranking-usvc/templates/configmap.yaml +++ b/helm-charts/common/reranking-usvc/templates/configmap.yaml @@ -8,11 +8,20 @@ metadata: labels: {{- include "reranking-usvc.labels" . | nindent 4 }} data: + {{- if eq "TEI" .Values.RERANK_BACKEND }} + RERANK_COMPONENT_NAME: "OPEA_TEI_RERANKING" {{- if .Values.TEI_RERANKING_ENDPOINT }} TEI_RERANKING_ENDPOINT: {{ .Values.TEI_RERANKING_ENDPOINT | quote }} {{- else }} TEI_RERANKING_ENDPOINT: "http://{{ .Release.Name }}-teirerank" {{- end }} + {{- else if eq "VideoRerank" .Values.RERANK_BACKEND }} + RERANK_COMPONENT_NAME: "OPEA_VIDEO_RERANKING" + CHUNK_DURATION: {{ .Values.CHUNK_DURATION | quote }} + FILE_SERVER_ENDPOINT: {{ .Values.FILE_SERVER_ENDPOINT | quote }} + {{- else }} + {{- cat "Invalid RERANK_BACKEND:" .Values.RERANK_BACKEND | fail }} + {{- end }} http_proxy: {{ .Values.global.http_proxy | quote }} https_proxy: {{ .Values.global.https_proxy | quote }} {{- if and (not .Values.TEI_RERANKING_ENDPOINT) (or .Values.global.http_proxy .Values.global.https_proxy) }} diff --git a/helm-charts/common/reranking-usvc/templates/deployment.yaml b/helm-charts/common/reranking-usvc/templates/deployment.yaml index 192016eca..84ca83a0f 100644 --- a/helm-charts/common/reranking-usvc/templates/deployment.yaml +++ b/helm-charts/common/reranking-usvc/templates/deployment.yaml @@ -29,7 +29,7 @@ spec: securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} containers: - - name: {{ .Release.Name }} + - name: {{ .Chart.Name }} envFrom: - configMapRef: name: {{ include "reranking-usvc.fullname" . }}-config diff --git a/helm-charts/common/reranking-usvc/templates/tests/test-pod.yaml b/helm-charts/common/reranking-usvc/templates/tests/test-pod.yaml index 4bd7ac745..abf8f7c81 100644 --- a/helm-charts/common/reranking-usvc/templates/tests/test-pod.yaml +++ b/helm-charts/common/reranking-usvc/templates/tests/test-pod.yaml @@ -21,7 +21,11 @@ spec: for ((i=1; i<=max_retry; i++)); do curl http://{{ include "reranking-usvc.fullname" . }}:{{ .Values.service.port }}/v1/reranking -sS --fail-with-body \ -X POST \ + {{- if eq "TEI" .Values.RERANK_BACKEND }} -d '{"initial_query":"What is Deep Learning?", "retrieved_docs": [{"text":"Deep Learning is not..."}, {"text":"Deep learning is..."}]}' \ + {{- else }} + -d '{"retrieved_docs":[{"doc": [{"text": "this is the retrieved text"}]}], "initial_query": "this is the query", "top_n": 1, "metadata":[{"other_key": "value", "video":"top_video_name", "timestamp":"20"},{"other_key": "value", "video":"second_video_name", "timestamp":"40"}]}' \ + {{- end }} -H 'Content-Type: application/json' && break; curlcode=$? if [[ $curlcode -eq 7 ]]; then sleep 10; else echo "curl failed with code $curlcode"; exit 1; fi; diff --git a/helm-charts/common/reranking-usvc/values.yaml b/helm-charts/common/reranking-usvc/values.yaml index c1b28a8a6..2e18abfc2 100644 --- a/helm-charts/common/reranking-usvc/values.yaml +++ b/helm-charts/common/reranking-usvc/values.yaml @@ -5,18 +5,24 @@ # This is a YAML-formatted file. # Declare variables to be passed into your templates. -teirerank: - enabled: false - replicaCount: 1 -# Set it as a non-null string, such as true, if you want to enable logging facility, -# otherwise, keep it as "" to disable it. +# Set it as a non-null string, such as true, if you want to enable logging facility. LOGFLAG: "" +# rerank-usvc need to talk to different backend engine: TEI, VideoRerank +# Default is to use TEI +RERANK_BACKEND: "TEI" +# TEI engine service endpoint, e.g. "http://teirerank:80" TEI_RERANKING_ENDPOINT: "" + +# Uncomment and set the following settings to use videorerank as backend engine +# RERANK_BACKEND: "VideoRerank" +CHUNK_DURATION: 10 +FILE_SERVER_ENDPOINT: "" + image: - repository: opea/reranking-tei + repository: opea/reranking # Uncomment the following line to set desired image pull policy if needed, as one of Always, IfNotPresent, Never. # pullPolicy: "" # Overrides the image tag whose default is the chart appVersion. @@ -58,25 +64,14 @@ service: # The default port for reranking service is 9000 port: 8000 -resources: {} - # We usually recommend not to specify default resources and to leave this as a conscious - # choice for the user. This also increases chances charts run on environments with little - # resources, such as Minikube. If you do want to specify resources, uncomment the following - # lines, adjust them as necessary, and remove the curly braces after 'resources:'. +resources: # limits: # cpu: 100m # memory: 128Mi - # requests: - # cpu: 100m - # memory: 128Mi + requests: + cpu: 100m + memory: 128Mi -livenessProbe: - httpGet: - path: v1/health_check - port: reranking-usvc - initialDelaySeconds: 5 - periodSeconds: 5 - failureThreshold: 24 readinessProbe: httpGet: path: v1/health_check @@ -111,3 +106,7 @@ global: # Prometheus Helm install release name for serviceMonitor prometheusRelease: prometheus-stack + +# Only related to CI tests +teirerank: + enabled: false diff --git a/helm-charts/common/web-retriever/.helmignore b/helm-charts/common/web-retriever/.helmignore index 0e8a0eb36..d2c43a2ac 100644 --- a/helm-charts/common/web-retriever/.helmignore +++ b/helm-charts/common/web-retriever/.helmignore @@ -21,3 +21,5 @@ .idea/ *.tmproj .vscode/ +# CI values +ci*-values.yaml diff --git a/helm-charts/common/web-retriever/templates/deployment.yaml b/helm-charts/common/web-retriever/templates/deployment.yaml index 25b01790a..11809fb11 100644 --- a/helm-charts/common/web-retriever/templates/deployment.yaml +++ b/helm-charts/common/web-retriever/templates/deployment.yaml @@ -29,7 +29,7 @@ spec: securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} containers: - - name: {{ .Release.Name }} + - name: {{ .Chart.Name }} envFrom: - configMapRef: name: {{ include "web-retriever.fullname" . }}-config diff --git a/helm-charts/common/web-retriever/values.yaml b/helm-charts/common/web-retriever/values.yaml index 12aba2905..a8c2de062 100644 --- a/helm-charts/common/web-retriever/values.yaml +++ b/helm-charts/common/web-retriever/values.yaml @@ -5,13 +5,9 @@ # This is a YAML-formatted file. # Declare variables to be passed into your templates. -tei: - enabled: false - replicaCount: 1 -# Set it as a non-null string, such as true, if you want to enable logging facility, -# otherwise, keep it as "" to disable it. +# Set it as a non-null string, such as true, if you want to enable logging. LOGFLAG: "" TEI_EMBEDDING_ENDPOINT: "" @@ -19,7 +15,7 @@ GOOGLE_API_KEY: "" GOOGLE_CSE_ID: "" image: - repository: opea/web-retriever-chroma + repository: opea/web-retriever # Uncomment the following line to set desired image pull policy if needed, as one of Always, IfNotPresent, Never. # pullPolicy: "" # Overrides the image tag whose default is the chart appVersion. @@ -61,25 +57,14 @@ service: # The default port for retriever service is 7000 port: 7077 -resources: {} - # We usually recommend not to specify default resources and to leave this as a conscious - # choice for the user. This also increases chances charts run on environments with little - # resources, such as Minikube. If you do want to specify resources, uncomment the following - # lines, adjust them as necessary, and remove the curly braces after 'resources:'. +resources: # limits: # cpu: 100m # memory: 128Mi - # requests: - # cpu: 100m - # memory: 128Mi + requests: + cpu: 100m + memory: 128Mi -livenessProbe: - httpGet: - path: v1/health_check - port: web-retriever - initialDelaySeconds: 5 - periodSeconds: 5 - failureThreshold: 24 readinessProbe: httpGet: path: v1/health_check @@ -108,3 +93,7 @@ global: # If set, it will overwrite serviceAccount.name. # If set, and serviceAccount.create is false, it will assume this service account is already created by others. sharedSAName: "" + +# For CI tests only +tei: + enabled: false