zep-cloud 2.12.2__tar.gz → 2.13.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/PKG-INFO +1 -1
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/pyproject.toml +1 -1
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/__init__.py +4 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/core/client_wrapper.py +1 -1
- zep_cloud-2.13.0/src/zep_cloud/external_clients/graph.py +131 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/external_clients/ontology.py +53 -16
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/graph/client.py +13 -6
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/__init__.py +4 -0
- zep_cloud-2.13.0/src/zep_cloud/types/edge_type.py +34 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/entity_edge.py +5 -0
- zep_cloud-2.13.0/src/zep_cloud/types/entity_edge_source_target.py +37 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/entity_type_response.py +2 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/search_filters.py +5 -0
- zep_cloud-2.12.2/src/zep_cloud/external_clients/graph.py +0 -38
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/LICENSE +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/README.md +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/base_client.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/client.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/core/__init__.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/core/api_error.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/core/datetime_utils.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/core/file.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/core/http_client.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/core/jsonable_encoder.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/core/pydantic_utilities.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/core/query_encoder.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/core/remove_none_from_dict.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/core/request_options.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/document/__init__.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/document/client.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/environment.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/errors/__init__.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/errors/bad_request_error.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/errors/conflict_error.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/errors/internal_server_error.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/errors/not_found_error.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/errors/unauthorized_error.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/external_clients/document.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/external_clients/memory.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/external_clients/user.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/extractor/__init__.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/extractor/models.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/graph/__init__.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/graph/edge/__init__.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/graph/edge/client.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/graph/episode/__init__.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/graph/episode/client.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/graph/node/__init__.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/graph/node/client.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/group/__init__.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/group/client.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/memory/__init__.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/memory/client.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/py.typed +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/add_memory_response.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/add_triple_response.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/api_error.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/apidata_document.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/apidata_document_collection.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/apidata_document_search_response.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/apidata_document_with_score.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/classify_session_request.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/create_document_request.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/end_session_response.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/end_sessions_response.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/entity_node.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/entity_property.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/entity_property_type.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/entity_type.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/episode.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/episode_data.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/episode_response.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/fact.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/fact_rating_examples.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/fact_rating_instruction.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/fact_response.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/facts_response.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/graph_data_type.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/graph_edges_request.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/graph_nodes_request.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/graph_search_results.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/graph_search_scope.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/group.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/group_list_response.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/memory.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/memory_search_result.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/message.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/message_list_response.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/new_fact.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/question.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/reranker.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/role_type.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/search_scope.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/search_type.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/session.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/session_classification.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/session_list_response.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/session_search_response.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/session_search_result.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/success_response.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/summary.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/summary_list_response.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/update_document_list_request.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/user.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/user_list_response.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/user_node_response.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/user/__init__.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/user/client.py +0 -0
- {zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/version.py +0 -0
|
@@ -10,9 +10,11 @@ from .types import (
|
|
|
10
10
|
ApidataDocumentWithScore,
|
|
11
11
|
ClassifySessionRequest,
|
|
12
12
|
CreateDocumentRequest,
|
|
13
|
+
EdgeType,
|
|
13
14
|
EndSessionResponse,
|
|
14
15
|
EndSessionsResponse,
|
|
15
16
|
EntityEdge,
|
|
17
|
+
EntityEdgeSourceTarget,
|
|
16
18
|
EntityNode,
|
|
17
19
|
EntityProperty,
|
|
18
20
|
EntityPropertyType,
|
|
@@ -74,9 +76,11 @@ __all__ = [
|
|
|
74
76
|
"ClassifySessionRequest",
|
|
75
77
|
"ConflictError",
|
|
76
78
|
"CreateDocumentRequest",
|
|
79
|
+
"EdgeType",
|
|
77
80
|
"EndSessionResponse",
|
|
78
81
|
"EndSessionsResponse",
|
|
79
82
|
"EntityEdge",
|
|
83
|
+
"EntityEdgeSourceTarget",
|
|
80
84
|
"EntityNode",
|
|
81
85
|
"EntityProperty",
|
|
82
86
|
"EntityPropertyType",
|
|
@@ -17,7 +17,7 @@ class BaseClientWrapper:
|
|
|
17
17
|
headers: typing.Dict[str, str] = {
|
|
18
18
|
"X-Fern-Language": "Python",
|
|
19
19
|
"X-Fern-SDK-Name": "zep-cloud",
|
|
20
|
-
"X-Fern-SDK-Version": "2.
|
|
20
|
+
"X-Fern-SDK-Version": "2.13.0",
|
|
21
21
|
}
|
|
22
22
|
headers["Authorization"] = f"Api-Key {self.api_key}"
|
|
23
23
|
return headers
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
from zep_cloud import EntityEdgeSourceTarget, EdgeType
|
|
2
|
+
from zep_cloud.core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
3
|
+
from zep_cloud.external_clients.ontology import EdgeModel, edge_model_to_api_schema
|
|
4
|
+
from zep_cloud.graph.client import GraphClient as BaseGraphClient, AsyncGraphClient as AsyncBaseGraphClient
|
|
5
|
+
from zep_cloud.types import EntityType
|
|
6
|
+
import typing
|
|
7
|
+
from zep_cloud.external_clients.ontology import entity_model_to_api_schema
|
|
8
|
+
if typing.TYPE_CHECKING:
|
|
9
|
+
from zep_cloud.external_clients.ontology import EntityModel
|
|
10
|
+
from zep_cloud.core.request_options import RequestOptions
|
|
11
|
+
|
|
12
|
+
class GraphClient(BaseGraphClient):
|
|
13
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
14
|
+
super().__init__(
|
|
15
|
+
client_wrapper=client_wrapper
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
def set_entity_types(self, entities: dict[str, "EntityModel"], request_options: typing.Optional[RequestOptions] = None):
|
|
19
|
+
api_entity_types: list[EntityType] = []
|
|
20
|
+
for name, entity in entities.items():
|
|
21
|
+
entity_dict = entity_model_to_api_schema(entity, name)
|
|
22
|
+
api_entity_types.append(EntityType(**entity_dict))
|
|
23
|
+
res = self.set_entity_types_internal(entity_types=api_entity_types, request_options=request_options)
|
|
24
|
+
return res
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class AsyncGraphClient(AsyncBaseGraphClient):
|
|
28
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
29
|
+
super().__init__(
|
|
30
|
+
client_wrapper=client_wrapper
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
async def set_entity_types(
|
|
34
|
+
self,
|
|
35
|
+
entities: dict[str, "EntityModel"],
|
|
36
|
+
edges: typing.Optional[dict[str, typing.Union["EdgeModel", typing.Tuple["EdgeModel", typing.List[EntityEdgeSourceTarget]]]]] = None,
|
|
37
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
38
|
+
):
|
|
39
|
+
"""
|
|
40
|
+
Sets the entity and edge types for a project, replacing any existing ones.
|
|
41
|
+
|
|
42
|
+
Parameters
|
|
43
|
+
----------
|
|
44
|
+
entities : dict[str, "EntityModel"]
|
|
45
|
+
|
|
46
|
+
edges : typing.Optional[dict[str, typing.Union["EdgeModel", typing.Tuple["EdgeModel", typing.List[EntityEdgeSourceTarget]]]]]
|
|
47
|
+
|
|
48
|
+
request_options : typing.Optional[RequestOptions]
|
|
49
|
+
Request-specific configuration.
|
|
50
|
+
|
|
51
|
+
Examples
|
|
52
|
+
--------
|
|
53
|
+
|
|
54
|
+
class Destination(EntityModel):
|
|
55
|
+
|
|
56
|
+
\"""A destination is a place that travelers visit.\"""
|
|
57
|
+
destination_name: EntityText = Field(
|
|
58
|
+
description="The name of the destination",
|
|
59
|
+
default=None
|
|
60
|
+
)
|
|
61
|
+
country: EntityText = Field(
|
|
62
|
+
description="The country of the destination",
|
|
63
|
+
default=None
|
|
64
|
+
)
|
|
65
|
+
region: EntityText = Field(
|
|
66
|
+
description="The region of the destination",
|
|
67
|
+
default=None
|
|
68
|
+
)
|
|
69
|
+
description: EntityText = Field(
|
|
70
|
+
description="A description of the destination",
|
|
71
|
+
default=None
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class TravelingTo(EdgeModel):
|
|
76
|
+
|
|
77
|
+
\"""An edge representing a traveler going to a destination.\"""
|
|
78
|
+
travel_date: EntityText = Field(
|
|
79
|
+
description="The date of travel to this destination",
|
|
80
|
+
default=None
|
|
81
|
+
)
|
|
82
|
+
purpose: EntityText = Field(
|
|
83
|
+
description="The purpose of travel (Business, Leisure, etc.)",
|
|
84
|
+
default=None
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
await client.graph.set_entity_types(
|
|
88
|
+
entities={
|
|
89
|
+
"Destination": Destination,
|
|
90
|
+
},
|
|
91
|
+
edges={
|
|
92
|
+
"TRAVELING_TO": (
|
|
93
|
+
TravelingTo,
|
|
94
|
+
[
|
|
95
|
+
EntityEdgeSourceTarget(
|
|
96
|
+
source="User",
|
|
97
|
+
target="Destination"
|
|
98
|
+
)
|
|
99
|
+
]
|
|
100
|
+
),
|
|
101
|
+
}
|
|
102
|
+
)
|
|
103
|
+
"""
|
|
104
|
+
api_entity_types: list[EntityType] = []
|
|
105
|
+
api_edge_types: list[EdgeType] = []
|
|
106
|
+
|
|
107
|
+
for name, entity in entities.items():
|
|
108
|
+
entity_dict = entity_model_to_api_schema(entity, name)
|
|
109
|
+
api_entity_types.append(EntityType(**entity_dict))
|
|
110
|
+
|
|
111
|
+
if edges:
|
|
112
|
+
for name, edge_data in edges.items():
|
|
113
|
+
# Handle both EdgeModel directly and tuple of (model, source_targets)
|
|
114
|
+
if isinstance(edge_data, tuple):
|
|
115
|
+
edge_model, source_targets = edge_data
|
|
116
|
+
else:
|
|
117
|
+
edge_model = edge_data
|
|
118
|
+
source_targets = None
|
|
119
|
+
|
|
120
|
+
edge_dict = edge_model_to_api_schema(edge_model, name)
|
|
121
|
+
if source_targets:
|
|
122
|
+
edge_dict["source_targets"] = [st.dict() for st in source_targets]
|
|
123
|
+
api_edge_types.append(EdgeType(**edge_dict))
|
|
124
|
+
|
|
125
|
+
res = await self.set_entity_types_internal(
|
|
126
|
+
entity_types=api_entity_types,
|
|
127
|
+
edge_types=api_edge_types,
|
|
128
|
+
request_options=request_options
|
|
129
|
+
)
|
|
130
|
+
return res
|
|
131
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from enum import Enum
|
|
2
2
|
import typing
|
|
3
|
-
from pydantic import BaseModel, Field, WithJsonSchema
|
|
3
|
+
from pydantic import BaseModel, Field, WithJsonSchema, create_model
|
|
4
4
|
from typing_extensions import Annotated
|
|
5
5
|
from pydantic.json_schema import GenerateJsonSchema, JsonSchemaValue
|
|
6
6
|
from pydantic_core import core_schema
|
|
@@ -12,20 +12,34 @@ class EntityPropertyType(Enum):
|
|
|
12
12
|
Boolean = "Boolean"
|
|
13
13
|
|
|
14
14
|
class EntityField(BaseModel):
|
|
15
|
+
"""Base class for entity field definitions"""
|
|
15
16
|
description: str
|
|
17
|
+
type: EntityPropertyType
|
|
16
18
|
|
|
17
19
|
class EntityBaseText(EntityField):
|
|
20
|
+
"""Entity field with Text type"""
|
|
18
21
|
type: EntityPropertyType = EntityPropertyType.Text
|
|
19
22
|
|
|
20
23
|
class EntityBaseInt(EntityField):
|
|
24
|
+
"""Entity field with Int type"""
|
|
21
25
|
type: EntityPropertyType = EntityPropertyType.Int
|
|
22
26
|
|
|
23
27
|
class EntityBaseFloat(EntityField):
|
|
28
|
+
"""Entity field with Float type"""
|
|
24
29
|
type: EntityPropertyType = EntityPropertyType.Float
|
|
25
30
|
|
|
26
31
|
class EntityBaseBoolean(EntityField):
|
|
32
|
+
"""Entity field with Boolean type"""
|
|
27
33
|
type: EntityPropertyType = EntityPropertyType.Boolean
|
|
28
34
|
|
|
35
|
+
# Annotated types for entity properties
|
|
36
|
+
# These types are used to define the properties of entity and edge models
|
|
37
|
+
# Each type includes:
|
|
38
|
+
# 1. The base Python type (str, int, float, bool)
|
|
39
|
+
# 2. A default value of None
|
|
40
|
+
# 3. Entity type information
|
|
41
|
+
# 4. JSON schema information for serialization
|
|
42
|
+
|
|
29
43
|
EntityText = Annotated[
|
|
30
44
|
typing.Optional[str],
|
|
31
45
|
Field(default=None),
|
|
@@ -62,28 +76,41 @@ class _CustomJsonSchema(GenerateJsonSchema):
|
|
|
62
76
|
def nullable_schema(self, schema: core_schema.CoreSchema) -> JsonSchemaValue:
|
|
63
77
|
return self.generate_inner(schema["schema"])
|
|
64
78
|
|
|
65
|
-
class
|
|
79
|
+
class _BaseSchemaModel(BaseModel):
|
|
80
|
+
"""Base class for models that need custom JSON schema generation"""
|
|
66
81
|
@classmethod
|
|
67
82
|
def model_json_schema(cls, *args, **kwargs):
|
|
68
83
|
kwargs["schema_generator"] = _CustomJsonSchema
|
|
69
84
|
return super().model_json_schema(*args, **kwargs)
|
|
70
85
|
|
|
71
|
-
|
|
72
|
-
"""
|
|
73
|
-
|
|
86
|
+
class EntityModel(_BaseSchemaModel):
|
|
87
|
+
"""Entity model for representing entity types"""
|
|
88
|
+
pass
|
|
89
|
+
|
|
90
|
+
class EdgeModel(_BaseSchemaModel):
|
|
91
|
+
"""Edge model for representing edge types"""
|
|
92
|
+
pass
|
|
93
|
+
|
|
94
|
+
def _model_to_api_schema_common(model_class: typing.Union["EntityModel", "EdgeModel"], name: str, is_edge: bool = False) -> dict[str, typing.Any]:
|
|
95
|
+
"""Common function to convert a Pydantic Model to a JSON schema for API EntityType or EdgeType"""
|
|
96
|
+
|
|
74
97
|
schema = model_class.model_json_schema()
|
|
75
|
-
|
|
76
|
-
# Define the
|
|
77
|
-
|
|
98
|
+
|
|
99
|
+
# Define the type with proper typings for properties as a list of dictionaries
|
|
100
|
+
result_type: dict[str, typing.Any] = {
|
|
78
101
|
"name": name,
|
|
79
102
|
"description": model_class.__doc__.strip() if model_class.__doc__ else "",
|
|
80
103
|
"properties": []
|
|
81
104
|
}
|
|
82
|
-
|
|
105
|
+
|
|
106
|
+
# Add source_targets field for edge types
|
|
107
|
+
if is_edge:
|
|
108
|
+
result_type["source_targets"] = []
|
|
109
|
+
|
|
83
110
|
for field_name, field_schema in schema.get("properties", {}).items():
|
|
84
111
|
if "type" not in field_schema:
|
|
85
112
|
continue
|
|
86
|
-
|
|
113
|
+
|
|
87
114
|
property_type = field_schema.get("type")
|
|
88
115
|
type_mapping = {
|
|
89
116
|
"string": "Text",
|
|
@@ -91,19 +118,29 @@ def entity_model_to_api_schema(model_class: "EntityModel", name: str) -> dict[st
|
|
|
91
118
|
"number": "Float",
|
|
92
119
|
"boolean": "Boolean"
|
|
93
120
|
}
|
|
94
|
-
|
|
121
|
+
|
|
95
122
|
if property_type in type_mapping:
|
|
96
123
|
property_type = type_mapping[property_type]
|
|
97
124
|
else:
|
|
98
125
|
raise ValueError(f"Unsupported property type: {property_type}")
|
|
99
|
-
|
|
126
|
+
|
|
100
127
|
description = field_schema.get("description", "")
|
|
101
|
-
|
|
102
|
-
|
|
128
|
+
|
|
129
|
+
result_type["properties"].append({
|
|
103
130
|
"name": field_name,
|
|
104
131
|
"type": property_type,
|
|
105
132
|
"description": description
|
|
106
133
|
})
|
|
107
|
-
|
|
108
|
-
return
|
|
134
|
+
|
|
135
|
+
return result_type
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def entity_model_to_api_schema(model_class: "EntityModel", name: str) -> dict[str, typing.Any]:
|
|
139
|
+
"""Convert a Pydantic EntityModel to a JSON schema for API EntityType"""
|
|
140
|
+
return _model_to_api_schema_common(model_class, name, is_edge=False)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def edge_model_to_api_schema(model_class: "EdgeModel", name: str) -> dict[str, typing.Any]:
|
|
144
|
+
"""Convert a Pydantic EdgeModel to a JSON schema for API EntityEdge"""
|
|
145
|
+
return _model_to_api_schema_common(model_class, name, is_edge=True)
|
|
109
146
|
|
|
@@ -12,6 +12,7 @@ from ..errors.internal_server_error import InternalServerError
|
|
|
12
12
|
from ..errors.not_found_error import NotFoundError
|
|
13
13
|
from ..types.add_triple_response import AddTripleResponse
|
|
14
14
|
from ..types.api_error import ApiError as types_api_error_ApiError
|
|
15
|
+
from ..types.edge_type import EdgeType
|
|
15
16
|
from ..types.entity_type import EntityType
|
|
16
17
|
from ..types.entity_type_response import EntityTypeResponse
|
|
17
18
|
from ..types.episode import Episode
|
|
@@ -82,6 +83,7 @@ class GraphClient:
|
|
|
82
83
|
def set_entity_types_internal(
|
|
83
84
|
self,
|
|
84
85
|
*,
|
|
86
|
+
edge_types: typing.Optional[typing.Sequence[EdgeType]] = OMIT,
|
|
85
87
|
entity_types: typing.Optional[typing.Sequence[EntityType]] = OMIT,
|
|
86
88
|
request_options: typing.Optional[RequestOptions] = None
|
|
87
89
|
) -> SuccessResponse:
|
|
@@ -90,6 +92,8 @@ class GraphClient:
|
|
|
90
92
|
|
|
91
93
|
Parameters
|
|
92
94
|
----------
|
|
95
|
+
edge_types : typing.Optional[typing.Sequence[EdgeType]]
|
|
96
|
+
|
|
93
97
|
entity_types : typing.Optional[typing.Sequence[EntityType]]
|
|
94
98
|
|
|
95
99
|
request_options : typing.Optional[RequestOptions]
|
|
@@ -112,7 +116,7 @@ class GraphClient:
|
|
|
112
116
|
_response = self._client_wrapper.httpx_client.request(
|
|
113
117
|
"entity-types",
|
|
114
118
|
method="PUT",
|
|
115
|
-
json={"entity_types": entity_types},
|
|
119
|
+
json={"edge_types": edge_types, "entity_types": entity_types},
|
|
116
120
|
request_options=request_options,
|
|
117
121
|
omit=OMIT,
|
|
118
122
|
)
|
|
@@ -144,7 +148,7 @@ class GraphClient:
|
|
|
144
148
|
request_options: typing.Optional[RequestOptions] = None
|
|
145
149
|
) -> Episode:
|
|
146
150
|
"""
|
|
147
|
-
Add data to the graph.
|
|
151
|
+
Add data to the graph.
|
|
148
152
|
|
|
149
153
|
Parameters
|
|
150
154
|
----------
|
|
@@ -219,7 +223,7 @@ class GraphClient:
|
|
|
219
223
|
request_options: typing.Optional[RequestOptions] = None
|
|
220
224
|
) -> typing.List[Episode]:
|
|
221
225
|
"""
|
|
222
|
-
Add data to the graph in batch mode
|
|
226
|
+
Add data to the graph in batch mode, processing episodes concurrently. Use only for data that is insensitive to processing order.
|
|
223
227
|
|
|
224
228
|
Parameters
|
|
225
229
|
----------
|
|
@@ -574,6 +578,7 @@ class AsyncGraphClient:
|
|
|
574
578
|
async def set_entity_types_internal(
|
|
575
579
|
self,
|
|
576
580
|
*,
|
|
581
|
+
edge_types: typing.Optional[typing.Sequence[EdgeType]] = OMIT,
|
|
577
582
|
entity_types: typing.Optional[typing.Sequence[EntityType]] = OMIT,
|
|
578
583
|
request_options: typing.Optional[RequestOptions] = None
|
|
579
584
|
) -> SuccessResponse:
|
|
@@ -582,6 +587,8 @@ class AsyncGraphClient:
|
|
|
582
587
|
|
|
583
588
|
Parameters
|
|
584
589
|
----------
|
|
590
|
+
edge_types : typing.Optional[typing.Sequence[EdgeType]]
|
|
591
|
+
|
|
585
592
|
entity_types : typing.Optional[typing.Sequence[EntityType]]
|
|
586
593
|
|
|
587
594
|
request_options : typing.Optional[RequestOptions]
|
|
@@ -612,7 +619,7 @@ class AsyncGraphClient:
|
|
|
612
619
|
_response = await self._client_wrapper.httpx_client.request(
|
|
613
620
|
"entity-types",
|
|
614
621
|
method="PUT",
|
|
615
|
-
json={"entity_types": entity_types},
|
|
622
|
+
json={"edge_types": edge_types, "entity_types": entity_types},
|
|
616
623
|
request_options=request_options,
|
|
617
624
|
omit=OMIT,
|
|
618
625
|
)
|
|
@@ -644,7 +651,7 @@ class AsyncGraphClient:
|
|
|
644
651
|
request_options: typing.Optional[RequestOptions] = None
|
|
645
652
|
) -> Episode:
|
|
646
653
|
"""
|
|
647
|
-
Add data to the graph.
|
|
654
|
+
Add data to the graph.
|
|
648
655
|
|
|
649
656
|
Parameters
|
|
650
657
|
----------
|
|
@@ -727,7 +734,7 @@ class AsyncGraphClient:
|
|
|
727
734
|
request_options: typing.Optional[RequestOptions] = None
|
|
728
735
|
) -> typing.List[Episode]:
|
|
729
736
|
"""
|
|
730
|
-
Add data to the graph in batch mode
|
|
737
|
+
Add data to the graph in batch mode, processing episodes concurrently. Use only for data that is insensitive to processing order.
|
|
731
738
|
|
|
732
739
|
Parameters
|
|
733
740
|
----------
|
|
@@ -9,9 +9,11 @@ from .apidata_document_search_response import ApidataDocumentSearchResponse
|
|
|
9
9
|
from .apidata_document_with_score import ApidataDocumentWithScore
|
|
10
10
|
from .classify_session_request import ClassifySessionRequest
|
|
11
11
|
from .create_document_request import CreateDocumentRequest
|
|
12
|
+
from .edge_type import EdgeType
|
|
12
13
|
from .end_session_response import EndSessionResponse
|
|
13
14
|
from .end_sessions_response import EndSessionsResponse
|
|
14
15
|
from .entity_edge import EntityEdge
|
|
16
|
+
from .entity_edge_source_target import EntityEdgeSourceTarget
|
|
15
17
|
from .entity_node import EntityNode
|
|
16
18
|
from .entity_property import EntityProperty
|
|
17
19
|
from .entity_property_type import EntityPropertyType
|
|
@@ -66,9 +68,11 @@ __all__ = [
|
|
|
66
68
|
"ApidataDocumentWithScore",
|
|
67
69
|
"ClassifySessionRequest",
|
|
68
70
|
"CreateDocumentRequest",
|
|
71
|
+
"EdgeType",
|
|
69
72
|
"EndSessionResponse",
|
|
70
73
|
"EndSessionsResponse",
|
|
71
74
|
"EntityEdge",
|
|
75
|
+
"EntityEdgeSourceTarget",
|
|
72
76
|
"EntityNode",
|
|
73
77
|
"EntityProperty",
|
|
74
78
|
"EntityPropertyType",
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import datetime as dt
|
|
4
|
+
import typing
|
|
5
|
+
|
|
6
|
+
from ..core.datetime_utils import serialize_datetime
|
|
7
|
+
from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1
|
|
8
|
+
from .entity_edge_source_target import EntityEdgeSourceTarget
|
|
9
|
+
from .entity_property import EntityProperty
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class EdgeType(pydantic_v1.BaseModel):
|
|
13
|
+
description: str
|
|
14
|
+
name: str
|
|
15
|
+
properties: typing.Optional[typing.List[EntityProperty]] = None
|
|
16
|
+
source_targets: typing.Optional[typing.List[EntityEdgeSourceTarget]] = None
|
|
17
|
+
|
|
18
|
+
def json(self, **kwargs: typing.Any) -> str:
|
|
19
|
+
kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
|
|
20
|
+
return super().json(**kwargs_with_defaults)
|
|
21
|
+
|
|
22
|
+
def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
|
|
23
|
+
kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
|
|
24
|
+
kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs}
|
|
25
|
+
|
|
26
|
+
return deep_union_pydantic_dicts(
|
|
27
|
+
super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none)
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
class Config:
|
|
31
|
+
frozen = True
|
|
32
|
+
smart_union = True
|
|
33
|
+
extra = pydantic_v1.Extra.allow
|
|
34
|
+
json_encoders = {dt.datetime: serialize_datetime}
|
|
@@ -8,6 +8,11 @@ from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class EntityEdge(pydantic_v1.BaseModel):
|
|
11
|
+
attributes: typing.Optional[typing.Dict[str, typing.Any]] = pydantic_v1.Field(default=None)
|
|
12
|
+
"""
|
|
13
|
+
Additional attributes of the edge. Dependent on edge types
|
|
14
|
+
"""
|
|
15
|
+
|
|
11
16
|
created_at: str = pydantic_v1.Field()
|
|
12
17
|
"""
|
|
13
18
|
Creation time of the edge
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import datetime as dt
|
|
4
|
+
import typing
|
|
5
|
+
|
|
6
|
+
from ..core.datetime_utils import serialize_datetime
|
|
7
|
+
from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class EntityEdgeSourceTarget(pydantic_v1.BaseModel):
|
|
11
|
+
source: typing.Optional[str] = pydantic_v1.Field(default=None)
|
|
12
|
+
"""
|
|
13
|
+
Source represents the originating node identifier in the edge type relationship. (optional)
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
target: typing.Optional[str] = pydantic_v1.Field(default=None)
|
|
17
|
+
"""
|
|
18
|
+
Target represents the target node identifier in the edge type relationship. (optional)
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
def json(self, **kwargs: typing.Any) -> str:
|
|
22
|
+
kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
|
|
23
|
+
return super().json(**kwargs_with_defaults)
|
|
24
|
+
|
|
25
|
+
def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
|
|
26
|
+
kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
|
|
27
|
+
kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs}
|
|
28
|
+
|
|
29
|
+
return deep_union_pydantic_dicts(
|
|
30
|
+
super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none)
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
class Config:
|
|
34
|
+
frozen = True
|
|
35
|
+
smart_union = True
|
|
36
|
+
extra = pydantic_v1.Extra.allow
|
|
37
|
+
json_encoders = {dt.datetime: serialize_datetime}
|
|
@@ -5,10 +5,12 @@ import typing
|
|
|
5
5
|
|
|
6
6
|
from ..core.datetime_utils import serialize_datetime
|
|
7
7
|
from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1
|
|
8
|
+
from .edge_type import EdgeType
|
|
8
9
|
from .entity_type import EntityType
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
class EntityTypeResponse(pydantic_v1.BaseModel):
|
|
13
|
+
edge_types: typing.Optional[typing.List[EdgeType]] = None
|
|
12
14
|
entity_types: typing.Optional[typing.List[EntityType]] = None
|
|
13
15
|
|
|
14
16
|
def json(self, **kwargs: typing.Any) -> str:
|
|
@@ -8,6 +8,11 @@ from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class SearchFilters(pydantic_v1.BaseModel):
|
|
11
|
+
edge_types: typing.Optional[typing.List[str]] = pydantic_v1.Field(default=None)
|
|
12
|
+
"""
|
|
13
|
+
List of edge types to filter on
|
|
14
|
+
"""
|
|
15
|
+
|
|
11
16
|
node_labels: typing.Optional[typing.List[str]] = pydantic_v1.Field(default=None)
|
|
12
17
|
"""
|
|
13
18
|
List of node labels to filter on
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
from zep_cloud.core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
2
|
-
from zep_cloud.graph.client import GraphClient as BaseGraphClient, AsyncGraphClient as AsyncBaseGraphClient
|
|
3
|
-
from zep_cloud.types import EntityType
|
|
4
|
-
import typing
|
|
5
|
-
from zep_cloud.external_clients.ontology import entity_model_to_api_schema
|
|
6
|
-
if typing.TYPE_CHECKING:
|
|
7
|
-
from zep_cloud.external_clients.ontology import EntityModel
|
|
8
|
-
from zep_cloud.core.request_options import RequestOptions
|
|
9
|
-
|
|
10
|
-
class GraphClient(BaseGraphClient):
|
|
11
|
-
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
12
|
-
super().__init__(
|
|
13
|
-
client_wrapper=client_wrapper
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
def set_entity_types(self, entities: dict[str, "EntityModel"], request_options: typing.Optional[RequestOptions] = None):
|
|
17
|
-
api_entity_types: list[EntityType] = []
|
|
18
|
-
for name, entity in entities.items():
|
|
19
|
-
entity_dict = entity_model_to_api_schema(entity, name)
|
|
20
|
-
api_entity_types.append(EntityType(**entity_dict))
|
|
21
|
-
res = self.set_entity_types_internal(entity_types=api_entity_types, request_options=request_options)
|
|
22
|
-
return res
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
class AsyncGraphClient(AsyncBaseGraphClient):
|
|
26
|
-
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
27
|
-
super().__init__(
|
|
28
|
-
client_wrapper=client_wrapper
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
async def set_entity_types(self, entities: dict[str, "EntityModel"], request_options: typing.Optional[RequestOptions] = None):
|
|
32
|
-
api_entity_types: list[EntityType] = []
|
|
33
|
-
for name, entity in entities.items():
|
|
34
|
-
entity_dict = entity_model_to_api_schema(entity, name)
|
|
35
|
-
api_entity_types.append(EntityType(**entity_dict))
|
|
36
|
-
res = await self.set_entity_types_internal(entity_types=api_entity_types, request_options=request_options)
|
|
37
|
-
return res
|
|
38
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{zep_cloud-2.12.2 → zep_cloud-2.13.0}/src/zep_cloud/types/apidata_document_search_response.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|