CoolFace
Apppublic

syedkhizarrayaz/BM-AI-Analysis-And-Alert-Prioritization-Agent

sourceHugging Faceupdated 8mo agoView on Hugging Face
0likes
openapi.yaml1367 linesDownload Raw Back to root
1openapi: 3.0.32info:3  title: SystemZ-AI API4  description: |5    Anti-Money Laundering (AML) Alert Classification and Analysis System API.6    7    This API provides endpoints for:8    - ML-based alert classification9    - Multiple analysis methods (OpenAI GPT, Local LLM, Hybrid)10    - Streaming analysis generation11    12    **Authentication**: Authentication is **optional** and only required when integrating with external systems. 13    For internal system use, authentication is **disabled** by default. All endpoints can be accessed without authentication tokens.14  version: 1.0.015  contact:16    name: API Support17    email: support@example.com18  license:19    name: Benchmatrix License20 21servers:22  - url: http://localhost:800023    description: Local development server24  - url: https://api.example.com25    description: Production server26 27tags:28  - name: Authentication29    description: Authentication and token management (Optional - only for external integrations)30  - name: Model Prediction31    description: ML model prediction endpoints32  - name: Analysis Generation33    description: AML analysis report generation34  - name: Email Alerts35    description: Email notification services (Optional/Future Feature - currently disabled)36 37paths:38  /api/ai-service/token:39    post:40      tags:41        - Authentication42      summary: Get access token (Optional)43      description: |44        Generate JWT access token for API authentication.45        46        **Note**: This endpoint is optional. Authentication is disabled for internal system use.47        Only use this endpoint when integrating with external systems that require authentication.48      operationId: getToken49      security: []50      requestBody:51        required: true52        content:53          application/x-www-form-urlencoded:54            schema:55              type: object56              required:57                - username58                - password59              properties:60                username:61                  type: string62                  description: API username63                  example: admin64                password:65                  type: string66                  format: password67                  description: API password68                  example: your_password69      responses:70        '200':71          description: Token generated successfully72          content:73            application/json:74              schema:75                $ref: '#/components/schemas/Token'76              examples:77                success:78                  summary: Successful token generation79                  value:80                    access_token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImV4cCI6MTcwNDA5NjAwMH0.example"81                    token_type: "bearer"82        '400':83          description: Invalid credentials84          content:85            application/json:86              schema:87                $ref: '#/components/schemas/Error'88              examples:89                invalid_credentials:90                  summary: Invalid username or password91                  value:92                    detail: "Incorrect username or password"93 94  /api/ai-service/predictalertpriority:95    post:96      tags:97        - Model Prediction98      summary: Predict alert priority99      description: |100        Predict whether an alert should be escalated or closed using the ML model.101        Accepts JSON input with alert data.102      operationId: predictAlertPriority103      security: []104      requestBody:105        required: true106        content:107          application/json:108            schema:109              $ref: '#/components/schemas/AlertDataRequest'110            examples:111              example1:112                summary: Example from aml_alerts_5_test_predict.json113                value:114                  AlertID: 1001115                  FocusColumnValue: "PK-42101-1234567-1"116                  AlertScore: 85.5117                  CreateDate: "2025-06-15T10:30:00"118                  riskLevel: "Low"119                  MatchDetails: "{\"id\": \"PK-42101-1234567-1\", \"scenario\": \"Unusually large installment\", \"score\": 85.5, \"riskLevel\": \"Low\"}"120                  MatchInfoJson: "[{\"ID\": \"PK-42101-1234567-1\", \"TRANSACTIONAMOUNT\": 150000, \"CURRENCY\": \"PKR\", \"INSTALLMENTNUMBER\": 1}, {\"ID\": \"PK-42101-1234567-1\", \"TRANSACTIONAMOUNT\": 180000, \"CURRENCY\": \"PKR\", \"INSTALLMENTNUMBER\": 2}, {\"ID\": \"PK-42101-1234567-1\", \"TRANSACTIONAMOUNT\": 200000, \"CURRENCY\": \"PKR\", \"INSTALLMENTNUMBER\": 3}]"121                  ScenarioName: "Unusually large installment"122                  workflow: "Unassigned"123              example2:124                summary: Another example125                value:126                  AlertID: 1002127                  FocusColumnValue: "PK-35202-9876543-2"128                  AlertScore: 92.0129                  CreateDate: "2025-06-20T14:15:00"130                  riskLevel: "High"131                  MatchDetails: "{\"id\": \"PK-35202-9876543-2\", \"scenario\": \"Structuring / Smurfing activity\", \"score\": 92.0, \"riskLevel\": \"High\"}"132                  MatchInfoJson: "[{\"ID\": \"PK-35202-9876543-2\", \"TRANSACTIONAMOUNT\": 9500, \"CURRENCY\": \"PKR\", \"TRANSACTIONTYPE\": \"Cash Deposit\"}]"133                  ScenarioName: "Structuring / Smurfing activity"134                  workflow: "Unassigned"135      responses:136        '200':137          description: Prediction successful138          content:139            application/json:140              schema:141                $ref: '#/components/schemas/PredictionResponse'142              examples:143                success:144                  summary: Successful prediction145                  value:146                    status: 200147                    message: "Success"148                    data:149                      - AlertID: 1001150                        FocusColumnValue: "PK-42101-1234567-1"151                        STRScenario: "Unusually large installment"152                        Prediction: "High"153        '422':154          description: Validation error - Invalid request data155          content:156            application/json:157              schema:158                $ref: '#/components/schemas/Error'159              examples:160                validation_error:161                  summary: Missing required fields162                  value:163                    detail: "Validation error: [{'loc': ['body', 'AlertID'], 'msg': 'field required', 'type': 'value_error.missing'}]"164        '500':165          description: Server error - Internal server error occurred166          content:167            application/json:168              schema:169                $ref: '#/components/schemas/Error'170              examples:171                server_error:172                  summary: Server error example173                  value:174                    detail: "An error occurred while predicting alert priority"175      x-code-samples:176        - lang: 'cURL'177          source: |178            curl -X POST "http://localhost:8000/api/ai-service/predictalertpriority" \179              -H "Content-Type: application/json" \180              -d '{181                "AlertID": 1001,182                "FocusColumnValue": "PK-42101-1234567-1",183                "AlertScore": 85.5,184                "CreateDate": "2025-06-15T10:30:00",185                "riskLevel": "Low",186                "MatchInfoJson": "[{\"ID\": \"PK-42101-1234567-1\", \"TRANSACTIONAMOUNT\": 150000, \"CURRENCY\": \"PKR\", \"INSTALLMENTNUMBER\": 1}]",187                "ScenarioName": "Unusually large installment",188                "workflow": "Unassigned"189              }'190        - lang: 'Python'191          source: |192            import requests193            194            response = requests.post(195                "http://localhost:8000/api/ai-service/predictalertpriority",196                json={197                    "AlertID": 1001,198                    "FocusColumnValue": "PK-42101-1234567-1",199                    "AlertScore": 85.5,200                    "CreateDate": "2025-06-15T10:30:00",201                    "riskLevel": "Low",202                    "MatchInfoJson": "[{\"ID\": \"PK-42101-1234567-1\", \"TRANSACTIONAMOUNT\": 150000, \"CURRENCY\": \"PKR\", \"INSTALLMENTNUMBER\": 1}]",203                    "ScenarioName": "Unusually large installment",204                    "workflow": "Unassigned"205                }206            )207            print(response.json())208        - lang: 'JavaScript'209          source: |210            fetch('http://localhost:8000/api/ai-service/predictalertpriority', {211              method: 'POST',212              headers: {213                'Content-Type': 'application/json'214              },215              body: JSON.stringify({216                AlertID: 1001,217                FocusColumnValue: "PK-42101-1234567-1",218                AlertScore: 85.5,219                CreateDate: "2025-06-15T10:30:00",220                riskLevel: "Low",221                MatchInfoJson: "[{\"ID\": \"PK-42101-1234567-1\", \"TRANSACTIONAMOUNT\": 150000, \"CURRENCY\": \"PKR\", \"INSTALLMENTNUMBER\": 1}]",222                ScenarioName: "Unusually large installment",223                workflow: "Unassigned"224              })225            })226            .then(response => response.json())227            .then(data => console.log(data));228 229  /api/ai-service/generateamlanalysisoai:230    post:231      tags:232        - Analysis Generation233      summary: Generate AML analysis (OpenAI GPT)234      description: |235        Generate comprehensive AML analysis report using OpenAI GPT models.236        Supports single alert or array of alerts.237      operationId: generateAMLAnalysisOAI238      security: []239      requestBody:240        required: true241        content:242          application/json:243            schema:244              oneOf:245                - $ref: '#/components/schemas/AnalysisAlertRequest'246                - type: array247                  items:248                    $ref: '#/components/schemas/AnalysisAlertRequest'249            examples:250              single:251                summary: Single alert example from aml_alerts_2_example.json252                value:253                  AlertID: 1254                  FilteredTransactions: "[{\"CUSTOMERID\":\"100001\",\"IDENTITYNUMBERS\":\"42101-1234567-1\",\"LOANID\":\"LN2024001\",\"ACCOUNTID\":\"AC100001\",\"CREATEDDATE\":\"2025-06-01 10:15:00\",\"TRANSACTIONAMOUNT\":150000.0,\"CURRENCY\":\"PKR\",\"INSTALLMENTNUMBER\":1,\"EXCESSAMOUNT\":0.0},{\"CUSTOMERID\":\"100001\",\"IDENTITYNUMBERS\":\"42101-1234567-1\",\"LOANID\":\"LN2024001\",\"ACCOUNTID\":\"AC100001\",\"CREATEDDATE\":\"2025-06-15 14:20:00\",\"TRANSACTIONAMOUNT\":180000.0,\"CURRENCY\":\"PKR\",\"INSTALLMENTNUMBER\":2,\"EXCESSAMOUNT\":0.0}]"255                  FocusColumnValue: "100001"256                  KYCMonthlyIncome: "85,000 PKR"257                  KYCNoOfCredits: "3-5"258                  KYCNoOfDebits: "8-12"259                  KYCRiskCategoryValue: "Low"260                  KYCValueOfCredits: "150,000 - 200,000 PKR"261                  KYCValueOfDebits: "80,000 - 120,000 PKR"262                  OccupationValue: "Private Employee"263                  STRCount: 0264                  STRScenarioHistory: ""265                  ScenarioName: "Unusually large installment"266                  CustomerName: "Muhammad Bilal Sheikh"267                  CUSTOMERID: "100001"268                  BranchID: "KHI-DHA"269                  Country: "Pakistan"270                  CustomerType: "Retail"271                  CustomerStatus: "Retail Customer"272                  CreatedDate: "2020-01-15"273                  RelationshipStartDate: "2020-01-15"274                  RiskScore: "4.2"275                  PreviousAlerts: []276                  Counterparties: []277                  BranchQueries:278                    Requested: "Verification required for loan installments totaling 530,000 PKR within one month, significantly exceeding declared monthly income of 85,000 PKR. Please confirm source of funds and provide documentation for additional income sources."279                    Response: "Customer stated installments are from remittances received from brother working in UAE, family savings from wedding expenses, and advance salary from employer for Eid holidays. Customer provided remittance receipts and employer letter."280              multiple:281                summary: Multiple alerts282                value:283                  - AlertID: 1284                    FocusColumnValue: "100001"285                    ScenarioName: "Unusually large installment"286                  - AlertID: 2287                    FocusColumnValue: "100002"288                    ScenarioName: "Structuring / Smurfing activity"289      responses:290        '200':291          description: Analysis generated successfully292          content:293            application/json:294              schema:295                $ref: '#/components/schemas/AnalysisResponse'296              examples:297                success:298                  summary: Successful analysis generation299                  value:300                    status: 200301                    message: "Success"302                    data:303                      - AlertID: 1304                        FocusColumnValue: "100001"305                        analysis: "**CONCLUSION UP FRONT**\nESCALATE - Multiple red flags detected including unusual transaction amounts, unknown counterparties, and pattern consistent with money laundering activities.\n\n**INITIAL RISK**\n- Alerted Scenario / Rule ID: Unusually large installment\n\n**REVIEWED PERIOD**\n- Analysis Date: 2025-06-15\n- Transaction Period: Based on provided transaction data\n\n**TRANSACTION REVIEW**\n- Transaction Data: [{\"CUSTOMERID\":\"100001\",\"TRANSACTIONAMOUNT\":150000.0,\"CURRENCY\":\"PKR\"}]\n- Risk Assessment: HIGH RISK - Immediate STR filing recommended\n\n**RESEARCH ON FOCUS**\n- KYC Profile:\n  - Monthly Income: 85,000 PKR\n  - Occupation: Private Employee\n  - Risk Category: Low\n  - Expected Credits: 3-5\n  - Expected Debits: 8-12\n\n**FINAL ASSESSMENT**\nFile STR immediately and freeze account pending investigation"306        '422':307          description: Validation error - Invalid request data308          content:309            application/json:310              schema:311                $ref: '#/components/schemas/Error'312              examples:313                validation_error:314                  summary: Validation error example315                  value:316                    detail: "Validation error: [{'loc': ['body', 'AlertID'], 'msg': 'field required', 'type': 'value_error.missing'}]"317        '500':318          description: Server error - Internal server error or OpenAI API error319          content:320            application/json:321              schema:322                $ref: '#/components/schemas/Error'323              examples:324                server_error:325                  summary: Server error example326                  value:327                    detail: "An error occurred while generating AML analysis using oai"328                openai_error:329                  summary: OpenAI API error330                  value:331                    detail: "OpenAI API error: Rate limit exceeded"332      x-code-samples:333        - lang: 'cURL'334          source: |335            curl -X POST "http://localhost:8000/api/ai-service/generateamlanalysisoai" \336              -H "Content-Type: application/json" \337              -d '{338                "AlertID": 1,339                "FocusColumnValue": "100001",340                "ScenarioName": "Unusually large installment",341                "FilteredTransactions": "[{\"CUSTOMERID\":\"100001\",\"TRANSACTIONAMOUNT\":150000.0,\"CURRENCY\":\"PKR\"}]",342                "KYCMonthlyIncome": "85,000 PKR"343              }'344        - lang: 'Python'345          source: |346            import requests347            348            response = requests.post(349                "http://localhost:8000/api/ai-service/generateamlanalysisoai",350                json={351                    "AlertID": 1,352                    "FocusColumnValue": "100001",353                    "ScenarioName": "Unusually large installment",354                    "FilteredTransactions": "[{\"CUSTOMERID\":\"100001\",\"TRANSACTIONAMOUNT\":150000.0,\"CURRENCY\":\"PKR\"}]",355                    "KYCMonthlyIncome": "85,000 PKR"356                }357            )358            print(response.json())359 360  /api/ai-service/generateamlanalysis:361    post:362      tags:363        - Analysis Generation364      summary: Generate AML analysis (Hybrid Template+LLM)365      description: |366        Generate AML analysis report using Hybrid Template+LLM system.367        Supports local Ollama LLM, cloud OpenRouter LLM, or remote Ollama server.368        369        **Parameters**:370        - `Cloud`: Use OpenRouter cloud LLM (requires OPENROUTER_API_KEY)371        - `llm_on_server`: Use LLM at specified URL372        - `url`: URL of remote Ollama server (required if llm_on_server=true)373      operationId: generateAMLAnalysis374      security: []375      requestBody:376        required: true377        content:378          application/json:379            schema:380              allOf:381                - $ref: '#/components/schemas/AnalysisAlertRequest'382                - type: object383                  properties:384                    Cloud:385                      type: boolean386                      description: Use cloud LLM (OpenRouter)387                      default: false388                      example: false389                    llm_on_server:390                      type: boolean391                      description: Use LLM on remote server392                      default: false393                      example: false394                    url:395                      type: string396                      description: URL of remote Ollama server397                      example: http://remote-server:11434398            examples:399              local:400                summary: Local LLM example from aml_alerts_2_example.json401                value:402                  AlertID: 2403                  FilteredTransactions: "[{\"CUSTOMERID\":\"100002\",\"IDENTITYNUMBERS\":\"35202-9876543-2\",\"LOANID\":\"\",\"ACCOUNTID\":\"AC100002\",\"CREATEDDATE\":\"2025-06-02 09:30:00\",\"TRANSACTIONAMOUNT\":9500.0,\"CURRENCY\":\"PKR\",\"TRANSACTIONTYPE\":\"Cash Deposit\",\"COUNTERPARTYACCOUNT\":\"\",\"EXCESSAMOUNT\":0.0}]"404                  FocusColumnValue: "100002"405                  KYCMonthlyIncome: "55,000 PKR"406                  KYCNoOfCredits: "7"407                  KYCNoOfDebits: "6"408                  KYCRiskCategoryValue: "Medium"409                  KYCValueOfCredits: "66,500 PKR"410                  KYCValueOfDebits: "56,525 PKR"411                  OccupationValue: "Textile Trader"412                  STRCount: 2413                  STRScenarioHistory: "Large Cash Deposits, Rapid Fund Transfers"414                  ScenarioName: "Structuring / Smurfing activity"415                  CustomerName: "Ayesha Malik"416                  CUSTOMERID: "100002"417                  BranchID: "LHR-GUL"418                  Country: "Pakistan"419                  CustomerType: "Retail"420                  CustomerStatus: "Retail Customer"421                  CreatedDate: "2019-03-20"422                  RelationshipStartDate: "2019-03-20"423                  RiskScore: "8.5"424                  PreviousAlerts:425                    - AlertName: "Large Cash Deposits"426                      Description: "1,200,000 PKR deposited in cash across multiple transactions in single day"427                      BranchExplanation: "Proceeds from sale of commercial property in Faisalabad"428                      Documentation: ""429                      RiskEscalation: ""430                  Counterparties:431                    - Name: "Al-Madina Textile Machinery LLC"432                      AccountID: "AE123456789012345678"433                      Country: "United Arab Emirates"434                      Jurisdiction: "Dubai"435                      TransactionAmount: 450000.0436                      Currency: "PKR"437                      TransactionDate: "2025-06-03 10:15:00"438                      TransactionType: "Wire Transfer"439                      Relationship: "Supplier"440                      RiskLevel: "Medium"441                      ScreeningResult: "No adverse media found"442                  BranchQueries:443                    Requested: "Multiple cash deposits totaling 66,500 PKR made in same day, each below 10,000 PKR threshold. Pattern suggests potential structuring to avoid CTR reporting. Please verify legitimate business purpose and provide sales invoices or receipts."444                    Response: "Customer explained these are daily cash collections from retail textile sales at Anarkali Bazaar. Customer provided daily sales register and GST invoices. Stated pattern is normal for cash-based business operations."445                  Cloud: false446              cloud:447                summary: Cloud LLM448                value:449                  AlertID: 1450                  FocusColumnValue: "100001"451                  ScenarioName: "Unusually large installment"452                  Cloud: true453              remote:454                summary: Remote LLM server455                value:456                  AlertID: 1457                  FocusColumnValue: "100001"458                  ScenarioName: "Unusually large installment"459                  llm_on_server: true460                  url: "http://remote-ollama:11434"461      responses:462        '200':463          description: Analysis generated successfully464          content:465            application/json:466              schema:467                $ref: '#/components/schemas/HybridAnalysisResponse'468              examples:469                success_local:470                  summary: Successful analysis with local LLM471                  value:472                    status: 200473                    message: "Success"474                    data:475                      - AlertID: 2476                        FocusColumnValue: "100002"477                        analysis: "AML Investigation Report - TMS Case: Structuring / Smurfing activity\n\nCustomer Name: Ayesha Malik\nCustomer ID: 100002\nBranch ID: LHR-GUL\nCountry: Pakistan\nCustomer Status: Retail Customer\nCreated Date: 2019-03-20\n\nAlert Summary\n\nAlert Trigger:\nWe have evidence to suggest structuring activity involving multiple cash deposits totaling 66,500 PKR made in the same day, each below 10,000 PKR threshold.\n\nCustomer Profile & Historical Patterns\n\n1. Customer Background:\nCustomer is a Textile Trader with monthly income of 55,000 PKR. Customer has medium risk category with 2 previous STRs filed.\n\n2. Historical Alerts:\n\nAlert 1 - Large Cash Deposits\n1,200,000 PKR deposited in cash across multiple transactions in single day. Branch explanation indicates proceeds from sale of commercial property.\n\n3. Current Alert:\n\nCurrent Alert - Structuring / Smurfing activity\nMultiple cash deposits totaling 66,500 PKR made in same day, each below 10,000 PKR threshold. Pattern suggests potential structuring to avoid CTR reporting.\n\nTransaction Analysis\n\nBehavioural Pattern Detected:\n1. Multiple cash deposits below reporting threshold\n2. Rapid fund transfers to high-risk jurisdictions\n3. Pattern inconsistent with declared business activity\n\nConclusion & Recommendations:\n\nConclusion: We have reason to believe this activity warrants immediate STR filing.\nAction: File STR\nJustification: Multiple red flags including structuring pattern, previous STR history, and transactions to high-risk jurisdictions."478                        response_time_ms: 1234.56479                        method: "hybrid_template_only"480                        model: "granite3.1-moe:3b"481                success_cloud:482                  summary: Successful analysis with cloud LLM483                  value:484                    status: 200485                    message: "Success"486                    data:487                      - AlertID: 1488                        FocusColumnValue: "100001"489                        analysis: "AML Investigation Report - TMS Case: Unusually large installment\n\n[Complete analysis report]"490                        response_time_ms: 2345.67491                        method: "hybrid_template_cloud"492                        model: "xiaomi/mimo-v2-flash:free"493        '422':494          description: Validation error - Invalid request data495          content:496            application/json:497              schema:498                $ref: '#/components/schemas/Error'499              examples:500                validation_error:501                  summary: Validation error example502                  value:503                    detail: "Validation error: [{'loc': ['body', 'AlertID'], 'msg': 'field required', 'type': 'value_error.missing'}]"504        '500':505          description: Server error - Internal server error or LLM service unavailable506          content:507            application/json:508              schema:509                $ref: '#/components/schemas/Error'510              examples:511                server_error:512                  summary: Server error example513                  value:514                    detail: "An error occurred while generating analysis"515                ollama_error:516                  summary: Ollama service unavailable517                  value:518                    detail: "Error calling local LLM API: Connection refused"519      x-code-samples:520        - lang: 'cURL'521          source: |522            # Local LLM523            curl -X POST "http://localhost:8000/api/ai-service/generateamlanalysis" \524              -H "Content-Type: application/json" \525              -d '{526                "AlertID": 2,527                "FocusColumnValue": "100002",528                "ScenarioName": "Structuring / Smurfing activity",529                "FilteredTransactions": "[{\"CUSTOMERID\":\"100002\",\"TRANSACTIONAMOUNT\":9500.0,\"CURRENCY\":\"PKR\"}]",530                "Cloud": false531              }'532            533            # Cloud LLM534            curl -X POST "http://localhost:8000/api/ai-service/generateamlanalysis" \535              -H "Content-Type: application/json" \536              -d '{537                "AlertID": 1,538                "FocusColumnValue": "100001",539                "ScenarioName": "Unusually large installment",540                "Cloud": true541              }'542        - lang: 'Python'543          source: |544            import requests545            546            # Local LLM547            response = requests.post(548                "http://localhost:8000/api/ai-service/generateamlanalysis",549                json={550                    "AlertID": 2,551                    "FocusColumnValue": "100002",552                    "ScenarioName": "Structuring / Smurfing activity",553                    "FilteredTransactions": "[{\"CUSTOMERID\":\"100002\",\"TRANSACTIONAMOUNT\":9500.0,\"CURRENCY\":\"PKR\"}]",554                    "Cloud": False555                }556            )557            print(response.json())558            559            # Cloud LLM560            response = requests.post(561                "http://localhost:8000/api/ai-service/generateamlanalysis",562                json={563                    "AlertID": 1,564                    "FocusColumnValue": "100001",565                    "ScenarioName": "Unusually large installment",566                    "Cloud": True567                }568            )569            print(response.json())570 571  /api/ai-service/generateamlanalysisstreaming:572    post:573      tags:574        - Analysis Generation575      summary: Generate AML analysis (Streaming)576      description: |577        Generate AML analysis report with Server-Sent Events (SSE) streaming.578        Uses Hybrid Template+LLM system.579      operationId: generateAMLAnalysisStreaming580      security: []581      requestBody:582        required: true583        content:584          application/json:585            schema:586              $ref: '#/components/schemas/AnalysisAlertRequest'587            examples:588              example:589                summary: Streaming example590                value:591                  AlertID: 2592                  FocusColumnValue: "100002"593                  ScenarioName: "Structuring / Smurfing activity"594                  FilteredTransactions: "[{\"CUSTOMERID\":\"100002\",\"TRANSACTIONAMOUNT\":9500.0,\"CURRENCY\":\"PKR\"}]"595      responses:596        '200':597          description: Streaming response598          content:599            text/plain:600              schema:601                type: string602                description: Server-Sent Events stream603                example: |604                  data: {"AlertID":2,"analysis":"...","response_time_ms":1234.56}605                  606                  data: {"status":"error","message":"Error message"}607                  608        '422':609          description: Validation error - Invalid request data610          content:611            application/json:612              schema:613                $ref: '#/components/schemas/Error'614              examples:615                validation_error:616                  summary: Validation error example617                  value:618                    detail: "Validation error: [{'loc': ['body', 'AlertID'], 'msg': 'field required', 'type': 'value_error.missing'}]"619        '500':620          description: Server error - Internal server error or streaming error621          content:622            application/json:623              schema:624                $ref: '#/components/schemas/Error'625              examples:626                server_error:627                  summary: Server error example628                  value:629                    detail: "An error occurred while generating analysis streaming"630      x-code-samples:631        - lang: 'cURL'632          source: |633            curl -X POST "http://localhost:8000/api/ai-service/generateamlanalysisstreaming" \634              -H "Content-Type: application/json" \635              -d '{636                "AlertID": 2,637                "FocusColumnValue": "100002",638                "ScenarioName": "Structuring / Smurfing activity",639                "FilteredTransactions": "[{\"CUSTOMERID\":\"100002\",\"TRANSACTIONAMOUNT\":9500.0,\"CURRENCY\":\"PKR\"}]"640              }' \641              --no-buffer642        - lang: 'JavaScript'643          source: |644            const eventSource = new EventSource('http://localhost:8000/api/ai-service/generateamlanalysisstreaming');645            646            // For POST requests, use fetch with streaming647            fetch('http://localhost:8000/api/ai-service/generateamlanalysisstreaming', {648              method: 'POST',649              headers: {650                'Content-Type': 'application/json'651              },652              body: JSON.stringify({653                AlertID: 2,654                FocusColumnValue: "100002",655                ScenarioName: "Structuring / Smurfing activity"656              })657            })658            .then(response => {659              const reader = response.body.getReader();660              const decoder = new TextDecoder();661              662              function readStream() {663                reader.read().then(({ done, value }) => {664                  if (done) return;665                  const chunk = decoder.decode(value);666                  const lines = chunk.split('\\n');667                  lines.forEach(line => {668                    if (line.startsWith('data: ')) {669                      const data = JSON.parse(line.slice(6));670                      console.log('Analysis:', data.analysis);671                    }672                  });673                  readStream();674                });675              }676              readStream();677            });678 679  /api/ai-service/sendalertsemailjson:680    post:681      tags:682        - Email Alerts683      summary: Send email alerts (JSON)684      description: |685        Send email alerts to compliance team for high-risk transactions using JSON input.686        Email is sent if STRCount > 0 OR (RevertedCount / TotalCount) * 100 > 50.687        688        **Status**: Optional/Future Feature - This endpoint is currently disabled in the application.689        To enable, uncomment the email router in app.py and configure email settings.690      operationId: sendAlertsEmailJson691      security: []692      requestBody:693        required: true694        content:695          application/json:696            schema:697              $ref: '#/components/schemas/EmailAlertData'698            examples:699              example:700                summary: Email alert request701                value:702                  to_emails:703                    - analyst1@example.com704                    - analyst2@example.com705                  alert_details:706                    AlertID: 12345707                    FocusColumnValue: "100001"708                    STRCount: 2709                    RevertedCount: 1710                    TotalCount: 3711                    CustomerName: "Muhammad Bilal Sheikh"712                    AccountNumber: "1234567890"713                    TransactionID: 98765714                    TransactionDate: "2025-06-15"715      responses:716        '200':717          description: Email sent successfully718          content:719            application/json:720              schema:721                type: array722                items:723                  $ref: '#/components/schemas/EmailResponse'724              examples:725                success:726                  summary: Successful email sending727                  value:728                    - status: "success"729                      alert_id: 12345730                      message: "Email sent successfully for Alert ID: 12345"731                partial_success:732                  summary: Partial success with some errors733                  value:734                    - status: "success"735                      alert_id: 12345736                      message: "Email sent successfully for Alert ID: 12345"737                    - status: "error"738                      alert_id: 12346739                      message: "Failed to send email for Alert ID: 12346: SMTP connection timeout"740        '500':741          description: Server error - Email service unavailable or configuration error742          content:743            application/json:744              schema:745                $ref: '#/components/schemas/Error'746              examples:747                server_error:748                  summary: Server error example749                  value:750                    detail: "Error sending alert emails from JSON data"751                email_config_error:752                  summary: Email configuration error753                  value:754                    detail: "Email sending failed: SMTP authentication failed"755 756  /api/ai-service/sendalertsemaildataframe:757    post:758      tags:759        - Email Alerts760      summary: Send email alerts (DataFrame)761      description: |762        Send email alerts from database data.763        Queries database for alerts with Prediction = 1.764        765        **Status**: Optional/Future Feature - This endpoint is currently disabled in the application.766        To enable, uncomment the email router in app.py and configure email settings.767        768        **Prerequisites**:769        - Valid `DB_CONNECTION_STR` in environment770        - `DATA_TABLE` table exists771        - Records with `Prediction = 1` in the table772        - Email configuration (`FROM_EMAIL`, `EMAIL_PASSWORD`)773      operationId: sendAlertsEmailDataFrame774      security: []775      requestBody:776        required: true777        content:778          application/json:779            schema:780              type: array781              items:782                type: string783                format: email784            description: List of recipient email addresses785            example:786              - analyst1@example.com787              - analyst2@example.com788      responses:789        '200':790          description: Email sent successfully791          content:792            application/json:793              schema:794                type: array795                items:796                  $ref: '#/components/schemas/EmailResponse'797              examples:798                success:799                  summary: Successful email sending800                  value:801                    - status: "success"802                      alert_id: 12345803                      message: "Email sent successfully for Alert ID: 12345"804                    - status: "success"805                      alert_id: 12346806                      message: "Email sent successfully for Alert ID: 12346"807                partial_success:808                  summary: Partial success with some errors809                  value:810                    - status: "success"811                      alert_id: 12345812                      message: "Email sent successfully for Alert ID: 12345"813                    - status: "error"814                      alert_id: 12346815                      message: "Failed to send email for Alert ID: 12346: SMTP connection timeout"816        '500':817          description: Server error - Database connection error or email service unavailable818          content:819            application/json:820              schema:821                $ref: '#/components/schemas/Error'822              examples:823                server_error:824                  summary: Server error example825                  value:826                    detail: "Error sending alert emails from DataFrame data"827                database_error:828                  summary: Database connection error829                  value:830                    detail: "Database connection failed: Unable to connect to SQL Server"831      x-code-samples:832        - lang: 'cURL'833          source: |834            curl -X POST "http://localhost:8000/api/ai-service/sendalertsemaildataframe" \835              -H "Content-Type: application/json" \836              -d '["analyst1@example.com", "analyst2@example.com"]'837        - lang: 'Python'838          source: |839            import requests840            841            response = requests.post(842                "http://localhost:8000/api/ai-service/sendalertsemaildataframe",843                json=["analyst1@example.com", "analyst2@example.com"]844            )845            print(response.json())846                server_error:847                  summary: Server error example848                  value:849                    detail: "Error sending alert emails from JSON data"850                email_config_error:851                  summary: Email configuration error852                  value:853                    detail: "Email sending failed: SMTP authentication failed"854      x-code-samples:855        - lang: 'cURL'856          source: |857            curl -X POST "http://localhost:8000/api/ai-service/sendalertsemailjson" \858              -H "Content-Type: application/json" \859              -d '{860                "to_emails": ["analyst@example.com"],861                "alert_details": {862                  "AlertID": 12345,863                  "FocusColumnValue": "100001",864                  "STRCount": 2,865                  "RevertedCount": 1,866                  "TotalCount": 3,867                  "CustomerName": "Muhammad Bilal Sheikh",868                  "AccountNumber": "1234567890",869                  "TransactionID": 98765,870                  "TransactionDate": "2025-06-15"871                }872              }'873        - lang: 'Python'874          source: |875            import requests876            877            response = requests.post(878                "http://localhost:8000/api/ai-service/sendalertsemailjson",879                json={880                    "to_emails": ["analyst@example.com"],881                    "alert_details": {882                        "AlertID": 12345,883                        "FocusColumnValue": "100001",884                        "STRCount": 2,885                        "RevertedCount": 1,886                        "TotalCount": 3,887                        "CustomerName": "Muhammad Bilal Sheikh",888                        "AccountNumber": "1234567890",889                        "TransactionID": 98765,890                        "TransactionDate": "2025-06-15"891                    }892                }893            )894            print(response.json())895 896components:897  securitySchemes:898    bearerAuth:899      type: http900      scheme: bearer901      bearerFormat: JWT902      description: JWT token obtained from /api/ai-service/token (Optional - only for external integrations)903 904  schemas:905    Token:906      type: object907      required:908        - access_token909        - token_type910      properties:911        access_token:912          type: string913          description: JWT access token914          example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...915        token_type:916          type: string917          enum: [bearer]918          example: bearer919 920    Error:921      type: object922      required:923        - detail924      properties:925        detail:926          oneOf:927            - type: string928              description: Error message string929              example: "An error occurred while generating analysis"930            - type: array931              description: Validation error details array932              items:933                type: object934                properties:935                  loc:936                    type: array937                    items:938                      type: string939                    description: Location of the error in the request940                    example: ["body", "AlertID"]941                  msg:942                    type: string943                    description: Error message944                    example: "field required"945                  type:946                    type: string947                    description: Error type948                    example: "value_error.missing"949              example:950                - loc: ["body", "AlertID"]951                  msg: "field required"952                  type: "value_error.missing"953      examples:954        string_error:955          summary: String error message956          value:957            detail: "An error occurred while generating analysis"958        validation_error:959          summary: Validation error array960          value:961            detail:962              - loc: ["body", "AlertID"]963                msg: "field required"964                type: "value_error.missing"965              - loc: ["body", "FocusColumnValue"]966                msg: "field required"967                type: "value_error.missing"968 969    AnalysisAlertRequest:970      type: object971      description: Request model for analysis generation. All fields are optional.972      properties:973        AlertID:974          type: integer975          description: Unique alert identifier976          example: 1977        FilteredTransactions:978          type: string979          description: JSON array string with transaction details980          example: "[{\"CUSTOMERID\":\"100001\",\"TRANSACTIONAMOUNT\":150000.0,\"CURRENCY\":\"PKR\"}]"981        FocusColumnValue:982          type: string983          description: Customer/entity identifier984          example: "100001"985        KYCMonthlyIncome:986          type: string987          description: Monthly income range988          example: "85,000 PKR"989        KYCNoOfCredits:990          type: string991          description: Expected number of credits992          example: "3-5"993        KYCNoOfDebits:994          type: string995          description: Expected number of debits996          example: "8-12"997        KYCRiskCategoryValue:998          type: string999          description: KYC risk category1000          enum: [Low, Medium, High]1001          example: Low1002        KYCValueOfCredits:1003          type: string1004          description: Expected value of credits1005          example: "150,000 - 200,000 PKR"1006        KYCValueOfDebits:1007          type: string1008          description: Expected value of debits1009          example: "80,000 - 120,000 PKR"1010        OccupationValue:1011          type: string1012          description: Customer occupation1013          example: Private Employee1014        STRCount:1015          type: integer1016          description: Count of previous STRs1017          default: 01018          example: 01019        STRScenarioHistory:1020          type: string1021          description: History of STR scenarios1022          default: ""1023          example: ""1024        ScenarioName:1025          type: string1026          description: Alert scenario name1027          example: Unusually large installment1028        CustomerName:1029          type: string1030          description: Customer full name1031          example: Muhammad Bilal Sheikh1032        CUSTOMERID:1033          type: string1034          description: Customer ID1035          example: "100001"1036        BranchID:1037          type: string1038          description: Branch identifier1039          example: KHI-DHA1040        Country:1041          type: string1042          description: Customer country1043          example: Pakistan1044        CustomerType:1045          type: string1046          description: Customer type1047          example: Retail1048        CustomerStatus:1049          type: string1050          description: Customer status1051          example: Retail Customer1052        CreatedDate:1053          type: string1054          format: date1055          description: Account creation date1056          example: "2020-01-15"1057        RelationshipStartDate:1058          type: string1059          format: date1060          description: Relationship start date1061          example: "2020-01-15"1062        RiskScore:1063          type: string1064          description: Risk score1065          example: "4.2"1066        PreviousAlerts:1067          type: array1068          description: Array of previous alert objects1069          items:1070            type: object1071            properties:1072              AlertName:1073                type: string1074                example: Large Cash Deposits1075              Description:1076                type: string1077                example: 1,200,000 PKR deposited in cash across multiple transactions in single day1078              BranchExplanation:1079                type: string1080                example: Proceeds from sale of commercial property in Faisalabad1081              Documentation:1082                type: string1083                example: ""1084              RiskEscalation:1085                type: string1086                example: ""1087          example: []1088        Counterparties:1089          type: array1090          description: Array of counterparty objects1091          items:1092            type: object1093            properties:1094              Name:1095                type: string1096                example: Al-Madina Textile Machinery LLC1097              AccountID:1098                type: string1099                example: AE1234567890123456781100              Country:1101                type: string1102                example: United Arab Emirates1103              Jurisdiction:1104                type: string1105                example: Dubai1106              TransactionAmount:1107                type: number1108                format: float1109                example: 450000.01110              Currency:1111                type: string1112                example: PKR1113              TransactionDate:1114                type: string1115                example: "2025-06-03 10:15:00"1116              TransactionType:1117                type: string1118                example: Wire Transfer1119              Relationship:1120                type: string1121                example: Supplier1122              RiskLevel:1123                type: string1124                example: Medium1125              ScreeningResult:1126                type: string1127                example: No adverse media found1128          example: []1129        BranchQueries:1130          type: object1131          description: Branch query request/response1132          properties:1133            Requested:1134              type: string1135              example: Verification required for loan installments totaling 530,000 PKR within one month, significantly exceeding declared monthly income of 85,000 PKR. Please confirm source of funds and provide documentation for additional income sources.1136            Response:1137              type: string1138              example: Customer stated installments are from remittances received from brother working in UAE, family savings from wedding expenses, and advance salary from employer for Eid holidays. Customer provided remittance receipts and employer letter.1139          example:1140            Requested: "Verification required..."1141            Response: "Customer stated..."1142 1143    AlertDataRequest:1144      type: object1145      description: Request model for ML prediction. AlertID and FocusColumnValue are required, all other fields are optional.1146      required:1147        - AlertID1148        - FocusColumnValue1149      properties:1150        AlertID:1151          type: integer1152          description: Unique alert identifier1153          example: 10011154        FocusColumnValue:1155          type: string1156          description: Customer/entity identifier1157          example: "PK-42101-1234567-1"1158        AlertScore:1159          type: number1160          format: float1161          description: Alert risk score (0-100)1162          example: 85.51163        CreateDate:1164          type: string1165          format: date-time1166          description: Alert creation date1167          example: "2025-06-15T10:30:00"1168        riskLevel:1169          type: string1170          description: Risk level1171          enum: [Low, Medium, High]1172          example: Low1173        MatchDetails:1174          type: string1175          description: JSON string with match details1176          example: "{\"id\": \"PK-42101-1234567-1\", \"scenario\": \"Unusually large installment\", \"score\": 85.5, \"riskLevel\": \"Low\"}"1177        MatchInfoJson:1178          type: string1179          description: JSON array string with transaction details1180          example: "[{\"ID\": \"PK-42101-1234567-1\", \"TRANSACTIONAMOUNT\": 150000, \"CURRENCY\": \"PKR\", \"INSTALLMENTNUMBER\": 1}]"1181        ScenarioName:1182          type: string1183          description: Alert scenario name1184          example: Unusually large installment1185        workflow:1186          type: string1187          description: Current workflow status1188          example: Unassigned1189 1190    PredictionResponse:1191      type: object1192      properties:1193        status:1194          type: integer1195          example: 2001196        message:1197          type: string1198          example: Success1199        data:1200          type: array

Showing the first 1,200 of 1367 lines. Download the file for the rest.