Skip to content

Commit 42bc3eb

Browse files
committed
FinanceAgent helm chart support
Agent chart changes. New tools deployment. Signed-off-by: Dolpher Du <dolpher.du@intel.com>
1 parent f1fe553 commit 42bc3eb

13 files changed

Lines changed: 497 additions & 4 deletions

File tree

helm-charts/agentqna/templates/tests/test-pod.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ spec:
6060
volumes:
6161
- name: test
6262
hostPath:
63-
path: /mnt/tools
63+
path: /mnt/tools/agentqna
6464
type: Directory
6565
{{- with .Values.nodeSelector }}
6666
nodeSelector:

helm-charts/agentqna/values.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ docretriever:
5858
tag: "latest"
5959

6060
sqlagent:
61-
toolHostPath: "/mnt/tools"
61+
toolHostPath: "/mnt/tools/agentqna"
6262
db_name: "Chinook"
6363
db_path: "sqlite:////home/user/tools/Chinook_Sqlite.sqlite"
6464
service:
@@ -77,7 +77,7 @@ sqlagent:
7777
require_human_feedback: "false"
7878

7979
ragagent:
80-
toolHostPath: "/mnt/tools"
80+
toolHostPath: "/mnt/tools/agentqna"
8181
service:
8282
port: 9095
8383
strategy: rag_agent_llama
@@ -94,7 +94,7 @@ ragagent:
9494
RETRIEVAL_TOOL_URL: ""
9595

9696
supervisor:
97-
toolHostPath: "/mnt/tools"
97+
toolHostPath: "/mnt/tools/agentqna"
9898
service:
9999
port: 9090
100100
strategy: react_llama

helm-charts/common/agent/templates/configmap.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,29 @@ data:
1717
{{- if .Values.tools }}
1818
tools: {{ .Values.tools | quote }}
1919
{{- end }}
20+
{{- if .Values.custom_prompt }}
21+
custom_prompt: {{ .Values.custom_prompt | quote }}
22+
{{- end }}
2023
{{- if .Values.llm_endpoint_url }}
2124
llm_endpoint_url: {{ tpl .Values.llm_endpoint_url . | quote }}
2225
{{- else }}
2326
llm_endpoint_url: "http://{{ .Release.Name }}-vllm"
2427
{{- end }}
28+
{{- if .Values.REDIS_URL_VECTOR }}
29+
REDIS_URL_VECTOR: {{ tpl .Values.REDIS_URL_VECTOR . | quote }}
30+
{{- else }}
31+
REDIS_URL_VECTOR: "redis://{{ .Release.Name }}-redis-vector-db:6379"
32+
{{- end }}
33+
{{- if .Values.REDIS_URL_KV }}
34+
REDIS_URL_KV: {{ tpl .Values.REDIS_URL_KV . | quote }}
35+
{{- else }}
36+
REDIS_URL_KV: "redis://{{ .Release.Name }}-redis-kv-store:6379"
37+
{{- end }}
38+
{{- if .Values.TEI_EMBEDDING_ENDPOINT }}
39+
TEI_EMBEDDING_ENDPOINT: {{ tpl .Values.TEI_EMBEDDING_ENDPOINT . | quote }}
40+
{{- else }}
41+
TEI_EMBEDDING_ENDPOINT: "http://{{ .Release.Name }}-tei"
42+
{{- end }}
2543
# {{- if .Values.port }}
2644
# port: {{ .Values.port | quote }}
2745
# {{- end }}
@@ -54,6 +72,21 @@ data:
5472
{{- else }}
5573
SQL_AGENT_URL: "http://{{ .Release.Name }}-sqlagent:9096/v1/chat/completions"
5674
{{- end }}
75+
{{- if .Values.WORKER_FINQA_AGENT_URL }}
76+
WORKER_FINQA_AGENT_URL: {{ .Values.WORKER_FINQA_AGENT_URL | quote }}
77+
{{- else }}
78+
WORKER_FINQA_AGENT_URL: "http://{{ .Release.Name }}-finqa-agent:9095/v1/chat/completions"
79+
{{- end }}
80+
{{- if .Values.WORKER_RESEARCH_AGENT_URL }}
81+
WORKER_RESEARCH_AGENT_URL: {{ .Values.WORKER_RESEARCH_AGENT_URL | quote }}
82+
{{- else }}
83+
WORKER_RESEARCH_AGENT_URL: "http://{{ .Release.Name }}-researchagent:9096/v1/chat/completions"
84+
{{- end }}
85+
{{- if .Values.DOCSUM_ENDPOINT }}
86+
DOCSUM_ENDPOINT: {{ .Values.DOCSUM_ENDPOINT | quote }}
87+
{{- else }}
88+
DOCSUM_ENDPOINT: "http://{{ .Release.Name }}-docsum:9000/v1/docsum"
89+
{{- end }}
5790
require_human_feedback: {{ .Values.require_human_feedback | quote }}
5891
recursion_limit: {{ .Values.recursion_limit | quote }}
5992
llm_engine: {{ .Values.llm_engine | quote }}
@@ -64,6 +97,12 @@ data:
6497
{{- if .Values.OPENAI_API_KEY }}
6598
OPENAI_API_KEY: {{ .Values.OPENAI_API_KEY | quote }}
6699
{{- end }}
100+
{{- if .Values.FINNHUB_API_KEY }}
101+
FINNHUB_API_KEY: {{ .Values.FINNHUB_API_KEY | quote }}
102+
{{- end }}
103+
{{- if .Values.FINANCIAL_DATASETS_API_KEY }}
104+
FINANCIAL_DATASETS_API_KEY: {{ .Values.FINANCIAL_DATASETS_API_KEY | quote }}
105+
{{- end }}
67106
HUGGINGFACEHUB_API_TOKEN: {{ .Values.global.HUGGINGFACEHUB_API_TOKEN | quote }}
68107
HF_HOME: "/tmp/.cache/huggingface"
69108
{{- if .Values.global.HF_ENDPOINT }}

helm-charts/common/data-prep/templates/configmap.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,30 @@ data:
4848
QDRANT_PORT: {{ .Values.QDRANT_PORT | quote }}
4949
COLLECTION_NAME: {{ .Values.COLLECTION_NAME | quote }}
5050
EMBED_MODEL: {{ .Values.LOCAL_EMBEDDING_MODEL | default "" | quote }}
51+
{{- else if eq "REDISFINANCE" .Values.DATAPREP_BACKEND }}
52+
DATAPREP_COMPONENT_NAME: "OPEA_DATAPREP_REDIS_FINANCE"
53+
{{- if .Values.REDIS_URL_VECTOR }}
54+
REDIS_URL_VECTOR: {{ tpl .Values.REDIS_URL_VECTOR . | quote}}
55+
{{- else }}
56+
REDIS_URL_VECTOR: "redis://{{ .Release.Name }}-redis-vector-db:6379"
57+
{{- end }}
58+
{{- if .Values.REDIS_URL_KV }}
59+
REDIS_URL_KV: {{ tpl .Values.REDIS_URL_KV . | quote}}
60+
{{- else }}
61+
REDIS_URL_KV: "redis://{{ .Release.Name }}-redis-kv-store:6379"
62+
{{- end }}
63+
{{- if .Values.LLM_ENDPOINT }}
64+
LLM_ENDPOINT: {{ tpl .Values.LLM_ENDPOINT . | quote}}
65+
LLM_MODEL: {{ .Values.LLM_MODEL | quote}}
66+
{{- else }}
67+
LLM_ENDPOINT: "http://{{ .Release.Name }}-vllm"
68+
LLM_MODEL: "meta-llama/Llama-3.3-70B-Instruct"
69+
{{- end }}
5170
{{- else }}
5271
{{- cat "Invalid DATAPREP_BACKEND:" .Values.DATAPREP_BACKEND | fail }}
5372
{{- end }}
5473
HUGGINGFACEHUB_API_TOKEN: {{ .Values.global.HUGGINGFACEHUB_API_TOKEN | quote}}
74+
HF_TOKEN: {{ .Values.global.HUGGINGFACEHUB_API_TOKEN | quote}}
5575
HF_HOME: "/tmp/.cache/huggingface"
5676
{{- if .Values.global.HF_ENDPOINT }}
5777
HF_ENDPOINT: {{ .Values.global.HF_ENDPOINT | quote}}

helm-charts/common/data-prep/templates/deployment.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ spec:
4343
{{- if eq "REDIS" .Values.DATAPREP_BACKEND }}
4444
TESTHOST=$(REDIS_HOST);
4545
TESTPORT=$(REDIS_PORT);
46+
{{- else if eq "REDISFINANCE" .Values.DATAPREP_BACKEND }}
47+
TESTHOST=$(echo $REDIS_URL_VECTOR | awk -F '[/:]' '{print $4}');
48+
TESTPORT=${REDIS_PORT:-6379};
4649
{{- else if eq "MILVUS" .Values.DATAPREP_BACKEND }}
4750
TESTHOST=$(MILVUS_HOST);
4851
TESTPORT=$(MILVUS_PORT);
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Copyright (C) 2024 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
apiVersion: v2
5+
name: financeagent
6+
description: The Helm chart to deploy FinanceAgent
7+
type: application
8+
dependencies:
9+
- name: agent
10+
version: 0-latest
11+
alias: finqa-agent
12+
repository: "file://../common/agent"
13+
- name: agent
14+
version: 0-latest
15+
alias: researchagent
16+
repository: "file://../common/agent"
17+
- name: agent
18+
version: 0-latest
19+
alias: supervisor
20+
repository: "file://../common/agent"
21+
- name: llm-uservice
22+
version: 0-latest
23+
alias: docsum
24+
repository: "file://../common/llm-uservice"
25+
- name: ui
26+
alias: agent-ui
27+
version: 0-latest
28+
repository: "file://../common/ui"
29+
- name: vllm
30+
version: 0-latest
31+
repository: "file://../common/vllm"
32+
condition: vllm.enabled
33+
- name: tei
34+
version: 0-latest
35+
repository: "file://../common/tei"
36+
- name: redis-vector-db
37+
version: 0-latest
38+
repository: "file://../common/redis-vector-db"
39+
- name: redis-vector-db
40+
version: 0-latest
41+
alias: redis-kv-store
42+
repository: "file://../common/redis-vector-db"
43+
- name: data-prep
44+
version: 0-latest
45+
repository: "file://../common/data-prep"
46+
version: 0-latest
47+
appVersion: "v1.0"

helm-charts/financeagent/README.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# FinanceAgent
2+
3+
Helm chart for deploying FinanceAgent example. It demonstrates how agent works, using prepared data and questions. See [FinanceAgent Overview](https://github.com/opea-project/GenAIExamples/tree/main/FinanceAgent#overview) for the details.
4+
5+
Using different datasets, models and questions may get different results.
6+
7+
Agent usually requires larger models to perform better, we used Llama-3.3-70B-Instruct for test, which requires 4x Gaudi devices for local deployment.
8+
9+
## Deploy
10+
11+
The Deployment includes preparing tools and SQL data.
12+
13+
### Prerequisites
14+
15+
A volume is required to put tools configuration used by agent, and the database data used by sqlagent.
16+
17+
We'll use hostPath in this readme, which is convenient for single worker node deployment. PVC is recommended in a bigger cluster. If you want to use a PVC, comment out the `toolHostPath` and replace with `toolPVC` in the `values.yaml`.
18+
19+
Create the directory `/mnt/tools` in the worker node, which is the default in `values.yaml`. We use the same directory for all 3 agents for easy configuration.
20+
21+
```
22+
sudo mkdir /mnt/tools
23+
sudo chmod 777 /mnt/tools
24+
```
25+
26+
Download tools and the configuration to `/mnt/tools`
27+
28+
```
29+
# tools used by supervisor
30+
wget https://raw.githubusercontent.com/opea-project/GenAIExamples/refs/heads/main/AgentQnA/tools/supervisor_agent_tools.yaml -O /mnt/tools/supervisor_agent_tools.yaml
31+
wget https://raw.githubusercontent.com/opea-project/GenAIExamples/refs/heads/main/AgentQnA/tools/tools.py -O /mnt/tools/tools.py
32+
wget https://raw.githubusercontent.com/opea-project/GenAIExamples/refs/heads/main/AgentQnA/tools/pycragapi.py -O /mnt/tools/pycragapi.py
33+
34+
# tools used by rag agent
35+
wget https://raw.githubusercontent.com/opea-project/GenAIExamples/refs/heads/main/AgentQnA/tools/worker_agent_tools.yaml -O /mnt/tools/worker_agent_tools.yaml
36+
wget https://raw.githubusercontent.com/opea-project/GenAIExamples/refs/heads/main/AgentQnA/tools/worker_agent_tools.py -O /mnt/tools/worker_agent_tools.py
37+
```
38+
39+
Download the `sqlite` database binary file
40+
41+
```
42+
wget https://raw.githubusercontent.com/lerocha/chinook-database/refs/heads/master/ChinookDatabase/DataSources/Chinook_Sqlite.sqlite -O /mnt/tools/Chinook_Sqlite.sqlite
43+
```
44+
45+
### Deploy with Helm chart
46+
47+
Deploy everything on Gaudi enabled Kubernetes cluster:
48+
49+
If you want to try with latest version, use `helm pull oci://ghcr.io/opea-project/charts/financeagent --version 0-latest --untar`
50+
51+
```
52+
export HUGGINGFACEHUB_API_TOKEN="YourOwnToken"
53+
helm pull oci://ghcr.io/opea-project/charts/financeagent --untar
54+
helm install financeagent financeagent -f financeagent/gaudi-values.yaml --set global.HUGGINGFACEHUB_API_TOKEN=${HUGGINGFACEHUB_API_TOKEN}
55+
```
56+
57+
## Verify
58+
59+
To verify the installation, run the command `kubectl get pod` to make sure all pods are running.
60+
61+
### Ingest data for RAG
62+
63+
Ingest data used by RAG.
64+
65+
```
66+
wget https://raw.githubusercontent.com/opea-project/GenAIExamples/refs/heads/main/AgentQnA/retrieval_tool/index_data.py -O /mnt/tools/index_data.py
67+
wget https://raw.githubusercontent.com/opea-project/GenAIExamples/refs/heads/main/AgentQnA/example_data/test_docs_music.jsonl -O /mnt/tools/test_docs_music.jsonl
68+
host_ip=$(kubectl get svc -o jsonpath="{.items[].spec.clusterIP}" --selector app.kubernetes.io/name=data-prep)
69+
python3 index_data.py --filedir /mnt/tools --filename test_docs_music.jsonl --host_ip $host_ip
70+
```
71+
72+
### Verify the workload through curl command
73+
74+
Run the command `kubectl port-forward svc/financeagent-supervisor 9090:9090` to expose the service for access.
75+
76+
Open another terminal and run the following command to verify the service if working:
77+
78+
```console
79+
curl http://localhost:9090/v1/chat/completions \
80+
-X POST \
81+
-H "Content-Type: application/json" \
82+
-d '{"messages": "How many albums does Iron Maiden have?"}'
83+
```
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright (C) 2024 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
vllm:
5+
enabled: true
6+
accelDevice: "gaudi"
7+
LLM_MODEL_ID: "meta-llama/Llama-3.3-70B-Instruct"
8+
image:
9+
repository: opea/vllm-gaudi
10+
OMPI_MCA_btl_vader_single_copy_mechanism: none
11+
extraCmdArgs: ["--tensor-parallel-size","4","--max-seq-len-to-capture","16384","--enable-auto-tool-choice","--tool-call-parser","llama3_json"]
12+
resources:
13+
limits:
14+
habana.ai/gaudi: 4
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "financeagent.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "financeagent.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "financeagent.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "financeagent.labels" -}}
37+
helm.sh/chart: {{ include "financeagent.chart" . }}
38+
{{ include "financeagent.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "financeagent.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "financeagent.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "financeagent.serviceAccountName" -}}
57+
{{- if .Values.global.sharedSAName }}
58+
{{- .Values.global.sharedSAName }}
59+
{{- else if .Values.serviceAccount.create }}
60+
{{- default (include "financeagent.fullname" .) .Values.serviceAccount.name }}
61+
{{- else }}
62+
{{- default "default" .Values.serviceAccount.name }}
63+
{{- end }}
64+
{{- end }}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright (C) 2024 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
{{- if .Values.serviceAccount.create }}
5+
apiVersion: v1
6+
kind: ServiceAccount
7+
metadata:
8+
name: {{ include "financeagent.serviceAccountName" . }}
9+
labels:
10+
{{- include "financeagent.labels" . | nindent 4 }}
11+
{{- with .Values.serviceAccount.annotations }}
12+
annotations:
13+
{{- toYaml . | nindent 4 }}
14+
{{- end }}
15+
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
16+
{{- end }}

0 commit comments

Comments
 (0)