Skip to content

Commit ad62ec6

Browse files
committed
update readme and tool yamls
Signed-off-by: minmin-intel <minmin.hou@intel.com>
1 parent a222d1c commit ad62ec6

File tree

7 files changed

+103
-84
lines changed

7 files changed

+103
-84
lines changed

FinanceAgent/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ genaiexamples
3636
```bash
3737
export HF_CACHE_DIR=/path/to/your/model/cache/
3838
export HF_TOKEN=<you-hf-token>
39-
39+
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
4041
```
4142

4243
### 2.3 Build docker images

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ services:
4747
ip_address: ${ip_address}
4848
strategy: react_llama
4949
with_memory: false
50-
recursion_limit: ${recursion_limit_worker}
50+
recursion_limit: 25
5151
llm_engine: vllm
5252
HUGGINGFACEHUB_API_TOKEN: ${HUGGINGFACEHUB_API_TOKEN}
5353
llm_endpoint_url: ${LLM_ENDPOINT_URL}
@@ -68,7 +68,7 @@ services:
6868
container_name: supervisor-agent-endpoint
6969
depends_on:
7070
- worker-finqa-agent
71-
# - worker-research-agent
71+
- worker-research-agent
7272
volumes:
7373
- ${TOOLSET_PATH}:/home/user/tools/
7474
- ${PROMPT_PATH}:/home/user/prompts/

FinanceAgent/prompts/research_prompt.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
4. Provide stock performance, because the financial report is used for stock investment analysis.
3434
5. Read the execution history if any to understand the tools that have been called and the information that has been gathered.
3535
6. Reason about the information gathered so far and decide if you can answer the question or if you need to call more tools.
36+
7. Most of the tools need ticker symbol, use your knowledge to convert the company name to the ticker symbol if user only provides the company name.
3637
3738
**Output format:**
3839
You should output your thought process:

FinanceAgent/tests/test.py

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ def process_request(url, query, is_stream=False):
1818
else:
1919
for line in resp.iter_lines(decode_unicode=True):
2020
print(line)
21-
ret = None
21+
ret = "Done"
2222

2323
resp.raise_for_status() # Raise an exception for unsuccessful HTTP status codes
2424
return ret
2525
except requests.exceptions.RequestException as e:
2626
ret = f"An error occurred:{e}"
27-
return None
27+
return ret
2828

2929

3030
def test_worker_agent(args):
@@ -35,13 +35,19 @@ def test_worker_agent(args):
3535
query = {"role": "user", "messages": args.prompt, "stream": "false", "tool_choice": args.tool_choice}
3636
ret = process_request(url, query)
3737
print("Response: ", ret)
38+
if "error" in ret.lower():
39+
print("Error in response, please check the server.")
40+
return "error"
41+
else:
42+
return "test completed with success"
3843

3944

4045
def add_message_and_run(url, user_message, thread_id, stream=False):
4146
print("User message: ", user_message)
4247
query = {"role": "user", "messages": user_message, "thread_id": thread_id, "stream": stream}
4348
ret = process_request(url, query, is_stream=stream)
4449
print("Response: ", ret)
50+
return ret
4551

4652

4753
def test_chat_completion_multi_turn(args):
@@ -51,28 +57,37 @@ def test_chat_completion_multi_turn(args):
5157
# first turn
5258
print("===============First turn==================")
5359
user_message = "Key takeaways of Gap's 2024 Q4 earnings call?"
54-
add_message_and_run(url, user_message, thread_id, stream=args.stream)
60+
ret = add_message_and_run(url, user_message, thread_id, stream=args.stream)
61+
if "error" in ret.lower():
62+
print("Error in response, please check the server.")
63+
return "error"
5564
print("===============End of first turn==================")
5665

5766
# second turn
5867
print("===============Second turn==================")
5968
user_message = "What was Gap's forecast for 2025?"
60-
add_message_and_run(url, user_message, thread_id, stream=args.stream)
69+
ret = add_message_and_run(url, user_message, thread_id, stream=args.stream)
70+
if "error" in ret.lower():
71+
print("Error in response, please check the server.")
72+
return "error"
6173
print("===============End of second turn==================")
62-
74+
return "test completed with success"
6375

6476
def test_supervisor_agent_single_turn(args):
6577
url = f"http://{args.ip_addr}:{args.ext_port}/v1/chat/completions"
6678
query_list = [
67-
"What was Gap's revenue growth in 2024?",
68-
"Can you summarize Costco's 2025 Q2 earnings call?",
69-
# "Should I increase investment in Costco?",
79+
# "What was Gap's revenue growth in 2024?",
80+
# "Can you summarize Costco's 2025 Q2 earnings call?",
81+
"Should I increase investment in Johnson & Johnson?",
7082
]
7183
for query in query_list:
7284
thread_id = f"{uuid.uuid4()}"
73-
add_message_and_run(url, query, thread_id, stream=args.stream)
85+
ret = add_message_and_run(url, query, thread_id, stream=args.stream)
86+
if "error" in ret.lower():
87+
print("Error in response, please check the server.")
88+
return "error"
7489
print("=" * 50)
75-
90+
return "test completed with success"
7691

7792
if __name__ == "__main__":
7893
parser = argparse.ArgumentParser()
@@ -89,10 +104,12 @@ def test_supervisor_agent_single_turn(args):
89104

90105
if args.agent_role == "supervisor":
91106
if args.multi_turn:
92-
test_chat_completion_multi_turn(args)
107+
ret = test_chat_completion_multi_turn(args)
93108
else:
94-
test_supervisor_agent_single_turn(args)
109+
ret = test_supervisor_agent_single_turn(args)
110+
print(ret)
95111
elif args.agent_role == "worker":
96-
test_worker_agent(args)
112+
ret = test_worker_agent(args)
113+
print(ret)
97114
else:
98115
raise ValueError("Invalid agent role")

FinanceAgent/tests/test_compose_on_gaudi.sh

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ function start_vllm_service_70B() {
7676
echo "token is ${HF_TOKEN}"
7777
echo "start vllm gaudi service"
7878
echo "**************model is $model**************"
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
79+
docker run -d --runtime=habana --rm --name "vllm-gaudi-server-mh" -e HABANA_VISIBLE_DEVICES=0,2,3,4 -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
8080
sleep 10s
8181
echo "Waiting vllm gaudi ready"
8282
n=0
@@ -165,50 +165,50 @@ 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="generate NVDA financial research report"
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" "NVDA" "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" "" "react-agent-endpoint")
201-
# echo $EXIT_CODE
202-
# local EXIT_CODE="${EXIT_CODE:0-1}"
203-
# if [ "$EXIT_CODE" == "1" ]; then
204-
# docker logs react-agent-endpoint
205-
# exit 1
206-
# fi
200+
local EXIT_CODE=$(validate "$CONTENT" "test completed with success" "react-agent-endpoint")
201+
echo $EXIT_CODE
202+
local EXIT_CODE="${EXIT_CODE:0-1}"
203+
if [ "$EXIT_CODE" == "1" ]; then
204+
docker logs react-agent-endpoint
205+
exit 1
206+
fi
207207

208-
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" "" "react-agent-endpoint")
208+
# 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")
212212
# echo $EXIT_CODE
213213
# local EXIT_CODE="${EXIT_CODE:0-1}"
214214
# if [ "$EXIT_CODE" == "1" ]; then
@@ -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

240240
# echo "=================== #1 Building docker images===================="
241-
build_vllm_docker_image
242-
build_dataprep_agent_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

248248
# echo "=================== #2 Start vllm endpoint===================="
249-
start_vllm_service_70B
249+
# start_vllm_service_70B
250250
# echo "=================== #2 vllm endpoint started===================="
251251

252252
# echo "=================== #3 Start dataprep and ingest data ===================="
253-
start_dataprep
254-
ingest_validate_dataprep
253+
# start_dataprep
254+
# ingest_validate_dataprep
255255
# 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!!"

FinanceAgent/tools/research_agent_tools.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ get_company_profile:
77
args_schema:
88
symbol:
99
type: str
10-
description: the company name or ticker symbol.
10+
description: the ticker symbol.
1111
return_output: profile
1212

1313
get_company_news:
@@ -16,7 +16,7 @@ get_company_news:
1616
args_schema:
1717
symbol:
1818
type: str
19-
description: the company name or ticker symbol.
19+
description: the ticker symbol.
2020
start_date:
2121
type: str
2222
description: start date of the search period for the company's basic financials, yyyy-mm-dd.
@@ -34,7 +34,7 @@ get_basic_financials_history:
3434
args_schema:
3535
symbol:
3636
type: str
37-
description: the company name or ticker symbol.
37+
description: the ticker symbol.
3838
freq:
3939
type: str
4040
description: reporting frequency of the company's basic financials, such as annual, quarterly.
@@ -55,7 +55,7 @@ get_basic_financials:
5555
args_schema:
5656
symbol:
5757
type: str
58-
description: the company name or ticker symbol.
58+
description: the ticker symbol.
5959
selected_columns:
6060
type: list
6161
description: List of column names of news to return, should be chosen from 'assetTurnoverTTM', 'bookValue', 'cashRatio', 'currentRatio', 'ebitPerShare', 'eps', 'ev', 'fcfMargin', 'fcfPerShareTTM', 'grossMargin', 'inventoryTurnoverTTM', 'longtermDebtTotalAsset', 'longtermDebtTotalCapital', 'longtermDebtTotalEquity', 'netDebtToTotalCapital', 'netDebtToTotalEquity', 'netMargin', 'operatingMargin', 'payoutRatioTTM', 'pb', 'peTTM', 'pfcfTTM', 'pretaxMargin', 'psTTM', 'ptbv', 'quickRatio', 'receivablesTurnoverTTM', 'roaTTM', 'roeTTM', 'roicTTM', 'rotcTTM', 'salesPerShare', 'sgaToSale', 'tangibleBookValue', 'totalDebtToEquity', 'totalDebtToTotalAsset', 'totalDebtToTotalCapital', 'totalRatio','10DayAverageTradingVolume', '13WeekPriceReturnDaily', '26WeekPriceReturnDaily', '3MonthADReturnStd', '3MonthAverageTradingVolume', '52WeekHigh', '52WeekHighDate', '52WeekLow', '52WeekLowDate', '52WeekPriceReturnDaily', '5DayPriceReturnDaily', 'assetTurnoverAnnual', 'assetTurnoverTTM', 'beta', 'bookValuePerShareAnnual', 'bookValuePerShareQuarterly', 'bookValueShareGrowth5Y', 'capexCagr5Y', 'cashFlowPerShareAnnual', 'cashFlowPerShareQuarterly', 'cashFlowPerShareTTM', 'cashPerSharePerShareAnnual', 'cashPerSharePerShareQuarterly', 'currentDividendYieldTTM', 'currentEv/freeCashFlowAnnual', 'currentEv/freeCashFlowTTM', 'currentRatioAnnual', 'currentRatioQuarterly', 'dividendGrowthRate5Y', 'dividendPerShareAnnual', 'dividendPerShareTTM', 'dividendYieldIndicatedAnnual', 'ebitdPerShareAnnual', 'ebitdPerShareTTM', 'ebitdaCagr5Y', 'ebitdaInterimCagr5Y', 'enterpriseValue', 'epsAnnual', 'epsBasicExclExtraItemsAnnual', 'epsBasicExclExtraItemsTTM', 'epsExclExtraItemsAnnual', 'epsExclExtraItemsTTM', 'epsGrowth3Y', 'epsGrowth5Y', 'epsGrowthQuarterlyYoy', 'epsGrowthTTMYoy', 'epsInclExtraItemsAnnual', 'epsInclExtraItemsTTM', 'epsNormalizedAnnual', 'epsTTM', 'focfCagr5Y', 'grossMargin5Y', 'grossMarginAnnual', 'grossMarginTTM', 'inventoryTurnoverAnnual', 'inventoryTurnoverTTM', 'longTermDebt/equityAnnual', 'longTermDebt/equityQuarterly', 'marketCapitalization', 'monthToDatePriceReturnDaily', 'netIncomeEmployeeAnnual', 'netIncomeEmployeeTTM', 'netInterestCoverageAnnual', 'netInterestCoverageTTM', 'netMarginGrowth5Y', 'netProfitMargin5Y', 'netProfitMarginAnnual', 'netProfitMarginTTM', 'operatingMargin5Y'.
@@ -72,7 +72,7 @@ analyze_balance_sheet:
7272
args_schema:
7373
symbol:
7474
type: str
75-
description: the company name or ticker symbol.
75+
description: the ticker symbol.
7676
period:
7777
type: str
7878
description: The period of the balance sheets, possible values such as annual, quarterly, ttm. Default is 'annual'.
@@ -87,7 +87,7 @@ analyze_income_stmt:
8787
args_schema:
8888
symbol:
8989
type: str
90-
description: the company name or ticker symbol.
90+
description: the ticker symbol.
9191
period:
9292
type: str
9393
description: The period of the balance sheets, possible values, such as annual, quarterly, ttm. Default is 'annual'.
@@ -102,7 +102,7 @@ analyze_cash_flow:
102102
args_schema:
103103
symbol:
104104
type: str
105-
description: the company name or ticker symbol.
105+
description: the ticker symbol.
106106
period:
107107
type: str
108108
description: The period of the balance sheets, possible values, such as annual, quarterly, ttm. Default is 'annual'.
@@ -117,7 +117,7 @@ get_share_performance:
117117
args_schema:
118118
symbol:
119119
type: str
120-
description: the company name or ticker symbol.
120+
description: the ticker symbol.
121121
end_date:
122122
type: str
123123
description: end date of the search period for the company's basic financials, yyyy-mm-dd.

FinanceAgent/tools/supervisor_agent_tools.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ summarization_tool:
2222
description: Name of the company document belongs to
2323
return_output: summary
2424

25-
# research_agent:
26-
# description: generate research report on a specified company with fundamentals analysis, sentiment analysis and risk analysis.
27-
# callable_api: supervisor_tools.py:research_agent
28-
# args_schema:
29-
# company:
30-
# type: str
31-
# description: the company name
32-
# return_output: report
25+
research_agent:
26+
description: generate research report on a specified company with fundamentals analysis, sentiment analysis and risk analysis.
27+
callable_api: supervisor_tools.py:research_agent
28+
args_schema:
29+
company:
30+
type: str
31+
description: the company name
32+
return_output: report

0 commit comments

Comments
 (0)