@personize/sdk 0.6.2 → 0.6.5
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 +220 -12
- package/dist/client.d.ts +100 -3
- package/dist/client.js +714 -11
- package/dist/types.d.ts +509 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -38,6 +38,7 @@ console.log(me.data.plan.limits);
|
|
|
38
38
|
| **AI** | | |
|
|
39
39
|
| POST | `/api/v1/ai/smart-guidelines` | `client.ai.smartGuidelines(opts)` |
|
|
40
40
|
| POST | `/api/v1/prompt` | `client.ai.prompt(opts)` |
|
|
41
|
+
| POST | `/api/v1/prompt` (stream) | `client.ai.promptStream(opts)` |
|
|
41
42
|
| **Memory** | | |
|
|
42
43
|
| POST | `/api/v1/memorize` | `client.memory.memorize(opts)` |
|
|
43
44
|
| POST | `/api/v1/smart-recall` | `client.memory.smartRecall(opts)` |
|
|
@@ -45,6 +46,7 @@ console.log(me.data.plan.limits);
|
|
|
45
46
|
| POST | `/api/v1/search` | `client.memory.search(opts)` |
|
|
46
47
|
| POST | `/api/v1/batch-memorize` | `client.memory.memorizeBatch(opts)` |
|
|
47
48
|
| POST | `/api/v1/smart-memory-digest` | `client.memory.smartDigest(opts)` |
|
|
49
|
+
| POST | `/api/v1/memory/properties` | `client.memory.properties(opts)` |
|
|
48
50
|
| **Guidelines** | | |
|
|
49
51
|
| GET | `/api/v1/guidelines` | `client.guidelines.list()` |
|
|
50
52
|
| POST | `/api/v1/guidelines` | `client.guidelines.create(payload)` |
|
|
@@ -185,6 +187,97 @@ console.log(research.data?.outputs?.company_profile);
|
|
|
185
187
|
console.log(research.data?.evaluation?.finalScore);
|
|
186
188
|
```
|
|
187
189
|
|
|
190
|
+
### Streaming Prompt Execution
|
|
191
|
+
|
|
192
|
+
`promptStream()` returns an async generator that yields Server-Sent Events as they arrive. Use this for real-time UI updates, progressive output delivery, or when you need structured outputs as soon as each one finishes generating.
|
|
193
|
+
|
|
194
|
+
```typescript
|
|
195
|
+
import type { PromptSSEEvent } from '@personize/sdk';
|
|
196
|
+
|
|
197
|
+
// Stream with structured outputs — events arrive as each output closes
|
|
198
|
+
for await (const event of client.ai.promptStream({
|
|
199
|
+
prompt: 'Generate a hero section and social proof for our landing page',
|
|
200
|
+
outputs: [
|
|
201
|
+
{ name: 'hero' },
|
|
202
|
+
{ name: 'social_proof' },
|
|
203
|
+
],
|
|
204
|
+
})) {
|
|
205
|
+
switch (event.type) {
|
|
206
|
+
case 'text':
|
|
207
|
+
// Raw LLM text chunks (everything outside <output> markers)
|
|
208
|
+
process.stdout.write(event.chunk);
|
|
209
|
+
break;
|
|
210
|
+
|
|
211
|
+
case 'output':
|
|
212
|
+
// A named output extracted — fired once per output as soon as </output> closes
|
|
213
|
+
// event.data is already parsed (JSON object or plain string)
|
|
214
|
+
console.log(`Output "${event.name}":`, event.data);
|
|
215
|
+
break;
|
|
216
|
+
|
|
217
|
+
case 'done':
|
|
218
|
+
// Final event — includes all outputs, evaluation, and metadata
|
|
219
|
+
console.log('All outputs:', event.outputs);
|
|
220
|
+
console.log('Metadata:', event.metadata);
|
|
221
|
+
break;
|
|
222
|
+
|
|
223
|
+
case 'error':
|
|
224
|
+
// Non-fatal error during streaming
|
|
225
|
+
console.error('Stream error:', event.message);
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
**SSE Event Types:**
|
|
232
|
+
|
|
233
|
+
| Event | Frequency | Description |
|
|
234
|
+
| :--- | :--- | :--- |
|
|
235
|
+
| `text` | Many per response | Plain text chunks from the LLM |
|
|
236
|
+
| `output` | Once per named output | Extracted output (JSON or string) — fired as soon as `</output>` closes |
|
|
237
|
+
| `step_complete` | Once per instruction step | Multi-step mode: step metadata |
|
|
238
|
+
| `done` | Once at end | Final reconciliation with all outputs + metadata |
|
|
239
|
+
| `error` | 0 or more | Non-fatal streaming errors |
|
|
240
|
+
|
|
241
|
+
**Options:**
|
|
242
|
+
|
|
243
|
+
| Option | Type | Default | Description |
|
|
244
|
+
| :--- | :--- | :--- | :--- |
|
|
245
|
+
| `streamTimeout` | number | `120000` | Overall stream timeout in ms |
|
|
246
|
+
| `signal` | AbortSignal | — | External abort signal for cancellation |
|
|
247
|
+
|
|
248
|
+
All other `PromptOptions` parameters (`outputs`, `context`, `instructions`, `tier`, `memorize`, `evaluate`, etc.) are supported.
|
|
249
|
+
|
|
250
|
+
**Cancellation:**
|
|
251
|
+
|
|
252
|
+
```typescript
|
|
253
|
+
const controller = new AbortController();
|
|
254
|
+
setTimeout(() => controller.abort(), 5000); // cancel after 5s
|
|
255
|
+
|
|
256
|
+
for await (const event of client.ai.promptStream({
|
|
257
|
+
prompt: '...',
|
|
258
|
+
signal: controller.signal,
|
|
259
|
+
})) {
|
|
260
|
+
// ...
|
|
261
|
+
}
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
#### Entity Identifiers
|
|
265
|
+
|
|
266
|
+
All memory endpoints support multiple CRM key types for entity scoping:
|
|
267
|
+
|
|
268
|
+
| Key | Use case |
|
|
269
|
+
|-----|----------|
|
|
270
|
+
| `email` | Contact lookup |
|
|
271
|
+
| `websiteUrl` | Company lookup |
|
|
272
|
+
| `recordId` | Direct record ID |
|
|
273
|
+
| `customKeyName` + `customKeyValue` | Custom CRM field (e.g. `hubspot_id`) |
|
|
274
|
+
| `phoneNumber` | Phone-based lookup |
|
|
275
|
+
| `postalCode` | Location-based lookup |
|
|
276
|
+
| `deviceId` | Device-based lookup |
|
|
277
|
+
| `contentId` | Content-based lookup |
|
|
278
|
+
|
|
279
|
+
You can pass multiple keys simultaneously for better matching.
|
|
280
|
+
|
|
188
281
|
### Memory (RAG)
|
|
189
282
|
|
|
190
283
|
```typescript
|
|
@@ -199,21 +292,20 @@ const memorized = await client.memory.memorize({
|
|
|
199
292
|
});
|
|
200
293
|
console.log(memorized.data?.recordId); // REC#<hex> — deterministic, use for recall/digest
|
|
201
294
|
|
|
202
|
-
// Smart recall —
|
|
295
|
+
// Smart recall — deep mode (default): reflection + answer generation, ~10-20s, 2 credits
|
|
203
296
|
const results = await client.memory.smartRecall({
|
|
204
297
|
query: 'What does John prefer?',
|
|
205
298
|
limit: 5,
|
|
206
299
|
minScore: 0.7,
|
|
207
|
-
|
|
208
|
-
generate_answer: true,
|
|
300
|
+
mode: 'deep',
|
|
209
301
|
});
|
|
210
302
|
|
|
211
|
-
//
|
|
303
|
+
// Smart recall — fast mode: skips reflection, ~500ms, 1 credit
|
|
212
304
|
const fast = await client.memory.smartRecall({
|
|
213
305
|
query: 'contact info for John',
|
|
214
306
|
email: 'john@example.com',
|
|
215
|
-
|
|
216
|
-
// min_results: 10 (default in
|
|
307
|
+
mode: 'fast',
|
|
308
|
+
// min_results: 10 (default in fast mode — always returns top N even below score threshold)
|
|
217
309
|
});
|
|
218
310
|
|
|
219
311
|
// Custom keys — bring your own identifier for any entity type
|
|
@@ -239,7 +331,7 @@ const student = await client.memory.smartRecall({
|
|
|
239
331
|
type: 'Student',
|
|
240
332
|
customKeyName: 'studentNumber',
|
|
241
333
|
customKeyValue: 'S-2024-1234',
|
|
242
|
-
|
|
334
|
+
mode: 'fast',
|
|
243
335
|
});
|
|
244
336
|
|
|
245
337
|
// Direct recall — DynamoDB lookup: properties + freeform memories (no AI, type required)
|
|
@@ -285,6 +377,47 @@ for (const [recordId, props] of Object.entries(found.data?.records ?? {})) {
|
|
|
285
377
|
}
|
|
286
378
|
// Note: 'email' and 'company-name' must match the property names in your collection definition
|
|
287
379
|
|
|
380
|
+
// --- Advanced Search Patterns ---
|
|
381
|
+
|
|
382
|
+
// Key-only lookup: find a record by email without needing property conditions
|
|
383
|
+
const byEmail = await client.memory.search({
|
|
384
|
+
email: 'sarah@acme.com',
|
|
385
|
+
returnRecords: true,
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
// Key-only lookup: find a record by custom key (no groups needed)
|
|
389
|
+
const byStudentNumber = await client.memory.search({
|
|
390
|
+
type: 'Student',
|
|
391
|
+
customKeyName: 'studentNumber',
|
|
392
|
+
customKeyValue: 'S-2024-1234',
|
|
393
|
+
returnRecords: true,
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
// Secondary key: find Students where email is a secondary attribute (not the primary key)
|
|
397
|
+
// Works because memorize stores all CRM keys on every LanceDB row
|
|
398
|
+
const studentByEmail = await client.memory.search({
|
|
399
|
+
type: 'Student',
|
|
400
|
+
email: 'alice@university.edu',
|
|
401
|
+
returnRecords: true,
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
// Cross-type search: find ALL records with this email across ALL entity types
|
|
405
|
+
// Returns Contacts, Students, Employees — whatever has this email
|
|
406
|
+
const crossType = await client.memory.search({
|
|
407
|
+
email: 'john@acme.com',
|
|
408
|
+
returnRecords: true,
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
// Property-value lookup: find records by a stored property (e.g. LinkedIn URL)
|
|
412
|
+
// Use this when the lookup key is a property value, not a CRM identifier
|
|
413
|
+
const byLinkedIn = await client.memory.search({
|
|
414
|
+
type: 'Contact',
|
|
415
|
+
returnRecords: true,
|
|
416
|
+
groups: [{
|
|
417
|
+
conditions: [{ property: 'linkedin_url', operator: 'EQ', value: 'https://linkedin.com/in/johndoe' }],
|
|
418
|
+
}],
|
|
419
|
+
});
|
|
420
|
+
|
|
288
421
|
// Batch sync — unified call with per-property extractMemories control
|
|
289
422
|
// IMPORTANT: Set extractMemories: true on rich text fields (notes, transcripts, descriptions)
|
|
290
423
|
// to enable AI extraction and semantic search. Without it, only structured storage occurs.
|
|
@@ -336,6 +469,38 @@ console.log(digest.data?.compiledContext); // ready-to-use markdown for LLM prom
|
|
|
336
469
|
|
|
337
470
|
```
|
|
338
471
|
|
|
472
|
+
### Get Record Properties
|
|
473
|
+
|
|
474
|
+
Fetch current property values for a record, joined with collection schema descriptions and the `update` flag.
|
|
475
|
+
|
|
476
|
+
```typescript
|
|
477
|
+
// Get specific properties with schema info
|
|
478
|
+
const result = await client.memory.properties({
|
|
479
|
+
email: 'john@acme.com',
|
|
480
|
+
propertyNames: ['Tasks', 'Lifecycle Stage'],
|
|
481
|
+
nonEmpty: true,
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
for (const prop of result.data.properties) {
|
|
485
|
+
console.log(`${prop.name}: ${JSON.stringify(prop.value)}`);
|
|
486
|
+
console.log(` Type: ${prop.type}, Update: ${prop.update}`);
|
|
487
|
+
console.log(` Description: ${prop.description}`);
|
|
488
|
+
}
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
Each property includes:
|
|
492
|
+
- `value` — current value
|
|
493
|
+
- `description` — from the collection schema, tells AI how to interpret/update
|
|
494
|
+
- `update` — `true` means replaceable (use `memory.update()` with `propertyValue`), `false` means append-only (use `arrayPush`)
|
|
495
|
+
- `type` — property type (`text`, `number`, `boolean`, `array`, `date`, `options`)
|
|
496
|
+
- `collectionName` — which collection this property belongs to
|
|
497
|
+
|
|
498
|
+
Options:
|
|
499
|
+
- `propertyNames` — filter to specific properties (recommended to save tokens)
|
|
500
|
+
- `includeDescriptions` — join with collection schema (default: `true`)
|
|
501
|
+
- `nonEmpty` — exclude null/empty values (default: `false`)
|
|
502
|
+
- Identifiers: `email`, `websiteUrl`, `recordId`, `customKeyName`+`customKeyValue`
|
|
503
|
+
|
|
339
504
|
### Agents
|
|
340
505
|
|
|
341
506
|
```typescript
|
|
@@ -415,12 +580,12 @@ console.log(evaluation.data.summary.propertiesOptimized);
|
|
|
415
580
|
|
|
416
581
|
| Operation | Mode | Credits/Call |
|
|
417
582
|
| :--- | :--- | :--- |
|
|
418
|
-
| Smart Recall | `
|
|
419
|
-
| Smart Recall | `
|
|
583
|
+
| Smart Recall | `mode: 'fast'` | 1 |
|
|
584
|
+
| Smart Recall | `mode: 'deep'` | 2 |
|
|
420
585
|
| Smart Guidelines | `mode: 'fast'` | 1 |
|
|
421
586
|
| Smart Guidelines | `mode: 'deep'` | 1 |
|
|
422
587
|
|
|
423
|
-
All read operations (recall, smart
|
|
588
|
+
Smart Recall cost depends on mode: fast = 1 credit, deep = 2 credits. All other read operations (recall, smart guidelines, smart context) charge a flat **1 credit per call**.
|
|
424
589
|
|
|
425
590
|
1 credit = $0.01.
|
|
426
591
|
|
|
@@ -455,6 +620,33 @@ await client.ai.prompt({
|
|
|
455
620
|
|
|
456
621
|
Response metadata includes `byok: true` and `creditsCharged` reflecting the flat 5-credit charge.
|
|
457
622
|
|
|
623
|
+
## Smart Recall Modes
|
|
624
|
+
|
|
625
|
+
The `mode` parameter controls smart recall behavior:
|
|
626
|
+
|
|
627
|
+
| Mode | Latency | Credits | Description |
|
|
628
|
+
| :--- | :--- | :--- | :--- |
|
|
629
|
+
| `"fast"` | ~500ms | 1 | Skips reflection and answer generation. Returns raw vector results with guaranteed minimum count. |
|
|
630
|
+
| `"deep"` | ~10-20s | 2 | Enables reflection + answer generation for higher-quality, synthesized responses. |
|
|
631
|
+
|
|
632
|
+
Default is `"deep"`. The `mode` parameter takes precedence over the individual `enable_reflection`, `generate_answer`, and `fast_mode` flags. If `mode` is set, those flags are ignored.
|
|
633
|
+
|
|
634
|
+
#### Recency Bias
|
|
635
|
+
|
|
636
|
+
Use `prefer_recent` to boost recent memories with exponential decay:
|
|
637
|
+
|
|
638
|
+
```typescript
|
|
639
|
+
const result = await client.memory.smartRecall({
|
|
640
|
+
query: "what changed on this contact recently?",
|
|
641
|
+
email: "john@acme.com",
|
|
642
|
+
mode: "deep",
|
|
643
|
+
prefer_recent: true,
|
|
644
|
+
recency_half_life_days: 30, // aggressive: 30-day half-life
|
|
645
|
+
});
|
|
646
|
+
```
|
|
647
|
+
|
|
648
|
+
Default half-life is 90 days. A memory 90 days old scores ~37% of its original relevance. Set to 7-30 for "what happened this week/month" queries.
|
|
649
|
+
|
|
458
650
|
## Best Practices: Query Crafting for smartRecall
|
|
459
651
|
|
|
460
652
|
The `smartRecall` endpoint uses vector similarity search. Query quality directly impacts result relevance. When building AI pipelines that call `smartRecall`, the **AI agent is responsible for crafting embedding-friendly queries**.
|
|
@@ -477,11 +669,11 @@ const bad = await client.memory.smartRecall({ query: 'Tell me about this contact
|
|
|
477
669
|
const good = await client.memory.smartRecall({
|
|
478
670
|
query: `${contactName} role company background interests preferences`,
|
|
479
671
|
email,
|
|
480
|
-
|
|
672
|
+
mode: 'fast',
|
|
481
673
|
});
|
|
482
674
|
```
|
|
483
675
|
|
|
484
|
-
**Guaranteed minimum results:** In `
|
|
676
|
+
**Guaranteed minimum results:** In `mode: 'fast'`, `smartRecall` guarantees at least 10 results (configurable via `min_results`) even when scores fall below the threshold. This ensures your AI workflow always has context to reason about — it can then decide whether the data is sufficient or not.
|
|
485
677
|
|
|
486
678
|
## Configuration
|
|
487
679
|
|
|
@@ -502,6 +694,22 @@ const client = new Personize({
|
|
|
502
694
|
});
|
|
503
695
|
```
|
|
504
696
|
|
|
697
|
+
## Migration from 0.6.2
|
|
698
|
+
|
|
699
|
+
**New in 0.6.3:**
|
|
700
|
+
|
|
701
|
+
| Feature | Details |
|
|
702
|
+
| :--- | :--- |
|
|
703
|
+
| `evaluationCriteria` on `PromptOptions` | Compatibility alias for `evaluate: { criteria, serverSide: true }` |
|
|
704
|
+
| `message` on `RecallOptions` / `SmartRecallOptions` | Compatibility alias for `query` |
|
|
705
|
+
| Legacy `memory.recall()` routing | If you call `recall()` with legacy advanced-recall-style inputs (`message`, `limit`, omitted `type`, collection-name scoping), the SDK routes to `/smart-recall` automatically |
|
|
706
|
+
| Shorthand semantic `memory.search()` | `search({ query, limit, collectionName })` is accepted and routed to `/smart-recall` when no filter groups are provided |
|
|
707
|
+
| `collectionName` / `collectionNames` on `memorize()` | Collection names are resolved client-side into `collectionIds` |
|
|
708
|
+
| Legacy collection payload aliases | `collections.create()` now accepts `name`, `slug`, `description`, array `options`, and `updateSemantics` |
|
|
709
|
+
| `records` shorthand on `memorizeBatch()` | Accepts record-style input and normalizes it client-side into `memorize()` + `/batch-memorize` calls |
|
|
710
|
+
|
|
711
|
+
See [SDK_0_6_3_COMPATIBILITY_CHANGES.md](SDK_0_6_3_COMPATIBILITY_CHANGES.md) for the full design notes and tradeoffs.
|
|
712
|
+
|
|
505
713
|
## Migration from 0.5.x
|
|
506
714
|
|
|
507
715
|
**New in 0.6.0:**
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PersonizeConfig, ApiResponse, MeResponse, TestResponse, ListOptions, GuidelinesResponse, GuidelineSectionOptions, GuidelineUpdatePayload, GuidelineCreatePayload, GuidelineHistoryResponse, GuidelineHistoryOptions, CollectionsResponse, CollectionCreatePayload, CollectionUpdatePayload, CollectionHistoryOptions, CollectionHistoryResponse, SmartGuidelinesOptions, SmartGuidelinesResponse, PromptOptions, PromptResponse, AgentRunOptions, AgentResponse, MemorizeOptions, SmartRecallOptions, RecallOptions, SearchOptions, SearchResponse, BatchMemorizeOptions, SmartDigestOptions, SmartDigestResponse, EvaluateMemorizationOptions, EvaluateMemorizationResponse } from './types';
|
|
1
|
+
import { PersonizeConfig, ApiResponse, MeResponse, TestResponse, ListOptions, GuidelinesResponse, GuidelineSectionOptions, GuidelineUpdatePayload, GuidelineCreatePayload, GuidelineHistoryResponse, GuidelineHistoryOptions, CollectionsResponse, CollectionCreatePayload, CollectionUpdatePayload, CollectionHistoryOptions, CollectionHistoryResponse, SmartGuidelinesOptions, SmartGuidelinesResponse, PromptOptions, PromptResponse, PromptStreamOptions, PromptSSEEvent, AgentRunOptions, AgentResponse, MemorizeOptions, SmartRecallOptions, RecallOptions, RecallResponse, SearchOptions, SearchResponse, BatchMemorizeOptions, SmartDigestOptions, SmartDigestResponse, EvaluateMemorizationOptions, EvaluateMemorizationResponse, UpdatePropertyOptions, UpdateResult, BulkUpdateOptions, BulkUpdateResult, PropertyHistoryOptions, PropertyHistoryResult, QueryPropertiesOptions, QueryPropertiesResult, DeleteMemoriesOptions, DeleteRecordOptions, DeletionResult, CancelDeletionOptions, CancelDeletionResult, FilterByPropertyOptions, FilterByPropertyResult, GetPropertiesOptions, GetPropertiesResponse } from './types';
|
|
2
2
|
export declare class Personize {
|
|
3
3
|
private client;
|
|
4
4
|
private _organizationId?;
|
|
@@ -8,6 +8,26 @@ export declare class Personize {
|
|
|
8
8
|
constructor(config: PersonizeConfig);
|
|
9
9
|
private resolveIdentity;
|
|
10
10
|
private getOrganizationId;
|
|
11
|
+
private normalizePropertyOptions;
|
|
12
|
+
private inferEntityTypeFromKeys;
|
|
13
|
+
private listAllCollections;
|
|
14
|
+
private resolveCollectionIdsByName;
|
|
15
|
+
private normalizeCollectionCreatePayload;
|
|
16
|
+
private attachArrayMetadata;
|
|
17
|
+
private normalizeGuidelinesListResponse;
|
|
18
|
+
private normalizeCollectionsListResponse;
|
|
19
|
+
private normalizePromptOptions;
|
|
20
|
+
private normalizeMemorizeOptions;
|
|
21
|
+
private normalizeSmartRecallOptions;
|
|
22
|
+
private isLegacyRecallRequest;
|
|
23
|
+
private normalizeLegacyRecallToSmartRecall;
|
|
24
|
+
private normalizeRecallOptions;
|
|
25
|
+
private buildSearchGroupsFromFilters;
|
|
26
|
+
private normalizeSearchRequest;
|
|
27
|
+
private normalizeSearchResponse;
|
|
28
|
+
private normalizeRecallResponse;
|
|
29
|
+
private isBatchRecordProperty;
|
|
30
|
+
private memorizeBatchFromRecords;
|
|
11
31
|
/**
|
|
12
32
|
* GET /api/v1/test — Verify API key is valid. Returns request metadata and resolved identity.
|
|
13
33
|
*/
|
|
@@ -85,6 +105,28 @@ export declare class Personize {
|
|
|
85
105
|
* Use `memorize` to auto-save outputs and tool results to memory.
|
|
86
106
|
*/
|
|
87
107
|
prompt: (options: PromptOptions) => Promise<ApiResponse<PromptResponse>>;
|
|
108
|
+
/**
|
|
109
|
+
* POST /api/v1/prompt (stream: true) — Stream prompt execution as Server-Sent Events.
|
|
110
|
+
*
|
|
111
|
+
* Returns an async generator that yields SSE events as they arrive:
|
|
112
|
+
* - `text`: plain text chunks from the LLM
|
|
113
|
+
* - `output`: a named output extracted when its </output> marker closes
|
|
114
|
+
* - `step_complete`: fired after each instruction step (multi-step mode)
|
|
115
|
+
* - `done`: final event with all outputs, evaluation, and metadata
|
|
116
|
+
* - `error`: non-fatal error during streaming
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```ts
|
|
120
|
+
* for await (const event of personize.ai.promptStream({
|
|
121
|
+
* prompt: 'Write a hero section',
|
|
122
|
+
* outputs: [{ name: 'headline' }, { name: 'subtitle' }],
|
|
123
|
+
* })) {
|
|
124
|
+
* if (event.type === 'output') console.log(event.name, event.data);
|
|
125
|
+
* if (event.type === 'done') console.log('Finished:', event.metadata);
|
|
126
|
+
* }
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
promptStream: (options: PromptStreamOptions) => AsyncGenerator<PromptSSEEvent>;
|
|
88
130
|
};
|
|
89
131
|
agents: {
|
|
90
132
|
/**
|
|
@@ -111,11 +153,11 @@ export declare class Personize {
|
|
|
111
153
|
* POST /api/v1/smart-recall — Advanced recall with reflection (RAG).
|
|
112
154
|
* Supports reflection loops for improved coverage, answer generation, and entity scoping.
|
|
113
155
|
*/
|
|
114
|
-
smartRecall: (data: SmartRecallOptions) => Promise<ApiResponse
|
|
156
|
+
smartRecall: (data: SmartRecallOptions) => Promise<ApiResponse<RecallResponse>>;
|
|
115
157
|
/**
|
|
116
158
|
* POST /api/v1/recall — Direct memory lookup (no reflection).
|
|
117
159
|
*/
|
|
118
|
-
recall: (data: RecallOptions) => Promise<ApiResponse
|
|
160
|
+
recall: (data: RecallOptions) => Promise<ApiResponse<RecallResponse>>;
|
|
119
161
|
/**
|
|
120
162
|
* POST /api/v1/search — Filter and search records by property conditions.
|
|
121
163
|
* Returns matching record IDs with optional property values and memories.
|
|
@@ -132,6 +174,61 @@ export declare class Personize {
|
|
|
132
174
|
* Combines DynamoDB properties + LanceDB memories into a token-budgeted markdown block.
|
|
133
175
|
*/
|
|
134
176
|
smartDigest: (data: SmartDigestOptions) => Promise<ApiResponse<SmartDigestResponse>>;
|
|
177
|
+
/**
|
|
178
|
+
* POST /api/v1/memory/update — Update a single property or freeform memory.
|
|
179
|
+
*
|
|
180
|
+
* For property updates: pass `propertyName` + `propertyValue` (or array operations).
|
|
181
|
+
* For freeform edits: pass `memoryId` + `text`.
|
|
182
|
+
* Use `expectedVersion` for optimistic concurrency (409 on mismatch).
|
|
183
|
+
*/
|
|
184
|
+
update: (data: UpdatePropertyOptions) => Promise<ApiResponse<UpdateResult>>;
|
|
185
|
+
/**
|
|
186
|
+
* POST /api/v1/memory/bulk-update — Update multiple properties on a record in one request.
|
|
187
|
+
* Use `expectedVersion` for optimistic concurrency (checked before any writes).
|
|
188
|
+
*/
|
|
189
|
+
bulkUpdate: (data: BulkUpdateOptions) => Promise<ApiResponse<BulkUpdateResult>>;
|
|
190
|
+
/**
|
|
191
|
+
* POST /api/v1/memory/delete — Soft-delete memories (30-day recovery window).
|
|
192
|
+
* Deleted items are excluded from all reads. Use `cancelDeletion` to restore.
|
|
193
|
+
*/
|
|
194
|
+
delete: (data: DeleteMemoriesOptions) => Promise<ApiResponse<DeletionResult>>;
|
|
195
|
+
/**
|
|
196
|
+
* POST /api/v1/memory/delete-record — Soft-delete all memories for a record (30-day recovery).
|
|
197
|
+
*/
|
|
198
|
+
deleteRecord: (data: DeleteRecordOptions) => Promise<ApiResponse<DeletionResult>>;
|
|
199
|
+
/**
|
|
200
|
+
* POST /api/v1/memory/cancel-deletion — Cancel a pending soft-delete within the 30-day window.
|
|
201
|
+
* Returns 409 DELETION_FINALIZED if the window has expired.
|
|
202
|
+
*/
|
|
203
|
+
cancelDeletion: (data: CancelDeletionOptions) => Promise<ApiResponse<CancelDeletionResult>>;
|
|
204
|
+
/**
|
|
205
|
+
* POST /api/v1/memory/property-history — Query property change history for a record.
|
|
206
|
+
* Supports filtering by property name, time range, and cursor-based pagination.
|
|
207
|
+
*/
|
|
208
|
+
propertyHistory: (data: PropertyHistoryOptions) => Promise<ApiResponse<PropertyHistoryResult>>;
|
|
209
|
+
/**
|
|
210
|
+
* POST /api/v1/memory/query-properties — LLM-powered search across property values.
|
|
211
|
+
* Finds records where a property value matches a natural-language query.
|
|
212
|
+
*/
|
|
213
|
+
queryProperties: (data: QueryPropertiesOptions) => Promise<ApiResponse<QueryPropertiesResult>>;
|
|
214
|
+
/**
|
|
215
|
+
* POST /api/v1/memory/filter-by-property — Deterministic property filter (no LLM, no token cost).
|
|
216
|
+
* Finds records where property values match structured conditions.
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* ```ts
|
|
220
|
+
* const result = await client.memory.filterByProperty({
|
|
221
|
+
* conditions: [{ propertyName: 'deal_stage', operator: 'equals', value: 'closed_won' }],
|
|
222
|
+
* type: 'Company',
|
|
223
|
+
* limit: 100,
|
|
224
|
+
* });
|
|
225
|
+
* ```
|
|
226
|
+
*/
|
|
227
|
+
filterByProperty: (data: FilterByPropertyOptions) => Promise<ApiResponse<FilterByPropertyResult>>;
|
|
228
|
+
/**
|
|
229
|
+
* POST /api/v1/properties — Get record properties with schema descriptions.
|
|
230
|
+
*/
|
|
231
|
+
properties: (data: GetPropertiesOptions) => Promise<ApiResponse<GetPropertiesResponse>>;
|
|
135
232
|
};
|
|
136
233
|
evaluate: {
|
|
137
234
|
/**
|