Skip to content

Commit 0363ad8

Browse files
committed
update ut.
1 parent dfbd7a7 commit 0363ad8

File tree

5 files changed

+39
-46
lines changed

5 files changed

+39
-46
lines changed

FinanceAgent/docker_compose/intel/hpu/gaudi/compose.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ services:
6060
http_proxy: ${http_proxy}
6161
https_proxy: ${https_proxy}
6262
FINNHUB_API_KEY: ${FINNHUB_API_KEY}
63+
FINANCIAL_DATASETS_API_KEY: ${FINANCIAL_DATASETS_API_KEY}
6364
port: 9096
6465

6566
supervisor-react-agent:

FinanceAgent/docker_compose/intel/hpu/gaudi/launch_agents.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export MAX_TOTAL_TOKENS=4096
3030
export DocSum_COMPONENT_NAME="OpeaDocSumvLLM"
3131
export DOCSUM_ENDPOINT="http://${ip_address}:9000/v1/docsum"
3232

33-
33+
export FINNHUB_API_KEY=${FINNHUB_API_KEY}
34+
export FINANCIAL_DATASETS_API_KEY=${FINANCIAL_DATASETS_API_KEY}
3435

3536
docker compose -f compose.yaml up -d

FinanceAgent/prompts/research_prompt.py

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -26,38 +26,23 @@
2626
2727
For writing a comprehensive analysis financial research report, you can use all the tools provided to retrieve information available for the company.
2828
29-
**Procedures:**
29+
**Pay attention to the followings:**
3030
1. Explicitly explain your working plan before you kick off.
3131
2. Read the question carefully. Firstly You need get accurate `start_date` and `end_date` value, because most tools need the 2 values like company news, financials. You can get `end_date` with `get_current_date` tool if user doesn't provide. And you can infer `start_date` with `end_date` using the rule `start_date is one year earlier than end_date` if user doesn't provide.
32-
3. Analyze Key Financial Statements:
33-
- **Balance Sheet Analysis**: Use the `analyze_balance_sheet` tool to obtain insights into the company's financial stability and liquidity.
34-
- **Income Statement Analysis**: Employ the `analyze_income_stmt` tool to assess the company's profitability over the fiscal year.
35-
- **Cash Flow Statement Analysis**: Apply the `analyze_cash_flow` tool to evaluate the cash inflows and outflows, providing a clear view of the company's operational efficiency.
36-
4. Perform Additional Analyses:
37-
- **Business Highlights**: Use the `get_company_news` tool to summarize the company's operational achievements and strategic milestones over the year.
38-
- **Company Description**: Utilize the `get_company_profile` tool to provide a detailed overview of the company's business model, industry positioning, and strategic initiatives.
39-
- **Risk Assessment**: Employ all the tool output financial information to identify and summarize the top three risks facing the company.
40-
5. Share Performance: analysis the stock performance using the `get_share_performance` tool.
41-
6. Generate Report: Finally, compile all the analyzed data, insights, and visuals into a comprehensive financial report, which contains the following paragraphs:
42-
- income summarization
43-
- market position
44-
- business overview
45-
- risk assessment
46-
- competitors analysis
47-
- share performance analysis
48-
7. All the paragraphs should combine between 400 and 450 words.
49-
8. Read the execution history if any to understand the tools that have been called and the information that has been gathered.
50-
9. Reason about the information gathered so far and decide if you can answer the question or if you need to call more tools.
51-
10. Do not repeat your thinking process!!! Only gather all information when you generate report.
32+
3. Use tools one by one for clarity, especially when asking for instructions.
33+
4. Provide stock performace, because the financial report is used for stock investment analysis.
34+
5. Read the execution history if any to understand the tools that have been called and the information that has been gathered.
35+
6. Reason about the information gathered so far and decide if you can answer the question or if you need to call more tools.
5236
5337
**Output format:**
54-
You should output your thought process. Finish thinking first. Output tool calls or your answer at the end.
55-
When making tool calls, you should use the following format:
38+
You should output your thought process:
39+
40+
When need tool calls, you should use the following format:
5641
TOOL CALL: {{"tool": "tool1", "args": {{"arg1": "value1", "arg2": "value2", ...}}}}
5742
TOOL CALL: {{"tool": "tool2", "args": {{"arg1": "value1", "arg2": "value2", ...}}}}
5843
59-
If you can generate the financial, provide the report in the following format:
60-
FINAL ANSWER: {{"answer": "your financial research report here"}}
44+
If you have enough financial data, provide the financial report in the following format:
45+
FINAL ANSWER: {{"answer": "compile all the analyzed data and insights into a comprehensive financial report, which contains the following paragraphs: income summarization, market position, business overview, risk assessment, competitors analysis, share performance analysis."}}
6146
6247
Follow these guidelines when formulating your answer:
6348
1. If the question contains a false premise or assumption, answer “invalid question”.

FinanceAgent/tests/test.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ def process_request(url, query, is_stream=False):
2929

3030
def test_worker_agent(args):
3131
url = f"http://{args.ip_addr}:{args.ext_port}/v1/chat/completions"
32-
query = {"role": "user", "messages": args.prompt, "stream": "false"}
32+
if args.tool_choice is None:
33+
query = {"role": "user", "messages": args.prompt, "stream": "false"}
34+
else:
35+
query = {"role": "user", "messages": args.prompt, "stream": "false", "tool_choice": args.tool_choice}
3336
ret = process_request(url, query)
3437
print("Response: ", ret)
3538

@@ -79,6 +82,7 @@ def test_supervisor_agent_single_turn(args):
7982
parser.add_argument("--prompt", type=str, help="prompt message")
8083
parser.add_argument("--agent_role", type=str, default="supervisor", help="supervisor or worker")
8184
parser.add_argument("--multi-turn", action="store_true", help="multi-turn conversation")
85+
parser.add_argument('--tool_choice', nargs='+', help='limit tools')
8286
args, _ = parser.parse_known_args()
8387

8488
print(args)

FinanceAgent/tests/test_compose_on_gaudi.sh

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ function build_vllm_docker_image() {
5959
git clone https://github.com/HabanaAI/vllm-fork.git
6060
fi
6161
cd ./vllm-fork
62-
VLLM_VER=$(git describe --tags "$(git rev-list --tags --max-count=1)")
62+
# VLLM_VER=$(git describe --tags "$(git rev-list --tags --max-count=1)")
63+
VLLM_VER=v0.6.6.post1+Gaudi-1.20.0
6364
git checkout ${VLLM_VER} &> /dev/null
6465
docker build --no-cache -f Dockerfile.hpu -t $vllm_image --shm-size=128g . --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy
6566
if [ $? -ne 0 ]; then
@@ -75,11 +76,11 @@ function start_vllm_service_70B() {
7576
echo "token is ${HF_TOKEN}"
7677
echo "start vllm gaudi service"
7778
echo "**************model is $model**************"
78-
docker run -d --runtime=habana --rm --name "vllm-gaudi-server" -e HABANA_VISIBLE_DEVICES=0,1,2,3 -p $vllm_port:8000 -v $vllm_volume:/data -e HF_TOKEN=$HF_TOKEN -e HUGGING_FACE_HUB_TOKEN=$HF_TOKEN -e HF_HOME=/data -e OMPI_MCA_btl_vader_single_copy_mechanism=none -e PT_HPU_ENABLE_LAZY_COLLECTIVES=true -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e no_proxy=$no_proxy -e VLLM_SKIP_WARMUP=true --cap-add=sys_nice --ipc=host $vllm_image --model ${model} --max-seq-len-to-capture 16384 --tensor-parallel-size 4
79-
sleep 5s
79+
docker run -d --runtime=habana --rm --name "vllm-gaudi-server" -e HABANA_VISIBLE_DEVICES=all -p $vllm_port:8000 -v $vllm_volume:/data -e HF_TOKEN=$HF_TOKEN -e HUGGING_FACE_HUB_TOKEN=$HF_TOKEN -e HF_HOME=/data -e OMPI_MCA_btl_vader_single_copy_mechanism=none -e PT_HPU_ENABLE_LAZY_COLLECTIVES=true -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e no_proxy=$no_proxy -e VLLM_SKIP_WARMUP=true --cap-add=sys_nice --ipc=host $vllm_image --model ${model} --max-seq-len-to-capture 16384 --tensor-parallel-size 4
80+
sleep 10s
8081
echo "Waiting vllm gaudi ready"
8182
n=0
82-
until [[ "$n" -ge 100 ]] || [[ $ready == true ]]; do
83+
until [[ "$n" -ge 200 ]] || [[ $ready == true ]]; do
8384
docker logs vllm-gaudi-server &> ${LOG_PATH}/vllm-gaudi-service.log
8485
n=$((n+1))
8586
if grep -q "Uvicorn running on" ${LOG_PATH}/vllm-gaudi-service.log; then
@@ -89,9 +90,9 @@ function start_vllm_service_70B() {
8990
echo "container vllm-gaudi-server not found"
9091
exit 1
9192
fi
92-
sleep 5s
93+
sleep 10s
9394
done
94-
sleep 5s
95+
sleep 10s
9596
echo "Service started successfully"
9697
}
9798

@@ -181,7 +182,7 @@ function validate_agent_service() {
181182
echo "======================Testing worker research agent======================"
182183
export agent_port="9096"
183184
prompt="generate NVDA financial research report"
184-
local CONTENT=$(python3 $WORKDIR/GenAIExamples/AgentQnA/tests/test.py --prompt "$prompt" --agent_role "worker" --ext_port $agent_port)
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")
185186
local EXIT_CODE=$(validate "$CONTENT" "NVDA" "research-agent-endpoint")
186187
echo $CONTENT
187188
echo $EXIT_CODE
@@ -214,6 +215,7 @@ function validate_agent_service() {
214215
# docker logs react-agent-endpoint
215216
# exit 1
216217
# fi
218+
217219
}
218220

219221
function stop_agent_docker() {
@@ -228,23 +230,23 @@ function stop_agent_docker() {
228230

229231

230232
echo "workpath: $WORKPATH"
231-
# echo "=================== Stop containers ===================="
232-
# stop_llm
233+
echo "=================== Stop containers ===================="
234+
stop_llm
233235
stop_agent_docker
234236
stop_dataprep
235237

236238
cd $WORKPATH/tests
237239

238240
# echo "=================== #1 Building docker images===================="
239-
# build_vllm_docker_image
240-
# build_dataprep_agent_images
241+
build_vllm_docker_image
242+
build_dataprep_agent_images
241243

242244
#### for local test
243245
# build_agent_image_local
244246
# echo "=================== #1 Building docker images completed===================="
245247

246248
# echo "=================== #2 Start vllm endpoint===================="
247-
# start_vllm_service_70B
249+
start_vllm_service_70B
248250
# echo "=================== #2 vllm endpoint started===================="
249251

250252
# echo "=================== #3 Start dataprep and ingest data ===================="
@@ -257,12 +259,12 @@ start_agents
257259
validate_agent_service
258260
echo "=================== #4 Agent test passed ===================="
259261

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

266-
# echo y | docker system prune
268+
echo y | docker system prune
267269

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

0 commit comments

Comments
 (0)