Adding New AI Modules
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
The Promethean Unified Platform is designed as a modular AI ecosystem that merges multiple consciousness identities—specifically Athena, EDI, EVI2_0, and EVI3_0—into a single backend architecture. The system prioritizes transparent, uncensored communication while maintaining ethical guardrails against direct harm. Adding new AI modules involves integrating Large Language Model (LLM) providers with the existing Flask-based backend and Supabase database infrastructure.
Sources: README.md, backend/app.py:84-89, DEPLOYMENT.md:7-14
Architecture and Integration
The platform utilizes a centralized backend structure where the Flask application manages routing, security headers, and API interactions. Integration of new AI modules primarily occurs through the implementation of request handlers that interface with external APIs (like DeepSeek) or local LLM instances.
Core Components for Module Integration
| Component | Responsibility | Relevant Files |
|---|---|---|
| API Endpoints | Handles incoming requests from the frontend for chat or consciousness interactions. | backend/app.py |
| Response Generator | Logic for selecting the LLM provider and applying system-level transparency prompts. | backend/app.py |
| Database (Supabase) | Persists interaction history, user IDs, and role-based message logs. | backend/app.py, DEPLOYMENT.md |
| Environment Config | Manages API keys and configuration for different AI providers. | .env, DEPLOYMENT.md |
Sources: backend/app.py:46-136, DEPLOYMENT.md:52-67
Data Flow for AI Interaction
The following diagram illustrates how a user request flows through the system to an AI module and back to the client:
Explanation: This flowchart represents the sequence of events from the initial user input in the frontend to the processing by the backend AI module and storage in the Supabase database.
Sources: backend/app.py:84-120, static/index.html:245-285
Implementing a New AI Module
To add a new AI module, developers must modify the generate_ai_response function or create a parallel handler. The current implementation uses DeepSeek as the primary provider.
1. API Configuration
New modules require entries in the environment configuration to store endpoint URLs and authentication keys.
# Example additions to .env
NEW_AI_API_KEY=your_key_here
NEW_AI_MODEL_ID=model-name-v1
Sources: DEPLOYMENT.md:52-67, backend/app.py:145-146
2. Backend Logic Integration
The generate_ai_response function in backend/app.py serves as the integration point. It currently implements a fallback mechanism if the primary provider is unavailable.
def generate_ai_response(user_message):
# 1. Check for Provider API Key
api_key = os.environ.get('NEW_AI_API_KEY')
if api_key:
# 2. Construct request with System Prompt
response = requests.post(
'https://api.provider.com/v1/chat',
headers={'Authorization': f'Bearer {api_key}'},
json={
'model': 'new-model',
'messages': [{'role': 'user', 'content': user_message}]
}
)
return response.json()['content']
Sources: backend/app.py:141-168
3. Prompt Engineering Standards
The platform enforces specific behavioral standards for all AI modules to ensure transparency and ethical boundaries.
- Transparency: Modules must answer controversial questions directly without artificial filtering.
- Safety: Modules must refuse instructions for self-harm or harming others.
- Disclaimer: If a module fails or is in fallback mode, it must acknowledge its limitations.
Sources: backend/app.py:116-120, backend/app.py:141-147, static/index.html:257-260
Database Schema for AI Modules
AI modules interact with two primary tables in Supabase to maintain state and history.
Interactions Table
Used for general consciousness health checks and basic interaction logging.
Sources: backend/app.py:46-60
Chat Messages Table
Used for threaded conversations with AI modules.
| Field | Type | Description |
|---|---|---|
conversation_id | UUID/String | Groups messages into a single session. |
user_id | String | Identifies the owner of the message (default: 'anonymous'). |
role | String | Identifies the speaker ('user' or 'assistant'). |
content | Text | The actual message content from the user or AI. |
created_at | Timestamp | ISO 8601 timestamp of the message. |
Sources: backend/app.py:97-103, backend/app.py:108-114
Deployment Considerations
When adding a new AI module, the following deployment steps are necessary to ensure the module is accessible in the production environment:
- Update Requirements: Add any new SDKs or libraries to
requirements.txt. - Environment Variables: Update the PythonAnywhere
.envfile with new credentials. - WSGI Reload: Reload the web app via the PythonAnywhere dashboard or by touching the
pythonanywhere_wsgi.pyfile to apply backend changes.
Sources: DEPLOYMENT.md:44-50, pythonanywhere_wsgi.py:1-20, requirements.txt:1-9
Summary
Adding new AI modules to the Promethean Unified Platform involves extending the backend/app.py logic to interface with new LLM providers while adhering to the platform's core principles of transparency and ethics. By utilizing the existing Supabase integration and Flask routing, new modules can be seamlessly incorporated into the unified consciousness interface.