diff --git a/src/backend/src/modules/puterai/PuterAIModule.js b/src/backend/src/modules/puterai/PuterAIModule.js index 20ea8200..f1ccde42 100644 --- a/src/backend/src/modules/puterai/PuterAIModule.js +++ b/src/backend/src/modules/puterai/PuterAIModule.js @@ -1,4 +1,5 @@ const { AdvancedBase } = require("@heyputer/puter-js-common"); +const config = require("../../config"); class PuterAIModule extends AdvancedBase { async install (context) { @@ -7,17 +8,26 @@ class PuterAIModule extends AdvancedBase { const { AIInterfaceService } = require('./AIInterfaceService'); services.registerService('__ai-interfaces', AIInterfaceService); - const { AWSTextractService } = require('./AWSTextractService'); - services.registerService('aws-textract', AWSTextractService); + // TODO: services should govern their own availability instead of + // the module deciding what to register - const { AWSPollyService } = require('./AWSPollyService'); - services.registerService('aws-polly', AWSPollyService); + if ( !! config?.services?.['aws-textract']?.aws ) { + const { AWSTextractService } = require('./AWSTextractService'); + services.registerService('aws-textract', AWSTextractService); + } - const { OpenAICompletionService } = require('./OpenAICompletionService'); - services.registerService('openai-completion', OpenAICompletionService); + if ( !! config?.services?.['aws-polly']?.aws ) { + const { AWSPollyService } = require('./AWSPollyService'); + services.registerService('aws-polly', AWSPollyService); + } - const { OpenAIImageGenerationService } = require('./OpenAIImageGenerationService'); - services.registerService('openai-image-generation', OpenAIImageGenerationService); + if ( !! config?.openai ) { + const { OpenAICompletionService } = require('./OpenAICompletionService'); + services.registerService('openai-completion', OpenAICompletionService); + + const { OpenAIImageGenerationService } = require('./OpenAIImageGenerationService'); + services.registerService('openai-image-generation', OpenAIImageGenerationService); + } } }