Geethuzzz commited on
Commit
cf7a8a9
·
verified ·
1 Parent(s): 8b564b6

Create Analyser.py

Browse files
Files changed (1) hide show
  1. Analyser.py +110 -0
Analyser.py ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ pip install streamlit crewai crewai-tools embedchain gemini-ai serper
2
+
3
+ import os
4
+ import streamlit as st
5
+ from crewai import Agent, Task, Crew
6
+ from crewai_tools import SerperDevTool
7
+ from embedchain.embedder import GeminiEmbedder
8
+ from embedchain import App
9
+
10
+ # Set API Keys
11
+ gemini_api_key = "AIzaSyAC_i-I9uCP2UP14H89uigWP7MDM2xQno8"
12
+ serper_api_key = "b86545fdabc35dcb13fd8cc0a9b88c3a17b6dc89"
13
+ os.environ["GEMINIAI_API_KEY"] = gemini_api_key
14
+ os.environ["SERPER_API_KEY"] = serper_api_key
15
+
16
+ # Initialize Gemini Embedding Model
17
+ gemini_embedder = GeminiEmbedder(api_key=gemini_api_key)
18
+
19
+ # Initialize Serper Tool
20
+ search_tool = SerperDevTool(api_key=serper_api_key)
21
+
22
+ # Initialize EmbedChain App (Optional for Future Use)
23
+ embedchain_app = App(embedding_model=gemini_embedder)
24
+
25
+ # Create Agents
26
+ researcher = Agent(
27
+ role="Market Researcher",
28
+ goal="Gather detailed information about G10X and its competitors.",
29
+ tools=[search_tool],
30
+ verbose=True,
31
+ backstory="You specialize in market research and can extract detailed company insights."
32
+ )
33
+
34
+ analyzer = Agent(
35
+ role="Data Analyzer",
36
+ goal="Analyze the strengths, weaknesses, and market positioning of G10X.",
37
+ tools=[search_tool],
38
+ verbose=True,
39
+ backstory="Your expertise lies in identifying business trends and company insights."
40
+ )
41
+
42
+ comparator = Agent(
43
+ role="Comparator",
44
+ goal="Compare G10X with its competitors and provide actionable suggestions.",
45
+ tools=[search_tool],
46
+ verbose=True,
47
+ backstory="You excel at comparing companies and offering improvement suggestions."
48
+ )
49
+
50
+ # Define Tasks
51
+ research_task = Task(
52
+ description="Conduct research on G10X and its competitors.",
53
+ expected_output="Detailed research document with company insights.",
54
+ agent=researcher,
55
+ async_execution=True
56
+ )
57
+
58
+ analysis_task = Task(
59
+ description="Analyze G10X's business performance, strengths, and weaknesses.",
60
+ expected_output="Comprehensive analysis of G10X.",
61
+ agent=analyzer,
62
+ async_execution=True
63
+ )
64
+
65
+ comparison_task = Task(
66
+ description="Compare G10X with its competitors and provide improvement suggestions.",
67
+ expected_output="Comparison document with actionable recommendations for G10X.",
68
+ agent=comparator,
69
+ async_execution=True
70
+ )
71
+
72
+ # Final Analysis Article Task
73
+ final_article_task = Task(
74
+ description="Combine insights from all agents to generate a final analysis article for G10X.",
75
+ expected_output="A well-structured analysis article about G10X.",
76
+ context=[research_task, analysis_task, comparison_task],
77
+ agent=None # This will use all agents' outputs
78
+ )
79
+
80
+ # Crew Setup
81
+ company_analysis_crew = Crew(
82
+ agents=[researcher, analyzer, comparator],
83
+ tasks=[research_task, analysis_task, comparison_task, final_article_task],
84
+ verbose=True
85
+ )
86
+
87
+ # Streamlit Interface
88
+ st.title("G10X Company Analyzer")
89
+
90
+ # Input Section
91
+ st.header("Enter Details")
92
+ company_name = st.text_input("Company Name", "G10X")
93
+ competitor_list = st.text_area(
94
+ "List of Competitors (comma-separated)",
95
+ "Competitor A, Competitor B, Competitor C"
96
+ )
97
+
98
+ if st.button("Start Analysis"):
99
+ st.write("Running Analysis... Please wait.")
100
+
101
+ # Kick off the Crew Process
102
+ inputs = {"company_name": company_name, "competitors": competitor_list.split(",")}
103
+ results = company_analysis_crew.kickoff(inputs=inputs)
104
+
105
+ # Display Results
106
+ st.success("Analysis Completed!")
107
+
108
+ if "final_article.md" in results:
109
+ st.header("Final Analysis Article")
110
+ st.markdown(results["final_article.md"], unsafe_allow_html=True)