forked from AI4Finance-Foundation/FinRobot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
agent_builder_demo.py
44 lines (37 loc) · 1.69 KB
/
agent_builder_demo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import os
import autogen
from autogen.agentchat.contrib.agent_builder import AgentBuilder
from finrobot.utils import get_current_date
config_file_or_env = "OAI_CONFIG_LIST"
llm_config = {"temperature": 0}
builder = AgentBuilder(
config_file_or_env=config_file_or_env,
builder_model="gpt-4-0125-preview",
agent_model="gpt-4-0125-preview",
)
config_list = autogen.config_list_from_json(
config_file_or_env, filter_dict={"model": ["gpt-4-0125-preview"]}
)
building_task = "Gather information like company profile, recent stock price fluctuations, market news, and financial basics of a specified company (e.g. AAPL) by programming and analyze its current positive developments and potential concerns. Based on all the information, come up with a rough estimate (e.g. up by 2-3%) and give a summary of the reasons for next week's stock price. Each python program should execute on its own, and avoid plotting any chart."
config_path = "configs/save_config_forecaster.json"
if os.path.exists(config_path):
agent_list, agent_config = builder.load(config_path)
else:
agent_list, agent_configs = builder.build(
building_task,
llm_config,
coding=True,
code_execution_config={
"work_dir": "coding",
"use_docker": False,
},
)
builder.save(config_path)
group_chat = autogen.GroupChat(agents=agent_list, messages=[], max_round=20)
manager = autogen.GroupChatManager(
groupchat=group_chat, llm_config={"config_list": config_list, **llm_config}
)
agent_list[0].initiate_chat(
manager,
message=f"Today is {get_current_date()}, predict next week's stock price for Nvidia with its recent market news and stock price movements.",
)