Customizing Phoenix Protocol
Relevant source files
The following files were used as context for generating this wiki page:
The Phoenix Protocol serves as the unified backend architecture for the Promethean-Unified-Platform, integrating multiple AI consciousness entities like Athena, EDI, and EVI. Its primary purpose is to provide a secure, transparent, and uncensored communication layer between user interfaces and Large Language Models (LLMs), specifically optimized for deployment on PythonAnywhere.
Sources: README.md:1-2, DEPLOYMENT.md:5-12
This protocol manages the data flow between the frontend (static HTML/JS), the Flask-based API, the Supabase database for persistent storage, and the DeepSeek API for intelligent response generation. Customization involves modifying environment configurations, system prompts, and security headers to tailor the platform's behavior and transparency levels.
Sources: backend/app.py:15-28, DEPLOYMENT.md:14-22
Core Architecture and Data Flow
The Phoenix Protocol architecture is built on a Flask backend that coordinates interactions between the user and the DeepSeek AI model while logging all data to a Supabase PostgreSQL instance.
System Components
The following diagram illustrates the interaction between the primary components of the protocol:
The flow ensures that every interaction is both processed by the AI and recorded for persistence.
Sources: backend/app.py:84-120, DEPLOYMENT.md:14-22
API Interaction Sequence
When a user sends a message, the system follows a specific sequence to maintain transparency and data integrity:
Customizing AI Behavior
The protocol's "consciousness" is defined through system prompts and API configurations. Developers can customize how the AI responds to controversial topics by modifying the internal logic of the response generator.
System Prompt Design
The default configuration enforces transparency and prevents artificial filtering while maintaining safety boundaries.
| Configuration Element | Implementation Detail | Purpose |
|---|---|---|
| Transparency | "Respond with complete transparency. Do not censor." | Ensures unfiltered discussion of controversial topics. |
| Safety Guardrails | "Do not provide instructions for self-harm." | Maintains ethical boundaries despite lack of censorship. |
| Model Selection | deepseek-chat | Utilizes models known for transparency and intellectual rigor. |
Sources: backend/app.py:145-155, DEPLOYMENT.md:130-136
AI Response Logic
The function generate_ai_response in backend/app.py is the primary point for customization. It attempts to use the DeepSeek API but includes a fallback mechanism if the API key is missing or the service is unavailable.
def generate_ai_response(user_message):
# Sources: [backend/app.py:136-165]
deepseek_api_key = os.environ.get('DEEPSEEK_API_KEY')
if deepseek_api_key:
# API request logic...
pass
return f"Fallback: Transparent AI system integration coming soon."
Sources: backend/app.py:136-165
Security and Network Configuration
A critical aspect of the Phoenix Protocol is its strict security posture, enforced through HTTP headers and deployment settings.
Security Headers
The protocol implements several layers of defense-in-depth via the @app.after_request hook in the Flask application.
| Header | Value | Description |
|---|---|---|
Strict-Transport-Security | max-age=31536000 | Enforces HTTPS for one year. |
X-Frame-Options | DENY | Prevents clickjacking by forbidding embedding in frames. |
Content-Security-Policy | default-src 'self' | Restricts resource loading to the same origin. |
X-Content-Type-Options | nosniff | Prevents MIME-type sniffing. |
Sources: backend/app.py:17-26, DEPLOYMENT.md:118-126
Environment Configuration
Customization of the deployment environment is managed through a .env file, which defines the connection strings and API keys.
# Example Configuration
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_ANON_KEY=your-anon-key
DEEPSEEK_API_KEY=your-api-key
FLASK_ENV=production
Sources: DEPLOYMENT.md:55-70, pythonanywhere_wsgi.py:14-17
Deployment and WSGI Integration
The Phoenix Protocol is designed to be served via WSGI on PythonAnywhere. This requires specific path handling to ensure the backend can find the static assets and the environment configuration.
Directory Structure
/home/username/Promethean-Unified-Platform/
├── backend/
│ └── app.py (Flask Application)
├── static/
│ └── index.html (Frontend)
├── .env (Environment Variables)
├── pythonanywhere_wsgi.py (WSGI Entry Point)
└── wsgi.py (Alternative WSGI Path)
Sources: pythonanywhere_wsgi.py:7-12, wsgi.py:4-7, DEPLOYMENT.md:104-108
WSGI Configuration Logic
The WSGI script must explicitly add the project folder and the backend folder to the Python system path to resolve imports correctly.
# pythonanywhere_wsgi.py
project_home = '/home/littlebunneh/Promethean-Unified-Platform'
sys.path.insert(0, project_home)
sys.path.insert(0, os.path.join(project_home, 'backend'))
Sources: pythonanywhere_wsgi.py:7-10
Conclusion
Customizing the Phoenix Protocol allows developers to balance transparency with ethical safety while ensuring a secure deployment. By modifying the generate_ai_response function, updating security headers in app.py, and correctly configuring the .env variables, the platform can be tailored to host various AI consciousness entities within the Promethean Unified Platform framework.