-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add web retriever component This is the retriever component for example SearchQnA Signed-off-by: Dolpher Du <[email protected]>
- Loading branch information
1 parent
2fcbb0d
commit 892c15f
Showing
8 changed files
with
346 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
apiVersion: v2 | ||
name: web-retriever | ||
description: The Helm chart for deploying web retriever as microservice | ||
type: application | ||
version: 0.8.0 | ||
# The web retriever microservice server version | ||
appVersion: "1.0.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# web-retriever | ||
|
||
Helm chart for deploying Web Retriever microservice. | ||
|
||
Web retriever depends on tei, you should set TEI_EMBEDDING_ENDPOINT endpoints before start. | ||
|
||
## Installing the Chart | ||
|
||
To install the chart, run the following: | ||
|
||
```console | ||
export TEI_EMBEDDING_ENDPOINT="http://tei" | ||
export GOOGLE_API_KEY="yourownkey" | ||
export GOOGLE_CSE_ID="yourownid" | ||
helm install web-retriever web-retriever --set TEI_EMBEDDING_ENDPOINT=${TEI_EMBEDDING_ENDPOINT} \ | ||
--set GOOGLE_API_KEY=${GOOGLE_API_KEY} \ | ||
--set GOOGLE_CSE_ID=${GOOGLE_CSE_ID} | ||
``` | ||
|
||
## Verify | ||
|
||
Use port-forward to access it from localhost. | ||
|
||
```console | ||
kubectl port-forward service/web-retriever 1234:7077 & | ||
your_embedding=$(python -c "import random; embedding = [random.uniform(-1, 1) for _ in range(768)]; print(embedding)") | ||
curl http://localhost:1234/v1/web_retrieval \ | ||
-X POST \ | ||
-d "{\"text\":\"What is OPEA?\",\"embedding\":${your_embedding}}" \ | ||
-H 'Content-Type: application/json' | ||
``` | ||
|
||
## Values | ||
|
||
| Key | Type | Default | Description | | ||
| ---------------------- | ------ | ------------------------------------ | ----------- | | ||
| image.repository | string | `"opea/web-retriever-chroma:latest"` | | | ||
| service.port | string | `"7077"` | | | ||
| TEI_EMBEDDING_ENDPOINT | string | `""` | | | ||
| GOOGLE_API_KEY | string | `""` | | | ||
| GOOGLE_CSE_ID | string | `""` | | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "web-retriever.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 "web-retriever.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 "web-retriever.chart" -}} | ||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Common labels | ||
*/}} | ||
{{- define "web-retriever.labels" -}} | ||
helm.sh/chart: {{ include "web-retriever.chart" . }} | ||
{{ include "web-retriever.selectorLabels" . }} | ||
{{- if .Chart.AppVersion }} | ||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} | ||
{{- end }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
{{- end }} | ||
|
||
{{/* | ||
Selector labels | ||
*/}} | ||
{{- define "web-retriever.selectorLabels" -}} | ||
app.kubernetes.io/name: {{ include "web-retriever.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create the name of the service account to use | ||
*/}} | ||
{{- define "web-retriever.serviceAccountName" -}} | ||
{{- if .Values.serviceAccount.create }} | ||
{{- default (include "web-retriever.fullname" .) .Values.serviceAccount.name }} | ||
{{- else }} | ||
{{- default "default" .Values.serviceAccount.name }} | ||
{{- end }} | ||
{{- end }} |
100 changes: 100 additions & 0 deletions
100
helm-charts/common/web-retriever/templates/deployment.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: {{ include "web-retriever.fullname" . }} | ||
labels: | ||
{{- include "web-retriever.labels" . | nindent 4 }} | ||
spec: | ||
replicas: {{ .Values.replicaCount }} | ||
selector: | ||
matchLabels: | ||
{{- include "web-retriever.selectorLabels" . | nindent 6 }} | ||
template: | ||
metadata: | ||
{{- with .Values.podAnnotations }} | ||
annotations: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
labels: | ||
{{- include "web-retriever.selectorLabels" . | nindent 8 }} | ||
spec: | ||
{{- with .Values.imagePullSecrets }} | ||
imagePullSecrets: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
securityContext: | ||
{{- toYaml .Values.podSecurityContext | nindent 8 }} | ||
containers: | ||
- name: {{ .Release.Name }} | ||
env: | ||
- name: TEI_EMBEDDING_ENDPOINT | ||
{{- if .Values.TEI_EMBEDDING_ENDPOINT }} | ||
value: {{ .Values.TEI_EMBEDDING_ENDPOINT | quote}} | ||
{{- else }} | ||
value: "http://{{ .Release.Name }}-tei" | ||
{{- end }} | ||
- name: GOOGLE_API_KEY | ||
value: {{ .Values.GOOGLE_API_KEY }} | ||
- name: GOOGLE_CSE_ID | ||
value: {{ .Values.GOOGLE_CSE_ID }} | ||
- name: EASYOCR_MODULE_PATH | ||
value: "/tmp/.EasyOCR" | ||
- name: http_proxy | ||
value: {{ .Values.global.http_proxy }} | ||
- name: https_proxy | ||
value: {{ .Values.global.https_proxy }} | ||
- name: no_proxy | ||
value: {{ .Values.global.no_proxy }} | ||
- name: HF_HOME | ||
value: "/tmp/.cache/huggingface" | ||
securityContext: | ||
{{- toYaml .Values.securityContext | nindent 12 }} | ||
image: "{{ .Values.image.repository }}" | ||
imagePullPolicy: {{ .Values.image.pullPolicy }} | ||
ports: | ||
- name: web-retriever | ||
containerPort: 7077 | ||
protocol: TCP | ||
volumeMounts: | ||
- mountPath: /tmp | ||
name: tmp | ||
startupProbe: | ||
exec: | ||
command: | ||
- curl | ||
{{- if .Values.TEI_EMBEDDING_ENDPOINT }} | ||
- {{ .Values.TEI_EMBEDDING_ENDPOINT }} | ||
{{- else }} | ||
- http://{{ .Release.Name }}-tei | ||
{{- end }} | ||
initialDelaySeconds: 5 | ||
periodSeconds: 5 | ||
failureThreshold: 120 | ||
# livenessProbe: | ||
# httpGet: | ||
# path: / | ||
# port: 7000 | ||
# readinessProbe: | ||
# httpGet: | ||
# path: / | ||
# port: 7000 | ||
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: {{ include "web-retriever.fullname" . }} | ||
labels: | ||
{{- include "web-retriever.labels" . | nindent 4 }} | ||
spec: | ||
type: {{ .Values.service.type }} | ||
ports: | ||
- port: {{ .Values.service.port }} | ||
targetPort: 7077 | ||
protocol: TCP | ||
name: web-retriever | ||
selector: | ||
{{- include "web-retriever.selectorLabels" . | nindent 4 }} |
26 changes: 26 additions & 0 deletions
26
helm-charts/common/web-retriever/templates/tests/test-pod.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: "{{ include "web-retriever.fullname" . }}-testpod" | ||
labels: | ||
{{- include "web-retriever.labels" . | nindent 4 }} | ||
annotations: | ||
"helm.sh/hook": test | ||
#"helm.sh/hook-delete-policy": "hook-succeeded, hook-failure" | ||
spec: | ||
containers: | ||
- name: curl | ||
#image: alpine/curl | ||
image: python:3.10.14 | ||
command: ['sh', '-c'] | ||
args: | ||
- | | ||
your_embedding=$(python -c "import random; embedding = [random.uniform(-1, 1) for _ in range(768)]; print(embedding)"); | ||
curl http://{{ include "web-retriever.fullname" . }}:{{ .Values.service.port }}/v1/web_retrieval \ | ||
-X POST \ | ||
-d "{\"text\":\"What is OPEA?\",\"embedding\":${your_embedding}}" \ | ||
-H 'Content-Type: application/json' | ||
restartPolicy: Never |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# Default values for web-retriever. | ||
# This is a YAML-formatted file. | ||
# Declare variables to be passed into your templates. | ||
|
||
replicaCount: 1 | ||
|
||
TEI_EMBEDDING_ENDPOINT: "" | ||
GOOGLE_API_KEY: "" | ||
GOOGLE_CSE_ID: "" | ||
|
||
image: | ||
repository: opea/web-retriever-chroma:latest | ||
pullPolicy: IfNotPresent | ||
# Overrides the image tag whose default is the chart appVersion. | ||
# tag: "1.0" | ||
|
||
imagePullSecrets: [] | ||
nameOverride: "" | ||
fullnameOverride: "" | ||
|
||
podAnnotations: {} | ||
|
||
podSecurityContext: {} | ||
# fsGroup: 2000 | ||
|
||
securityContext: | ||
readOnlyRootFilesystem: true | ||
allowPrivilegeEscalation: false | ||
runAsNonRoot: true | ||
runAsUser: 1000 | ||
capabilities: | ||
drop: | ||
- ALL | ||
seccompProfile: | ||
type: RuntimeDefault | ||
|
||
service: | ||
type: ClusterIP | ||
# 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:'. | ||
# limits: | ||
# cpu: 100m | ||
# memory: 128Mi | ||
# requests: | ||
# cpu: 100m | ||
# memory: 128Mi | ||
|
||
nodeSelector: {} | ||
|
||
tolerations: [] | ||
|
||
affinity: {} | ||
|
||
global: | ||
http_proxy: | ||
https_proxy: | ||
no_proxy: |