Loading...
Loading...
Loading...
# NX-EDITOR8 AI AGENTS FLOW
**Date:** October 4, 2025
**Status:** β
**LANGCHAIN ENABLED WITH AI AGENTS PIPELINE**
## π€ AI AGENTS ARCHITECTURE
nx-editor8 uses **LangChain** and **LiteLLM** to implement a sophisticated multi-agent AI processing pipeline for content transformation.
## π AI AGENTS FLOW DIAGRAM
```
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β KAFKA CONTENT SOURCES β
βββββββββββββββββββ¬ββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββ€
β youtube_content β tiktok_content β facebook_content β
βββββββββββββββββββ΄ββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β MESSAGE PROCESSOR β
β (src/core/message_processor.py) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β π€ AI AGENT 1: REQUIREMENTS VALIDATOR β
β (src/validation/requirements_validator.py) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β’ Word/Character Count Validation β
β β’ Content Format Detection β
β β’ Language Validation β
β β’ Quality Assessment β
β β
β π ENHANCEMENT LOOP (if requirements not met): β
β βββ LLM-Powered Content Enhancement β
β βββ Retry Logic (max 3 attempts) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ (requirements met)
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β π€ AI AGENT 2: CONTENT ANALYZER β
β (_analyze_content method) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Prompt: src/ai/prompts/content_analysis.md β
β β
β AI Tasks: β
β β’ Sentiment Analysis (positive/negative/neutral) β
β β’ Topic Extraction β
β β’ Key Points Identification β
β β’ Title Generation β
β β’ Description Creation β
β β’ SEO Keywords Generation β
β β’ Content Type Classification β
β β’ Quality Score Assessment β
β β
β Output: ContentAnalysis model β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β π€ AI AGENT 3: SCENE GENERATOR β
β (_generate_scenes method) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Prompt: src/ai/prompts/scene_generation.md β
β β
β AI Tasks: β
β β’ Video Script Structure Creation β
β β’ Scene Type Assignment (title/text/image/outro) β
β β’ TTS-Optimized Text Generation β
β β’ Visual Design (colors, duration) β
β β’ Scene Flow Optimization β
β β’ Engagement Optimization β
β β
β Scene Types: β
β ββ title_scene: Opening with title/intro β
β ββ text_scene: Main content presentation β
β ββ image_scene: Visual content with text β
β ββ outro_scene: Closing with CTA β
β β
β Output: List[Scene] models β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β OUTPUT FORMATTER β
β (_create_nx_maker8_input method) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β’ NXMaker8Input Model Creation β
β β’ Video Settings Configuration β
β β’ Storage and TTS Provider Setup β
β β’ Metadata Enrichment β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β KAFKA PUBLISHER β
β (src/integrations/kafka_client.py) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β’ nx-maker8 Topic Publishing β
β β’ Video Request Formatting β
β β’ Success/Error Handling β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β NX-MAKER8 ECOSYSTEM β
β (Video Generation Pipeline) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
```
## π§ AI AGENTS DETAILED CAPABILITIES
### π€ Agent 1: Requirements Validator
**File:** `src/validation/requirements_validator.py`
**LangChain Integration:** Content Enhancement via LLM
**Core Functions:**
- `verify_requirements()` - Multi-criteria content validation
- `enhance_content_for_requirements()` - LLM-powered content expansion
- `_validate_content_format()` - Format compliance checking
- `_detect_language()` - Language identification
**AI Enhancement Logic:**
```python
# When content fails requirements:
enhanced_content = await self.llm_client.generate(
prompt=enhancement_prompt,
system_message="You are nx-editor8's content enhancement specialist..."
)
```
### π€ Agent 2: Content Analyzer
**File:** `src/core/message_processor.py` (`_analyze_content` method)
**Prompt Template:** `src/ai/prompts/content_analysis.md`
**AI Capabilities:**
- **Sentiment Analysis:** positive/negative/neutral classification
- **Topic Extraction:** Multi-topic identification and categorization
- **Key Points:** Hierarchical content structure analysis
- **SEO Optimization:** Title, description, and keyword generation
- **Quality Assessment:** Content scoring for video suitability
**JSON Output Structure:**
```json
{
"sentiment": "positive|negative|neutral",
"topics": ["topic1", "topic2"],
"key_points": ["point1", "point2"],
"suggested_title": "AI-generated engaging title",
"suggested_description": "Compelling description",
"suggested_keywords": ["kw1", "kw2"],
"content_type": "educational|entertainment|news|tutorial",
"quality_score": 0.85,
"engagement_potential": "high|medium|low"
}
```
### π€ Agent 3: Scene Generator
**File:** `src/core/message_processor.py` (`_generate_scenes` method)
**Prompt Template:** `src/ai/prompts/scene_generation.md`
**AI Capabilities:**
- **Video Structure:** Intelligent scene breakdown and flow
- **TTS Optimization:** Text length and pronunciation optimization
- **Visual Design:** Color schemes and timing coordination
- **Engagement Flow:** Hook, content, and call-to-action structure
**Scene Types Generated:**
1. **title_scene:** Opening hook with title and introduction
2. **text_scene:** Main content delivery with optimized pacing
3. **image_scene:** Visual content integration (when available)
4. **outro_scene:** Conclusion with engagement prompts
## π§ LiteLLM CLIENT ARCHITECTURE
**File:** `src/integrations/llm_client.py`
**Design Pattern:** Singleton with async/await
**Key Features:**
- **EngineX Compatibility:** Follows established xProjects patterns
- **Multi-Fallback Configuration:** Environment variable hierarchy
- **Retry Logic:** Exponential backoff with 3 attempts
- **JSON Parsing:** Automatic structured response handling
- **Error Recovery:** Graceful fallback mechanisms
**Client Methods:**
```python
# Text generation
response = await llm_client.generate(prompt, system_message)
# Structured JSON generation
data = await llm_client.generate_json(prompt, system_message)
```
## π AI PROCESSING PIPELINE FLOW
### Step-by-Step Execution:
1. **Message Ingestion:** Kafka consumer receives content message
2. **Requirements Check:** AI validates content against criteria
3. **Enhancement Loop:** If needed, AI expands/improves content
4. **Content Analysis:** AI extracts insights and metadata
5. **Scene Generation:** AI creates structured video scenes
6. **Output Formatting:** Data transformed to nx-maker8 format
7. **Publication:** Structured video request published to Kafka
### Retry and Error Handling:
- **Requirements Validation:** Up to 3 enhancement attempts
- **LLM Requests:** Exponential backoff retry logic
- **Fallback Mechanisms:** Basic scene generation if AI fails
- **Error Publishing:** Structured error reporting to Kafka topics
## π― LangChain Integration Points
### Current LangChain Usage:
- **Dependencies:** `langchain>=0.1.0,<0.2.0` and `langchain-core>=0.1.7,<0.2.0`
- **LangGraph:** `langgraph==0.0.26` for potential agent orchestration
- **Integration Patterns:** Compatible with LangChain's agent framework
### Potential LangChain Enhancements:
- **Agent Orchestration:** LangGraph for complex multi-agent workflows
- **Memory Systems:** Conversation memory for content context
- **Tool Integration:** External tool calling for image search, data retrieval
- **Chain Composition:** Sophisticated prompt chaining and conditional logic
## π Performance Characteristics
### AI Processing Metrics:
- **Content Analysis:** ~2-3 seconds per message
- **Scene Generation:** ~3-5 seconds per message
- **Enhancement Cycles:** ~2-4 seconds per retry
- **Total Processing:** ~5-15 seconds end-to-end
### Scalability Features:
- **Async Processing:** Non-blocking I/O throughout pipeline
- **Singleton Clients:** Resource-efficient client management
- **Configurable Limits:** Adjustable retry counts and timeouts
- **Error Isolation:** Failed messages don't block pipeline
---
**nx-editor8 implements a sophisticated AI agents pipeline using LangChain and LiteLLM for intelligent content transformation and video scene generation!** π€β¨[](http://colab.research.google.com/github/rinongal/stylegan-nada/blob/main/stylegan_nada.ipynb)
get signed picture and voice authorisations from our parents
Parses a structured video script, extracts all `Narrator:` blocks, and synthesises them into a single MP3 using Azure OpenAI TTS.
<img src="https://img.shields.io/github/forks/artkulak/text2youtube.svg">