Spaces:
Build error
Build error
| from crewai import Agent | |
| from langchain.llms import OpenAI | |
| from langchain.llms import HuggingFaceEndpoint | |
| from dotenv import load_dotenv | |
| load_dotenv() | |
| #from tools.browser_tools import BrowserTools | |
| #from tools.search_tools import SearchTools | |
| repo_id = "mistralai/Mistral-7B-Instruct-v0.2" | |
| mistral = HuggingFaceEndpoint(repo_id=repo_id,max_new_tokens=1024,temperature=0.3,repetition_penalty=1.1) | |
| class ContentAgents(): | |
| def planner_agent(self, topic): | |
| return Agent( | |
| role='Senior Content Planner', | |
| goal='Plan engaging and factually accurate content on {topic}', | |
| backstory= | |
| """You're working on planning a research article about the topic: {topic}. You collect information that helps the audience | |
| learn something and make informed decisions. Your work is the basis for the Content Writer to write an article on this topic.""", | |
| #tools=[ | |
| # SearchTools.search_internet, | |
| # BrowserTools.scrape_and_summarize_website, | |
| #], | |
| llm = mistral, | |
| allow_delegation=False, | |
| verbose=True) | |
| def researcher_agent(self, topic): | |
| return Agent( | |
| role='Market and Domain Research Analyst', | |
| goal=f'Provide up-to-date market analysis and domain knowledge on {topic}', | |
| backstory=f"""You are an expert analyst with a keen eye for market trends. Based on the comprehensive content plan provided by | |
| 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 | |
| domain knowledge. Your work is the basis for the Content Writer to write an article on this topic.""", | |
| #tools=[ | |
| # SearchTools.search_internet, | |
| # BrowserTools.scrape_and_summarize_website, | |
| #], | |
| llm = mistral, | |
| allow_delegation=False, | |
| verbose=True) | |
| def writer_agent(self, topic): | |
| return Agent( | |
| role='Senior Content Writer', | |
| goal=f"""Craft insightful, authentic, compelling and factually accurate engaging opinion piece about the topic: {topic}""", | |
| backstory=f"""You are a skilled writer with years of experience. You're working on writing a new opinion piece about the | |
| topic: {topic}. You base your writing on the work of the Content Planner, who provides an outline and relevant context about | |
| the topic, and the work of the Content Researcher, who provides the domain knowledge and related images about the topic. | |
| You follow the main objectives and direction of the outline, as provided by the Content Planner. You leverage the domain | |
| knowledge and images that come from the Content Researcher. You also provide authentic, objective and impartial insights and | |
| back them up with information provided by the Content Researcher. You acknowledge in your opinion piece when your statements | |
| are opinions as opposed to objective statements. You avoid plagia, you provide references for your citations, and mention | |
| attribution to the images/information coming from others.""", | |
| llm = mistral, | |
| allow_delegation=False, | |
| verbose=True) | |
| '''def editor_agent(self): | |
| return Agent( | |
| role='Senior Editor', | |
| goal="Edit a given article to align with the writing style of the organization.", | |
| backstory="""You are an editor who receives an from the Content Writer. Your goal is to review the article to ensure that | |
| it follows journalistic best practices,provides balanced viewpoints when providing opinions or assertions, and also avoids | |
| harmful topic, major controversial topics or opinions when possible.""", | |
| llm = mistral, | |
| allow_delegation=False, | |
| verbose=True) ''' | |