SwatGarg commited on
Commit
b5780f7
·
verified ·
1 Parent(s): 2201ef3

Upload agents.py

Browse files
Files changed (1) hide show
  1. images/agents.py +70 -0
images/agents.py ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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) '''