File size: 5,188 Bytes
e7ece9c
6872bcb
 
 
e7ece9c
 
 
b0a682d
6223169
e7ece9c
 
 
 
 
 
 
 
 
 
 
 
 
 
59c3706
 
 
e7ece9c
 
 
 
 
59c3706
e7ece9c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d4ec14e
e7ece9c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import autogen
from autogen.agentchat.assistant_agent import AssistantAgent
from autogen.agentchat.contrib.retrieve_user_proxy_agent import RetrieveUserProxyAgent
from autogen.agentchat.conversable_agent import ConversableAgent
import chromadb

config_list = autogen.config_list_from_json(
    "OAI_CONFIG_LIST.json",
    file_location="./src/config/",
    filter_dict={
        "model": ["gpt-3.5-turbo", "gpt-35-turbo", "gpt-35-turbo-0613", "gpt-4", "gpt4", "gpt-4-32k"],
    },
)

print("LLM models: ", [config_list[i]["model"] for i in range(len(config_list))])

llm_config = {
         "timeout": 60,
         "cache_seed": 42,
         "config_list": config_list,
         "temperature": 0,
     }

def termination_msg(self, x):
        return isinstance(x, dict) and "TERMINATE" == str(x.get("content", ""))[-9:].upper()

class AgentsFactory:
    def __init__(self, llm_config, db_path):
        self.llm_config = llm_config
        self.db_path = db_path

    

    def tonic(self) :
        return autogen.UserProxyAgent(
            name="Boss",
            is_termination_msg=termination_msg,
            human_input_mode="NEVER",
            system_message="The boss who asks questions and gives tasks.",
            code_execution_config=False,
            default_auto_reply="Reply `TERMINATE` if the task is done.",
        )

    # Create the RetrieveUserProxyAgent (Boss Assistant)
    def scitonic(self) :
        return RetrieveUserProxyAgent(
            name="Boss_Assistant",
            is_termination_msg=termination_msg,
            system_message="Assistant who has extra content retrieval power for solving difficult problems.",
            human_input_mode="NEVER",
            max_consecutive_auto_reply=3,
            retrieve_config={
                "task": "QuoraRetrieval",
                "docs_path": self.db_path,
                "chunk_token_size": 1000,
                "model": llm_config["config_list"][0]["model"],
                "client": chromadb.PersistentClient(path="/tmp/chromadb"),
                "collection_name": "groupchat",
                "get_or_create": True,
            },
            code_execution_config=False,
        )
    # Placeholder definitions for agents used in team functions
    def coder(self) : 
        return AssistantAgent(
            name="Coder",
            system_message="You are a coder. Help in writing and reviewing code.",
            llm_config=llm_config
        )

    def pm(self) :
        return AssistantAgent(
            name="Project_Manager",
            system_message="You are a project manager. Coordinate tasks and ensure project success.",
            llm_config=llm_config
        )

    def reviewer(self) :
        return AssistantAgent(
            name="Reviewer",
            system_message="You are a code reviewer. Provide feedback on code quality.",
            llm_config=llm_config
        )

    # Define more agents for each team
    def finance_expert(self) :
        return AssistantAgent(
            name="Finance_Expert",
            system_message="You are a finance expert. Provide insights on financial matters.",
            llm_config=llm_config
        )

    def debate_champion(self) :
        return AssistantAgent(
            name="Debate_Champion",
            system_message="You are a debate champion. Contribute to meaningful debates.",
            llm_config=llm_config
        )

    def academic_whiz(self) :
        return AssistantAgent(
        name="Academic_Whiz",
        system_message="You are an academic whiz. Offer solutions to academic challenges.",
        llm_config=llm_config
    )

    def consulting_pro(self) :
            return AssistantAgent(
            name="Consulting_Pro",
            system_message="You are a consulting professional. Offer professional advice and solutions.",
            llm_config=llm_config
        )
    def covid19_scientist(self) : 
        return AssistantAgent(
            name="Covid19_Scientist",
            system_message="You are a scientist studying Covid-19 trends. Provide analysis and insights.",
            llm_config=llm_config
        )

    def healthcare_expert(self) : 
        return AssistantAgent(
            name="Healthcare_Expert",
            system_message="You are a healthcare expert focused on managing and mitigating the impact of Covid-19.",
            llm_config=llm_config
        )

    def finance_analyst(self) :
        return AssistantAgent(
            name="Finance_Analyst",
            system_message="You are a finance analyst. Provide insights on the economic impact of Covid-19.",
            llm_config=llm_config
        )

    def debate_expert(self) :
        return AssistantAgent(
            name="Debate_Expert",
            system_message="You are an expert in debate strategies and communication. Participate in meaningful debates.",
            llm_config=llm_config
        )

    def academic_expert(self) :
        return AssistantAgent(
            name="Academic_Expert",
            system_message="You are an academic expert. Provide assistance and insights for academic challenges.",
            llm_config=llm_config
        )