An Autonomous AI System for Generating Humorous & Viral Tweets using Open-Source LLMs
Tweeting Agent is an AI-powered system designed to help users generate humorous, engaging, and potentially viral tweets on any given topic. It leverages open-source Large Language Models (LLMs) orchestrated through LangGraph, enabling an iterative generate → evaluate → optimize workflow.
Unlike single-prompt tweet generators, Tweeting Agent behaves like a creative loop, refining tweets over multiple iterations until the best possible version emerges.
- 🤖 Multi-Agent Architecture using LangGraph
- 🔁 Iterative Improvement Loop (Generator → Evaluator → Optimizer)
- 🧠 Fully Open-Source LLM Stack via Ollama
- 🎯 Optimized for humor, virality, clarity, and engagement
- ⚡ Modular, extensible, and framework-agnostic design
- 🧪 Easy experimentation with different models, prompts, and scoring logic
The Tweeting Agent uses three specialized LLM roles, each optimized for a specific task:
-
Model:
gpt-oss:20b -
Purpose: Generates creative, humorous tweets based on the user-provided topic.
-
Strengths:
- Strong generative creativity
- Produces multiple candidate tweets
- Explores diverse humorous angles
generator_model = ChatOllama(model="gpt-oss:20b")-
Model:
llama3.1:latest -
Purpose: Critically evaluates generated tweets based on predefined quality metrics.
-
Evaluation Criteria:
- Humor
- Virality potential
- Clarity
- Brevity
- Relevance to topic
evaluator_model = ChatOllama(model="llama3.1:latest")-
Model:
llama3.2:3b -
Purpose: Refines tweets using evaluator feedback, improving punchlines, wording, and structure.
-
Why a smaller model?
- Faster iterations
- Lower compute cost
- Ideal for targeted rewriting and fine-tuning
optimizer_model = ChatOllama(model="llama3.2:3b")The entire system is orchestrated using LangGraph, enabling a clean, stateful, and iterative agent flow.
- Input Topic
- Tweet Generation
- Tweet Evaluation
- Tweet Optimization
- Quality Check
- Repeat until optimal tweet is achieved
graph TD
A[User Topic] --> B[Generator Agent]
B --> C[Evaluator Agent]
C --> D[Optimizer Agent]
D --> C
C -->|Meets Quality Threshold| E[Final Tweet]
| Component | Technology |
|---|---|
| Agent Framework | LangGraph |
| LLM Provider | Ollama |
| Generator Model | gpt-oss:20b |
| Evaluator Model | llama3.1 |
| Optimizer Model | llama3.2:3b |
| Language | Python |
- Python 3.9+
- Ollama installed locally
- Required models pulled via Ollama
ollama pull gpt-oss:20b
ollama pull llama3.1
ollama pull llama3.2:3bpython main.py --topic "AI replacing human jobs"“AI won’t take your job. It’ll just ask for your help… then quietly stop replying.”
- Demonstrates agentic AI design patterns
- Real-world use of LangGraph
- Easy to extend with more agents or evaluation criteria
- Generates high-quality, funny tweets
- Reduces creative fatigue
- Increases engagement potential
- Experiment with self-improving LLM systems
- Compare multi-model collaboration vs single-model prompting
- LangGraph for agent orchestration
- Ollama for local, open-source LLM inference
- The open-source LLM community ❤️