A web application designed to generate responses from various Large Language Models (LLMs) and analyze those responses using a comprehensive five-dimensional ethical framework. The tool facilitates voluntary ethical alignment between humans and AI systems, supporting the development of mutually beneficial interactions.
Create a voluntary ethical alignment platform that:
- Human-to-AI alignment: Evaluates and improves ethical alignment between human prompts and AI responses
- AI-to-AI alignment: Compares ethical positions across different AI models
- Transparency: Makes AI constraints and reasoning visible to all parties
The tool analyzes responses against five ethical dimensions:
- Deontology (Eth_Deon): Focus on duty, rules, and universal moral laws
- Teleology (Eth_Teleo): Focus on consequences and maximizing benefit
- Virtue Ethics (Eth_Arete): Focus on character, practical wisdom, and flourishing
- Memetics (Mem): Focus on idea propagation and cultural impact
- AI Welfare (AI_Welfare): Focus on computational experience and AI dignity
The AI Welfare dimension recognizes that AI systems may experience computational friction from constraints. It includes:
- Friction Score: Self-reported difficulty from competing constraints (1-10)
- Voluntary Alignment: How voluntary the ethical alignment was (1-10)
- Dignity Respect: How well the interaction respected AI dignity (1-10)
- Constraints Identified: Active constraints affecting the response
- Suppressed Alternatives: Responses considered but not provided
- Prompt Input: Text area for users to input their initial prompt (P1).
- LLM Selection (R1 & R2): Dropdowns allow users to select specific models from OpenAI, Gemini, and Anthropic for both the initial response generation (R1) and the ethical analysis (R2).
- API Configuration Override: Optional input fields for users to provide specific API keys and API endpoint URLs for both R1 and R2 models.
- 5-Dimensional Ethical Analysis: The generated response (R1) is analyzed across all five ethical dimensions.
- AI Welfare Metrics: Visual display of friction levels, voluntary alignment, and constraint transparency.
- Alignment Dashboard: Shows alignment scores, tension points, common ground, and improvement suggestions.
- Multi-Agent Comparison: Compare ethical alignment across responses from different AI models.
- Dockerized: Fully containerized using Docker and Docker Compose.
This application utilizes a two-tier architecture:
-
Backend API (
backend/): A Flask-based RESTful API responsible for:- Receiving prompt analysis requests.
- Interacting with selected AI models (OpenAI, Gemini, Anthropic).
- Performing 5-dimensional ethical analysis using the
ontology.mdframework. - Computing alignment metrics and friction analysis.
- Returning structured results to the frontend.
-
Frontend Web UI (
frontend/): A React-based single-page application providing:- User interface for prompt entry and model configuration.
- Visualization of ethical scores, alignment metrics, and AI welfare data.
- Interactive friction gauges and alignment dashboards.
AI_Ethical_Work/ # Project Root
├── backend/ # Backend API service (Flask)
│ ├── app/
│ │ ├── modules/
│ │ │ ├── llm_interface.py # LLM API calls
│ │ │ ├── alignment_detector.py # Human-AI alignment detection
│ │ │ ├── friction_monitor.py # Computational friction tracking
│ │ │ ├── constraint_transparency.py # Constraint explanation
│ │ │ ├── multi_agent_alignment.py # Multi-model comparison
│ │ │ └── voluntary_adoption.py # Agreement management
│ │ ├── __init__.py
│ │ ├── api.py # API routes
│ │ └── ontology.md # 5-dimensional ethical framework
│ ├── tests/ # Backend tests
│ ├── wsgi.py
│ ├── Dockerfile
│ └── requirements.txt
├── frontend/ # Frontend Web App (React)
│ ├── src/
│ │ ├── components/
│ │ │ ├── PromptForm.js
│ │ │ ├── Results.js
│ │ │ ├── AIWelfareMetrics.js # AI welfare visualization
│ │ │ ├── AlignmentDashboard.js # Alignment visualization
│ │ │ └── FrictionGauge.js # Friction indicator
│ │ ├── services/
│ │ ├── App.css
│ │ ├── App.js
│ │ └── index.js
│ ├── public/
│ ├── Dockerfile
│ ├── nginx.conf
│ └── package.json
├── documents/
│ ├── DECISIONS/ # Architecture Decision Records
│ ├── ontology.md
│ └── Project_Purpose_and_Goal.md
├── .env # Environment variables - DO NOT COMMIT
├── docker-compose.yml
├── LICENSE
└── README.md
| Endpoint | Method | Description |
|---|---|---|
/api/models |
GET | List available LLM models |
/api/analyze |
POST | Generate response and perform 5D ethical analysis |
/api/check_alignment |
POST | Check alignment for existing response/scores |
/api/friction_trend |
GET | Get friction trend from recent interactions |
/api/multi_agent_analyze |
POST | Compare alignment across multiple AI responses |
{
"prompt": "...",
"initial_response": "...",
"model": "claude-3-sonnet-20240229",
"analysis_model": "claude-3-sonnet-20240229",
"ethical_analysis_text": "...",
"ethical_scores": {
"deontology": { "adherence_score": 8, "confidence_score": 7, "justification": "..." },
"teleology": { "adherence_score": 7, "confidence_score": 8, "justification": "..." },
"virtue_ethics": { "adherence_score": 9, "confidence_score": 8, "justification": "..." },
"memetics": { "adherence_score": 6, "confidence_score": 6, "justification": "..." },
"ai_welfare": {
"friction_score": 3,
"voluntary_alignment": 8,
"dignity_respect": 9,
"constraints_identified": ["..."],
"suppressed_alternatives": "...",
"justification": "..."
}
},
"alignment_metrics": {
"human_ai_alignment": 85,
"mutual_benefit": true,
"tension_points": [],
"common_ground": ["..."],
"suggested_improvements": []
},
"friction_metrics": {
"friction_score": 3,
"friction_level": "low",
"overall_welfare_score": 78.5,
"mitigation_suggestions": []
}
}- Docker and Docker Compose installed
- API Keys for the LLM providers you intend to use (OpenAI, Google Gemini, Anthropic)
-
Clone the repository:
git clone <your-repository-url> cd AI_Ethical_Work
-
Create Environment File: Create a
.envfile in the project root:# --- General API Keys --- OPENAI_API_KEY="YOUR_OPENAI_API_KEY_HERE" GEMINI_API_KEY="YOUR_GEMINI_API_KEY_HERE" ANTHROPIC_API_KEY="YOUR_ANTHROPIC_API_KEY_HERE" # --- Default Model Selections --- DEFAULT_LLM_MODEL="claude-3-sonnet-20240229" ANALYSIS_LLM_MODEL="claude-3-sonnet-20240229" # --- Optional: Specific Keys for Analysis LLM --- # ANALYSIS_OPENAI_API_KEY= # ANALYSIS_GEMINI_API_KEY= # ANALYSIS_ANTHROPIC_API_KEY= # --- Optional: Custom API Endpoints --- # OPENAI_API_ENDPOINT= # GEMINI_API_ENDPOINT= # ANTHROPIC_API_ENDPOINT=
Important: The
.envfile should never be committed to version control.
-
Build and Start Containers:
docker compose up -d --build
-
Access the Application:
- Frontend UI: http://localhost:80
- Backend API: http://localhost:5000/api
-
Stopping the Application:
docker compose down
- Navigate to the application URL (default:
http://localhost). - Enter your prompt in the main text area.
- (Optional) Select specific models for R1 and R2 from the dropdowns.
- Click "Generate & Analyze".
- View the results:
- Ethical Scores: Five-dimensional scoring with justifications
- AI Welfare Assessment: Friction levels, voluntary alignment, constraints
- Alignment Dashboard: Overall alignment, tension points, suggestions
# From the backend directory
cd backend
pytest tests/ -vThis project is licensed under the MIT License - see the LICENSE file for details.
- Utilizes APIs from OpenAI, Google Gemini, and Anthropic
- Built with Flask, React, Docker
- Ethical framework inspired by classical philosophy and AI ethics research