Spaces:
Build error
Build error
Initial Commit
Browse filesFiles changed (5)
- agents.pyAdded+53
- crew.pyAdded+90
- requirements.txtAdded+5
- tasks.pyAdded+30
- tools.pyAdded+8
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253from crewai import Agent
from dotenv import load_dotenv
from langchain_groq import ChatGroq
import os
from tools import tool
load_dotenv()
llm = ChatGroq(
model = "groq/llama-3.1-8b-instant",
verbose = True,
temperature = 0.5,
)
## Creating a researcher agent who is responsible to dig the details of particular
## topic in detail
News_Researcher = Agent(
role = "Senior Researcher",
goal = "uncover ground breaking Technologies in {topic}",
verbose = True,
memory = True,
backstory = (
"""
Driven by curiosity, you are at forefront of the innovation,
eager to explore and share knowledge that could change the world
"""
),
tools = [tool],
llm = llm,
allow_delegation = True,
)
## Creating a writer agent with custom tools responsible in writing news blog
News_Writer = Agent(
role = 'Writer',
goal = 'Narrate compelling tech stories about {topic}',
verbose = True,
memory = True,
backstory = (
"""
With a Flair for simplifying complex topics, you craft engaging
narratives that captivate and educate, bringing new discoveries to light
in an accessible manner.
"""
),
tools = [tool],
llm = llm,
allow_delegations = False
)
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990import streamlit as st
from crewai import Crew, Process
from pydantic import BaseModel
from agents import News_Researcher, News_Writer
from tasks import Research_task, Write_task
from tools import tool
st.set_page_config(page_title="CrewAI Article Generator", page_icon="📝", layout="wide")
st.markdown("""
<style>
.reportview-container {
background: #f0f2f6
}
.main {
background: #00000;
padding: 3rem;
border-radius: 10px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.stButton>button {
background-color: #0000;
color: white;
border-radius: 5px;
}
.stTextInput>div>div>input {
border-radius: 5px;
}
.sidebar .sidebar-content {
background-color: #f8f9fa;
}
</style>
""", unsafe_allow_html=True)
st.sidebar.title("📊 API Configuration")
st.sidebar.markdown("Enter your API keys below:")
serper_api_key = st.sidebar.text_input("Serper API Key", type="password")
groq_api_key = st.sidebar.text_input("Groq API Key", type="password")
if st.sidebar.button("Save API Keys"):
if serper_api_key and groq_api_key:
st.sidebar.success("API keys saved successfully!")
else:
st.sidebar.error("Please enter both API keys.")
st.title("📝 Culprit ")
st.markdown("This is an Agent which can write articles for your blog on any Topic - Have a Try")
topic = st.text_input("Enter a topic for your article:", placeholder="e.g., Space exploration, Climate change, Artificial intelligence")
if st.button("Generate Article"):
if not serper_api_key or not groq_api_key:
st.error("Please enter both API keys in the sidebar before generating an article.")
elif not topic:
st.warning("Please enter a topic before generating the article.")
else:
progress_bar = st.progress(0)
crew = Crew(
agents=[News_Researcher, News_Writer],
tasks=[Research_task, Write_task],
process=Process.sequential,
)
with st.spinner(f"Researching and writing the article about '{topic}'..."):
progress_bar.progress(50)
result = crew.kickoff(inputs={'topic': topic})
progress_bar.progress(100)
st.subheader("Generated Article:")
if isinstance(result, str):
article_text = result
elif isinstance(result, dict) and 'article' in result:
article_text = result['article']
else:
article_text = str(result)
st.markdown(article_text)
st.download_button(
label="Download Article",
data=article_text,
file_name=f"{topic.replace(' ', '_').lower()}_article.txt",
mime="text/plain"
)
st.markdown("---------")
st.markdown("Created using CrewAI with ❤️ by BLJP ")12345crewai
langchain-groq
load_dotenv
crewai_tools
streamlit123456789101112131415161718192021222324252627282930from crewai import Task
from tools import *
from agents import *
Research_task = Task(
description = (
'''
Identify the next big trend in {topic}.Focus in Identifying the pros and cons
and the overall narrative.Your final report should clearly articulate the key points,
its market opportunities, and potential risks.
'''
),
expected_output = 'A Comprehensive 13 paragraphs long report on the latest AI Trends',
tools = [tool],
agent = News_Researcher,
)
Write_task = Task(
description = (
'''
Compose an insightful article on {topic}.Focus on the latest trends
and how it's impacting the industry.This article should be easy to understand,engaging and positive.
'''
),
expected_output = 'A paragraph article on {topic} advancements in around 12 to 14 paragraphs formatted as markdown',
tools = [tool],
agent = News_Writer,
async_execution = False,
output_file = 'new-blog-post.md'
)12345678import os
from crewai_tools import SerperDevTool
from dotenv import load_dotenv
load_dotenv()
os.environ['SERPER_API_KEY'] = os.getenv('SERPER_API_KEY')
tool = SerperDevTool()agents.pyAdded+53
crew.pyAdded+90
requirements.txtAdded+5
tasks.pyAdded+30
tools.pyAdded+8