feat: Add metadata param to TS-SDK in client.update (#3415)

This commit is contained in:
Saket Aryan
2025-09-04 03:22:12 +05:30
committed by GitHub
parent 5e8d5e4664
commit f0e8c3f760
3 changed files with 16 additions and 3 deletions
+5
View File
@@ -611,6 +611,11 @@ mode: "wide"
<Tab title="TypeScript"> <Tab title="TypeScript">
<Update label="2025-09-04" description="v2.1.38">
**New Features:**
- **Client:** Added `metadata` param to `update` method.
</Update>
<Update label="2025-08-04" description="v2.1.37"> <Update label="2025-08-04" description="v2.1.37">
**New Features:** **New Features:**
- **OSS:** Added `RedisCloud` search module check - **OSS:** Added `RedisCloud` search module check
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "mem0ai", "name": "mem0ai",
"version": "2.1.37", "version": "2.1.38",
"description": "The Memory Layer For Your AI Apps", "description": "The Memory Layer For Your AI Apps",
"main": "./dist/index.js", "main": "./dist/index.js",
"module": "./dist/index.mjs", "module": "./dist/index.mjs",
+10 -2
View File
@@ -251,11 +251,19 @@ export default class MemoryClient {
return response; return response;
} }
async update(memoryId: string, message: string): Promise<Array<Memory>> { async update(
memoryId: string,
{ text, metadata }: { text?: string; metadata?: Record<string, any> },
): Promise<Array<Memory>> {
if (text === undefined && metadata === undefined) {
throw new Error("Either text or metadata must be provided for update.");
}
if (this.telemetryId === "") await this.ping(); if (this.telemetryId === "") await this.ping();
this._validateOrgProject(); this._validateOrgProject();
const payload = { const payload = {
text: message, text: text,
metadata: metadata,
}; };
const payloadKeys = Object.keys(payload); const payloadKeys = Object.keys(payload);