Skip to content

Commit 55273c7

Browse files
Expand pattern detection API (#306)
* chore: Fix fact ratings table * SDK regeneration * chore: Version bump * chore: Version bump * SDK regeneration * chore: Add support for user/graph ontology targets * SDK regeneration * chore: Add support for setting entity/edges on a list of users/graphs * SDK regeneration * chore: Bump version * SDK regeneration * feat: Update compose context string util to include episodes and display entity attributes * chore: Bump version * fix: tests * chore: Remove redundant timestamp conversion branch * SDK regeneration * chore: Version bump * SDK regeneration * SDK regeneration * fix: tests * chore: Version bump * SDK regeneration * chore: Simplify date parsing in string composition utility * chore: Add python date util dep * chore: Bump version * SDK regeneration * SDK regeneration * chore: Bump version * SDK regeneration * chore: Remove langchain dependency * chore: Bump version * SDK regeneration * SDK regeneration * SDK regeneration * chore: Bump version * SDK regeneration * SDK regeneration * SDK regeneration * SDK regeneration * SDK regeneration * SDK regeneration * SDK regeneration * SDK regeneration * SDK regeneration * chore: Bump version * SDK regeneration * SDK regeneration * SDK regeneration * chore: Bump version * SDK regeneration * SDK regeneration * SDK regeneration * SDK regeneration * SDK regeneration * chore: Bump version * SDK regeneration * SDK regeneration * SDK regeneration * SDK regeneration * SDK regeneration * chore: Bump version * SDK regeneration * chore: Bump version * SDK regeneration * SDK regeneration * SDK regeneration * chore: Bump version * SDK regeneration * SDK regeneration * SDK regeneration * chore: Bump version * SDK regeneration * chore: Bump version * SDK regeneration * chore: Bump version * SDK regeneration * SDK regeneration * chore: Bump version * SDK regeneration --------- Co-authored-by: fern-api <115122769+fern-api[bot]@users.noreply.github.com>
1 parent ff60f88 commit 55273c7

14 files changed

Lines changed: 287 additions & 79 deletions

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "zep-cloud"
33

44
[tool.poetry]
55
name = "zep-cloud"
6-
version = "3.17.0"
6+
version = "3.18.0"
77
description = ""
88
readme = "README.md"
99
authors = []

reference.md

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,6 +1507,8 @@ client.graph.list_all(
15071507

15081508
Detects structural patterns in a knowledge graph including relationship frequencies,
15091509
multi-hop paths, co-occurrences, hubs, and clusters.
1510+
When a query is provided, uses hybrid search to discover seed nodes,
1511+
detects triple-frequency patterns, and returns resolved edges ranked by relevance.
15101512
</dd>
15111513
</dl>
15121514
</dd>
@@ -1545,23 +1547,23 @@ client.graph.detect_patterns()
15451547
**detect:** `typing.Optional[DetectConfig]`
15461548

15471549
Which pattern types to detect with type-specific configuration.
1548-
Omit to detect all types with defaults.
1550+
Omit to detect all types with defaults. Ignored when query is set.
15491551

15501552
</dd>
15511553
</dl>
15521554

15531555
<dl>
15541556
<dd>
15551557

1556-
**graph_id:** `typing.Optional[str]`Graph ID when detecting patterns on a named graph
1558+
**edge_limit:** `typing.Optional[int]`Max resolved edges per pattern. Default: 10, Max: 100. Only used with query.
15571559

15581560
</dd>
15591561
</dl>
15601562

15611563
<dl>
15621564
<dd>
15631565

1564-
**include_examples:** `typing.Optional[bool]`Include example node/edge UUIDs per pattern. Default: false
1566+
**graph_id:** `typing.Optional[str]`Graph ID when detecting patterns on a named graph
15651567

15661568
</dd>
15671569
</dl>
@@ -1585,6 +1587,26 @@ Omit to detect all types with defaults.
15851587
<dl>
15861588
<dd>
15871589

1590+
**query:** `typing.Optional[str]`
1591+
1592+
Search query for discovering seed nodes via hybrid search.
1593+
When set, forces triple-frequency detection only and enables edge resolution
1594+
with cross-encoder reranking. Mutually exclusive with seeds.
1595+
1596+
</dd>
1597+
</dl>
1598+
1599+
<dl>
1600+
<dd>
1601+
1602+
**query_limit:** `typing.Optional[int]` — Max seed nodes from search. Default: 10, Max: 50. Only used with query.
1603+
1604+
</dd>
1605+
</dl>
1606+
1607+
<dl>
1608+
<dd>
1609+
15881610
**recency_weight:** `typing.Optional[RecencyWeight]`
15891611

15901612
Exponential half-life decay applied to edge created_at timestamps.
@@ -1607,7 +1629,7 @@ Reuses the same filter format as /graph/search.
16071629
<dl>
16081630
<dd>
16091631

1610-
**seeds:** `typing.Optional[PatternSeeds]` — Seed selection. If omitted, analyzes the entire graph.
1632+
**seeds:** `typing.Optional[PatternSeeds]` — Seed selection. If omitted, analyzes the entire graph. Mutually exclusive with query.
16111633

16121634
</dd>
16131635
</dl>

src/zep_cloud/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
Message,
4444
MessageListResponse,
4545
PathDetectConfig,
46-
PatternExample,
4746
PatternMetadata,
4847
PatternResult,
4948
PatternSeeds,
@@ -118,7 +117,6 @@
118117
"MessageListResponse",
119118
"NotFoundError",
120119
"PathDetectConfig",
121-
"PatternExample",
122120
"PatternMetadata",
123121
"PatternResult",
124122
"PatternSeeds",

src/zep_cloud/core/client_wrapper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ def __init__(
2222

2323
def get_headers(self) -> typing.Dict[str, str]:
2424
headers: typing.Dict[str, str] = {
25-
"User-Agent": "zep-cloud/3.17.0",
25+
"User-Agent": "zep-cloud/3.18.0",
2626
"X-Fern-Language": "Python",
2727
"X-Fern-SDK-Name": "zep-cloud",
28-
"X-Fern-SDK-Version": "3.17.0",
28+
"X-Fern-SDK-Version": "3.18.0",
2929
**(self.get_custom_headers() or {}),
3030
}
3131
headers["Authorization"] = f"Api-Key {self.api_key}"

src/zep_cloud/graph/client.py

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -682,10 +682,12 @@ def detect_patterns(
682682
self,
683683
*,
684684
detect: typing.Optional[DetectConfig] = OMIT,
685+
edge_limit: typing.Optional[int] = OMIT,
685686
graph_id: typing.Optional[str] = OMIT,
686-
include_examples: typing.Optional[bool] = OMIT,
687687
limit: typing.Optional[int] = OMIT,
688688
min_occurrences: typing.Optional[int] = OMIT,
689+
query: typing.Optional[str] = OMIT,
690+
query_limit: typing.Optional[int] = OMIT,
689691
recency_weight: typing.Optional[RecencyWeight] = OMIT,
690692
search_filters: typing.Optional[SearchFilters] = OMIT,
691693
seeds: typing.Optional[PatternSeeds] = OMIT,
@@ -695,25 +697,35 @@ def detect_patterns(
695697
"""
696698
Detects structural patterns in a knowledge graph including relationship frequencies,
697699
multi-hop paths, co-occurrences, hubs, and clusters.
700+
When a query is provided, uses hybrid search to discover seed nodes,
701+
detects triple-frequency patterns, and returns resolved edges ranked by relevance.
698702
699703
Parameters
700704
----------
701705
detect : typing.Optional[DetectConfig]
702706
Which pattern types to detect with type-specific configuration.
703-
Omit to detect all types with defaults.
707+
Omit to detect all types with defaults. Ignored when query is set.
708+
709+
edge_limit : typing.Optional[int]
710+
Max resolved edges per pattern. Default: 10, Max: 100. Only used with query.
704711
705712
graph_id : typing.Optional[str]
706713
Graph ID when detecting patterns on a named graph
707714
708-
include_examples : typing.Optional[bool]
709-
Include example node/edge UUIDs per pattern. Default: false
710-
711715
limit : typing.Optional[int]
712716
Max patterns to return. Default: 50, Max: 200
713717
714718
min_occurrences : typing.Optional[int]
715719
Minimum occurrence count to report a pattern. Default: 2
716720
721+
query : typing.Optional[str]
722+
Search query for discovering seed nodes via hybrid search.
723+
When set, forces triple-frequency detection only and enables edge resolution
724+
with cross-encoder reranking. Mutually exclusive with seeds.
725+
726+
query_limit : typing.Optional[int]
727+
Max seed nodes from search. Default: 10, Max: 50. Only used with query.
728+
717729
recency_weight : typing.Optional[RecencyWeight]
718730
Exponential half-life decay applied to edge created_at timestamps.
719731
Valid values: none, 7_days, 30_days, 90_days. Default: none
@@ -723,7 +735,7 @@ def detect_patterns(
723735
Reuses the same filter format as /graph/search.
724736
725737
seeds : typing.Optional[PatternSeeds]
726-
Seed selection. If omitted, analyzes the entire graph.
738+
Seed selection. If omitted, analyzes the entire graph. Mutually exclusive with query.
727739
728740
user_id : typing.Optional[str]
729741
User ID when detecting patterns on a user graph
@@ -747,10 +759,12 @@ def detect_patterns(
747759
"""
748760
_response = self._raw_client.detect_patterns(
749761
detect=detect,
762+
edge_limit=edge_limit,
750763
graph_id=graph_id,
751-
include_examples=include_examples,
752764
limit=limit,
753765
min_occurrences=min_occurrences,
766+
query=query,
767+
query_limit=query_limit,
754768
recency_weight=recency_weight,
755769
search_filters=search_filters,
756770
seeds=seeds,
@@ -1686,10 +1700,12 @@ async def detect_patterns(
16861700
self,
16871701
*,
16881702
detect: typing.Optional[DetectConfig] = OMIT,
1703+
edge_limit: typing.Optional[int] = OMIT,
16891704
graph_id: typing.Optional[str] = OMIT,
1690-
include_examples: typing.Optional[bool] = OMIT,
16911705
limit: typing.Optional[int] = OMIT,
16921706
min_occurrences: typing.Optional[int] = OMIT,
1707+
query: typing.Optional[str] = OMIT,
1708+
query_limit: typing.Optional[int] = OMIT,
16931709
recency_weight: typing.Optional[RecencyWeight] = OMIT,
16941710
search_filters: typing.Optional[SearchFilters] = OMIT,
16951711
seeds: typing.Optional[PatternSeeds] = OMIT,
@@ -1699,25 +1715,35 @@ async def detect_patterns(
16991715
"""
17001716
Detects structural patterns in a knowledge graph including relationship frequencies,
17011717
multi-hop paths, co-occurrences, hubs, and clusters.
1718+
When a query is provided, uses hybrid search to discover seed nodes,
1719+
detects triple-frequency patterns, and returns resolved edges ranked by relevance.
17021720
17031721
Parameters
17041722
----------
17051723
detect : typing.Optional[DetectConfig]
17061724
Which pattern types to detect with type-specific configuration.
1707-
Omit to detect all types with defaults.
1725+
Omit to detect all types with defaults. Ignored when query is set.
1726+
1727+
edge_limit : typing.Optional[int]
1728+
Max resolved edges per pattern. Default: 10, Max: 100. Only used with query.
17081729
17091730
graph_id : typing.Optional[str]
17101731
Graph ID when detecting patterns on a named graph
17111732
1712-
include_examples : typing.Optional[bool]
1713-
Include example node/edge UUIDs per pattern. Default: false
1714-
17151733
limit : typing.Optional[int]
17161734
Max patterns to return. Default: 50, Max: 200
17171735
17181736
min_occurrences : typing.Optional[int]
17191737
Minimum occurrence count to report a pattern. Default: 2
17201738
1739+
query : typing.Optional[str]
1740+
Search query for discovering seed nodes via hybrid search.
1741+
When set, forces triple-frequency detection only and enables edge resolution
1742+
with cross-encoder reranking. Mutually exclusive with seeds.
1743+
1744+
query_limit : typing.Optional[int]
1745+
Max seed nodes from search. Default: 10, Max: 50. Only used with query.
1746+
17211747
recency_weight : typing.Optional[RecencyWeight]
17221748
Exponential half-life decay applied to edge created_at timestamps.
17231749
Valid values: none, 7_days, 30_days, 90_days. Default: none
@@ -1727,7 +1753,7 @@ async def detect_patterns(
17271753
Reuses the same filter format as /graph/search.
17281754
17291755
seeds : typing.Optional[PatternSeeds]
1730-
Seed selection. If omitted, analyzes the entire graph.
1756+
Seed selection. If omitted, analyzes the entire graph. Mutually exclusive with query.
17311757
17321758
user_id : typing.Optional[str]
17331759
User ID when detecting patterns on a user graph
@@ -1759,10 +1785,12 @@ async def main() -> None:
17591785
"""
17601786
_response = await self._raw_client.detect_patterns(
17611787
detect=detect,
1788+
edge_limit=edge_limit,
17621789
graph_id=graph_id,
1763-
include_examples=include_examples,
17641790
limit=limit,
17651791
min_occurrences=min_occurrences,
1792+
query=query,
1793+
query_limit=query_limit,
17661794
recency_weight=recency_weight,
17671795
search_filters=search_filters,
17681796
seeds=seeds,

0 commit comments

Comments
 (0)