diff --git a/pyproject.toml b/pyproject.toml index 782e9a8d..b839bfc9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "zep-cloud" -version = "2.15.0" +version = "2.16.0" description = "" readme = "README.md" authors = [] diff --git a/reference.md b/reference.md index e545c0ec..d006e092 100644 --- a/reference.md +++ b/reference.md @@ -1596,6 +1596,98 @@ client.graph.add_fact_triple( + + + + +
client.graph.clone(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Clone a user or group graph. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from zep_cloud.client import Zep + +client = Zep( + api_key="YOUR_API_KEY", +) +client.graph.clone() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**source_group_id:** `typing.Optional[str]` — group_id of the group whose graph is being cloned. Required if user_id is not provided + +
+
+ +
+
+ +**source_user_id:** `typing.Optional[str]` — user_id of the user whose graph is being cloned. Required if group_id is not provided + +
+
+ +
+
+ +**target_group_id:** `typing.Optional[str]` — group_id to be set on the cloned group. Must not point to an existing group. Required if target_user_id is not provided. + +
+
+ +
+
+ +**target_user_id:** `typing.Optional[str]` — user_id to be set on the cloned user. Must not point to an existing user. Required if target_group_id is not provided. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ +
@@ -2478,7 +2570,7 @@ Fact rating instructions can not be unset.
-Classifies a session. +Deprecated: Classifies a session.
@@ -2676,7 +2768,7 @@ client.memory.end_session(
-extract data from a session by session id +Deprecated: extract data from a session by session id
diff --git a/src/zep_cloud/__init__.py b/src/zep_cloud/__init__.py index 81bcfce5..043d1216 100644 --- a/src/zep_cloud/__init__.py +++ b/src/zep_cloud/__init__.py @@ -9,6 +9,7 @@ ApidataDocumentSearchResponse, ApidataDocumentWithScore, ClassifySessionRequest, + CloneGraphResponse, CreateDocumentRequest, EdgeType, EndSessionResponse, @@ -75,6 +76,7 @@ "ApidataDocumentWithScore", "BadRequestError", "ClassifySessionRequest", + "CloneGraphResponse", "ConflictError", "CreateDocumentRequest", "EdgeType", diff --git a/src/zep_cloud/core/client_wrapper.py b/src/zep_cloud/core/client_wrapper.py index 37a4f1c3..b44462b5 100644 --- a/src/zep_cloud/core/client_wrapper.py +++ b/src/zep_cloud/core/client_wrapper.py @@ -17,7 +17,7 @@ def get_headers(self) -> typing.Dict[str, str]: headers: typing.Dict[str, str] = { "X-Fern-Language": "Python", "X-Fern-SDK-Name": "zep-cloud", - "X-Fern-SDK-Version": "2.15.0", + "X-Fern-SDK-Version": "2.16.0", } headers["Authorization"] = f"Api-Key {self.api_key}" return headers diff --git a/src/zep_cloud/external_clients/memory.py b/src/zep_cloud/external_clients/memory.py index 67196b01..d047a250 100644 --- a/src/zep_cloud/external_clients/memory.py +++ b/src/zep_cloud/external_clients/memory.py @@ -25,7 +25,7 @@ def extract( last_n: int = 4, validate: bool = False, ): - """Extracts structured data from a session based on a ZepModel schema. + """Deprecated: Extracts structured data from a session based on a ZepModel schema. This method retrieves data based on a given model and session details. It then returns the extracted and validated data as an instance of the given ZepModel. @@ -94,7 +94,7 @@ async def extract( last_n: int = 4, validate: bool = False, ): - """Extracts structured data from a session based on a ZepModel schema. + """Deprecated: Extracts structured data from a session based on a ZepModel schema. This method retrieves data based on a given model and session details. It then returns the extracted and validated data as an instance of the given ZepModel. diff --git a/src/zep_cloud/graph/client.py b/src/zep_cloud/graph/client.py index b33f1000..47641d5b 100644 --- a/src/zep_cloud/graph/client.py +++ b/src/zep_cloud/graph/client.py @@ -12,6 +12,7 @@ from ..errors.not_found_error import NotFoundError from ..types.add_triple_response import AddTripleResponse from ..types.api_error import ApiError as types_api_error_ApiError +from ..types.clone_graph_response import CloneGraphResponse from ..types.edge_type import EdgeType from ..types.entity_type import EntityType from ..types.entity_type_response import EntityTypeResponse @@ -409,6 +410,77 @@ def add_fact_triple( raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + def clone( + self, + *, + source_group_id: typing.Optional[str] = OMIT, + source_user_id: typing.Optional[str] = OMIT, + target_group_id: typing.Optional[str] = OMIT, + target_user_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None + ) -> CloneGraphResponse: + """ + Clone a user or group graph. + + Parameters + ---------- + source_group_id : typing.Optional[str] + group_id of the group whose graph is being cloned. Required if user_id is not provided + + source_user_id : typing.Optional[str] + user_id of the user whose graph is being cloned. Required if group_id is not provided + + target_group_id : typing.Optional[str] + group_id to be set on the cloned group. Must not point to an existing group. Required if target_user_id is not provided. + + target_user_id : typing.Optional[str] + user_id to be set on the cloned user. Must not point to an existing user. Required if target_group_id is not provided. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CloneGraphResponse + Response object containing group_id or user_id pointing to the new graph + + Examples + -------- + from zep_cloud.client import Zep + + client = Zep( + api_key="YOUR_API_KEY", + ) + client.graph.clone() + """ + _response = self._client_wrapper.httpx_client.request( + "graph/clone", + method="POST", + json={ + "source_group_id": source_group_id, + "source_user_id": source_user_id, + "target_group_id": target_group_id, + "target_user_id": target_user_id, + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(CloneGraphResponse, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError( + pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore + ) + if _response.status_code == 500: + raise InternalServerError( + pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) + raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + def search( self, *, @@ -941,6 +1013,85 @@ async def main() -> None: raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + async def clone( + self, + *, + source_group_id: typing.Optional[str] = OMIT, + source_user_id: typing.Optional[str] = OMIT, + target_group_id: typing.Optional[str] = OMIT, + target_user_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None + ) -> CloneGraphResponse: + """ + Clone a user or group graph. + + Parameters + ---------- + source_group_id : typing.Optional[str] + group_id of the group whose graph is being cloned. Required if user_id is not provided + + source_user_id : typing.Optional[str] + user_id of the user whose graph is being cloned. Required if group_id is not provided + + target_group_id : typing.Optional[str] + group_id to be set on the cloned group. Must not point to an existing group. Required if target_user_id is not provided. + + target_user_id : typing.Optional[str] + user_id to be set on the cloned user. Must not point to an existing user. Required if target_group_id is not provided. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CloneGraphResponse + Response object containing group_id or user_id pointing to the new graph + + Examples + -------- + import asyncio + + from zep_cloud.client import AsyncZep + + client = AsyncZep( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.graph.clone() + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "graph/clone", + method="POST", + json={ + "source_group_id": source_group_id, + "source_user_id": source_user_id, + "target_group_id": target_group_id, + "target_user_id": target_user_id, + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(CloneGraphResponse, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError( + pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore + ) + if _response.status_code == 500: + raise InternalServerError( + pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) + raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + async def search( self, *, diff --git a/src/zep_cloud/memory/client.py b/src/zep_cloud/memory/client.py index 972d84d7..cdc983b8 100644 --- a/src/zep_cloud/memory/client.py +++ b/src/zep_cloud/memory/client.py @@ -573,7 +573,7 @@ def classify_session( request_options: typing.Optional[RequestOptions] = None, ) -> SessionClassification: """ - Classifies a session. + Deprecated: Classifies a session. Parameters ---------- @@ -716,7 +716,7 @@ def extract_data( request_options: typing.Optional[RequestOptions] = None, ) -> typing.Dict[str, str]: """ - extract data from a session by session id + Deprecated: extract data from a session by session id Parameters ---------- @@ -2091,7 +2091,7 @@ async def classify_session( request_options: typing.Optional[RequestOptions] = None, ) -> SessionClassification: """ - Classifies a session. + Deprecated: Classifies a session. Parameters ---------- @@ -2250,7 +2250,7 @@ async def extract_data( request_options: typing.Optional[RequestOptions] = None, ) -> typing.Dict[str, str]: """ - extract data from a session by session id + Deprecated: extract data from a session by session id Parameters ---------- diff --git a/src/zep_cloud/types/__init__.py b/src/zep_cloud/types/__init__.py index 8f5d09d6..7c714285 100644 --- a/src/zep_cloud/types/__init__.py +++ b/src/zep_cloud/types/__init__.py @@ -8,6 +8,7 @@ from .apidata_document_search_response import ApidataDocumentSearchResponse from .apidata_document_with_score import ApidataDocumentWithScore from .classify_session_request import ClassifySessionRequest +from .clone_graph_response import CloneGraphResponse from .create_document_request import CreateDocumentRequest from .edge_type import EdgeType from .end_session_response import EndSessionResponse @@ -68,6 +69,7 @@ "ApidataDocumentSearchResponse", "ApidataDocumentWithScore", "ClassifySessionRequest", + "CloneGraphResponse", "CreateDocumentRequest", "EdgeType", "EndSessionResponse", diff --git a/src/zep_cloud/types/clone_graph_response.py b/src/zep_cloud/types/clone_graph_response.py new file mode 100644 index 00000000..7bddded6 --- /dev/null +++ b/src/zep_cloud/types/clone_graph_response.py @@ -0,0 +1,30 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 + + +class CloneGraphResponse(pydantic_v1.BaseModel): + group_id: typing.Optional[str] = None + user_id: typing.Optional[str] = None + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) + + class Config: + frozen = True + smart_union = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime}