GiantAnalytics commited on
Commit
93b4009
·
verified ·
1 Parent(s): 569b11a

Create phase3_agents.py

Browse files
Files changed (1) hide show
  1. phase3_agents.py +167 -0
phase3_agents.py ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from phi.agent import Agent
3
+ from phi.model.openai import OpenAIChat
4
+ import markdown2
5
+ import pdfkit
6
+ from bni_agent import get_bni_benefits
7
+ from rag_agent import recommend_bni_connections
8
+
9
+ # Load environment variables (API keys, etc.)
10
+ from dotenv import load_dotenv
11
+ load_dotenv()
12
+
13
+ #####################################################################################
14
+ # PHASE 3 #
15
+ #####################################################################################
16
+
17
+ ##############################
18
+ # 1️⃣ Reasoning Agent #
19
+ ##############################
20
+ reasoning_agent = Agent(
21
+ name="Reasoning Agent",
22
+ model=OpenAIChat(id="gpt-4o"),
23
+ description="Processes all collected data and generates structured AI adoption strategies.",
24
+ show_tool_calls=True,
25
+ markdown=True,
26
+ )
27
+
28
+ def generate_ai_strategy(company_data: str, industry_trends: str, ai_use_cases: str) -> str:
29
+ """Generates a structured AI adoption strategy based on company details and industry insights."""
30
+ query = f"""
31
+ You are an AI business strategist analyzing a company's AI adoption potential. Given:
32
+ - **Company Overview:** {company_data}
33
+ - **Industry Trends:** {industry_trends}
34
+ - **AI Use Cases:** {ai_use_cases}
35
+
36
+ Generate a structured AI strategy including:
37
+ 1. Key AI Opportunities
38
+ 2. Recommended AI Tools & Technologies
39
+ 3. AI Implementation Roadmap
40
+ 4. Future Scalability Plan
41
+ """
42
+ response = reasoning_agent.run(query)
43
+ return response.content # Returns the generated AI strategy
44
+
45
+
46
+ ##############################
47
+ # 2️⃣ AI Integration Advisor #
48
+ ##############################
49
+ ai_integration_agent = Agent(
50
+ name="AI Integration Advisor",
51
+ model=OpenAIChat(id="gpt-4o"),
52
+ description="Suggests AI implementation strategies based on industry insights and company operations.",
53
+ show_tool_calls=True,
54
+ markdown=True,
55
+ )
56
+
57
+ def suggest_ai_integration(company_data: str, ai_strategy: str) -> str:
58
+ """Suggests a structured AI implementation plan."""
59
+ query = f"""
60
+ Based on the AI adoption strategy:
61
+ - **Company Context:** {company_data}
62
+ - **AI Strategy Summary:** {ai_strategy}
63
+
64
+ Provide a structured AI implementation plan including:
65
+ 1. Step-by-step AI adoption process
66
+ 2. Required AI Technologies & Infrastructure
67
+ 3. Workforce training & AI skill development
68
+ 4. Risk considerations (data security, compliance, ethical AI)
69
+ 5. Key performance indicators (KPIs) for AI success.
70
+ """
71
+ response = ai_integration_agent.run(query)
72
+ return response.content # Returns AI integration plan
73
+
74
+
75
+ ##############################
76
+ # 3️⃣ Revenue Growth Agent #
77
+ ##############################
78
+ revenue_growth_agent = Agent(
79
+ name="Revenue Growth Agent",
80
+ model=OpenAIChat(id="gpt-4o"),
81
+ description="Identifies AI-driven opportunities to enhance revenue and efficiency.",
82
+ show_tool_calls=True,
83
+ markdown=True,
84
+ )
85
+
86
+ def identify_revenue_opportunities(company_data: str, ai_strategy: str) -> str:
87
+ """Identifies AI-driven revenue generation opportunities for a business."""
88
+ query = f"""
89
+ You are an AI business analyst identifying AI-driven revenue growth opportunities for:
90
+ - **Company Overview:** {company_data}
91
+ - **AI Strategy:** {ai_strategy}
92
+
93
+ Provide:
94
+ 1. AI-based Monetization Strategies (new revenue streams)
95
+ 2. Cost Reduction & Operational Efficiency
96
+ 3. Market Expansion through AI-driven solutions
97
+ 4. Competitive Positioning & Differentiation using AI.
98
+ """
99
+ response = revenue_growth_agent.run(query)
100
+ return response.content # Returns revenue opportunities
101
+
102
+
103
+ ##############################
104
+ # 4️⃣ BNI Agent: Membership Benefits #
105
+ ##############################
106
+ def get_bni_membership_benefits(company_data: str) -> str:
107
+ """Fetches BNI membership benefits tailored to the user's company."""
108
+ return get_bni_benefits(company_data)
109
+
110
+
111
+ ##############################
112
+ # 5️⃣ BNI RAG Agent: Pearl Chapter Connections #
113
+ ##############################
114
+ def get_bni_recommendations(company_data: str) -> str:
115
+ """Recommends relevant BNI Pearl Chapter members based on the user's company data."""
116
+ return recommend_bni_connections(company_data)
117
+
118
+
119
+ ##############################
120
+ # 6️⃣ Report Generation Agent #
121
+ ##############################
122
+ def generate_report(company_name: str, company_data: str, industry_trends: str, ai_use_cases: str,
123
+ ai_strategy: str, ai_integration: str, revenue_opportunities: str,
124
+ bni_benefits: str, bni_recommendations: str) -> str:
125
+ """
126
+ Generates a structured AI strategy report in PDF format using `pdfkit`.
127
+
128
+ Returns:
129
+ str: Filename of the generated PDF.
130
+ """
131
+ report_content = f"""
132
+ # AI Strategy Report for {company_name}
133
+
134
+ ## 1️⃣ Company Overview
135
+ {company_data}
136
+
137
+ ## 2️⃣ Industry Trends
138
+ {industry_trends}
139
+
140
+ ## 3️⃣ AI Use Cases
141
+ {ai_use_cases}
142
+
143
+ ## 4️⃣ AI Adoption Strategy
144
+ {ai_strategy}
145
+
146
+ ## 5️⃣ AI Implementation Plan
147
+ {ai_integration}
148
+
149
+ ## 6️⃣ Revenue Growth Opportunities
150
+ {revenue_opportunities}
151
+
152
+ ## 7️⃣ How BNI Can Help Your Business
153
+ {bni_benefits}
154
+
155
+ ## 8️⃣ Recommended BNI Pearl Chapter Connections
156
+ {bni_recommendations}
157
+
158
+ """
159
+
160
+ # Convert to Markdown
161
+ markdown_report = markdown2.markdown(report_content)
162
+
163
+ # Convert Markdown to PDF (Ensure wkhtmltopdf is installed)
164
+ pdf_filename = f"{company_name}_AI_Report.pdf"
165
+ pdfkit.from_string(markdown_report, pdf_filename)
166
+
167
+ return pdf_filename # Returns the generated PDF filename