Skip to content

Feguna-1103/Conflict-Simulation-Lab

Repository files navigation

🎭 Conflict Conversation Generator

A Python project that simulates realistic conflict conversations between two virtual agents with configurable personality traits. Uses RAG (Retrieval-Augmented Generation) to create contextually relevant dialogues based on personality examples.

✨ Features

  • 🎭 Multiple Personality Types: Aggressive, defensive, passive, open-minded, emotional, logical
  • πŸ” RAG System: Retrieves relevant personality examples using embeddings
  • πŸ€– Dual Generation: Local LLM (Mistral-7B/Zephyr) + OpenAI integration
  • πŸ’¬ Topic-Specific: Realistic conflicts about household chores, money, parenting, etc.
  • πŸ”„ Interactive CLI: Easy-to-use command-line interface
  • πŸ“Š ARM Compatible: Works on Apple Silicon Macs without FAISS issues
  • πŸ†“ Free & Open Source: No paid APIs required (OpenAI optional)

πŸš€ Quick Start

1. Installation

# Clone the repository
git clone <your-repo-url>
cd Conflict-Simulation-Lab

# Install backend dependencies
pip install -r backend/requirements.txt

2. Basic Usage

# Interactive mode (recommended)
python run_rag_system.py --interactive

# Command line mode
python run_rag_system.py --personality-a aggressive --personality-b defensive --topic "money and financial decisions"

# List available personalities
python run_rag_system.py --list-personalities

3. OpenAI Enhancement (Optional)

For more realistic, topic-specific conversations:

# Set your OpenAI API key
export OPENAI_API_KEY="your-api-key-here"

# Use OpenAI for generation
python run_rag_system.py --interactive --use-openai

# Or specify directly
python run_rag_system.py --personality-a aggressive --personality-b defensive --topic "parenting styles" --use-openai

🎯 How It Works

Current System (Local LLM)

  1. Embedding: Converts personality examples to vectors
  2. Retrieval: Finds most relevant examples for each personality
  3. Generation: Local LLM creates dialogue using retrieved examples
  4. Result: Personality-styled conversation (may be generic)

OpenAI Enhanced System

  1. Topic Analysis: Understands specific conflict scenarios
  2. Context Integration: Combines personality + topic context
  3. Realistic Generation: Creates topic-specific arguments
  4. Result: Realistic, topic-aware conflict conversations

πŸ“Š Comparison: Local vs OpenAI

Aspect Local LLM OpenAI
Topic Specificity Generic conflicts Realistic, topic-aware
Cost Free ~$0.002 per conversation
Speed Slower (local processing) Fast (API)
Quality Good personality style Excellent realism
Privacy 100% local Data sent to OpenAI

🎭 Available Personalities

  • Aggressive: Confrontational, direct, forceful
  • Defensive: Protective, justifying, reactive
  • Passive: Yielding, non-confrontational, submissive
  • Open-minded: Receptive, compromising, understanding
  • Emotional: Feeling-driven, expressive, sensitive
  • Logical: Analytical, fact-based, systematic

πŸ’¬ Conversation Topics

  • Household chores and responsibilities
  • Money and financial decisions
  • Parenting styles and discipline
  • Work-life balance
  • Social plans and commitments
  • Custom topics

πŸ› οΈ Project Structure

Conflict-Simulation-Lab/
β”œβ”€β”€ run_rag_system.py          # Main runner script
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ main.py               # Flask API server
β”‚   β”œβ”€β”€ requirements.txt      # Backend dependencies
β”‚   └── models/               # AI model implementations
β”‚       β”œβ”€β”€ __init__.py       # Package initialization
β”‚       β”œβ”€β”€ rag_consumer_complaints.py  # Main RAG system
β”‚       β”œβ”€β”€ compare_enhanced_rag.py     # Comparison script
β”‚       β”œβ”€β”€ requirements_enhanced_rag.txt # Model dependencies
β”‚       └── ENHANCED_RAG_README.md      # Model documentation
β”œβ”€β”€ frontend/                 # React frontend application
β”œβ”€β”€ data/
β”‚   β”œβ”€β”€ personality_index.pkl  # Embedding index
β”‚   └── style_examples.json    # Personality examples
└── README.md                 # This file

πŸ”§ Advanced Usage

Testing Different Systems

Compare local vs OpenAI generation

python test_openai_comparison.py

Test topic specificity

python test_openai_comparison.py

Custom Personalities

Edit data/style_examples.json to add new personality types:

{
  "sarcastic": {
    "description": "Uses irony and wit in communication",
    "tone": "Ironic, witty, sometimes cutting",
    "examples": [
      "Oh, great. Another brilliant idea.",
      "Well, that went exactly as planned...",
      "I'm shocked, shocked I tell you."
    ]
  }
}

LangChain Integration

For advanced features like conversation memory and chaining:

Install LangChain version

pip install -r requirements_langchain.txt

Run LangChain version

python langchain_integration.py

🎯 RAG System Explanation

The system uses Retrieval-Augmented Generation to improve dialogue quality:

  1. Retrieval: Finds relevant personality examples from the database
  2. Augmentation: Combines examples with the generation prompt
  3. Generation: Creates dialogue that matches the retrieved style

Why it works better:

  • Provides concrete examples of how each personality communicates
  • Ensures consistency in personality expression
  • Improves topic relevance when combined with OpenAI

πŸš€ Strengthening the RAG System

1. Expand the Database

  • Add more personality examples
  • Include topic-specific examples
  • Add conversation context examples

2. Improve Retrieval

  • Use better embedding models
  • Implement reranking
  • Add semantic search

3. Enhanced Generation

  • Use larger models (GPT-4, Claude)
  • Implement conversation memory
  • Add multi-turn dialogue

πŸ”‘ OpenAI Setup

  1. Get API Key: Visit OpenAI Platform
  2. Set Environment Variable:
    export OPENAI_API_KEY="your-key-here"
  3. Test Integration:
    python test_openai_comparison.py

πŸ› Troubleshooting

Common Issues

Segmentation Fault on ARM Mac:

  • The system is designed to work without FAISS
  • Uses pure numpy-based retrieval
  • Should work on Apple Silicon without issues

OpenAI API Errors:

  • Check your API key is valid
  • Ensure you have sufficient credits
  • Verify internet connection

Local Generation Issues:

  • Check model downloads
  • Verify sufficient RAM (8GB+ recommended)
  • Try different models in generate.py

Performance Tips

  • Local: Use GPU if available for faster generation
  • OpenAI: Batch requests to reduce API calls
  • Memory: Close other applications for local generation

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Add your improvements
  4. Test thoroughly
  5. Submit a pull request

πŸ“„ License

This project is open source and available under the MIT License.

πŸ™ Acknowledgments

  • Hugging Face for open-source models
  • OpenAI for enhanced generation capabilities
  • SentenceTransformers for embeddings
  • The open-source community for tools and libraries

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5