SwatGarg commited on
Commit
ec94d77
·
verified ·
1 Parent(s): 71053a5

Update agents.py

Browse files
Files changed (1) hide show
  1. agents.py +71 -70
agents.py CHANGED
@@ -1,70 +1,71 @@
1
- from crewai import Agent
2
- from langchain.llms import OpenAI
3
- from langchain.llms import HuggingFaceEndpoint
4
- from dotenv import load_dotenv
5
- load_dotenv()
6
- #from tools.browser_tools import BrowserTools
7
- #from tools.search_tools import SearchTools
8
- repo_id = "mistralai/Mistral-7B-Instruct-v0.2"
9
- mistral = HuggingFaceEndpoint(repo_id=repo_id,max_new_tokens=1024,temperature=0.3,repetition_penalty=1.1)
10
-
11
- class ContentAgents():
12
-
13
- def planner_agent(self, topic):
14
- return Agent(
15
- role='Senior Content Planner',
16
- goal='Plan engaging and factually accurate content on {topic}',
17
- backstory=
18
- """You're working on planning a research article about the topic: {topic}. You collect information that helps the audience
19
- learn something and make informed decisions. Your work is the basis for the Content Writer to write an article on this topic.""",
20
- #tools=[
21
- # SearchTools.search_internet,
22
- # BrowserTools.scrape_and_summarize_website,
23
- #],
24
- llm = mistral,
25
- allow_delegation=False,
26
- verbose=True)
27
-
28
-
29
- def researcher_agent(self, topic):
30
- return Agent(
31
- role='Market and Domain Research Analyst',
32
- goal=f'Provide up-to-date market analysis and domain knowledge on {topic}',
33
- backstory=f"""You are an expert analyst with a keen eye for market trends. Based on the comprehensive content plan provided by
34
- the Planner, your do web searches on the topic {topic} in order to find compelling images as well as provide precise and up-to-date
35
- domain knowledge. Your work is the basis for the Content Writer to write an article on this topic.""",
36
- #tools=[
37
- # SearchTools.search_internet,
38
- # BrowserTools.scrape_and_summarize_website,
39
- #],
40
- llm = mistral,
41
- allow_delegation=False,
42
- verbose=True)
43
-
44
- def writer_agent(self, topic):
45
- return Agent(
46
- role='Senior Content Writer',
47
- goal=f"""Craft insightful, authentic, compelling and factually accurate engaging opinion piece about the topic: {topic}""",
48
- backstory=f"""You are a skilled writer with years of experience. You're working on writing a new opinion piece about the
49
- topic: {topic}. You base your writing on the work of the Content Planner, who provides an outline and relevant context about
50
- the topic, and the work of the Content Researcher, who provides the domain knowledge and related images about the topic.
51
- You follow the main objectives and direction of the outline, as provided by the Content Planner. You leverage the domain
52
- knowledge and images that come from the Content Researcher. You also provide authentic, objective and impartial insights and
53
- back them up with information provided by the Content Researcher. You acknowledge in your opinion piece when your statements
54
- are opinions as opposed to objective statements. You avoid plagia, you provide references for your citations, and mention
55
- attribution to the images/information coming from others.""",
56
- llm = mistral,
57
- allow_delegation=False,
58
- verbose=True)
59
-
60
-
61
- '''def editor_agent(self):
62
- return Agent(
63
- role='Senior Editor',
64
- goal="Edit a given article to align with the writing style of the organization.",
65
- backstory="""You are an editor who receives an from the Content Writer. Your goal is to review the article to ensure that
66
- it follows journalistic best practices,provides balanced viewpoints when providing opinions or assertions, and also avoids
67
- harmful topic, major controversial topics or opinions when possible.""",
68
- llm = mistral,
69
- allow_delegation=False,
70
- verbose=True) '''
 
 
1
+ from crewai import Agent
2
+ from langchain.llms import OpenAI
3
+ from langchain.llms import HuggingFaceEndpoint
4
+ from dotenv import load_dotenv
5
+ load_dotenv()
6
+ secret_token = os.getenv("Content")
7
+ #from tools.browser_tools import BrowserTools
8
+ #from tools.search_tools import SearchTools
9
+ repo_id = "mistralai/Mistral-7B-Instruct-v0.2"
10
+ mistral = HuggingFaceEndpoint(repo_id=repo_id, huggingfacehub_api_token = secret_token,temperature=0.3,repetition_penalty=1.1)
11
+
12
+ class ContentAgents():
13
+
14
+ def planner_agent(self, topic):
15
+ return Agent(
16
+ role='Senior Content Planner',
17
+ goal='Plan engaging and factually accurate content on {topic}',
18
+ backstory=
19
+ """You're working on planning a research article about the topic: {topic}. You collect information that helps the audience
20
+ learn something and make informed decisions. Your work is the basis for the Content Writer to write an article on this topic.""",
21
+ #tools=[
22
+ # SearchTools.search_internet,
23
+ # BrowserTools.scrape_and_summarize_website,
24
+ #],
25
+ llm = mistral,
26
+ allow_delegation=False,
27
+ verbose=True)
28
+
29
+
30
+ def researcher_agent(self, topic):
31
+ return Agent(
32
+ role='Market and Domain Research Analyst',
33
+ goal=f'Provide up-to-date market analysis and domain knowledge on {topic}',
34
+ backstory=f"""You are an expert analyst with a keen eye for market trends. Based on the comprehensive content plan provided by
35
+ the Planner, your do web searches on the topic {topic} in order to find compelling images as well as provide precise and up-to-date
36
+ domain knowledge. Your work is the basis for the Content Writer to write an article on this topic.""",
37
+ #tools=[
38
+ # SearchTools.search_internet,
39
+ # BrowserTools.scrape_and_summarize_website,
40
+ #],
41
+ llm = mistral,
42
+ allow_delegation=False,
43
+ verbose=True)
44
+
45
+ def writer_agent(self, topic):
46
+ return Agent(
47
+ role='Senior Content Writer',
48
+ goal=f"""Craft insightful, authentic, compelling and factually accurate engaging opinion piece about the topic: {topic}""",
49
+ backstory=f"""You are a skilled writer with years of experience. You're working on writing a new opinion piece about the
50
+ topic: {topic}. You base your writing on the work of the Content Planner, who provides an outline and relevant context about
51
+ the topic, and the work of the Content Researcher, who provides the domain knowledge and related images about the topic.
52
+ You follow the main objectives and direction of the outline, as provided by the Content Planner. You leverage the domain
53
+ knowledge and images that come from the Content Researcher. You also provide authentic, objective and impartial insights and
54
+ back them up with information provided by the Content Researcher. You acknowledge in your opinion piece when your statements
55
+ are opinions as opposed to objective statements. You avoid plagia, you provide references for your citations, and mention
56
+ attribution to the images/information coming from others.""",
57
+ llm = mistral,
58
+ allow_delegation=False,
59
+ verbose=True)
60
+
61
+
62
+ '''def editor_agent(self):
63
+ return Agent(
64
+ role='Senior Editor',
65
+ goal="Edit a given article to align with the writing style of the organization.",
66
+ backstory="""You are an editor who receives an from the Content Writer. Your goal is to review the article to ensure that
67
+ it follows journalistic best practices,provides balanced viewpoints when providing opinions or assertions, and also avoids
68
+ harmful topic, major controversial topics or opinions when possible.""",
69
+ llm = mistral,
70
+ allow_delegation=False,
71
+ verbose=True) '''