|
| 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 | +``` |
0 commit comments