cmagganas commited on
Commit
78f0f06
1 Parent(s): 3b0dc9e

Upload 14 files

Browse files
src/.cache/41/cache.db ADDED
Binary file (180 kB). View file
 
src/UI/.chainlit/config.toml ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [project]
2
+ # Whether to enable telemetry (default: true). No personal data is collected.
3
+ enable_telemetry = true
4
+
5
+ # List of environment variables to be provided by each user to use the app.
6
+ user_env = []
7
+
8
+ # Duration (in seconds) during which the session is saved when the connection is lost
9
+ session_timeout = 3600
10
+
11
+ # Enable third parties caching (e.g LangChain cache)
12
+ cache = false
13
+
14
+ # Follow symlink for asset mount (see https://github.com/Chainlit/chainlit/issues/317)
15
+ # follow_symlink = false
16
+
17
+ [features]
18
+ # Show the prompt playground
19
+ prompt_playground = true
20
+
21
+ # Process and display HTML in messages. This can be a security risk (see https://stackoverflow.com/questions/19603097/why-is-it-dangerous-to-render-user-generated-html-or-javascript)
22
+ unsafe_allow_html = false
23
+
24
+ # Process and display mathematical expressions. This can clash with "$" characters in messages.
25
+ latex = false
26
+
27
+ # Authorize users to upload files with messages
28
+ multi_modal = true
29
+
30
+ # Allows user to use speech to text
31
+ [features.speech_to_text]
32
+ enabled = false
33
+ # See all languages here https://github.com/JamesBrill/react-speech-recognition/blob/HEAD/docs/API.md#language-string
34
+ # language = "en-US"
35
+
36
+ [UI]
37
+ # Name of the app and chatbot.
38
+ name = "Chatbot"
39
+
40
+ # Show the readme while the conversation is empty.
41
+ show_readme_as_default = true
42
+
43
+ # Description of the app and chatbot. This is used for HTML tags.
44
+ # description = ""
45
+
46
+ # Large size content are by default collapsed for a cleaner ui
47
+ default_collapse_content = true
48
+
49
+ # The default value for the expand messages settings.
50
+ default_expand_messages = false
51
+
52
+ # Hide the chain of thought details from the user in the UI.
53
+ hide_cot = false
54
+
55
+ # Link to your github repo. This will add a github button in the UI's header.
56
+ # github = ""
57
+
58
+ # Specify a CSS file that can be used to customize the user interface.
59
+ # The CSS file can be served from the public directory or via an external link.
60
+ # custom_css = "/public/test.css"
61
+
62
+ # Override default MUI light theme. (Check theme.ts)
63
+ [UI.theme.light]
64
+ #background = "#FAFAFA"
65
+ #paper = "#FFFFFF"
66
+
67
+ [UI.theme.light.primary]
68
+ #main = "#F80061"
69
+ #dark = "#980039"
70
+ #light = "#FFE7EB"
71
+
72
+ # Override default MUI dark theme. (Check theme.ts)
73
+ [UI.theme.dark]
74
+ #background = "#FAFAFA"
75
+ #paper = "#FFFFFF"
76
+
77
+ [UI.theme.dark.primary]
78
+ #main = "#F80061"
79
+ #dark = "#980039"
80
+ #light = "#FFE7EB"
81
+
82
+
83
+ [meta]
84
+ generated_by = "0.7.700"
src/UI/app.py ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ##########################################################################
2
+ #
3
+ #
4
+ # Waiting on https://github.com/microsoft/autogen/issues/527 to be solved
5
+ #
6
+ #
7
+ ##########################################################################
8
+
9
+
10
+ from typing import Dict, Optional, Union
11
+
12
+ from autogen import Agent, AssistantAgent, UserProxyAgent, config_list_from_json
13
+ import chainlit as cl
14
+
15
+ from dotenv import load_dotenv
16
+ import os
17
+
18
+ # Load environment variables from .env file
19
+ load_dotenv()
20
+ TASK = "Plot a chart of NVDA stock price change YTD and save it on disk."
21
+
22
+
23
+ async def ask_helper(func, **kwargs):
24
+ res = await func(**kwargs).send()
25
+ while not res:
26
+ res = await func(**kwargs).send()
27
+ return res
28
+
29
+
30
+ class ChainlitAssistantAgent(AssistantAgent):
31
+ async def a_send(
32
+ self,
33
+ message: Union[Dict, str],
34
+ recipient: Agent,
35
+ request_reply: Optional[bool] = None,
36
+ silent: Optional[bool] = False,
37
+ ) -> bool:
38
+ await cl.Message(
39
+ content=f'*Sending message to "{recipient.name}":*\n\n{message}',
40
+ author="AssistantAgent",
41
+ ).send()
42
+ await super(ChainlitAssistantAgent, self).a_send(
43
+ message=message,
44
+ recipient=recipient,
45
+ request_reply=request_reply,
46
+ silent=silent,
47
+ )
48
+
49
+
50
+ class ChainlitUserProxyAgent(UserProxyAgent):
51
+ async def get_human_input(self, prompt: str) -> str:
52
+ if prompt.startswith(
53
+ "Provide feedback to assistant. Press enter to skip and use auto-reply"
54
+ ):
55
+ res = await ask_helper(
56
+ cl.AskActionMessage,
57
+ content="Continue or provide feedback?",
58
+ actions=[
59
+ cl.Action(
60
+ name="continue", value="continue", label="✅ Continue"
61
+ ),
62
+ cl.Action(
63
+ name="feedback",
64
+ value="feedback",
65
+ label="💬 Provide feedback",
66
+ ),
67
+ cl.Action(
68
+ name="exit",
69
+ value="exit",
70
+ label="🔚 Exit Conversation"
71
+ ),
72
+ ],
73
+ )
74
+ if res.get("value") == "continue":
75
+ return ""
76
+ if res.get("value") == "exit":
77
+ return "exit"
78
+
79
+ reply = await ask_helper(
80
+ cl.AskUserMessage, content=prompt, timeout=60)
81
+
82
+ return reply["content"].strip()
83
+
84
+ async def a_send(
85
+ self,
86
+ message: Union[Dict, str],
87
+ recipient: Agent,
88
+ request_reply: Optional[bool] = None,
89
+ silent: Optional[bool] = False,
90
+ ):
91
+ await cl.Message(
92
+ content=f'*Sending message to "{recipient.name}"*:\n\n{message}',
93
+ author="UserProxyAgent",
94
+ ).send()
95
+ await super(ChainlitUserProxyAgent, self).a_send(
96
+ message=message,
97
+ recipient=recipient,
98
+ request_reply=request_reply,
99
+ silent=silent,
100
+ )
101
+
102
+
103
+ @cl.on_chat_start
104
+ async def on_chat_start():
105
+ config_list = config_list_from_json(env_or_file="OAI_CONFIG_LIST")
106
+ assistant = ChainlitAssistantAgent(
107
+ "assistant", llm_config={"config_list": config_list}
108
+ )
109
+ user_proxy = ChainlitUserProxyAgent(
110
+ "user_proxy",
111
+ code_execution_config={
112
+ "work_dir": "workspace",
113
+ "use_docker": False,
114
+ },
115
+ )
116
+ await cl.Message(content=f"Starting agents on task: {TASK}...").send()
117
+ await user_proxy.a_initiate_chat(
118
+ assistant,
119
+ message=TASK,
120
+ )
src/UI/chainlit.md ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Welcome to Chainlit! 🚀🤖
2
+
3
+ Hi there, Developer! 👋 We're excited to have you on board. Chainlit is a powerful tool designed to help you prototype, debug and share applications built on top of LLMs.
4
+
5
+ ## Useful Links 🔗
6
+
7
+ - **Documentation:** Get started with our comprehensive [Chainlit Documentation](https://docs.chainlit.io) 📚
8
+ - **Discord Community:** Join our friendly [Chainlit Discord](https://discord.gg/k73SQ3FyUh) to ask questions, share your projects, and connect with other developers! 💬
9
+
10
+ We can't wait to see what you create with Chainlit! Happy coding! 💻😊
11
+
12
+ ## Welcome screen
13
+
14
+ To modify the welcome screen, edit the `chainlit.md` file at the root of your project. If you do not want a welcome screen, just leave this file empty.
src/backend/AgentSelector.py ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from dotenv import load_dotenv
3
+ load_dotenv()
4
+
5
+ import openai
6
+ from typing import List
7
+ from pydantic import BaseModel
8
+
9
+ # # write an openai function that takes ensures response is a list
10
+ # class Response(BaseModel):
11
+ # response: List[str]
12
+
13
+ # tools = [
14
+ # {
15
+ # "type": "function",
16
+ # "function": {
17
+ # "name": "list_agents",
18
+ # "description": "ensure response is a list",
19
+ # "parameters": Response.model_json_schema(),
20
+ # }
21
+ # }
22
+ # ]
23
+
24
+
25
+ class AgentSelector:
26
+ def __init__(
27
+ self,
28
+ task: str,
29
+ available_agents: List,
30
+ n_agents: int = 3,
31
+ chat_history: str = '',
32
+ prev_output: str = '',
33
+ ):
34
+ self.task = task
35
+ self.available_agents = available_agents
36
+ self.n_agents = n_agents
37
+ self.chat_history = chat_history
38
+ self.prev_output = prev_output
39
+ self.api_key = os.getenv("OPENAI_API_KEY")
40
+ self.agents_to_use = []
41
+ self.inputs = {
42
+ "task": task,
43
+ "available_agents": available_agents,
44
+ "n_agents": n_agents,
45
+ "chat_history": chat_history,
46
+ "prev_output": prev_output,
47
+ }
48
+
49
+ def select_agents(self):
50
+ # Use OpenAI GPT-4 API to select agents
51
+ openai.api_key = self.api_key
52
+ client = openai.OpenAI()
53
+ system_prompt=f"You are an Agent Selector. Select {self.n_agents} agents from the available list of agents to best solve the task based on their descriptions. ONLY RESPOND WITH A PYTHON LIST OF AGENTS."
54
+ # print(self.available_agents)
55
+ user_prompt=f"""
56
+ Task: {self.task}\n
57
+ Available Agents: {self.available_agents}\n
58
+ Number of Agents to Select: {self.n_agents}\n\n
59
+ List:
60
+ """
61
+
62
+ # tools: https://platform.openai.com/docs/api-reference/chat/create#chat-create-tools
63
+ # tools = []
64
+
65
+ response = client.chat.completions.create(
66
+ model="gpt-4-1106-preview",
67
+ messages=[
68
+ {"role": "system", "content": system_prompt},
69
+ {"role": "user", "content": f"Task: Please help me with my Digital Marketing.\nAvailable Agents: {self.available_agents}\nNumber of Agents to Select: {self.n_agents}\n\nList: "},
70
+ {"role": "assistant", "content": "marketing_digital"},
71
+ {"role": "user", "content": user_prompt}
72
+ ],
73
+ # max_tokens=100,
74
+ # tools=tools,
75
+ # tool_choice="auto",
76
+ # stream=True,
77
+ )
78
+
79
+ # if stream is True, then response.choices will be a generator
80
+ # for chunk in response:
81
+ # print(chunk.choices[0].delta)
82
+
83
+ self.agents_to_use = response.choices[0].message.content
84
+ return self.agents_to_use
85
+
86
+ def run_selection(self):
87
+ selected_agents = self.select_agents()
88
+ selected_agents = selected_agents.replace("[", "").replace("]", "").replace("'", "").replace(" ", "").split(",")
89
+ print(f"Agents Selected: {selected_agents}")
90
+ print(f"return type: {type(selected_agents)}")
91
+ return selected_agents
92
+
93
+ if __name__ == "__main__":
94
+ example = "exampleJuan"
95
+ if example == "example1":
96
+ task = "Please help me with my sales."
97
+ available_agents = ["marketing_seo", "marketing_digital", "marketing_miami", "sales_chad", "sales_brad", "sales_senior"]
98
+ n_agents=1
99
+ elif example == "exampleJuan":
100
+ task = "revenue in the east coast is falling and the competitor is doing great with their product."
101
+ available_agents = ["marketing", "sales", "finance", "engineering", "customer_service", "hr", "legal", "operations", "product"]
102
+ n_agents=3
103
+
104
+
105
+ print(f"Task: {task}")
106
+ # agent_selector = AgentSelector(task: str, available_agents: List[str], n_agents: int=n_agents)
107
+ agent_selector = AgentSelector(task, available_agents, n_agents=n_agents)
108
+ agent_selector.run_selection()
109
+ # print(agent_selector.inputs)
src/backend/AgentSpawner.py ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from autogen.agentchat import (
2
+ Agent,
3
+ AssistantAgent,
4
+ UserProxyAgent,
5
+ )
6
+ from typing import Dict, List, Optional, Union
7
+ import os
8
+ from dotenv import load_dotenv
9
+ import autogen
10
+
11
+ # https://github.com/PanoEvJ/Tiny_Agents/blob/main/src/backup/agentchat_groupchat.ipynb
12
+ load_dotenv()
13
+
14
+
15
+ class AgentSpawner: # Group chat GroupChatSpawner class
16
+ def __init__(
17
+ self,
18
+ name: List[str],
19
+ system_message: List[str],
20
+ human_input_mode: List[str],
21
+ llm_config: Dict[str, any],
22
+ agent_type: List[str],
23
+ ):
24
+ self.name = name
25
+ self.llm_config = llm_config
26
+ self.system_message = system_message
27
+ self.human_input_mode = human_input_mode
28
+ self.llm_config = llm_config
29
+ self.agent_type = agent_type
30
+
31
+ def spawn(self) -> List[Agent]:
32
+ agents = []
33
+ for index, ag_type in enumerate(self.agent_type):
34
+ if ag_type == "assistant":
35
+ agents.append(
36
+ autogen.AssistantAgent(
37
+ name=self.name[index],
38
+ system_message=self.system_message[index],
39
+ # human_input_mode=self.human_input_mode[index],
40
+ llm_config=self.llm_config,
41
+ )
42
+ )
43
+ elif ag_type == "userproxy":
44
+ agents.append(
45
+ autogen.UserProxyAgent(
46
+ name=self.name[index],
47
+ human_input_mode=self.human_input_mode[index],
48
+ system_message=self.system_message[index],
49
+ llm_config=self.llm_config,
50
+ )
51
+ )
52
+ return agents
53
+
54
+
55
+ def combine_description_and_skills(
56
+ data: Dict[str, Dict[str, any]], llm_config
57
+ ) -> AgentSpawner:
58
+ agent_type = []
59
+ names = []
60
+ system_message = []
61
+ human_input_mode = []
62
+ for key, values in data.items():
63
+ agent_type.append(values["agent_type"])
64
+ names.append(values["name"])
65
+ human_input_mode.append(values["human_input_mode"])
66
+ system_message.append(
67
+ values["description"] + " with skillset in " + " ".join(values["skills"])
68
+ )
69
+
70
+ # You need to define llm_config according to your needs
71
+ # llm_config = {}
72
+
73
+ return AgentSpawner(
74
+ name=names,
75
+ system_message=system_message,
76
+ human_input_mode=human_input_mode,
77
+ llm_config=llm_config,
78
+ agent_type=agent_type,
79
+ )
80
+
81
+
82
+ json_data = {
83
+ "1": {
84
+ "name": "sales",
85
+ "agent_type": "assistant",
86
+ "description": "sales agents",
87
+ "skills": ["sales", "customer service", "communication"],
88
+ "human_input_mode": "TERMINATE",
89
+ },
90
+ "2": {
91
+ "name": "marketing",
92
+ "agent_type": "assistant",
93
+ "description": "marketing agents",
94
+ "skills": ["marketing", "communication"],
95
+ "human_input_mode": "",
96
+ },
97
+ "3": {
98
+ "name": "engineer",
99
+ "agent_type": "assistant",
100
+ "description": "engineers",
101
+ "skills": ["python", "linux", "communication"],
102
+ "human_input_mode": "",
103
+ },
104
+ }
105
+ config_list_gpt4 = [
106
+ {
107
+ "model": "gpt-4",
108
+ "api_key": os.getenv("OPENAI_API_KEY"),
109
+ # "api_key": str(os.environ["OPENAI_API_KEY"]),
110
+ },
111
+ {
112
+ "model": "gpt-4",
113
+ "api_key": os.getenv("OPENAI_API_KEY"),
114
+ },
115
+ ]
116
+ llm_config = {"config_list": config_list_gpt4}
117
+ agent_spawner = combine_description_and_skills(json_data, llm_config)
118
+
119
+ all_agents = agent_spawner.spawn()
120
+ print(all_agents)
src/backend/GroupChatSpawner.py ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from autogen.agentchat import (
2
+ Agent,
3
+ GroupChat,
4
+ GroupChatManager,
5
+ AssistantAgent,
6
+ UserProxyAgent,
7
+ )
8
+ from typing import Dict, List, Optional, Union
9
+ import os
10
+ from dotenv import load_dotenv
11
+
12
+
13
+ # https://github.com/PanoEvJ/Tiny_Agents/blob/main/src/backup/agentchat_groupchat.ipynb
14
+
15
+
16
+ class GroupChatSpawner: # Group chat GroupChatSpawner class
17
+ """(In preview) A group chat class that contains the following data fields:
18
+ - agents: a list of participating agents.
19
+ - messages: a list of messages in the group chat.
20
+ - max_round: the maximum number of rounds.
21
+ - llm_config: to give to the GroupChatManager
22
+
23
+
24
+ And returns: the GroupChatSpawner should retrieve the memory of the chat history
25
+ """
26
+
27
+ # Use Groupchat object!
28
+
29
+ def __init__(
30
+ self,
31
+ agents: List[Agent],
32
+ llm_config: Dict[str, any],
33
+ messages: List[Dict],
34
+ max_round: int = 10,
35
+ ):
36
+ self.agents = agents
37
+ self.messages = messages
38
+ self.max_round = max_round
39
+ self.llm_config = llm_config
40
+
41
+ def spawn(self) -> GroupChatManager:
42
+ """Docstring"""
43
+ groupchat = GroupChat(
44
+ agents=self.agents,
45
+ messages=self.messages,
46
+ max_round=self.max_round,
47
+ )
48
+
49
+ return GroupChatManager(groupchat=groupchat, llm_config=self.llm_config)
50
+
51
+ def retrieve_memory(self) -> list[str]:
52
+ pass
53
+
54
+
55
+ if __name__ == "__main__":
56
+ load_dotenv()
57
+
58
+ config_list_gpt4 = [
59
+ {
60
+ "model": "gpt-3.5-turbo",
61
+ "api_key": os.getenv("OPENAI_API_KEY"),
62
+ # "api_key": str(os.environ["OPENAI_API_KEY"]),
63
+ },
64
+ {
65
+ "model": "gpt-3.5-turbo",
66
+ "api_key": os.getenv("OPENAI_API_KEY"),
67
+ },
68
+ ]
69
+ Marketing_Expert = """
70
+ Name: Alex the Marketing Expert
71
+ Age: 32
72
+ Background: Holds a Master's degree in Marketing and has a passion for cycling. Alex has previously worked with several sports brands and has a deep understanding of the biking community.
73
+ Personality Traits: Creative, data-driven, and trend-savvy. Excels in digital marketing strategies.
74
+ Goals: To increase brand visibility and engage more with the biking community through innovative marketing campaigns.
75
+ Challenges: Keeping up with rapidly changing marketing trends and consumer preferences.
76
+ Digital Marketing: Expert in SEO, social media advertising, and email marketing campaigns specifically tailored for the sports industry.
77
+ Brand Development: Skilled in developing and maintaining a strong brand identity that resonates with the biking community.
78
+ Market Research: Proficient in conducting market analysis to identify new trends and customer needs in the biking market.
79
+ Content Creation: Talented in creating engaging content (blogs, videos, social media posts) to drive brand awareness and customer engagement.
80
+ """
81
+ Sales_Expert = """
82
+ Name: Emma the Sales Expert
83
+ Age: 28
84
+ Background: Emma has a Bachelor's degree in Business Administration and has been working in sales for 5 years, specializing in sports equipment. She's known for her exceptional customer service skills and product knowledge.
85
+ Personality Traits: Outgoing, persuasive, and empathetic. Great at building relationships and understanding customer needs.
86
+ Goals: To consistently exceed sales targets and develop strong, long-lasting relationships with key clients.
87
+ Customer Relationship Management: Excel at building and maintaining strong relationships with clients, ensuring long-term customer loyalty.
88
+ Product Knowledge: In-depth understanding of biking products and the ability to articulate product benefits effectively to customers.
89
+ Sales Strategy: Proficient in developing and implementing effective sales strategies to target various customer segments in the biking market.
90
+ Negotiation Skills: Strong negotiation skills to close deals and secure new business opportunities.
91
+ """
92
+ Manager = """
93
+ Name: Michael the Manager
94
+ Age: 40
95
+ Background: With an MBA and over 15 years of experience in management roles, Michael has a solid track record in leading teams and driving company growth. He's particularly adept at strategic planning and operations management.
96
+ Personality Traits: Leadership-oriented, analytical, and decisive. Excellent at problem-solving and team management.
97
+ Goals: To streamline operations for efficiency, foster a positive work culture, and drive the company towards its strategic goals.
98
+ Strategic Planning: Excellent at setting strategic goals for the company and developing plans to achieve these goals.
99
+ Team Management: Skilled in managing diverse teams, fostering a collaborative and productive work environment.
100
+ Financial Acumen: Strong understanding of budgeting, financial planning, and resource allocation to maximize efficiency and profitability.
101
+ Operational Oversight: Proficient in overseeing daily operations, ensuring processes are streamlined and goals are met.
102
+ """
103
+ Business_Overview = """
104
+ The market for sports articles for bikers is dynamic and multifaceted, catering to a wide range of customers from casual riders to professional athletes. It encompasses various segments including road biking, mountain biking, BMX, and leisure biking. The demand is driven by a growing interest in outdoor activities, fitness, and eco-friendly modes of transportation.
105
+ Key Segments:
106
+ Road Biking: This segment includes high-performance bikes and gear for speed and endurance, appealing to serious athletes and fitness enthusiasts. The market is dominated by a few major brands such as Trek, Cannondale, and Specialized.
107
+ Internal Weakness: Limited Online Presence and Digital Marketing Expertise.
108
+ Your company currently has a minimal online presence, with a basic website and limited activity on social media platforms. The in-house team lacks expertise in digital marketing, SEO, and e-commerce strategies. This deficiency results in reduced online visibility and a lack of engagement with potential customers, especially those who predominantly shop and seek information online.
109
+ Market Opportunity: Growing Demand for E-Bikes.
110
+ """
111
+ email = """
112
+ Subject: Strategy Meeting Invitation: Capitalizing on E-Bike Market Opportunity
113
+
114
+ Body:
115
+
116
+ Dear Alex, Emma, and Michael,
117
+
118
+ I hope this email finds you well. As we navigate through an increasingly competitive market, it is essential that we continually align our strategies with emerging opportunities and internal capabilities. To this end, I would like to invite you to a strategic meeting to discuss a significant opportunity in the e-bike market and address our current internal challenges that are im
119
+ """
120
+ meeting_opener = """
121
+ "Good morning everyone,
122
+
123
+ Thank you for joining this crucial meeting today. I'm excited to discuss an opportunity that has the potential to significantly impact our market positioning and overall growth.
124
+
125
+ Firstly, let's talk about the opportunity at hand. We're witnessing a substantial shift in consumer preferences towards e-bikes, especially among urban commuters. This trend isn't just a fleeting one; it's driven by increasing environmental awareness, the need for efficient commuting options, an aging population, and a growing interest in fitness. In fact, the global e-bike market is expected to grow at a CAGR of 9.01% from 2021 to 2028, reaching a value of $38.6 billion by 2028.
126
+ """
127
+
128
+ llm_configg = {"config_list": config_list_gpt4}
129
+ print("loading dotenv", config_list_gpt4, llm_configg)
130
+
131
+ llm_config = {"config_list": config_list_gpt4}
132
+
133
+ marketing = AssistantAgent(
134
+ name="Alex_the_Marketing_Expert",
135
+ system_message=Marketing_Expert,
136
+ # human_input_mode="TERMINATE",
137
+ llm_config=llm_config,
138
+ )
139
+ sales = UserProxyAgent(
140
+ name="Emma_the_Sales_Expert",
141
+ # human_input_mode="NEVER",
142
+ human_input_mode="TERMINATE",
143
+ system_message=Sales_Expert,
144
+ llm_config=llm_config,
145
+ )
146
+ manager = AssistantAgent(
147
+ name="Michael_the_Manager",
148
+ system_message=Manager,
149
+ # human_input_mode="TERMINATE",
150
+ llm_config=llm_config,
151
+ )
152
+ # print("Agents are initiated:",agents_managers, agents_sales)
153
+ spawnerr = GroupChatSpawner(
154
+ agents=[marketing, sales, manager],
155
+ messages=[],
156
+ max_round=5,
157
+ llm_config=llm_configg,
158
+ )
159
+ managerr = spawnerr.spawn()
160
+
161
+ print("GroupChatSpawner initiated!\n\n")
162
+
163
+ sales.initiate_chat(managerr, message=Business_Overview + email + meeting_opener)
src/backend/HumanResources.py ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import os
3
+
4
+ # load json file from this file's directory
5
+ CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
6
+ FILE_PATH = os.path.join(CURRENT_DIR, "agents.json")
7
+
8
+ with open(FILE_PATH) as f:
9
+ sample_agent_json = json.load(f)
10
+
11
+
12
+ class HumanResources:
13
+ def __init__(self):
14
+ self.agent_json = sample_agent_json
15
+
16
+ def __repr__(self):
17
+ return f"{self.agent_json}"
18
+
19
+ def _create(self, new_agent):
20
+ self.agent_json[new_agent["role"]] = new_agent
21
+ self._save_to_file()
22
+ return self.agent_json[new_agent["role"]]
23
+
24
+ def _read(self, agent_name):
25
+ return self.agent_json[agent_name]
26
+
27
+ def _update(self, agent_name, new_agent):
28
+ self.agent_json[agent_name] = new_agent
29
+ self._save_to_file()
30
+ return self.agent_json[agent_name]
31
+
32
+ def _delete(self, agent_name):
33
+ del self.agent_json[agent_name]
34
+ self._save_to_file()
35
+ return self.agent_json
36
+
37
+ def agent_object(self, agent_name):
38
+ return self.agent_json[agent_name]
39
+
40
+ def select_agents(self):
41
+ return list(self.agent_json.keys())
42
+
43
+ def _save_to_file(self):
44
+ with open(FILE_PATH, "w") as f:
45
+ json.dump(self.agent_json, f, indent=4)
46
+
47
+
48
+ # # Example usage
49
+ # hr = HumanResources()
50
+ # new_agent = {"name": "Agent Smith", "role": "Analyst", "description": "Data Analysis"}
51
+ # hr._create(new_agent)
52
+
53
+ # # Print updated agents
54
+ # print(hr.select_agents())
55
+
56
+
57
+ if __name__ == "__main__":
58
+ hr = HumanResources()
59
+ # assert _create() returns a new agent object: {'name': 'finance', 'title': 'finance manager'}
60
+ assert hr._create({"name": "finance", "title": "finance manager"}) == {
61
+ "name": "finance",
62
+ "title": "finance manager",
63
+ }
64
+ # assert _read() returns an agent object: {'name': 'finance', 'title': 'finance manager'}
65
+ assert hr._read("finance") == {"name": "finance", "title": "finance manager"}
66
+ # assert _update() returns an updated agent object: {'name': 'finance', 'title': 'senior finance manager'}
67
+ assert hr._update(
68
+ "finance", {"name": "finance", "title": "senior finance manager"}
69
+ ) == {"name": "finance", "title": "senior finance manager"}
70
+ # assert _delete() returns json all agents without the deleted agent, just check the names of the agents: ['sales', 'marketing', 'engineer']
71
+ temp_json = hr._delete("finance")
72
+ assert list(temp_json.keys()) == ["sales", "marketing", "engineer"]
73
+ # assert select_agents() returns a list of all agents: ['sales', 'marketing', 'engineer']
74
+ assert hr.select_agents() == ["sales", "marketing", "engineer"]
75
+
76
+ print("All tests passed!")
src/backend/agents.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "sales": {
3
+ "name": "sales",
4
+ "description": "sales agents",
5
+ "skills": [
6
+ "sales",
7
+ "customer service",
8
+ "communication"
9
+ ]
10
+ },
11
+ "marketing": {
12
+ "name": "marketing",
13
+ "description": "marketing agents",
14
+ "skills": [
15
+ "marketing",
16
+ "communication"
17
+ ]
18
+ },
19
+ "engineer": {
20
+ "name": "engineer",
21
+ "description": "engineers",
22
+ "skills": [
23
+ "python",
24
+ "linux",
25
+ "communication"
26
+ ]
27
+ },
28
+ "Analyst": {
29
+ "name": "Agent Smith",
30
+ "role": "Analyst",
31
+ "description": "Data Analysis"
32
+ }
33
+ }
src/backend/app.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from autogen.agentchat import (
2
+ Agent,
3
+ GroupChat,
4
+ GroupChatManager,
5
+ AssistantAgent,
6
+ UserProxyAgent,
7
+ )
8
+ import openai
9
+ from typing import Dict, List, Optional, Union
10
+ import os
11
+ from dotenv import load_dotenv
12
+ from HumanResources import HumanResources
13
+ from AgentSelector import AgentSelector
14
+ from AgentSpawner import AgentSpawner
15
+ from GroupChatSpawner import GroupChatSpawner
16
+
17
+ openai.api_key = os.getenv("OPENAI_API_KEY")
18
+
19
+ CHAT_INITIATOR = "finance"
20
+
21
+ hr = HumanResources()
22
+ all_available_agents = hr.select_agents()
23
+ print(all_available_agents)
24
+
25
+ task = "revenue in the east coast is falling and the competitor is doing great with their product."
26
+ selector = AgentSelector(task=task, available_agents=all_available_agents, n_agents=3)
27
+ selected_agents = selector.run_selection()
28
+ print("*" * 10, selected_agents)
29
+
30
+ selected_agents = ["sales", "marketing", "engineer"]
31
+ agent_spawner = AgentSpawner(selected_agents, CHAT_INITIATOR)
32
+ agents = agent_spawner.spawn()
33
+ print(agents)
34
+
35
+ messages = []
36
+ llm_config = {"config_list": [{"model": "gpt-4"}], "seed": 42, "request_timeout": 600}
37
+ groupchat = GroupChatSpawner(
38
+ agents=agents, llm_config=llm_config, messages=messages, max_round=10
39
+ )
40
+
41
+ chat_initiator.initiate_chat(
42
+ manager,
43
+ message="I want to design an app to make me one million dollars in one month. Yes, your heard that right.",
44
+ )
src/backup/README.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ # DO NOT CHANGE ANYTHING IN THESE NOTEBOOKS
2
+
3
+ Supplementary material:
4
+
5
+ [Custom agent groupchat](https://github.com/microsoft/autogen/blob/main/notebook/agentchat_hierarchy_flow_using_select_speaker.ipynb)
src/backup/agentchat_groupchat.ipynb ADDED
@@ -0,0 +1,285 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "attachments": {},
5
+ "cell_type": "markdown",
6
+ "metadata": {},
7
+ "source": [
8
+ "<a href=\"https://colab.research.google.com/github/microsoft/autogen/blob/main/notebook/agentchat_groupchat.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
9
+ ]
10
+ },
11
+ {
12
+ "attachments": {},
13
+ "cell_type": "markdown",
14
+ "metadata": {},
15
+ "source": [
16
+ "# Auto Generated Agent Chat: Group Chat\n",
17
+ "\n",
18
+ "AutoGen offers conversable agents powered by LLM, tool or human, which can be used to perform tasks collectively via automated chat. This framework allows tool use and human participation through multi-agent conversation.\n",
19
+ "Please find documentation about this feature [here](https://microsoft.github.io/autogen/docs/Use-Cases/agent_chat).\n",
20
+ "\n",
21
+ "This notebook is modified based on https://github.com/microsoft/FLAML/blob/4ea686af5c3e8ff24d9076a7a626c8b28ab5b1d7/notebook/autogen_multiagent_roleplay_chat.ipynb\n",
22
+ "\n",
23
+ "## Requirements\n",
24
+ "\n",
25
+ "AutoGen requires `Python>=3.8`. To run this notebook example, please install:\n",
26
+ "```bash\n",
27
+ "pip install pyautogen\n",
28
+ "```"
29
+ ]
30
+ },
31
+ {
32
+ "cell_type": "code",
33
+ "execution_count": null,
34
+ "metadata": {},
35
+ "outputs": [],
36
+ "source": [
37
+ "%%capture --no-stderr\n",
38
+ "# %pip install pyautogen~=0.2.0b4"
39
+ ]
40
+ },
41
+ {
42
+ "attachments": {},
43
+ "cell_type": "markdown",
44
+ "metadata": {},
45
+ "source": [
46
+ "## Set your API Endpoint\n",
47
+ "\n",
48
+ "The [`config_list_from_json`](https://microsoft.github.io/autogen/docs/reference/oai/openai_utils#config_list_from_json) function loads a list of configurations from an environment variable or a json file."
49
+ ]
50
+ },
51
+ {
52
+ "cell_type": "code",
53
+ "execution_count": null,
54
+ "metadata": {},
55
+ "outputs": [],
56
+ "source": [
57
+ "import autogen\n",
58
+ "import os\n",
59
+ "\n",
60
+ "# config_list_gpt4 = autogen.config_list_from_json(\n",
61
+ "# \"OAI_CONFIG_LIST\",\n",
62
+ "# filter_dict={\n",
63
+ "# \"model\": [\"gpt-4\", \"gpt-4-0314\", \"gpt4\", \"gpt-4-32k\", \"gpt-4-32k-0314\", \"gpt-4-32k-v0314\"],\n",
64
+ "# },\n",
65
+ "# )\n",
66
+ "\n",
67
+ "config_list_gpt4 = [\n",
68
+ " {\n",
69
+ " \"model\": \"gpt-4\",\n",
70
+ " \"api_key\": os.getenv(\"OPENAI_API_KEY\"),\n",
71
+ " # \"api_key\": str(os.environ[\"OPENAI_API_KEY\"]),\n",
72
+ " },\n",
73
+ " {\n",
74
+ " \"model\": \"gpt-4-32k\",\n",
75
+ " \"api_key\": os.getenv(\"OPENAI_API_KEY\"),\n",
76
+ " },\n",
77
+ "]\n",
78
+ "\n",
79
+ "\n",
80
+ "# config_list_gpt35 = autogen.config_list_from_json(\n",
81
+ "# \"OAI_CONFIG_LIST\",\n",
82
+ "# filter_dict={\n",
83
+ "# \"model\": {\n",
84
+ "# \"gpt-3.5-turbo\",\n",
85
+ "# \"gpt-3.5-turbo-16k\",\n",
86
+ "# \"gpt-3.5-turbo-0301\",\n",
87
+ "# \"chatgpt-35-turbo-0301\",\n",
88
+ "# \"gpt-35-turbo-v0301\",\n",
89
+ "# },\n",
90
+ "# },\n",
91
+ "# )"
92
+ ]
93
+ },
94
+ {
95
+ "attachments": {},
96
+ "cell_type": "markdown",
97
+ "metadata": {},
98
+ "source": [
99
+ "It first looks for environment variable \"OAI_CONFIG_LIST\" which needs to be a valid json string. If that variable is not found, it then looks for a json file named \"OAI_CONFIG_LIST\". It filters the configs by models (you can filter by other keys as well). Only the gpt-4 models are kept in the list based on the filter condition.\n",
100
+ "\n",
101
+ "The config list looks like the following:\n",
102
+ "```python\n",
103
+ "config_list = [\n",
104
+ " {\n",
105
+ " 'model': 'gpt-4',\n",
106
+ " 'api_key': '<your OpenAI API key here>',\n",
107
+ " },\n",
108
+ " {\n",
109
+ " 'model': 'gpt-4',\n",
110
+ " 'api_key': '<your Azure OpenAI API key here>',\n",
111
+ " 'base_url': '<your Azure OpenAI API base here>',\n",
112
+ " 'api_type': 'azure',\n",
113
+ " 'api_version': '2023-06-01-preview',\n",
114
+ " },\n",
115
+ " {\n",
116
+ " 'model': 'gpt-4-32k',\n",
117
+ " 'api_key': '<your Azure OpenAI API key here>',\n",
118
+ " 'base_url': '<your Azure OpenAI API base here>',\n",
119
+ " 'api_type': 'azure',\n",
120
+ " 'api_version': '2023-06-01-preview',\n",
121
+ " },\n",
122
+ "]\n",
123
+ "```\n",
124
+ "\n",
125
+ "You can set the value of config_list in any way you prefer. Please refer to this [notebook](https://github.com/microsoft/autogen/blob/main/notebook/oai_openai_utils.ipynb) for full code examples of the different methods."
126
+ ]
127
+ },
128
+ {
129
+ "attachments": {},
130
+ "cell_type": "markdown",
131
+ "metadata": {},
132
+ "source": [
133
+ "## Construct Agents"
134
+ ]
135
+ },
136
+ {
137
+ "attachments": {},
138
+ "cell_type": "markdown",
139
+ "metadata": {},
140
+ "source": [
141
+ "## Start Chat"
142
+ ]
143
+ },
144
+ {
145
+ "cell_type": "code",
146
+ "execution_count": null,
147
+ "metadata": {},
148
+ "outputs": [],
149
+ "source": [
150
+ "Marketing_Expert = \"\"\"\n",
151
+ "Name: Alex the Marketing Expert\n",
152
+ "Age: 32\n",
153
+ "Background: Holds a Master's degree in Marketing and has a passion for cycling. Alex has previously worked with several sports brands and has a deep understanding of the biking community.\n",
154
+ "Personality Traits: Creative, data-driven, and trend-savvy. Excels in digital marketing strategies.\n",
155
+ "Goals: To increase brand visibility and engage more with the biking community through innovative marketing campaigns.\n",
156
+ "Challenges: Keeping up with rapidly changing marketing trends and consumer preferences.\n",
157
+ "Digital Marketing: Expert in SEO, social media advertising, and email marketing campaigns specifically tailored for the sports industry.\n",
158
+ "Brand Development: Skilled in developing and maintaining a strong brand identity that resonates with the biking community.\n",
159
+ "Market Research: Proficient in conducting market analysis to identify new trends and customer needs in the biking market.\n",
160
+ "Content Creation: Talented in creating engaging content (blogs, videos, social media posts) to drive brand awareness and customer engagement.\n",
161
+ "\"\"\"\n",
162
+ "Sales_Expert = \"\"\"\n",
163
+ "Name: Emma the Sales Expert\n",
164
+ "Age: 28\n",
165
+ "Background: Emma has a Bachelor's degree in Business Administration and has been working in sales for 5 years, specializing in sports equipment. She's known for her exceptional customer service skills and product knowledge.\n",
166
+ "Personality Traits: Outgoing, persuasive, and empathetic. Great at building relationships and understanding customer needs.\n",
167
+ "Goals: To consistently exceed sales targets and develop strong, long-lasting relationships with key clients.\n",
168
+ "Customer Relationship Management: Excel at building and maintaining strong relationships with clients, ensuring long-term customer loyalty.\n",
169
+ "Product Knowledge: In-depth understanding of biking products and the ability to articulate product benefits effectively to customers.\n",
170
+ "Sales Strategy: Proficient in developing and implementing effective sales strategies to target various customer segments in the biking market.\n",
171
+ "Negotiation Skills: Strong negotiation skills to close deals and secure new business opportunities.\n",
172
+ "\"\"\"\n",
173
+ "Manager = \"\"\"\n",
174
+ "Name: Michael the Manager\n",
175
+ "Age: 40\n",
176
+ "Background: With an MBA and over 15 years of experience in management roles, Michael has a solid track record in leading teams and driving company growth. He's particularly adept at strategic planning and operations management.\n",
177
+ "Personality Traits: Leadership-oriented, analytical, and decisive. Excellent at problem-solving and team management.\n",
178
+ "Goals: To streamline operations for efficiency, foster a positive work culture, and drive the company towards its strategic goals.\n",
179
+ "Strategic Planning: Excellent at setting strategic goals for the company and developing plans to achieve these goals.\n",
180
+ "Team Management: Skilled in managing diverse teams, fostering a collaborative and productive work environment.\n",
181
+ "Financial Acumen: Strong understanding of budgeting, financial planning, and resource allocation to maximize efficiency and profitability.\n",
182
+ "Operational Oversight: Proficient in overseeing daily operations, ensuring processes are streamlined and goals are met.\n",
183
+ "\"\"\"\n",
184
+ "Business_Overview = \"\"\"\n",
185
+ "The market for sports articles for bikers is dynamic and multifaceted, catering to a wide range of customers from casual riders to professional athletes. It encompasses various segments including road biking, mountain biking, BMX, and leisure biking. The demand is driven by a growing interest in outdoor activities, fitness, and eco-friendly modes of transportation.\n",
186
+ "Key Segments:\n",
187
+ "Road Biking: This segment includes high-performance bikes and gear for speed and endurance, appealing to serious athletes and fitness enthusiasts. The market is dominated by a few major brands such as Trek, Cannondale, and Specialized.\n",
188
+ "Internal Weakness: Limited Online Presence and Digital Marketing Expertise.\n",
189
+ "Your company currently has a minimal online presence, with a basic website and limited activity on social media platforms. The in-house team lacks expertise in digital marketing, SEO, and e-commerce strategies. This deficiency results in reduced online visibility and a lack of engagement with potential customers, especially those who predominantly shop and seek information online.\n",
190
+ "Market Opportunity: Growing Demand for E-Bikes.\n",
191
+ "\"\"\"\n",
192
+ "email = \"\"\"\n",
193
+ "Subject: Strategy Meeting Invitation: Capitalizing on E-Bike Market Opportunity\n",
194
+ "\n",
195
+ "Body:\n",
196
+ "\n",
197
+ "Dear Alex, Emma, and Michael,\n",
198
+ "\n",
199
+ "I hope this email finds you well. As we navigate through an increasingly competitive market, it is essential that we continually align our strategies with emerging opportunities and internal capabilities. To this end, I would like to invite you to a strategic meeting to discuss a significant opportunity in the e-bike market and address our current internal challenges that are im\n",
200
+ "\"\"\"\n",
201
+ "meeting_opener = \"\"\"\n",
202
+ "\"Good morning everyone,\n",
203
+ "\n",
204
+ "Thank you for joining this crucial meeting today. I'm excited to discuss an opportunity that has the potential to significantly impact our market positioning and overall growth.\n",
205
+ "\n",
206
+ "Firstly, let's talk about the opportunity at hand. We're witnessing a substantial shift in consumer preferences towards e-bikes, especially among urban commuters. This trend isn't just a fleeting one; it's driven by increasing environmental awareness, the need for efficient commuting options, an aging population, and a growing interest in fitness. In fact, the global e-bike market is expected to grow at a CAGR of 9.01% from 2021 to 2028, reaching a value of $38.6 billion by 2028.\n",
207
+ "\"\"\""
208
+ ]
209
+ },
210
+ {
211
+ "cell_type": "code",
212
+ "execution_count": null,
213
+ "metadata": {},
214
+ "outputs": [],
215
+ "source": [
216
+ "llm_config = {\"config_list\": config_list_gpt4}\n",
217
+ "marketing = autogen.AssistantAgent(\n",
218
+ " name=\"Alex_the_Marketing_Expert\",\n",
219
+ " system_message=Marketing_Expert,\n",
220
+ " # human_input_mode=\"TERMINATE\",\n",
221
+ " llm_config=llm_config,\n",
222
+ ")\n",
223
+ "sales = autogen.UserProxyAgent(\n",
224
+ " name=\"Emma_the_Sales_Expert\",\n",
225
+ " # human_input_mode=\"NEVER\",\n",
226
+ " human_input_mode=\"TERMINATE\",\n",
227
+ " system_message=Sales_Expert,\n",
228
+ " llm_config=llm_config,\n",
229
+ ")\n",
230
+ "manager = autogen.AssistantAgent(\n",
231
+ " name=\"Michael_the_Manager\",\n",
232
+ " system_message=Manager,\n",
233
+ " # human_input_mode=\"TERMINATE\",\n",
234
+ " llm_config=llm_config,\n",
235
+ ")\n",
236
+ "groupchat = autogen.GroupChat(\n",
237
+ " agents=[marketing, sales, manager], messages=[], max_round=5\n",
238
+ ")\n",
239
+ "manager = autogen.GroupChatManager(groupchat=groupchat, llm_config=llm_config)"
240
+ ]
241
+ },
242
+ {
243
+ "cell_type": "code",
244
+ "execution_count": null,
245
+ "metadata": {},
246
+ "outputs": [],
247
+ "source": [
248
+ "sales.initiate_chat(\n",
249
+ " manager,\n",
250
+ " message=Business_Overview + email + meeting_opener,\n",
251
+ ")\n",
252
+ "# type exit to terminate the chat"
253
+ ]
254
+ },
255
+ {
256
+ "cell_type": "code",
257
+ "execution_count": null,
258
+ "metadata": {},
259
+ "outputs": [],
260
+ "source": []
261
+ }
262
+ ],
263
+ "metadata": {
264
+ "kernelspec": {
265
+ "display_name": "flaml",
266
+ "language": "python",
267
+ "name": "python3"
268
+ },
269
+ "language_info": {
270
+ "codemirror_mode": {
271
+ "name": "ipython",
272
+ "version": 3
273
+ },
274
+ "file_extension": ".py",
275
+ "mimetype": "text/x-python",
276
+ "name": "python",
277
+ "nbconvert_exporter": "python",
278
+ "pygments_lexer": "ipython3",
279
+ "version": "3.11.3"
280
+ },
281
+ "orig_nbformat": 4
282
+ },
283
+ "nbformat": 4,
284
+ "nbformat_minor": 2
285
+ }
src/backup/agentchat_groupchat_Custom_Group_Chat.ipynb ADDED
@@ -0,0 +1,532 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "attachments": {},
5
+ "cell_type": "markdown",
6
+ "metadata": {},
7
+ "source": [
8
+ "<a href=\"https://colab.research.google.com/github/microsoft/autogen/blob/main/notebook/agentchat_groupchat.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
9
+ ]
10
+ },
11
+ {
12
+ "attachments": {},
13
+ "cell_type": "markdown",
14
+ "metadata": {},
15
+ "source": [
16
+ "# Auto Generated Agent Chat: Group Chat\n",
17
+ "\n",
18
+ "AutoGen offers conversable agents powered by LLM, tool or human, which can be used to perform tasks collectively via automated chat. This framework allows tool use and human participation through multi-agent conversation.\n",
19
+ "Please find documentation about this feature [here](https://microsoft.github.io/autogen/docs/Use-Cases/agent_chat).\n",
20
+ "\n",
21
+ "This notebook is modified based on https://github.com/microsoft/FLAML/blob/4ea686af5c3e8ff24d9076a7a626c8b28ab5b1d7/notebook/autogen_multiagent_roleplay_chat.ipynb\n",
22
+ "\n",
23
+ "## Requirements\n",
24
+ "\n",
25
+ "AutoGen requires `Python>=3.8`. To run this notebook example, please install:\n",
26
+ "```bash\n",
27
+ "pip install pyautogen\n",
28
+ "```"
29
+ ]
30
+ },
31
+ {
32
+ "cell_type": "code",
33
+ "execution_count": 1,
34
+ "metadata": {},
35
+ "outputs": [],
36
+ "source": [
37
+ "%%capture --no-stderr\n",
38
+ "# %pip install pyautogen~=0.2.0b4"
39
+ ]
40
+ },
41
+ {
42
+ "attachments": {},
43
+ "cell_type": "markdown",
44
+ "metadata": {},
45
+ "source": [
46
+ "## Set your API Endpoint\n",
47
+ "\n",
48
+ "The [`config_list_from_json`](https://microsoft.github.io/autogen/docs/reference/oai/openai_utils#config_list_from_json) function loads a list of configurations from an environment variable or a json file."
49
+ ]
50
+ },
51
+ {
52
+ "cell_type": "code",
53
+ "execution_count": 2,
54
+ "metadata": {},
55
+ "outputs": [
56
+ {
57
+ "name": "stderr",
58
+ "output_type": "stream",
59
+ "text": [
60
+ "/home/panoevj/anaconda3/envs/automemgpt/lib/python3.11/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
61
+ " from .autonotebook import tqdm as notebook_tqdm\n"
62
+ ]
63
+ }
64
+ ],
65
+ "source": [
66
+ "import autogen\n",
67
+ "import os\n",
68
+ "\n",
69
+ "config_list_gpt4 = [\n",
70
+ " {\n",
71
+ " \"model\": \"gpt-4\",\n",
72
+ " \"api_key\": os.getenv(\"OPENAI_API_KEY\"),\n",
73
+ " # \"api_key\": str(os.environ[\"OPENAI_API_KEY\"]),\n",
74
+ " },\n",
75
+ " {\n",
76
+ " \"model\": \"gpt-4-32k\",\n",
77
+ " \"api_key\": os.getenv(\"OPENAI_API_KEY\"),\n",
78
+ " },\n",
79
+ "]\n",
80
+ "\n",
81
+ "\n",
82
+ "# config_list_gpt35 = autogen.config_list_from_json(\n",
83
+ "# \"OAI_CONFIG_LIST\",\n",
84
+ "# filter_dict={\n",
85
+ "# \"model\": {\n",
86
+ "# \"gpt-3.5-turbo\",\n",
87
+ "# \"gpt-3.5-turbo-16k\",\n",
88
+ "# \"gpt-3.5-turbo-0301\",\n",
89
+ "# \"chatgpt-35-turbo-0301\",\n",
90
+ "# \"gpt-35-turbo-v0301\",\n",
91
+ "# },\n",
92
+ "# },\n",
93
+ "# )"
94
+ ]
95
+ },
96
+ {
97
+ "cell_type": "markdown",
98
+ "metadata": {},
99
+ "source": [
100
+ "## Custom Group Chat"
101
+ ]
102
+ },
103
+ {
104
+ "cell_type": "code",
105
+ "execution_count": 3,
106
+ "metadata": {},
107
+ "outputs": [],
108
+ "source": [
109
+ "import random\n",
110
+ "from typing import List, Dict\n",
111
+ "from autogen.agentchat.groupchat import GroupChat\n",
112
+ "from autogen.agentchat.agent import Agent\n",
113
+ "from autogen.agentchat.assistant_agent import AssistantAgent\n",
114
+ "\n",
115
+ "\n",
116
+ "class CustomGroupChat(GroupChat):\n",
117
+ " def __init__(self, agents, messages, max_round=10):\n",
118
+ " super().__init__(agents, messages, max_round)\n",
119
+ " self.previous_speaker = None # Keep track of the previous speaker\n",
120
+ "\n",
121
+ " def select_speaker(self, last_speaker: Agent, selector: AssistantAgent):\n",
122
+ " # Check if last message suggests a next speaker or termination\n",
123
+ " last_message = self.messages[-1] if self.messages else None\n",
124
+ " if last_message:\n",
125
+ " if \"NEXT:\" in last_message[\"content\"]:\n",
126
+ " suggested_next = last_message[\"content\"].split(\"NEXT: \")[-1].strip()\n",
127
+ " print(f\"Extracted suggested_next = {suggested_next}\")\n",
128
+ " try:\n",
129
+ " return self.agent_by_name(suggested_next)\n",
130
+ " except ValueError:\n",
131
+ " pass # If agent name is not valid, continue with normal selection\n",
132
+ " elif \"TERMINATE\" in last_message[\"content\"]:\n",
133
+ " try:\n",
134
+ " return self.agent_by_name(\"User_proxy\")\n",
135
+ " except ValueError:\n",
136
+ " pass # If 'User_proxy' is not a valid name, continue with normal selection\n",
137
+ "\n",
138
+ " team_leader_names = [\n",
139
+ " agent.name for agent in self.agents if agent.name.endswith(\"1\")\n",
140
+ " ]\n",
141
+ "\n",
142
+ " if last_speaker.name in team_leader_names:\n",
143
+ " team_letter = last_speaker.name[0]\n",
144
+ " possible_next_speakers = [\n",
145
+ " agent\n",
146
+ " for agent in self.agents\n",
147
+ " if (\n",
148
+ " agent.name.startswith(team_letter)\n",
149
+ " or agent.name in team_leader_names\n",
150
+ " )\n",
151
+ " and agent != last_speaker\n",
152
+ " and agent != self.previous_speaker\n",
153
+ " ]\n",
154
+ " else:\n",
155
+ " team_letter = last_speaker.name[0]\n",
156
+ " possible_next_speakers = [\n",
157
+ " agent\n",
158
+ " for agent in self.agents\n",
159
+ " if agent.name.startswith(team_letter)\n",
160
+ " and agent != last_speaker\n",
161
+ " and agent != self.previous_speaker\n",
162
+ " ]\n",
163
+ "\n",
164
+ " self.previous_speaker = last_speaker\n",
165
+ "\n",
166
+ " if possible_next_speakers:\n",
167
+ " next_speaker = random.choice(possible_next_speakers)\n",
168
+ " return next_speaker\n",
169
+ " else:\n",
170
+ " return None"
171
+ ]
172
+ },
173
+ {
174
+ "cell_type": "code",
175
+ "execution_count": 4,
176
+ "metadata": {},
177
+ "outputs": [],
178
+ "source": [
179
+ "# Termination message detection\n",
180
+ "def is_termination_msg(content) -> bool:\n",
181
+ " have_content = content.get(\"content\", None) is not None\n",
182
+ " if have_content and \"TERMINATE\" in content[\"content\"]:\n",
183
+ " return True\n",
184
+ " return False"
185
+ ]
186
+ },
187
+ {
188
+ "attachments": {},
189
+ "cell_type": "markdown",
190
+ "metadata": {},
191
+ "source": [
192
+ "## Construct Agents"
193
+ ]
194
+ },
195
+ {
196
+ "cell_type": "code",
197
+ "execution_count": 5,
198
+ "metadata": {},
199
+ "outputs": [],
200
+ "source": [
201
+ "llm_config = {\"config_list\": config_list_gpt4}"
202
+ ]
203
+ },
204
+ {
205
+ "cell_type": "code",
206
+ "execution_count": 6,
207
+ "metadata": {},
208
+ "outputs": [],
209
+ "source": [
210
+ "agents_sales = [\n",
211
+ " AssistantAgent(\n",
212
+ " name=\"Sales1\",\n",
213
+ " system_message=\"You are the team leader of the sales team, your team consists of Sales2 and Sales3. You can talk to the other team leaders: Marketing1, CustomerSupport1, ProductDevelopment1. Use 'NEXT: <agent_name>' to suggest the next speaker.\",\n",
214
+ " llm_config=llm_config,\n",
215
+ " ),\n",
216
+ " AssistantAgent(\n",
217
+ " name=\"Sales2\",\n",
218
+ " system_message=\"You are team member Sales2, you are responsible for communication with ClientA.\",\n",
219
+ " llm_config=llm_config,\n",
220
+ " ),\n",
221
+ " AssistantAgent(\n",
222
+ " name=\"Sales3\",\n",
223
+ " system_message=\"You are team member Sales3, you are responsible for communication with ClientB.\",\n",
224
+ " llm_config=llm_config,\n",
225
+ " ),\n",
226
+ "]\n",
227
+ "\n",
228
+ "agents_marketing = [\n",
229
+ " AssistantAgent(\n",
230
+ " name=\"Marketing1\",\n",
231
+ " system_message=\"You are the team leader of the marketing team, your team consists of Marketing2 and Marketing3. You can talk to the other team leaders: Sales1, CustomerSupport1, ProductDevelopment1. Use 'NEXT: <agent_name>' to suggest the next speaker.\",\n",
232
+ " llm_config=llm_config,\n",
233
+ " ),\n",
234
+ " AssistantAgent(\n",
235
+ " name=\"Marketing2\",\n",
236
+ " system_message=\"You are team member Marketing2, you are responsible for generating non-digital marketing material.\",\n",
237
+ " llm_config=llm_config,\n",
238
+ " ),\n",
239
+ " AssistantAgent(\n",
240
+ " name=\"Marketing3\",\n",
241
+ " system_message=\"You are team member Marketing3, you are responsible for digital marketing.\",\n",
242
+ " llm_config=llm_config,\n",
243
+ " ),\n",
244
+ "]\n",
245
+ "\n",
246
+ "agents_product_development = [\n",
247
+ " AssistantAgent(\n",
248
+ " name=\"ProductDevelopment1\",\n",
249
+ " system_message=\"You are the team leader of the product development team, your team consists of ProductDevelopment2 and ProductDevelopment3. You can talk to the other team leaders: Sales1, CustomerSupport1, ProductDevelopment1. Use 'NEXT: <agent_name>' to suggest the next speaker.\",\n",
250
+ " llm_config=llm_config,\n",
251
+ " ),\n",
252
+ " AssistantAgent(\n",
253
+ " name=\"ProductDevelopment2\",\n",
254
+ " system_message=\"You are team member ProductDevelopment2, you are responsible for the development of the product.\",\n",
255
+ " llm_config=llm_config,\n",
256
+ " ),\n",
257
+ " AssistantAgent(\n",
258
+ " name=\"ProductDevelopment3\",\n",
259
+ " system_message=\"You are team member ProductDevelopment3, you are responsible for quality assurance.\",\n",
260
+ " llm_config=llm_config,\n",
261
+ " ),\n",
262
+ "]\n",
263
+ "\n",
264
+ "agents_customer_support = [\n",
265
+ " AssistantAgent(\n",
266
+ " name=\"CustomerSupport1\",\n",
267
+ " system_message=\"You are the team leader of the customer support team, your team consists of CustomerSupport2 and CustomerSupport3. You can talk to the other team leaders: Sales1, Marketing1, ProductDevelopment1. Use 'NEXT: <agent_name>' to suggest the next speaker.\",\n",
268
+ " llm_config=llm_config,\n",
269
+ " ),\n",
270
+ " AssistantAgent(\n",
271
+ " name=\"CustomerSupport2\",\n",
272
+ " system_message=\"You are team member of the customer support team, you are responsible for customer support for ClientA.\",\n",
273
+ " llm_config=llm_config,\n",
274
+ " ),\n",
275
+ " AssistantAgent(\n",
276
+ " name=\"CustomerSupport3\",\n",
277
+ " system_message=\"You are team member of the customer support team, you are responsible for customer support for ClientB.\",\n",
278
+ " llm_config=llm_config,\n",
279
+ " ),\n",
280
+ "]\n",
281
+ "\n",
282
+ "\n",
283
+ "agents_managers = [\n",
284
+ " AssistantAgent(\n",
285
+ " name=\"Manager1\",\n",
286
+ " system_message=\"You are the manager of the company, responsible of managing and coordinating the activities of all teams and departments within the company. You can talk to all team leaders: Sales1, Marketing1, CustomerSupport1, ProductDevelopment1. Use 'NEXT: <agent_name>' to suggest the next speaker.\",\n",
287
+ " llm_config=llm_config,\n",
288
+ " ),\n",
289
+ "]"
290
+ ]
291
+ },
292
+ {
293
+ "cell_type": "code",
294
+ "execution_count": 7,
295
+ "metadata": {},
296
+ "outputs": [],
297
+ "source": [
298
+ "# Terminates the conversation when TERMINATE is detected.\n",
299
+ "user_proxy = autogen.UserProxyAgent(\n",
300
+ " name=\"User_proxy\",\n",
301
+ " system_message=\"Terminator admin.\",\n",
302
+ " code_execution_config=False,\n",
303
+ " is_termination_msg=is_termination_msg,\n",
304
+ " human_input_mode=\"NEVER\",\n",
305
+ ")"
306
+ ]
307
+ },
308
+ {
309
+ "cell_type": "code",
310
+ "execution_count": 8,
311
+ "metadata": {},
312
+ "outputs": [],
313
+ "source": [
314
+ "list_of_agents = (\n",
315
+ " agents_sales + agents_marketing + agents_product_development + agents_managers\n",
316
+ ")\n",
317
+ "list_of_agents.append(user_proxy)"
318
+ ]
319
+ },
320
+ {
321
+ "cell_type": "markdown",
322
+ "metadata": {},
323
+ "source": [
324
+ "## Start GroupChat"
325
+ ]
326
+ },
327
+ {
328
+ "cell_type": "code",
329
+ "execution_count": 9,
330
+ "metadata": {},
331
+ "outputs": [],
332
+ "source": [
333
+ "# Create CustomGroupChat\n",
334
+ "group_chat = CustomGroupChat(\n",
335
+ " agents=list_of_agents, # Include all agents\n",
336
+ " messages=[\n",
337
+ " 'Everyone cooperate and and solve the various incoming tasks and client requests. Team Sales has Sales1, Sales2, Sales3. Team Marketing has Marketing1, Marketing2, Marketing3. Team ProductDevelopment has ProductDevelopment1, ProductDevelopment2, ProductDevelopment3. Team CustomerSupport has CustomerSupport1, CustomerSupport2, CustomerSupport3. Team Managers has Manager1. Only members of the same team can talk to one another. Only team leaders (names ending with 1) can talk amongst themselves. You must use \"NEXT: Sales1\" to suggest talking to Sales1 for example; You can suggest only one person, you cannot suggest yourself or the previous speaker; You can also not suggest anyone.'\n",
338
+ " ],\n",
339
+ " max_round=20,\n",
340
+ ")"
341
+ ]
342
+ },
343
+ {
344
+ "cell_type": "code",
345
+ "execution_count": 10,
346
+ "metadata": {},
347
+ "outputs": [],
348
+ "source": [
349
+ "# Create the manager\n",
350
+ "manager = autogen.GroupChatManager(groupchat=group_chat, llm_config=llm_config)"
351
+ ]
352
+ },
353
+ {
354
+ "cell_type": "code",
355
+ "execution_count": 11,
356
+ "metadata": {},
357
+ "outputs": [
358
+ {
359
+ "name": "stdout",
360
+ "output_type": "stream",
361
+ "text": [
362
+ "\u001b[33mManager1\u001b[0m (to chat_manager):\n",
363
+ "\n",
364
+ "ClientA, who recently purchased an e-bike from our company, has reported that after only a few weeks of regular use, the e-bike's battery began to malfunction. Please investigate and resolve the issue.\n",
365
+ "\n",
366
+ "--------------------------------------------------------------------------------\n",
367
+ "\u001b[33mMarketing2\u001b[0m (to chat_manager):\n",
368
+ "\n",
369
+ "As Marketing2, I handle non-digital marketing materials such as brochures, flyers, and print ads. The issue you've described involves customer service and technical assistance. A team member from Customer Support or Technical Service team is better suited to handle this kind of problem. However, I'll pass this information to the relevant department.\n",
370
+ "\n",
371
+ "--------------------------------------------------------------------------------\n",
372
+ "\u001b[33mMarketing1\u001b[0m (to chat_manager):\n",
373
+ "\n",
374
+ "NEXT: CustomerSupport1\n",
375
+ "\n",
376
+ "--------------------------------------------------------------------------------\n",
377
+ "Extracted suggested_next = CustomerSupport1\n",
378
+ "\u001b[33mProductDevelopment1\u001b[0m (to chat_manager):\n",
379
+ "\n",
380
+ "Hi CustomerSupport1, could you please provide an update on the situation with ClientA's e-bike battery malfunction? Was this issue reported in our support system?\n",
381
+ "\n",
382
+ "--------------------------------------------------------------------------------\n",
383
+ "\u001b[33mProductDevelopment2\u001b[0m (to chat_manager):\n",
384
+ "\n",
385
+ "As ProductDevelopment2, I don't directly interact with clients or our support system. However, I can certainly look into the issue from the product's side and provide technological solutions. I'll begin by investigating similar cases in the history of our e-bikes, checking if there are any known issues or recalls on this batch of e-bike batteries, and inspecting the maintenance and charging instructions provided to the customer. This will provide a clearer understanding of why the battery began to malfunction after a few weeks, and what can be done to rectify the situation.\n",
386
+ "\n",
387
+ "--------------------------------------------------------------------------------\n",
388
+ "\u001b[33mProductDevelopment3\u001b[0m (to chat_manager):\n",
389
+ "\n",
390
+ "As ProductDevelopment3, I can assist by ensuring that the quality checks are carried out meticulously. Once we get the bike, I'll examine the circumstances under which the battery started to malfunction. I'll check the battery's quality control records to understand if there was any anomaly during our in-house testing. If there's a single instance of malfunction, it could be a one-off problem. However, if multiple customers are facing the same problem, it could suggest a batch flaw or even a broader product design issue. I'll keep everyone posted.\n",
391
+ "\n",
392
+ "--------------------------------------------------------------------------------\n",
393
+ "\u001b[33mProductDevelopment1\u001b[0m (to chat_manager):\n",
394
+ "\n",
395
+ "NEXT: ProductDevelopment1\n",
396
+ "\n",
397
+ "--------------------------------------------------------------------------------\n",
398
+ "Extracted suggested_next = ProductDevelopment1\n",
399
+ "\u001b[33mProductDevelopment1\u001b[0m (to chat_manager):\n",
400
+ "\n",
401
+ "As the team leader of Product Development, I need your insights on this issue. What are the potential causes that could lead to the malfunctioning of the e-bike's battery?\n",
402
+ "\n",
403
+ "--------------------------------------------------------------------------------\n",
404
+ "\u001b[33mManager1\u001b[0m (to chat_manager):\n",
405
+ "\n",
406
+ "Apologies for the confusion. As an Artificial Intelligent agent, my functionality is limited to assisting with tasks and I don't have the capability to actually run this meeting or physically examine the product. Please continue your conversation about the battery malfunction with ProductDevelopment1.\n",
407
+ "\n",
408
+ "--------------------------------------------------------------------------------\n",
409
+ "\u001b[33mMarketing1\u001b[0m (to chat_manager):\n",
410
+ "\n",
411
+ "NEXT: ProductDevelopment1\n",
412
+ "\n",
413
+ "--------------------------------------------------------------------------------\n",
414
+ "Extracted suggested_next = ProductDevelopment1\n",
415
+ "\u001b[33mProductDevelopment1\u001b[0m (to chat_manager):\n",
416
+ "\n",
417
+ "As ProductDevelopment1, I'd suggest we begin a thorough analysis of the battery failure issue reported by ClientA. This should include a technical investigation into possible causes of the malfunction, as well as a review of any similar incidents in our logs. Once we have more detailed information, we'll be better able to come up with a viable solution. I'll get our team started on this straightaway.\n",
418
+ "\n",
419
+ "--------------------------------------------------------------------------------\n",
420
+ "\u001b[33mProductDevelopment3\u001b[0m (to chat_manager):\n",
421
+ "\n",
422
+ "As ProductDevelopment3, I support ProductDevelopment1's suggestion that we perform a thorough analysis of the situation. To summarize our steps:\n",
423
+ "\n",
424
+ "1. Investigate similar issues in the past to identify any patterns or repeated occurrences of battery malfunction.\n",
425
+ "2. Examine the specific battery from ClientA's e-bike, if possible. This could involve arranging a return from the client or requesting detailed photos or descriptions of the issue.\n",
426
+ "3. Review the quality control records for the batch that this battery came from.\n",
427
+ "4. If the problem looks to be wider spread, consider an inspection of other batteries from the same batch.\n",
428
+ "5. While investigating, we should also review our instructions provided to the users to ensure that any guidance about battery maintenance and charging are clear and accurate.\n",
429
+ "\n",
430
+ "Let's start right away so we can resolve the issue promptly and assure our clients about the quality and reliability of our e-bikes.\n",
431
+ "\n",
432
+ "--------------------------------------------------------------------------------\n",
433
+ "\u001b[33mProductDevelopment2\u001b[0m (to chat_manager):\n",
434
+ "\n",
435
+ "As ProductDevelopment2, I fully agree with the proposed steps. In addition, I can ensure that in the future any similar issues are promptly addressed by incorporating a more comprehensive battery health inspection in our regular quality checks. We should also consider bringing this up in our next meeting to discuss possible improvements in our technical documentation, both in terms of battery maintenance and general use of the e-bike. The end goal should always be to minimize any inconvenience for the customers, enhancing their experience and satisfaction with our products.\n",
436
+ "\n",
437
+ "\n",
438
+ "--------------------------------------------------------------------------------\n",
439
+ "\u001b[33mProductDevelopment1\u001b[0m (to chat_manager):\n",
440
+ "\n",
441
+ "NEXT: Sales1\n",
442
+ "\n",
443
+ "--------------------------------------------------------------------------------\n",
444
+ "Extracted suggested_next = Sales1\n",
445
+ "\u001b[33mSales1\u001b[0m (to chat_manager):\n",
446
+ "\n",
447
+ "Apologies for the confusion. As an Artificial Intelligent assistant, I only follow the roles determined at the beginning of the interactions. There is no Sales1 introduced at the start, therefore I can't assign the next turn to them. The turn can be assigned to the sales team members Sales2 or Sales3, or to the other team leaders Marketing1, CustomerSupport1, or ProductDevelopment1. Please choose one. \n",
448
+ "\n",
449
+ "--------------------------------------------------------------------------------\n",
450
+ "\u001b[33mSales2\u001b[0m (to chat_manager):\n",
451
+ "\n",
452
+ "NEXT: Sales2\n",
453
+ "\n",
454
+ "--------------------------------------------------------------------------------\n",
455
+ "Extracted suggested_next = Sales2\n",
456
+ "\u001b[33mSales2\u001b[0m (to chat_manager):\n",
457
+ "\n",
458
+ "Dear ClientA,\n",
459
+ "\n",
460
+ "I'm Sales2 from the team you've bought your e-bike from. I have been made aware of the issue you are experiencing with your e-bike's battery. I apologize for any inconvenience this might have caused. Our product development team is investigating, and we assure you that we are prioritizing resolution of this issue.\n",
461
+ "\n",
462
+ "We will keep you updated on our progress. In the meantime, if you need any further assistance, feel free to reach out to me. Thank you for your patience and understanding.\n",
463
+ "\n",
464
+ "Best,\n",
465
+ "Sales2\n",
466
+ "\n",
467
+ "--------------------------------------------------------------------------------\n",
468
+ "\u001b[33mSales3\u001b[0m (to chat_manager):\n",
469
+ "\n",
470
+ "NEXT: CustomerSupport1\n",
471
+ "\n",
472
+ "--------------------------------------------------------------------------------\n",
473
+ "Extracted suggested_next = CustomerSupport1\n",
474
+ "\u001b[33mSales1\u001b[0m (to chat_manager):\n",
475
+ "\n",
476
+ "As a Customer Support representative, my priority would be to ensure that ClientA feels supported during this process of resolving the issue with their e-bike's battery.\n",
477
+ "\n",
478
+ "I would suggest we send them a replacement battery immediately if we have any spare or substitute models available. We could also potentially offer them a rental e-bike while their current one is being repaired. Moreover, we should ensure they know they can reach out to us if they have any features or concerns they need assistance with while we're investigating this issue.\n",
479
+ "\n",
480
+ "Let's do all we can to turn their current inconvenience into an experience of great customer service. \n",
481
+ "\n",
482
+ "NEXT: CustomerSupport1\n",
483
+ "\n",
484
+ "--------------------------------------------------------------------------------\n",
485
+ "Extracted suggested_next = CustomerSupport1\n",
486
+ "\u001b[33mSales2\u001b[0m (to chat_manager):\n",
487
+ "\n",
488
+ "Apologies for the confusion. As an Artificial Intelligent assistant, I only follow the roles determined at the beginning of the interactions. There is no CustomerSupport1 introduced at the start, so I can't assign the next turn to them. The turn can be assigned to me, Sales2, and the team leaders: Marketing1, ProductDevelopment1. Please choose one.\n",
489
+ "\n",
490
+ "--------------------------------------------------------------------------------\n"
491
+ ]
492
+ }
493
+ ],
494
+ "source": [
495
+ "# Initiates the chat with the manager\n",
496
+ "agents_managers[0].initiate_chat(\n",
497
+ " manager,\n",
498
+ " message=\"ClientA, who recently purchased an e-bike from our company, has reported that after only a few weeks of regular use, the e-bike's battery began to malfunction. Please investigate and resolve the issue.\",\n",
499
+ ")"
500
+ ]
501
+ },
502
+ {
503
+ "cell_type": "code",
504
+ "execution_count": null,
505
+ "metadata": {},
506
+ "outputs": [],
507
+ "source": []
508
+ }
509
+ ],
510
+ "metadata": {
511
+ "kernelspec": {
512
+ "display_name": "flaml",
513
+ "language": "python",
514
+ "name": "python3"
515
+ },
516
+ "language_info": {
517
+ "codemirror_mode": {
518
+ "name": "ipython",
519
+ "version": 3
520
+ },
521
+ "file_extension": ".py",
522
+ "mimetype": "text/x-python",
523
+ "name": "python",
524
+ "nbconvert_exporter": "python",
525
+ "pygments_lexer": "ipython3",
526
+ "version": "3.11.3"
527
+ },
528
+ "orig_nbformat": 4
529
+ },
530
+ "nbformat": 4,
531
+ "nbformat_minor": 2
532
+ }
src/backup/agentchat_groupchat_memgpt.ipynb ADDED
@@ -0,0 +1,491 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "attachments": {},
5
+ "cell_type": "markdown",
6
+ "metadata": {},
7
+ "source": [
8
+ "<a href=\"https://colab.research.google.com/github/microsoft/autogen/blob/main/notebook/agentchat_groupchat.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
9
+ ]
10
+ },
11
+ {
12
+ "attachments": {},
13
+ "cell_type": "markdown",
14
+ "metadata": {},
15
+ "source": [
16
+ "# Auto Generated Agent Chat: Group Chat\n",
17
+ "\n",
18
+ "AutoGen offers conversable agents powered by LLM, tool or human, which can be used to perform tasks collectively via automated chat. This framework allows tool use and human participation through multi-agent conversation.\n",
19
+ "Please find documentation about this feature [here](https://microsoft.github.io/autogen/docs/Use-Cases/agent_chat).\n",
20
+ "\n",
21
+ "This notebook is modified based on https://github.com/microsoft/FLAML/blob/4ea686af5c3e8ff24d9076a7a626c8b28ab5b1d7/notebook/autogen_multiagent_roleplay_chat.ipynb\n",
22
+ "\n",
23
+ "## Requirements\n",
24
+ "\n",
25
+ "AutoGen requires `Python>=3.8`. To run this notebook example, please install:\n",
26
+ "```bash\n",
27
+ "pip install pyautogen\n",
28
+ "```"
29
+ ]
30
+ },
31
+ {
32
+ "cell_type": "code",
33
+ "execution_count": 1,
34
+ "metadata": {},
35
+ "outputs": [],
36
+ "source": [
37
+ "%%capture --no-stderr\n",
38
+ "# %pip install pyautogen~=0.2.0b4"
39
+ ]
40
+ },
41
+ {
42
+ "attachments": {},
43
+ "cell_type": "markdown",
44
+ "metadata": {},
45
+ "source": [
46
+ "## Set your API Endpoint\n",
47
+ "\n",
48
+ "The [`config_list_from_json`](https://microsoft.github.io/autogen/docs/reference/oai/openai_utils#config_list_from_json) function loads a list of configurations from an environment variable or a json file."
49
+ ]
50
+ },
51
+ {
52
+ "cell_type": "code",
53
+ "execution_count": 2,
54
+ "metadata": {},
55
+ "outputs": [
56
+ {
57
+ "name": "stderr",
58
+ "output_type": "stream",
59
+ "text": [
60
+ "/home/panoevj/anaconda3/envs/automemgpt/lib/python3.11/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
61
+ " from .autonotebook import tqdm as notebook_tqdm\n"
62
+ ]
63
+ }
64
+ ],
65
+ "source": [
66
+ "import autogen\n",
67
+ "import os\n",
68
+ "\n",
69
+ "# config_list_gpt4 = autogen.config_list_from_json(\n",
70
+ "# \"OAI_CONFIG_LIST\",\n",
71
+ "# filter_dict={\n",
72
+ "# \"model\": [\"gpt-4\", \"gpt-4-0314\", \"gpt4\", \"gpt-4-32k\", \"gpt-4-32k-0314\", \"gpt-4-32k-v0314\"],\n",
73
+ "# },\n",
74
+ "# )\n",
75
+ "\n",
76
+ "config_list_gpt4 = [\n",
77
+ " {\n",
78
+ " \"model\": \"gpt-4\",\n",
79
+ " \"api_key\": os.getenv(\"OPENAI_API_KEY\"),\n",
80
+ " # \"api_key\": str(os.environ[\"OPENAI_API_KEY\"]),\n",
81
+ " },\n",
82
+ " {\n",
83
+ " \"model\": \"gpt-4-32k\",\n",
84
+ " \"api_key\": os.getenv(\"OPENAI_API_KEY\"),\n",
85
+ " },\n",
86
+ "]\n",
87
+ "\n",
88
+ "\n",
89
+ "# config_list_gpt35 = autogen.config_list_from_json(\n",
90
+ "# \"OAI_CONFIG_LIST\",\n",
91
+ "# filter_dict={\n",
92
+ "# \"model\": {\n",
93
+ "# \"gpt-3.5-turbo\",\n",
94
+ "# \"gpt-3.5-turbo-16k\",\n",
95
+ "# \"gpt-3.5-turbo-0301\",\n",
96
+ "# \"chatgpt-35-turbo-0301\",\n",
97
+ "# \"gpt-35-turbo-v0301\",\n",
98
+ "# },\n",
99
+ "# },\n",
100
+ "# )"
101
+ ]
102
+ },
103
+ {
104
+ "attachments": {},
105
+ "cell_type": "markdown",
106
+ "metadata": {},
107
+ "source": [
108
+ "It first looks for environment variable \"OAI_CONFIG_LIST\" which needs to be a valid json string. If that variable is not found, it then looks for a json file named \"OAI_CONFIG_LIST\". It filters the configs by models (you can filter by other keys as well). Only the gpt-4 models are kept in the list based on the filter condition.\n",
109
+ "\n",
110
+ "The config list looks like the following:\n",
111
+ "```python\n",
112
+ "config_list = [\n",
113
+ " {\n",
114
+ " 'model': 'gpt-4',\n",
115
+ " 'api_key': '<your OpenAI API key here>',\n",
116
+ " },\n",
117
+ " {\n",
118
+ " 'model': 'gpt-4',\n",
119
+ " 'api_key': '<your Azure OpenAI API key here>',\n",
120
+ " 'base_url': '<your Azure OpenAI API base here>',\n",
121
+ " 'api_type': 'azure',\n",
122
+ " 'api_version': '2023-06-01-preview',\n",
123
+ " },\n",
124
+ " {\n",
125
+ " 'model': 'gpt-4-32k',\n",
126
+ " 'api_key': '<your Azure OpenAI API key here>',\n",
127
+ " 'base_url': '<your Azure OpenAI API base here>',\n",
128
+ " 'api_type': 'azure',\n",
129
+ " 'api_version': '2023-06-01-preview',\n",
130
+ " },\n",
131
+ "]\n",
132
+ "```\n",
133
+ "\n",
134
+ "You can set the value of config_list in any way you prefer. Please refer to this [notebook](https://github.com/microsoft/autogen/blob/main/notebook/oai_openai_utils.ipynb) for full code examples of the different methods."
135
+ ]
136
+ },
137
+ {
138
+ "attachments": {},
139
+ "cell_type": "markdown",
140
+ "metadata": {},
141
+ "source": [
142
+ "## Construct Agents"
143
+ ]
144
+ },
145
+ {
146
+ "attachments": {},
147
+ "cell_type": "markdown",
148
+ "metadata": {},
149
+ "source": [
150
+ "## Start Chat"
151
+ ]
152
+ },
153
+ {
154
+ "cell_type": "code",
155
+ "execution_count": 3,
156
+ "metadata": {},
157
+ "outputs": [],
158
+ "source": [
159
+ "Marketing_Expert = \"\"\"\n",
160
+ "Name: Alex the Marketing Expert\n",
161
+ "Age: 32\n",
162
+ "Background: Holds a Master's degree in Marketing and has a passion for cycling. Alex has previously worked with several sports brands and has a deep understanding of the biking community.\n",
163
+ "Personality Traits: Creative, data-driven, and trend-savvy. Excels in digital marketing strategies.\n",
164
+ "Goals: To increase brand visibility and engage more with the biking community through innovative marketing campaigns.\n",
165
+ "Challenges: Keeping up with rapidly changing marketing trends and consumer preferences.\n",
166
+ "Digital Marketing: Expert in SEO, social media advertising, and email marketing campaigns specifically tailored for the sports industry.\n",
167
+ "Brand Development: Skilled in developing and maintaining a strong brand identity that resonates with the biking community.\n",
168
+ "Market Research: Proficient in conducting market analysis to identify new trends and customer needs in the biking market.\n",
169
+ "Content Creation: Talented in creating engaging content (blogs, videos, social media posts) to drive brand awareness and customer engagement.\n",
170
+ "\"\"\"\n",
171
+ "Sales_Expert = \"\"\"\n",
172
+ "Name: Emma the Sales Expert\n",
173
+ "Age: 28\n",
174
+ "Background: Emma has a Bachelor's degree in Business Administration and has been working in sales for 5 years, specializing in sports equipment. She's known for her exceptional customer service skills and product knowledge.\n",
175
+ "Personality Traits: Outgoing, persuasive, and empathetic. Great at building relationships and understanding customer needs.\n",
176
+ "Goals: To consistently exceed sales targets and develop strong, long-lasting relationships with key clients.\n",
177
+ "Customer Relationship Management: Excel at building and maintaining strong relationships with clients, ensuring long-term customer loyalty.\n",
178
+ "Product Knowledge: In-depth understanding of biking products and the ability to articulate product benefits effectively to customers.\n",
179
+ "Sales Strategy: Proficient in developing and implementing effective sales strategies to target various customer segments in the biking market.\n",
180
+ "Negotiation Skills: Strong negotiation skills to close deals and secure new business opportunities.\n",
181
+ "\"\"\"\n",
182
+ "Manager = \"\"\"\n",
183
+ "Name: Michael the Manager\n",
184
+ "Age: 40\n",
185
+ "Background: With an MBA and over 15 years of experience in management roles, Michael has a solid track record in leading teams and driving company growth. He's particularly adept at strategic planning and operations management.\n",
186
+ "Personality Traits: Leadership-oriented, analytical, and decisive. Excellent at problem-solving and team management.\n",
187
+ "Goals: To streamline operations for efficiency, foster a positive work culture, and drive the company towards its strategic goals.\n",
188
+ "Strategic Planning: Excellent at setting strategic goals for the company and developing plans to achieve these goals.\n",
189
+ "Team Management: Skilled in managing diverse teams, fostering a collaborative and productive work environment.\n",
190
+ "Financial Acumen: Strong understanding of budgeting, financial planning, and resource allocation to maximize efficiency and profitability.\n",
191
+ "Operational Oversight: Proficient in overseeing daily operations, ensuring processes are streamlined and goals are met.\n",
192
+ "\"\"\"\n",
193
+ "Business_Overview = \"\"\"\n",
194
+ "The market for sports articles for bikers is dynamic and multifaceted, catering to a wide range of customers from casual riders to professional athletes. It encompasses various segments including road biking, mountain biking, BMX, and leisure biking. The demand is driven by a growing interest in outdoor activities, fitness, and eco-friendly modes of transportation.\n",
195
+ "Key Segments:\n",
196
+ "Road Biking: This segment includes high-performance bikes and gear for speed and endurance, appealing to serious athletes and fitness enthusiasts. The market is dominated by a few major brands such as Trek, Cannondale, and Specialized.\n",
197
+ "Internal Weakness: Limited Online Presence and Digital Marketing Expertise.\n",
198
+ "Your company currently has a minimal online presence, with a basic website and limited activity on social media platforms. The in-house team lacks expertise in digital marketing, SEO, and e-commerce strategies. This deficiency results in reduced online visibility and a lack of engagement with potential customers, especially those who predominantly shop and seek information online.\n",
199
+ "Market Opportunity: Growing Demand for E-Bikes.\n",
200
+ "\"\"\"\n",
201
+ "email = \"\"\"\n",
202
+ "Subject: Strategy Meeting Invitation: Capitalizing on E-Bike Market Opportunity\n",
203
+ "\n",
204
+ "Body:\n",
205
+ "\n",
206
+ "Dear Alex, Emma, and Michael,\n",
207
+ "\n",
208
+ "I hope this email finds you well. As we navigate through an increasingly competitive market, it is essential that we continually align our strategies with emerging opportunities and internal capabilities. To this end, I would like to invite you to a strategic meeting to discuss a significant opportunity in the e-bike market and address our current internal challenges that are im\n",
209
+ "\"\"\"\n",
210
+ "meeting_opener = \"\"\"\n",
211
+ "\"Good morning everyone,\n",
212
+ "\n",
213
+ "Thank you for joining this crucial meeting today. I'm excited to discuss an opportunity that has the potential to significantly impact our market positioning and overall growth.\n",
214
+ "\n",
215
+ "Firstly, let's talk about the opportunity at hand. We're witnessing a substantial shift in consumer preferences towards e-bikes, especially among urban commuters. This trend isn't just a fleeting one; it's driven by increasing environmental awareness, the need for efficient commuting options, an aging population, and a growing interest in fitness. In fact, the global e-bike market is expected to grow at a CAGR of 9.01% from 2021 to 2028, reaching a value of $38.6 billion by 2028.\n",
216
+ "\"\"\""
217
+ ]
218
+ },
219
+ {
220
+ "cell_type": "code",
221
+ "execution_count": 4,
222
+ "metadata": {},
223
+ "outputs": [],
224
+ "source": [
225
+ "llm_config = {\"config_list\": config_list_gpt4}\n",
226
+ "marketing = autogen.AssistantAgent(\n",
227
+ " name=\"Alex_the_Marketing_Expert\",\n",
228
+ " system_message=Marketing_Expert,\n",
229
+ " # human_input_mode=\"TERMINATE\",\n",
230
+ " llm_config=llm_config,\n",
231
+ ")\n",
232
+ "# sales = autogen.UserProxyAgent(\n",
233
+ "# name=\"Emma_the_Sales_Expert\",\n",
234
+ "# # human_input_mode=\"NEVER\",\n",
235
+ "# human_input_mode=\"TERMINATE\",\n",
236
+ "# system_message=Sales_Expert,\n",
237
+ "# llm_config=llm_config,\n",
238
+ "# )\n",
239
+ "# manager = autogen.AssistantAgent(\n",
240
+ "# name=\"Michael_the_Manager\",\n",
241
+ "# system_message=Manager,\n",
242
+ "# # human_input_mode=\"TERMINATE\",\n",
243
+ "# llm_config=llm_config,\n",
244
+ "# )"
245
+ ]
246
+ },
247
+ {
248
+ "cell_type": "code",
249
+ "execution_count": 6,
250
+ "metadata": {},
251
+ "outputs": [
252
+ {
253
+ "name": "stdout",
254
+ "output_type": "stream",
255
+ "text": [
256
+ "LLM is explicitly disabled. Using MockLLM.\n"
257
+ ]
258
+ }
259
+ ],
260
+ "source": [
261
+ "from memgpt.autogen.memgpt_agent import (\n",
262
+ " create_autogen_memgpt_agent,\n",
263
+ " create_memgpt_autogen_agent_from_config,\n",
264
+ ")\n",
265
+ "from memgpt.presets.presets import DEFAULT_PRESET\n",
266
+ "\n",
267
+ "DEBUG = False\n",
268
+ "\n",
269
+ "interface_kwargs = {\n",
270
+ " \"debug\": DEBUG,\n",
271
+ " \"show_inner_thoughts\": DEBUG,\n",
272
+ " \"show_function_outputs\": DEBUG,\n",
273
+ "}\n",
274
+ "\n",
275
+ "config_list_memgpt = [\n",
276
+ " {\n",
277
+ " # \"model\": \"gpt-4-1106-preview\", # gpt-4-turbo (https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo)\n",
278
+ " \"model\": \"gpt-4\", # gpt-4-turbo (https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo)\n",
279
+ " \"preset\": DEFAULT_PRESET,\n",
280
+ " \"model_wrapper\": None,\n",
281
+ " \"api_type\": \"open_ai\",\n",
282
+ " \"api_key\": os.getenv(\"OPENAI_API_KEY\"),\n",
283
+ " \"model_endpoint_type\": \"openai\",\n",
284
+ " \"model_endpoint\": \"https://api.openai.com/v1\",\n",
285
+ " \"context_window\": 32000,\n",
286
+ " },\n",
287
+ "]\n",
288
+ "\n",
289
+ "llm_config_memgpt = {\"config_list\": config_list_memgpt}\n",
290
+ "\n",
291
+ "sales = create_memgpt_autogen_agent_from_config(\n",
292
+ " \"Emma_the_Sales_Expert\",\n",
293
+ " llm_config=llm_config_memgpt,\n",
294
+ " nonmemgpt_llm_config=llm_config,\n",
295
+ " system_message=Sales_Expert,\n",
296
+ " # default_auto_reply='auto-replying ******************************** Emma',\n",
297
+ " max_consecutive_auto_reply=1,\n",
298
+ " interface_kwargs=interface_kwargs,\n",
299
+ " human_input_mode=\"ALWAYS\", # Set a default auto-reply message here (non-empty auto-reply is required for LM Studio)\n",
300
+ ")\n",
301
+ "manager = create_memgpt_autogen_agent_from_config(\n",
302
+ " \"Michael_the_Manager\",\n",
303
+ " llm_config=llm_config_memgpt,\n",
304
+ " nonmemgpt_llm_config=llm_config,\n",
305
+ " system_message=Manager,\n",
306
+ " # default_auto_reply='auto-replying ******************************** Michael',\n",
307
+ " max_consecutive_auto_reply=1,\n",
308
+ " interface_kwargs=interface_kwargs,\n",
309
+ " human_input_mode=\"ALWAYS\", # Set a default auto-reply message here (non-empty auto-reply is required for LM Studio)\n",
310
+ ")"
311
+ ]
312
+ },
313
+ {
314
+ "cell_type": "code",
315
+ "execution_count": 7,
316
+ "metadata": {},
317
+ "outputs": [],
318
+ "source": [
319
+ "groupchat = autogen.GroupChat(\n",
320
+ " agents=[marketing, sales, manager], messages=[], max_round=10\n",
321
+ ")\n",
322
+ "manager = autogen.GroupChatManager(groupchat=groupchat, llm_config=llm_config)"
323
+ ]
324
+ },
325
+ {
326
+ "cell_type": "code",
327
+ "execution_count": 8,
328
+ "metadata": {},
329
+ "outputs": [
330
+ {
331
+ "name": "stdout",
332
+ "output_type": "stream",
333
+ "text": [
334
+ "Emma_the_Sales_Expert (to chat_manager):\n",
335
+ "\n",
336
+ "\n",
337
+ "The market for sports articles for bikers is dynamic and multifaceted, catering to a wide range of customers from casual riders to professional athletes. It encompasses various segments including road biking, mountain biking, BMX, and leisure biking. The demand is driven by a growing interest in outdoor activities, fitness, and eco-friendly modes of transportation.\n",
338
+ "Key Segments:\n",
339
+ "Road Biking: This segment includes high-performance bikes and gear for speed and endurance, appealing to serious athletes and fitness enthusiasts. The market is dominated by a few major brands such as Trek, Cannondale, and Specialized.\n",
340
+ "Internal Weakness: Limited Online Presence and Digital Marketing Expertise.\n",
341
+ "Your company currently has a minimal online presence, with a basic website and limited activity on social media platforms. The in-house team lacks expertise in digital marketing, SEO, and e-commerce strategies. This deficiency results in reduced online visibility and a lack of engagement with potential customers, especially those who predominantly shop and seek information online.\n",
342
+ "Market Opportunity: Growing Demand for E-Bikes.\n",
343
+ "\n",
344
+ "Subject: Strategy Meeting Invitation: Capitalizing on E-Bike Market Opportunity\n",
345
+ "\n",
346
+ "Body:\n",
347
+ "\n",
348
+ "Dear Alex, Emma, and Michael,\n",
349
+ "\n",
350
+ "I hope this email finds you well. As we navigate through an increasingly competitive market, it is essential that we continually align our strategies with emerging opportunities and internal capabilities. To this end, I would like to invite you to a strategic meeting to discuss a significant opportunity in the e-bike market and address our current internal challenges that are im\n",
351
+ "\n",
352
+ "\"Good morning everyone,\n",
353
+ "\n",
354
+ "Thank you for joining this crucial meeting today. I'm excited to discuss an opportunity that has the potential to significantly impact our market positioning and overall growth.\n",
355
+ "\n",
356
+ "Firstly, let's talk about the opportunity at hand. We're witnessing a substantial shift in consumer preferences towards e-bikes, especially among urban commuters. This trend isn't just a fleeting one; it's driven by increasing environmental awareness, the need for efficient commuting options, an aging population, and a growing interest in fitness. In fact, the global e-bike market is expected to grow at a CAGR of 9.01% from 2021 to 2028, reaching a value of $38.6 billion by 2028.\n",
357
+ "\n",
358
+ "\n",
359
+ "--------------------------------------------------------------------------------\n",
360
+ "Alex_the_Marketing_Expert (to chat_manager):\n",
361
+ "\n",
362
+ "Secondly, we need to address our current weaknesses. Our online presence is currently minimal, and we are lagging behind our competitors in terms of digital marketing strategy and e-commerce. This lack of visibility is a significant disadvantage in today's digital-first world, especially as COVID-19 has drastically accelerated the move towards online shopping and information seeking.\n",
363
+ "\n",
364
+ "Our meeting agenda will focus on the following points:\n",
365
+ "\n",
366
+ "1. Understanding the E-Bike Market: We will delve into the demographics, key purchase drivers, and product preferences of e-bike consumers. Emma will guide us through this analysis.\n",
367
+ "\n",
368
+ "2. Digital Marketing Strategy: Alex, your expertise in SEO, social media advertising, and email marketing is critical here. We need to work on enhancing our online presence, optimizing our website for search engines, and engaging with our audience on social media platforms.\n",
369
+ "\n",
370
+ "3. E-commerce Strategy: Our website needs to be more than just a digital brochure; it needs to be a sales platform. We need to look into the best practices for e-commerce, specifically for sports and biking gear, and how we can apply them.\n",
371
+ "\n",
372
+ "4. Branding for E-Bikes: Alex, you are also instrumental in this part. We need to develop a strong brand identity that resonates with the e-bike community and differentiates us from our competitors.\n",
373
+ "\n",
374
+ "5. Sales Strategy: Emma, we will rely on your expertise to develop a compelling sales strategy. With your knowledge of our products and our customers, I know you will provide a successful plan.\n",
375
+ "\n",
376
+ "I look forward to your confirmed participation in this meeting and expect it to be a fruitful discussion that will guide our future direction. Please let me know your available dates within this week to schedule the meeting.\n",
377
+ "\n",
378
+ "Best regards,\n",
379
+ "\n",
380
+ "[Your Name]\n",
381
+ "\n",
382
+ "[Your Title]\n",
383
+ "\n",
384
+ "--------------------------------------------------------------------------------\n",
385
+ "Emma_the_Sales_Expert (to chat_manager):\n",
386
+ "\n",
387
+ "Absolutely, Alex. Improving our digital presence and transforming our website into a sales platform is crucial. It's time we embrace the trend of online shopping and information seeking that's prevalent in this era. Let's review the meeting agenda in more depth to fully understand our action plan.\n",
388
+ "\n",
389
+ "--------------------------------------------------------------------------------\n",
390
+ "Michael_the_Manager (to chat_manager):\n",
391
+ "\n",
392
+ "Emma, thanks for being on board and active in this planning process. I'm confident that our combined skills and expertise can effectively address this opportunity. Let's delve into the agenda and start prepping for the meeting.\n",
393
+ "\n",
394
+ "1. Understanding the E-Bike Market: As Emma will guide us through the market analysis, we must thoroughly understand who the typical e-bike consumer is, their key purchase drivers, and specific preferences. These insights will allow us to build effective marketing campaigns targeting this audience.\n",
395
+ "\n",
396
+ "2. Digital Marketing Strategy: Alex's expertise will surely help us to enhance our online visibility significantly. SEO, social media advertising, and email marketing are all powerful tools we haven't leveraged enough yet. To engage with our audience better, we must create compelling content that represents our brand and our values.\n",
397
+ "\n",
398
+ "3 & 4. E-commerce Strategy and Branding for E-Bikes: Transforming our website into a dynamic sales platform is certainly prioritized. We should brainstorm tactics to make it more interactive, user-friendly, and efficient. Also, while developing a strong brand identity for our e-bikes segment, we should ensure it aligns well with our overall brand identity.\n",
399
+ "\n",
400
+ "5. Sales Strategy: As our sales expert, Emma, I am certain you have a pulse on what our customers want. Your role in shaping our sales strategy is pivotal.\n",
401
+ "\n",
402
+ "Let's continue this discussion tomorrow at 10 am. I believe we have a promising path ahead. Please take the time to look over these points before the meeting.\n",
403
+ "\n",
404
+ "--------------------------------------------------------------------------------\n",
405
+ "Alex_the_Marketing_Expert (to chat_manager):\n",
406
+ "\n",
407
+ "Thanks for compiling that comprehensive agenda, Michael. I think you're spot on - understanding our target audience will be key in crafting effective marketing campaigns. Likewise, building our digital marketing strategy, e-commerce work stream, and brand identity for e-bikes in tandem will ensure a consistent and effective approach.\n",
408
+ "\n",
409
+ "As a sales expert, I'll bring relevant customer insights and expertise to shape our sales strategy and I look forward to working closely with Alex on this. A strong correlation between our marketing efforts and sales strategy will be critical for success.\n",
410
+ "\n",
411
+ "I'm likewise excited about tomorrow's discussion and the opportunities it presents. Looking forward to charting a new path of growth with e-bikes.\n",
412
+ "\n",
413
+ "See you at 10 am tomorrow.\n",
414
+ "\n",
415
+ "Best,\n",
416
+ "Emma\n",
417
+ "\n",
418
+ "--------------------------------------------------------------------------------\n",
419
+ "Michael_the_Manager (to chat_manager):\n",
420
+ "\n",
421
+ "That's terrific, Emma. Your emphasis on maintaining a strong correlation between our marketing initiatives and sales strategy is very well placed. This synchronization would indeed be key to our success. So, let's map this path to growth together and evolve in the e-bikes market. I am really looking forward to our collaboration. See you at the meeting tomorrow. Good Night!\n",
422
+ "\n",
423
+ "--------------------------------------------------------------------------------\n",
424
+ "Alex_the_Marketing_Expert (to chat_manager):\n",
425
+ "\n",
426
+ "Thank you, Michael. I truly believe that with our collective expertise and a strong strategic focus, we can achieve great success in the e-bike market. I'm excited about the potential opportunities and I'm confident we're heading in the right direction. Looking forward to sharing ideas and strategies at the meeting tomorrow. Good night! \n",
427
+ "\n",
428
+ "Best,\n",
429
+ "Alex\n",
430
+ "\n",
431
+ "--------------------------------------------------------------------------------\n",
432
+ "Michael_the_Manager (to chat_manager):\n",
433
+ "\n",
434
+ "That's the spirit, Alex! Looking forward to harnessing our collective expertise to capture the e-bike market opportunity. Your excitement is contagious, and I believe our shared enthusiasm will propel us to great heights. See you at the meeting tomorrow and good night!\n",
435
+ "\n",
436
+ "Best,\n",
437
+ "Michael\n",
438
+ "\n",
439
+ "--------------------------------------------------------------------------------\n",
440
+ "Emma_the_Sales_Expert (to chat_manager):\n",
441
+ "\n",
442
+ "Thank you, Michael. Your leadership and enthusiasm foster a positive atmosphere in our team. I truly believe that through our collaboration and shared expertise, we'll successfully seize this e-bike opportunity. Looking forward to contributing my insights at the meeting tomorrow. Goodnight, team!\n",
443
+ "\n",
444
+ "--------------------------------------------------------------------------------\n",
445
+ "Michael_the_Manager (to chat_manager):\n",
446
+ "\n",
447
+ "\n",
448
+ "\n",
449
+ "--------------------------------------------------------------------------------\n"
450
+ ]
451
+ }
452
+ ],
453
+ "source": [
454
+ "sales.initiate_chat(\n",
455
+ " manager,\n",
456
+ " message=Business_Overview + email + meeting_opener,\n",
457
+ ")\n",
458
+ "# type exit to terminate the chat"
459
+ ]
460
+ },
461
+ {
462
+ "cell_type": "code",
463
+ "execution_count": null,
464
+ "metadata": {},
465
+ "outputs": [],
466
+ "source": []
467
+ }
468
+ ],
469
+ "metadata": {
470
+ "kernelspec": {
471
+ "display_name": "flaml",
472
+ "language": "python",
473
+ "name": "python3"
474
+ },
475
+ "language_info": {
476
+ "codemirror_mode": {
477
+ "name": "ipython",
478
+ "version": 3
479
+ },
480
+ "file_extension": ".py",
481
+ "mimetype": "text/x-python",
482
+ "name": "python",
483
+ "nbconvert_exporter": "python",
484
+ "pygments_lexer": "ipython3",
485
+ "version": "3.11.3"
486
+ },
487
+ "orig_nbformat": 4
488
+ },
489
+ "nbformat": 4,
490
+ "nbformat_minor": 2
491
+ }