fix: disable unconfigured ai services

This commit is contained in:
KernelDeimos 2024-08-05 16:04:21 -04:00
parent c97688706e
commit 476acae0e0

View File

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