Browse Source

fix: allow fake-chat to report usage for costly model

Modified the event handler in AIChatService to only skip usage reporting for fake-chat when it's not using the costly model, allowing the costly model to properly report its usage and costs.

ai: true
KernelDeimos 1 month ago
parent
commit
617fb49178
1 changed files with 2 additions and 1 deletions
  1. 2 1
      src/backend/src/modules/puterai/AIChatService.js

+ 2 - 1
src/backend/src/modules/puterai/AIChatService.js

@@ -78,7 +78,8 @@ class AIChatService extends BaseService {
 
 
         const svc_event = this.services.get('event');
         const svc_event = this.services.get('event');
         svc_event.on('ai.prompt.report-usage', async (_, details) => {
         svc_event.on('ai.prompt.report-usage', async (_, details) => {
-            if ( details.service_used === 'fake-chat' ) return;
+            // Only skip usage reporting for fake-chat if it's not using the costly model
+            if ( details.service_used === 'fake-chat' && details.model_used !== 'costly' ) return;
 
 
             const values = {
             const values = {
                 user_id: details.actor?.type?.user?.id,
                 user_id: details.actor?.type?.user?.id,