File size: 4,035 Bytes
dc81b70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fb11726
 
 
dc81b70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fb11726
 
dc81b70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fb11726
 
dc81b70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c09164a
 
 
 
dc81b70
 
 
 
 
 
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
import os
from phi.agent import Agent
from phi.model.openai import OpenAIChat
from typing import List
from pydantic import BaseModel, Field
import markdown2
import pdfkit

# Load environment variables (API keys, etc.)
from dotenv import load_dotenv
load_dotenv()

#####################################################################################
#                                    PHASE 3                                        #
#####################################################################################

##############################
# 1️⃣ Reasoning Agent        #
##############################
reasoning_agent = Agent(
    name="Reasoning Agent",
    model=OpenAIChat(id="gpt-4o"),
    description="Processes all collected data and generates structured AI adoption strategies.",
    show_tool_calls=True,
    markdown=True,
)

def generate_ai_strategy(company_data: str, industry_trends: str, ai_use_cases: str, competitor_analysis: str):
    query = f"""
    You are an AI business strategist analyzing a company's potential AI adoption. Given the following:
    - **Company Overview:** {company_data}
    - **Industry Trends:** {industry_trends}
    - **AI Use Cases:** {ai_use_cases}
    - **Competitor AI Strategies:** {competitor_analysis}
    Generate a structured AI adoption strategy including key opportunities, recommended AI tools, implementation roadmap, and future scalability.
    """
    response = reasoning_agent.run(query)
    return response.content 
    


##############################
# 2️⃣ AI Integration Advisor  #
##############################
ai_integration_agent = Agent(
    name="AI Integration Advisor",
    model=OpenAIChat(id="gpt-4o"),
    description="Suggests AI implementation strategies based on industry insights and company operations.",
    show_tool_calls=True,
    markdown=True,
)

def suggest_ai_integration(company_data: str, ai_strategy: str):
    query = f"""
    Based on the AI adoption strategy:
    - **Company Context:** {company_data}
    - **AI Strategy Summary:** {ai_strategy}
    Provide a structured AI implementation plan including step-by-step integration, required technologies, workforce training, risk considerations, and key performance indicators.
    """
    response = ai_integration_agent.run(query)
    return response.content

##############################
# 3️⃣ Revenue Growth Agent    #
##############################
revenue_growth_agent = Agent(
    name="Revenue Growth Agent",
    model=OpenAIChat(id="gpt-4o"),
    description="Identifies AI-driven opportunities to enhance revenue and efficiency.",
    show_tool_calls=True,
    markdown=True,
)

def identify_revenue_opportunities(company_data: str, ai_strategy: str):
    query = f"""
    You are an AI business analyst tasked with identifying AI-driven revenue growth opportunities for:
    - **Company Overview:** {company_data}
    - **AI Strategy:** {ai_strategy}
    Provide AI monetization strategies, cost-saving efficiencies, market expansion possibilities, and competitive positioning tactics.
    """
    response = revenue_growth_agent.run(query)
    return response.content  # Return the revenue opportunities


##############################
# 4️⃣ Report Generation Agent #
##############################
def generate_report(company_name: str, ai_strategy: str, ai_integration: str, revenue_opportunities: str):
    report_content = f"""
    # AI Strategy Report for {company_name}
    
    ## AI Adoption Strategy
    {ai_strategy}
    
    ## AI Implementation Plan
    {ai_integration}
    
    ## Revenue Growth Opportunities
    {revenue_opportunities}
    
    """
    
    # Convert to Markdown
    markdown_report = markdown2.markdown(report_content)

    # Define the path to wkhtmltopdf configuration
    config = pdfkit.configuration(wkhtmltopdf="/usr/bin/wkhtmltopdf")

    
    # Convert Markdown to PDF
    pdf_filename = f"{company_name}_AI_Report.pdf"
    pdfkit.from_string(markdown_report, pdf_filename)
    
    return pdf_filename