@bernierllc/ai-content-generator
Version:
AI-powered content generation service for social posts, blog articles, emails, and multi-platform content
538 lines • 10.6 kB
TypeScript
import { CompletionRequest, CompletionResponse } from '@bernierllc/ai-provider-core';
/**
* Social media platforms supported for content generation
*/
export type SocialPlatform = 'twitter' | 'linkedin' | 'facebook' | 'instagram' | 'mastodon' | 'bluesky';
/**
* Email types for generation
*/
export type EmailType = 'newsletter' | 'announcement' | 'promotional' | 'transactional';
/**
* Content formats for generation
*/
export type ContentFormat = 'blog' | 'social' | 'email';
/**
* Provider client interface for internal use
* Matches the minimal interface needed from @bernierllc/ai-provider-core AIProvider
*/
export interface AIProviderClient {
/**
* Generate a completion
*/
complete(request: CompletionRequest): Promise<CompletionResponse>;
/**
* Get provider name
*/
getProviderName(): string;
}
/**
* AI Content Generator Configuration
*/
export interface AIContentGeneratorConfig {
/**
* AI provider instance to use for generation
* Accepts any object with complete() and getProviderName() methods
*/
provider: AIProviderClient;
/**
* Optional fallback provider for failover
*/
fallbackProvider?: AIProviderClient;
/**
* Default generation options
*/
defaultOptions?: GenerationOptions;
/**
* Enable analytics tracking
*/
enableAnalytics?: boolean;
/**
* Maximum retries for failed generations
*/
maxRetries?: number;
/**
* Default temperature for generation (0-1)
*/
defaultTemperature?: number;
}
/**
* Options for content generation
*/
export interface GenerationOptions {
/**
* Creativity level (0-1, where 0 is deterministic, 1 is creative)
*/
creativity?: number;
/**
* Target audience for the content
*/
targetAudience?: string;
/**
* Desired tone of the content
*/
tone?: string;
/**
* Include hashtags in social content
*/
includeHashtags?: boolean;
/**
* Number of hashtags to include
*/
hashtagCount?: number;
/**
* Include emojis in content
*/
includeEmojis?: boolean;
/**
* Include a call to action
*/
callToAction?: boolean;
/**
* Custom call to action text
*/
callToActionText?: string;
/**
* Number of alternate versions to generate
*/
alternateVersions?: number;
}
/**
* Blog post outline for generation
*/
export interface BlogOutline {
/**
* Main topic of the blog post
*/
topic: string;
/**
* Sections to include in the post
*/
sections: BlogSection[];
/**
* Target audience for the blog
*/
targetAudience: string;
/**
* Desired tone
*/
tone: string;
/**
* Target length (short, medium, long)
*/
length?: 'short' | 'medium' | 'long';
}
/**
* A section in a blog outline
*/
export interface BlogSection {
/**
* Section title
*/
title: string;
/**
* Key points to cover in this section
*/
keyPoints: string[];
}
/**
* Options specific to blog generation
*/
export interface BlogGenerationOptions extends GenerationOptions {
/**
* Target word count
*/
targetLength?: number;
/**
* Include an introduction section
*/
includeIntro?: boolean;
/**
* Include a conclusion section
*/
includeConclusion?: boolean;
/**
* Include source citations
*/
includeSources?: boolean;
/**
* SEO keywords to incorporate
*/
seoKeywords?: string[];
}
/**
* Options specific to email generation
*/
export interface EmailGenerationOptions extends GenerationOptions {
/**
* Include a call to action button/link
*/
includeCallToAction?: boolean;
/**
* Personalization placeholders
*/
personalization?: Record<string, string>;
/**
* Maximum length for subject line
*/
maxSubjectLength?: number;
}
/**
* Generated content result
*/
export interface GeneratedContent {
/**
* Whether generation was successful
*/
success: boolean;
/**
* The generated content
*/
content: string;
/**
* Metadata about the generation
*/
metadata?: GenerationMetadata;
/**
* Alternate versions if requested
*/
alternateVersions?: string[];
/**
* Error message if generation failed
*/
error?: string;
}
/**
* Metadata about a generation
*/
export interface GenerationMetadata {
/**
* Platform the content was generated for
*/
platform?: string;
/**
* Email type if applicable
*/
emailType?: string;
/**
* Email subject line
*/
subject?: string;
/**
* Email preheader text
*/
preheader?: string;
/**
* When the content was generated
*/
generatedAt: Date;
/**
* Model used for generation
*/
model: string;
/**
* Tokens used for the prompt
*/
promptTokens: number;
/**
* Tokens used for the completion
*/
completionTokens: number;
/**
* Total tokens used
*/
totalTokens: number;
/**
* Generation duration in milliseconds
*/
durationMs?: number;
/**
* Character count of generated content
*/
characterCount?: number;
/**
* Word count of generated content
*/
wordCount?: number;
}
/**
* Result of batch generation
*/
export interface BatchGenerationResult {
/**
* Whether overall batch was successful
*/
success: boolean;
/**
* Individual results
*/
results: Array<{
id?: string;
platform?: SocialPlatform;
result: GeneratedContent;
}>;
/**
* Total items generated
*/
totalGenerated: number;
/**
* Number of successful generations
*/
successCount: number;
/**
* Number of failed generations
*/
failureCount: number;
/**
* Batch metadata
*/
metadata?: {
sourceLength?: number;
platforms?: SocialPlatform[];
generatedAt?: Date;
};
}
/**
* Request for batch generation
*/
export interface BatchGenerationRequest {
/**
* Unique identifier for this request
*/
id: string;
/**
* Type of content to generate
*/
type: 'social' | 'blog' | 'email';
/**
* Source content for generation
*/
sourceContent: string;
/**
* Platform for social content
*/
platform?: SocialPlatform;
/**
* Outline for blog content
*/
outline?: BlogOutline;
/**
* Email type for email content
*/
emailType?: EmailType;
/**
* General generation options
*/
options?: GenerationOptions;
/**
* Blog-specific options
*/
blogOptions?: BlogGenerationOptions;
/**
* Email-specific options
*/
emailOptions?: EmailGenerationOptions;
}
/**
* Result of thread generation
*/
export interface ThreadGenerationResult {
/**
* Whether generation was successful
*/
success: boolean;
/**
* Individual posts in the thread
*/
posts: string[];
/**
* Total number of posts
*/
totalPosts?: number;
/**
* Platform the thread is for
*/
platform?: string;
/**
* Thread metadata
*/
metadata?: {
generatedAt?: Date;
durationMs?: number;
};
/**
* Error message if generation failed
*/
error?: string;
}
/**
* Result of hashtag generation
*/
export interface HashtagResult {
/**
* Whether generation was successful
*/
success: boolean;
/**
* Generated hashtags
*/
hashtags: string[];
/**
* Number of hashtags generated
*/
count?: number;
/**
* Error message if generation failed
*/
error?: string;
}
/**
* Commit data for generating content from code changes
*/
export interface CommitData {
/**
* Commit SHA
*/
sha: string;
/**
* Commit message
*/
message: string;
/**
* Author name
*/
author: string;
/**
* Files changed
*/
files: string[];
/**
* Lines added
*/
additions: number;
/**
* Lines deleted
*/
deletions: number;
/**
* Full diff content
*/
diff?: string;
}
/**
* Result of generating content from a commit
*/
export interface CommitContentResult {
/**
* Whether generation was successful
*/
success: boolean;
/**
* The commit data
*/
commit: CommitData;
/**
* Generated content by format
*/
generatedContent: Partial<Record<ContentFormat, GeneratedContent>>;
/**
* Total formats generated
*/
totalGenerated: number;
/**
* Error message if generation failed
*/
error?: string;
}
/**
* Time range for analytics queries
*/
export interface TimeRange {
/**
* Start of the time range
*/
start: Date;
/**
* End of the time range
*/
end: Date;
}
/**
* Generation analytics data
*/
export interface GenerationAnalytics {
/**
* Total number of generations
*/
totalGenerations: number;
/**
* Generations by platform
*/
byPlatform: Record<string, number>;
/**
* Generations by type
*/
byType: Record<string, number>;
/**
* Average tokens per generation
*/
averageTokens: number;
/**
* Total estimated cost
*/
totalCost: number;
/**
* Trend data over time
*/
trendData: Array<{
date: Date;
count: number;
tokens: number;
}>;
}
/**
* Platform specifications for social media
*/
export interface PlatformSpecs {
/**
* Maximum character length
*/
maxLength: number;
/**
* Recommended tone
*/
tone: string;
/**
* Recommended style
*/
style: string;
/**
* Supports hashtags
*/
supportsHashtags: boolean;
/**
* Supports media attachments
*/
supportsMedia: boolean;
/**
* Maximum hashtag count recommended
*/
maxHashtags?: number;
}
/**
* Parsed email content
*/
export interface ParsedEmail {
/**
* Subject line
*/
subject: string;
/**
* Preheader text
*/
preheader: string;
/**
* Email body
*/
body: string;
}
//# sourceMappingURL=types.d.ts.map