Skip to content

Predictive alert and multi lang#438

Open
Sadeequ wants to merge 3 commits into
Traqora:mainfrom
Sadeequ:predictiveAlert_and_MultiLang
Open

Predictive alert and multi lang#438
Sadeequ wants to merge 3 commits into
Traqora:mainfrom
Sadeequ:predictiveAlert_and_MultiLang

Conversation

@Sadeequ

@Sadeequ Sadeequ commented Jun 29, 2026

Copy link
Copy Markdown

I have successfully implemented these two features:

Issue 1: Multi-language Support for LLM Outputs

Translation Service (api/services/translation.py):

Created a comprehensive translation service supporting 15+ languages (English, Spanish, French, German, Chinese, Japanese, Korean, Portuguese, Italian, Russian, Arabic, Hindi, Dutch, Polish, Turkish)
Implemented multi-layer caching with Redis backend and in-memory fallback
Added locale-aware formatting for dates, numbers, currencies, and percentages using Babel
Included cache statistics and invalidation capabilities
Provided async support for non-blocking operations
Translation Endpoints (api/routers/llm.py):

GET /api/v1/llm/translate/languages - Lists supported languages
POST /api/v1/llm/translate - Translates single text
POST /api/v1/llm/translate/batch - Translates multiple texts
POST /api/v1/llm/translate/format - Formats values for specific locales
GET /api/v1/llm/translate/cache/stats - Cache statistics
POST /api/v1/llm/translate/cache/invalidate - Cache invalidation
Schema Updates (api/schemas.py):

Added all necessary translation-related Pydantic models ✅
Issue 2: Predictive Alerts for Account Behavior Changes

Predictive Alerts Service (api/services/predictive_alerts.py):

BehavioralLearner: Learns baseline behaviors from historical transaction data
DeviationDetector: Identifies significant deviations using statistical thresholds
AlertGenerator: Creates LLM-based explanations for anomalies
PredictiveAlertService: Main orchestrator coordinating all components
Predictive Alerts Endpoints (api/routers/alerts.py):

GET /api/v1/alerts/predictive - Generates predictive alerts for account behavior
POST /api/v1/alerts/generate-explanations - Creates LLM explanations for detected anomalies
GET /api/v1/alerts/predictive/status - Service status and metrics
Schema Updates (api/schemas.py):

Added predictive alerts schemas: BehavioralBaseline, DeviationAlert, PredictiveAlertRequest/Response, etc. ✔️

Key Features:

  1. Learns behavioral baselines from transaction history (daily transaction counts, amounts, etc.)
  2. Detects deviations using configurable sensitivity levels (low/medium/high sigma thresholds)
  3. Generates natural-language explanations using LLM
  4. Analyzes multiple metrics: transaction count, total amount, average amount, unique counterparties
  5. Proper error handling, validation, and informative responses
  6. Both implementations follow existing codebase patterns, integrate with current infrastructure (using MockLLMProvider, Redis caching, etc.), and are ready for testing within the AstroML system. All imports and dependencies have been verified to work correctly.

Related Issues:

CLOSES #408 ✔️

CLOSES #409 ✔️

@drips-wave

drips-wave Bot commented Jun 29, 2026

Copy link
Copy Markdown

@Sadeequ Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[LLM] Implement multi-language support for LLM outputs [LLM] Build predictive alerts for account behavior changes

1 participant