Version Bump/Formatting (#2923)

This commit is contained in:
Saket Aryan
2025-06-06 21:49:03 +05:30
committed by GitHub
parent e10a509645
commit 9a12ea7b3c
5 changed files with 74 additions and 30 deletions

View File

@@ -288,6 +288,14 @@ mode: "wide"
<Tab title="TypeScript">
<Update label="2025-06-06" description="v2.1.30">
**New Features:**
- **OSS:** Added Cloudflare support
**Improvements:**
- **OSS:** Fixed baseURL param in LLM Config.
</Update>
<Update label="2025-05-30" description="v2.1.29">
**Improvements:**
- **Client:** Added Async Mode Param for `add` method.

View File

@@ -1,6 +1,6 @@
{
"name": "mem0ai",
"version": "2.1.29",
"version": "2.1.30",
"description": "The Memory Layer For Your AI Apps",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
@@ -107,6 +107,8 @@
"@types/sqlite3": "3.1.11",
"groq-sdk": "0.3.0",
"@langchain/core": "^0.3.44",
"cloudflare": "^4.2.0",
"@cloudflare/workers-types": "^4.20250504.0",
"neo4j-driver": "^5.28.1",
"ollama": "^0.5.14",
"pg": "8.11.3",

32
mem0-ts/pnpm-lock.yaml generated
View File

@@ -10,6 +10,9 @@ importers:
"@anthropic-ai/sdk":
specifier: ^0.40.1
version: 0.40.1(encoding@0.1.13)
"@cloudflare/workers-types":
specifier: ^4.20250504.0
version: 4.20250606.0
"@google/genai":
specifier: ^1.2.0
version: 1.2.0(@modelcontextprotocol/sdk@1.12.1)(encoding@0.1.13)
@@ -37,6 +40,9 @@ importers:
axios:
specifier: 1.7.7
version: 1.7.7
cloudflare:
specifier: ^4.2.0
version: 4.3.0(encoding@0.1.13)
groq-sdk:
specifier: 0.3.0
version: 0.3.0(encoding@0.1.13)
@@ -385,6 +391,12 @@ packages:
integrity: sha512-gAmrUZSGtKc3AiBL71iNWxDsyUC5uMaKKGdvzYsBoTW/xi42JQHl7eKV2OYzCUqvc+D2RCcf7EXY2iCyFIk6og==,
}
"@cloudflare/workers-types@4.20250606.0":
resolution:
{
integrity: sha512-9T/Y/Mxe57UVzqgfjJKheiMplnStj/3CmCHlgoZNLU8JW2waRbXvpY3EEeliiYAJfeHZTjeAaKO2pCabxAoyCw==,
}
"@cspotcode/source-map-support@0.8.1":
resolution:
{
@@ -1811,6 +1823,12 @@ packages:
}
engines: { node: ">=12" }
cloudflare@4.3.0:
resolution:
{
integrity: sha512-C+4Jhsl/OY4V5sykRB1yJxComDld5BkKW1xd3s0MDJ1yYamT2sFAoC2FEUQg5zipyxMaaGU4N7hZ6il+gfJxZg==,
}
cluster-key-slot@1.1.2:
resolution:
{
@@ -5465,6 +5483,8 @@ snapshots:
"@cfworker/json-schema@4.1.1": {}
"@cloudflare/workers-types@4.20250606.0": {}
"@cspotcode/source-map-support@0.8.1":
dependencies:
"@jridgewell/trace-mapping": 0.3.9
@@ -6397,6 +6417,18 @@ snapshots:
strip-ansi: 6.0.1
wrap-ansi: 7.0.0
cloudflare@4.3.0(encoding@0.1.13):
dependencies:
"@types/node": 18.19.76
"@types/node-fetch": 2.6.12
abort-controller: 3.0.0
agentkeepalive: 4.6.0
form-data-encoder: 1.7.2
formdata-node: 4.4.1
node-fetch: 2.7.0(encoding@0.1.13)
transitivePeerDependencies:
- encoding
cluster-key-slot@1.1.2: {}
co@4.6.0: {}

View File

@@ -117,6 +117,7 @@ export const MemoryConfigSchema = z.object({
modelProperties: z.record(z.string(), z.any()).optional(),
apiKey: z.string().optional(),
model: z.union([z.string(), z.any()]).optional(),
baseURL: z.string().optional(),
}),
}),
vectorStore: z.object({
@@ -135,6 +136,7 @@ export const MemoryConfigSchema = z.object({
apiKey: z.string().optional(),
model: z.union([z.string(), z.any()]).optional(),
modelProperties: z.record(z.string(), z.any()).optional(),
baseURL: z.string().optional(),
}),
}),
historyDbPath: z.string().optional(),

View File

@@ -32,7 +32,7 @@ export class VectorizeDB implements VectorStore {
async insert(
vectors: number[][],
ids: string[],
payloads: Record<string, any>[]
payloads: Record<string, any>[],
): Promise<void> {
try {
const vectorObjects: CloudflareVector[] = vectors.map(
@@ -40,7 +40,7 @@ export class VectorizeDB implements VectorStore {
id: ids[index],
values: vector,
metadata: payloads[index] || {},
})
}),
);
const ndjsonPayload = vectorObjects
@@ -56,19 +56,19 @@ export class VectorizeDB implements VectorStore {
Authorization: `Bearer ${this.client?.apiToken}`,
},
body: ndjsonPayload,
}
},
);
if (!response.ok) {
const errorText = await response.text();
throw new Error(
`Failed to insert vectors: ${response.status} ${errorText}`
`Failed to insert vectors: ${response.status} ${errorText}`,
);
}
} catch (error) {
console.error("Error inserting vectors:", error);
throw new Error(
`Failed to insert vectors: ${error instanceof Error ? error.message : String(error)}`
`Failed to insert vectors: ${error instanceof Error ? error.message : String(error)}`,
);
}
}
@@ -76,7 +76,7 @@ export class VectorizeDB implements VectorStore {
async search(
query: number[],
limit: number = 5,
filters?: SearchFilters
filters?: SearchFilters,
): Promise<VectorStoreResult[]> {
try {
const result = await this.client?.vectorize.indexes.query(
@@ -87,7 +87,7 @@ export class VectorizeDB implements VectorStore {
filter: filters,
returnMetadata: "all",
topK: limit,
}
},
);
return (
@@ -100,7 +100,7 @@ export class VectorizeDB implements VectorStore {
} catch (error) {
console.error("Error searching vectors:", error);
throw new Error(
`Failed to search vectors: ${error instanceof Error ? error.message : String(error)}`
`Failed to search vectors: ${error instanceof Error ? error.message : String(error)}`,
);
}
}
@@ -112,7 +112,7 @@ export class VectorizeDB implements VectorStore {
{
account_id: this.accountId,
ids: [vectorId],
}
},
)) as any;
if (!result?.length) return null;
@@ -124,7 +124,7 @@ export class VectorizeDB implements VectorStore {
} catch (error) {
console.error("Error getting vector:", error);
throw new Error(
`Failed to get vector: ${error instanceof Error ? error.message : String(error)}`
`Failed to get vector: ${error instanceof Error ? error.message : String(error)}`,
);
}
}
@@ -132,7 +132,7 @@ export class VectorizeDB implements VectorStore {
async update(
vectorId: string,
vector: number[],
payload: Record<string, any>
payload: Record<string, any>,
): Promise<void> {
try {
const data: VectorizeVector = {
@@ -150,19 +150,19 @@ export class VectorizeDB implements VectorStore {
Authorization: `Bearer ${this.client?.apiToken}`,
},
body: JSON.stringify(data) + "\n", // ndjson format
}
},
);
if (!response.ok) {
const errorText = await response.text();
throw new Error(
`Failed to update vector: ${response.status} ${errorText}`
`Failed to update vector: ${response.status} ${errorText}`,
);
}
} catch (error) {
console.error("Error updating vector:", error);
throw new Error(
`Failed to update vector: ${error instanceof Error ? error.message : String(error)}`
`Failed to update vector: ${error instanceof Error ? error.message : String(error)}`,
);
}
}
@@ -176,7 +176,7 @@ export class VectorizeDB implements VectorStore {
} catch (error) {
console.error("Error deleting vector:", error);
throw new Error(
`Failed to delete vector: ${error instanceof Error ? error.message : String(error)}`
`Failed to delete vector: ${error instanceof Error ? error.message : String(error)}`,
);
}
}
@@ -189,14 +189,14 @@ export class VectorizeDB implements VectorStore {
} catch (error) {
console.error("Error deleting collection:", error);
throw new Error(
`Failed to delete collection: ${error instanceof Error ? error.message : String(error)}`
`Failed to delete collection: ${error instanceof Error ? error.message : String(error)}`,
);
}
}
async list(
filters?: SearchFilters,
limit: number = 20
limit: number = 20,
): Promise<[VectorStoreResult[], number]> {
try {
const result = await this.client?.vectorize.indexes.query(
@@ -207,7 +207,7 @@ export class VectorizeDB implements VectorStore {
filter: filters,
topK: limit,
returnMetadata: "all",
}
},
);
const matches =
@@ -221,7 +221,7 @@ export class VectorizeDB implements VectorStore {
} catch (error) {
console.error("Error listing vectors:", error);
throw new Error(
`Failed to list vectors: ${error instanceof Error ? error.message : String(error)}`
`Failed to list vectors: ${error instanceof Error ? error.message : String(error)}`,
);
}
}
@@ -233,7 +233,7 @@ export class VectorizeDB implements VectorStore {
const r = (Math.random() * 16) | 0;
const v = c === "x" ? r : (r & 0x3) | 0x8;
return v.toString(16);
}
},
);
}
@@ -267,7 +267,7 @@ export class VectorizeDB implements VectorStore {
vector: [0],
topK: 1,
returnMetadata: "all",
}
},
);
if (result.matches.length > 0) {
return result.matches[0].metadata.userId as string;
@@ -292,13 +292,13 @@ export class VectorizeDB implements VectorStore {
Authorization: `Bearer ${this.client?.apiToken}`,
},
body: JSON.stringify(data) + "\n", // ndjson format
}
},
);
return randomUserId;
} catch (error) {
console.error("Error getting user ID:", error);
throw new Error(
`Failed to get user ID: ${error instanceof Error ? error.message : String(error)}`
`Failed to get user ID: ${error instanceof Error ? error.message : String(error)}`,
);
}
}
@@ -313,7 +313,7 @@ export class VectorizeDB implements VectorStore {
vector: [0],
topK: 1,
returnMetadata: "all",
}
},
);
const pointId =
result.matches.length > 0 ? result.matches[0].id : this.generateUUID();
@@ -332,12 +332,12 @@ export class VectorizeDB implements VectorStore {
Authorization: `Bearer ${this.client?.apiToken}`,
},
body: JSON.stringify(data) + "\n", // ndjson format
}
},
);
} catch (error) {
console.error("Error setting user ID:", error);
throw new Error(
`Failed to set user ID: ${error instanceof Error ? error.message : String(error)}`
`Failed to set user ID: ${error instanceof Error ? error.message : String(error)}`,
);
}
}
@@ -375,7 +375,7 @@ export class VectorizeDB implements VectorStore {
account_id: this.accountId,
indexType: "string",
propertyName,
}
},
);
}
} catch (err: any) {
@@ -389,7 +389,7 @@ export class VectorizeDB implements VectorStore {
this.indexName,
{
account_id: this.accountId,
}
},
);
const existingMetadataIndexes = new Set<string>();
for (const metadataIndex of metadataIndexes?.metadataIndexes || []) {
@@ -404,7 +404,7 @@ export class VectorizeDB implements VectorStore {
account_id: this.accountId,
indexType: "string",
propertyName,
}
},
);
}
}