rust-kgdb 0.5.5 → 0.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +49 -0
- package/README.md +128 -0
- package/examples/fraud-detection-agent.js +134 -0
- package/examples/hypermind-complete-demo.js +926 -0
- package/examples/underwriting-agent.js +127 -0
- package/package.json +1 -1
|
@@ -533,6 +533,133 @@ async function main() {
|
|
|
533
533
|
console.log(` Model: ${witness.model}`)
|
|
534
534
|
console.log(` Tools executed: ${witness.tools.length}`)
|
|
535
535
|
console.log()
|
|
536
|
+
|
|
537
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
538
|
+
// PHASE 6: CONVERSATIONAL AGENT DEMONSTRATION
|
|
539
|
+
// This shows how an underwriter would naturally interact with the agent
|
|
540
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
541
|
+
|
|
542
|
+
console.log('═'.repeat(78))
|
|
543
|
+
console.log(' CONVERSATIONAL AGENT DEMONSTRATION')
|
|
544
|
+
console.log(' Natural Language Interaction for Underwriting')
|
|
545
|
+
console.log('═'.repeat(78))
|
|
546
|
+
console.log()
|
|
547
|
+
|
|
548
|
+
// Simulated conversation
|
|
549
|
+
console.log(' ┌──────────────────────────────────────────────────────────────────────┐')
|
|
550
|
+
console.log(' │ USER: "What accounts need my attention today and why?" │')
|
|
551
|
+
console.log(' └──────────────────────────────────────────────────────────────────────┘')
|
|
552
|
+
console.log()
|
|
553
|
+
|
|
554
|
+
// Agent reasoning
|
|
555
|
+
console.log(' Agent Reasoning:')
|
|
556
|
+
console.log(' ─────────────────')
|
|
557
|
+
console.log(' 1. Parsing intent: underwriting queue prioritization')
|
|
558
|
+
console.log(' 2. Required data: risk scores, loss ratios, rule violations')
|
|
559
|
+
console.log(' 3. Tool selection: kg.sparql.query, kg.graphframe.pagerank, kg.datalog.infer')
|
|
560
|
+
console.log(' 4. Type checking: all tools compatible for risk assessment pipeline')
|
|
561
|
+
console.log()
|
|
562
|
+
|
|
563
|
+
// Agent response
|
|
564
|
+
console.log(' ┌──────────────────────────────────────────────────────────────────────┐')
|
|
565
|
+
console.log(' │ AGENT RESPONSE: │')
|
|
566
|
+
console.log(' └──────────────────────────────────────────────────────────────────────┘')
|
|
567
|
+
console.log()
|
|
568
|
+
console.log(' I analyzed your underwriting queue and found the following:')
|
|
569
|
+
console.log()
|
|
570
|
+
|
|
571
|
+
if (referToUW.length > 0) {
|
|
572
|
+
console.log(' [ATTENTION REQUIRED] ACCOUNTS FOR MANUAL REVIEW:')
|
|
573
|
+
console.log(' ────────────────────────────────────────────────')
|
|
574
|
+
referToUW.forEach(r => {
|
|
575
|
+
console.log(` - ${r.args[0]}: Flagged by Datalog rule for elevated risk`)
|
|
576
|
+
})
|
|
577
|
+
console.log()
|
|
578
|
+
console.log(' WHY THESE NEED REVIEW:')
|
|
579
|
+
console.log(' Rule triggered: refer_to_underwriter(?A) :-')
|
|
580
|
+
console.log(' account(?A), loss_ratio(?A, ?L),')
|
|
581
|
+
console.log(' ?L > 0.5.')
|
|
582
|
+
console.log()
|
|
583
|
+
console.log(' This rule encodes industry best practice:')
|
|
584
|
+
console.log(' "Accounts with loss ratio > 50% require human judgment"')
|
|
585
|
+
console.log()
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
if (autoApprove.length > 0) {
|
|
589
|
+
console.log(' [AUTO-APPROVED] LOW-RISK ACCOUNTS:')
|
|
590
|
+
console.log(' ──────────────────────────────────')
|
|
591
|
+
autoApprove.forEach(a => {
|
|
592
|
+
console.log(` - ${a.args[0]}: Meets all auto-approval criteria`)
|
|
593
|
+
})
|
|
594
|
+
console.log()
|
|
595
|
+
console.log(' Rule: auto_approve(?A) :- account(?A), loss_ratio(?A, ?L),')
|
|
596
|
+
console.log(' years_business(?A, ?Y), ?L < 0.35, ?Y > 5.')
|
|
597
|
+
console.log()
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
console.log(' PREMIUM RECOMMENDATIONS:')
|
|
601
|
+
console.log(' ────────────────────────')
|
|
602
|
+
premiums.forEach(p => {
|
|
603
|
+
const flag = p.decision === 'refer' ? ' [NEEDS REVIEW]' : ''
|
|
604
|
+
console.log(` ${p.id}: $${p.premium.toLocaleString()}/year${flag}`)
|
|
605
|
+
})
|
|
606
|
+
console.log()
|
|
607
|
+
|
|
608
|
+
// Follow-up
|
|
609
|
+
console.log(' ┌──────────────────────────────────────────────────────────────────────┐')
|
|
610
|
+
console.log(' │ USER: "Why is TransCo flagged for review?" │')
|
|
611
|
+
console.log(' └──────────────────────────────────────────────────────────────────────┘')
|
|
612
|
+
console.log()
|
|
613
|
+
console.log(' ┌──────────────────────────────────────────────────────────────────────┐')
|
|
614
|
+
console.log(' │ AGENT RESPONSE: │')
|
|
615
|
+
console.log(' └──────────────────────────────────────────────────────────────────────┘')
|
|
616
|
+
console.log()
|
|
617
|
+
console.log(' TransCo Logistics (BUS003) was flagged for the following reasons:')
|
|
618
|
+
console.log()
|
|
619
|
+
console.log(' DATALOG RULE FIRED:')
|
|
620
|
+
console.log(' ┌────────────────────────────────────────────────────────────────────┐')
|
|
621
|
+
console.log(' │ refer_to_underwriter(?A) :- │')
|
|
622
|
+
console.log(' │ account(?A), │')
|
|
623
|
+
console.log(' │ loss_ratio(?A, ?L), │')
|
|
624
|
+
console.log(' │ ?L > 0.5. │')
|
|
625
|
+
console.log(' └────────────────────────────────────────────────────────────────────┘')
|
|
626
|
+
console.log()
|
|
627
|
+
console.log(' MATCHING FACTS:')
|
|
628
|
+
console.log(' account(BUS003) ✓ TransCo is an account')
|
|
629
|
+
console.log(' loss_ratio(BUS003, 0.65) ✓ Loss ratio is 65%')
|
|
630
|
+
console.log(' 0.65 > 0.5 ✓ Threshold exceeded')
|
|
631
|
+
console.log()
|
|
632
|
+
console.log(' ADDITIONAL RISK FACTORS FROM GRAPHFRAME:')
|
|
633
|
+
console.log(' - Industry: Transportation (high-risk sector)')
|
|
634
|
+
console.log(' - PageRank Score: Indicates high network centrality')
|
|
635
|
+
console.log(' - Embedding Similarity: Clusters with other high-risk accounts')
|
|
636
|
+
console.log()
|
|
637
|
+
console.log(' RECOMMENDATION:')
|
|
638
|
+
console.log(' Review loss history in detail. Consider:')
|
|
639
|
+
console.log(' - Driver safety programs')
|
|
640
|
+
console.log(' - Fleet telematics requirements')
|
|
641
|
+
console.log(' - Higher deductible options')
|
|
642
|
+
console.log()
|
|
643
|
+
|
|
644
|
+
// Value proposition
|
|
645
|
+
console.log(' ═══════════════════════════════════════════════════════════════════════')
|
|
646
|
+
console.log(' WHY THIS MATTERS FOR UNDERWRITING:')
|
|
647
|
+
console.log(' ────────────────────────────────────')
|
|
648
|
+
console.log(' Unlike vanilla LLMs that might say "this looks risky":')
|
|
649
|
+
console.log()
|
|
650
|
+
console.log(' HyperMind provides:')
|
|
651
|
+
console.log(' ✓ Specific rule that triggered the flag')
|
|
652
|
+
console.log(' ✓ Exact facts that matched the rule')
|
|
653
|
+
console.log(' ✓ Quantified metrics (65% loss ratio)')
|
|
654
|
+
console.log(' ✓ Audit trail with cryptographic hash')
|
|
655
|
+
console.log()
|
|
656
|
+
console.log(' Regulators and auditors can verify:')
|
|
657
|
+
console.log(' "This account was flagged because rule R1 matched facts F1, F2, F3"')
|
|
658
|
+
console.log()
|
|
659
|
+
console.log(' This is how AI should work in regulated industries.')
|
|
660
|
+
console.log(' ═══════════════════════════════════════════════════════════════════════')
|
|
661
|
+
console.log()
|
|
662
|
+
|
|
536
663
|
console.log('═'.repeat(78))
|
|
537
664
|
console.log()
|
|
538
665
|
console.log('HyperMind Agent completed successfully.')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rust-kgdb",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.6",
|
|
4
4
|
"description": "Production-grade Neuro-Symbolic AI Framework: +86.4% accuracy improvement over vanilla LLMs. High-performance knowledge graph (2.78µs lookups, 35x faster than RDFox). Features fraud detection, underwriting agents, WASM sandbox, type/category/proof theory, and W3C SPARQL 1.1 compliance.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|