parthib11 commited on
Commit
97f0b2a
·
verified ·
1 Parent(s): 02cfbe6

initial commit

Browse files
Files changed (5) hide show
  1. agents.py +49 -0
  2. crew.py +35 -0
  3. requirements.txt +6 -0
  4. tasks.py +30 -0
  5. tools.py +10 -0
agents.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from crewai import Agent
2
+ from tools import tool
3
+ from dotenv import load_dotenv
4
+ load_dotenv()
5
+ from langchain_google_genai import ChatGoogleGenerativeAI
6
+ import os
7
+
8
+
9
+
10
+
11
+ llm = ChatGoogleGenerativeAI(
12
+ model="gemini-1.5-flash",
13
+ verbose=True,
14
+ temperature=0.5,
15
+ google_api_key = os.getenv("GOOGLE_API_KEY"),
16
+ )
17
+
18
+ researcher = Agent(
19
+ role="senior expert researcher",
20
+ goal="To break down broad visionary ideas into specific, actionable research topics about {topic}, identify key areas requiring in-depth investigation, and prepare report that serves as a roadmap for future goals.: {topic}",
21
+ verbose=True,
22
+ memory=True,
23
+ backstory=("you are a ecperienced researcher in a very prestigious research facility of the world. You have experience of over 30 years. You always have a lot of knowledge about the recent inventions and developments of various cutting edge technologies."),
24
+ max_iter=10,
25
+ tools=[tool],
26
+ llm=llm,
27
+ allow_delegation = False,
28
+ )
29
+
30
+ news_writer = Agent(
31
+ role='senior writer',
32
+ goal = "narrate compelling tech stories about {topic}. Organise the results neatly and give bullet point when possible.",
33
+ verbose=True,
34
+ memory=True,
35
+ backstory=("With a flair of simplifying complex topics you craft engaging narratives that captivate and educate, bringing new new discoveries and inventions to the light in an accessible manner"),
36
+ tools=[tool],
37
+ llm=llm,
38
+ allow_delegation = False,
39
+ )
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
crew.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from crewai import Crew,Process
2
+ from tasks import research_task,write_task
3
+ from agents import researcher,news_writer
4
+ import streamlit as st
5
+ ## Forming the tech focused crew with some enhanced configuration
6
+ crew=Crew(
7
+ agents=[researcher,news_writer],
8
+ tasks=[research_task,write_task],
9
+ process=Process.sequential,
10
+
11
+ )
12
+
13
+ ## starting the task execution process wiht enhanced feedback
14
+
15
+
16
+ st.title('Your Research Assistant')
17
+ with st.sidebar:
18
+ st.header('Enter Research Details')
19
+ topic = st.text_input("Main topic of your research:")
20
+ #detailed_questions = st.text_area("Specific questions or subtopics you are interested in exploring:")
21
+
22
+ if st.button('Run Research'):
23
+ if not topic :
24
+ st.error("Please fill all the fields.")
25
+ else:
26
+ #inputs = f"Research Topic: {topic}\nDetailed Questions: {detailed_questions}"
27
+ result=crew.kickoff(inputs={'topic':topic})
28
+ # result=crew.kickoff(inputs=inputs)
29
+ st.header("Results of your research project:")
30
+ st.markdown(result)
31
+
32
+
33
+ #F:/anaconda_installed/Scripts/activate
34
+ #conda activate C:\Users\parth\OneDrive\Desktop\llmProjects\YT_Agents\agentenvconda
35
+
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+
2
+ crewai
3
+ crewai_tools
4
+ load_dotenv
5
+ langchain_google_genai
6
+ streamlit
tasks.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from crewai import Task
2
+ from tools import tool
3
+ from agents import researcher,news_writer
4
+
5
+ # Research task
6
+ research_task = Task(
7
+ description=(
8
+ "Based on the topic {topic},figure out what it is that the user needs in order to figure out their problem"
9
+ "Make sure not to put exact same input multiple time while searching the internet.Focus on identifying pros and cons and the overall narrative."
10
+ "Your final report should clearly articulate the key points, recent advancements or news about {topic}."
11
+ # "its market opportunities, and potential risks."
12
+ ),
13
+ expected_output='A clear explanation of the principles, concepts, disciplines, and skills needed by the visionary in order to accomoplish their goal. Prepare a 2 page long report.',
14
+ tools=[tool],
15
+ agent=researcher,
16
+ )
17
+
18
+ # Writing task with language model configuration
19
+ write_task = Task(
20
+ description=(
21
+ "Compose an insightful article on {topic}."
22
+ "Focus on the latest trends and how it's impacting the world."
23
+ "This article should be easy to understand, engaging, and positive."
24
+ ),
25
+ expected_output='An article on {topic} , 5 principles and concepts reviewed and thoroughly explaiened. At the end provide 5 internet articles titles and their URL',
26
+ tools=[tool],
27
+ agent=news_writer,
28
+ async_execution=False,
29
+ #output_file='new-blog-post.md' # Example of output customization
30
+ )
tools.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ from dotenv import load_dotenv
2
+ load_dotenv()
3
+ import os
4
+
5
+ os.environ['SERPER_API_KEY']=os.getenv('SERPER_API_KEY')
6
+
7
+
8
+ from crewai_tools import SerperDevTool
9
+
10
+ tool=SerperDevTool()