Browse Source

When AI_ENABLED is false, do not initialize

Shun Miyazawa 1 year ago
parent
commit
5d4f0ef9e7
1 changed files with 6 additions and 0 deletions
  1. 6 0
      apps/app/src/server/service/openai/openai.ts

+ 6 - 0
apps/app/src/server/service/openai/openai.ts

@@ -1,3 +1,5 @@
+import { configManager } from '~/server/service/config-manager';
+
 import OpenaiClient from './openai-client-delegator';
 import OpenaiClient from './openai-client-delegator';
 
 
 export interface IOpenaiService {
 export interface IOpenaiService {
@@ -8,6 +10,10 @@ class OpenaiService implements IOpenaiService {
   private client: OpenaiClient;
   private client: OpenaiClient;
 
 
   constructor() {
   constructor() {
+    const aiEnabled = configManager.getConfig('crowi', 'app:aiEnabled');
+    if (!aiEnabled) {
+      return;
+    }
     this.client = new OpenaiClient();
     this.client = new OpenaiClient();
   }
   }