rust-kgdb 0.6.3 → 0.6.5
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/README.md +38 -23
- package/examples/core-concepts-demo.ts +50 -35
- package/examples/datalog-example.ts +246 -339
- package/examples/fraud-detection-agent.js +23 -36
- package/examples/hypermind-fraud-underwriter.ts +54 -51
- package/examples/underwriting-agent.js +16 -20
- package/hypermind-agent.js +1003 -2347
- package/index.d.ts +79 -0
- package/package.json +1 -1
- package/rust-kgdb-napi.darwin-x64.node +0 -0
package/index.d.ts
CHANGED
|
@@ -1370,6 +1370,43 @@ export interface MemoryRetrievalResults {
|
|
|
1370
1370
|
combined: Array<{ score: number; source: string; [key: string]: unknown }>
|
|
1371
1371
|
}
|
|
1372
1372
|
|
|
1373
|
+
/**
|
|
1374
|
+
* Options for recallWithKG - unified memory + knowledge graph retrieval
|
|
1375
|
+
*/
|
|
1376
|
+
export interface RecallWithKGOptions {
|
|
1377
|
+
/** Natural language query for semantic retrieval */
|
|
1378
|
+
query: string
|
|
1379
|
+
/** Optional KG filter constraint */
|
|
1380
|
+
kgFilter?: {
|
|
1381
|
+
predicate: string
|
|
1382
|
+
operator: 'gt' | 'lt' | 'eq' | 'gte' | 'lte'
|
|
1383
|
+
value: number | string
|
|
1384
|
+
}
|
|
1385
|
+
/** Maximum results to return (default: 10) */
|
|
1386
|
+
limit?: number
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
/**
|
|
1390
|
+
* Result from recallWithKG - combines episodic memory with KG context
|
|
1391
|
+
*/
|
|
1392
|
+
export interface RecallWithKGResult {
|
|
1393
|
+
/** Retrieved results combining memory episodes with KG entities */
|
|
1394
|
+
results: Array<{
|
|
1395
|
+
/** Episode URI from memory graph */
|
|
1396
|
+
episode: string
|
|
1397
|
+
/** Original prompt/finding from episode */
|
|
1398
|
+
finding: string
|
|
1399
|
+
/** Related KG context (entities, properties) */
|
|
1400
|
+
kgContext: Record<string, unknown>
|
|
1401
|
+
/** Semantic hash for deduplication */
|
|
1402
|
+
semanticHash: string
|
|
1403
|
+
}>
|
|
1404
|
+
/** Whether result was served from semantic cache */
|
|
1405
|
+
fromCache: boolean
|
|
1406
|
+
/** Semantic hash of the query (LSH-based) */
|
|
1407
|
+
semanticHash: string
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1373
1410
|
/**
|
|
1374
1411
|
* MemoryManager - Unified memory retrieval with weighted scoring
|
|
1375
1412
|
*
|
|
@@ -1445,6 +1482,48 @@ export class MemoryManager {
|
|
|
1445
1482
|
|
|
1446
1483
|
/** Clear working memory (episodic and long-term persist) */
|
|
1447
1484
|
clearWorking(): this
|
|
1485
|
+
|
|
1486
|
+
/**
|
|
1487
|
+
* Recall memories with knowledge graph context - unified typed API
|
|
1488
|
+
*
|
|
1489
|
+
* Executes a semantic memory retrieval that joins episodic memory with
|
|
1490
|
+
* knowledge graph entities in a single atomic operation. Uses LSH-based
|
|
1491
|
+
* semantic hashing for deduplication and caching.
|
|
1492
|
+
*
|
|
1493
|
+
* Research: SimHash (Charikar 2002), Semantic Hashing (Salakhutdinov & Hinton 2009)
|
|
1494
|
+
*
|
|
1495
|
+
* @example
|
|
1496
|
+
* ```typescript
|
|
1497
|
+
* const result = await manager.recallWithKG({
|
|
1498
|
+
* query: 'Find fraud patterns for Provider P001',
|
|
1499
|
+
* kgFilter: { predicate: 'riskScore', operator: 'gt', value: 0.8 },
|
|
1500
|
+
* limit: 10
|
|
1501
|
+
* })
|
|
1502
|
+
*
|
|
1503
|
+
* for (const r of result.results) {
|
|
1504
|
+
* console.log(`Episode: ${r.episode}`)
|
|
1505
|
+
* console.log(`Finding: ${r.finding}`)
|
|
1506
|
+
* console.log(`KG Context: ${JSON.stringify(r.kgContext)}`)
|
|
1507
|
+
* console.log(`Semantic Hash: ${r.semanticHash}`)
|
|
1508
|
+
* }
|
|
1509
|
+
*
|
|
1510
|
+
* // Semantic caching: identical queries return cached results
|
|
1511
|
+
* console.log(`From cache: ${result.fromCache}`)
|
|
1512
|
+
* console.log(`Query hash: ${result.semanticHash}`)
|
|
1513
|
+
* ```
|
|
1514
|
+
*/
|
|
1515
|
+
recallWithKG(options: RecallWithKGOptions): Promise<RecallWithKGResult>
|
|
1516
|
+
|
|
1517
|
+
/**
|
|
1518
|
+
* Generate semantic hash for a query using LSH (Locality Sensitive Hashing)
|
|
1519
|
+
*
|
|
1520
|
+
* Similar queries produce similar hashes for semantic deduplication.
|
|
1521
|
+
* Based on SimHash algorithm with entity and action keyword extraction.
|
|
1522
|
+
*
|
|
1523
|
+
* @param text - Query text to hash
|
|
1524
|
+
* @returns Semantic hash in format `semhash:xxx-xxx-xxx`
|
|
1525
|
+
*/
|
|
1526
|
+
generateSemanticHash(text: string): string
|
|
1448
1527
|
}
|
|
1449
1528
|
|
|
1450
1529
|
// ==============================================
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rust-kgdb",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.5",
|
|
4
4
|
"description": "Production-grade Neuro-Symbolic AI Framework with Memory Hypergraph: +86.4% accuracy improvement over vanilla LLMs. High-performance knowledge graph (2.78µs lookups, 35x faster than RDFox). Features Memory Hypergraph (temporal scoring, rolling context window, idempotent responses), 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",
|
|
Binary file
|