# Install dependencies:
# pip install crewai crewai-tools
# Set provider credentials, e.g. export OPENAI_API_KEY="your-key"
# Also set export SERPER_API_KEY="your-key" for SerperDevTool.
#
# CrewAI research agent example, following the lab's sequential workflow.

from crewai import Agent, Task, Crew, Process
from crewai_tools import SerperDevTool

topic = "Artificial Intelligence in Healthcare"


def main():
    search_tool = SerperDevTool()
    research_agent = Agent(
        role="Research Agent",
        goal="Research the given topic and collect useful factual information.",
        backstory="You are an AI research agent that searches for relevant information.",
        tools=[search_tool],
        verbose=True,
    )
    research_task = Task(
        description=(
            f"Research the topic: {topic}. "
            "Collect important facts, applications, and benefits. "
            "Include source URLs and note limitations."
        ),
        expected_output="A clear research summary containing important facts and source URLs.",
        agent=research_agent,
    )
    crew = Crew(
        agents=[research_agent],
        tasks=[research_task],
        process=Process.sequential,
        verbose=True,
    )
    result = crew.kickoff()
    print("\nRESEARCH AGENT OUTPUT")
    print(result)


if __name__ == "__main__":
    main()
