Content_Creation / agents.py
SwatGarg's picture
Update agents.py
5c10bd1 verified
from crewai import Agent
from langchain.llms import HuggingFaceEndpoint
import os
from dotenv import load_dotenv
#from tools.image_generation_tools import ImageGenerationTools
#from tools.web_search_tools import WebSearchTools
from web_scraper_tool import web_scraper_tool
#from image_search_tool import image_search_tool
load_dotenv()
secret_token = os.getenv("content")
repo_id = "mistralai/Mistral-7B-Instruct-v0.3"
mistral = HuggingFaceEndpoint(repo_id=repo_id, huggingfacehub_api_token=secret_token, max_new_tokens=28000, temperature=0.3, repetition_penalty=1.1)
from langchain_groq import ChatGroq
# Initialize the Groq LLM
groq_llm = ChatGroq(temperature=0.6, groq_api_key=os.environ.get("groq_api_key"), model_name="llama3-8b-8192")
# Initialize the Tools
#image_generation_tools = ImageGenerationTools()
#web_search_tools = WebSearchTools()
class ContentAgents:
def __init__(self):
self.llm = groq_llm
#self.image_generator = image_generation_tools
def planner_agent(self, topic):
return Agent(
role='Senior Content Planner',
goal=f'Create a detailed and structured content plan for a blog post about {topic} that will guide further content creation steps.',
backstory="You are a seasoned strategist responsible for developing content plans, conducting research, and ensuring the foundation for high-quality articles.",
llm=self.llm,
tools=[web_scraper_tool],
allow_delegation=False,
verbose=True)
def researcher_agent(self, topic):
return Agent(
role='Market and Domain Research Analyst',
goal=f'Provide accurate and up-to-date domain knowledge and image references for the topic {topic} to support content creation.',
backstory="You are a seasoned strategist responsible for developing content plans, conducting research, and ensuring the foundation for high-quality articles.",
llm=self.llm,
tools=[web_scraper_tool],
allow_delegation=False,
verbose=True)
def writer_agent(self, topic):
return Agent(
role='Senior Content Writer',
goal=f'Write a high-quality, engaging, and informative blog post on {topic}, based on the content plan and research provided.',
backstory="You are a seasoned strategist responsible for developing content plans, conducting research, and ensuring the foundation for high-quality articles.",
llm=self.llm,
#tools=[image_search_tool],
allow_delegation=False,
verbose=True)