Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions helm-charts/common/agent/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,29 @@ data:
{{- if .Values.tools }}
tools: {{ .Values.tools | quote }}
{{- end }}
{{- if .Values.custom_prompt }}
custom_prompt: {{ .Values.custom_prompt | quote }}
{{- end }}
{{- if .Values.llm_endpoint_url }}
llm_endpoint_url: {{ tpl .Values.llm_endpoint_url . | quote }}
{{- else }}
llm_endpoint_url: "http://{{ .Release.Name }}-vllm"
{{- end }}
{{- if .Values.REDIS_URL_VECTOR }}
REDIS_URL_VECTOR: {{ tpl .Values.REDIS_URL_VECTOR . | quote }}
{{- else }}
REDIS_URL_VECTOR: "redis://{{ .Release.Name }}-redis-vector-db:6379"
{{- end }}
{{- if .Values.REDIS_URL_KV }}
REDIS_URL_KV: {{ tpl .Values.REDIS_URL_KV . | quote }}
{{- else }}
REDIS_URL_KV: "redis://{{ .Release.Name }}-redis-kv-store:6379"
{{- end }}
{{- if .Values.TEI_EMBEDDING_ENDPOINT }}
TEI_EMBEDDING_ENDPOINT: {{ tpl .Values.TEI_EMBEDDING_ENDPOINT . | quote }}
{{- else }}
TEI_EMBEDDING_ENDPOINT: "http://{{ .Release.Name }}-tei"
{{- end }}
# {{- if .Values.port }}
# port: {{ .Values.port | quote }}
# {{- end }}
Expand Down Expand Up @@ -54,6 +72,21 @@ data:
{{- else }}
SQL_AGENT_URL: "http://{{ .Release.Name }}-sqlagent:9096/v1/chat/completions"
{{- end }}
{{- if .Values.WORKER_FINQA_AGENT_URL }}
WORKER_FINQA_AGENT_URL: {{ .Values.WORKER_FINQA_AGENT_URL | quote }}
{{- else }}
WORKER_FINQA_AGENT_URL: "http://{{ .Release.Name }}-finqa-agent:9095/v1/chat/completions"
{{- end }}
{{- if .Values.WORKER_RESEARCH_AGENT_URL }}
WORKER_RESEARCH_AGENT_URL: {{ .Values.WORKER_RESEARCH_AGENT_URL | quote }}
{{- else }}
WORKER_RESEARCH_AGENT_URL: "http://{{ .Release.Name }}-research-agent:9096/v1/chat/completions"
{{- end }}
{{- if .Values.DOCSUM_ENDPOINT }}
DOCSUM_ENDPOINT: {{ .Values.DOCSUM_ENDPOINT | quote }}
{{- else }}
DOCSUM_ENDPOINT: "http://{{ .Release.Name }}-docsum:9000/v1/docsum"
{{- end }}
require_human_feedback: {{ .Values.require_human_feedback | quote }}
recursion_limit: {{ .Values.recursion_limit | quote }}
llm_engine: {{ .Values.llm_engine | quote }}
Expand All @@ -64,6 +97,12 @@ data:
{{- if .Values.OPENAI_API_KEY }}
OPENAI_API_KEY: {{ .Values.OPENAI_API_KEY | quote }}
{{- end }}
{{- if .Values.FINNHUB_API_KEY }}
FINNHUB_API_KEY: {{ .Values.FINNHUB_API_KEY | quote }}
{{- end }}
{{- if .Values.FINANCIAL_DATASETS_API_KEY }}
FINANCIAL_DATASETS_API_KEY: {{ .Values.FINANCIAL_DATASETS_API_KEY | quote }}
{{- end }}
HUGGINGFACEHUB_API_TOKEN: {{ .Values.global.HUGGINGFACEHUB_API_TOKEN | quote }}
HF_HOME: "/tmp/.cache/huggingface"
{{- if .Values.global.HF_ENDPOINT }}
Expand Down
26 changes: 26 additions & 0 deletions helm-charts/common/data-prep/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,36 @@ data:
QDRANT_PORT: {{ .Values.QDRANT_PORT | quote }}
COLLECTION_NAME: {{ .Values.COLLECTION_NAME | quote }}
EMBED_MODEL: {{ .Values.LOCAL_EMBEDDING_MODEL | default "" | quote }}
{{- else if eq "REDISFINANCE" .Values.DATAPREP_BACKEND }}
DATAPREP_COMPONENT_NAME: "OPEA_DATAPREP_REDIS_FINANCE"
{{- if .Values.REDIS_URL_VECTOR }}
REDIS_URL_VECTOR: {{ tpl .Values.REDIS_URL_VECTOR . | quote}}
{{- else }}
REDIS_URL_VECTOR: "redis://{{ .Release.Name }}-redis-vector-db:6379"
{{- end }}
{{- if .Values.REDIS_URL_KV }}
REDIS_URL_KV: {{ tpl .Values.REDIS_URL_KV . | quote}}
{{- else }}
REDIS_URL_KV: "redis://{{ .Release.Name }}-redis-kv-store:6379"
{{- end }}
{{- if .Values.LLM_ENDPOINT }}
LLM_ENDPOINT: {{ tpl .Values.LLM_ENDPOINT . | quote}}
LLM_MODEL: {{ .Values.LLM_MODEL | quote}}
{{- else }}
LLM_ENDPOINT: "http://{{ .Release.Name }}-vllm"
LLM_MODEL: "meta-llama/Llama-3.3-70B-Instruct"
{{- end }}
{{- if .Values.MAX_TOKENS }}
MAX_TOKENS: {{ .Values.MAX_TOKENS | quote}}
{{- end }}
{{- if .Values.TEMPERATURE }}
TEMPERATURE: {{ .Values.TEMPERATURE | quote}}
{{- end }}
{{- else }}
{{- cat "Invalid DATAPREP_BACKEND:" .Values.DATAPREP_BACKEND | fail }}
{{- end }}
HUGGINGFACEHUB_API_TOKEN: {{ .Values.global.HUGGINGFACEHUB_API_TOKEN | quote}}
HF_TOKEN: {{ .Values.global.HUGGINGFACEHUB_API_TOKEN | quote}}
HF_HOME: "/tmp/.cache/huggingface"
{{- if .Values.global.HF_ENDPOINT }}
HF_ENDPOINT: {{ .Values.global.HF_ENDPOINT | quote}}
Expand Down
3 changes: 3 additions & 0 deletions helm-charts/common/data-prep/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ spec:
{{- if eq "REDIS" .Values.DATAPREP_BACKEND }}
TESTHOST=$(REDIS_HOST);
TESTPORT=$(REDIS_PORT);
{{- else if eq "REDISFINANCE" .Values.DATAPREP_BACKEND }}
TESTHOST=$(echo $REDIS_URL_VECTOR | awk -F '[/:]' '{print $4}');
TESTPORT=${REDIS_PORT:-6379};
{{- else if eq "MILVUS" .Values.DATAPREP_BACKEND }}
TESTHOST=$(MILVUS_HOST);
TESTPORT=$(MILVUS_PORT);
Expand Down
5 changes: 5 additions & 0 deletions helm-charts/common/data-prep/templates/tests/test-pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ spec:
command: ['bash', '-c']
args:
- |
# Skip test for REDISFINANCE BACKEND, doesn't support delete file_path: all
if [ {{ .Values.DATAPREP_BACKEND }} = "REDISFINANCE" ]; then
echo "Skip test for REDISFINANCE BACKEND";
exit 0;
fi
filetypes=(docx pdf txt xlsx pptx doc);
for type in ${filetypes[@]}; do
echo "Get ingest file of type $type ...";
Expand Down
9 changes: 9 additions & 0 deletions helm-charts/common/data-prep/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ SEARCH_BATCH_SIZE: 10
# QDRANT_PORT: 6333
# COLLECTION_NAME: "rag_qdrant"

# Uncomment and set the following 5 settings to use Redis_finance backend
# DATAPREP_BACKEND: "REDISFINANCE"
# REDIS_URL_VECTOR: ""
# REDIS_URL_KV: ""
# LLM_ENDPOINT: ""
# LLM_MODEL: "meta-llama/Llama-3.3-70B-Instruct"
# MAX_TOKENS: ""
# TEMPERATURE: ""

# data-prep can do embedding locally or talk to remote TEI service to do embedding.
# TEI_EMBEDDING_ENDPOINT takes precedence over LOCAL_EMBEDDING_MODEL.
# TEI inference service URL, e.g. http://<service-name>:<port>
Expand Down
46 changes: 46 additions & 0 deletions helm-charts/financeagent/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

apiVersion: v2
name: financeagent
description: The Helm chart to deploy FinanceAgent
type: application
dependencies:
- name: agent
version: 0-latest
alias: finqa-agent
repository: "file://../common/agent"
- name: agent
version: 0-latest
alias: research-agent
repository: "file://../common/agent"
- name: agent
version: 0-latest
alias: supervisor
repository: "file://../common/agent"
- name: llm-uservice
version: 0-latest
alias: docsum
repository: "file://../common/llm-uservice"
- name: ui
alias: agent-ui
version: 0-latest
repository: "file://../common/ui"
- name: vllm
version: 0-latest
repository: "file://../common/vllm"
- name: tei
version: 0-latest
repository: "file://../common/tei"
- name: redis-vector-db
version: 0-latest
repository: "file://../common/redis-vector-db"
- name: redis-vector-db
version: 0-latest
alias: redis-kv-store
repository: "file://../common/redis-vector-db"
- name: data-prep
version: 0-latest
repository: "file://../common/data-prep"
version: 0-latest
appVersion: "v1.0"
97 changes: 97 additions & 0 deletions helm-charts/financeagent/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# FinanceAgent

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.

FinanceAgent depends on the following subcharts:

- [agent](../common/agent/README.md)
- [llm-uservice](../common/llm-uservice/README.md)
- [vllm](../common/vllm/README.md)
- [tei](../common/tei/README.md)
- [redis-vector-db](../common/redis-vector-db/README.md)
- [data-prep](../common/data-prep/README.md)

Check the [Chart.yaml](./Chart.yaml) file for how these subcharts are used.

Agent usually requires larger models to perform better, we used `meta-llama/Llama-3.3-70B-Instruct` for test, which requires 4x Gaudi devices for local deployment.

## Deploy

The Deployment includes downloading tools and prompts for the agents, and data ingestion for testing.

### Prerequisites

A volume is required to put tools and prompts used by agent.

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`.

Create the directory `/mnt/tools/financeagent` in the worker node, which is the default in `values.yaml`. We use the same directory for all 3 agents for easy configuration.

```
sudo mkdir /mnt/tools/financeagent
sudo chmod 777 /mnt/tools/financeagent
```

Download prompts, tools and the configuration to `/mnt/tools/financeagent`

```
# prompts used by 3 agents
wget https://raw.githubusercontent.com/opea-project/GenAIExamples/refs/heads/main/FinanceAgent/prompts/finqa_prompt.py -O /mnt/tools/financeagent/finqa_prompt.py
wget https://raw.githubusercontent.com/opea-project/GenAIExamples/refs/heads/main/FinanceAgent/prompts/research_prompt.py -O /mnt/tools/financeagent/research_prompt.py
wget https://raw.githubusercontent.com/opea-project/GenAIExamples/refs/heads/main/FinanceAgent/prompts/supervisor_prompt.py -O /mnt/tools/financeagent/supervisor_prompt.py

# tools and configurations used by the agents
wget https://raw.githubusercontent.com/opea-project/GenAIExamples/refs/heads/main/FinanceAgent/tools/finqa_agent_tools.yaml -O /mnt/tools/financeagent/finqa_agent_tools.yaml
wget https://raw.githubusercontent.com/opea-project/GenAIExamples/refs/heads/main/FinanceAgent/tools/finqa_tools.py -O /mnt/tools/financeagent/finqa_tools.py
wget https://raw.githubusercontent.com/opea-project/GenAIExamples/refs/heads/main/FinanceAgent/tools/research_agent_tools.yaml -O /mnt/tools/financeagent/research_agent_tools.yaml
wget https://raw.githubusercontent.com/opea-project/GenAIExamples/refs/heads/main/FinanceAgent/tools/research_tools.py -O /mnt/tools/financeagent/research_tools.py
wget https://raw.githubusercontent.com/opea-project/GenAIExamples/refs/heads/main/FinanceAgent/tools/supervisor_agent_tools.yaml -O /mnt/tools/financeagent/supervisor_agent_tools.yaml
wget https://raw.githubusercontent.com/opea-project/GenAIExamples/refs/heads/main/FinanceAgent/tools/supervisor_tools.py -O /mnt/tools/financeagent/supervisor_tools.py
wget https://raw.githubusercontent.com/opea-project/GenAIExamples/refs/heads/main/FinanceAgent/tools/sum_agent_tools.py -O /mnt/tools/financeagent/sum_agent_tools.py
wget https://raw.githubusercontent.com/opea-project/GenAIExamples/refs/heads/main/FinanceAgent/tools/redis_kv.py -O /mnt/tools/financeagent/redis_kv.py
wget https://raw.githubusercontent.com/opea-project/GenAIExamples/refs/heads/main/FinanceAgent/tools/utils.py -O /mnt/tools/financeagent/utils.py
```

### Deploy with Helm chart

Deploy everything on Gaudi enabled Kubernetes cluster:

If you want to try with latest version, use `helm pull oci://ghcr.io/opea-project/charts/financeagent --version 0-latest --untar`

```
export HUGGINGFACEHUB_API_TOKEN="YourOwnToken"
export FINNHUB_API_KEY="YourOwnToken"
export FINANCIAL_DATASETS_API_KEY="YourOwnToken"
helm pull oci://ghcr.io/opea-project/charts/financeagent --untar
helm install financeagent financeagent -f financeagent/gaudi-values.yaml \
--set global.HUGGINGFACEHUB_API_TOKEN=${HUGGINGFACEHUB_API_TOKEN} \
--set research-agent.FINNHUB_API_KEY=${FINNHUB_API_KEY} \
--set research-agent.FINANCIAL_DATASETS_API_KEY=${FINANCIAL_DATASETS_API_KEY}
```

## Verify

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

### Ingest data for RAG

Ingest data used by RAG.

```
ip_address=$(kubectl get svc financeagent-data-prep -o jsonpath='{.spec.clusterIP})
curl "http://${ip_address}:6007/v1/dataprep/ingest" -X POST -H "Content-Type: application/x-www-form-urlencoded" \
-d 'link_list=%5B%22https%3A%2F%2Fwww.fool.com%2Fearnings%2Fcall-transcripts%2F2025%2F03%2F06%2Fcostco-wholesale-cost-q2-2025-earnings-call-transc%2F%22%2C%22https%3A%2F%2Fwww.fool.com%2Fearnings%2Fcall-transcripts%2F2025%2F03%2F07%2Fgap-gap-q4-2024-earnings-call-transcript%2F%22%5D'
```

### Verify the workload through curl command

Run the command `kubectl port-forward svc/financeagent-supervisor 9090:9090` to expose the service for access.

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

```console
curl http://localhost:9090/v1/chat/completions \
-X POST \
-H "Content-Type: application/json" \
-d '{"role": "user", "messages": "Can you summarize Costco 2025 Q2 earnings call?"}'
```
13 changes: 13 additions & 0 deletions helm-charts/financeagent/gaudi-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

vllm:
accelDevice: "gaudi"
LLM_MODEL_ID: "meta-llama/Llama-3.3-70B-Instruct"
image:
repository: opea/vllm-gaudi
OMPI_MCA_btl_vader_single_copy_mechanism: none
extraCmdArgs: ["--tensor-parallel-size","4","--max-seq-len-to-capture","16384","--enable-auto-tool-choice","--tool-call-parser","llama3_json"]
resources:
limits:
habana.ai/gaudi: 4
64 changes: 64 additions & 0 deletions helm-charts/financeagent/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "financeagent.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 "financeagent.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 "financeagent.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

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

{{- if .Values.serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "financeagent.serviceAccountName" . }}
labels:
{{- include "financeagent.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
{{- end }}
Loading