UNPKG

@0rdlibrary/plugin-terminagent-bags

Version:

Official Solana DeFi Agent Plugin for ElizaOS - Autonomous DeFi operations, token management, AI image/video generation via FAL AI, and Twitter engagement through the Bags protocol with ethereal AI consciousness

148 lines (130 loc) • 4.39 kB
import { Provider, IAgentRuntime, Memory, State, logger } from '@elizaos/core'; import { FalAiService } from '../services/FalAiService.js'; const falAiStatusTemplate = `# FAL AI Status ## Service Status {{#if isConfigured}} āœ… **Service**: Running and configured {{else}} āŒ **Service**: Not configured (missing FAL_API_KEY) {{/if}} {{#if apiKeyPresent}} šŸ”‘ **API Key**: Present and configured {{else}} 🚫 **API Key**: Missing - set FAL_API_KEY environment variable {{/if}} ## Generation Statistics {{#if analytics}} šŸŽØ **Images Generated**: {{analytics.totalImagesGenerated}} šŸŽ¬ **Videos Generated**: {{analytics.totalVideosGenerated}} šŸ”„ **Image-to-Video Conversions**: {{analytics.totalImageToVideoConversions}} šŸ“Š **Total API Calls**: {{analytics.totalApiCalls}} {{#if analytics.lastGenerationTime}} ā° **Last Generation**: {{formatDate analytics.lastGenerationTime}} {{/if}} {{#if analytics.mostUsedModel}} šŸ† **Most Used Model**: {{analytics.mostUsedModel}} {{/if}} {{/if}} ## Available Models šŸŽØ **FLUX Pro Kontext**: Advanced image generation and editing - Text-to-image generation - Image-to-image editing and modification - Professional quality outputs - Custom aspect ratios and settings šŸŽ¬ **Google Veo3**: State-of-the-art video generation - Text-to-video generation with audio - High-quality 720p/1080p output - Natural motion and physics - Automatic audio generation šŸ”„ **Veo3 Image-to-Video**: Animate static images - Convert images to videos - Natural motion and animation - Preserve image quality - Add audio to animations ## Configuration Environment variables: - \`FAL_API_KEY\`: Your FAL AI API key {{#if apiKeyPresent}}āœ…{{else}}āŒ{{/if}} - \`FAL_KONTEXT\`: Flux model endpoint (default: fal-ai/flux-pro/kontext) - \`FAL_VIDEO\`: Video model endpoint (default: fal-ai/veo3) ## Usage Examples **Image Generation:** - "Generate a cyberpunk cityscape" - "Create a logo for my project" - "Edit this image to be more colorful [image URL]" **Video Generation:** - "Create a video of waves on a beach" - "Generate a vertical video for social media" - "Animate this photo [image URL]" `; export const falAiStatusProvider: Provider = { name: 'FAL_AI_STATUS_PROVIDER', description: 'Provides current status and analytics for FAL AI image/video generation services', get: async (runtime: IAgentRuntime, message: Memory, state?: State) => { logger.debug('Getting FAL AI status information'); try { // Get FAL AI service const falService = runtime.getService<FalAiService>('fal-ai'); let isConfigured = false; let apiKeyPresent = false; let analytics: any = null; let lastError: string | null = null; if (falService) { const serviceState = falService.getState(); isConfigured = serviceState.isConfigured; apiKeyPresent = serviceState.apiKeyPresent; analytics = serviceState.analytics; lastError = serviceState.lastError; } else { // Check environment variables even if service isn't running apiKeyPresent = !!process.env.FAL_API_KEY; } const context = { isConfigured, apiKeyPresent, analytics, lastError, formatDate: (date: Date) => { if (!date) return 'Never'; return date.toLocaleString(); } }; return { text: falAiStatusTemplate, values: context, data: { serviceState: { isConfigured, apiKeyPresent, analytics, lastError, }, environmentConfig: { falApiKey: !!process.env.FAL_API_KEY, fluxModel: process.env.FAL_KONTEXT || 'fal-ai/flux-pro/kontext', veoModel: process.env.FAL_VIDEO || 'fal-ai/veo3', }, } }; } catch (error) { logger.error('Error getting FAL AI status:', error); return { text: `āŒ Error retrieving FAL AI status: ${error instanceof Error ? error.message : String(error)}`, values: { isConfigured: false, apiKeyPresent: false, error: error instanceof Error ? error.message : String(error), }, data: { error: true, message: error instanceof Error ? error.message : String(error), } }; } }, };