@personize/sdk 0.7.0 → 0.7.2
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/dist/client.d.ts +13 -1
- package/dist/client.js +18 -0
- package/dist/types.d.ts +203 -0
- package/package.json +1 -1
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, 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, ResponsesCreateOptions, ResponsesCompletedResult, ChatCompletionsOptions, ChatCompletionResult } 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, ResponsesCreateOptions, ResponsesCompletedResult, ChatCompletionsOptions, ChatCompletionResult, SimilarOptions, SimilarResponse, SegmentOptions, SegmentResponse } from './types';
|
|
2
2
|
export declare class Personize {
|
|
3
3
|
private client;
|
|
4
4
|
private _organizationId?;
|
|
@@ -229,6 +229,18 @@ export declare class Personize {
|
|
|
229
229
|
* POST /api/v1/properties — Get record properties with schema descriptions.
|
|
230
230
|
*/
|
|
231
231
|
properties: (data: GetPropertiesOptions) => Promise<ApiResponse<GetPropertiesResponse>>;
|
|
232
|
+
/**
|
|
233
|
+
* POST /api/v1/similar -- Find records similar to a seed record.
|
|
234
|
+
* Returns ranked results with similarity tiers.
|
|
235
|
+
* @see https://docs.personize.ai/api#similar
|
|
236
|
+
*/
|
|
237
|
+
similar: (data: SimilarOptions) => Promise<ApiResponse<SimilarResponse>>;
|
|
238
|
+
/**
|
|
239
|
+
* POST /api/v1/segment -- Bucket all records into similarity tiers.
|
|
240
|
+
* Supports record-based or text-based seeds.
|
|
241
|
+
* @see https://docs.personize.ai/api#segment
|
|
242
|
+
*/
|
|
243
|
+
segment: (data: SegmentOptions) => Promise<ApiResponse<SegmentResponse>>;
|
|
232
244
|
};
|
|
233
245
|
evaluate: {
|
|
234
246
|
/**
|
package/dist/client.js
CHANGED
|
@@ -456,6 +456,24 @@ class Personize {
|
|
|
456
456
|
});
|
|
457
457
|
return response.data;
|
|
458
458
|
},
|
|
459
|
+
/**
|
|
460
|
+
* POST /api/v1/similar -- Find records similar to a seed record.
|
|
461
|
+
* Returns ranked results with similarity tiers.
|
|
462
|
+
* @see https://docs.personize.ai/api#similar
|
|
463
|
+
*/
|
|
464
|
+
similar: async (data) => {
|
|
465
|
+
const response = await this.client.post('/api/v1/similar', data);
|
|
466
|
+
return response.data;
|
|
467
|
+
},
|
|
468
|
+
/**
|
|
469
|
+
* POST /api/v1/segment -- Bucket all records into similarity tiers.
|
|
470
|
+
* Supports record-based or text-based seeds.
|
|
471
|
+
* @see https://docs.personize.ai/api#segment
|
|
472
|
+
*/
|
|
473
|
+
segment: async (data) => {
|
|
474
|
+
const response = await this.client.post('/api/v1/segment', data);
|
|
475
|
+
return response.data;
|
|
476
|
+
},
|
|
459
477
|
};
|
|
460
478
|
this.evaluate = {
|
|
461
479
|
/**
|
package/dist/types.d.ts
CHANGED
|
@@ -760,6 +760,10 @@ export interface SmartRecallOptions {
|
|
|
760
760
|
recency_half_life_days?: number;
|
|
761
761
|
/** Metadata filters for narrowing results. */
|
|
762
762
|
filters?: Record<string, unknown>;
|
|
763
|
+
/** Group results by record. Returns recordGroups array alongside flat results. */
|
|
764
|
+
groupByRecord?: boolean;
|
|
765
|
+
/** Alias for groupByRecord. */
|
|
766
|
+
group_by_record?: boolean;
|
|
763
767
|
}
|
|
764
768
|
/** @deprecated Use SmartRecallOptions instead. */
|
|
765
769
|
export type RecallProOptions = SmartRecallOptions;
|
|
@@ -802,6 +806,10 @@ export interface RecallOptions {
|
|
|
802
806
|
collectionName?: string;
|
|
803
807
|
/** Compatibility alias for collection scoping by name. */
|
|
804
808
|
collectionNames?: string[];
|
|
809
|
+
/** Group results by record. Returns recordGroups array alongside flat results. */
|
|
810
|
+
groupByRecord?: boolean;
|
|
811
|
+
/** Alias for groupByRecord. */
|
|
812
|
+
group_by_record?: boolean;
|
|
805
813
|
}
|
|
806
814
|
export interface RecallResultItem {
|
|
807
815
|
content?: string;
|
|
@@ -973,6 +981,10 @@ export interface SmartDigestOptions {
|
|
|
973
981
|
deviceId?: string;
|
|
974
982
|
/** Content ID for entity scoping. */
|
|
975
983
|
contentId?: string;
|
|
984
|
+
/** Custom key name for custom entity types (e.g. 'linkedin_url', 'studentNumber'). */
|
|
985
|
+
customKeyName?: string;
|
|
986
|
+
/** Custom key value. Used with customKeyName to scope to a custom-keyed record. */
|
|
987
|
+
customKeyValue?: string;
|
|
976
988
|
}
|
|
977
989
|
export interface SmartDigestResponse {
|
|
978
990
|
success: boolean;
|
|
@@ -1050,6 +1062,27 @@ export interface MemoryItem {
|
|
|
1050
1062
|
score?: number;
|
|
1051
1063
|
metadata?: Record<string, PropertyValue>;
|
|
1052
1064
|
}
|
|
1065
|
+
/** CRM identifier keys for a record, returned in search responses. */
|
|
1066
|
+
export interface RecordCrmKeys {
|
|
1067
|
+
type?: string;
|
|
1068
|
+
email?: string;
|
|
1069
|
+
websiteUrl?: string;
|
|
1070
|
+
phoneNumber?: string;
|
|
1071
|
+
postalCode?: string;
|
|
1072
|
+
deviceId?: string;
|
|
1073
|
+
contentId?: string;
|
|
1074
|
+
customKeyName?: string;
|
|
1075
|
+
customKeyValue?: string;
|
|
1076
|
+
}
|
|
1077
|
+
/** AI extraction metadata aggregated per record, returned in search responses. */
|
|
1078
|
+
export interface RecordIndexMeta {
|
|
1079
|
+
entities?: string[];
|
|
1080
|
+
keywords?: string[];
|
|
1081
|
+
persons?: string[];
|
|
1082
|
+
topics?: string[];
|
|
1083
|
+
locations?: string[];
|
|
1084
|
+
sources?: string[];
|
|
1085
|
+
}
|
|
1053
1086
|
export interface SearchResultItem {
|
|
1054
1087
|
recordId?: string;
|
|
1055
1088
|
mainProperties?: Record<string, string>;
|
|
@@ -1091,6 +1124,10 @@ export interface SearchResponse extends Array<SearchResultItem> {
|
|
|
1091
1124
|
memories?: Record<string, MemoryItem[]>;
|
|
1092
1125
|
/** Compatibility flattened result list derived client-side when possible. */
|
|
1093
1126
|
results?: SearchResultItem[];
|
|
1127
|
+
/** CRM keys per record (email, phone, website, etc.). */
|
|
1128
|
+
crmKeys?: Record<string, RecordCrmKeys>;
|
|
1129
|
+
/** AI extraction metadata per record (entities, keywords, persons, etc.). */
|
|
1130
|
+
indexMeta?: Record<string, RecordIndexMeta>;
|
|
1094
1131
|
}
|
|
1095
1132
|
/** @deprecated Use SearchResponse instead. */
|
|
1096
1133
|
export type ExportResponse = SearchResponse;
|
|
@@ -1553,3 +1590,169 @@ export interface ChatCompletionResult {
|
|
|
1553
1590
|
byok?: boolean;
|
|
1554
1591
|
};
|
|
1555
1592
|
}
|
|
1593
|
+
/** Options for POST /api/v1/similar -- find records similar to a seed record. */
|
|
1594
|
+
export interface SimilarOptions {
|
|
1595
|
+
/** Seed record identifier. Provide exactly one: recordId, email, websiteUrl, or customKey. */
|
|
1596
|
+
seed: {
|
|
1597
|
+
recordId?: string;
|
|
1598
|
+
email?: string;
|
|
1599
|
+
websiteUrl?: string;
|
|
1600
|
+
customKeyName?: string;
|
|
1601
|
+
customKeyValue?: string;
|
|
1602
|
+
};
|
|
1603
|
+
/** Seed entity type. Inferred from seed key if omitted (email -> contact, websiteUrl -> company). */
|
|
1604
|
+
type?: string;
|
|
1605
|
+
/** What dimensions drive similarity. Default: 'hybrid'. */
|
|
1606
|
+
dimensions?: 'properties' | 'memories' | 'hybrid' | 'connections';
|
|
1607
|
+
/** Fine-tune which properties/connections matter. */
|
|
1608
|
+
dimensionFilters?: {
|
|
1609
|
+
propertyNames?: string[];
|
|
1610
|
+
collectionIds?: string[];
|
|
1611
|
+
systemNames?: string[];
|
|
1612
|
+
keywords?: string[];
|
|
1613
|
+
entities?: string[];
|
|
1614
|
+
};
|
|
1615
|
+
/** Scoring mode. Default: 'balanced'. */
|
|
1616
|
+
rankingMode?: 'balanced' | 'weighted';
|
|
1617
|
+
/** Dimension weights. Only used with rankingMode: 'weighted'. */
|
|
1618
|
+
weights?: {
|
|
1619
|
+
properties?: number;
|
|
1620
|
+
memories?: number;
|
|
1621
|
+
};
|
|
1622
|
+
/** Scope search to specific candidates. */
|
|
1623
|
+
candidatePool?: {
|
|
1624
|
+
recordIds?: string[];
|
|
1625
|
+
type?: string;
|
|
1626
|
+
collectionIds?: string[];
|
|
1627
|
+
};
|
|
1628
|
+
/** Max results per page (default: 25, max: 500). */
|
|
1629
|
+
topK?: number;
|
|
1630
|
+
/** Pagination offset (default: 0). */
|
|
1631
|
+
offset?: number;
|
|
1632
|
+
/** Min similarity threshold (default: 0.3). */
|
|
1633
|
+
minScore?: number;
|
|
1634
|
+
/** Include tier arrays in response (default: true). */
|
|
1635
|
+
includeTiers?: boolean;
|
|
1636
|
+
/** Override tier thresholds. */
|
|
1637
|
+
tierThresholds?: {
|
|
1638
|
+
very_similar?: number;
|
|
1639
|
+
similar?: number;
|
|
1640
|
+
};
|
|
1641
|
+
/** Max matched snippets per result (default: 3, max: 5). */
|
|
1642
|
+
maxSnippetsPerResult?: number;
|
|
1643
|
+
/** Batch mode: return flat list of all matching recordIds (default: false). */
|
|
1644
|
+
returnAllIds?: boolean;
|
|
1645
|
+
}
|
|
1646
|
+
export interface SimilarResult {
|
|
1647
|
+
recordId: string;
|
|
1648
|
+
type: string;
|
|
1649
|
+
score: number;
|
|
1650
|
+
tier: 'very_similar' | 'similar' | 'somewhat_similar';
|
|
1651
|
+
matchBreakdown: {
|
|
1652
|
+
propertiesScore: number | null;
|
|
1653
|
+
memoriesScore: number | null;
|
|
1654
|
+
connectionsScore: number | null;
|
|
1655
|
+
matchedProperties: {
|
|
1656
|
+
name: string;
|
|
1657
|
+
value: string;
|
|
1658
|
+
similarity: number;
|
|
1659
|
+
}[];
|
|
1660
|
+
matchedMemorySnippets: {
|
|
1661
|
+
seedSnippet: string;
|
|
1662
|
+
matchSnippet: string;
|
|
1663
|
+
score: number;
|
|
1664
|
+
}[];
|
|
1665
|
+
sharedConnections: {
|
|
1666
|
+
persons: string[];
|
|
1667
|
+
entities: string[];
|
|
1668
|
+
keywords: string[];
|
|
1669
|
+
} | null;
|
|
1670
|
+
};
|
|
1671
|
+
}
|
|
1672
|
+
export interface SimilarResponse {
|
|
1673
|
+
seed: {
|
|
1674
|
+
recordId: string;
|
|
1675
|
+
type: string;
|
|
1676
|
+
label: string;
|
|
1677
|
+
vectorsUsed: number;
|
|
1678
|
+
};
|
|
1679
|
+
results?: SimilarResult[];
|
|
1680
|
+
tiers?: Record<string, string[]>;
|
|
1681
|
+
allIds?: {
|
|
1682
|
+
recordId: string;
|
|
1683
|
+
score: number;
|
|
1684
|
+
tier: string;
|
|
1685
|
+
}[];
|
|
1686
|
+
tierSummary?: Record<string, number>;
|
|
1687
|
+
totalMatches: number;
|
|
1688
|
+
metadata: Record<string, unknown>;
|
|
1689
|
+
warning?: string;
|
|
1690
|
+
usage: {
|
|
1691
|
+
credits: number;
|
|
1692
|
+
};
|
|
1693
|
+
}
|
|
1694
|
+
/** Options for POST /api/v1/segment -- bucket records into similarity tiers. */
|
|
1695
|
+
export interface SegmentOptions {
|
|
1696
|
+
/** Seed: record identifier OR text. Text creates a text-based seed. */
|
|
1697
|
+
seed: {
|
|
1698
|
+
recordId?: string;
|
|
1699
|
+
email?: string;
|
|
1700
|
+
websiteUrl?: string;
|
|
1701
|
+
customKeyName?: string;
|
|
1702
|
+
customKeyValue?: string;
|
|
1703
|
+
/** Free-form text seed (e.g., "Enterprise SaaS CTO"). Segment only. */
|
|
1704
|
+
text?: string;
|
|
1705
|
+
};
|
|
1706
|
+
/** Entity type (default: 'contact'). */
|
|
1707
|
+
type?: string;
|
|
1708
|
+
/** What dimensions drive similarity. Default: 'hybrid'. No 'connections' for segment. */
|
|
1709
|
+
dimensions?: 'properties' | 'memories' | 'hybrid';
|
|
1710
|
+
/** Fine-tune which properties matter. */
|
|
1711
|
+
dimensionFilters?: {
|
|
1712
|
+
propertyNames?: string[];
|
|
1713
|
+
collectionIds?: string[];
|
|
1714
|
+
systemNames?: string[];
|
|
1715
|
+
};
|
|
1716
|
+
/** Scope to candidate records. */
|
|
1717
|
+
candidatePool?: {
|
|
1718
|
+
type?: string;
|
|
1719
|
+
collectionIds?: string[];
|
|
1720
|
+
};
|
|
1721
|
+
/** Override tier thresholds. */
|
|
1722
|
+
tierThresholds?: {
|
|
1723
|
+
very_similar?: number;
|
|
1724
|
+
similar?: number;
|
|
1725
|
+
};
|
|
1726
|
+
/** Min similarity threshold (default: 0.3). */
|
|
1727
|
+
minScore?: number;
|
|
1728
|
+
/** Max recordIds per tier page (default: 50, max: 500). */
|
|
1729
|
+
maxPerTier?: number;
|
|
1730
|
+
/** Skip N recordIds per tier for pagination (default: 0). */
|
|
1731
|
+
tierOffset?: number;
|
|
1732
|
+
/** Fetch only one tier. */
|
|
1733
|
+
returnTier?: 'very_similar' | 'similar' | 'somewhat_similar';
|
|
1734
|
+
}
|
|
1735
|
+
export interface SegmentTier {
|
|
1736
|
+
count: number;
|
|
1737
|
+
recordIds: string[];
|
|
1738
|
+
scoreRange: {
|
|
1739
|
+
min: number;
|
|
1740
|
+
max: number;
|
|
1741
|
+
};
|
|
1742
|
+
hasMore: boolean;
|
|
1743
|
+
approximate?: boolean;
|
|
1744
|
+
}
|
|
1745
|
+
export interface SegmentResponse {
|
|
1746
|
+
seed: {
|
|
1747
|
+
recordId: string | null;
|
|
1748
|
+
type: string;
|
|
1749
|
+
label: string;
|
|
1750
|
+
vectorsUsed: number;
|
|
1751
|
+
};
|
|
1752
|
+
tiers: Record<string, SegmentTier>;
|
|
1753
|
+
totalRecords: number;
|
|
1754
|
+
metadata: Record<string, unknown>;
|
|
1755
|
+
usage: {
|
|
1756
|
+
credits: number;
|
|
1757
|
+
};
|
|
1758
|
+
}
|