mem0ai 2.4.6 → 3.0.0-beta.0

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/oss/index.js CHANGED
@@ -101,8 +101,7 @@ var MemoryConfigSchema = import_zod.z.object({
101
101
  })
102
102
  }),
103
103
  historyDbPath: import_zod.z.string().optional(),
104
- customPrompt: import_zod.z.string().optional(),
105
- enableGraph: import_zod.z.boolean().optional(),
104
+ customInstructions: import_zod.z.string().optional(),
106
105
  graphStore: import_zod.z.object({
107
106
  provider: import_zod.z.string(),
108
107
  config: import_zod.z.object({
@@ -114,7 +113,7 @@ var MemoryConfigSchema = import_zod.z.object({
114
113
  provider: import_zod.z.string(),
115
114
  config: import_zod.z.record(import_zod.z.string(), import_zod.z.any())
116
115
  }).optional(),
117
- customPrompt: import_zod.z.string().optional()
116
+ customInstructions: import_zod.z.string().optional()
118
117
  }).optional(),
119
118
  historyStore: import_zod.z.object({
120
119
  provider: import_zod.z.string(),
@@ -626,7 +625,7 @@ var MemoryVectorStore = class {
626
625
  );
627
626
  insertMany(vectors, ids, payloads);
628
627
  }
629
- async search(query, limit = 10, filters) {
628
+ async search(query, topK = 10, filters) {
630
629
  if (query.length !== this.dimension) {
631
630
  throw new Error(
632
631
  `Query dimension mismatch. Expected ${this.dimension}, got ${query.length}`
@@ -656,7 +655,7 @@ var MemoryVectorStore = class {
656
655
  }
657
656
  }
658
657
  results.sort((a, b) => (b.score || 0) - (a.score || 0));
659
- return results.slice(0, limit);
658
+ return results.slice(0, topK);
660
659
  }
661
660
  async get(vectorId) {
662
661
  const row = this.db.prepare(`SELECT * FROM vectors WHERE id = ?`).get(vectorId);
@@ -683,7 +682,7 @@ var MemoryVectorStore = class {
683
682
  this.db.exec(`DROP TABLE IF EXISTS vectors`);
684
683
  this.init();
685
684
  }
686
- async list(filters, limit = 100) {
685
+ async list(filters, topK = 100) {
687
686
  const rows = this.db.prepare(`SELECT * FROM vectors`).all();
688
687
  const results = [];
689
688
  for (const row of rows) {
@@ -706,7 +705,7 @@ var MemoryVectorStore = class {
706
705
  });
707
706
  }
708
707
  }
709
- return [results.slice(0, limit), results.length];
708
+ return [results.slice(0, topK), results.length];
710
709
  }
711
710
  async getUserId() {
712
711
  const row = this.db.prepare(`SELECT user_id FROM memory_migrations LIMIT 1`).get();
@@ -798,12 +797,12 @@ var Qdrant = class {
798
797
  points
799
798
  });
800
799
  }
801
- async search(query, limit = 5, filters) {
800
+ async search(query, topK = 5, filters) {
802
801
  const queryFilter = this.createFilter(filters);
803
802
  const results = await this.client.search(this.collectionName, {
804
803
  vector: query,
805
804
  filter: queryFilter,
806
- limit
805
+ limit: topK
807
806
  });
808
807
  return results.map((hit) => ({
809
808
  id: String(hit.id),
@@ -840,9 +839,9 @@ var Qdrant = class {
840
839
  async deleteCol() {
841
840
  await this.client.deleteCollection(this.collectionName);
842
841
  }
843
- async list(filters, limit = 100) {
842
+ async list(filters, topK = 100) {
844
843
  const scrollRequest = {
845
- limit,
844
+ limit: topK,
846
845
  filter: this.createFilter(filters),
847
846
  with_payload: true,
848
847
  with_vectors: false
@@ -1012,7 +1011,7 @@ var VectorizeDB = class {
1012
1011
  );
1013
1012
  }
1014
1013
  }
1015
- async search(query, limit = 5, filters) {
1014
+ async search(query, topK = 5, filters) {
1016
1015
  var _a2, _b;
1017
1016
  try {
1018
1017
  const result = await ((_a2 = this.client) == null ? void 0 : _a2.vectorize.indexes.query(
@@ -1022,7 +1021,7 @@ var VectorizeDB = class {
1022
1021
  vector: query,
1023
1022
  filter: filters,
1024
1023
  returnMetadata: "all",
1025
- topK: limit
1024
+ topK
1026
1025
  }
1027
1026
  ));
1028
1027
  return ((_b = result == null ? void 0 : result.matches) == null ? void 0 : _b.map((match) => ({
@@ -1119,7 +1118,7 @@ var VectorizeDB = class {
1119
1118
  );
1120
1119
  }
1121
1120
  }
1122
- async list(filters, limit = 20) {
1121
+ async list(filters, topK = 20) {
1123
1122
  var _a2, _b;
1124
1123
  try {
1125
1124
  const result = await ((_a2 = this.client) == null ? void 0 : _a2.vectorize.indexes.query(
@@ -1129,7 +1128,7 @@ var VectorizeDB = class {
1129
1128
  vector: Array(this.dimensions).fill(0),
1130
1129
  // Dummy vector for listing
1131
1130
  filter: filters,
1132
- topK: limit,
1131
+ topK,
1133
1132
  returnMetadata: "all"
1134
1133
  }
1135
1134
  ));
@@ -1570,7 +1569,7 @@ var RedisDB = class {
1570
1569
  throw error;
1571
1570
  }
1572
1571
  }
1573
- async search(query, limit = 5, filters) {
1572
+ async search(query, topK = 5, filters) {
1574
1573
  const snakeFilters = filters ? toSnakeCase(filters) : void 0;
1575
1574
  const filterExpr = snakeFilters ? Object.entries(snakeFilters).filter(([_, value]) => value !== null).map(([key, value]) => `@${key}:{${value}}`).join(" ") : "*";
1576
1575
  const queryVector = new Float32Array(query).buffer;
@@ -1593,13 +1592,13 @@ var RedisDB = class {
1593
1592
  DIALECT: 2,
1594
1593
  LIMIT: {
1595
1594
  from: 0,
1596
- size: limit
1595
+ size: topK
1597
1596
  }
1598
1597
  };
1599
1598
  try {
1600
1599
  const results = await this.client.ft.search(
1601
1600
  this.indexName,
1602
- `${filterExpr} =>[KNN ${limit} @embedding $vec AS __vector_score]`,
1601
+ `${filterExpr} =>[KNN ${topK} @embedding $vec AS __vector_score]`,
1603
1602
  searchOptions
1604
1603
  );
1605
1604
  return results.documents.map((doc) => {
@@ -1764,7 +1763,7 @@ var RedisDB = class {
1764
1763
  async deleteCol() {
1765
1764
  await this.client.ft.dropIndex(this.indexName);
1766
1765
  }
1767
- async list(filters, limit = 100) {
1766
+ async list(filters, topK = 100) {
1768
1767
  const snakeFilters = filters ? toSnakeCase(filters) : void 0;
1769
1768
  const filterExpr = snakeFilters ? Object.entries(snakeFilters).filter(([_, value]) => value !== null).map(([key, value]) => `@${key}:{${value}}`).join(" ") : "*";
1770
1769
  const searchOptions = {
@@ -1772,7 +1771,7 @@ var RedisDB = class {
1772
1771
  SORTDIR: "DESC",
1773
1772
  LIMIT: {
1774
1773
  from: 0,
1775
- size: limit
1774
+ size: topK
1776
1775
  }
1777
1776
  };
1778
1777
  const results = await this.client.ft.search(
@@ -2055,11 +2054,11 @@ See the SQL migration instructions in the code comments.`
2055
2054
  throw error;
2056
2055
  }
2057
2056
  }
2058
- async search(query, limit = 5, filters) {
2057
+ async search(query, topK = 5, filters) {
2059
2058
  try {
2060
2059
  const rpcQuery = {
2061
2060
  query_embedding: query,
2062
- match_count: limit
2061
+ match_count: topK
2063
2062
  };
2064
2063
  if (filters) {
2065
2064
  rpcQuery.filter = filters;
@@ -2125,9 +2124,9 @@ See the SQL migration instructions in the code comments.`
2125
2124
  throw error;
2126
2125
  }
2127
2126
  }
2128
- async list(filters, limit = 100) {
2127
+ async list(filters, topK = 100) {
2129
2128
  try {
2130
- let query = this.client.from(this.tableName).select("*", { count: "exact" }).limit(limit);
2129
+ let query = this.client.from(this.tableName).select("*", { count: "exact" }).limit(topK);
2131
2130
  if (filters) {
2132
2131
  Object.entries(filters).forEach(([key, value]) => {
2133
2132
  query = query.eq(`${this.metadataColumnName}->>${key}`, value);
@@ -3190,7 +3189,7 @@ var LangchainVectorStore = class {
3190
3189
  await this.lcStore.addVectors(vectors, documents);
3191
3190
  }
3192
3191
  }
3193
- async search(query, limit = 5, filters) {
3192
+ async search(query, topK = 5, filters) {
3194
3193
  if (this.dimension && query.length !== this.dimension) {
3195
3194
  throw new Error(
3196
3195
  `Query vector dimension mismatch. Expected ${this.dimension}, got ${query.length}`
@@ -3198,7 +3197,7 @@ var LangchainVectorStore = class {
3198
3197
  }
3199
3198
  const results = await this.lcStore.similaritySearchVectorWithScore(
3200
3199
  query,
3201
- limit
3200
+ topK
3202
3201
  // Do not pass lcFilter here
3203
3202
  );
3204
3203
  return results.map(([doc, score]) => ({
@@ -3246,7 +3245,7 @@ var LangchainVectorStore = class {
3246
3245
  );
3247
3246
  }
3248
3247
  }
3249
- async list(filters, limit = 100) {
3248
+ async list(filters, topK = 100) {
3250
3249
  console.error(
3251
3250
  `LangchainVectorStore: The 'list' method is not supported by the generic LangchainVectorStore wrapper.`
3252
3251
  );
@@ -3467,12 +3466,12 @@ var AzureAISearch = class {
3467
3466
  /**
3468
3467
  * Search for similar vectors
3469
3468
  */
3470
- async search(query, limit = 5, filters) {
3469
+ async search(query, topK = 5, filters) {
3471
3470
  const filterExpression = filters ? this.buildFilterExpression(filters) : void 0;
3472
3471
  const vectorQuery = {
3473
3472
  kind: "vector",
3474
3473
  vector: query,
3475
- kNearestNeighborsCount: limit,
3474
+ kNearestNeighborsCount: topK,
3476
3475
  fields: ["vector"]
3477
3476
  };
3478
3477
  let searchResults;
@@ -3483,7 +3482,7 @@ var AzureAISearch = class {
3483
3482
  filterMode: this.vectorFilterMode
3484
3483
  },
3485
3484
  filter: filterExpression,
3486
- top: limit,
3485
+ top: topK,
3487
3486
  searchFields: ["payload"]
3488
3487
  });
3489
3488
  } else {
@@ -3493,7 +3492,7 @@ var AzureAISearch = class {
3493
3492
  filterMode: this.vectorFilterMode
3494
3493
  },
3495
3494
  filter: filterExpression,
3496
- top: limit
3495
+ top: topK
3497
3496
  });
3498
3497
  }
3499
3498
  const results = [];
@@ -3599,11 +3598,11 @@ var AzureAISearch = class {
3599
3598
  /**
3600
3599
  * List all vectors in the index
3601
3600
  */
3602
- async list(filters, limit = 100) {
3601
+ async list(filters, topK = 100) {
3603
3602
  const filterExpression = filters ? this.buildFilterExpression(filters) : void 0;
3604
3603
  const searchResults = await this.searchClient.search("*", {
3605
3604
  filter: filterExpression,
3606
- top: limit
3605
+ top: topK
3607
3606
  });
3608
3607
  const results = [];
3609
3608
  for await (const result of searchResults.results) {
@@ -3833,10 +3832,10 @@ var PGVector = class {
3833
3832
  )
3834
3833
  );
3835
3834
  }
3836
- async search(query, limit = 5, filters) {
3835
+ async search(query, topK = 5, filters) {
3837
3836
  const filterConditions = [];
3838
3837
  const queryVector = `[${query.join(",")}]`;
3839
- const filterValues = [queryVector, limit];
3838
+ const filterValues = [queryVector, topK];
3840
3839
  let filterIndex = 3;
3841
3840
  if (filters) {
3842
3841
  for (const [key, value] of Object.entries(filters)) {
@@ -3899,7 +3898,7 @@ var PGVector = class {
3899
3898
  `);
3900
3899
  return result.rows.map((row) => row.table_name);
3901
3900
  }
3902
- async list(filters, limit = 100) {
3901
+ async list(filters, topK = 100) {
3903
3902
  const filterConditions = [];
3904
3903
  const filterValues = [];
3905
3904
  let paramIndex = 1;
@@ -3922,7 +3921,7 @@ var PGVector = class {
3922
3921
  FROM ${this.collectionName}
3923
3922
  ${filterClause}
3924
3923
  `;
3925
- filterValues.push(limit);
3924
+ filterValues.push(topK);
3926
3925
  const [listResult, countResult] = await Promise.all([
3927
3926
  this.client.query(listQuery, filterValues),
3928
3927
  this.client.query(countQuery, filterValues.slice(0, -1))
@@ -3960,6 +3959,38 @@ var PGVector = class {
3960
3959
  }
3961
3960
  };
3962
3961
 
3962
+ // src/oss/src/llms/deepseek.ts
3963
+ var DeepSeekLLM = class extends OpenAILLM {
3964
+ constructor(config) {
3965
+ const apiKey = config.apiKey || process.env.DEEPSEEK_API_KEY;
3966
+ if (!apiKey) {
3967
+ throw new Error("DeepSeek API key is required");
3968
+ }
3969
+ super({
3970
+ ...config,
3971
+ apiKey,
3972
+ baseURL: config.baseURL || process.env.DEEPSEEK_API_BASE || "https://api.deepseek.com",
3973
+ model: config.model || "deepseek-chat"
3974
+ });
3975
+ }
3976
+ async generateResponse(messages, responseFormat, tools) {
3977
+ try {
3978
+ return await super.generateResponse(messages, responseFormat, tools);
3979
+ } catch (err) {
3980
+ const message = err instanceof Error ? err.message : String(err);
3981
+ throw new Error(`DeepSeek LLM failed: ${message}`);
3982
+ }
3983
+ }
3984
+ async generateChat(messages) {
3985
+ try {
3986
+ return await super.generateChat(messages);
3987
+ } catch (err) {
3988
+ const message = err instanceof Error ? err.message : String(err);
3989
+ throw new Error(`DeepSeek LLM failed: ${message}`);
3990
+ }
3991
+ }
3992
+ };
3993
+
3963
3994
  // src/oss/src/utils/factory.ts
3964
3995
  var EmbedderFactory = class {
3965
3996
  static create(provider, config) {
@@ -4006,6 +4037,8 @@ var LLMFactory = class {
4006
4037
  return new MistralLLM(config);
4007
4038
  case "langchain":
4008
4039
  return new LangchainLLM(config);
4040
+ case "deepseek":
4041
+ return new DeepSeekLLM(config);
4009
4042
  default:
4010
4043
  throw new Error(`Unsupported LLM provider: ${provider}`);
4011
4044
  }
@@ -4099,15 +4132,6 @@ var DEFAULT_MEMORY_CONFIG = {
4099
4132
  modelProperties: void 0
4100
4133
  }
4101
4134
  },
4102
- enableGraph: false,
4103
- graphStore: {
4104
- provider: "neo4j",
4105
- config: {
4106
- url: process.env.NEO4J_URL || "neo4j://localhost:7687",
4107
- username: process.env.NEO4J_USERNAME || "neo4j",
4108
- password: process.env.NEO4J_PASSWORD || "password"
4109
- }
4110
- },
4111
4135
  historyStore: {
4112
4136
  provider: "sqlite",
4113
4137
  config: {
@@ -4196,11 +4220,8 @@ var ConfigManager = class {
4196
4220
  })()
4197
4221
  },
4198
4222
  historyDbPath: userConfig.historyDbPath || ((_e = (_d = userConfig.historyStore) == null ? void 0 : _d.config) == null ? void 0 : _e.historyDbPath) || ((_g = (_f = DEFAULT_MEMORY_CONFIG.historyStore) == null ? void 0 : _f.config) == null ? void 0 : _g.historyDbPath),
4199
- customPrompt: userConfig.customPrompt,
4200
- graphStore: {
4201
- ...DEFAULT_MEMORY_CONFIG.graphStore,
4202
- ...userConfig.graphStore
4203
- },
4223
+ customInstructions: userConfig.customInstructions,
4224
+ graphStore: userConfig.graphStore ? { ...userConfig.graphStore } : void 0,
4204
4225
  historyStore: (() => {
4205
4226
  var _a3, _b2;
4206
4227
  const defaultHistoryStore = DEFAULT_MEMORY_CONFIG.historyStore;
@@ -4217,8 +4238,7 @@ var ConfigManager = class {
4217
4238
  }
4218
4239
  };
4219
4240
  })(),
4220
- disableHistory: userConfig.disableHistory || DEFAULT_MEMORY_CONFIG.disableHistory,
4221
- enableGraph: userConfig.enableGraph || DEFAULT_MEMORY_CONFIG.enableGraph
4241
+ disableHistory: userConfig.disableHistory || DEFAULT_MEMORY_CONFIG.disableHistory
4222
4242
  };
4223
4243
  return MemoryConfigSchema.parse(mergedConfig);
4224
4244
  }
@@ -4401,7 +4421,7 @@ var MemoryGraph = class {
4401
4421
  relations: toBeAdded
4402
4422
  };
4403
4423
  }
4404
- async search(query, filters, limit = 100) {
4424
+ async search(query, filters, topK = 100) {
4405
4425
  const entityTypeMap = await this._retrieveNodesFromData(query, filters);
4406
4426
  const searchOutput = await this._searchGraphDb(
4407
4427
  Object.keys(entityTypeMap),
@@ -4436,7 +4456,7 @@ var MemoryGraph = class {
4436
4456
  await session.close();
4437
4457
  }
4438
4458
  }
4439
- async getAll(filters, limit = 100) {
4459
+ async getAll(filters, topK = 100) {
4440
4460
  const session = this.graph.session();
4441
4461
  try {
4442
4462
  const result = await session.run(
@@ -4445,7 +4465,7 @@ var MemoryGraph = class {
4445
4465
  RETURN n.name AS source, type(r) AS relationship, m.name AS target
4446
4466
  LIMIT toInteger($limit)
4447
4467
  `,
4448
- { user_id: filters["userId"], limit: Math.floor(Number(limit)) }
4468
+ { user_id: filters["userId"], limit: Math.floor(Number(topK)) }
4449
4469
  );
4450
4470
  const finalResults = result.records.map((record) => ({
4451
4471
  source: record.get("source"),
@@ -4498,7 +4518,7 @@ var MemoryGraph = class {
4498
4518
  async _establishNodesRelationsFromData(data, filters, entityTypeMap) {
4499
4519
  var _a2;
4500
4520
  let messages;
4501
- if ((_a2 = this.config.graphStore) == null ? void 0 : _a2.customPrompt) {
4521
+ if ((_a2 = this.config.graphStore) == null ? void 0 : _a2.customInstructions) {
4502
4522
  messages = [
4503
4523
  {
4504
4524
  role: "system",
@@ -4507,7 +4527,7 @@ var MemoryGraph = class {
4507
4527
  filters["userId"]
4508
4528
  ).replace(
4509
4529
  "CUSTOM_PROMPT",
4510
- `4. ${this.config.graphStore.customPrompt}`
4530
+ `4. ${this.config.graphStore.customInstructions}`
4511
4531
  ) + "\nPlease provide your response in JSON format."
4512
4532
  },
4513
4533
  { role: "user", content: data }
@@ -4544,7 +4564,7 @@ Text: ${data}`
4544
4564
  logger.debug(`Extracted entities: ${JSON.stringify(entities)}`);
4545
4565
  return entities;
4546
4566
  }
4547
- async _searchGraphDb(nodeList, filters, limit = 100) {
4567
+ async _searchGraphDb(nodeList, filters, topK = 100) {
4548
4568
  const resultRelations = [];
4549
4569
  const session = this.graph.session();
4550
4570
  try {
@@ -4577,7 +4597,7 @@ Text: ${data}`
4577
4597
  n_embedding: nEmbedding,
4578
4598
  threshold: this.threshold,
4579
4599
  user_id: filters["userId"],
4580
- limit: Math.floor(Number(limit))
4600
+ limit: Math.floor(Number(topK))
4581
4601
  });
4582
4602
  resultRelations.push(
4583
4603
  ...result.records.map((record) => ({
@@ -4893,6 +4913,22 @@ try {
4893
4913
  }
4894
4914
  var POSTHOG_API_KEY = "phc_hgJkUVJFYtmaJqrvf6CYN67TIQ8yhXAkWzUn9AMU4yX";
4895
4915
  var POSTHOG_HOST = "https://us.i.posthog.com/i/v0/e/";
4916
+ var DEFAULT_SAMPLE_RATE = 0.1;
4917
+ var MEM0_TELEMETRY_SAMPLE_RATE = (() => {
4918
+ var _a2;
4919
+ try {
4920
+ const raw = (_a2 = process == null ? void 0 : process.env) == null ? void 0 : _a2.MEM0_TELEMETRY_SAMPLE_RATE;
4921
+ if (raw !== void 0) {
4922
+ const parsed = Number(raw);
4923
+ if (Number.isFinite(parsed) && parsed >= 0 && parsed <= 1) {
4924
+ return parsed;
4925
+ }
4926
+ }
4927
+ } catch (e) {
4928
+ }
4929
+ return DEFAULT_SAMPLE_RATE;
4930
+ })();
4931
+ var LIFECYCLE_EVENTS = /* @__PURE__ */ new Set(["init", "reset"]);
4896
4932
  var UnifiedTelemetry = class {
4897
4933
  constructor(projectApiKey, host) {
4898
4934
  this.apiKey = projectApiKey;
@@ -4937,6 +4973,10 @@ async function captureClientEvent(eventName, instance, additionalData = {}) {
4937
4973
  console.warn("No telemetry ID found for instance");
4938
4974
  return;
4939
4975
  }
4976
+ const isLifecycle = LIFECYCLE_EVENTS.has(eventName);
4977
+ if (!isLifecycle && Math.random() >= MEM0_TELEMETRY_SAMPLE_RATE) {
4978
+ return;
4979
+ }
4940
4980
  const eventData = {
4941
4981
  function: `${instance.constructor.name}`,
4942
4982
  method: eventName,
@@ -4944,7 +4984,9 @@ async function captureClientEvent(eventName, instance, additionalData = {}) {
4944
4984
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
4945
4985
  client_version: version,
4946
4986
  client_source: "nodejs",
4947
- ...additionalData
4987
+ ...additionalData,
4988
+ // sample_rate set AFTER the spread so callers can never override it
4989
+ sample_rate: isLifecycle ? 1 : MEM0_TELEMETRY_SAMPLE_RATE
4948
4990
  };
4949
4991
  await telemetry.captureEvent(
4950
4992
  instance.telemetryId,
@@ -4957,7 +4999,7 @@ async function captureClientEvent(eventName, instance, additionalData = {}) {
4957
4999
  var Memory = class _Memory {
4958
5000
  constructor(config = {}) {
4959
5001
  this.config = ConfigManager.mergeConfig(config);
4960
- this.customPrompt = this.config.customPrompt;
5002
+ this.customInstructions = this.config.customInstructions;
4961
5003
  this.embedder = EmbedderFactory.create(
4962
5004
  this.config.embedder.provider,
4963
5005
  this.config.embedder.config
@@ -4976,9 +5018,8 @@ var Memory = class _Memory {
4976
5018
  }
4977
5019
  this.collectionName = this.config.vectorStore.config.collectionName;
4978
5020
  this.apiVersion = this.config.version || "v1.0";
4979
- this.enableGraph = this.config.enableGraph || false;
4980
5021
  this.telemetryId = "anonymous";
4981
- if (this.enableGraph && this.config.graphStore) {
5022
+ if (this.config.graphStore) {
4982
5023
  this.graphMemory = new MemoryGraph(this.config);
4983
5024
  }
4984
5025
  this._initPromise = this._autoInitialize().catch((error) => {
@@ -5033,8 +5074,7 @@ var Memory = class _Memory {
5033
5074
  await captureClientEvent("init", this, {
5034
5075
  api_version: this.apiVersion,
5035
5076
  client_type: "Memory",
5036
- collection_name: this.collectionName,
5037
- enable_graph: this.enableGraph
5077
+ collection_name: this.collectionName
5038
5078
  });
5039
5079
  } catch (error) {
5040
5080
  }
@@ -5140,8 +5180,8 @@ var Memory = class _Memory {
5140
5180
  return returnedMemories;
5141
5181
  }
5142
5182
  const parsedMessages = messages.map((m) => m.content).join("\n");
5143
- const [systemPrompt, userPrompt] = this.customPrompt ? [
5144
- this.customPrompt.toLowerCase().includes("json") ? this.customPrompt : `${this.customPrompt}
5183
+ const [systemPrompt, userPrompt] = this.customInstructions ? [
5184
+ this.customInstructions.toLowerCase().includes("json") ? this.customInstructions : `${this.customInstructions}
5145
5185
 
5146
5186
  You MUST return a valid JSON object with a 'facts' key containing an array of strings.`,
5147
5187
  `Input:
@@ -5295,10 +5335,10 @@ ${parsedMessages}`
5295
5335
  await this._ensureInitialized();
5296
5336
  await this._captureEvent("search", {
5297
5337
  query_length: query.length,
5298
- limit: config.limit,
5338
+ topK: config.topK,
5299
5339
  has_filters: !!config.filters
5300
5340
  });
5301
- const { userId, agentId, runId, limit = 100, filters = {} } = config;
5341
+ const { userId, agentId, runId, topK = 100, filters = {} } = config;
5302
5342
  if (userId) filters.userId = userId;
5303
5343
  if (agentId) filters.agentId = agentId;
5304
5344
  if (runId) filters.runId = runId;
@@ -5310,7 +5350,7 @@ ${parsedMessages}`
5310
5350
  const queryEmbedding = await this.embedder.embed(query);
5311
5351
  const memories = await this.vectorStore.search(
5312
5352
  queryEmbedding,
5313
- limit,
5353
+ topK,
5314
5354
  filters
5315
5355
  );
5316
5356
  let graphResults;
@@ -5426,17 +5466,17 @@ ${parsedMessages}`
5426
5466
  async getAll(config) {
5427
5467
  await this._ensureInitialized();
5428
5468
  await this._captureEvent("get_all", {
5429
- limit: config.limit,
5469
+ topK: config.topK,
5430
5470
  has_user_id: !!config.userId,
5431
5471
  has_agent_id: !!config.agentId,
5432
5472
  has_run_id: !!config.runId
5433
5473
  });
5434
- const { userId, agentId, runId, limit = 100 } = config;
5474
+ const { userId, agentId, runId, topK = 100 } = config;
5435
5475
  const filters = {};
5436
5476
  if (userId) filters.userId = userId;
5437
5477
  if (agentId) filters.agentId = agentId;
5438
5478
  if (runId) filters.runId = runId;
5439
- const [memories] = await this.vectorStore.list(filters, limit);
5479
+ const [memories] = await this.vectorStore.list(filters, topK);
5440
5480
  const excludedKeys = /* @__PURE__ */ new Set([
5441
5481
  "userId",
5442
5482
  "agentId",