@agentdao/core
Version:
Core functionality, skills, and ready-made UI components for AgentDAO - Web3 subscriptions, content generation, social media, help support, live chat, RSS fetching, web search, and agent pricing integration
145 lines (144 loc) • 4.15 kB
TypeScript
import { BlogPost, SocialPost, Email } from './content-utils';
export interface ContentGeneratorConfig {
agentId: string;
agentName: string;
domain: string;
ai: {
provider: 'openai' | 'anthropic' | 'google' | 'cohere';
apiKey: string;
model: string;
temperature: number;
maxTokens: number;
retryAttempts: number;
};
templates: {
[templateId: string]: {
name: string;
type: 'blog' | 'social' | 'email' | 'ad' | 'product' | 'newsletter';
prompt: string;
maxLength: number;
format: 'text' | 'html' | 'markdown' | 'json';
variables: string[];
examples: string[];
};
};
brand: {
name: string;
voice: string;
tone: string;
keywords: string[];
styleGuide: string;
logo?: string;
colors?: string[];
};
seo: {
enabled: boolean;
keywords: string[];
metaDescriptionLength: number;
titleMaxLength: number;
autoOptimize: boolean;
};
categories: {
[categoryId: string]: {
name: string;
description: string;
keywords: string[];
templates: string[];
};
};
integration: {
autoSave: boolean;
saveLocation: 'database' | 'file' | 'api';
publishAutomatically: boolean;
reviewRequired: boolean;
};
}
export declare class ContentGeneratorSkill {
private config;
private retryCount;
private maxRetries;
constructor(config: ContentGeneratorConfig);
/**
* Validate configuration on initialization
*/
private validateConfig;
/**
* Generate blog post with robust error handling and retries
*/
generateBlogPost(topic: string, keywords?: string[], options?: {
length?: 'short' | 'medium' | 'long';
tone?: 'professional' | 'casual' | 'technical';
includeSEO?: boolean;
retryOnFailure?: boolean;
}): Promise<BlogPost>;
/**
* Generate social media post with robust error handling
*/
generateSocialPost(platform: 'twitter' | 'linkedin' | 'facebook' | 'instagram', topic: string, options?: {
tone?: 'professional' | 'casual' | 'engaging';
includeHashtags?: boolean;
retryOnFailure?: boolean;
}): Promise<SocialPost>;
/**
* Generate email content with robust error handling
*/
generateEmail(purpose: string, recipient: string, options?: {
tone?: 'formal' | 'casual' | 'friendly';
length?: 'short' | 'medium' | 'long';
retryOnFailure?: boolean;
}): Promise<Email>;
/**
* Generate content using custom template
*/
generateFromTemplate(templateId: string, variables: Record<string, string>, options?: {
retryOnFailure?: boolean;
}): Promise<any>;
/**
* Optimize existing content for SEO
*/
optimizeContent(content: string, keywords?: string[], options?: {
retryOnFailure?: boolean;
}): Promise<any>;
/**
* Generate meta tags for SEO
*/
generateMetaTags(title: string, content: string, options?: {
retryOnFailure?: boolean;
}): Promise<any>;
/**
* Execute function with retry logic
*/
private executeWithRetry;
/**
* Determine if an error should not be retried
*/
private shouldNotRetry;
/**
* Input validation helper
*/
private validateInput;
/**
* Validate template variables
*/
private validateTemplateVariables;
/**
* Handle content generation errors with detailed logging
*/
private handleContentGenerationError;
/**
* Log error to external service (placeholder for monitoring)
*/
private logErrorToExternalService;
/**
* Generate content from template (internal implementation)
*/
private generateFromTemplateInternal;
/**
* Replace variables in template prompt
*/
private replaceTemplateVariables;
/**
* Sleep utility for retry delays
*/
private sleep;
}