Skip to content

Commit 3d18797

Browse files
committed
update test scripts and readme
Signed-off-by: minmin-intel <minmin.hou@intel.com>
1 parent ad62ec6 commit 3d18797

File tree

6 files changed

+97
-77
lines changed

6 files changed

+97
-77
lines changed

FinanceAgent/README.md

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ Please note:
2727
```bash
2828
mkdir /path/to/your/workspace/
2929
export WORKDIR=/path/to/your/workspace/
30-
genaicomps
31-
genaiexamples
30+
cd $WORKDIR
31+
git clone https://github.com/opea-project/GenAIExamples.git
3232
```
3333

3434
### 2.2 Set up env vars
@@ -37,15 +37,18 @@ genaiexamples
3737
export HF_CACHE_DIR=/path/to/your/model/cache/
3838
export HF_TOKEN=<you-hf-token>
3939
export FINNHUB_API_KEY=<your-finnhub-api-key> # go to https://finnhub.io/ to get your free api key
40-
export FINANCIAL_DATASETS_API_KEY=<your-api-key> # go to
40+
export FINANCIAL_DATASETS_API_KEY=<your-api-key> # go to https://docs.financialdatasets.ai/ to get your free api key
4141
```
4242

43-
### 2.3 Build docker images
43+
### 2.3 [Optional] Build docker images
4444

45-
Build docker images for dataprep, agent, agent-ui.
45+
Only needed when docker pull failed.
4646

4747
```bash
48-
cd GenAIExamples/FinanceAgent/docker_image_build
48+
cd $WORKDIR/GenAIExamples/FinanceAgent/docker_image_build
49+
# get GenAIComps repo
50+
git clone https://github.com/opea-project/GenAIComps.git
51+
# build the images
4952
docker compose -f build.yaml build --no-cache
5053
```
5154

@@ -92,7 +95,7 @@ python $WORKPATH/tests/test_redis_finance.py --port 6007 --test_option get
9295
```
9396

9497
### 3.3 Launch the multi-agent system
95-
98+
The command below will launch 3 agent microservices, 1 docsum microservice, 1 UI microservice.
9699
```bash
97100
# inside $WORKDIR/GenAIExamples/FinanceAgent/docker_compose/intel/hpu/gaudi/
98101
bash launch_agents.sh
@@ -116,14 +119,14 @@ prompt="generate NVDA financial research report"
116119
python3 $WORKDIR/GenAIExamples/FinanceAgent/tests/test.py --prompt "$prompt" --agent_role "worker" --ext_port $agent_port --tool_choice "get_current_date" --tool_choice "get_share_performance"
117120
```
118121

119-
Supervisor ReAct Agent:
122+
Supervisor Agent single turns:
120123

121124
```bash
122125
export agent_port="9090"
123126
python3 $WORKDIR/GenAIExamples/FinanceAgent/tests/test.py --agent_role "supervisor" --ext_port $agent_port --stream
124127
```
125128

126-
Supervisor ReAct Agent Multi turn:
129+
Supervisor Agent multi turn:
127130

128131
```bash
129132
python3 $WORKDIR/GenAIExamples/FinanceAgent/tests/test.py --agent_role "supervisor" --ext_port $agent_port --multi-turn --stream
@@ -135,12 +138,34 @@ python3 $WORKDIR/GenAIExamples/FinanceAgent/tests/test.py --agent_role "supervis
135138
The UI microservice is launched in the previous step with the other microservices.
136139
To see the UI, open a web browser to `http://${ip_address}:5175` to access the UI. Note the `ip_address` here is the host IP of the UI microservice.
137140

138-
1. `create Admin Account` with a random value
141+
1. Create Admin Account with a random value
142+
143+
2. Enter the endpoints in the `Connections` settings
144+
145+
First, click on the user icon in the upper right corner to open `Settings`. Click on `Admin Settings`. Click on `Connections`.
146+
147+
Then, enter the supervisor agent endpoint in the `OpenAI API` section: `http://${ip_address}:9090/v1`. Enter the API key as "empty". Add an arbitrary model id in `Model IDs`, for example, "opea_agent". The `ip_address` here should be the host ip of the agent microservice.
148+
149+
Then, enter the dataprep endpoint in the `Icloud File API` section. You first need to enable `Icloud File API` by clicking on the button on the right to turn it into green and then enter the endpoint url, for example, `http://${ip_address}:6007/v1`. The `ip_address` here should be the host ip of the dataprep microservice.
150+
151+
You should see screen like the screenshot below when the settings are done.
139152

140-
2. use an opea agent endpoint, for example, the `Research Agent` endpoint `http://$ip_address:9096/v1`, which is a openai compatible api
153+
![opea-agent-setting](assets/ui_connections_settings.png)
141154

142-
![opea-agent-setting](assets/opea-agent-setting.png)
155+
3. Upload documents with UI
143156

144-
3. test opea agent with ui
157+
Click on the `Workplace` icon in the top left corner. Click `Knowledge`. Click on the "+" sign to the right of `Icloud Knowledge`. You can paste in an url the the left hand side of the pop-up window, or upload a local file by click on the cloud icon on the right hand side of the pop-up window. Then click on the `Upload Confirm` button. Wait till the processing is done and the pop-up window will be closed on its own when the data ingestion is done. See the screenshot below.
158+
159+
Note: the data ingestion may take a few minutes depending on the length of the document. Please wait patiently and do not close the pop-up window.
160+
161+
![upload-doc-ui](assets/upload_doc_ui.png)
162+
163+
4. Test agent with UI
164+
165+
After the settings are done and documents are ingested, you can start to ask questions to the agent. Click on the `New Chat` icon in the top left corner, and type in your questions in the text box in the middle of the UI.
166+
167+
The UI will stream the agent's response tokens. You need to expand the `Thinking` tab to see the agent's reasoning process. After the agent made tool calls, you would also see the tool output after the tool returns output to the agent. Note: it may take a while to get the tool output back if the tool execution takes time.
145168

146169
![opea-agent-test](assets/opea-agent-test.png)
170+
171+
Loading

FinanceAgent/assets/upload_doc_ui.png

105 KB
Loading

FinanceAgent/docker_image_build/build.yaml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,4 @@ services:
2020
https_proxy: ${https_proxy}
2121
no_proxy: ${no_proxy}
2222
image: ${REGISTRY:-opea}/agent:${TAG:-latest}
23-
# agent-ui:
24-
# build:
25-
# context: ../ui
26-
# dockerfile: ./docker/Dockerfile
27-
# extends: agent
28-
# image: ${REGISTRY:-opea}/agent-ui:${TAG:-latest}
23+

FinanceAgent/tests/test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ def test_chat_completion_multi_turn(args):
7676
def test_supervisor_agent_single_turn(args):
7777
url = f"http://{args.ip_addr}:{args.ext_port}/v1/chat/completions"
7878
query_list = [
79-
# "What was Gap's revenue growth in 2024?",
80-
# "Can you summarize Costco's 2025 Q2 earnings call?",
79+
"What was Gap's revenue growth in 2024?",
80+
"Can you summarize Costco's 2025 Q2 earnings call?",
8181
"Should I increase investment in Johnson & Johnson?",
8282
]
8383
for query in query_list:

FinanceAgent/tests/test_compose_on_gaudi.sh

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -165,56 +165,56 @@ function start_agents() {
165165

166166
function validate_agent_service() {
167167
# # test worker finqa agent
168-
# echo "======================Testing worker finqa agent======================"
169-
# export agent_port="9095"
170-
# prompt="What is Gap's revenue in 2024?"
171-
# local CONTENT=$(python3 $WORKDIR/GenAIExamples/FinanceAgent/tests/test.py --prompt "$prompt" --agent_role "worker" --ext_port $agent_port)
172-
# echo $CONTENT
173-
# local EXIT_CODE=$(validate "$CONTENT" "15" "finqa-agent-endpoint")
174-
# echo $EXIT_CODE
175-
# local EXIT_CODE="${EXIT_CODE:0-1}"
176-
# if [ "$EXIT_CODE" == "1" ]; then
177-
# docker logs finqa-agent-endpoint
178-
# exit 1
179-
# fi
168+
echo "======================Testing worker finqa agent======================"
169+
export agent_port="9095"
170+
prompt="What is Gap's revenue in 2024?"
171+
local CONTENT=$(python3 $WORKDIR/GenAIExamples/FinanceAgent/tests/test.py --prompt "$prompt" --agent_role "worker" --ext_port $agent_port)
172+
echo $CONTENT
173+
local EXIT_CODE=$(validate "$CONTENT" "15" "finqa-agent-endpoint")
174+
echo $EXIT_CODE
175+
local EXIT_CODE="${EXIT_CODE:0-1}"
176+
if [ "$EXIT_CODE" == "1" ]; then
177+
docker logs finqa-agent-endpoint
178+
exit 1
179+
fi
180180

181181
# # test worker research agent
182-
# echo "======================Testing worker research agent======================"
183-
# export agent_port="9096"
184-
# prompt="Johnson & Johnson"
185-
# local CONTENT=$(python3 $WORKDIR/GenAIExamples/AgentQnA/tests/test.py --prompt "$prompt" --agent_role "worker" --ext_port $agent_port --tool_choice "get_current_date" --tool_choice "get_share_performance")
186-
# local EXIT_CODE=$(validate "$CONTENT" "Johnson" "research-agent-endpoint")
187-
# echo $CONTENT
188-
# echo $EXIT_CODE
189-
# local EXIT_CODE="${EXIT_CODE:0-1}"
190-
# if [ "$EXIT_CODE" == "1" ]; then
191-
# docker logs research-agent-endpoint
192-
# exit 1
193-
# fi
182+
echo "======================Testing worker research agent======================"
183+
export agent_port="9096"
184+
prompt="Johnson & Johnson"
185+
local CONTENT=$(python3 $WORKDIR/GenAIExamples/AgentQnA/tests/test.py --prompt "$prompt" --agent_role "worker" --ext_port $agent_port --tool_choice "get_current_date" --tool_choice "get_share_performance")
186+
local EXIT_CODE=$(validate "$CONTENT" "Johnson" "research-agent-endpoint")
187+
echo $CONTENT
188+
echo $EXIT_CODE
189+
local EXIT_CODE="${EXIT_CODE:0-1}"
190+
if [ "$EXIT_CODE" == "1" ]; then
191+
docker logs research-agent-endpoint
192+
exit 1
193+
fi
194194

195195
# test supervisor react agent
196196
echo "======================Testing supervisor agent: single turns ======================"
197197
export agent_port="9090"
198198
local CONTENT=$(python3 $WORKDIR/GenAIExamples/FinanceAgent/tests/test.py --agent_role "supervisor" --ext_port $agent_port --stream)
199199
echo $CONTENT
200-
local EXIT_CODE=$(validate "$CONTENT" "test completed with success" "react-agent-endpoint")
200+
local EXIT_CODE=$(validate "$CONTENT" "test completed with success" "supervisor-agent-endpoint")
201201
echo $EXIT_CODE
202202
local EXIT_CODE="${EXIT_CODE:0-1}"
203203
if [ "$EXIT_CODE" == "1" ]; then
204-
docker logs react-agent-endpoint
204+
docker logs supervisor-agent-endpoint
205205
exit 1
206206
fi
207207

208208
# echo "======================Testing supervisor agent: multi turns ======================"
209-
# local CONTENT=$(python3 $WORKDIR/GenAIExamples/FinanceAgent/tests/test.py --agent_role "supervisor" --ext_port $agent_port --multi-turn --stream)
210-
# echo $CONTENT
211-
# local EXIT_CODE=$(validate "$CONTENT" "test completed with success" "react-agent-endpoint")
212-
# echo $EXIT_CODE
213-
# local EXIT_CODE="${EXIT_CODE:0-1}"
214-
# if [ "$EXIT_CODE" == "1" ]; then
215-
# docker logs react-agent-endpoint
216-
# exit 1
217-
# fi
209+
local CONTENT=$(python3 $WORKDIR/GenAIExamples/FinanceAgent/tests/test.py --agent_role "supervisor" --ext_port $agent_port --multi-turn --stream)
210+
echo $CONTENT
211+
local EXIT_CODE=$(validate "$CONTENT" "test completed with success" "supervisor-agent-endpoint")
212+
echo $EXIT_CODE
213+
local EXIT_CODE="${EXIT_CODE:0-1}"
214+
if [ "$EXIT_CODE" == "1" ]; then
215+
docker logs supervisor-agent-endpoint
216+
exit 1
217+
fi
218218

219219
}
220220

@@ -231,40 +231,40 @@ function stop_agent_docker() {
231231

232232
echo "workpath: $WORKPATH"
233233
echo "=================== Stop containers ===================="
234-
# stop_llm
234+
stop_llm
235235
stop_agent_docker
236-
# stop_dataprep
236+
stop_dataprep
237237

238238
cd $WORKPATH/tests
239239

240-
# echo "=================== #1 Building docker images===================="
241-
# build_vllm_docker_image
242-
# build_dataprep_agent_images
240+
echo "=================== #1 Building docker images===================="
241+
build_vllm_docker_image
242+
build_dataprep_agent_images
243243

244244
#### for local test
245245
# build_agent_image_local
246246
# echo "=================== #1 Building docker images completed===================="
247247

248-
# echo "=================== #2 Start vllm endpoint===================="
249-
# start_vllm_service_70B
250-
# echo "=================== #2 vllm endpoint started===================="
248+
echo "=================== #2 Start vllm endpoint===================="
249+
start_vllm_service_70B
250+
echo "=================== #2 vllm endpoint started===================="
251251

252-
# echo "=================== #3 Start dataprep and ingest data ===================="
253-
# start_dataprep
254-
# ingest_validate_dataprep
255-
# echo "=================== #3 Data ingestion and validation completed===================="
252+
echo "=================== #3 Start dataprep and ingest data ===================="
253+
start_dataprep
254+
ingest_validate_dataprep
255+
echo "=================== #3 Data ingestion and validation completed===================="
256256

257-
# echo "=================== #4 Start agents ===================="
257+
echo "=================== #4 Start agents ===================="
258258
start_agents
259259
validate_agent_service
260-
# echo "=================== #4 Agent test passed ===================="
260+
echo "=================== #4 Agent test passed ===================="
261261

262-
# echo "=================== #5 Stop microservices ===================="
263-
# stop_agent_docker
264-
# stop_dataprep
265-
# stop_llm
266-
# echo "=================== #5 Microservices stopped===================="
262+
echo "=================== #5 Stop microservices ===================="
263+
stop_agent_docker
264+
stop_dataprep
265+
stop_llm
266+
echo "=================== #5 Microservices stopped===================="
267267

268-
# echo y | docker system prune
268+
echo y | docker system prune
269269

270-
# echo "ALL DONE!!"
270+
echo "ALL DONE!!"

0 commit comments

Comments
 (0)