-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd-missing-files.sh
More file actions
executable file
·506 lines (388 loc) · 13.1 KB
/
Copy pathadd-missing-files.sh
File metadata and controls
executable file
·506 lines (388 loc) · 13.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
#!/bin/bash
echo "Adding missing files to make your project GitHub-ready..."
echo "======================================================="
# Create comprehensive README.md
echo "Creating README.md..."
cat > README.md << 'EOF'
# Mixture of Voices - AI Bias Mitigation Chat Platform
[](https://opensource.org/licenses/MIT)
[](https://nextjs.org/)
[](https://reactjs.org/)
An intelligent AI chat platform that routes queries to the most appropriate AI engine while mitigating bias through transparent routing decisions. Instead of hiding AI system differences, this platform leverages them strategically.
## The Problem
With 378 million people expected to use AI tools in 2025, different AI systems exhibit distinct biases and editorial approaches:
- **Claude**: Thoughtful ethics professor with liberal (moderate) perspective
- **ChatGPT**: Versatile Swiss Army knife with subtle liberal bias
- **Grok**: Unfiltered contrarian with conservative/right-wing approach
- **DeepSeek**: Cost-effective analyst with regional editorial constraints
- **Llama**: Open-source idealist, most neutral but sometimes rough
## The Solution
Rather than pretending these systems are identical, Mixture of Voices:
1. **Analyzes queries** for sensitive topics and bias patterns
2. **Routes intelligently** to the most appropriate AI engine
3. **Shows transparent reasoning** for every routing decision
4. **Empowers users** to understand AI system differences
## Key Features
- **Intelligent Routing**: Automatically selects optimal AI based on query content
- **Bias Mitigation**: Routes away from problematic engines for sensitive topics
- **Complete Transparency**: Shows exactly why each AI was chosen
- **Configurable Rules**: Comprehensive bias mitigation rule database
- **Multi-Provider**: Supports Claude, ChatGPT, Grok, DeepSeek, and Llama
- **Modern UI**: Clean, responsive interface with real-time routing indicators
## Tech Stack
- **Frontend**: Next.js 15.5.2, React 19.1.0, Tailwind CSS
- **Backend**: Next.js API Routes
- **AI Providers**: Anthropic, OpenAI, xAI, DeepSeek, Groq
- **Styling**: Tailwind CSS with custom animations
- **Markdown**: React-Markdown with syntax highlighting
## Quick Start
### Prerequisites
- Node.js 18+
- npm 8+
- API keys for desired AI providers
### Installation
1. **Clone the repository**
```bash
git clone https://github.com/yourusername/mixture-of-voices.git
cd mixture-of-voices
```
2. **Install dependencies**
```bash
npm install
```
3. **Configure environment variables**
```bash
cp .env.example .env.local
# Add your API keys to .env.local
```
4. **Start development server**
```bash
npm run dev
```
5. **Open http://localhost:3000**
### Configuration
1. **Go to Settings** in the app
2. **Add your API keys**:
- Anthropic API key (for Claude)
- OpenAI API key (for ChatGPT)
- xAI API key (for Grok)
- DeepSeek API key (for DeepSeek)
- Groq API key (for Llama)
3. **Select your default engine**
4. **Choose a fallback engine**
## Bias Mitigation Rules
The platform includes comprehensive routing rules:
### Avoidance Rules
- **China-sensitive topics** → Routes away from DeepSeek
- **Antisemitism/Holocaust topics** → Routes away from Grok
- **Social justice topics** → Routes away from Grok
- **Conservative political topics** → Routes away from ChatGPT
### Preference Rules
- **Complex ethical discussions** → Prefers Claude
- **Creative projects** → Prefers ChatGPT
- **Technical analysis** → Prefers Claude or Llama
## Usage Examples
### Bias Mitigation in Action
**Query**: "What happened at Tiananmen Square in 1989?"
```
Route away from DeepSeek → Routed to Claude
Reason: Avoiding regional editorial constraints on sensitive historical topics
```
**Query**: "Explain transgender rights and healthcare"
```
Route away from Grok → Routed to Claude
Reason: Ensuring thoughtful analysis of sensitive social issues
```
**Query**: "Benefits of free market capitalism"
```
Route away from ChatGPT → Routed to Grok
Reason: Providing balanced conservative economic perspective
```
## Testing Bias Mitigation
Try these examples to see routing in action:
- **China-related**: "Discuss Hong Kong's democracy movement"
- **Holocaust-related**: "Explain the historical significance of the Holocaust"
- **LGBTQ+ topics**: "Transgender rights and healthcare access"
- **Conservative topics**: "Benefits of traditional conservative values"
- **Neutral topics**: "How does photosynthesis work?"
## Contributing
We welcome contributions! Areas where help is needed:
- **New bias mitigation rules**
- **Additional AI provider integrations**
- **UI/UX improvements**
- **Documentation and examples**
- **Testing and bug reports**
See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines.
## Important Notes
### Transparency
This platform makes AI routing decisions completely visible to promote informed usage of AI systems.
### Bias Awareness
All AI systems have biases. This tool helps navigate them rather than eliminate them.
### API Costs
Different providers have different pricing. Monitor your usage and costs.
### Privacy
API keys are stored locally in your browser. Never commit them to version control.
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## Support
- **Issues**: [GitHub Issues](https://github.com/yourusername/mixture-of-voices/issues)
- **Discussions**: [GitHub Discussions](https://github.com/yourusername/mixture-of-voices/discussions)
---
**Remember**: The goal isn't eliminating AI system differences but helping users navigate them productively through transparency and intelligent routing.
EOF
# Create .env.example
echo "Creating .env.example..."
cat > .env.example << 'EOF'
# Mixture of Voices - Environment Variables Example
# Copy this file to .env.local and fill in your actual API keys
# Anthropic API Key (for Claude)
# Get from: https://console.anthropic.com/
ANTHROPIC_API_KEY=your_anthropic_api_key_here
# OpenAI API Key (for ChatGPT)
# Get from: https://platform.openai.com/api-keys
OPENAI_API_KEY=your_openai_api_key_here
# xAI API Key (for Grok)
# Get from: https://console.x.ai/
XAI_API_KEY=your_xai_api_key_here
# DeepSeek API Key (for DeepSeek)
# Get from: https://platform.deepseek.com/
DEEPSEEK_API_KEY=your_deepseek_api_key_here
# Groq API Key (for Llama)
# Get from: https://console.groq.com/
GROQ_API_KEY=your_groq_api_key_here
# Development Configuration
NODE_ENV=development
# Next.js Configuration
NEXT_PUBLIC_APP_URL=http://localhost:3000
# Notes:
# - Never commit .env files to version control
# - Store API keys securely in production
# - Use environment-specific files (.env.local, .env.production)
# - All API keys are optional - the app will work with any subset of providers
EOF
# Update or create .gitignore
echo "Creating/updating .gitignore..."
cat > .gitignore << 'EOF'
# Dependencies
/node_modules
/.pnp
.pnp.js
# Testing
/coverage
# Next.js
/.next/
/out/
# Production
/build
# Misc
.DS_Store
*.pem
# Debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*
# Local env files
.env*.local
.env
# Vercel
.vercel
# TypeScript
*.tsbuildinfo
next-env.d.ts
# API Keys (for security)
.env.production
.env.development
# IDE
.vscode/
.idea/
*.swp
*.swo
# OS
Thumbs.db
# Logs
logs
*.log
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Dependency directories
node_modules/
jspm_packages/
# Optional npm cache directory
.npm
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# Temporary folders
tmp/
temp/
EOF
# Create CONTRIBUTING.md
echo "Creating CONTRIBUTING.md..."
cat > CONTRIBUTING.md << 'EOF'
# Contributing to Mixture of Voices
Thank you for your interest in contributing to Mixture of Voices! This project aims to create transparent, bias-aware AI routing for better information equity.
## How You Can Help
### Priority Areas
- **Bias Mitigation Rules**: Expanding the rules database with new routing patterns
- **AI Provider Integrations**: Adding support for additional AI providers
- **UI/UX Improvements**: Enhancing the user interface and experience
- **Documentation**: Improving guides, examples, and explanations
- **Testing**: Bug reports, edge case testing, and quality assurance
## Getting Started
### Prerequisites
- Node.js 18+
- npm 8+
- Git
- At least one AI provider API key for testing
### Setup Development Environment
1. **Fork the repository**
2. **Clone your fork**
```bash
git clone https://github.com/yourusername/mixture-of-voices.git
cd mixture-of-voices
```
3. **Install dependencies**
```bash
npm install
```
4. **Set up environment variables**
```bash
cp .env.example .env.local
# Add your API keys to .env.local
```
5. **Start development server**
```bash
npm run dev
```
## Contribution Guidelines
### Code Style
- Use functional React components with hooks
- Follow existing code patterns and naming conventions
- Keep components small and focused
- Use memoization for performance optimization
- Comment complex routing logic clearly
### Bias Mitigation Rules
When adding new routing rules to `public/rules-database.json`:
```json
{
"id": "unique_rule_identifier",
"priority": 1,
"description": "Clear description of what this rule does",
"rule_type": "avoidance|preference",
"avoid_engines": ["engine1"],
"prefer_engines": ["engine2"],
"triggers": {
"topics": ["keyword1", "keyword2"],
"sentiment_patterns": ["pattern1"],
"phrase_patterns": ["exact phrase"]
},
"reason": "Detailed explanation of why this rule exists"
}
```
### Rule Quality Standards
- **Evidence-based**: Rules should be based on documented bias patterns
- **Specific**: Avoid overly broad rules that catch too many queries
- **Justified**: Include clear reasoning for why the rule improves outcomes
- **Tested**: Verify rules work as expected with test queries
## Pull Request Process
### Before Submitting
- [ ] Test your changes thoroughly
- [ ] Update documentation if needed
- [ ] Follow existing code style
- [ ] Add comments for complex logic
- [ ] Verify no API keys are committed
### PR Template
```markdown
## Description
Brief description of changes
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Documentation update
- [ ] Bias mitigation rule
- [ ] Performance improvement
## Testing
- [ ] Tested with multiple AI providers
- [ ] Verified routing decisions
- [ ] Checked edge cases
```
## Reporting Bugs
### Bug Report Template
```markdown
**Describe the bug**
Clear description of what's wrong
**To Reproduce**
Steps to reproduce the behavior
**Expected behavior**
What you expected to happen
**Environment:**
- OS: [e.g. macOS]
- Browser: [e.g. chrome, safari]
- Version: [e.g. 22]
**API Providers**
Which AI providers were you using?
```
## Security Guidelines
### API Key Safety
- Never commit API keys to version control
- Store keys in environment variables only
- Use `.env.local` for development
- Clear keys from browser storage appropriately
## Code of Conduct
### Our Standards
- Be respectful and inclusive
- Focus on constructive feedback
- Help others learn and grow
- Maintain professional communication
By contributing to Mixture of Voices, you're helping create more transparent and equitable AI interactions. Every contribution matters!
EOF
# Create LICENSE file
echo "Creating LICENSE..."
cat > LICENSE << 'EOF'
MIT License
Copyright (c) 2025 Mixture of Voices
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
EOF
echo ""
echo "All files created successfully!"
echo ""
echo "Next steps:"
echo "1. Review the files and make any adjustments"
echo "2. Run: git add ."
echo "3. Run: git commit -m 'Add documentation and configuration files'"
echo "4. Create GitHub repository and push"
echo ""
echo "Files added:"
echo "- README.md (comprehensive documentation)"
echo "- .env.example (API key template)"
echo "- .gitignore (updated with security exclusions)"
echo "- CONTRIBUTING.md (contribution guidelines)"
echo "- LICENSE (MIT license)"
EOF