How nebeyoumusie/news-ai-agents-using-crewai-and-google-gemini-pro-llm-models works
Project Type and Purpose
• This is a Python-based AI agent application (CLI/automation script) that orchestrates multiple tools and LLM calls to generate news articles.
• Key parts: CrewAI framework (agents, tasks, tools), Google Gemini Pro LLM, Serper web search API, output writer.
File Structure
• Top-level:
• README.md – project overview
• requirements.txt – dependencies
• crew/ – core Python modules
• news.md – generated output
• Inside crew/:
• crew.py – main orchestrator script (entry point)
• agents.py – defines the AI agent(s) and agent policies
• tasks.py – encapsulates individual “task” definitions assigned to agents
• tools.py – wraps external capabilities (search API, LLM calls, file I/O)
Extract Additional Insights from README
• Dependencies include crewai (agent framework), crewai-tools (prebuilt tools), langchain-google-genai (Gemini adapter), python-dotenv, streamlit.
• Workflow: user runs python crew/crew.py → agent uses CrewAI tools + Gemini Pro model + Serper API → generates news content → writes news.md.
Main Components
a. User/Runner (CLI or Streamlit if used)
b. crew.py (Orchestrator)
c. CrewAI Agent
d. Task Engine (tasks.py)
e. Toolset (tools.py):
• Google Gemini Pro LLM via langchain-google-genai
• Serper Search API
• File Writer (markdown)
f. External Services:
• Google Gemini Pro API
• Serper API
g. Output Storage: news.md (local file system)
h. Configuration Loader: python-dotenv (loads .env variables)
Relationships & Data Flows
• User invokes crew.py
• crew.py initializes:
• Loads .env (dotenv)
• Registers Agent (agents.py)
• Registers Tasks (tasks.py)
• Registers Tools (tools.py)
• Agent → Task Engine: determines steps (e.g., “search headlines,” “compose article”)
• Task Engine → Tools: calls Serper API or Gemini API as needed
• Tools → External Services: HTTP calls to Serper & Gemini Pro
• Tools receive responses → return data to Agent
• Agent collates results → calls File Writer → writes news.md
Architectural Patterns & Principles
• Modular layering: orchestrator → agent logic → tasks → tools → external APIs
• Separation of concerns:
• Agents focus on high-level strategy
• Tasks focus on discrete actions
• Tools focus on external integration
• Dependency injection: crew.py wires modules together
Essential Elements
• Component labels: crew.py, agents.py, tasks.py, tools.py, External APIs, news.md