contaigents
Version:
Modular AI Content Ecosystem with Audio Generation
155 lines (135 loc) • 5.76 kB
JavaScript
import { BaseLLM } from './BaseLLM.js';
export class DummyLLM extends BaseLLM {
getRandomDelay(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
}
simulateNetworkDelay() {
// Random delay between 500ms-1.5s for testing
const delay = this.getRandomDelay(500, 1500);
return new Promise((resolve) => setTimeout(resolve, delay));
}
constructor() {
super(DummyLLM.providerConfig);
}
isConfigured() {
// Only configured if config file exists
try {
const fs = require('fs');
return fs.existsSync('./.config/llm_config/dummyllm.json');
}
catch {
return false;
}
}
async executePrompt(prompt, options = {}) {
console.log('🤖 DummyLLM executing prompt:', prompt.substring(0, 100) + '...');
try {
// Simulate network latency
await this.simulateNetworkDelay();
// Generate contextual responses based on prompt content
let content = '';
if (prompt.toLowerCase().includes('conversation') || prompt.toLowerCase().includes('chat')) {
content = `Hello! I'm a test AI assistant. I understand you're testing the conversation system.
I can help you with:
- Content creation and writing
- File analysis and review
- Project management assistance
- Technical documentation
What would you like to work on today?`;
}
else if (prompt.toLowerCase().includes('analyze') || prompt.toLowerCase().includes('analysis')) {
content = `# File Analysis Results
## Summary
The analyzed content appears to be well-structured and contains the following key elements:
## Key Findings
- **Structure**: The content follows a logical organization
- **Quality**: The writing is clear and coherent
- **Completeness**: Most sections are adequately covered
- **Recommendations**: Consider adding more examples and expanding on technical details
## Suggestions for Improvement
1. Add more specific examples
2. Include additional context where needed
3. Consider breaking down complex sections
4. Enhance readability with better formatting`;
}
else if (prompt.toLowerCase().includes('generate') || prompt.toLowerCase().includes('create') || prompt.toLowerCase().includes('write')) {
content = `# Generated Content
## Introduction
This is a sample piece of content generated by the DummyLLM for testing purposes.
## Main Content
Here's some example content that demonstrates the system's ability to generate structured text:
- **Point 1**: Clear and concise information delivery
- **Point 2**: Well-organized structure and formatting
- **Point 3**: Relevant examples and practical insights
## Conclusion
This generated content showcases the basic functionality of the content generation system.`;
}
else if (prompt.toLowerCase().includes('help') || prompt.toLowerCase().includes('capabilities')) {
content = `# AI Assistant Capabilities
I'm a test AI assistant with the following capabilities:
## Content Creation
- Writing articles, blog posts, and documentation
- Creating structured content with proper formatting
- Generating ideas and outlines
## Analysis & Review
- Analyzing existing content for quality and structure
- Providing feedback and suggestions for improvement
- Identifying gaps and areas for enhancement
## Project Assistance
- Helping with project planning and organization
- Providing technical guidance and best practices
- Supporting workflow optimization
How can I assist you with your project today?`;
}
else {
content = `# AI Assistant Response
Thank you for your message. I'm a test AI assistant designed to help with content creation, analysis, and project management.
## Your Request
I've received your message and I'm ready to help. Based on your input, I can provide assistance with:
- **Content Creation**: Writing, editing, and structuring content
- **Analysis**: Reviewing and analyzing existing materials
- **Guidance**: Providing recommendations and best practices
## Next Steps
Please let me know specifically what you'd like to work on, and I'll provide more targeted assistance.
Is there a particular task or project you'd like help with?`;
}
return {
content,
raw: {
model: 'dummy-test-model',
usage: {
prompt_tokens: prompt.length / 4, // Rough estimate
completion_tokens: content.length / 4,
total_tokens: (prompt.length + content.length) / 4,
},
provider: 'DummyLLM',
timestamp: Date.now()
},
};
}
catch (error) {
throw new Error(`DummyLLM error: ${error instanceof Error ? error.message : 'Unknown error'}`);
}
}
async imagine(prompt, options = {}) {
console.log('🎨 DummyLLM generating image for:', prompt);
try {
await this.simulateNetworkDelay();
return {
urls: ['https://placehold.co/800x600/png?text=DummyLLM+Test+Image'],
raw: {
model: 'dummy-image-model',
created: Date.now(),
provider: 'DummyLLM'
}
};
}
catch (error) {
throw new Error(`DummyLLM image generation error: ${error instanceof Error ? error.message : 'Unknown error'}`);
}
}
}
DummyLLM.providerConfig = {
name: 'DummyLLM',
configFields: [],
};