Project

General

Profile

Actions

Improvement #30414

open

Improvement #29635: Code Review, Upgrade and changes in Prompt of Email Boat

Feature: Implement Logging Service for ML Data Collection and Debugging

Added by Sachin Suresh 5 months ago. Updated 5 months ago.

Status:
Fixed not Tested
Priority:
Normal
Assignee:
Target version:
-
Start date:
11/25/2025
Due date:
11/27/2025 (about 5 months late)
% Done:

100%

Estimated time:
6:00 h
Spent time:
remarks:
DB Changes:
Keys & Permissions:
Areas Affected:
Files Changed:

Description

Description:We need to implement a robust logging service for the CaxiAIQuote application. The primary goal is to capture transaction data to debug current issues and build a dataset for fine-tuning our own AI model in the future.Functional Requirements:Non-Blocking Performance: The logging process must be asynchronous and must not slow down the main email processing loop (zero latency impact).Format: Logs must be stored in JSONL (JSON Lines) format. Each line must be a valid, self-contained JSON object. This is required for compatibility with Vertex AI / OpenAI fine-tuning tools.Separation of Data:Successful Transactions: Log to logs/training_data.jsonl. These represent "perfect" examples (Prompt $\rightarrow$ Correct Payload).Failed Transactions: Log to logs/failed_prompts.jsonl. These are for developer review to improve the system instructions.Auto-Initialization: The service must automatically create the logs directory and the .jsonl files if they do not exist when the application starts.Data to Capture (Schema):Each log entry should include:timestamp: ISO string.user: Sender email address.prompt: The original email body text.status: 'success' or 'failed'.rawAiParams: The raw JSON returned by Gemini (crucial for debugging hallucinations).standardizedParams: The validated parameters used for logic.finalPayload: The actual JSON sent to the Flight API (only for success).errorMessage: Reason for failure (only for failed).Technical Implementation:Service File: Create services/loggerService.js.Method: Use Node.js fs.createWriteStream with the 'a' (append) flag to keep file streams open for high performance.Integration: Update index.js (Main Worker) to call logTransaction() immediately after the AI processing step (Step 2).Deliverables:services/loggerService.jsUpdated index.jsLogs folder generated in root directory (/logs/*.jsonl)

Actions

Also available in: Atom PDF