Browse Source

fix: add _init method to register FakeChatService as a provider

Added _init method to FakeChatService to register itself as a provider with AIChatService, ensuring that the service and its models are properly recognized by the system.

ai: true
KernelDeimos 1 tháng trước cách đây
mục cha
commit
7a2851d2cc

+ 13 - 0
src/backend/src/modules/puterai/FakeChatService.js

@@ -29,6 +29,19 @@ const BaseService = require("../../services/BaseService");
 * Implements the 'puter-chat-completion' interface with list() and complete() methods.
 * Implements the 'puter-chat-completion' interface with list() and complete() methods.
 */
 */
 class FakeChatService extends BaseService {
 class FakeChatService extends BaseService {
+    /**
+     * Initializes the service and registers it as a provider with AIChatService
+     * @private
+     * @returns {Promise<void>}
+     */
+    async _init() {
+        const svc_aiChat = this.services.get('ai-chat');
+        svc_aiChat.register_provider({
+            service_name: this.service_name,
+            alias: true,
+        });
+    }
+
     get_default_model () {
     get_default_model () {
         return 'fake';
         return 'fake';
     }
     }