# Install dependencies:
# pip install crewai
# Set provider credentials, e.g. export OPENAI_API_KEY="your-key"
#
# CrewAI writer agent. A research agent supplies context to the writer.

from crewai import Agent, Task, Crew, Process

topic = "Agentic AI"


def main():
    research_agent = Agent(
        role="Research Agent",
        goal="Provide useful information on the given topic.",
        backstory="You collect relevant information for the writer agent.",
        verbose=True,
    )
    writer_agent = Agent(
        role="Writer Agent",
        goal="Convert research information into a clear and well-structured article.",
        backstory="You are an expert technical writer.",
        verbose=True,
    )
    research_task = Task(
        description=f"Research and explain the topic: {topic}.",
        expected_output="A concise set of facts and key points about Agentic AI.",
        agent=research_agent,
    )
    writing_task = Task(
        description=(
            "Using the research provided by the previous task, "
            "write a short, well-structured article on Agentic AI."
        ),
        expected_output="A clear article with an introduction, main points, and conclusion.",
        agent=writer_agent,
        context=[research_task],
    )
    crew = Crew(
        agents=[research_agent, writer_agent],
        tasks=[research_task, writing_task],
        process=Process.sequential,
        verbose=True,
    )
    result = crew.kickoff()
    print("\nWRITER AGENT OUTPUT")
    print(result)


if __name__ == "__main__":
    main()
