diff --git a/pyproject.toml b/pyproject.toml index 316bf16..8e22b40 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ name = "zep-cloud" [tool.poetry] name = "zep-cloud" -version = "3.18.0" +version = "3.19.0" description = "" readme = "README.md" authors = [] diff --git a/reference.md b/reference.md index 94c80bf..aba5c59 100644 --- a/reference.md +++ b/reference.md @@ -1431,6 +1431,7 @@ client = Zep( client.graph.list_all( page_number=1, page_size=1, + search="search", order_by="order_by", asc=True, ) @@ -1465,6 +1466,14 @@ client.graph.list_all(
+**search:** `typing.Optional[str]` — Search term for filtering graphs by graph_id. + +
+
+ +
+
+ **order_by:** `typing.Optional[str]` — Column to sort by (created_at, group_id, name).
@@ -1763,7 +1772,7 @@ client.graph.search(
-**scope:** `typing.Optional[GraphSearchScope]` — Defaults to Edges. Communities will be added in the future. +**scope:** `typing.Optional[GraphSearchScope]` — Defaults to Edges.
@@ -3690,6 +3699,249 @@ client.user.warm(
+ + + + +## Graph Community +
client.graph.community.get_by_graph_id(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Returns read-only community nodes for a graph. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from zep_cloud import Zep + +client = Zep( + api_key="YOUR_API_KEY", +) +client.graph.community.get_by_graph_id( + graph_id="graph_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**graph_id:** `str` — Graph ID + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Maximum number of items to return + +
+
+ +
+
+ +**uuid_cursor:** `typing.Optional[str]` — UUID based cursor, used for pagination. Should be the UUID of the last item in the previous page + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.graph.community.get_by_user_id(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Returns read-only community nodes for a user's graph. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from zep_cloud import Zep + +client = Zep( + api_key="YOUR_API_KEY", +) +client.graph.community.get_by_user_id( + user_id="user_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**user_id:** `str` — User ID + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Maximum number of items to return + +
+
+ +
+
+ +**uuid_cursor:** `typing.Optional[str]` — UUID based cursor, used for pagination. Should be the UUID of the last item in the previous page + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.graph.community.get(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Returns a specific community node by UUID. Community nodes are read-only. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from zep_cloud import Zep + +client = Zep( + api_key="YOUR_API_KEY", +) +client.graph.community.get( + uuid_="uuid", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**uuid_:** `str` — Community UUID + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ +
diff --git a/src/zep_cloud/__init__.py b/src/zep_cloud/__init__.py index 4f8ffb7..43dd438 100644 --- a/src/zep_cloud/__init__.py +++ b/src/zep_cloud/__init__.py @@ -10,6 +10,7 @@ CloneGraphResponse, ClusterDetectConfig, CoOccurrenceDetectConfig, + CommunityNode, ComparisonOperator, ContextTemplateResponse, CustomInstruction, @@ -30,6 +31,7 @@ EpisodeResponse, GetTaskResponse, Graph, + GraphCommunitiesRequest, GraphDataType, GraphEdgesRequest, GraphListResponse, @@ -81,6 +83,7 @@ "CloneGraphResponse", "ClusterDetectConfig", "CoOccurrenceDetectConfig", + "CommunityNode", "ComparisonOperator", "ContextTemplateResponse", "CustomInstruction", @@ -102,6 +105,7 @@ "ForbiddenError", "GetTaskResponse", "Graph", + "GraphCommunitiesRequest", "GraphDataType", "GraphEdgesRequest", "GraphListResponse", diff --git a/src/zep_cloud/core/client_wrapper.py b/src/zep_cloud/core/client_wrapper.py index 0a08cd2..effb6a1 100644 --- a/src/zep_cloud/core/client_wrapper.py +++ b/src/zep_cloud/core/client_wrapper.py @@ -22,10 +22,10 @@ def __init__( def get_headers(self) -> typing.Dict[str, str]: headers: typing.Dict[str, str] = { - "User-Agent": "zep-cloud/3.18.0", + "User-Agent": "zep-cloud/3.19.0", "X-Fern-Language": "Python", "X-Fern-SDK-Name": "zep-cloud", - "X-Fern-SDK-Version": "3.18.0", + "X-Fern-SDK-Version": "3.19.0", **(self.get_custom_headers() or {}), } headers["Authorization"] = f"Api-Key {self.api_key}" diff --git a/src/zep_cloud/graph/__init__.py b/src/zep_cloud/graph/__init__.py index 6a0c51b..dc37848 100644 --- a/src/zep_cloud/graph/__init__.py +++ b/src/zep_cloud/graph/__init__.py @@ -2,6 +2,6 @@ # isort: skip_file -from . import edge, episode, node +from . import community, edge, episode, node -__all__ = ["edge", "episode", "node"] +__all__ = ["community", "edge", "episode", "node"] diff --git a/src/zep_cloud/graph/client.py b/src/zep_cloud/graph/client.py index f686275..28480b5 100644 --- a/src/zep_cloud/graph/client.py +++ b/src/zep_cloud/graph/client.py @@ -25,6 +25,7 @@ from ..types.reranker import Reranker from ..types.search_filters import SearchFilters from ..types.success_response import SuccessResponse +from .community.client import AsyncCommunityClient, CommunityClient from .edge.client import AsyncEdgeClient, EdgeClient from .episode.client import AsyncEpisodeClient, EpisodeClient from .node.client import AsyncNodeClient, NodeClient @@ -37,6 +38,8 @@ class GraphClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._raw_client = RawGraphClient(client_wrapper=client_wrapper) + self.community = CommunityClient(client_wrapper=client_wrapper) + self.edge = EdgeClient(client_wrapper=client_wrapper) self.episode = EpisodeClient(client_wrapper=client_wrapper) @@ -630,6 +633,7 @@ def list_all( *, page_number: typing.Optional[int] = None, page_size: typing.Optional[int] = None, + search: typing.Optional[str] = None, order_by: typing.Optional[str] = None, asc: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None, @@ -645,6 +649,9 @@ def list_all( page_size : typing.Optional[int] Number of graphs to retrieve per page. + search : typing.Optional[str] + Search term for filtering graphs by graph_id. + order_by : typing.Optional[str] Column to sort by (created_at, group_id, name). @@ -669,12 +676,18 @@ def list_all( client.graph.list_all( page_number=1, page_size=1, + search="search", order_by="order_by", asc=True, ) """ _response = self._raw_client.list_all( - page_number=page_number, page_size=page_size, order_by=order_by, asc=asc, request_options=request_options + page_number=page_number, + page_size=page_size, + search=search, + order_by=order_by, + asc=asc, + request_options=request_options, ) return _response.data @@ -815,7 +828,7 @@ def search( Defaults to RRF scope : typing.Optional[GraphSearchScope] - Defaults to Edges. Communities will be added in the future. + Defaults to Edges. search_filters : typing.Optional[SearchFilters] Search filters to apply to the search @@ -967,6 +980,8 @@ def update( class AsyncGraphClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._raw_client = AsyncRawGraphClient(client_wrapper=client_wrapper) + self.community = AsyncCommunityClient(client_wrapper=client_wrapper) + self.edge = AsyncEdgeClient(client_wrapper=client_wrapper) self.episode = AsyncEpisodeClient(client_wrapper=client_wrapper) @@ -1640,6 +1655,7 @@ async def list_all( *, page_number: typing.Optional[int] = None, page_size: typing.Optional[int] = None, + search: typing.Optional[str] = None, order_by: typing.Optional[str] = None, asc: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None, @@ -1655,6 +1671,9 @@ async def list_all( page_size : typing.Optional[int] Number of graphs to retrieve per page. + search : typing.Optional[str] + Search term for filtering graphs by graph_id. + order_by : typing.Optional[str] Column to sort by (created_at, group_id, name). @@ -1684,6 +1703,7 @@ async def main() -> None: await client.graph.list_all( page_number=1, page_size=1, + search="search", order_by="order_by", asc=True, ) @@ -1692,7 +1712,12 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._raw_client.list_all( - page_number=page_number, page_size=page_size, order_by=order_by, asc=asc, request_options=request_options + page_number=page_number, + page_size=page_size, + search=search, + order_by=order_by, + asc=asc, + request_options=request_options, ) return _response.data @@ -1841,7 +1866,7 @@ async def search( Defaults to RRF scope : typing.Optional[GraphSearchScope] - Defaults to Edges. Communities will be added in the future. + Defaults to Edges. search_filters : typing.Optional[SearchFilters] Search filters to apply to the search diff --git a/src/zep_cloud/graph/community/__init__.py b/src/zep_cloud/graph/community/__init__.py new file mode 100644 index 0000000..5cde020 --- /dev/null +++ b/src/zep_cloud/graph/community/__init__.py @@ -0,0 +1,4 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + diff --git a/src/zep_cloud/graph/community/client.py b/src/zep_cloud/graph/community/client.py new file mode 100644 index 0000000..73e46d3 --- /dev/null +++ b/src/zep_cloud/graph/community/client.py @@ -0,0 +1,313 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.request_options import RequestOptions +from ...types.community_node import CommunityNode +from .raw_client import AsyncRawCommunityClient, RawCommunityClient + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class CommunityClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawCommunityClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawCommunityClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawCommunityClient + """ + return self._raw_client + + def get_by_graph_id( + self, + graph_id: str, + *, + limit: typing.Optional[int] = OMIT, + uuid_cursor: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.List[CommunityNode]: + """ + Returns read-only community nodes for a graph. + + Parameters + ---------- + graph_id : str + Graph ID + + limit : typing.Optional[int] + Maximum number of items to return + + uuid_cursor : typing.Optional[str] + UUID based cursor, used for pagination. Should be the UUID of the last item in the previous page + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.List[CommunityNode] + Communities + + Examples + -------- + from zep_cloud import Zep + + client = Zep( + api_key="YOUR_API_KEY", + ) + client.graph.community.get_by_graph_id( + graph_id="graph_id", + ) + """ + _response = self._raw_client.get_by_graph_id( + graph_id, limit=limit, uuid_cursor=uuid_cursor, request_options=request_options + ) + return _response.data + + def get_by_user_id( + self, + user_id: str, + *, + limit: typing.Optional[int] = OMIT, + uuid_cursor: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.List[CommunityNode]: + """ + Returns read-only community nodes for a user's graph. + + Parameters + ---------- + user_id : str + User ID + + limit : typing.Optional[int] + Maximum number of items to return + + uuid_cursor : typing.Optional[str] + UUID based cursor, used for pagination. Should be the UUID of the last item in the previous page + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.List[CommunityNode] + Communities + + Examples + -------- + from zep_cloud import Zep + + client = Zep( + api_key="YOUR_API_KEY", + ) + client.graph.community.get_by_user_id( + user_id="user_id", + ) + """ + _response = self._raw_client.get_by_user_id( + user_id, limit=limit, uuid_cursor=uuid_cursor, request_options=request_options + ) + return _response.data + + def get(self, uuid_: str, *, request_options: typing.Optional[RequestOptions] = None) -> CommunityNode: + """ + Returns a specific community node by UUID. Community nodes are read-only. + + Parameters + ---------- + uuid_ : str + Community UUID + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CommunityNode + Community + + Examples + -------- + from zep_cloud import Zep + + client = Zep( + api_key="YOUR_API_KEY", + ) + client.graph.community.get( + uuid_="uuid", + ) + """ + _response = self._raw_client.get(uuid_, request_options=request_options) + return _response.data + + +class AsyncCommunityClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawCommunityClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawCommunityClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawCommunityClient + """ + return self._raw_client + + async def get_by_graph_id( + self, + graph_id: str, + *, + limit: typing.Optional[int] = OMIT, + uuid_cursor: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.List[CommunityNode]: + """ + Returns read-only community nodes for a graph. + + Parameters + ---------- + graph_id : str + Graph ID + + limit : typing.Optional[int] + Maximum number of items to return + + uuid_cursor : typing.Optional[str] + UUID based cursor, used for pagination. Should be the UUID of the last item in the previous page + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.List[CommunityNode] + Communities + + Examples + -------- + import asyncio + + from zep_cloud import AsyncZep + + client = AsyncZep( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.graph.community.get_by_graph_id( + graph_id="graph_id", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.get_by_graph_id( + graph_id, limit=limit, uuid_cursor=uuid_cursor, request_options=request_options + ) + return _response.data + + async def get_by_user_id( + self, + user_id: str, + *, + limit: typing.Optional[int] = OMIT, + uuid_cursor: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.List[CommunityNode]: + """ + Returns read-only community nodes for a user's graph. + + Parameters + ---------- + user_id : str + User ID + + limit : typing.Optional[int] + Maximum number of items to return + + uuid_cursor : typing.Optional[str] + UUID based cursor, used for pagination. Should be the UUID of the last item in the previous page + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.List[CommunityNode] + Communities + + Examples + -------- + import asyncio + + from zep_cloud import AsyncZep + + client = AsyncZep( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.graph.community.get_by_user_id( + user_id="user_id", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.get_by_user_id( + user_id, limit=limit, uuid_cursor=uuid_cursor, request_options=request_options + ) + return _response.data + + async def get(self, uuid_: str, *, request_options: typing.Optional[RequestOptions] = None) -> CommunityNode: + """ + Returns a specific community node by UUID. Community nodes are read-only. + + Parameters + ---------- + uuid_ : str + Community UUID + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CommunityNode + Community + + Examples + -------- + import asyncio + + from zep_cloud import AsyncZep + + client = AsyncZep( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.graph.community.get( + uuid_="uuid", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.get(uuid_, request_options=request_options) + return _response.data diff --git a/src/zep_cloud/graph/community/raw_client.py b/src/zep_cloud/graph/community/raw_client.py new file mode 100644 index 0000000..1ec6251 --- /dev/null +++ b/src/zep_cloud/graph/community/raw_client.py @@ -0,0 +1,561 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ...core.api_error import ApiError as core_api_error_ApiError +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.http_response import AsyncHttpResponse, HttpResponse +from ...core.jsonable_encoder import jsonable_encoder +from ...core.pydantic_utilities import parse_obj_as +from ...core.request_options import RequestOptions +from ...errors.bad_request_error import BadRequestError +from ...errors.internal_server_error import InternalServerError +from ...errors.not_found_error import NotFoundError +from ...types.api_error import ApiError as types_api_error_ApiError +from ...types.community_node import CommunityNode + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawCommunityClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get_by_graph_id( + self, + graph_id: str, + *, + limit: typing.Optional[int] = OMIT, + uuid_cursor: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[typing.List[CommunityNode]]: + """ + Returns read-only community nodes for a graph. + + Parameters + ---------- + graph_id : str + Graph ID + + limit : typing.Optional[int] + Maximum number of items to return + + uuid_cursor : typing.Optional[str] + UUID based cursor, used for pagination. Should be the UUID of the last item in the previous page + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[typing.List[CommunityNode]] + Communities + """ + _response = self._client_wrapper.httpx_client.request( + f"graph/community/graph/{jsonable_encoder(graph_id)}", + method="POST", + json={ + "limit": limit, + "uuid_cursor": uuid_cursor, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + typing.List[CommunityNode], + parse_obj_as( + type_=typing.List[CommunityNode], # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def get_by_user_id( + self, + user_id: str, + *, + limit: typing.Optional[int] = OMIT, + uuid_cursor: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[typing.List[CommunityNode]]: + """ + Returns read-only community nodes for a user's graph. + + Parameters + ---------- + user_id : str + User ID + + limit : typing.Optional[int] + Maximum number of items to return + + uuid_cursor : typing.Optional[str] + UUID based cursor, used for pagination. Should be the UUID of the last item in the previous page + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[typing.List[CommunityNode]] + Communities + """ + _response = self._client_wrapper.httpx_client.request( + f"graph/community/user/{jsonable_encoder(user_id)}", + method="POST", + json={ + "limit": limit, + "uuid_cursor": uuid_cursor, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + typing.List[CommunityNode], + parse_obj_as( + type_=typing.List[CommunityNode], # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def get( + self, uuid_: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[CommunityNode]: + """ + Returns a specific community node by UUID. Community nodes are read-only. + + Parameters + ---------- + uuid_ : str + Community UUID + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[CommunityNode] + Community + """ + _response = self._client_wrapper.httpx_client.request( + f"graph/community/{jsonable_encoder(uuid_)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + CommunityNode, + parse_obj_as( + type_=CommunityNode, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + +class AsyncRawCommunityClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get_by_graph_id( + self, + graph_id: str, + *, + limit: typing.Optional[int] = OMIT, + uuid_cursor: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[typing.List[CommunityNode]]: + """ + Returns read-only community nodes for a graph. + + Parameters + ---------- + graph_id : str + Graph ID + + limit : typing.Optional[int] + Maximum number of items to return + + uuid_cursor : typing.Optional[str] + UUID based cursor, used for pagination. Should be the UUID of the last item in the previous page + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[typing.List[CommunityNode]] + Communities + """ + _response = await self._client_wrapper.httpx_client.request( + f"graph/community/graph/{jsonable_encoder(graph_id)}", + method="POST", + json={ + "limit": limit, + "uuid_cursor": uuid_cursor, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + typing.List[CommunityNode], + parse_obj_as( + type_=typing.List[CommunityNode], # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def get_by_user_id( + self, + user_id: str, + *, + limit: typing.Optional[int] = OMIT, + uuid_cursor: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[typing.List[CommunityNode]]: + """ + Returns read-only community nodes for a user's graph. + + Parameters + ---------- + user_id : str + User ID + + limit : typing.Optional[int] + Maximum number of items to return + + uuid_cursor : typing.Optional[str] + UUID based cursor, used for pagination. Should be the UUID of the last item in the previous page + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[typing.List[CommunityNode]] + Communities + """ + _response = await self._client_wrapper.httpx_client.request( + f"graph/community/user/{jsonable_encoder(user_id)}", + method="POST", + json={ + "limit": limit, + "uuid_cursor": uuid_cursor, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + typing.List[CommunityNode], + parse_obj_as( + type_=typing.List[CommunityNode], # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def get( + self, uuid_: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[CommunityNode]: + """ + Returns a specific community node by UUID. Community nodes are read-only. + + Parameters + ---------- + uuid_ : str + Community UUID + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[CommunityNode] + Community + """ + _response = await self._client_wrapper.httpx_client.request( + f"graph/community/{jsonable_encoder(uuid_)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + CommunityNode, + parse_obj_as( + type_=CommunityNode, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) diff --git a/src/zep_cloud/graph/raw_client.py b/src/zep_cloud/graph/raw_client.py index 63e19b5..e2e6ed1 100644 --- a/src/zep_cloud/graph/raw_client.py +++ b/src/zep_cloud/graph/raw_client.py @@ -1044,6 +1044,7 @@ def list_all( *, page_number: typing.Optional[int] = None, page_size: typing.Optional[int] = None, + search: typing.Optional[str] = None, order_by: typing.Optional[str] = None, asc: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None, @@ -1059,6 +1060,9 @@ def list_all( page_size : typing.Optional[int] Number of graphs to retrieve per page. + search : typing.Optional[str] + Search term for filtering graphs by graph_id. + order_by : typing.Optional[str] Column to sort by (created_at, group_id, name). @@ -1079,6 +1083,7 @@ def list_all( params={ "pageNumber": page_number, "pageSize": page_size, + "search": search, "order_by": order_by, "asc": asc, }, @@ -1328,7 +1333,7 @@ def search( Defaults to RRF scope : typing.Optional[GraphSearchScope] - Defaults to Edges. Communities will be added in the future. + Defaults to Edges. search_filters : typing.Optional[SearchFilters] Search filters to apply to the search @@ -2644,6 +2649,7 @@ async def list_all( *, page_number: typing.Optional[int] = None, page_size: typing.Optional[int] = None, + search: typing.Optional[str] = None, order_by: typing.Optional[str] = None, asc: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None, @@ -2659,6 +2665,9 @@ async def list_all( page_size : typing.Optional[int] Number of graphs to retrieve per page. + search : typing.Optional[str] + Search term for filtering graphs by graph_id. + order_by : typing.Optional[str] Column to sort by (created_at, group_id, name). @@ -2679,6 +2688,7 @@ async def list_all( params={ "pageNumber": page_number, "pageSize": page_size, + "search": search, "order_by": order_by, "asc": asc, }, @@ -2928,7 +2938,7 @@ async def search( Defaults to RRF scope : typing.Optional[GraphSearchScope] - Defaults to Edges. Communities will be added in the future. + Defaults to Edges. search_filters : typing.Optional[SearchFilters] Search filters to apply to the search diff --git a/src/zep_cloud/types/__init__.py b/src/zep_cloud/types/__init__.py index 33ff8ca..19acdf1 100644 --- a/src/zep_cloud/types/__init__.py +++ b/src/zep_cloud/types/__init__.py @@ -9,6 +9,7 @@ from .clone_graph_response import CloneGraphResponse from .cluster_detect_config import ClusterDetectConfig from .co_occurrence_detect_config import CoOccurrenceDetectConfig +from .community_node import CommunityNode from .comparison_operator import ComparisonOperator from .context_template_response import ContextTemplateResponse from .custom_instruction import CustomInstruction @@ -29,6 +30,7 @@ from .episode_response import EpisodeResponse from .get_task_response import GetTaskResponse from .graph import Graph +from .graph_communities_request import GraphCommunitiesRequest from .graph_data_type import GraphDataType from .graph_edges_request import GraphEdgesRequest from .graph_list_response import GraphListResponse @@ -72,6 +74,7 @@ "CloneGraphResponse", "ClusterDetectConfig", "CoOccurrenceDetectConfig", + "CommunityNode", "ComparisonOperator", "ContextTemplateResponse", "CustomInstruction", @@ -92,6 +95,7 @@ "EpisodeResponse", "GetTaskResponse", "Graph", + "GraphCommunitiesRequest", "GraphDataType", "GraphEdgesRequest", "GraphListResponse", diff --git a/src/zep_cloud/types/community_node.py b/src/zep_cloud/types/community_node.py new file mode 100644 index 0000000..92fd643 --- /dev/null +++ b/src/zep_cloud/types/community_node.py @@ -0,0 +1,60 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +import typing_extensions +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from ..core.serialization import FieldMetadata + + +class CommunityNode(UniversalBaseModel): + attributes: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None) + """ + Additional attributes of the community node. + """ + + created_at: str = pydantic.Field() + """ + Creation time of the node + """ + + labels: typing.Optional[typing.List[str]] = pydantic.Field(default=None) + """ + Labels associated with the node + """ + + name: str = pydantic.Field() + """ + Name of the node + """ + + relevance: typing.Optional[float] = pydantic.Field(default=None) + """ + Relevance is an experimental rank-aligned score in [0,1] derived from Score via logit transformation. + Only populated when using cross_encoder reranker; omitted for other reranker types (e.g., RRF). + """ + + score: typing.Optional[float] = pydantic.Field(default=None) + """ + Score is the reranker output: sigmoid-distributed logits [0,1] when using cross_encoder reranker, or RRF ordinal rank when using rrf reranker + """ + + summary: typing.Optional[str] = pydantic.Field(default=None) + """ + Region summary of member nodes + """ + + uuid_: typing_extensions.Annotated[str, FieldMetadata(alias="uuid")] = pydantic.Field() + """ + UUID of the node + """ + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/zep_cloud/types/graph_communities_request.py b/src/zep_cloud/types/graph_communities_request.py new file mode 100644 index 0000000..0000269 --- /dev/null +++ b/src/zep_cloud/types/graph_communities_request.py @@ -0,0 +1,27 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel + + +class GraphCommunitiesRequest(UniversalBaseModel): + limit: typing.Optional[int] = pydantic.Field(default=None) + """ + Maximum number of items to return + """ + + uuid_cursor: typing.Optional[str] = pydantic.Field(default=None) + """ + UUID based cursor, used for pagination. Should be the UUID of the last item in the previous page + """ + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/zep_cloud/types/graph_search_results.py b/src/zep_cloud/types/graph_search_results.py index 8b73e52..d1ac3b4 100644 --- a/src/zep_cloud/types/graph_search_results.py +++ b/src/zep_cloud/types/graph_search_results.py @@ -4,12 +4,14 @@ import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .community_node import CommunityNode from .entity_edge import EntityEdge from .entity_node import EntityNode from .episode import Episode class GraphSearchResults(UniversalBaseModel): + communities: typing.Optional[typing.List[CommunityNode]] = None edges: typing.Optional[typing.List[EntityEdge]] = None episodes: typing.Optional[typing.List[Episode]] = None nodes: typing.Optional[typing.List[EntityNode]] = None diff --git a/src/zep_cloud/types/graph_search_scope.py b/src/zep_cloud/types/graph_search_scope.py index 07edf5d..a2d69b9 100644 --- a/src/zep_cloud/types/graph_search_scope.py +++ b/src/zep_cloud/types/graph_search_scope.py @@ -2,4 +2,4 @@ import typing -GraphSearchScope = typing.Union[typing.Literal["edges", "nodes", "episodes"], typing.Any] +GraphSearchScope = typing.Union[typing.Literal["edges", "nodes", "episodes", "communities"], typing.Any]