File size: 4,680 Bytes
4137016
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
import streamlit as st
from crewai import Agent, Task, Crew, LLM

# Set your Gemini AI API key and model
gemini_api_key = "AIzaSyAC_i-I9uCP2UP14H89uigWP7MDM2xQno8"
serper_api_key = "b86545fdabc35dcb13fd8cc0a9b88c3a17b6dc89"
os.environ["GEMINI_API_KEY"] = gemini_api_key

# Initialize the LLM instance
my_llm = LLM(
    api_key=gemini_api_key,
    model="gemini/gemini-pro"
)

# Define your agents with roles, goals, and backstory
researcher = Agent(
    role="Market Researcher",
    goal=(
        f"Gather detailed information about {company_name}, including its market position, "
        f"competitor strategies, customer segments, and latest trends in the industry. "
        f"Leverage tools like online databases, market reports, and press releases to provide comprehensive insights."
    ),
    backstory=(
        f"You are an experienced market researcher with expertise in extracting actionable intelligence "
        f"about companies like {company_name}. You excel in identifying emerging opportunities, uncovering "
        f"competitor strengths, and analyzing industry dynamics to provide a complete overview of the business landscape."
    ),
    llm=my_llm,
    allow_delegation=False,
    verbose=True,
   
)
analyzer = Agent(
    role="Data Analyzer",
    goal=(
        f"Analyze {company_name}'s financial performance, operational metrics, strengths, and weaknesses. "
        f"Identify key performance indicators (KPIs) and assess the impact of external factors like market trends "
        f"and economic conditions. Provide actionable insights and recommendations for improvement."
    ),
    backstory=(
        f"You are a skilled data analyst with extensive experience in dissecting business data. Your expertise lies in "
        f"transforming raw data into meaningful insights, creating detailed performance analyses, and offering strategic guidance "
        f"tailored to companies like {company_name}. You utilize advanced analytics tools to generate reliable and insightful reports."
    ),
    llm=my_llm,
    allow_delegation=False,
    verbose=True,
)
research_task = Task(
    description=f"Conduct research on {company_name}, focusing on its competitors, market trends, and customer demographics.",
    expected_output=f"A detailed research document outlining {company_name}'s market position, competitor insights, and growth opportunities.",
    agent=researcher,
)

analysis_task = Task(
    description=f"Perform an in-depth analysis of {company_name}'s financial performance, operational metrics, and market impact.",
    expected_output=f"A comprehensive report on {company_name}'s strengths, weaknesses, and actionable recommendations for growth.",
    agent=analyzer,
)

final_article_task = Task(
    description=f"Combine the research and analysis results into a final article that provides a holistic overview of {company_name}.",
    expected_output=f"A well-structured final analysis article about {company_name}, including actionable recommendations.",
    context=[research_task, analysis_task],
    agent=researcher,
)
# comparator = Agent(
#     role="Comparator",
#     goal="Compare the company with its competitors and provide actionable suggestions.",
#     backstory="You specialize in comparing companies and offering improvement strategies.",
#     llm=my_llm,
#     allow_delegation=False,
#     verbose=True,
# )

# Define Tasks for Agents

# Create the crew with your agents and tasks
company_analysis_crew = Crew(
    agents=[researcher, analyzer],
    tasks=[research_task, analysis_task, final_article_task],
    verbose=True,
)

# Streamlit Interface for user input
st.title("Company  Analysis")

# Input section for company and competitors
st.write("Enter Company Details")
company_name = st.text_input(":)")
# competitor_list = st.text_area(
#     "List of Competitors (comma-separated)",
#     "Competitor A, Competitor B, Competitor C"
# )

# Start the analysis when the user clicks the button
if st.button("Start Analysis"):
    st.write("Running Analysis... Please wait.")
    
    # Define inputs for the analysis tasks
    inputs = {
        "company_name": company_name,
        # "competitors": competitor_list.split(","),
    }
    
    # Kick off the Crew Process
    results = company_analysis_crew.kickoff(inputs=inputs)
    st.markdown(results)
    
        # Display Results
    st.success("Analysis Completed!")
    if "final_article.md" in results:
        st.header("Final Analysis Article")
        st.markdown(results["final_article.md"], unsafe_allow_html=True)