Note: This project is an educational proof of concept exploring AI-driven content generation and workflow automation using LangGraph and Ollama.
An intelligent agent that transforms plain text into engaging LinkedIn posts through an iterative, feedback-driven approach. Built with LangGraph and Ollama, it demonstrates how AI can simulate a team of content experts working together.
- Python 3.11+
- Ollama installed and running
- Required Ollama model:
llama3:latest
# Clone the repository
git clone [REPO_URL]
cd linkedin-agent
# Create and activate virtual environment
python -m venv venv
source venv/bin/activate # or `venv\Scripts\activate` on Windows
# Install dependencies
pip install -e .
# Start Ollama service
ollama serve
# Pull required model
ollama pull llama3:latest
uvicorn src.api:app --reload
The API will be available at http://localhost:8000
curl -X POST http://localhost:8000/generate \
-H "Content-Type: application/json" \
-d '{
"text": "We are launching a new AI product",
"target_audience": "Tech leaders",
"n_drafts": 3
}'
Response:
{
"final_post": "...",
"all_versions": [
{
"version": 1,
"content": "...",
"feedback": null
}
],
"workflow_status": "completed"
}
curl http://localhost:8000/health
Response:
{
"status": "healthy",
"timestamp": "2024-12-27T09:00:00.000Z",
"version": "1.0.0",
"environment": {
"python_version": "3.11.0",
"platform": "..."
},
"services": {
"ollama": {
"status": "healthy",
"model": "llama3:latest",
"available": true,
"available_models": ["llama3:latest", "..."]
}
},
"system": {
"cpu_usage": 45.2,
"memory": {
"total": 17179869184,
"available": 8589934592,
"percent": 50.0
},
"disk": {
"total": 499963174912,
"free": 374972680192,
"percent": 25.0
}
}
}
# Build and start services
docker-compose up --build
# The services will be available at:
# - API: http://localhost:8000
# - Ollama: http://localhost:11434
- Self-contained environment with all dependencies
- Automatic model download during build
- Persistent model storage
- Health monitoring
- Automatic service orchestration
OLLAMA_BASE_URL=http://localhost:11434
# View logs
docker-compose logs -f
# Stop services
docker-compose down
# Remove volumes (will delete downloaded models)
docker-compose down -v
-
API Layer (
src/api.py
)- FastAPI application
- Health monitoring
- Request validation
-
Workflow Engine (
src/workflow.py
)- LangGraph state management
- Node orchestration
- Conditional routing
-
AI Agents (
src/services/linkedin_agent.py
)- Editor: Improves text clarity
- Writer: Creates LinkedIn-optimized content
- Critic: Provides feedback
- Supervisor: Manages iterations
-
Models (
src/models/
)- State management
- Post structure
- Configuration
Key parameters in src/utils/constants.py
:
OLLAMA_MODEL = "llama3:latest"
OLLAMA_TEMPERATURE = 0.7
MAX_POST_LENGTH = 1300
MIN_HASHTAGS = 3
MAX_HASHTAGS = 5
This project is released under the MIT License.
This is a proof of concept for educational purposes. While it demonstrates interesting possibilities in AI-driven content generation, it should not be considered production-ready software.