|
import os
|
|
import streamlit as st
|
|
from crewai import Agent, Task, Crew, LLM
|
|
|
|
|
|
gemini_api_key = "AIzaSyAC_i-I9uCP2UP14H89uigWP7MDM2xQno8"
|
|
serper_api_key = "b86545fdabc35dcb13fd8cc0a9b88c3a17b6dc89"
|
|
os.environ["GEMINI_API_KEY"] = gemini_api_key
|
|
|
|
|
|
my_llm = LLM(
|
|
api_key=gemini_api_key,
|
|
model="gemini/gemini-pro"
|
|
)
|
|
|
|
|
|
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,
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
company_analysis_crew = Crew(
|
|
agents=[researcher, analyzer],
|
|
tasks=[research_task, analysis_task, final_article_task],
|
|
verbose=True,
|
|
)
|
|
|
|
|
|
st.title("Company Analysis")
|
|
|
|
|
|
st.write("Enter Company Details")
|
|
company_name = st.text_input(":)")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if st.button("Start Analysis"):
|
|
st.write("Running Analysis... Please wait.")
|
|
|
|
|
|
inputs = {
|
|
"company_name": company_name,
|
|
|
|
}
|
|
|
|
|
|
results = company_analysis_crew.kickoff(inputs=inputs)
|
|
st.markdown(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)
|
|
|