Geethuzzz commited on
Commit
4137016
·
verified ·
1 Parent(s): 8187a56

Upload app2.py

Browse files
Files changed (1) hide show
  1. app2.py +115 -0
app2.py ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import streamlit as st
3
+ from crewai import Agent, Task, Crew, LLM
4
+
5
+ # Set your Gemini AI API key and model
6
+ gemini_api_key = "AIzaSyAC_i-I9uCP2UP14H89uigWP7MDM2xQno8"
7
+ serper_api_key = "b86545fdabc35dcb13fd8cc0a9b88c3a17b6dc89"
8
+ os.environ["GEMINI_API_KEY"] = gemini_api_key
9
+
10
+ # Initialize the LLM instance
11
+ my_llm = LLM(
12
+ api_key=gemini_api_key,
13
+ model="gemini/gemini-pro"
14
+ )
15
+
16
+ # Define your agents with roles, goals, and backstory
17
+ researcher = Agent(
18
+ role="Market Researcher",
19
+ goal=(
20
+ f"Gather detailed information about {company_name}, including its market position, "
21
+ f"competitor strategies, customer segments, and latest trends in the industry. "
22
+ f"Leverage tools like online databases, market reports, and press releases to provide comprehensive insights."
23
+ ),
24
+ backstory=(
25
+ f"You are an experienced market researcher with expertise in extracting actionable intelligence "
26
+ f"about companies like {company_name}. You excel in identifying emerging opportunities, uncovering "
27
+ f"competitor strengths, and analyzing industry dynamics to provide a complete overview of the business landscape."
28
+ ),
29
+ llm=my_llm,
30
+ allow_delegation=False,
31
+ verbose=True,
32
+
33
+ )
34
+ analyzer = Agent(
35
+ role="Data Analyzer",
36
+ goal=(
37
+ f"Analyze {company_name}'s financial performance, operational metrics, strengths, and weaknesses. "
38
+ f"Identify key performance indicators (KPIs) and assess the impact of external factors like market trends "
39
+ f"and economic conditions. Provide actionable insights and recommendations for improvement."
40
+ ),
41
+ backstory=(
42
+ f"You are a skilled data analyst with extensive experience in dissecting business data. Your expertise lies in "
43
+ f"transforming raw data into meaningful insights, creating detailed performance analyses, and offering strategic guidance "
44
+ f"tailored to companies like {company_name}. You utilize advanced analytics tools to generate reliable and insightful reports."
45
+ ),
46
+ llm=my_llm,
47
+ allow_delegation=False,
48
+ verbose=True,
49
+ )
50
+ research_task = Task(
51
+ description=f"Conduct research on {company_name}, focusing on its competitors, market trends, and customer demographics.",
52
+ expected_output=f"A detailed research document outlining {company_name}'s market position, competitor insights, and growth opportunities.",
53
+ agent=researcher,
54
+ )
55
+
56
+ analysis_task = Task(
57
+ description=f"Perform an in-depth analysis of {company_name}'s financial performance, operational metrics, and market impact.",
58
+ expected_output=f"A comprehensive report on {company_name}'s strengths, weaknesses, and actionable recommendations for growth.",
59
+ agent=analyzer,
60
+ )
61
+
62
+ final_article_task = Task(
63
+ description=f"Combine the research and analysis results into a final article that provides a holistic overview of {company_name}.",
64
+ expected_output=f"A well-structured final analysis article about {company_name}, including actionable recommendations.",
65
+ context=[research_task, analysis_task],
66
+ agent=researcher,
67
+ )
68
+ # comparator = Agent(
69
+ # role="Comparator",
70
+ # goal="Compare the company with its competitors and provide actionable suggestions.",
71
+ # backstory="You specialize in comparing companies and offering improvement strategies.",
72
+ # llm=my_llm,
73
+ # allow_delegation=False,
74
+ # verbose=True,
75
+ # )
76
+
77
+ # Define Tasks for Agents
78
+
79
+ # Create the crew with your agents and tasks
80
+ company_analysis_crew = Crew(
81
+ agents=[researcher, analyzer],
82
+ tasks=[research_task, analysis_task, final_article_task],
83
+ verbose=True,
84
+ )
85
+
86
+ # Streamlit Interface for user input
87
+ st.title("Company Analysis")
88
+
89
+ # Input section for company and competitors
90
+ st.write("Enter Company Details")
91
+ company_name = st.text_input(":)")
92
+ # competitor_list = st.text_area(
93
+ # "List of Competitors (comma-separated)",
94
+ # "Competitor A, Competitor B, Competitor C"
95
+ # )
96
+
97
+ # Start the analysis when the user clicks the button
98
+ if st.button("Start Analysis"):
99
+ st.write("Running Analysis... Please wait.")
100
+
101
+ # Define inputs for the analysis tasks
102
+ inputs = {
103
+ "company_name": company_name,
104
+ # "competitors": competitor_list.split(","),
105
+ }
106
+
107
+ # Kick off the Crew Process
108
+ results = company_analysis_crew.kickoff(inputs=inputs)
109
+ st.markdown(results)
110
+
111
+ # Display Results
112
+ st.success("Analysis Completed!")
113
+ if "final_article.md" in results:
114
+ st.header("Final Analysis Article")
115
+ st.markdown(results["final_article.md"], unsafe_allow_html=True)