From 2ae52510a31249d8585cddfd167bb96623b091e4 Mon Sep 17 00:00:00 2001 From: paulpaliychuk Date: Wed, 16 Apr 2025 15:16:59 -0400 Subject: [PATCH 01/28] chore: Fix fact ratings table --- examples/chat_history/memory.py | 15 ++- examples/graph_example/entity_types.py | 17 +-- examples/graph_example/tickets_example.py | 156 ++++++++++++++++++++++ 3 files changed, 171 insertions(+), 17 deletions(-) create mode 100644 examples/graph_example/tickets_example.py diff --git a/examples/chat_history/memory.py b/examples/chat_history/memory.py index 362b4c20..d5c3f54f 100644 --- a/examples/chat_history/memory.py +++ b/examples/chat_history/memory.py @@ -20,7 +20,7 @@ from chat_history_shoe_purchase import history from zep_cloud.client import AsyncZep -from zep_cloud.types import Message +from zep_cloud.types import Message, FactRatingInstruction, FactRatingExamples load_dotenv( dotenv_path=find_dotenv() @@ -36,7 +36,15 @@ async def main() -> None: # Create a user user_id = uuid.uuid4().hex # unique user id. can be any alphanum string - + fact_rating_instruction = """Rate the facts by poignancy. Highly poignant + facts have a significant emotional impact or relevance to the user. + Facts with low poignancy are minimally relevant or of little emotional + significance.""" + fact_rating_examples = FactRatingExamples( + high="The user received news of a family member's serious illness.", + medium="The user completed a challenging marathon.", + low="The user bought a new brand of toothpaste.", + ) await client.user.add( user_id=user_id, email="user@example.com", @@ -44,9 +52,10 @@ async def main() -> None: last_name="Smith", metadata={"vip": "true"}, ) + # await asyncio.sleep(1) print(f"User added: {user_id}") - + return session_id = uuid.uuid4().hex # unique session id. can be any alphanum string # Create session associated with the above user diff --git a/examples/graph_example/entity_types.py b/examples/graph_example/entity_types.py index 58aa41b0..9aa89e94 100644 --- a/examples/graph_example/entity_types.py +++ b/examples/graph_example/entity_types.py @@ -39,21 +39,10 @@ class Purchase(EntityModel): default=None ) await client.graph.set_entity_types( - entities={ - "Purchase": Purchase, - } + entities={} ) - search_results = await client.graph.search( - user_id="", - query="tickets for the concert", - scope="nodes", - search_filters=SearchFilters( - node_labels=["Purchase"] - ) - ) - print("search_results", search_results) - purchases = [Purchase(**purchase_node.attributes) for purchase_node in search_results.nodes] - print(purchases) + enntl = await client.graph.list_entity_types() + print(enntl) if __name__ == "__main__": diff --git a/examples/graph_example/tickets_example.py b/examples/graph_example/tickets_example.py new file mode 100644 index 00000000..2839f04c --- /dev/null +++ b/examples/graph_example/tickets_example.py @@ -0,0 +1,156 @@ +""" +Example of using Zep Graph API to create a concert ticket purchasing scenario. +This playground demonstrates user interactions with a ticket sales system, +mixing chat messages and purchase events to build a knowledge graph. +""" + +import asyncio +import os +import uuid +import json +from dotenv import find_dotenv, load_dotenv + +from zep_cloud.client import AsyncZep +from zep_cloud.types import Message + +load_dotenv(dotenv_path=find_dotenv()) + +API_KEY = os.environ.get("ZEP_API_KEY") or "YOUR_API_KEY" + +async def create_ticket_playground() -> None: + client = AsyncZep(api_key=API_KEY) + + # Create a user for the playground + user_id = uuid.uuid4().hex + await client.user.add(user_id=user_id, first_name="Sarah", last_name="Smith", email="sarah.smith@example.com") + print(f"Created playground user: {user_id}") + + + # Sample user interactions and system events + episodes = [ + { + "type": "message", + "data": "Sarah (user): Hi, I'm looking for Taylor Swift concert tickets in New York, I am a huge fan!" + }, + { + "type": "json", + "data": { + "event_type": "search_performed", + "user_id": user_id, + "artist": "Taylor Swift", + "location": "New York", + "date_range": "2024-07", + "timestamp": "2024-01-15T10:30:00Z" + } + }, + { + "type": "message", + "data": "TickerSalesBot (assistant): Hi Sarah, welcome to the TicketSales. I found 2 Taylor Swift concerts at Madison Square Garden on July 15 and 16, 2024. Tickets start at $199." + }, + { + "type": "message", + "data": "Sarah (user): Great! I'd like 2 tickets for July 15th please." + }, + { + "type": "json", + "data": { + "event_type": "ticket_purchase", + "user_id": user_id, + "email": "sarah.smith@example.com", + "concert_id": "TS-MSG-0715", + "artist": "Taylor Swift", + "venue": "Madison Square Garden", + "date": "2024-07-15", + "quantity": 2, + "seat_type": "Floor", + "price_per_ticket": 199, + "total_amount": 398, + "transaction_id": "TRX-12345", + "purchase_timestamp": "2024-01-15T10:35:00Z" + } + }, + { + "type": "message", + "data": "Sarah (user): Are there any upcoming Arctic Monkeys concerts?" + }, + { + "type": "json", + "data": { + "event_type": "search_performed", + "user_id": user_id, + "artist": "Arctic Monkeys", + "timestamp": "2024-01-15T10:40:00Z" + } + }, + { + "type": "message", + "data": "TickerSalesBot (assistant): Yes! Arctic Monkeys are playing at Barclays Center on August 5th, 2024." + }, + { + "type": "message", + "data": "Sarah (user): Can you add me to the waitlist for that concert?" + }, + { + "type": "json", + "data": { + "event_type": "waitlist_addition", + "user_id": user_id, + "concert_id": "AM-BC-0805", + "artist": "Arctic Monkeys", + "venue": "Barclays Center", + "date": "2024-08-05", + "timestamp": "2024-01-15T10:42:00Z" + } + }, + { + "type": "message", + "data": "System Notification - Arctic Monkeys tickets are now available for waitlist members!" + }, + { + "type": "json", + "data": { + "event_type": "ticket_purchase", + "user_id": user_id, + "concert_id": "AM-BC-0805", + "artist": "Arctic Monkeys", + "venue": "Barclays Center", + "date": "2024-08-05", + "quantity": 1, + "seat_type": "General Admission", + "price_per_ticket": 150, + "total_amount": 150, + "transaction_id": "TRX-12346", + "purchase_timestamp": "2024-01-15T14:20:00Z" + } + } + ] + + # Add all episodes to the graph + for episode in episodes: + if episode["type"] == "json": + await client.graph.add( + user_id=user_id, + type="json", + data=json.dumps(episode["data"]), + ) + else: # message type + await client.graph.add( + user_id=user_id, + type="message", + data=episode["data"], + ) + + print("Added all ticket purchase episodes to the graph") + print("Waiting for graph processing...") + await asyncio.sleep(30) + + episodes = await client.graph.episode.get_by_user_id(user_id=user_id) + print(episodes) + + + return user_id + +if __name__ == "__main__": + user_id = asyncio.run(create_ticket_playground()) + print(f"\nPlayground ready! User ID: {user_id}") + print("You can now explore the ticket purchase graph and add new episodes!") \ No newline at end of file From e2adc9f26230a233b5e4e91b1ca0654c9b627bac Mon Sep 17 00:00:00 2001 From: paulpaliychuk Date: Mon, 26 May 2025 09:59:04 -0400 Subject: [PATCH 02/28] chore: Bump version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 773f1968..dca56c0d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "zep-cloud" -version = "2.12.3" +version = "2.13.0" description = "" readme = "README.md" authors = [] From c80c78cb552aaec56676fc96867aca379b44c2b8 Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Mon, 26 May 2025 14:00:50 +0000 Subject: [PATCH 03/28] SDK regeneration --- reference.md | 8 ++++ src/zep_cloud/__init__.py | 4 ++ src/zep_cloud/core/client_wrapper.py | 2 +- src/zep_cloud/graph/client.py | 11 +++++- src/zep_cloud/types/__init__.py | 4 ++ .../apidata_entity_edge_source_target.py | 37 +++++++++++++++++++ src/zep_cloud/types/edge_type.py | 34 +++++++++++++++++ src/zep_cloud/types/entity_type_response.py | 2 + 8 files changed, 99 insertions(+), 3 deletions(-) create mode 100644 src/zep_cloud/types/apidata_entity_edge_source_target.py create mode 100644 src/zep_cloud/types/edge_type.py diff --git a/reference.md b/reference.md index fe8783ca..d4f42917 100644 --- a/reference.md +++ b/reference.md @@ -1185,6 +1185,14 @@ client.graph.set_entity_types_internal()
+**edge_types:** `typing.Optional[typing.Sequence[EdgeType]]` + +
+
+ +
+
+ **entity_types:** `typing.Optional[typing.Sequence[EntityType]]`
diff --git a/src/zep_cloud/__init__.py b/src/zep_cloud/__init__.py index ed5f77df..549423a7 100644 --- a/src/zep_cloud/__init__.py +++ b/src/zep_cloud/__init__.py @@ -8,8 +8,10 @@ ApidataDocumentCollection, ApidataDocumentSearchResponse, ApidataDocumentWithScore, + ApidataEntityEdgeSourceTarget, ClassifySessionRequest, CreateDocumentRequest, + EdgeType, EndSessionResponse, EndSessionsResponse, EntityEdge, @@ -70,10 +72,12 @@ "ApidataDocumentCollection", "ApidataDocumentSearchResponse", "ApidataDocumentWithScore", + "ApidataEntityEdgeSourceTarget", "BadRequestError", "ClassifySessionRequest", "ConflictError", "CreateDocumentRequest", + "EdgeType", "EndSessionResponse", "EndSessionsResponse", "EntityEdge", diff --git a/src/zep_cloud/core/client_wrapper.py b/src/zep_cloud/core/client_wrapper.py index bdd44236..5c12aa26 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.12.3", + "X-Fern-SDK-Version": "2.13.0", } headers["Authorization"] = f"Api-Key {self.api_key}" return headers diff --git a/src/zep_cloud/graph/client.py b/src/zep_cloud/graph/client.py index e208c288..97849207 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.edge_type import EdgeType from ..types.entity_type import EntityType from ..types.entity_type_response import EntityTypeResponse from ..types.episode import Episode @@ -82,6 +83,7 @@ def list_entity_types(self, *, request_options: typing.Optional[RequestOptions] def set_entity_types_internal( self, *, + edge_types: typing.Optional[typing.Sequence[EdgeType]] = OMIT, entity_types: typing.Optional[typing.Sequence[EntityType]] = OMIT, request_options: typing.Optional[RequestOptions] = None ) -> SuccessResponse: @@ -90,6 +92,8 @@ def set_entity_types_internal( Parameters ---------- + edge_types : typing.Optional[typing.Sequence[EdgeType]] + entity_types : typing.Optional[typing.Sequence[EntityType]] request_options : typing.Optional[RequestOptions] @@ -112,7 +116,7 @@ def set_entity_types_internal( _response = self._client_wrapper.httpx_client.request( "entity-types", method="PUT", - json={"entity_types": entity_types}, + json={"edge_types": edge_types, "entity_types": entity_types}, request_options=request_options, omit=OMIT, ) @@ -574,6 +578,7 @@ async def main() -> None: async def set_entity_types_internal( self, *, + edge_types: typing.Optional[typing.Sequence[EdgeType]] = OMIT, entity_types: typing.Optional[typing.Sequence[EntityType]] = OMIT, request_options: typing.Optional[RequestOptions] = None ) -> SuccessResponse: @@ -582,6 +587,8 @@ async def set_entity_types_internal( Parameters ---------- + edge_types : typing.Optional[typing.Sequence[EdgeType]] + entity_types : typing.Optional[typing.Sequence[EntityType]] request_options : typing.Optional[RequestOptions] @@ -612,7 +619,7 @@ async def main() -> None: _response = await self._client_wrapper.httpx_client.request( "entity-types", method="PUT", - json={"entity_types": entity_types}, + json={"edge_types": edge_types, "entity_types": entity_types}, request_options=request_options, omit=OMIT, ) diff --git a/src/zep_cloud/types/__init__.py b/src/zep_cloud/types/__init__.py index 47937d43..750a323b 100644 --- a/src/zep_cloud/types/__init__.py +++ b/src/zep_cloud/types/__init__.py @@ -7,8 +7,10 @@ from .apidata_document_collection import ApidataDocumentCollection from .apidata_document_search_response import ApidataDocumentSearchResponse from .apidata_document_with_score import ApidataDocumentWithScore +from .apidata_entity_edge_source_target import ApidataEntityEdgeSourceTarget from .classify_session_request import ClassifySessionRequest from .create_document_request import CreateDocumentRequest +from .edge_type import EdgeType from .end_session_response import EndSessionResponse from .end_sessions_response import EndSessionsResponse from .entity_edge import EntityEdge @@ -64,8 +66,10 @@ "ApidataDocumentCollection", "ApidataDocumentSearchResponse", "ApidataDocumentWithScore", + "ApidataEntityEdgeSourceTarget", "ClassifySessionRequest", "CreateDocumentRequest", + "EdgeType", "EndSessionResponse", "EndSessionsResponse", "EntityEdge", diff --git a/src/zep_cloud/types/apidata_entity_edge_source_target.py b/src/zep_cloud/types/apidata_entity_edge_source_target.py new file mode 100644 index 00000000..13931b93 --- /dev/null +++ b/src/zep_cloud/types/apidata_entity_edge_source_target.py @@ -0,0 +1,37 @@ +# 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 ApidataEntityEdgeSourceTarget(pydantic_v1.BaseModel): + source: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + Source represents the originating node identifier in the edge type relationship. (optional) + """ + + target: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + Target represents the target node identifier in the edge type relationship. (optional) + """ + + 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} diff --git a/src/zep_cloud/types/edge_type.py b/src/zep_cloud/types/edge_type.py new file mode 100644 index 00000000..718409f4 --- /dev/null +++ b/src/zep_cloud/types/edge_type.py @@ -0,0 +1,34 @@ +# 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 +from .apidata_entity_edge_source_target import ApidataEntityEdgeSourceTarget +from .entity_property import EntityProperty + + +class EdgeType(pydantic_v1.BaseModel): + description: str + name: str + properties: typing.Optional[typing.List[EntityProperty]] = None + source_targets: typing.Optional[typing.List[ApidataEntityEdgeSourceTarget]] = 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} diff --git a/src/zep_cloud/types/entity_type_response.py b/src/zep_cloud/types/entity_type_response.py index fc72e335..b27f30d7 100644 --- a/src/zep_cloud/types/entity_type_response.py +++ b/src/zep_cloud/types/entity_type_response.py @@ -5,10 +5,12 @@ from ..core.datetime_utils import serialize_datetime from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from .edge_type import EdgeType from .entity_type import EntityType class EntityTypeResponse(pydantic_v1.BaseModel): + edge_types: typing.Optional[typing.List[EdgeType]] = None entity_types: typing.Optional[typing.List[EntityType]] = None def json(self, **kwargs: typing.Any) -> str: From cd968d7b6654acc9bd9b264fa89f754b2ca85b1e Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Mon, 26 May 2025 14:13:45 +0000 Subject: [PATCH 04/28] SDK regeneration --- src/zep_cloud/__init__.py | 4 ++-- src/zep_cloud/types/__init__.py | 4 ++-- src/zep_cloud/types/edge_type.py | 4 ++-- ...ity_edge_source_target.py => entity_edge_source_target.py} | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) rename src/zep_cloud/types/{apidata_entity_edge_source_target.py => entity_edge_source_target.py} (95%) diff --git a/src/zep_cloud/__init__.py b/src/zep_cloud/__init__.py index 549423a7..42d4fec9 100644 --- a/src/zep_cloud/__init__.py +++ b/src/zep_cloud/__init__.py @@ -8,13 +8,13 @@ ApidataDocumentCollection, ApidataDocumentSearchResponse, ApidataDocumentWithScore, - ApidataEntityEdgeSourceTarget, ClassifySessionRequest, CreateDocumentRequest, EdgeType, EndSessionResponse, EndSessionsResponse, EntityEdge, + EntityEdgeSourceTarget, EntityNode, EntityProperty, EntityPropertyType, @@ -72,7 +72,6 @@ "ApidataDocumentCollection", "ApidataDocumentSearchResponse", "ApidataDocumentWithScore", - "ApidataEntityEdgeSourceTarget", "BadRequestError", "ClassifySessionRequest", "ConflictError", @@ -81,6 +80,7 @@ "EndSessionResponse", "EndSessionsResponse", "EntityEdge", + "EntityEdgeSourceTarget", "EntityNode", "EntityProperty", "EntityPropertyType", diff --git a/src/zep_cloud/types/__init__.py b/src/zep_cloud/types/__init__.py index 750a323b..8c8db6bb 100644 --- a/src/zep_cloud/types/__init__.py +++ b/src/zep_cloud/types/__init__.py @@ -7,13 +7,13 @@ from .apidata_document_collection import ApidataDocumentCollection from .apidata_document_search_response import ApidataDocumentSearchResponse from .apidata_document_with_score import ApidataDocumentWithScore -from .apidata_entity_edge_source_target import ApidataEntityEdgeSourceTarget from .classify_session_request import ClassifySessionRequest from .create_document_request import CreateDocumentRequest from .edge_type import EdgeType from .end_session_response import EndSessionResponse from .end_sessions_response import EndSessionsResponse from .entity_edge import EntityEdge +from .entity_edge_source_target import EntityEdgeSourceTarget from .entity_node import EntityNode from .entity_property import EntityProperty from .entity_property_type import EntityPropertyType @@ -66,13 +66,13 @@ "ApidataDocumentCollection", "ApidataDocumentSearchResponse", "ApidataDocumentWithScore", - "ApidataEntityEdgeSourceTarget", "ClassifySessionRequest", "CreateDocumentRequest", "EdgeType", "EndSessionResponse", "EndSessionsResponse", "EntityEdge", + "EntityEdgeSourceTarget", "EntityNode", "EntityProperty", "EntityPropertyType", diff --git a/src/zep_cloud/types/edge_type.py b/src/zep_cloud/types/edge_type.py index 718409f4..4c53f85d 100644 --- a/src/zep_cloud/types/edge_type.py +++ b/src/zep_cloud/types/edge_type.py @@ -5,7 +5,7 @@ from ..core.datetime_utils import serialize_datetime from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -from .apidata_entity_edge_source_target import ApidataEntityEdgeSourceTarget +from .entity_edge_source_target import EntityEdgeSourceTarget from .entity_property import EntityProperty @@ -13,7 +13,7 @@ class EdgeType(pydantic_v1.BaseModel): description: str name: str properties: typing.Optional[typing.List[EntityProperty]] = None - source_targets: typing.Optional[typing.List[ApidataEntityEdgeSourceTarget]] = None + source_targets: typing.Optional[typing.List[EntityEdgeSourceTarget]] = None def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} diff --git a/src/zep_cloud/types/apidata_entity_edge_source_target.py b/src/zep_cloud/types/entity_edge_source_target.py similarity index 95% rename from src/zep_cloud/types/apidata_entity_edge_source_target.py rename to src/zep_cloud/types/entity_edge_source_target.py index 13931b93..7fb171e3 100644 --- a/src/zep_cloud/types/apidata_entity_edge_source_target.py +++ b/src/zep_cloud/types/entity_edge_source_target.py @@ -7,7 +7,7 @@ from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -class ApidataEntityEdgeSourceTarget(pydantic_v1.BaseModel): +class EntityEdgeSourceTarget(pydantic_v1.BaseModel): source: typing.Optional[str] = pydantic_v1.Field(default=None) """ Source represents the originating node identifier in the edge type relationship. (optional) From 3e756483600e62c60211a8743814ca5c8b68e720 Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Mon, 26 May 2025 18:57:05 +0000 Subject: [PATCH 05/28] SDK regeneration From 96ad439c611952a3fdaee1c6e741db4e189ed9ac Mon Sep 17 00:00:00 2001 From: paulpaliychuk Date: Tue, 27 May 2025 10:13:08 -0400 Subject: [PATCH 06/28] feat: Add support for custom entity edges --- examples/graph_example/entity_types.py | 56 ++++++--- src/zep_cloud/external_clients/graph.py | 32 ++++- src/zep_cloud/external_clients/ontology.py | 130 ++++++++++++++++++--- 3 files changed, 186 insertions(+), 32 deletions(-) diff --git a/examples/graph_example/entity_types.py b/examples/graph_example/entity_types.py index 9aa89e94..f7c32456 100644 --- a/examples/graph_example/entity_types.py +++ b/examples/graph_example/entity_types.py @@ -3,10 +3,11 @@ from dotenv import find_dotenv, load_dotenv +from zep_cloud import EntityEdgeSourceTarget from zep_cloud.client import AsyncZep -from zep_cloud.types import SearchFilters from pydantic import Field -from zep_cloud.external_clients.ontology import EntityModel, EntityText, EntityFloat, EntityInt +from zep_cloud.external_clients.ontology import EntityModel, EntityText, EdgeModel + load_dotenv( dotenv_path=find_dotenv() ) @@ -18,32 +19,59 @@ async def main() -> None: client = AsyncZep( api_key=API_KEY, ) - class Purchase(EntityModel): + + class Destination(EntityModel): """ - A purchase is an item that was purchased. + A destination is a place that travelers visit. """ - item_name: EntityText = Field( - description="The name of the item purchased", + destination_name: EntityText = Field( + description="The name of the destination", default=None ) - item_price: EntityFloat = Field( - description="The price of the item", + country: EntityText = Field( + description="The country of the destination", default=None ) - quantity: EntityInt = Field( - description="The quantity of the item purchased", + region: EntityText = Field( + description="The region of the destination", default=None ) - additional_notes: EntityText = Field( - description="Additional notes about the purchase", + description: EntityText = Field( + description="A description of the destination", default=None ) + + class TravelingTo(EdgeModel): + """ + An edge representing a traveler going to a destination. + """ + travel_date: EntityText = Field( + description="The date of travel to this destination", + default=None + ) + purpose: EntityText = Field( + description="The purpose of travel (Business, Leisure, etc.)", + default=None + ) + await client.graph.set_entity_types( - entities={} + entities={ + "Destination": Destination, + }, + edges={ + "TRAVELING_TO": ( + TravelingTo, + [ + EntityEdgeSourceTarget( + source="User", + target="Destination" + ) + ] + ), + } ) enntl = await client.graph.list_entity_types() print(enntl) - if __name__ == "__main__": asyncio.run(main()) \ No newline at end of file diff --git a/src/zep_cloud/external_clients/graph.py b/src/zep_cloud/external_clients/graph.py index cc7fef8d..ee1306d7 100644 --- a/src/zep_cloud/external_clients/graph.py +++ b/src/zep_cloud/external_clients/graph.py @@ -1,4 +1,6 @@ +from zep_cloud import EntityEdgeSourceTarget, EdgeType from zep_cloud.core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from zep_cloud.external_clients.ontology import EdgeModel, edge_model_to_api_schema from zep_cloud.graph.client import GraphClient as BaseGraphClient, AsyncGraphClient as AsyncBaseGraphClient from zep_cloud.types import EntityType import typing @@ -28,11 +30,37 @@ def __init__(self, *, client_wrapper: AsyncClientWrapper): client_wrapper=client_wrapper ) - async def set_entity_types(self, entities: dict[str, "EntityModel"], request_options: typing.Optional[RequestOptions] = None): + async def set_entity_types( + self, + entities: dict[str, "EntityModel"], + edges: typing.Optional[dict[str, typing.Union["EdgeModel", typing.Tuple["EdgeModel", typing.List[EntityEdgeSourceTarget]]]]] = None, + request_options: typing.Optional[RequestOptions] = None, + ): api_entity_types: list[EntityType] = [] + api_edge_types: list[EdgeType] = [] + for name, entity in entities.items(): entity_dict = entity_model_to_api_schema(entity, name) api_entity_types.append(EntityType(**entity_dict)) - res = await self.set_entity_types_internal(entity_types=api_entity_types, request_options=request_options) + + if edges: + for name, edge_data in edges.items(): + # Handle both EdgeModel directly and tuple of (model, source_targets) + if isinstance(edge_data, tuple): + edge_model, source_targets = edge_data + else: + edge_model = edge_data + source_targets = None + + edge_dict = edge_model_to_api_schema(edge_model, name) + if source_targets: + edge_dict["source_targets"] = [st.dict() for st in source_targets] + api_edge_types.append(EdgeType(**edge_dict)) + + res = await self.set_entity_types_internal( + entity_types=api_entity_types, + edge_types=api_edge_types, + request_options=request_options + ) return res \ No newline at end of file diff --git a/src/zep_cloud/external_clients/ontology.py b/src/zep_cloud/external_clients/ontology.py index 510dbb3c..0047d7a1 100644 --- a/src/zep_cloud/external_clients/ontology.py +++ b/src/zep_cloud/external_clients/ontology.py @@ -1,10 +1,13 @@ from enum import Enum import typing -from pydantic import BaseModel, Field, WithJsonSchema +from pydantic import BaseModel, Field, WithJsonSchema, create_model from typing_extensions import Annotated from pydantic.json_schema import GenerateJsonSchema, JsonSchemaValue from pydantic_core import core_schema +from zep_cloud import EntityEdgeSourceTarget, EntityType + + class EntityPropertyType(Enum): Text = "Text" Int = "Int" @@ -12,20 +15,34 @@ class EntityPropertyType(Enum): Boolean = "Boolean" class EntityField(BaseModel): + """Base class for entity field definitions""" description: str + type: EntityPropertyType class EntityBaseText(EntityField): + """Entity field with Text type""" type: EntityPropertyType = EntityPropertyType.Text class EntityBaseInt(EntityField): + """Entity field with Int type""" type: EntityPropertyType = EntityPropertyType.Int class EntityBaseFloat(EntityField): + """Entity field with Float type""" type: EntityPropertyType = EntityPropertyType.Float class EntityBaseBoolean(EntityField): + """Entity field with Boolean type""" type: EntityPropertyType = EntityPropertyType.Boolean +# Annotated types for entity properties +# These types are used to define the properties of entity and edge models +# Each type includes: +# 1. The base Python type (str, int, float, bool) +# 2. A default value of None +# 3. Entity type information +# 4. JSON schema information for serialization + EntityText = Annotated[ typing.Optional[str], Field(default=None), @@ -62,28 +79,41 @@ class _CustomJsonSchema(GenerateJsonSchema): def nullable_schema(self, schema: core_schema.CoreSchema) -> JsonSchemaValue: return self.generate_inner(schema["schema"]) -class EntityModel(BaseModel): +class _BaseSchemaModel(BaseModel): + """Base class for models that need custom JSON schema generation""" @classmethod def model_json_schema(cls, *args, **kwargs): kwargs["schema_generator"] = _CustomJsonSchema return super().model_json_schema(*args, **kwargs) -def entity_model_to_api_schema(model_class: "EntityModel", name: str) -> dict[str, typing.Any]: - """Convert a Pydantic EntityModel to a JSON schema for Go EntityType""" - +class EntityModel(_BaseSchemaModel): + """Entity model for representing entity types""" + pass + +class EdgeModel(_BaseSchemaModel): + """Edge model for representing edge types""" + pass + +def _model_to_api_schema_common(model_class: typing.Union["EntityModel", "EdgeModel"], name: str, is_edge: bool = False) -> dict[str, typing.Any]: + """Common function to convert a Pydantic Model to a JSON schema for API EntityType or EdgeType""" + schema = model_class.model_json_schema() - - # Define the entity type with proper typings for properties as a list of dictionaries - entity_type: dict[str, typing.Any] = { + + # Define the type with proper typings for properties as a list of dictionaries + result_type: dict[str, typing.Any] = { "name": name, "description": model_class.__doc__.strip() if model_class.__doc__ else "", "properties": [] } - + + # Add source_targets field for edge types + if is_edge: + result_type["source_targets"] = [] + for field_name, field_schema in schema.get("properties", {}).items(): if "type" not in field_schema: continue - + property_type = field_schema.get("type") type_mapping = { "string": "Text", @@ -91,19 +121,87 @@ def entity_model_to_api_schema(model_class: "EntityModel", name: str) -> dict[st "number": "Float", "boolean": "Boolean" } - + if property_type in type_mapping: property_type = type_mapping[property_type] else: raise ValueError(f"Unsupported property type: {property_type}") - + description = field_schema.get("description", "") - - entity_type["properties"].append({ + + result_type["properties"].append({ "name": field_name, "type": property_type, "description": description }) - - return entity_type + return result_type + + +def entity_model_to_api_schema(model_class: "EntityModel", name: str) -> dict[str, typing.Any]: + """Convert a Pydantic EntityModel to a JSON schema for API EntityType""" + return _model_to_api_schema_common(model_class, name, is_edge=False) + + +def edge_model_to_api_schema(model_class: "EdgeModel", name: str) -> dict[str, typing.Any]: + """Convert a Pydantic EdgeModel to a JSON schema for API EntityEdge""" + return _model_to_api_schema_common(model_class, name, is_edge=True) + + +def convert_edge_schema_to_model(edge_schema: EntityType) -> (typing.Type[EdgeModel], list[EntityEdgeSourceTarget]): + """ + Convert a JSON schema from Go EntityType back to a Pydantic EdgeModel class + + This function takes an EntityType object (which can represent an edge type in the API) + and converts it to a Pydantic EdgeModel class. It maps the properties from the EntityType + to the appropriate Pydantic field types (EntityText, EntityInt, etc.) and creates a new + model class dynamically using create_model. + + Args: + edge_schema: The EntityType object representing an edge type + + Returns: + A tuple containing: + - The dynamically created EdgeModel class + - The list of source_targets from the edge_schema + """ + + edge_name = edge_schema.name + properties = edge_schema.properties + edge_description = edge_schema.description + + field_definitions: dict[str, typing.Any] = {} + + type_mapping = { + 'Text': EntityText, + 'Int': EntityInt, + 'Float': EntityFloat, + 'Boolean': EntityBoolean, + } + + for prop in properties: + prop_name = prop.name + prop_type = prop.type + prop_description = prop.description + + if not prop_name or not prop_type: + continue + + field_type = type_mapping.get(prop_type) + if not field_type: + continue + + field_definitions[prop_name] = ( + field_type, + Field(description=prop_description, default=None), + ) + + model_class = create_model( + edge_name, + __base__=EntityModel, + __module__=EntityModel.__module__, + __doc__=edge_description, + **field_definitions, + ) + + return model_class, edge_schema.source_targets From 6a5be5e0455e4917ea08b1acfa02a76e97bfb6ab Mon Sep 17 00:00:00 2001 From: paulpaliychuk Date: Tue, 27 May 2025 10:40:36 -0400 Subject: [PATCH 07/28] simplify ontology client --- src/zep_cloud/external_clients/ontology.py | 61 ---------------------- 1 file changed, 61 deletions(-) diff --git a/src/zep_cloud/external_clients/ontology.py b/src/zep_cloud/external_clients/ontology.py index 0047d7a1..9638d184 100644 --- a/src/zep_cloud/external_clients/ontology.py +++ b/src/zep_cloud/external_clients/ontology.py @@ -5,9 +5,6 @@ from pydantic.json_schema import GenerateJsonSchema, JsonSchemaValue from pydantic_core import core_schema -from zep_cloud import EntityEdgeSourceTarget, EntityType - - class EntityPropertyType(Enum): Text = "Text" Int = "Int" @@ -147,61 +144,3 @@ def edge_model_to_api_schema(model_class: "EdgeModel", name: str) -> dict[str, t """Convert a Pydantic EdgeModel to a JSON schema for API EntityEdge""" return _model_to_api_schema_common(model_class, name, is_edge=True) - -def convert_edge_schema_to_model(edge_schema: EntityType) -> (typing.Type[EdgeModel], list[EntityEdgeSourceTarget]): - """ - Convert a JSON schema from Go EntityType back to a Pydantic EdgeModel class - - This function takes an EntityType object (which can represent an edge type in the API) - and converts it to a Pydantic EdgeModel class. It maps the properties from the EntityType - to the appropriate Pydantic field types (EntityText, EntityInt, etc.) and creates a new - model class dynamically using create_model. - - Args: - edge_schema: The EntityType object representing an edge type - - Returns: - A tuple containing: - - The dynamically created EdgeModel class - - The list of source_targets from the edge_schema - """ - - edge_name = edge_schema.name - properties = edge_schema.properties - edge_description = edge_schema.description - - field_definitions: dict[str, typing.Any] = {} - - type_mapping = { - 'Text': EntityText, - 'Int': EntityInt, - 'Float': EntityFloat, - 'Boolean': EntityBoolean, - } - - for prop in properties: - prop_name = prop.name - prop_type = prop.type - prop_description = prop.description - - if not prop_name or not prop_type: - continue - - field_type = type_mapping.get(prop_type) - if not field_type: - continue - - field_definitions[prop_name] = ( - field_type, - Field(description=prop_description, default=None), - ) - - model_class = create_model( - edge_name, - __base__=EntityModel, - __module__=EntityModel.__module__, - __doc__=edge_description, - **field_definitions, - ) - - return model_class, edge_schema.source_targets From 1c23a194eced1dc7f6211bdefb59367d169ffc3e Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Wed, 28 May 2025 21:32:28 +0000 Subject: [PATCH 08/28] SDK regeneration --- src/zep_cloud/types/search_filters.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/zep_cloud/types/search_filters.py b/src/zep_cloud/types/search_filters.py index c2bb1f28..2d08551d 100644 --- a/src/zep_cloud/types/search_filters.py +++ b/src/zep_cloud/types/search_filters.py @@ -8,6 +8,11 @@ class SearchFilters(pydantic_v1.BaseModel): + edge_types: typing.Optional[typing.List[str]] = pydantic_v1.Field(default=None) + """ + List of edge types to filter on + """ + node_labels: typing.Optional[typing.List[str]] = pydantic_v1.Field(default=None) """ List of node labels to filter on From 626ca50a7016aa462f21e28e6e42ced82ac50cd8 Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Thu, 29 May 2025 22:26:08 +0000 Subject: [PATCH 09/28] SDK regeneration --- src/zep_cloud/types/entity_edge.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/zep_cloud/types/entity_edge.py b/src/zep_cloud/types/entity_edge.py index d12e28af..5e5ec2cb 100644 --- a/src/zep_cloud/types/entity_edge.py +++ b/src/zep_cloud/types/entity_edge.py @@ -8,6 +8,11 @@ class EntityEdge(pydantic_v1.BaseModel): + attributes: typing.Optional[typing.Dict[str, typing.Any]] = pydantic_v1.Field(default=None) + """ + Additional attributes of the edge. Dependent on edge types + """ + created_at: str = pydantic_v1.Field() """ Creation time of the edge From 1d958ad71a30e6c45156520499a9e1cedad380f9 Mon Sep 17 00:00:00 2001 From: paulpaliychuk Date: Mon, 2 Jun 2025 14:23:51 -0400 Subject: [PATCH 10/28] chore: Update doc string --- examples/graph_example/entity_types.py | 23 ++++++++- src/zep_cloud/external_clients/graph.py | 65 +++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 2 deletions(-) diff --git a/examples/graph_example/entity_types.py b/examples/graph_example/entity_types.py index f7c32456..97c8efa5 100644 --- a/examples/graph_example/entity_types.py +++ b/examples/graph_example/entity_types.py @@ -3,7 +3,7 @@ from dotenv import find_dotenv, load_dotenv -from zep_cloud import EntityEdgeSourceTarget +from zep_cloud import EntityEdgeSourceTarget, SearchFilters from zep_cloud.client import AsyncZep from pydantic import Field from zep_cloud.external_clients.ontology import EntityModel, EntityText, EdgeModel @@ -53,7 +53,6 @@ class TravelingTo(EdgeModel): description="The purpose of travel (Business, Leisure, etc.)", default=None ) - await client.graph.set_entity_types( entities={ "Destination": Destination, @@ -70,6 +69,26 @@ class TravelingTo(EdgeModel): ), } ) + + results = await client.graph.search( + user_id="", + query="travel", + # scope="nodes", + scope="edges", + search_filters=SearchFilters( + edge_types=["TRAVELING_TO"] + # node_labels=["Destination"] + ) + ) + + if results.nodes: + for node in results.nodes: + print(Destination(**node.attributes)) + if results.edges: + for edge in results.edges: + print(TravelingTo(**edge.attributes)) + + enntl = await client.graph.list_entity_types() print(enntl) diff --git a/src/zep_cloud/external_clients/graph.py b/src/zep_cloud/external_clients/graph.py index ee1306d7..09e47782 100644 --- a/src/zep_cloud/external_clients/graph.py +++ b/src/zep_cloud/external_clients/graph.py @@ -36,6 +36,71 @@ async def set_entity_types( edges: typing.Optional[dict[str, typing.Union["EdgeModel", typing.Tuple["EdgeModel", typing.List[EntityEdgeSourceTarget]]]]] = None, request_options: typing.Optional[RequestOptions] = None, ): + """ + Sets the entity and edge types for a project, replacing any existing ones. + + Parameters + ---------- + entities : dict[str, "EntityModel"] + + edges : typing.Optional[dict[str, typing.Union["EdgeModel", typing.Tuple["EdgeModel", typing.List[EntityEdgeSourceTarget]]]]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Examples + -------- + + class Destination(EntityModel): + + \"""A destination is a place that travelers visit.\""" + destination_name: EntityText = Field( + description="The name of the destination", + default=None + ) + country: EntityText = Field( + description="The country of the destination", + default=None + ) + region: EntityText = Field( + description="The region of the destination", + default=None + ) + description: EntityText = Field( + description="A description of the destination", + default=None + ) + + + class TravelingTo(EdgeModel): + + \"""An edge representing a traveler going to a destination.\""" + travel_date: EntityText = Field( + description="The date of travel to this destination", + default=None + ) + purpose: EntityText = Field( + description="The purpose of travel (Business, Leisure, etc.)", + default=None + ) + + await client.graph.set_entity_types( + entities={ + "Destination": Destination, + }, + edges={ + "TRAVELING_TO": ( + TravelingTo, + [ + EntityEdgeSourceTarget( + source="User", + target="Destination" + ) + ] + ), + } + ) + """ api_entity_types: list[EntityType] = [] api_edge_types: list[EdgeType] = [] From 6e9c3310404cfb83f05da439ddc3060241508a6f Mon Sep 17 00:00:00 2001 From: paulpaliychuk Date: Tue, 3 Jun 2025 18:20:41 -0400 Subject: [PATCH 11/28] feat: Update sync version of set entity type method --- pyproject.toml | 2 +- src/zep_cloud/external_clients/graph.py | 94 ++++++++++++++++++++++++- 2 files changed, 93 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index dca56c0d..319dc6df 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "zep-cloud" -version = "2.13.0" +version = "2.13.1" description = "" readme = "README.md" authors = [] diff --git a/src/zep_cloud/external_clients/graph.py b/src/zep_cloud/external_clients/graph.py index 09e47782..d71a3da0 100644 --- a/src/zep_cloud/external_clients/graph.py +++ b/src/zep_cloud/external_clients/graph.py @@ -15,12 +15,102 @@ def __init__(self, *, client_wrapper: SyncClientWrapper): client_wrapper=client_wrapper ) - def set_entity_types(self, entities: dict[str, "EntityModel"], request_options: typing.Optional[RequestOptions] = None): + def set_entity_types( + self, + entities: dict[str, "EntityModel"], + edges: typing.Optional[dict[str, typing.Union["EdgeModel", typing.Tuple["EdgeModel", typing.List[EntityEdgeSourceTarget]]]]] = None, + request_options: typing.Optional[RequestOptions] = None, + ): + """ + Sets the entity and edge types for a project, replacing any existing ones. + + Parameters + ---------- + entities : dict[str, "EntityModel"] + + edges : typing.Optional[dict[str, typing.Union["EdgeModel", typing.Tuple["EdgeModel", typing.List[EntityEdgeSourceTarget]]]]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Examples + -------- + + class Destination(EntityModel): + + \"""A destination is a place that travelers visit.\""" + destination_name: EntityText = Field( + description="The name of the destination", + default=None + ) + country: EntityText = Field( + description="The country of the destination", + default=None + ) + region: EntityText = Field( + description="The region of the destination", + default=None + ) + description: EntityText = Field( + description="A description of the destination", + default=None + ) + + + class TravelingTo(EdgeModel): + + \"""An edge representing a traveler going to a destination.\""" + travel_date: EntityText = Field( + description="The date of travel to this destination", + default=None + ) + purpose: EntityText = Field( + description="The purpose of travel (Business, Leisure, etc.)", + default=None + ) + + client.graph.set_entity_types( + entities={ + "Destination": Destination, + }, + edges={ + "TRAVELING_TO": ( + TravelingTo, + [ + EntityEdgeSourceTarget( + source="User", + target="Destination" + ) + ] + ), + } + ) + """ api_entity_types: list[EntityType] = [] + api_edge_types: list[EdgeType] = [] + for name, entity in entities.items(): entity_dict = entity_model_to_api_schema(entity, name) api_entity_types.append(EntityType(**entity_dict)) - res = self.set_entity_types_internal(entity_types=api_entity_types, request_options=request_options) + + if edges: + for name, edge_data in edges.items(): + # Handle both EdgeModel directly and tuple of (model, source_targets) + if isinstance(edge_data, tuple): + edge_model, source_targets = edge_data + else: + edge_model = edge_data + source_targets = None + + edge_dict = edge_model_to_api_schema(edge_model, name) + if source_targets: + edge_dict["source_targets"] = [st.dict() for st in source_targets] + api_edge_types.append(EdgeType(**edge_dict)) + res = self.set_entity_types_internal( + entity_types=api_entity_types, + edge_types=api_edge_types, + request_options=request_options, + ) return res From bb5382a1591b4d63ec1e109ef34391567f75fed6 Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Wed, 4 Jun 2025 15:34:14 +0000 Subject: [PATCH 12/28] SDK regeneration --- src/zep_cloud/core/client_wrapper.py | 2 +- src/zep_cloud/types/graph_search_scope.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/zep_cloud/core/client_wrapper.py b/src/zep_cloud/core/client_wrapper.py index 5c12aa26..5677da7b 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.13.0", + "X-Fern-SDK-Version": "2.14.0", } headers["Authorization"] = f"Api-Key {self.api_key}" return headers diff --git a/src/zep_cloud/types/graph_search_scope.py b/src/zep_cloud/types/graph_search_scope.py index b57a0216..07edf5de 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"], typing.Any] +GraphSearchScope = typing.Union[typing.Literal["edges", "nodes", "episodes"], typing.Any] From ecb706e6f9b60e9c28e1ef2d44f7cc196b095f3d Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Wed, 4 Jun 2025 15:49:28 +0000 Subject: [PATCH 13/28] SDK regeneration --- src/zep_cloud/__init__.py | 4 +++ src/zep_cloud/types/__init__.py | 4 +++ src/zep_cloud/types/episode_type.py | 5 +++ src/zep_cloud/types/graph_search_results.py | 2 ++ src/zep_cloud/types/graphiti_episode.py | 38 +++++++++++++++++++++ 5 files changed, 53 insertions(+) create mode 100644 src/zep_cloud/types/episode_type.py create mode 100644 src/zep_cloud/types/graphiti_episode.py diff --git a/src/zep_cloud/__init__.py b/src/zep_cloud/__init__.py index 42d4fec9..48ffacb3 100644 --- a/src/zep_cloud/__init__.py +++ b/src/zep_cloud/__init__.py @@ -23,6 +23,7 @@ Episode, EpisodeData, EpisodeResponse, + EpisodeType, Fact, FactRatingExamples, FactRatingInstruction, @@ -33,6 +34,7 @@ GraphNodesRequest, GraphSearchResults, GraphSearchScope, + GraphitiEpisode, Group, GroupListResponse, Memory, @@ -89,6 +91,7 @@ "Episode", "EpisodeData", "EpisodeResponse", + "EpisodeType", "Fact", "FactRatingExamples", "FactRatingInstruction", @@ -99,6 +102,7 @@ "GraphNodesRequest", "GraphSearchResults", "GraphSearchScope", + "GraphitiEpisode", "Group", "GroupListResponse", "InternalServerError", diff --git a/src/zep_cloud/types/__init__.py b/src/zep_cloud/types/__init__.py index 8c8db6bb..49ecac62 100644 --- a/src/zep_cloud/types/__init__.py +++ b/src/zep_cloud/types/__init__.py @@ -22,6 +22,7 @@ from .episode import Episode from .episode_data import EpisodeData from .episode_response import EpisodeResponse +from .episode_type import EpisodeType from .fact import Fact from .fact_rating_examples import FactRatingExamples from .fact_rating_instruction import FactRatingInstruction @@ -32,6 +33,7 @@ from .graph_nodes_request import GraphNodesRequest from .graph_search_results import GraphSearchResults from .graph_search_scope import GraphSearchScope +from .graphiti_episode import GraphitiEpisode from .group import Group from .group_list_response import GroupListResponse from .memory import Memory @@ -81,6 +83,7 @@ "Episode", "EpisodeData", "EpisodeResponse", + "EpisodeType", "Fact", "FactRatingExamples", "FactRatingInstruction", @@ -91,6 +94,7 @@ "GraphNodesRequest", "GraphSearchResults", "GraphSearchScope", + "GraphitiEpisode", "Group", "GroupListResponse", "Memory", diff --git a/src/zep_cloud/types/episode_type.py b/src/zep_cloud/types/episode_type.py new file mode 100644 index 00000000..3310c2c5 --- /dev/null +++ b/src/zep_cloud/types/episode_type.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +EpisodeType = typing.Union[typing.Literal["message", "text", "json"], typing.Any] diff --git a/src/zep_cloud/types/graph_search_results.py b/src/zep_cloud/types/graph_search_results.py index feed264c..2cd6389b 100644 --- a/src/zep_cloud/types/graph_search_results.py +++ b/src/zep_cloud/types/graph_search_results.py @@ -7,10 +7,12 @@ from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .entity_edge import EntityEdge from .entity_node import EntityNode +from .graphiti_episode import GraphitiEpisode class GraphSearchResults(pydantic_v1.BaseModel): edges: typing.Optional[typing.List[EntityEdge]] = None + episodes: typing.Optional[typing.List[GraphitiEpisode]] = None nodes: typing.Optional[typing.List[EntityNode]] = None def json(self, **kwargs: typing.Any) -> str: diff --git a/src/zep_cloud/types/graphiti_episode.py b/src/zep_cloud/types/graphiti_episode.py new file mode 100644 index 00000000..ded345b9 --- /dev/null +++ b/src/zep_cloud/types/graphiti_episode.py @@ -0,0 +1,38 @@ +# 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 +from .episode_type import EpisodeType + + +class GraphitiEpisode(pydantic_v1.BaseModel): + content: str + created_at: str + name: str + source: EpisodeType + source_description: str + uuid_: str = pydantic_v1.Field(alias="uuid") + valid_at: 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 + allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} From a341d16933d1c6993a2a7d9e5b5121ed5c16a337 Mon Sep 17 00:00:00 2001 From: paulpaliychuk Date: Wed, 4 Jun 2025 19:51:45 -0400 Subject: [PATCH 14/28] chore: Bump version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 319dc6df..4c5471e8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "zep-cloud" -version = "2.13.1" +version = "2.14.0" description = "" readme = "README.md" authors = [] From 32a3342deb483965cba87f4743d5d98adbac2457 Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Thu, 5 Jun 2025 00:11:13 +0000 Subject: [PATCH 15/28] SDK regeneration --- src/zep_cloud/__init__.py | 2 ++ src/zep_cloud/graph/episode/client.py | 14 ++++---- src/zep_cloud/types/__init__.py | 2 ++ src/zep_cloud/types/graph_search_results.py | 4 +-- .../types/graphiti_graph_search_results.py | 34 +++++++++++++++++++ 5 files changed, 47 insertions(+), 9 deletions(-) create mode 100644 src/zep_cloud/types/graphiti_graph_search_results.py diff --git a/src/zep_cloud/__init__.py b/src/zep_cloud/__init__.py index 48ffacb3..ad3426bf 100644 --- a/src/zep_cloud/__init__.py +++ b/src/zep_cloud/__init__.py @@ -35,6 +35,7 @@ GraphSearchResults, GraphSearchScope, GraphitiEpisode, + GraphitiGraphSearchResults, Group, GroupListResponse, Memory, @@ -103,6 +104,7 @@ "GraphSearchResults", "GraphSearchScope", "GraphitiEpisode", + "GraphitiGraphSearchResults", "Group", "GroupListResponse", "InternalServerError", diff --git a/src/zep_cloud/graph/episode/client.py b/src/zep_cloud/graph/episode/client.py index 17676392..cad581e2 100644 --- a/src/zep_cloud/graph/episode/client.py +++ b/src/zep_cloud/graph/episode/client.py @@ -14,7 +14,7 @@ from ...types.api_error import ApiError as types_api_error_ApiError from ...types.episode import Episode from ...types.episode_response import EpisodeResponse -from ...types.graph_search_results import GraphSearchResults +from ...types.graphiti_graph_search_results import GraphitiGraphSearchResults from ...types.success_response import SuccessResponse @@ -240,7 +240,7 @@ def delete(self, uuid_: str, *, request_options: typing.Optional[RequestOptions] def get_nodes_and_edges( self, uuid_: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> GraphSearchResults: + ) -> GraphitiGraphSearchResults: """ Returns nodes and edges mentioned in an episode @@ -254,7 +254,7 @@ def get_nodes_and_edges( Returns ------- - GraphSearchResults + GraphitiGraphSearchResults Graph search results Examples @@ -273,7 +273,7 @@ def get_nodes_and_edges( ) try: if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GraphSearchResults, _response.json()) # type: ignore + return pydantic_v1.parse_obj_as(GraphitiGraphSearchResults, _response.json()) # type: ignore if _response.status_code == 400: raise BadRequestError( pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore @@ -542,7 +542,7 @@ async def main() -> None: async def get_nodes_and_edges( self, uuid_: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> GraphSearchResults: + ) -> GraphitiGraphSearchResults: """ Returns nodes and edges mentioned in an episode @@ -556,7 +556,7 @@ async def get_nodes_and_edges( Returns ------- - GraphSearchResults + GraphitiGraphSearchResults Graph search results Examples @@ -583,7 +583,7 @@ async def main() -> None: ) try: if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GraphSearchResults, _response.json()) # type: ignore + return pydantic_v1.parse_obj_as(GraphitiGraphSearchResults, _response.json()) # type: ignore if _response.status_code == 400: raise BadRequestError( pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore diff --git a/src/zep_cloud/types/__init__.py b/src/zep_cloud/types/__init__.py index 49ecac62..1ebf4cdd 100644 --- a/src/zep_cloud/types/__init__.py +++ b/src/zep_cloud/types/__init__.py @@ -34,6 +34,7 @@ from .graph_search_results import GraphSearchResults from .graph_search_scope import GraphSearchScope from .graphiti_episode import GraphitiEpisode +from .graphiti_graph_search_results import GraphitiGraphSearchResults from .group import Group from .group_list_response import GroupListResponse from .memory import Memory @@ -95,6 +96,7 @@ "GraphSearchResults", "GraphSearchScope", "GraphitiEpisode", + "GraphitiGraphSearchResults", "Group", "GroupListResponse", "Memory", diff --git a/src/zep_cloud/types/graph_search_results.py b/src/zep_cloud/types/graph_search_results.py index 2cd6389b..6da40e2b 100644 --- a/src/zep_cloud/types/graph_search_results.py +++ b/src/zep_cloud/types/graph_search_results.py @@ -7,12 +7,12 @@ from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .entity_edge import EntityEdge from .entity_node import EntityNode -from .graphiti_episode import GraphitiEpisode +from .episode import Episode class GraphSearchResults(pydantic_v1.BaseModel): edges: typing.Optional[typing.List[EntityEdge]] = None - episodes: typing.Optional[typing.List[GraphitiEpisode]] = None + episodes: typing.Optional[typing.List[Episode]] = None nodes: typing.Optional[typing.List[EntityNode]] = None def json(self, **kwargs: typing.Any) -> str: diff --git a/src/zep_cloud/types/graphiti_graph_search_results.py b/src/zep_cloud/types/graphiti_graph_search_results.py new file mode 100644 index 00000000..0056682a --- /dev/null +++ b/src/zep_cloud/types/graphiti_graph_search_results.py @@ -0,0 +1,34 @@ +# 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 +from .entity_edge import EntityEdge +from .entity_node import EntityNode +from .graphiti_episode import GraphitiEpisode + + +class GraphitiGraphSearchResults(pydantic_v1.BaseModel): + edges: typing.Optional[typing.List[EntityEdge]] = None + episodes: typing.Optional[typing.List[GraphitiEpisode]] = None + nodes: typing.Optional[typing.List[EntityNode]] = 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} From 47bb4108398c89a8e59243fc4ce832d248882829 Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Thu, 5 Jun 2025 00:34:38 +0000 Subject: [PATCH 16/28] SDK regeneration --- src/zep_cloud/__init__.py | 2 ++ src/zep_cloud/types/__init__.py | 2 ++ src/zep_cloud/types/episode.py | 11 +++++++++++ src/zep_cloud/types/models_role_type.py | 5 +++++ 4 files changed, 20 insertions(+) create mode 100644 src/zep_cloud/types/models_role_type.py diff --git a/src/zep_cloud/__init__.py b/src/zep_cloud/__init__.py index ad3426bf..5209f565 100644 --- a/src/zep_cloud/__init__.py +++ b/src/zep_cloud/__init__.py @@ -42,6 +42,7 @@ MemorySearchResult, Message, MessageListResponse, + ModelsRoleType, NewFact, Question, Reranker, @@ -112,6 +113,7 @@ "MemorySearchResult", "Message", "MessageListResponse", + "ModelsRoleType", "NewFact", "NotFoundError", "Question", diff --git a/src/zep_cloud/types/__init__.py b/src/zep_cloud/types/__init__.py index 1ebf4cdd..bafa070e 100644 --- a/src/zep_cloud/types/__init__.py +++ b/src/zep_cloud/types/__init__.py @@ -41,6 +41,7 @@ from .memory_search_result import MemorySearchResult from .message import Message from .message_list_response import MessageListResponse +from .models_role_type import ModelsRoleType from .new_fact import NewFact from .question import Question from .reranker import Reranker @@ -103,6 +104,7 @@ "MemorySearchResult", "Message", "MessageListResponse", + "ModelsRoleType", "NewFact", "Question", "Reranker", diff --git a/src/zep_cloud/types/episode.py b/src/zep_cloud/types/episode.py index ee7314da..67c82726 100644 --- a/src/zep_cloud/types/episode.py +++ b/src/zep_cloud/types/episode.py @@ -6,12 +6,23 @@ from ..core.datetime_utils import serialize_datetime from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .graph_data_type import GraphDataType +from .models_role_type import ModelsRoleType class Episode(pydantic_v1.BaseModel): content: str created_at: str processed: typing.Optional[bool] = None + role: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + Optional role, will only be present if the episode was created using memory.add API + """ + + role_type: typing.Optional[ModelsRoleType] = pydantic_v1.Field(default=None) + """ + Optional role_type, will only be present if the episode was created using memory.add API + """ + session_id: typing.Optional[str] = pydantic_v1.Field(default=None) """ Optional session ID. Will be present only if the episode corresponds to the messages added using memory.add API diff --git a/src/zep_cloud/types/models_role_type.py b/src/zep_cloud/types/models_role_type.py new file mode 100644 index 00000000..942b4970 --- /dev/null +++ b/src/zep_cloud/types/models_role_type.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +ModelsRoleType = typing.Union[typing.Literal["norole", "system", "assistant", "user", "function", "tool"], typing.Any] From 3990f92c3a26dfa9b63b2d6ad45710d2eaaa25f4 Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Thu, 5 Jun 2025 00:39:28 +0000 Subject: [PATCH 17/28] SDK regeneration From 368e86c50ae0a4f6adaa73d9f57dafdd90457ed5 Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Thu, 5 Jun 2025 00:51:26 +0000 Subject: [PATCH 18/28] SDK regeneration --- src/zep_cloud/__init__.py | 6 --- src/zep_cloud/types/__init__.py | 6 --- src/zep_cloud/types/episode.py | 4 +- src/zep_cloud/types/episode_type.py | 5 --- src/zep_cloud/types/graphiti_episode.py | 38 ------------------- .../types/graphiti_graph_search_results.py | 2 - src/zep_cloud/types/models_role_type.py | 5 --- 7 files changed, 2 insertions(+), 64 deletions(-) delete mode 100644 src/zep_cloud/types/episode_type.py delete mode 100644 src/zep_cloud/types/graphiti_episode.py delete mode 100644 src/zep_cloud/types/models_role_type.py diff --git a/src/zep_cloud/__init__.py b/src/zep_cloud/__init__.py index 5209f565..e0e61970 100644 --- a/src/zep_cloud/__init__.py +++ b/src/zep_cloud/__init__.py @@ -23,7 +23,6 @@ Episode, EpisodeData, EpisodeResponse, - EpisodeType, Fact, FactRatingExamples, FactRatingInstruction, @@ -34,7 +33,6 @@ GraphNodesRequest, GraphSearchResults, GraphSearchScope, - GraphitiEpisode, GraphitiGraphSearchResults, Group, GroupListResponse, @@ -42,7 +40,6 @@ MemorySearchResult, Message, MessageListResponse, - ModelsRoleType, NewFact, Question, Reranker, @@ -93,7 +90,6 @@ "Episode", "EpisodeData", "EpisodeResponse", - "EpisodeType", "Fact", "FactRatingExamples", "FactRatingInstruction", @@ -104,7 +100,6 @@ "GraphNodesRequest", "GraphSearchResults", "GraphSearchScope", - "GraphitiEpisode", "GraphitiGraphSearchResults", "Group", "GroupListResponse", @@ -113,7 +108,6 @@ "MemorySearchResult", "Message", "MessageListResponse", - "ModelsRoleType", "NewFact", "NotFoundError", "Question", diff --git a/src/zep_cloud/types/__init__.py b/src/zep_cloud/types/__init__.py index bafa070e..e0640edc 100644 --- a/src/zep_cloud/types/__init__.py +++ b/src/zep_cloud/types/__init__.py @@ -22,7 +22,6 @@ from .episode import Episode from .episode_data import EpisodeData from .episode_response import EpisodeResponse -from .episode_type import EpisodeType from .fact import Fact from .fact_rating_examples import FactRatingExamples from .fact_rating_instruction import FactRatingInstruction @@ -33,7 +32,6 @@ from .graph_nodes_request import GraphNodesRequest from .graph_search_results import GraphSearchResults from .graph_search_scope import GraphSearchScope -from .graphiti_episode import GraphitiEpisode from .graphiti_graph_search_results import GraphitiGraphSearchResults from .group import Group from .group_list_response import GroupListResponse @@ -41,7 +39,6 @@ from .memory_search_result import MemorySearchResult from .message import Message from .message_list_response import MessageListResponse -from .models_role_type import ModelsRoleType from .new_fact import NewFact from .question import Question from .reranker import Reranker @@ -85,7 +82,6 @@ "Episode", "EpisodeData", "EpisodeResponse", - "EpisodeType", "Fact", "FactRatingExamples", "FactRatingInstruction", @@ -96,7 +92,6 @@ "GraphNodesRequest", "GraphSearchResults", "GraphSearchScope", - "GraphitiEpisode", "GraphitiGraphSearchResults", "Group", "GroupListResponse", @@ -104,7 +99,6 @@ "MemorySearchResult", "Message", "MessageListResponse", - "ModelsRoleType", "NewFact", "Question", "Reranker", diff --git a/src/zep_cloud/types/episode.py b/src/zep_cloud/types/episode.py index 67c82726..bfa2e248 100644 --- a/src/zep_cloud/types/episode.py +++ b/src/zep_cloud/types/episode.py @@ -6,7 +6,7 @@ from ..core.datetime_utils import serialize_datetime from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .graph_data_type import GraphDataType -from .models_role_type import ModelsRoleType +from .role_type import RoleType class Episode(pydantic_v1.BaseModel): @@ -18,7 +18,7 @@ class Episode(pydantic_v1.BaseModel): Optional role, will only be present if the episode was created using memory.add API """ - role_type: typing.Optional[ModelsRoleType] = pydantic_v1.Field(default=None) + role_type: typing.Optional[RoleType] = pydantic_v1.Field(default=None) """ Optional role_type, will only be present if the episode was created using memory.add API """ diff --git a/src/zep_cloud/types/episode_type.py b/src/zep_cloud/types/episode_type.py deleted file mode 100644 index 3310c2c5..00000000 --- a/src/zep_cloud/types/episode_type.py +++ /dev/null @@ -1,5 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -EpisodeType = typing.Union[typing.Literal["message", "text", "json"], typing.Any] diff --git a/src/zep_cloud/types/graphiti_episode.py b/src/zep_cloud/types/graphiti_episode.py deleted file mode 100644 index ded345b9..00000000 --- a/src/zep_cloud/types/graphiti_episode.py +++ /dev/null @@ -1,38 +0,0 @@ -# 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 -from .episode_type import EpisodeType - - -class GraphitiEpisode(pydantic_v1.BaseModel): - content: str - created_at: str - name: str - source: EpisodeType - source_description: str - uuid_: str = pydantic_v1.Field(alias="uuid") - valid_at: 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 - allow_population_by_field_name = True - populate_by_name = True - extra = pydantic_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/zep_cloud/types/graphiti_graph_search_results.py b/src/zep_cloud/types/graphiti_graph_search_results.py index 0056682a..e1c0d663 100644 --- a/src/zep_cloud/types/graphiti_graph_search_results.py +++ b/src/zep_cloud/types/graphiti_graph_search_results.py @@ -7,12 +7,10 @@ from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .entity_edge import EntityEdge from .entity_node import EntityNode -from .graphiti_episode import GraphitiEpisode class GraphitiGraphSearchResults(pydantic_v1.BaseModel): edges: typing.Optional[typing.List[EntityEdge]] = None - episodes: typing.Optional[typing.List[GraphitiEpisode]] = None nodes: typing.Optional[typing.List[EntityNode]] = None def json(self, **kwargs: typing.Any) -> str: diff --git a/src/zep_cloud/types/models_role_type.py b/src/zep_cloud/types/models_role_type.py deleted file mode 100644 index 942b4970..00000000 --- a/src/zep_cloud/types/models_role_type.py +++ /dev/null @@ -1,5 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -ModelsRoleType = typing.Union[typing.Literal["norole", "system", "assistant", "user", "function", "tool"], typing.Any] From daa52bdd351b5201c5e1e5fc709358499cf09069 Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Thu, 5 Jun 2025 17:25:29 +0000 Subject: [PATCH 19/28] SDK regeneration --- src/zep_cloud/__init__.py | 4 ++-- src/zep_cloud/graph/episode/client.py | 18 +++++++++--------- src/zep_cloud/types/__init__.py | 4 ++-- ...h_search_results.py => episode_mentions.py} | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) rename src/zep_cloud/types/{graphiti_graph_search_results.py => episode_mentions.py} (95%) diff --git a/src/zep_cloud/__init__.py b/src/zep_cloud/__init__.py index e0e61970..81bcfce5 100644 --- a/src/zep_cloud/__init__.py +++ b/src/zep_cloud/__init__.py @@ -22,6 +22,7 @@ EntityTypeResponse, Episode, EpisodeData, + EpisodeMentions, EpisodeResponse, Fact, FactRatingExamples, @@ -33,7 +34,6 @@ GraphNodesRequest, GraphSearchResults, GraphSearchScope, - GraphitiGraphSearchResults, Group, GroupListResponse, Memory, @@ -89,6 +89,7 @@ "EntityTypeResponse", "Episode", "EpisodeData", + "EpisodeMentions", "EpisodeResponse", "Fact", "FactRatingExamples", @@ -100,7 +101,6 @@ "GraphNodesRequest", "GraphSearchResults", "GraphSearchScope", - "GraphitiGraphSearchResults", "Group", "GroupListResponse", "InternalServerError", diff --git a/src/zep_cloud/graph/episode/client.py b/src/zep_cloud/graph/episode/client.py index cad581e2..cd4ebce5 100644 --- a/src/zep_cloud/graph/episode/client.py +++ b/src/zep_cloud/graph/episode/client.py @@ -13,8 +13,8 @@ from ...errors.not_found_error import NotFoundError from ...types.api_error import ApiError as types_api_error_ApiError from ...types.episode import Episode +from ...types.episode_mentions import EpisodeMentions from ...types.episode_response import EpisodeResponse -from ...types.graphiti_graph_search_results import GraphitiGraphSearchResults from ...types.success_response import SuccessResponse @@ -240,7 +240,7 @@ def delete(self, uuid_: str, *, request_options: typing.Optional[RequestOptions] def get_nodes_and_edges( self, uuid_: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> GraphitiGraphSearchResults: + ) -> EpisodeMentions: """ Returns nodes and edges mentioned in an episode @@ -254,8 +254,8 @@ def get_nodes_and_edges( Returns ------- - GraphitiGraphSearchResults - Graph search results + EpisodeMentions + Edges and nodes mentioned in an episode Examples -------- @@ -273,7 +273,7 @@ def get_nodes_and_edges( ) try: if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GraphitiGraphSearchResults, _response.json()) # type: ignore + return pydantic_v1.parse_obj_as(EpisodeMentions, _response.json()) # type: ignore if _response.status_code == 400: raise BadRequestError( pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore @@ -542,7 +542,7 @@ async def main() -> None: async def get_nodes_and_edges( self, uuid_: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> GraphitiGraphSearchResults: + ) -> EpisodeMentions: """ Returns nodes and edges mentioned in an episode @@ -556,8 +556,8 @@ async def get_nodes_and_edges( Returns ------- - GraphitiGraphSearchResults - Graph search results + EpisodeMentions + Edges and nodes mentioned in an episode Examples -------- @@ -583,7 +583,7 @@ async def main() -> None: ) try: if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GraphitiGraphSearchResults, _response.json()) # type: ignore + return pydantic_v1.parse_obj_as(EpisodeMentions, _response.json()) # type: ignore if _response.status_code == 400: raise BadRequestError( pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore diff --git a/src/zep_cloud/types/__init__.py b/src/zep_cloud/types/__init__.py index e0640edc..8f5d09d6 100644 --- a/src/zep_cloud/types/__init__.py +++ b/src/zep_cloud/types/__init__.py @@ -21,6 +21,7 @@ from .entity_type_response import EntityTypeResponse from .episode import Episode from .episode_data import EpisodeData +from .episode_mentions import EpisodeMentions from .episode_response import EpisodeResponse from .fact import Fact from .fact_rating_examples import FactRatingExamples @@ -32,7 +33,6 @@ from .graph_nodes_request import GraphNodesRequest from .graph_search_results import GraphSearchResults from .graph_search_scope import GraphSearchScope -from .graphiti_graph_search_results import GraphitiGraphSearchResults from .group import Group from .group_list_response import GroupListResponse from .memory import Memory @@ -81,6 +81,7 @@ "EntityTypeResponse", "Episode", "EpisodeData", + "EpisodeMentions", "EpisodeResponse", "Fact", "FactRatingExamples", @@ -92,7 +93,6 @@ "GraphNodesRequest", "GraphSearchResults", "GraphSearchScope", - "GraphitiGraphSearchResults", "Group", "GroupListResponse", "Memory", diff --git a/src/zep_cloud/types/graphiti_graph_search_results.py b/src/zep_cloud/types/episode_mentions.py similarity index 95% rename from src/zep_cloud/types/graphiti_graph_search_results.py rename to src/zep_cloud/types/episode_mentions.py index e1c0d663..f981e2b1 100644 --- a/src/zep_cloud/types/graphiti_graph_search_results.py +++ b/src/zep_cloud/types/episode_mentions.py @@ -9,7 +9,7 @@ from .entity_node import EntityNode -class GraphitiGraphSearchResults(pydantic_v1.BaseModel): +class EpisodeMentions(pydantic_v1.BaseModel): edges: typing.Optional[typing.List[EntityEdge]] = None nodes: typing.Optional[typing.List[EntityNode]] = None From f6663714975e1d728e3c91fab44b385f89c4a424 Mon Sep 17 00:00:00 2001 From: paulpaliychuk Date: Fri, 6 Jun 2025 16:03:09 -0400 Subject: [PATCH 20/28] chore: Set up set ontology method --- pyproject.toml | 2 +- src/zep_cloud/external_clients/graph.py | 154 ++++++++++++++++++++++++ 2 files changed, 155 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 4c5471e8..ef138ef3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "zep-cloud" -version = "2.14.0" +version = "2.14.1" description = "" readme = "README.md" authors = [] diff --git a/src/zep_cloud/external_clients/graph.py b/src/zep_cloud/external_clients/graph.py index d71a3da0..020d096c 100644 --- a/src/zep_cloud/external_clients/graph.py +++ b/src/zep_cloud/external_clients/graph.py @@ -15,6 +15,83 @@ def __init__(self, *, client_wrapper: SyncClientWrapper): client_wrapper=client_wrapper ) + def set_ontology( + self, + entities: dict[str, "EntityModel"], + edges: typing.Optional[dict[str, typing.Union["EdgeModel", typing.Tuple["EdgeModel", typing.List[EntityEdgeSourceTarget]]]]] = None, + request_options: typing.Optional[RequestOptions] = None, + ): + """ + Sets the entity and edge types for a project, replacing any existing ones. + + Parameters + ---------- + entities : dict[str, "EntityModel"] + + edges : typing.Optional[dict[str, typing.Union["EdgeModel", typing.Tuple["EdgeModel", typing.List[EntityEdgeSourceTarget]]]]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Examples + -------- + + class Destination(EntityModel): + + \"""A destination is a place that travelers visit.\""" + destination_name: EntityText = Field( + description="The name of the destination", + default=None + ) + country: EntityText = Field( + description="The country of the destination", + default=None + ) + region: EntityText = Field( + description="The region of the destination", + default=None + ) + description: EntityText = Field( + description="A description of the destination", + default=None + ) + + + class TravelingTo(EdgeModel): + + \"""An edge representing a traveler going to a destination.\""" + travel_date: EntityText = Field( + description="The date of travel to this destination", + default=None + ) + purpose: EntityText = Field( + description="The purpose of travel (Business, Leisure, etc.)", + default=None + ) + + client.graph.set_ontology( + entities={ + "Destination": Destination, + }, + edges={ + "TRAVELING_TO": ( + TravelingTo, + [ + EntityEdgeSourceTarget( + source="User", + target="Destination" + ) + ] + ), + } + ) + """ + return self.set_entity_types( + entities=entities, + edges=edges, + request_options=request_options, + ) + def set_entity_types( self, entities: dict[str, "EntityModel"], @@ -120,6 +197,83 @@ def __init__(self, *, client_wrapper: AsyncClientWrapper): client_wrapper=client_wrapper ) + async def set_ontology( + self, + entities: dict[str, "EntityModel"], + edges: typing.Optional[dict[str, typing.Union["EdgeModel", typing.Tuple["EdgeModel", typing.List[EntityEdgeSourceTarget]]]]] = None, + request_options: typing.Optional[RequestOptions] = None, + ): + """ + Sets the entity and edge types for a project, replacing any existing ones. + + Parameters + ---------- + entities : dict[str, "EntityModel"] + + edges : typing.Optional[dict[str, typing.Union["EdgeModel", typing.Tuple["EdgeModel", typing.List[EntityEdgeSourceTarget]]]]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Examples + -------- + + class Destination(EntityModel): + + \"""A destination is a place that travelers visit.\""" + destination_name: EntityText = Field( + description="The name of the destination", + default=None + ) + country: EntityText = Field( + description="The country of the destination", + default=None + ) + region: EntityText = Field( + description="The region of the destination", + default=None + ) + description: EntityText = Field( + description="A description of the destination", + default=None + ) + + + class TravelingTo(EdgeModel): + + \"""An edge representing a traveler going to a destination.\""" + travel_date: EntityText = Field( + description="The date of travel to this destination", + default=None + ) + purpose: EntityText = Field( + description="The purpose of travel (Business, Leisure, etc.)", + default=None + ) + + await client.graph.set_ontology( + entities={ + "Destination": Destination, + }, + edges={ + "TRAVELING_TO": ( + TravelingTo, + [ + EntityEdgeSourceTarget( + source="User", + target="Destination" + ) + ] + ), + } + ) + """ + return await self.set_entity_types( + entities=entities, + edges=edges, + request_options=request_options + ) + async def set_entity_types( self, entities: dict[str, "EntityModel"], From 574e6067a48a774d91b58fd91562ca544e4d8564 Mon Sep 17 00:00:00 2001 From: paulpaliychuk Date: Wed, 18 Jun 2025 13:24:22 -0400 Subject: [PATCH 21/28] chore: Bump version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ef138ef3..782e9a8d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "zep-cloud" -version = "2.14.1" +version = "2.15.0" description = "" readme = "README.md" authors = [] From 8a6d79b5e1a02ae32e6dd6e847eae8b849f31eed Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Wed, 18 Jun 2025 17:26:16 +0000 Subject: [PATCH 22/28] SDK regeneration --- reference.md | 8 ++++++++ src/zep_cloud/core/client_wrapper.py | 2 +- src/zep_cloud/graph/client.py | 10 ++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/reference.md b/reference.md index d4f42917..e545c0ec 100644 --- a/reference.md +++ b/reference.md @@ -1658,6 +1658,14 @@ client.graph.search(
+**bfs_origin_node_uuids:** `typing.Optional[typing.Sequence[str]]` — Nodes that are the origins of the BFS searches + +
+
+ +
+
+ **center_node_uuid:** `typing.Optional[str]` — Node to rerank around for node distance reranking
diff --git a/src/zep_cloud/core/client_wrapper.py b/src/zep_cloud/core/client_wrapper.py index 5677da7b..37a4f1c3 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.14.0", + "X-Fern-SDK-Version": "2.15.0", } headers["Authorization"] = f"Api-Key {self.api_key}" return headers diff --git a/src/zep_cloud/graph/client.py b/src/zep_cloud/graph/client.py index 97849207..b33f1000 100644 --- a/src/zep_cloud/graph/client.py +++ b/src/zep_cloud/graph/client.py @@ -413,6 +413,7 @@ def search( self, *, query: str, + bfs_origin_node_uuids: typing.Optional[typing.Sequence[str]] = OMIT, center_node_uuid: typing.Optional[str] = OMIT, group_id: typing.Optional[str] = OMIT, limit: typing.Optional[int] = OMIT, @@ -433,6 +434,9 @@ def search( query : str The string to search for (required) + bfs_origin_node_uuids : typing.Optional[typing.Sequence[str]] + Nodes that are the origins of the BFS searches + center_node_uuid : typing.Optional[str] Node to rerank around for node distance reranking @@ -486,6 +490,7 @@ def search( "graph/search", method="POST", json={ + "bfs_origin_node_uuids": bfs_origin_node_uuids, "center_node_uuid": center_node_uuid, "group_id": group_id, "limit": limit, @@ -940,6 +945,7 @@ async def search( self, *, query: str, + bfs_origin_node_uuids: typing.Optional[typing.Sequence[str]] = OMIT, center_node_uuid: typing.Optional[str] = OMIT, group_id: typing.Optional[str] = OMIT, limit: typing.Optional[int] = OMIT, @@ -960,6 +966,9 @@ async def search( query : str The string to search for (required) + bfs_origin_node_uuids : typing.Optional[typing.Sequence[str]] + Nodes that are the origins of the BFS searches + center_node_uuid : typing.Optional[str] Node to rerank around for node distance reranking @@ -1021,6 +1030,7 @@ async def main() -> None: "graph/search", method="POST", json={ + "bfs_origin_node_uuids": bfs_origin_node_uuids, "center_node_uuid": center_node_uuid, "group_id": group_id, "limit": limit, From dee4a4c064c1fc34765ba5e7bf4fa0503f5d69e8 Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Wed, 18 Jun 2025 18:05:18 +0000 Subject: [PATCH 23/28] SDK regeneration From ceabe944cf1d89f4f6416cbf912028ec21d6489b Mon Sep 17 00:00:00 2001 From: paulpaliychuk Date: Thu, 19 Jun 2025 22:48:33 -0400 Subject: [PATCH 24/28] chore: Bump version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 = [] From 62d14ef6f2acffb2523507a8ac98c9e7fbccf24e Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Fri, 20 Jun 2025 02:50:04 +0000 Subject: [PATCH 25/28] SDK regeneration --- reference.md | 92 ++++++++++++ src/zep_cloud/__init__.py | 2 + src/zep_cloud/core/client_wrapper.py | 2 +- src/zep_cloud/graph/client.py | 151 ++++++++++++++++++++ src/zep_cloud/types/__init__.py | 2 + src/zep_cloud/types/clone_graph_response.py | 30 ++++ 6 files changed, 278 insertions(+), 1 deletion(-) create mode 100644 src/zep_cloud/types/clone_graph_response.py diff --git a/reference.md b/reference.md index e545c0ec..6095a73d 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]` — Optional group_id to be set on the cloned group + +
+
+ +
+
+ +**target_user_id:** `typing.Optional[str]` — Optional user_id to be set on the cloned user + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ +
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/graph/client.py b/src/zep_cloud/graph/client.py index b33f1000..58253f19 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] + Optional group_id to be set on the cloned group + + target_user_id : typing.Optional[str] + Optional user_id to be set on the cloned user + + 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] + Optional group_id to be set on the cloned group + + target_user_id : typing.Optional[str] + Optional user_id to be set on the cloned user + + 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/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} From f091d804d7f46b226270287265c73c670c33d863 Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Fri, 20 Jun 2025 18:46:12 +0000 Subject: [PATCH 26/28] SDK regeneration --- reference.md | 4 ++-- src/zep_cloud/graph/client.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/reference.md b/reference.md index 6095a73d..f2f3a0d6 100644 --- a/reference.md +++ b/reference.md @@ -1664,7 +1664,7 @@ client.graph.clone()
-**target_group_id:** `typing.Optional[str]` — Optional group_id to be set on the cloned group +**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.
@@ -1672,7 +1672,7 @@ client.graph.clone()
-**target_user_id:** `typing.Optional[str]` — Optional user_id to be set on the cloned user +**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.
diff --git a/src/zep_cloud/graph/client.py b/src/zep_cloud/graph/client.py index 58253f19..47641d5b 100644 --- a/src/zep_cloud/graph/client.py +++ b/src/zep_cloud/graph/client.py @@ -431,10 +431,10 @@ def clone( user_id of the user whose graph is being cloned. Required if group_id is not provided target_group_id : typing.Optional[str] - Optional group_id to be set on the cloned group + 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] - Optional user_id to be set on the cloned user + 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. @@ -1034,10 +1034,10 @@ async def clone( user_id of the user whose graph is being cloned. Required if group_id is not provided target_group_id : typing.Optional[str] - Optional group_id to be set on the cloned group + 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] - Optional user_id to be set on the cloned user + 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. From 2b556a22354dcbcdbe56487a3e9f158aabed75e5 Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Fri, 20 Jun 2025 18:53:11 +0000 Subject: [PATCH 27/28] SDK regeneration --- reference.md | 4 ++-- src/zep_cloud/memory/client.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/reference.md b/reference.md index f2f3a0d6..d006e092 100644 --- a/reference.md +++ b/reference.md @@ -2570,7 +2570,7 @@ Fact rating instructions can not be unset.
-Classifies a session. +Deprecated: Classifies a session.
@@ -2768,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/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 ---------- From 38806fd25f91e3dbdeff0e5d3a570bef2dc760d9 Mon Sep 17 00:00:00 2001 From: paulpaliychuk Date: Fri, 20 Jun 2025 15:46:35 -0400 Subject: [PATCH 28/28] chore: Add deprecation notice to structured data extraction --- src/zep_cloud/external_clients/memory.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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.