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.
- π 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)
# Clone the repository
git clone <your-repo-url>
cd Conflict-Simulation-Lab
# Install backend dependencies
pip install -r backend/requirements.txt# 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-personalitiesFor 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- Embedding: Converts personality examples to vectors
- Retrieval: Finds most relevant examples for each personality
- Generation: Local LLM creates dialogue using retrieved examples
- Result: Personality-styled conversation (may be generic)
- Topic Analysis: Understands specific conflict scenarios
- Context Integration: Combines personality + topic context
- Realistic Generation: Creates topic-specific arguments
- Result: Realistic, topic-aware conflict conversations
| 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 |
- 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
- Household chores and responsibilities
- Money and financial decisions
- Parenting styles and discipline
- Work-life balance
- Social plans and commitments
- Custom topics
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
python test_openai_comparison.py
python test_openai_comparison.py
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."
]
}
}For advanced features like conversation memory and chaining:
pip install -r requirements_langchain.txt
python langchain_integration.py
The system uses Retrieval-Augmented Generation to improve dialogue quality:
- Retrieval: Finds relevant personality examples from the database
- Augmentation: Combines examples with the generation prompt
- 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
- Add more personality examples
- Include topic-specific examples
- Add conversation context examples
- Use better embedding models
- Implement reranking
- Add semantic search
- Use larger models (GPT-4, Claude)
- Implement conversation memory
- Add multi-turn dialogue
- Get API Key: Visit OpenAI Platform
- Set Environment Variable:
export OPENAI_API_KEY="your-key-here"
- Test Integration:
python test_openai_comparison.py
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
- Local: Use GPU if available for faster generation
- OpenAI: Batch requests to reduce API calls
- Memory: Close other applications for local generation
- Fork the repository
- Create a feature branch
- Add your improvements
- Test thoroughly
- Submit a pull request
This project is open source and available under the MIT License.
- Hugging Face for open-source models
- OpenAI for enhanced generation capabilities
- SentenceTransformers for embeddings
- The open-source community for tools and libraries