DegenPy is an advanced automated content generation and publishing platform designed for cryptocurrency and financial news. The system leverages AI to process data from various sources, generate engaging video content, and publish it to social media platforms like TikTok and Twitter.
- AI-Powered Content Generation: Transform financial data into engaging narratives using customizable AI agents
- Automated Video Creation: Convert text content to high-quality videos using D-ID's API
- Multi-Platform Publishing: Seamlessly publish content to TikTok, Twitter, and other platforms
- Flexible Database Integration: Support for MongoDB, MySQL, and PostgreSQL
- Modular Architecture: Easily extendable with new data sources, AI models, and publishing platforms
- Real-time Processing: Handle both scheduled and real-time data processing workflows
DegenPy/
├── warehouse/ # Data warehouse components
│ ├── api.py # Warehouse API implementation
│ ├── storage/ # Database connectors
│ │ ├── mongodb/ # MongoDB connector
│ │ ├── mysql/ # MySQL connector
│ │ ├── pgsql/ # PostgreSQL connector
│ │ └── init_db.py # Database initialization script
│ └── utils/ # Utility functions and classes
├── server/ # Server components
│ ├── agents/ # Agent configurations
│ │ ├── trump-xbt.json # Trump-style crypto agent
│ │ ├── tiktok-agent.json # TikTok-optimized agent
│ │ └── engine.py # Agent engine implementation
│ ├── tasks/ # Task definitions
│ │ ├── timeline_task/ # Timeline data processing (every 30 min)
│ │ ├── special_attention_task/ # Special attention data (real-time)
│ │ └── task_executor.py # Task executor
│ ├── actions/ # Action implementations
│ │ ├── text2v.py # Text-to-video generation
│ │ ├── webhook.py # Webhook notifications
│ │ ├── tiktok.py # TikTok publishing
│ │ └── twitter.py # Twitter publishing
│ └── api.py # Server API
├── examples/ # Example scripts and usage demos
├── plugins/ # Plugin system directory
├── run.py # Main application runner
├── .env.example # Example environment variables
└── requirements.txt # Python dependencies
-
Data Warehouse (
warehouse/api.py)- Centralized data storage and retrieval system
- Supports multiple database backends (MongoDB, MySQL, PostgreSQL)
- Simplified data structure with uid, content (dict), and tags (dict)
- Provides unified interface for data operations
-
Agent Engine (
server/agents/engine.py)- Manages AI agent behaviors and interactions
- Loads and configures agent personalities
- Processes data according to agent preferences
- Generates content with consistent tone and style
-
Task Executor (
server/tasks/task_executor.py)- Orchestrates task execution workflows
- Manages timeline and special attention data processing
- Uses UID tracker to monitor processing status
- Handles both scheduled and real-time tasks
-
Action Modules (
server/actions/)- text2v.py: Text-to-video generation using D-ID API
- tiktok.py: TikTok publishing and token management
- twitter.py: Twitter content publishing
- webhook.py: External notification system
- Scheduled execution (every 30 minutes)
- Processes general news and updates
- Direct video generation without additional verification
- Suitable for regular content updates
- Real-time execution for high-priority data
- Enhanced verification and AI processing
- Generates breaking news videos
- Suitable for important events requiring immediate attention
- Task is triggered and retrieves data from the warehouse
- AI agent processes the data and generates narrative content
- Text-to-video request is sent to D-ID API
- Video is generated and status is monitored
- Upon completion, video is published to configured platforms
- Webhook notifications are sent to external systems
The system provides a unified interface for different database backends:
- MongoDB: Document-based storage with flexible schema
- MySQL: Relational database for structured data
- PostgreSQL: Advanced relational database with JSON support
The active database is selected through the DB_TYPE environment variable.
All database connectors implement the following methods:
store_data: Store data with optional tagsget_data_by_uid: Retrieve data by a single UIDget_recent_data: Get recently added dataget_data_by_uids: Retrieve data by multiple UIDsexecute_query: Run custom database queries
The RecentUIDTracker class maintains a record of recently added UIDs:
- Categorizes UIDs by source type
- Provides retrieval and clearing operations
- Facilitates efficient data processing workflows
-
POST /warehouse/data: Store new data- Parameters:
content(dict),tags(optional dict) - Returns: Generated UID
- Parameters:
-
GET /warehouse/data/{uid}: Retrieve data by UID- Returns: Complete data object
-
GET /warehouse/recent: Get recent data entries- Parameters:
limit(optional, default=10) - Returns: List of recent data objects
- Parameters:
-
POST /server/generate-video: Create a new video- Parameters:
text,presenter,voice(optional) - Returns: Video task ID
- Parameters:
-
GET /server/video-status/{task_id}: Check video generation status- Returns: Status and result URL when complete
# Clone the repository
git clone https://github.com/your-org/DegenPy.git
cd DegenPy
# Install dependencies
pip install -r requirements.txt-
Create your environment file:
cp .env.example .env
-
Edit the
.envfile with your API keys and database credentials -
Initialize the database:
python -m warehouse.storage.init_db [mongodb|mysql|pgsql]
python run.pyCheck the examples/ directory for sample scripts demonstrating how to:
- Configure the environment variables
- Generate videos using the D-ID API
- Publish content to TikTok
- Implement custom data processing workflows
POST /data: Store data- Parameters:
content,author_id,source_type,uid(optional)
- Parameters:
GET /content/{uid}: Get data for a specific UIDGET /recent-content: Get recently stored items- Parameters:
source_type(optional),limit(default 30)
- Parameters:
GET /content-by-uids: Get data for a list of UIDs- Parameters:
uids(comma-separated list of UIDs)
- Parameters:
GET /recent-uids: Get list of recently added UIDs- Parameters:
source_type(optional)
- Parameters:
GET /agents: List all agentsGET /agents/{agent_id}: Get agent detailsGET /tasks: List all available tasksGET /tasks/{task_id}: Get details for a specific taskPOST /run-task/{task_id}: Manually run a specific taskGET /conditions: List all available conditionsGET /conditions/{condition_id}: Get details for a specific condition