Mustafa-Shoukat1 commited on
Commit
94846cb
·
verified ·
1 Parent(s): 65791cc

Create aap.py

Browse files
Files changed (1) hide show
  1. aap.py +172 -0
aap.py ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py
2
+ import os
3
+ from crewai import Agent, Task, Crew
4
+ from crewai_tools import DirectoryReadTool, FileReadTool, SerperDevTool, BaseTool
5
+ from langchain_groq import ChatGroq
6
+ import gradio as gr
7
+
8
+ # Set environment variables for API keys
9
+ os.environ["SERPER_API_KEY"] = "3c75331dffc120acfa03b3bc75a4fbb3202c4927"
10
+ os.environ['GROQ_API_KEY'] = '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'
11
+
12
+ # Initialize the ChatGroq model
13
+ llm = ChatGroq(
14
+ api_key=os.getenv('GROQ_API_KEY'),
15
+ model="mixtral-8x7b-32768"
16
+ )
17
+
18
+ # Define the agents
19
+ class SalesAgents:
20
+ def __init__(self):
21
+ self.llm = llm
22
+
23
+ def sales_rep_agent(self):
24
+ return Agent(
25
+ role="Sales Representative",
26
+ goal="Identify high-value leads that match our ideal customer profile",
27
+ backstory=(
28
+ "As a key member of the dynamic sales team at COMET Estimating LLC, your mission is to navigate the construction and "
29
+ "estimating sectors to uncover promising leads. Leveraging state-of-the-art tools and a strategic approach, "
30
+ "you delve into data, market trends, and industry interactions to identify opportunities that others might miss. "
31
+ "Your role is essential in fostering valuable connections and driving the growth of our estimating services, "
32
+ "ensuring that general contractors and subcontractors benefit from precise, actionable insights and expert support."
33
+ ),
34
+ allow_delegation=False,
35
+ verbose=True,
36
+ llm=self.llm,
37
+ max_iter=5,
38
+ memory=True
39
+ )
40
+
41
+ def lead_sales_rep_agent(self):
42
+ return Agent(
43
+ role="Lead Sales Representative",
44
+ goal="Nurture leads with personalized, compelling communications",
45
+ backstory=(
46
+ "Within the dynamic landscape of crewAI's sales department, you excel as the crucial link "
47
+ "between prospective clients and the estimating solutions they require. By crafting tailored, engaging communications, "
48
+ "you not only showcase our expert services but also ensure that general contractors and subcontractors feel understood and valued. "
49
+ "Your role is key in transforming interest into tangible outcomes, guiding leads from initial curiosity through to securing our "
50
+ "estimating services."
51
+ ),
52
+ allow_delegation=False,
53
+ verbose=True,
54
+ llm=self.llm,
55
+ max_iter=5,
56
+ memory=True
57
+ )
58
+
59
+ # Define the tools
60
+ directory_read_tool = DirectoryReadTool(directory='./content')
61
+ file_read_tool = FileReadTool()
62
+ search_tool = SerperDevTool()
63
+
64
+ class SentimentAnalysisTool(BaseTool):
65
+ name: str = "Sentiment Analysis Tool"
66
+ description: str = ("Analyzes the sentiment of text to ensure positive and engaging communication according to context.")
67
+
68
+ def _run(self, text: str) -> str:
69
+ # Custom sentiment analysis logic
70
+ return "positive"
71
+
72
+ sentiment_analysis_tool = SentimentAnalysisTool()
73
+
74
+ # Define the tasks
75
+ class SalesTasks:
76
+ def lead_profiling_task(self):
77
+ return Task(
78
+ description=(
79
+ """
80
+ Conduct a thorough analysis of [Lead Name], a general contractor or subcontractor in the construction sector that
81
+ recently expressed interest in our estimating services. Utilize all available data sources, including industry databases,
82
+ company websites, LinkedIn, and recent news articles, to compile a comprehensive profile. This profile should include:
83
+
84
+ 1. Identification of key decision-makers within the company, such as project managers or procurement officers.
85
+ 2. A summary of recent project developments or contracts that the company is involved in.
86
+ 3. An assessment of their specific needs related to estimating services, such as budgeting, cost forecasting, or bidding accuracy.
87
+
88
+ Ensure that all the information used is accurate and verified, as this analysis will be crucial for customizing our
89
+ engagement strategy to effectively meet the company’s needs.
90
+ """
91
+ ),
92
+ expected_output=(
93
+ "A detailed report on {lead_name}, covering company background, key personnel and specific needs related to estimating services. "
94
+ "Identify potential areas where our estimating solutions can add value and propose customized engagement strategies."
95
+ ),
96
+ tools=[directory_read_tool, file_read_tool, search_tool],
97
+ agent=SalesAgents().sales_rep_agent()
98
+ )
99
+
100
+ def personalized_outreach_task(self):
101
+ return Task(
102
+ description=(
103
+ """
104
+ Work at an estimating company where you are tasked with targeting general contractors or subcontractors in the construction sector.
105
+ Using insights from sales representative agents and the lead profiling report on {lead_name}, create a personalized outreach campaign for targeting {key_decision_maker},
106
+ the {position} of {lead_name}. The campaign should address their recent project developments and demonstrate how our estimating services can enhance their operations.
107
+ Your communication must align with {lead_name}'s company culture and demonstrate a clear understanding of their needs and objectives.
108
+ Ensure all information is accurate and verified.
109
+
110
+ In the dynamic world of sales, you act as the crucial link between potential clients and the services they need.
111
+ By crafting tailored, engaging communications, you not only showcase the strengths of the services offered but also ensure that clients feel understood and valued,
112
+ particularly when targeting general contractors or subcontractors in the construction sector.
113
+ Your role is key in transforming interest into actionable outcomes, guiding leads from initial curiosity to securing the service offered.
114
+ Adapt these strategies to effectively connect with any company looking to engage with similar clients.
115
+ """
116
+ ),
117
+ expected_output=(
118
+ "A series of customized email drafts for {lead_name}, specifically directed at {key_decision_maker}. "
119
+ "Each draft should clearly connect our estimating services with their project developments and goals. "
120
+ "The tone should be professional, engaging, and consistent with {lead_name}'s company culture."
121
+ ),
122
+ tools=[sentiment_analysis_tool, search_tool],
123
+ agent=SalesAgents().lead_sales_rep_agent()
124
+ )
125
+
126
+ # Create the crew
127
+ crew = Crew(
128
+ agents=[
129
+ SalesAgents().sales_rep_agent(),
130
+ SalesAgents().lead_sales_rep_agent()
131
+ ],
132
+ tasks=[
133
+ SalesTasks().lead_profiling_task(),
134
+ SalesTasks().personalized_outreach_task()
135
+ ],
136
+ verbose=2,
137
+ memory=True
138
+ )
139
+
140
+ # Define the Gradio app
141
+ def run_tasks(lead_name, industry, key_decision_maker, position, milestone):
142
+ # Set up inputs for the crew
143
+ inputs = {
144
+ "lead_name": lead_name,
145
+ "industry": industry,
146
+ "key_decision_maker": key_decision_maker,
147
+ "position": position,
148
+ "milestone": milestone
149
+ }
150
+
151
+ # Run the crew tasks
152
+ result = crew.kickoff(inputs=inputs)
153
+ return result
154
+
155
+ # Create the Gradio interface
156
+ iface = gr.Interface(
157
+ fn=run_tasks,
158
+ inputs=[
159
+ gr.Textbox(label="Lead Name", placeholder="Enter the company name"),
160
+ gr.Textbox(label="Industry", placeholder="Enter the industry"),
161
+ gr.Textbox(label="Key Decision Maker", placeholder="Enter the name of the key decision maker"),
162
+ gr.Textbox(label="Position", placeholder="Enter the position of the key decision maker"),
163
+ gr.Textbox(label="Milestone", placeholder="Enter the milestone")
164
+ ],
165
+ outputs="text",
166
+ title="Sales Task Runner",
167
+ description="Enter the company details to run the sales tasks and get the results."
168
+ )
169
+
170
+ # Launch the Gradio app
171
+ if __name__ == "__main__":
172
+ iface.launch()