@personize/sdk 0.7.0 → 0.7.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/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;
@@ -1553,3 +1561,169 @@ export interface ChatCompletionResult {
1553
1561
  byok?: boolean;
1554
1562
  };
1555
1563
  }
1564
+ /** Options for POST /api/v1/similar -- find records similar to a seed record. */
1565
+ export interface SimilarOptions {
1566
+ /** Seed record identifier. Provide exactly one: recordId, email, websiteUrl, or customKey. */
1567
+ seed: {
1568
+ recordId?: string;
1569
+ email?: string;
1570
+ websiteUrl?: string;
1571
+ customKeyName?: string;
1572
+ customKeyValue?: string;
1573
+ };
1574
+ /** Seed entity type. Inferred from seed key if omitted (email -> contact, websiteUrl -> company). */
1575
+ type?: string;
1576
+ /** What dimensions drive similarity. Default: 'hybrid'. */
1577
+ dimensions?: 'properties' | 'memories' | 'hybrid' | 'connections';
1578
+ /** Fine-tune which properties/connections matter. */
1579
+ dimensionFilters?: {
1580
+ propertyNames?: string[];
1581
+ collectionIds?: string[];
1582
+ systemNames?: string[];
1583
+ keywords?: string[];
1584
+ entities?: string[];
1585
+ };
1586
+ /** Scoring mode. Default: 'balanced'. */
1587
+ rankingMode?: 'balanced' | 'weighted';
1588
+ /** Dimension weights. Only used with rankingMode: 'weighted'. */
1589
+ weights?: {
1590
+ properties?: number;
1591
+ memories?: number;
1592
+ };
1593
+ /** Scope search to specific candidates. */
1594
+ candidatePool?: {
1595
+ recordIds?: string[];
1596
+ type?: string;
1597
+ collectionIds?: string[];
1598
+ };
1599
+ /** Max results per page (default: 25, max: 500). */
1600
+ topK?: number;
1601
+ /** Pagination offset (default: 0). */
1602
+ offset?: number;
1603
+ /** Min similarity threshold (default: 0.3). */
1604
+ minScore?: number;
1605
+ /** Include tier arrays in response (default: true). */
1606
+ includeTiers?: boolean;
1607
+ /** Override tier thresholds. */
1608
+ tierThresholds?: {
1609
+ very_similar?: number;
1610
+ similar?: number;
1611
+ };
1612
+ /** Max matched snippets per result (default: 3, max: 5). */
1613
+ maxSnippetsPerResult?: number;
1614
+ /** Batch mode: return flat list of all matching recordIds (default: false). */
1615
+ returnAllIds?: boolean;
1616
+ }
1617
+ export interface SimilarResult {
1618
+ recordId: string;
1619
+ type: string;
1620
+ score: number;
1621
+ tier: 'very_similar' | 'similar' | 'somewhat_similar';
1622
+ matchBreakdown: {
1623
+ propertiesScore: number | null;
1624
+ memoriesScore: number | null;
1625
+ connectionsScore: number | null;
1626
+ matchedProperties: {
1627
+ name: string;
1628
+ value: string;
1629
+ similarity: number;
1630
+ }[];
1631
+ matchedMemorySnippets: {
1632
+ seedSnippet: string;
1633
+ matchSnippet: string;
1634
+ score: number;
1635
+ }[];
1636
+ sharedConnections: {
1637
+ persons: string[];
1638
+ entities: string[];
1639
+ keywords: string[];
1640
+ } | null;
1641
+ };
1642
+ }
1643
+ export interface SimilarResponse {
1644
+ seed: {
1645
+ recordId: string;
1646
+ type: string;
1647
+ label: string;
1648
+ vectorsUsed: number;
1649
+ };
1650
+ results?: SimilarResult[];
1651
+ tiers?: Record<string, string[]>;
1652
+ allIds?: {
1653
+ recordId: string;
1654
+ score: number;
1655
+ tier: string;
1656
+ }[];
1657
+ tierSummary?: Record<string, number>;
1658
+ totalMatches: number;
1659
+ metadata: Record<string, unknown>;
1660
+ warning?: string;
1661
+ usage: {
1662
+ credits: number;
1663
+ };
1664
+ }
1665
+ /** Options for POST /api/v1/segment -- bucket records into similarity tiers. */
1666
+ export interface SegmentOptions {
1667
+ /** Seed: record identifier OR text. Text creates a text-based seed. */
1668
+ seed: {
1669
+ recordId?: string;
1670
+ email?: string;
1671
+ websiteUrl?: string;
1672
+ customKeyName?: string;
1673
+ customKeyValue?: string;
1674
+ /** Free-form text seed (e.g., "Enterprise SaaS CTO"). Segment only. */
1675
+ text?: string;
1676
+ };
1677
+ /** Entity type (default: 'contact'). */
1678
+ type?: string;
1679
+ /** What dimensions drive similarity. Default: 'hybrid'. No 'connections' for segment. */
1680
+ dimensions?: 'properties' | 'memories' | 'hybrid';
1681
+ /** Fine-tune which properties matter. */
1682
+ dimensionFilters?: {
1683
+ propertyNames?: string[];
1684
+ collectionIds?: string[];
1685
+ systemNames?: string[];
1686
+ };
1687
+ /** Scope to candidate records. */
1688
+ candidatePool?: {
1689
+ type?: string;
1690
+ collectionIds?: string[];
1691
+ };
1692
+ /** Override tier thresholds. */
1693
+ tierThresholds?: {
1694
+ very_similar?: number;
1695
+ similar?: number;
1696
+ };
1697
+ /** Min similarity threshold (default: 0.3). */
1698
+ minScore?: number;
1699
+ /** Max recordIds per tier page (default: 50, max: 500). */
1700
+ maxPerTier?: number;
1701
+ /** Skip N recordIds per tier for pagination (default: 0). */
1702
+ tierOffset?: number;
1703
+ /** Fetch only one tier. */
1704
+ returnTier?: 'very_similar' | 'similar' | 'somewhat_similar';
1705
+ }
1706
+ export interface SegmentTier {
1707
+ count: number;
1708
+ recordIds: string[];
1709
+ scoreRange: {
1710
+ min: number;
1711
+ max: number;
1712
+ };
1713
+ hasMore: boolean;
1714
+ approximate?: boolean;
1715
+ }
1716
+ export interface SegmentResponse {
1717
+ seed: {
1718
+ recordId: string | null;
1719
+ type: string;
1720
+ label: string;
1721
+ vectorsUsed: number;
1722
+ };
1723
+ tiers: Record<string, SegmentTier>;
1724
+ totalRecords: number;
1725
+ metadata: Record<string, unknown>;
1726
+ usage: {
1727
+ credits: number;
1728
+ };
1729
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@personize/sdk",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "Official Personize SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",