@mnexium/sdk 0.2.0 → 0.2.1
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/README.md +61 -0
- package/dist/index.d.mts +37 -8
- package/dist/index.d.ts +37 -8
- package/dist/index.js +20 -2
- package/dist/index.mjs +20 -2
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -224,6 +224,43 @@ const task = await alice.state.get('current_task');
|
|
|
224
224
|
await alice.state.delete('current_task');
|
|
225
225
|
```
|
|
226
226
|
|
|
227
|
+
### Records (Structured Data)
|
|
228
|
+
|
|
229
|
+
Define typed schemas and work with structured records:
|
|
230
|
+
|
|
231
|
+
```typescript
|
|
232
|
+
// Define a schema
|
|
233
|
+
await mnx.records.defineSchema(
|
|
234
|
+
'deal',
|
|
235
|
+
{
|
|
236
|
+
title: { type: 'string', required: true },
|
|
237
|
+
value: { type: 'number' },
|
|
238
|
+
stage: { type: 'string' },
|
|
239
|
+
},
|
|
240
|
+
{ displayName: 'Deal', description: 'Sales opportunities' }
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
// Insert a record
|
|
244
|
+
const deal = await mnx.records.insert('deal', {
|
|
245
|
+
title: 'Acme Renewal',
|
|
246
|
+
value: 500000,
|
|
247
|
+
stage: 'negotiation',
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
// Get/update/delete
|
|
251
|
+
const found = await mnx.records.get('deal', deal.record_id);
|
|
252
|
+
await mnx.records.update('deal', deal.record_id, { stage: 'closed_won' });
|
|
253
|
+
await mnx.records.delete('deal', deal.record_id);
|
|
254
|
+
|
|
255
|
+
// Query/search
|
|
256
|
+
const wonDeals = await mnx.records.query('deal', {
|
|
257
|
+
where: { stage: 'closed_won' },
|
|
258
|
+
orderBy: '-value',
|
|
259
|
+
limit: 10,
|
|
260
|
+
});
|
|
261
|
+
const similar = await mnx.records.search('deal', 'large enterprise renewals');
|
|
262
|
+
```
|
|
263
|
+
|
|
227
264
|
### Chat History
|
|
228
265
|
|
|
229
266
|
```typescript
|
|
@@ -280,6 +317,7 @@ const mnx = new Mnexium({
|
|
|
280
317
|
recall: false,
|
|
281
318
|
profile: false,
|
|
282
319
|
history: true,
|
|
320
|
+
memoryPolicy: 'mp_sales_v1', // Or false to disable policy for a request
|
|
283
321
|
},
|
|
284
322
|
});
|
|
285
323
|
```
|
|
@@ -298,9 +336,31 @@ Every `process()` and `chat.process()` call supports these options:
|
|
|
298
336
|
| `log` | boolean | `true` | Save messages to chat history |
|
|
299
337
|
| `summarize` | boolean/string | `false` | `'light'`, `'balanced'`, or `'aggressive'` |
|
|
300
338
|
| `systemPrompt` | boolean/string | `true` | `true` (auto), `false` (skip), or prompt ID |
|
|
339
|
+
| `memoryPolicy` | string/boolean | — | Policy ID string to force a policy, or `false` to disable policy for this request |
|
|
340
|
+
| `records` | object | — | Records controls: `learn: 'force' | 'auto' | false`, `tables: string[]`, `sync: boolean`, `recall: boolean` |
|
|
301
341
|
| `stream` | boolean | `false` | Enable streaming response |
|
|
302
342
|
| `metadata` | object | — | Custom metadata attached to saved logs |
|
|
303
343
|
|
|
344
|
+
Memory policy fallback header: the SDK also sends `x-mnx-memory-policy` when `memoryPolicy` is set.
|
|
345
|
+
- `memoryPolicy: false` -> `x-mnx-memory-policy: false`
|
|
346
|
+
- `memoryPolicy: 'mp_abc123'` -> `x-mnx-memory-policy: mp_abc123`
|
|
347
|
+
|
|
348
|
+
Records extraction controls:
|
|
349
|
+
|
|
350
|
+
```typescript
|
|
351
|
+
const response = await mnx.process({
|
|
352
|
+
content: 'Extract and save order details',
|
|
353
|
+
records: {
|
|
354
|
+
learn: 'force', // 'force' | 'auto' | false
|
|
355
|
+
tables: ['orders'], // Optional allowlist
|
|
356
|
+
sync: true, // Wait for write completion
|
|
357
|
+
recall: true, // Include prior records in context
|
|
358
|
+
},
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
console.log(response.records); // Sync extraction metadata (when returned by backend)
|
|
362
|
+
```
|
|
363
|
+
|
|
304
364
|
## Trial Keys
|
|
305
365
|
|
|
306
366
|
If you don't provide an API key, Mnexium auto-provisions a trial key:
|
|
@@ -362,6 +422,7 @@ See the [examples/](./examples/) directory for runnable demos:
|
|
|
362
422
|
| `npm run claims` | Claims extraction and manual setting |
|
|
363
423
|
| `npm run state` | Agent state with TTL |
|
|
364
424
|
| `npm run profile` | User profiles |
|
|
425
|
+
| `npm run records` | Structured records (schemas, CRUD, query, search) |
|
|
365
426
|
| `npm run prompts` | System prompt management |
|
|
366
427
|
| `npm run multi` | Multi-provider (OpenAI, Claude, Gemini) |
|
|
367
428
|
| `npm run full` | Full API demo |
|
package/dist/index.d.mts
CHANGED
|
@@ -5,6 +5,17 @@
|
|
|
5
5
|
interface ProviderConfig {
|
|
6
6
|
apiKey: string;
|
|
7
7
|
}
|
|
8
|
+
type MnxRecordsLearnMode = 'force' | 'auto' | false;
|
|
9
|
+
interface MnxRecordsConfig {
|
|
10
|
+
/** Enable record recall (inject existing records as context) */
|
|
11
|
+
recall?: boolean;
|
|
12
|
+
/** Records extraction mode: "auto" (best effort), "force" (must attempt), false (off) */
|
|
13
|
+
learn?: MnxRecordsLearnMode;
|
|
14
|
+
/** Whether extraction should be synchronous (blocking) */
|
|
15
|
+
sync?: boolean;
|
|
16
|
+
/** Restrict extraction to specific tables */
|
|
17
|
+
tables?: string[];
|
|
18
|
+
}
|
|
8
19
|
/** Default settings for all process() calls */
|
|
9
20
|
interface MnexiumDefaults {
|
|
10
21
|
/** Default model to use */
|
|
@@ -35,6 +46,10 @@ interface MnexiumDefaults {
|
|
|
35
46
|
temperature?: number;
|
|
36
47
|
/** Force regenerate trial key on every request (for testing) */
|
|
37
48
|
regenerateKey?: boolean;
|
|
49
|
+
/** Memory policy override: policy ID string, or false to disable policy for this request */
|
|
50
|
+
memoryPolicy?: string | false;
|
|
51
|
+
/** Default records behavior for process/chat requests */
|
|
52
|
+
records?: MnxRecordsConfig;
|
|
38
53
|
}
|
|
39
54
|
interface MnexiumConfig {
|
|
40
55
|
/** Mnexium API key. If omitted, a trial key will be auto-provisioned. */
|
|
@@ -82,6 +97,10 @@ interface ChatSessionOptions {
|
|
|
82
97
|
temperature?: number;
|
|
83
98
|
/** Custom metadata attached to saved logs */
|
|
84
99
|
metadata?: Record<string, unknown>;
|
|
100
|
+
/** Memory policy override: policy ID string, or false to disable policy for this request */
|
|
101
|
+
memoryPolicy?: string | false;
|
|
102
|
+
/** Records extraction/recall behavior */
|
|
103
|
+
records?: MnxRecordsConfig;
|
|
85
104
|
}
|
|
86
105
|
/** Options for creating a Chat */
|
|
87
106
|
interface ChatOptions {
|
|
@@ -109,6 +128,10 @@ interface ChatOptions {
|
|
|
109
128
|
temperature?: number;
|
|
110
129
|
/** Custom metadata attached to saved logs */
|
|
111
130
|
metadata?: Record<string, unknown>;
|
|
131
|
+
/** Memory policy override: policy ID string, or false to disable policy for this request */
|
|
132
|
+
memoryPolicy?: string | false;
|
|
133
|
+
/** Records extraction/recall behavior */
|
|
134
|
+
records?: MnxRecordsConfig;
|
|
112
135
|
}
|
|
113
136
|
/** Options for listing chat history */
|
|
114
137
|
interface ChatHistoryListOptions {
|
|
@@ -160,6 +183,10 @@ interface ChatProcessOptions {
|
|
|
160
183
|
metadata?: Record<string, unknown>;
|
|
161
184
|
/** Force regenerate trial key */
|
|
162
185
|
regenerateKey?: boolean;
|
|
186
|
+
/** Override memory policy: policy ID string, or false to disable policy for this request */
|
|
187
|
+
memoryPolicy?: string | false;
|
|
188
|
+
/** Override records extraction/recall behavior */
|
|
189
|
+
records?: MnxRecordsConfig;
|
|
163
190
|
}
|
|
164
191
|
/** Options for the simplified process() API */
|
|
165
192
|
interface ProcessOptions {
|
|
@@ -195,6 +222,10 @@ interface ProcessOptions {
|
|
|
195
222
|
metadata?: Record<string, unknown>;
|
|
196
223
|
/** Force regenerate trial key (for key recovery) */
|
|
197
224
|
regenerateKey?: boolean;
|
|
225
|
+
/** Memory policy override: policy ID string, or false to disable policy for this request */
|
|
226
|
+
memoryPolicy?: string | false;
|
|
227
|
+
/** Records extraction/recall behavior */
|
|
228
|
+
records?: MnxRecordsConfig;
|
|
198
229
|
}
|
|
199
230
|
/** Response from process() */
|
|
200
231
|
interface ProcessResponse {
|
|
@@ -216,6 +247,8 @@ interface ProcessResponse {
|
|
|
216
247
|
provisionedKey?: string;
|
|
217
248
|
/** Claim URL for trial key */
|
|
218
249
|
claimUrl?: string;
|
|
250
|
+
/** Records extraction result metadata when sync records mode is enabled */
|
|
251
|
+
records?: unknown;
|
|
219
252
|
/** Full raw response (for advanced use) */
|
|
220
253
|
raw: ChatCompletionResponse;
|
|
221
254
|
}
|
|
@@ -258,15 +291,10 @@ interface MnxOptions {
|
|
|
258
291
|
metadata?: Record<string, unknown>;
|
|
259
292
|
/** Force regenerate trial key (for key recovery) */
|
|
260
293
|
regenerateKey?: boolean;
|
|
294
|
+
/** Memory policy override: policy ID string, or false to disable policy for this request */
|
|
295
|
+
memoryPolicy?: string | false;
|
|
261
296
|
/** Records configuration */
|
|
262
|
-
records?:
|
|
263
|
-
/** Enable record recall (inject existing records as context) */
|
|
264
|
-
recall?: boolean;
|
|
265
|
-
/** Enable record extraction: true = async, "sync" = await and return results (non-streaming only) */
|
|
266
|
-
learn?: boolean | 'sync';
|
|
267
|
-
/** Limit extraction to specific record types */
|
|
268
|
-
types?: string[];
|
|
269
|
-
};
|
|
297
|
+
records?: MnxRecordsConfig;
|
|
270
298
|
}
|
|
271
299
|
interface ChatCompletionOptions extends MnxOptions {
|
|
272
300
|
/** Model to use (e.g., 'gpt-4o-mini', 'claude-3-sonnet', 'gemini-1.5-pro') */
|
|
@@ -305,6 +333,7 @@ interface MnxResponseData {
|
|
|
305
333
|
subject_id: string;
|
|
306
334
|
provisioned_key?: string;
|
|
307
335
|
claim_url?: string;
|
|
336
|
+
records?: unknown;
|
|
308
337
|
}
|
|
309
338
|
interface ChatCompletionResponse {
|
|
310
339
|
id: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,17 @@
|
|
|
5
5
|
interface ProviderConfig {
|
|
6
6
|
apiKey: string;
|
|
7
7
|
}
|
|
8
|
+
type MnxRecordsLearnMode = 'force' | 'auto' | false;
|
|
9
|
+
interface MnxRecordsConfig {
|
|
10
|
+
/** Enable record recall (inject existing records as context) */
|
|
11
|
+
recall?: boolean;
|
|
12
|
+
/** Records extraction mode: "auto" (best effort), "force" (must attempt), false (off) */
|
|
13
|
+
learn?: MnxRecordsLearnMode;
|
|
14
|
+
/** Whether extraction should be synchronous (blocking) */
|
|
15
|
+
sync?: boolean;
|
|
16
|
+
/** Restrict extraction to specific tables */
|
|
17
|
+
tables?: string[];
|
|
18
|
+
}
|
|
8
19
|
/** Default settings for all process() calls */
|
|
9
20
|
interface MnexiumDefaults {
|
|
10
21
|
/** Default model to use */
|
|
@@ -35,6 +46,10 @@ interface MnexiumDefaults {
|
|
|
35
46
|
temperature?: number;
|
|
36
47
|
/** Force regenerate trial key on every request (for testing) */
|
|
37
48
|
regenerateKey?: boolean;
|
|
49
|
+
/** Memory policy override: policy ID string, or false to disable policy for this request */
|
|
50
|
+
memoryPolicy?: string | false;
|
|
51
|
+
/** Default records behavior for process/chat requests */
|
|
52
|
+
records?: MnxRecordsConfig;
|
|
38
53
|
}
|
|
39
54
|
interface MnexiumConfig {
|
|
40
55
|
/** Mnexium API key. If omitted, a trial key will be auto-provisioned. */
|
|
@@ -82,6 +97,10 @@ interface ChatSessionOptions {
|
|
|
82
97
|
temperature?: number;
|
|
83
98
|
/** Custom metadata attached to saved logs */
|
|
84
99
|
metadata?: Record<string, unknown>;
|
|
100
|
+
/** Memory policy override: policy ID string, or false to disable policy for this request */
|
|
101
|
+
memoryPolicy?: string | false;
|
|
102
|
+
/** Records extraction/recall behavior */
|
|
103
|
+
records?: MnxRecordsConfig;
|
|
85
104
|
}
|
|
86
105
|
/** Options for creating a Chat */
|
|
87
106
|
interface ChatOptions {
|
|
@@ -109,6 +128,10 @@ interface ChatOptions {
|
|
|
109
128
|
temperature?: number;
|
|
110
129
|
/** Custom metadata attached to saved logs */
|
|
111
130
|
metadata?: Record<string, unknown>;
|
|
131
|
+
/** Memory policy override: policy ID string, or false to disable policy for this request */
|
|
132
|
+
memoryPolicy?: string | false;
|
|
133
|
+
/** Records extraction/recall behavior */
|
|
134
|
+
records?: MnxRecordsConfig;
|
|
112
135
|
}
|
|
113
136
|
/** Options for listing chat history */
|
|
114
137
|
interface ChatHistoryListOptions {
|
|
@@ -160,6 +183,10 @@ interface ChatProcessOptions {
|
|
|
160
183
|
metadata?: Record<string, unknown>;
|
|
161
184
|
/** Force regenerate trial key */
|
|
162
185
|
regenerateKey?: boolean;
|
|
186
|
+
/** Override memory policy: policy ID string, or false to disable policy for this request */
|
|
187
|
+
memoryPolicy?: string | false;
|
|
188
|
+
/** Override records extraction/recall behavior */
|
|
189
|
+
records?: MnxRecordsConfig;
|
|
163
190
|
}
|
|
164
191
|
/** Options for the simplified process() API */
|
|
165
192
|
interface ProcessOptions {
|
|
@@ -195,6 +222,10 @@ interface ProcessOptions {
|
|
|
195
222
|
metadata?: Record<string, unknown>;
|
|
196
223
|
/** Force regenerate trial key (for key recovery) */
|
|
197
224
|
regenerateKey?: boolean;
|
|
225
|
+
/** Memory policy override: policy ID string, or false to disable policy for this request */
|
|
226
|
+
memoryPolicy?: string | false;
|
|
227
|
+
/** Records extraction/recall behavior */
|
|
228
|
+
records?: MnxRecordsConfig;
|
|
198
229
|
}
|
|
199
230
|
/** Response from process() */
|
|
200
231
|
interface ProcessResponse {
|
|
@@ -216,6 +247,8 @@ interface ProcessResponse {
|
|
|
216
247
|
provisionedKey?: string;
|
|
217
248
|
/** Claim URL for trial key */
|
|
218
249
|
claimUrl?: string;
|
|
250
|
+
/** Records extraction result metadata when sync records mode is enabled */
|
|
251
|
+
records?: unknown;
|
|
219
252
|
/** Full raw response (for advanced use) */
|
|
220
253
|
raw: ChatCompletionResponse;
|
|
221
254
|
}
|
|
@@ -258,15 +291,10 @@ interface MnxOptions {
|
|
|
258
291
|
metadata?: Record<string, unknown>;
|
|
259
292
|
/** Force regenerate trial key (for key recovery) */
|
|
260
293
|
regenerateKey?: boolean;
|
|
294
|
+
/** Memory policy override: policy ID string, or false to disable policy for this request */
|
|
295
|
+
memoryPolicy?: string | false;
|
|
261
296
|
/** Records configuration */
|
|
262
|
-
records?:
|
|
263
|
-
/** Enable record recall (inject existing records as context) */
|
|
264
|
-
recall?: boolean;
|
|
265
|
-
/** Enable record extraction: true = async, "sync" = await and return results (non-streaming only) */
|
|
266
|
-
learn?: boolean | 'sync';
|
|
267
|
-
/** Limit extraction to specific record types */
|
|
268
|
-
types?: string[];
|
|
269
|
-
};
|
|
297
|
+
records?: MnxRecordsConfig;
|
|
270
298
|
}
|
|
271
299
|
interface ChatCompletionOptions extends MnxOptions {
|
|
272
300
|
/** Model to use (e.g., 'gpt-4o-mini', 'claude-3-sonnet', 'gemini-1.5-pro') */
|
|
@@ -305,6 +333,7 @@ interface MnxResponseData {
|
|
|
305
333
|
subject_id: string;
|
|
306
334
|
provisioned_key?: string;
|
|
307
335
|
claim_url?: string;
|
|
336
|
+
records?: unknown;
|
|
308
337
|
}
|
|
309
338
|
interface ChatCompletionResponse {
|
|
310
339
|
id: string;
|
package/dist/index.js
CHANGED
|
@@ -96,7 +96,9 @@ var Chat = class {
|
|
|
96
96
|
temperature: options.temperature ?? this.options.temperature,
|
|
97
97
|
stream: options.stream,
|
|
98
98
|
metadata: options.metadata ?? this.options.metadata,
|
|
99
|
-
regenerateKey: options.regenerateKey
|
|
99
|
+
regenerateKey: options.regenerateKey,
|
|
100
|
+
memoryPolicy: options.memoryPolicy ?? this.options.memoryPolicy,
|
|
101
|
+
records: options.records ?? this.options.records
|
|
100
102
|
});
|
|
101
103
|
}
|
|
102
104
|
};
|
|
@@ -603,6 +605,11 @@ var ChatCompletionsResource = class {
|
|
|
603
605
|
} else if (options.googleKey) {
|
|
604
606
|
headers["x-google-key"] = options.googleKey;
|
|
605
607
|
}
|
|
608
|
+
if (options.memoryPolicy === false) {
|
|
609
|
+
headers["x-mnx-memory-policy"] = "false";
|
|
610
|
+
} else if (typeof options.memoryPolicy === "string" && options.memoryPolicy.trim()) {
|
|
611
|
+
headers["x-mnx-memory-policy"] = options.memoryPolicy;
|
|
612
|
+
}
|
|
606
613
|
const body = {
|
|
607
614
|
model: options.model,
|
|
608
615
|
messages: options.messages,
|
|
@@ -622,6 +629,7 @@ var ChatCompletionsResource = class {
|
|
|
622
629
|
system_prompt: options.systemPrompt,
|
|
623
630
|
metadata: options.metadata,
|
|
624
631
|
regenerate_key: options.regenerateKey,
|
|
632
|
+
memory_policy: options.memoryPolicy,
|
|
625
633
|
records: options.records
|
|
626
634
|
}
|
|
627
635
|
};
|
|
@@ -999,6 +1007,8 @@ var Mnexium = class {
|
|
|
999
1007
|
const maxTokens = options.maxTokens || this.defaults.maxTokens;
|
|
1000
1008
|
const temperature = options.temperature ?? this.defaults.temperature;
|
|
1001
1009
|
const regenerateKey = options.regenerateKey ?? this.defaults.regenerateKey ?? false;
|
|
1010
|
+
const memoryPolicy = options.memoryPolicy ?? this.defaults.memoryPolicy;
|
|
1011
|
+
const records = options.records ?? this.defaults.records;
|
|
1002
1012
|
const headers = {};
|
|
1003
1013
|
const provider = detectProvider(model);
|
|
1004
1014
|
if (provider === "anthropic" && this.anthropicConfig?.apiKey) {
|
|
@@ -1012,6 +1022,11 @@ var Mnexium = class {
|
|
|
1012
1022
|
} else if (this.googleConfig?.apiKey) {
|
|
1013
1023
|
headers["x-google-key"] = this.googleConfig.apiKey;
|
|
1014
1024
|
}
|
|
1025
|
+
if (memoryPolicy === false) {
|
|
1026
|
+
headers["x-mnx-memory-policy"] = "false";
|
|
1027
|
+
} else if (typeof memoryPolicy === "string" && memoryPolicy.trim()) {
|
|
1028
|
+
headers["x-mnx-memory-policy"] = memoryPolicy;
|
|
1029
|
+
}
|
|
1015
1030
|
const body = {
|
|
1016
1031
|
model,
|
|
1017
1032
|
messages: [{ role: "user", content: options.content }],
|
|
@@ -1029,7 +1044,9 @@ var Mnexium = class {
|
|
|
1029
1044
|
summarize,
|
|
1030
1045
|
system_prompt: systemPrompt,
|
|
1031
1046
|
metadata,
|
|
1032
|
-
regenerate_key: regenerateKey
|
|
1047
|
+
regenerate_key: regenerateKey,
|
|
1048
|
+
memory_policy: memoryPolicy,
|
|
1049
|
+
records
|
|
1033
1050
|
}
|
|
1034
1051
|
};
|
|
1035
1052
|
if (options.stream) {
|
|
@@ -1062,6 +1079,7 @@ var Mnexium = class {
|
|
|
1062
1079
|
} : void 0,
|
|
1063
1080
|
provisionedKey: raw.mnx.provisioned_key,
|
|
1064
1081
|
claimUrl: raw.mnx.claim_url,
|
|
1082
|
+
records: raw.mnx.records,
|
|
1065
1083
|
raw
|
|
1066
1084
|
};
|
|
1067
1085
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -61,7 +61,9 @@ var Chat = class {
|
|
|
61
61
|
temperature: options.temperature ?? this.options.temperature,
|
|
62
62
|
stream: options.stream,
|
|
63
63
|
metadata: options.metadata ?? this.options.metadata,
|
|
64
|
-
regenerateKey: options.regenerateKey
|
|
64
|
+
regenerateKey: options.regenerateKey,
|
|
65
|
+
memoryPolicy: options.memoryPolicy ?? this.options.memoryPolicy,
|
|
66
|
+
records: options.records ?? this.options.records
|
|
65
67
|
});
|
|
66
68
|
}
|
|
67
69
|
};
|
|
@@ -568,6 +570,11 @@ var ChatCompletionsResource = class {
|
|
|
568
570
|
} else if (options.googleKey) {
|
|
569
571
|
headers["x-google-key"] = options.googleKey;
|
|
570
572
|
}
|
|
573
|
+
if (options.memoryPolicy === false) {
|
|
574
|
+
headers["x-mnx-memory-policy"] = "false";
|
|
575
|
+
} else if (typeof options.memoryPolicy === "string" && options.memoryPolicy.trim()) {
|
|
576
|
+
headers["x-mnx-memory-policy"] = options.memoryPolicy;
|
|
577
|
+
}
|
|
571
578
|
const body = {
|
|
572
579
|
model: options.model,
|
|
573
580
|
messages: options.messages,
|
|
@@ -587,6 +594,7 @@ var ChatCompletionsResource = class {
|
|
|
587
594
|
system_prompt: options.systemPrompt,
|
|
588
595
|
metadata: options.metadata,
|
|
589
596
|
regenerate_key: options.regenerateKey,
|
|
597
|
+
memory_policy: options.memoryPolicy,
|
|
590
598
|
records: options.records
|
|
591
599
|
}
|
|
592
600
|
};
|
|
@@ -964,6 +972,8 @@ var Mnexium = class {
|
|
|
964
972
|
const maxTokens = options.maxTokens || this.defaults.maxTokens;
|
|
965
973
|
const temperature = options.temperature ?? this.defaults.temperature;
|
|
966
974
|
const regenerateKey = options.regenerateKey ?? this.defaults.regenerateKey ?? false;
|
|
975
|
+
const memoryPolicy = options.memoryPolicy ?? this.defaults.memoryPolicy;
|
|
976
|
+
const records = options.records ?? this.defaults.records;
|
|
967
977
|
const headers = {};
|
|
968
978
|
const provider = detectProvider(model);
|
|
969
979
|
if (provider === "anthropic" && this.anthropicConfig?.apiKey) {
|
|
@@ -977,6 +987,11 @@ var Mnexium = class {
|
|
|
977
987
|
} else if (this.googleConfig?.apiKey) {
|
|
978
988
|
headers["x-google-key"] = this.googleConfig.apiKey;
|
|
979
989
|
}
|
|
990
|
+
if (memoryPolicy === false) {
|
|
991
|
+
headers["x-mnx-memory-policy"] = "false";
|
|
992
|
+
} else if (typeof memoryPolicy === "string" && memoryPolicy.trim()) {
|
|
993
|
+
headers["x-mnx-memory-policy"] = memoryPolicy;
|
|
994
|
+
}
|
|
980
995
|
const body = {
|
|
981
996
|
model,
|
|
982
997
|
messages: [{ role: "user", content: options.content }],
|
|
@@ -994,7 +1009,9 @@ var Mnexium = class {
|
|
|
994
1009
|
summarize,
|
|
995
1010
|
system_prompt: systemPrompt,
|
|
996
1011
|
metadata,
|
|
997
|
-
regenerate_key: regenerateKey
|
|
1012
|
+
regenerate_key: regenerateKey,
|
|
1013
|
+
memory_policy: memoryPolicy,
|
|
1014
|
+
records
|
|
998
1015
|
}
|
|
999
1016
|
};
|
|
1000
1017
|
if (options.stream) {
|
|
@@ -1027,6 +1044,7 @@ var Mnexium = class {
|
|
|
1027
1044
|
} : void 0,
|
|
1028
1045
|
provisionedKey: raw.mnx.provisioned_key,
|
|
1029
1046
|
claimUrl: raw.mnx.claim_url,
|
|
1047
|
+
records: raw.mnx.records,
|
|
1030
1048
|
raw
|
|
1031
1049
|
};
|
|
1032
1050
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mnexium/sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Official Mnexium SDK for JavaScript/TypeScript - Add memory to your AI applications",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"example:claims": "cd examples && npm run claims",
|
|
29
29
|
"example:state": "cd examples && npm run state",
|
|
30
30
|
"example:profile": "cd examples && npm run profile",
|
|
31
|
+
"example:records": "cd examples && npm run records",
|
|
31
32
|
"example:prompts": "cd examples && npm run prompts",
|
|
32
33
|
"example:streaming": "cd examples && npm run streaming",
|
|
33
34
|
"example:events": "cd examples && npm run events",
|