mem0ai 2.4.2 → 2.4.4

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.
@@ -679,6 +679,20 @@ declare class MemoryVectorStore implements VectorStore {
679
679
  }
680
680
 
681
681
  interface QdrantConfig extends VectorStoreConfig {
682
+ /**
683
+ * Pre-configured QdrantClient instance. If using Qdrant Cloud, you must pass
684
+ * `port` explicitly when constructing the client to avoid "Illegal host" errors
685
+ * caused by a known upstream bug (qdrant/qdrant-js#59).
686
+ *
687
+ * @example
688
+ * ```typescript
689
+ * const client = new QdrantClient({
690
+ * url: "https://xxx.cloud.qdrant.io:6333",
691
+ * port: 6333,
692
+ * apiKey: "xxx",
693
+ * });
694
+ * ```
695
+ */
682
696
  client?: QdrantClient;
683
697
  host?: string;
684
698
  port?: number;
@@ -679,6 +679,20 @@ declare class MemoryVectorStore implements VectorStore {
679
679
  }
680
680
 
681
681
  interface QdrantConfig extends VectorStoreConfig {
682
+ /**
683
+ * Pre-configured QdrantClient instance. If using Qdrant Cloud, you must pass
684
+ * `port` explicitly when constructing the client to avoid "Illegal host" errors
685
+ * caused by a known upstream bug (qdrant/qdrant-js#59).
686
+ *
687
+ * @example
688
+ * ```typescript
689
+ * const client = new QdrantClient({
690
+ * url: "https://xxx.cloud.qdrant.io:6333",
691
+ * port: 6333,
692
+ * apiKey: "xxx",
693
+ * });
694
+ * ```
695
+ */
682
696
  client?: QdrantClient;
683
697
  host?: string;
684
698
  port?: number;
package/dist/oss/index.js CHANGED
@@ -734,6 +734,12 @@ var Qdrant = class {
734
734
  }
735
735
  if (config.url) {
736
736
  params.url = config.url;
737
+ try {
738
+ const parsedUrl = new URL(config.url);
739
+ params.port = parsedUrl.port ? parseInt(parsedUrl.port, 10) : 6333;
740
+ } catch (_) {
741
+ params.port = 6333;
742
+ }
737
743
  }
738
744
  if (config.host && config.port) {
739
745
  params.host = config.host;
@@ -2523,7 +2529,7 @@ var MemoryUpdateSchema = import_zod2.z.object({
2523
2529
  event: import_zod2.z.enum(["ADD", "UPDATE", "DELETE", "NONE"]).describe(
2524
2530
  "The action taken for this memory item (ADD, UPDATE, DELETE, or NONE)."
2525
2531
  ),
2526
- old_memory: import_zod2.z.string().optional().describe(
2532
+ old_memory: import_zod2.z.string().optional().nullable().describe(
2527
2533
  "The previous content of the memory item if the event was UPDATE."
2528
2534
  )
2529
2535
  })
@@ -3682,7 +3688,8 @@ var AzureAISearch = class {
3682
3688
  };
3683
3689
 
3684
3690
  // src/oss/src/vector_stores/pgvector.ts
3685
- var import_pg = require("pg");
3691
+ var import_pg = __toESM(require("pg"));
3692
+ var { Client } = import_pg.default;
3686
3693
  var PGVector = class {
3687
3694
  constructor(config) {
3688
3695
  this.collectionName = config.collectionName || "memories";
@@ -3690,7 +3697,7 @@ var PGVector = class {
3690
3697
  this.useHnsw = config.hnsw || false;
3691
3698
  this.dbName = config.dbname || "vector_store";
3692
3699
  this.config = config;
3693
- this.client = new import_pg.Client({
3700
+ this.client = new Client({
3694
3701
  database: "postgres",
3695
3702
  // Initially connect to default postgres database
3696
3703
  user: config.user,
@@ -3698,6 +3705,7 @@ var PGVector = class {
3698
3705
  host: config.host,
3699
3706
  port: config.port
3700
3707
  });
3708
+ this.initialize().catch(console.error);
3701
3709
  }
3702
3710
  async initialize() {
3703
3711
  try {
@@ -3707,7 +3715,7 @@ var PGVector = class {
3707
3715
  await this.createDatabase(this.dbName);
3708
3716
  }
3709
3717
  await this.client.end();
3710
- this.client = new import_pg.Client({
3718
+ this.client = new Client({
3711
3719
  database: this.dbName,
3712
3720
  user: this.config.user,
3713
3721
  password: this.config.password,
@@ -4066,12 +4074,6 @@ var DEFAULT_MEMORY_CONFIG = {
4066
4074
  url: process.env.NEO4J_URL || "neo4j://localhost:7687",
4067
4075
  username: process.env.NEO4J_USERNAME || "neo4j",
4068
4076
  password: process.env.NEO4J_PASSWORD || "password"
4069
- },
4070
- llm: {
4071
- provider: "openai",
4072
- config: {
4073
- model: "gpt-4-turbo-preview"
4074
- }
4075
4077
  }
4076
4078
  },
4077
4079
  historyStore: {
@@ -4307,7 +4309,7 @@ function getDeleteMessages(existingMemoriesString, data, userId) {
4307
4309
  // src/oss/src/memory/graph_memory.ts
4308
4310
  var MemoryGraph = class {
4309
4311
  constructor(config) {
4310
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
4312
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
4311
4313
  this.config = config;
4312
4314
  if (!((_b = (_a2 = config.graphStore) == null ? void 0 : _a2.config) == null ? void 0 : _b.url) || !((_d = (_c = config.graphStore) == null ? void 0 : _c.config) == null ? void 0 : _d.username) || !((_f = (_e = config.graphStore) == null ? void 0 : _e.config) == null ? void 0 : _f.password)) {
4313
4315
  throw new Error("Neo4j configuration is incomplete");
@@ -4324,17 +4326,16 @@ var MemoryGraph = class {
4324
4326
  this.config.embedder.config
4325
4327
  );
4326
4328
  this.llmProvider = "openai";
4329
+ let llmConfig = this.config.llm.config;
4327
4330
  if ((_g = this.config.llm) == null ? void 0 : _g.provider) {
4328
4331
  this.llmProvider = this.config.llm.provider;
4329
4332
  }
4330
4333
  if ((_i = (_h = this.config.graphStore) == null ? void 0 : _h.llm) == null ? void 0 : _i.provider) {
4331
4334
  this.llmProvider = this.config.graphStore.llm.provider;
4335
+ llmConfig = (_j = this.config.graphStore.llm.config) != null ? _j : llmConfig;
4332
4336
  }
4333
- this.llm = LLMFactory.create(this.llmProvider, this.config.llm.config);
4334
- this.structuredLlm = LLMFactory.create(
4335
- this.llmProvider,
4336
- this.config.llm.config
4337
- );
4337
+ this.llm = LLMFactory.create(this.llmProvider, llmConfig);
4338
+ this.structuredLlm = LLMFactory.create(this.llmProvider, llmConfig);
4338
4339
  this.threshold = 0.7;
4339
4340
  }
4340
4341
  async add(data, filters) {