Skip to content

ravikiranediga/llm-writer-critic-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LLM Writer-Critic System

An agentic joke generation application powered by Groq's LLaMA model, featuring a dual-agent architecture with independent writer and critic roles for quality-controlled humor generation.

Overview

This project implements a sophisticated Writer-Critic pattern for generating high-quality jokes. The system uses two specialized LLM agents:

  • Writer Agent: Generates creative, original jokes with high creativity settings (temperature: 0.9)
  • Critic Agent: Reviews jokes against quality criteria with strict, deterministic evaluation (temperature: 0.0)
graph TD
    A[User Request] --> B[Writer Agent]
    B -->|Generate Joke| C[Critic Agent]
    C -->|Approved| D[Display Joke]
    C -->|Rejected| E[Retry Loop]
    E -->|Max Retries| F[Fail]
    E -->|Retry| B
    
    B -.->|Temperature 0.9| G[High Creativity]
    C -.->|Temperature 0.0| H[Strict Evaluation]
Loading

Features

  • Multi-category jokes: programming, dad jokes, dark humor, one-liners, slapstick, knock-knock, tech, career, relationships, random
  • Multi-language support: English, Spanish, French, German, Italian, Portuguese, Hindi, Japanese, Chinese, Korean, Russian, Arabic, Tamil, Telugu
  • Quality control: Automatic review against humor, appropriateness, category match, originality, and language criteria
  • Retry mechanism: Up to 3 attempts per joke with feedback integration
  • Interactive CLI: User-friendly menu for category/language selection

Project Structure

llm-writer-critic-system/
├── README.md              # This file
├── requirements.txt       # Python dependencies
├── config.yaml            # Configuration settings
├── .env.example           # Environment template
└── app/
    ├── __init__.py
    ├── main.py            # Main CLI application
    ├── llm.py             # LLM initialization & validation
    ├── writer.py          # Writer agent for joke generation
    └── critic.py          # Critic agent for quality review

Installation

  1. Clone the repository

    cd llm-writer-critic-system
  2. Create virtual environment

    python -m venv venv
    source venv/bin/activate  # Linux/Mac
    # or
    .\venv\Scripts\activate   # Windows
  3. Install dependencies

    pip install -r requirements.txt
  4. Configure environment

    cp .env.example .env
    # Edit .env and add your Groq API key

Configuration

Edit config.yaml to customize:

  • LLM provider and model settings
  • Temperature parameters (writer creativity vs. critic strictness)
  • Application defaults (max retries, categories, languages)
  • Logging preferences

Usage

python -m app.main

Controls

  • n - Generate next joke
  • c - Change category
  • l - Change language
  • m - Show full menu
  • e - Exit

Architecture Details

Writer Agent (app/writer.py)

Generates jokes using a carefully crafted prompt with:

  • Category-specific descriptions
  • Language targeting
  • Previous attempt avoidance
  • Creative temperature (0.9)

Critic Agent (app/critic.py)

Evaluates jokes against six criteria:

  1. Funny - Genuine humor
  2. Appropriate - Clean and suitable
  3. Category Match - Fits the theme
  4. Original - Creative, not clichéd
  5. Concise - Short (1-3 lines)
  6. Language - Correctly written

LLM Interface (app/llm.py)

Uses LangChain's ChatGroq integration with Groq's llama-3.1-8b-instant model.

Requirements

  • Python 3.8+
  • Groq API key (get one here)
  • Dependencies: langchain-groq, python-dotenv, langchain-core

License

MIT License

About

An agentic joke generation application powered by Groq's LLaMA model, featuring a dual-agent architecture with independent writer and critic roles for quality-controlled humor generation.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages