@prmichaelsen/remember-mcp 1.0.6 → 1.0.7
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/dist/server-factory.js +103 -96
- package/dist/server.js +103 -96
- package/package.json +1 -1
- package/src/tools/search-memory.ts +7 -7
package/dist/server-factory.js
CHANGED
|
@@ -1409,6 +1409,103 @@ async function handleCreateMemory(args, userId, context) {
|
|
|
1409
1409
|
}
|
|
1410
1410
|
}
|
|
1411
1411
|
|
|
1412
|
+
// src/utils/weaviate-filters.ts
|
|
1413
|
+
import { Filters } from "weaviate-client";
|
|
1414
|
+
function buildCombinedSearchFilters(collection, filters) {
|
|
1415
|
+
const memoryFilters = buildDocTypeFilters(collection, "memory", filters);
|
|
1416
|
+
const relationshipFilters = buildDocTypeFilters(collection, "relationship", filters);
|
|
1417
|
+
const validFilters = [memoryFilters, relationshipFilters].filter((f) => f !== void 0 && f !== null);
|
|
1418
|
+
if (validFilters.length === 0) {
|
|
1419
|
+
return void 0;
|
|
1420
|
+
} else if (validFilters.length === 1) {
|
|
1421
|
+
return validFilters[0];
|
|
1422
|
+
} else {
|
|
1423
|
+
return combineFiltersWithOr(validFilters);
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
function buildDocTypeFilters(collection, docType, filters) {
|
|
1427
|
+
const filterList = [];
|
|
1428
|
+
filterList.push(
|
|
1429
|
+
collection.filter.byProperty("doc_type").equal(docType)
|
|
1430
|
+
);
|
|
1431
|
+
if (docType === "memory" && filters?.types && filters.types.length > 0) {
|
|
1432
|
+
if (filters.types.length === 1) {
|
|
1433
|
+
filterList.push(
|
|
1434
|
+
collection.filter.byProperty("type").equal(filters.types[0])
|
|
1435
|
+
);
|
|
1436
|
+
} else {
|
|
1437
|
+
filterList.push(
|
|
1438
|
+
collection.filter.byProperty("type").containsAny(filters.types)
|
|
1439
|
+
);
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
if (filters?.weight_min !== void 0) {
|
|
1443
|
+
filterList.push(
|
|
1444
|
+
collection.filter.byProperty("weight").greaterThanOrEqual(filters.weight_min)
|
|
1445
|
+
);
|
|
1446
|
+
}
|
|
1447
|
+
if (filters?.weight_max !== void 0) {
|
|
1448
|
+
filterList.push(
|
|
1449
|
+
collection.filter.byProperty("weight").lessThanOrEqual(filters.weight_max)
|
|
1450
|
+
);
|
|
1451
|
+
}
|
|
1452
|
+
if (filters?.trust_min !== void 0) {
|
|
1453
|
+
filterList.push(
|
|
1454
|
+
collection.filter.byProperty("trust").greaterThanOrEqual(filters.trust_min)
|
|
1455
|
+
);
|
|
1456
|
+
}
|
|
1457
|
+
if (filters?.trust_max !== void 0) {
|
|
1458
|
+
filterList.push(
|
|
1459
|
+
collection.filter.byProperty("trust").lessThanOrEqual(filters.trust_max)
|
|
1460
|
+
);
|
|
1461
|
+
}
|
|
1462
|
+
if (filters?.date_from) {
|
|
1463
|
+
filterList.push(
|
|
1464
|
+
collection.filter.byProperty("created_at").greaterThanOrEqual(new Date(filters.date_from))
|
|
1465
|
+
);
|
|
1466
|
+
}
|
|
1467
|
+
if (filters?.date_to) {
|
|
1468
|
+
filterList.push(
|
|
1469
|
+
collection.filter.byProperty("created_at").lessThanOrEqual(new Date(filters.date_to))
|
|
1470
|
+
);
|
|
1471
|
+
}
|
|
1472
|
+
if (filters?.tags && filters.tags.length > 0) {
|
|
1473
|
+
if (filters.tags.length === 1) {
|
|
1474
|
+
filterList.push(
|
|
1475
|
+
collection.filter.byProperty("tags").containsAny([filters.tags[0]])
|
|
1476
|
+
);
|
|
1477
|
+
} else {
|
|
1478
|
+
filterList.push(
|
|
1479
|
+
collection.filter.byProperty("tags").containsAny(filters.tags)
|
|
1480
|
+
);
|
|
1481
|
+
}
|
|
1482
|
+
}
|
|
1483
|
+
return combineFiltersWithAnd(filterList);
|
|
1484
|
+
}
|
|
1485
|
+
function buildMemoryOnlyFilters(collection, filters) {
|
|
1486
|
+
return buildDocTypeFilters(collection, "memory", filters);
|
|
1487
|
+
}
|
|
1488
|
+
function combineFiltersWithAnd(filters) {
|
|
1489
|
+
const validFilters = filters.filter((f) => f !== void 0 && f !== null);
|
|
1490
|
+
if (validFilters.length === 0) {
|
|
1491
|
+
return void 0;
|
|
1492
|
+
}
|
|
1493
|
+
if (validFilters.length === 1) {
|
|
1494
|
+
return validFilters[0];
|
|
1495
|
+
}
|
|
1496
|
+
return Filters.and(...validFilters);
|
|
1497
|
+
}
|
|
1498
|
+
function combineFiltersWithOr(filters) {
|
|
1499
|
+
const validFilters = filters.filter((f) => f !== void 0 && f !== null);
|
|
1500
|
+
if (validFilters.length === 0) {
|
|
1501
|
+
return void 0;
|
|
1502
|
+
}
|
|
1503
|
+
if (validFilters.length === 1) {
|
|
1504
|
+
return validFilters[0];
|
|
1505
|
+
}
|
|
1506
|
+
return Filters.or(...validFilters);
|
|
1507
|
+
}
|
|
1508
|
+
|
|
1412
1509
|
// src/tools/search-memory.ts
|
|
1413
1510
|
var searchMemoryTool = {
|
|
1414
1511
|
name: "remember_search_memory",
|
|
@@ -1512,15 +1609,19 @@ async function handleSearchMemory(args, userId) {
|
|
|
1512
1609
|
const alpha = args.alpha ?? 0.7;
|
|
1513
1610
|
const limit = args.limit ?? 10;
|
|
1514
1611
|
const offset = args.offset ?? 0;
|
|
1612
|
+
const filters = includeRelationships ? buildCombinedSearchFilters(collection, args.filters) : buildMemoryOnlyFilters(collection, args.filters);
|
|
1515
1613
|
const searchOptions = {
|
|
1516
1614
|
alpha,
|
|
1517
1615
|
limit: limit + offset
|
|
1518
1616
|
// Get extra for offset
|
|
1519
1617
|
};
|
|
1618
|
+
if (filters) {
|
|
1619
|
+
searchOptions.filters = filters;
|
|
1620
|
+
}
|
|
1520
1621
|
logger.info("Weaviate query", {
|
|
1521
1622
|
query: args.query,
|
|
1522
|
-
searchOptions: JSON.stringify(searchOptions, null, 2)
|
|
1523
|
-
|
|
1623
|
+
searchOptions: JSON.stringify(searchOptions, null, 2),
|
|
1624
|
+
hasFilters: !!filters
|
|
1524
1625
|
});
|
|
1525
1626
|
const results = await collection.query.hybrid(args.query, searchOptions);
|
|
1526
1627
|
const paginatedResults = results.objects.slice(offset);
|
|
@@ -1914,100 +2015,6 @@ async function handleFindSimilar(args, userId) {
|
|
|
1914
2015
|
}
|
|
1915
2016
|
}
|
|
1916
2017
|
|
|
1917
|
-
// src/utils/weaviate-filters.ts
|
|
1918
|
-
import { Filters } from "weaviate-client";
|
|
1919
|
-
function buildCombinedSearchFilters(collection, filters) {
|
|
1920
|
-
const memoryFilters = buildDocTypeFilters(collection, "memory", filters);
|
|
1921
|
-
const relationshipFilters = buildDocTypeFilters(collection, "relationship", filters);
|
|
1922
|
-
const validFilters = [memoryFilters, relationshipFilters].filter((f) => f !== void 0 && f !== null);
|
|
1923
|
-
if (validFilters.length === 0) {
|
|
1924
|
-
return void 0;
|
|
1925
|
-
} else if (validFilters.length === 1) {
|
|
1926
|
-
return validFilters[0];
|
|
1927
|
-
} else {
|
|
1928
|
-
return combineFiltersWithOr(validFilters);
|
|
1929
|
-
}
|
|
1930
|
-
}
|
|
1931
|
-
function buildDocTypeFilters(collection, docType, filters) {
|
|
1932
|
-
const filterList = [];
|
|
1933
|
-
filterList.push(
|
|
1934
|
-
collection.filter.byProperty("doc_type").equal(docType)
|
|
1935
|
-
);
|
|
1936
|
-
if (docType === "memory" && filters?.types && filters.types.length > 0) {
|
|
1937
|
-
if (filters.types.length === 1) {
|
|
1938
|
-
filterList.push(
|
|
1939
|
-
collection.filter.byProperty("type").equal(filters.types[0])
|
|
1940
|
-
);
|
|
1941
|
-
} else {
|
|
1942
|
-
filterList.push(
|
|
1943
|
-
collection.filter.byProperty("type").containsAny(filters.types)
|
|
1944
|
-
);
|
|
1945
|
-
}
|
|
1946
|
-
}
|
|
1947
|
-
if (filters?.weight_min !== void 0) {
|
|
1948
|
-
filterList.push(
|
|
1949
|
-
collection.filter.byProperty("weight").greaterThanOrEqual(filters.weight_min)
|
|
1950
|
-
);
|
|
1951
|
-
}
|
|
1952
|
-
if (filters?.weight_max !== void 0) {
|
|
1953
|
-
filterList.push(
|
|
1954
|
-
collection.filter.byProperty("weight").lessThanOrEqual(filters.weight_max)
|
|
1955
|
-
);
|
|
1956
|
-
}
|
|
1957
|
-
if (filters?.trust_min !== void 0) {
|
|
1958
|
-
filterList.push(
|
|
1959
|
-
collection.filter.byProperty("trust").greaterThanOrEqual(filters.trust_min)
|
|
1960
|
-
);
|
|
1961
|
-
}
|
|
1962
|
-
if (filters?.trust_max !== void 0) {
|
|
1963
|
-
filterList.push(
|
|
1964
|
-
collection.filter.byProperty("trust").lessThanOrEqual(filters.trust_max)
|
|
1965
|
-
);
|
|
1966
|
-
}
|
|
1967
|
-
if (filters?.date_from) {
|
|
1968
|
-
filterList.push(
|
|
1969
|
-
collection.filter.byProperty("created_at").greaterThanOrEqual(new Date(filters.date_from))
|
|
1970
|
-
);
|
|
1971
|
-
}
|
|
1972
|
-
if (filters?.date_to) {
|
|
1973
|
-
filterList.push(
|
|
1974
|
-
collection.filter.byProperty("created_at").lessThanOrEqual(new Date(filters.date_to))
|
|
1975
|
-
);
|
|
1976
|
-
}
|
|
1977
|
-
if (filters?.tags && filters.tags.length > 0) {
|
|
1978
|
-
if (filters.tags.length === 1) {
|
|
1979
|
-
filterList.push(
|
|
1980
|
-
collection.filter.byProperty("tags").containsAny([filters.tags[0]])
|
|
1981
|
-
);
|
|
1982
|
-
} else {
|
|
1983
|
-
filterList.push(
|
|
1984
|
-
collection.filter.byProperty("tags").containsAny(filters.tags)
|
|
1985
|
-
);
|
|
1986
|
-
}
|
|
1987
|
-
}
|
|
1988
|
-
return combineFiltersWithAnd(filterList);
|
|
1989
|
-
}
|
|
1990
|
-
function combineFiltersWithAnd(filters) {
|
|
1991
|
-
const validFilters = filters.filter((f) => f !== void 0 && f !== null);
|
|
1992
|
-
if (validFilters.length === 0) {
|
|
1993
|
-
return void 0;
|
|
1994
|
-
}
|
|
1995
|
-
if (validFilters.length === 1) {
|
|
1996
|
-
return validFilters[0];
|
|
1997
|
-
}
|
|
1998
|
-
return Filters.and(...validFilters);
|
|
1999
|
-
}
|
|
2000
|
-
function combineFiltersWithOr(filters) {
|
|
2001
|
-
const validFilters = filters.filter((f) => f !== void 0 && f !== null);
|
|
2002
|
-
if (validFilters.length === 0) {
|
|
2003
|
-
return void 0;
|
|
2004
|
-
}
|
|
2005
|
-
if (validFilters.length === 1) {
|
|
2006
|
-
return validFilters[0];
|
|
2007
|
-
}
|
|
2008
|
-
return Filters.or(...validFilters);
|
|
2009
|
-
}
|
|
2010
|
-
|
|
2011
2018
|
// src/tools/query-memory.ts
|
|
2012
2019
|
var queryMemoryTool = {
|
|
2013
2020
|
name: "remember_query_memory",
|
package/dist/server.js
CHANGED
|
@@ -1338,6 +1338,103 @@ async function handleCreateMemory(args, userId, context) {
|
|
|
1338
1338
|
}
|
|
1339
1339
|
}
|
|
1340
1340
|
|
|
1341
|
+
// src/utils/weaviate-filters.ts
|
|
1342
|
+
import { Filters } from "weaviate-client";
|
|
1343
|
+
function buildCombinedSearchFilters(collection, filters) {
|
|
1344
|
+
const memoryFilters = buildDocTypeFilters(collection, "memory", filters);
|
|
1345
|
+
const relationshipFilters = buildDocTypeFilters(collection, "relationship", filters);
|
|
1346
|
+
const validFilters = [memoryFilters, relationshipFilters].filter((f) => f !== void 0 && f !== null);
|
|
1347
|
+
if (validFilters.length === 0) {
|
|
1348
|
+
return void 0;
|
|
1349
|
+
} else if (validFilters.length === 1) {
|
|
1350
|
+
return validFilters[0];
|
|
1351
|
+
} else {
|
|
1352
|
+
return combineFiltersWithOr(validFilters);
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
function buildDocTypeFilters(collection, docType, filters) {
|
|
1356
|
+
const filterList = [];
|
|
1357
|
+
filterList.push(
|
|
1358
|
+
collection.filter.byProperty("doc_type").equal(docType)
|
|
1359
|
+
);
|
|
1360
|
+
if (docType === "memory" && filters?.types && filters.types.length > 0) {
|
|
1361
|
+
if (filters.types.length === 1) {
|
|
1362
|
+
filterList.push(
|
|
1363
|
+
collection.filter.byProperty("type").equal(filters.types[0])
|
|
1364
|
+
);
|
|
1365
|
+
} else {
|
|
1366
|
+
filterList.push(
|
|
1367
|
+
collection.filter.byProperty("type").containsAny(filters.types)
|
|
1368
|
+
);
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
if (filters?.weight_min !== void 0) {
|
|
1372
|
+
filterList.push(
|
|
1373
|
+
collection.filter.byProperty("weight").greaterThanOrEqual(filters.weight_min)
|
|
1374
|
+
);
|
|
1375
|
+
}
|
|
1376
|
+
if (filters?.weight_max !== void 0) {
|
|
1377
|
+
filterList.push(
|
|
1378
|
+
collection.filter.byProperty("weight").lessThanOrEqual(filters.weight_max)
|
|
1379
|
+
);
|
|
1380
|
+
}
|
|
1381
|
+
if (filters?.trust_min !== void 0) {
|
|
1382
|
+
filterList.push(
|
|
1383
|
+
collection.filter.byProperty("trust").greaterThanOrEqual(filters.trust_min)
|
|
1384
|
+
);
|
|
1385
|
+
}
|
|
1386
|
+
if (filters?.trust_max !== void 0) {
|
|
1387
|
+
filterList.push(
|
|
1388
|
+
collection.filter.byProperty("trust").lessThanOrEqual(filters.trust_max)
|
|
1389
|
+
);
|
|
1390
|
+
}
|
|
1391
|
+
if (filters?.date_from) {
|
|
1392
|
+
filterList.push(
|
|
1393
|
+
collection.filter.byProperty("created_at").greaterThanOrEqual(new Date(filters.date_from))
|
|
1394
|
+
);
|
|
1395
|
+
}
|
|
1396
|
+
if (filters?.date_to) {
|
|
1397
|
+
filterList.push(
|
|
1398
|
+
collection.filter.byProperty("created_at").lessThanOrEqual(new Date(filters.date_to))
|
|
1399
|
+
);
|
|
1400
|
+
}
|
|
1401
|
+
if (filters?.tags && filters.tags.length > 0) {
|
|
1402
|
+
if (filters.tags.length === 1) {
|
|
1403
|
+
filterList.push(
|
|
1404
|
+
collection.filter.byProperty("tags").containsAny([filters.tags[0]])
|
|
1405
|
+
);
|
|
1406
|
+
} else {
|
|
1407
|
+
filterList.push(
|
|
1408
|
+
collection.filter.byProperty("tags").containsAny(filters.tags)
|
|
1409
|
+
);
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
return combineFiltersWithAnd(filterList);
|
|
1413
|
+
}
|
|
1414
|
+
function buildMemoryOnlyFilters(collection, filters) {
|
|
1415
|
+
return buildDocTypeFilters(collection, "memory", filters);
|
|
1416
|
+
}
|
|
1417
|
+
function combineFiltersWithAnd(filters) {
|
|
1418
|
+
const validFilters = filters.filter((f) => f !== void 0 && f !== null);
|
|
1419
|
+
if (validFilters.length === 0) {
|
|
1420
|
+
return void 0;
|
|
1421
|
+
}
|
|
1422
|
+
if (validFilters.length === 1) {
|
|
1423
|
+
return validFilters[0];
|
|
1424
|
+
}
|
|
1425
|
+
return Filters.and(...validFilters);
|
|
1426
|
+
}
|
|
1427
|
+
function combineFiltersWithOr(filters) {
|
|
1428
|
+
const validFilters = filters.filter((f) => f !== void 0 && f !== null);
|
|
1429
|
+
if (validFilters.length === 0) {
|
|
1430
|
+
return void 0;
|
|
1431
|
+
}
|
|
1432
|
+
if (validFilters.length === 1) {
|
|
1433
|
+
return validFilters[0];
|
|
1434
|
+
}
|
|
1435
|
+
return Filters.or(...validFilters);
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1341
1438
|
// src/tools/search-memory.ts
|
|
1342
1439
|
var searchMemoryTool = {
|
|
1343
1440
|
name: "remember_search_memory",
|
|
@@ -1441,15 +1538,19 @@ async function handleSearchMemory(args, userId) {
|
|
|
1441
1538
|
const alpha = args.alpha ?? 0.7;
|
|
1442
1539
|
const limit = args.limit ?? 10;
|
|
1443
1540
|
const offset = args.offset ?? 0;
|
|
1541
|
+
const filters = includeRelationships ? buildCombinedSearchFilters(collection, args.filters) : buildMemoryOnlyFilters(collection, args.filters);
|
|
1444
1542
|
const searchOptions = {
|
|
1445
1543
|
alpha,
|
|
1446
1544
|
limit: limit + offset
|
|
1447
1545
|
// Get extra for offset
|
|
1448
1546
|
};
|
|
1547
|
+
if (filters) {
|
|
1548
|
+
searchOptions.filters = filters;
|
|
1549
|
+
}
|
|
1449
1550
|
logger.info("Weaviate query", {
|
|
1450
1551
|
query: args.query,
|
|
1451
|
-
searchOptions: JSON.stringify(searchOptions, null, 2)
|
|
1452
|
-
|
|
1552
|
+
searchOptions: JSON.stringify(searchOptions, null, 2),
|
|
1553
|
+
hasFilters: !!filters
|
|
1453
1554
|
});
|
|
1454
1555
|
const results = await collection.query.hybrid(args.query, searchOptions);
|
|
1455
1556
|
const paginatedResults = results.objects.slice(offset);
|
|
@@ -1843,100 +1944,6 @@ async function handleFindSimilar(args, userId) {
|
|
|
1843
1944
|
}
|
|
1844
1945
|
}
|
|
1845
1946
|
|
|
1846
|
-
// src/utils/weaviate-filters.ts
|
|
1847
|
-
import { Filters } from "weaviate-client";
|
|
1848
|
-
function buildCombinedSearchFilters(collection, filters) {
|
|
1849
|
-
const memoryFilters = buildDocTypeFilters(collection, "memory", filters);
|
|
1850
|
-
const relationshipFilters = buildDocTypeFilters(collection, "relationship", filters);
|
|
1851
|
-
const validFilters = [memoryFilters, relationshipFilters].filter((f) => f !== void 0 && f !== null);
|
|
1852
|
-
if (validFilters.length === 0) {
|
|
1853
|
-
return void 0;
|
|
1854
|
-
} else if (validFilters.length === 1) {
|
|
1855
|
-
return validFilters[0];
|
|
1856
|
-
} else {
|
|
1857
|
-
return combineFiltersWithOr(validFilters);
|
|
1858
|
-
}
|
|
1859
|
-
}
|
|
1860
|
-
function buildDocTypeFilters(collection, docType, filters) {
|
|
1861
|
-
const filterList = [];
|
|
1862
|
-
filterList.push(
|
|
1863
|
-
collection.filter.byProperty("doc_type").equal(docType)
|
|
1864
|
-
);
|
|
1865
|
-
if (docType === "memory" && filters?.types && filters.types.length > 0) {
|
|
1866
|
-
if (filters.types.length === 1) {
|
|
1867
|
-
filterList.push(
|
|
1868
|
-
collection.filter.byProperty("type").equal(filters.types[0])
|
|
1869
|
-
);
|
|
1870
|
-
} else {
|
|
1871
|
-
filterList.push(
|
|
1872
|
-
collection.filter.byProperty("type").containsAny(filters.types)
|
|
1873
|
-
);
|
|
1874
|
-
}
|
|
1875
|
-
}
|
|
1876
|
-
if (filters?.weight_min !== void 0) {
|
|
1877
|
-
filterList.push(
|
|
1878
|
-
collection.filter.byProperty("weight").greaterThanOrEqual(filters.weight_min)
|
|
1879
|
-
);
|
|
1880
|
-
}
|
|
1881
|
-
if (filters?.weight_max !== void 0) {
|
|
1882
|
-
filterList.push(
|
|
1883
|
-
collection.filter.byProperty("weight").lessThanOrEqual(filters.weight_max)
|
|
1884
|
-
);
|
|
1885
|
-
}
|
|
1886
|
-
if (filters?.trust_min !== void 0) {
|
|
1887
|
-
filterList.push(
|
|
1888
|
-
collection.filter.byProperty("trust").greaterThanOrEqual(filters.trust_min)
|
|
1889
|
-
);
|
|
1890
|
-
}
|
|
1891
|
-
if (filters?.trust_max !== void 0) {
|
|
1892
|
-
filterList.push(
|
|
1893
|
-
collection.filter.byProperty("trust").lessThanOrEqual(filters.trust_max)
|
|
1894
|
-
);
|
|
1895
|
-
}
|
|
1896
|
-
if (filters?.date_from) {
|
|
1897
|
-
filterList.push(
|
|
1898
|
-
collection.filter.byProperty("created_at").greaterThanOrEqual(new Date(filters.date_from))
|
|
1899
|
-
);
|
|
1900
|
-
}
|
|
1901
|
-
if (filters?.date_to) {
|
|
1902
|
-
filterList.push(
|
|
1903
|
-
collection.filter.byProperty("created_at").lessThanOrEqual(new Date(filters.date_to))
|
|
1904
|
-
);
|
|
1905
|
-
}
|
|
1906
|
-
if (filters?.tags && filters.tags.length > 0) {
|
|
1907
|
-
if (filters.tags.length === 1) {
|
|
1908
|
-
filterList.push(
|
|
1909
|
-
collection.filter.byProperty("tags").containsAny([filters.tags[0]])
|
|
1910
|
-
);
|
|
1911
|
-
} else {
|
|
1912
|
-
filterList.push(
|
|
1913
|
-
collection.filter.byProperty("tags").containsAny(filters.tags)
|
|
1914
|
-
);
|
|
1915
|
-
}
|
|
1916
|
-
}
|
|
1917
|
-
return combineFiltersWithAnd(filterList);
|
|
1918
|
-
}
|
|
1919
|
-
function combineFiltersWithAnd(filters) {
|
|
1920
|
-
const validFilters = filters.filter((f) => f !== void 0 && f !== null);
|
|
1921
|
-
if (validFilters.length === 0) {
|
|
1922
|
-
return void 0;
|
|
1923
|
-
}
|
|
1924
|
-
if (validFilters.length === 1) {
|
|
1925
|
-
return validFilters[0];
|
|
1926
|
-
}
|
|
1927
|
-
return Filters.and(...validFilters);
|
|
1928
|
-
}
|
|
1929
|
-
function combineFiltersWithOr(filters) {
|
|
1930
|
-
const validFilters = filters.filter((f) => f !== void 0 && f !== null);
|
|
1931
|
-
if (validFilters.length === 0) {
|
|
1932
|
-
return void 0;
|
|
1933
|
-
}
|
|
1934
|
-
if (validFilters.length === 1) {
|
|
1935
|
-
return validFilters[0];
|
|
1936
|
-
}
|
|
1937
|
-
return Filters.or(...validFilters);
|
|
1938
|
-
}
|
|
1939
|
-
|
|
1940
1947
|
// src/tools/query-memory.ts
|
|
1941
1948
|
var queryMemoryTool = {
|
|
1942
1949
|
name: "remember_query_memory",
|
package/package.json
CHANGED
|
@@ -127,9 +127,9 @@ export async function handleSearchMemory(
|
|
|
127
127
|
|
|
128
128
|
// Build filters using v3 API
|
|
129
129
|
// Use OR logic to search both memories and relationships
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
130
|
+
const filters = includeRelationships
|
|
131
|
+
? buildCombinedSearchFilters(collection, args.filters)
|
|
132
|
+
: buildMemoryOnlyFilters(collection, args.filters);
|
|
133
133
|
|
|
134
134
|
// Build search options
|
|
135
135
|
const searchOptions: any = {
|
|
@@ -138,15 +138,15 @@ export async function handleSearchMemory(
|
|
|
138
138
|
};
|
|
139
139
|
|
|
140
140
|
// Add filters if present
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
if (filters) {
|
|
142
|
+
searchOptions.filters = filters;
|
|
143
|
+
}
|
|
144
144
|
|
|
145
145
|
// Log the query for debugging
|
|
146
146
|
logger.info('Weaviate query', {
|
|
147
147
|
query: args.query,
|
|
148
148
|
searchOptions: JSON.stringify(searchOptions, null, 2),
|
|
149
|
-
|
|
149
|
+
hasFilters: !!filters,
|
|
150
150
|
});
|
|
151
151
|
|
|
152
152
|
// Perform hybrid search with Weaviate v3 API
|