Skip to content

Commit 6a5be5e

Browse files
simplify ontology client
1 parent cc47bdf commit 6a5be5e

File tree

1 file changed

+0
-61
lines changed

1 file changed

+0
-61
lines changed

src/zep_cloud/external_clients/ontology.py

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
from pydantic.json_schema import GenerateJsonSchema, JsonSchemaValue
66
from pydantic_core import core_schema
77

8-
from zep_cloud import EntityEdgeSourceTarget, EntityType
9-
10-
118
class EntityPropertyType(Enum):
129
Text = "Text"
1310
Int = "Int"
@@ -147,61 +144,3 @@ def edge_model_to_api_schema(model_class: "EdgeModel", name: str) -> dict[str, t
147144
"""Convert a Pydantic EdgeModel to a JSON schema for API EntityEdge"""
148145
return _model_to_api_schema_common(model_class, name, is_edge=True)
149146

150-
151-
def convert_edge_schema_to_model(edge_schema: EntityType) -> (typing.Type[EdgeModel], list[EntityEdgeSourceTarget]):
152-
"""
153-
Convert a JSON schema from Go EntityType back to a Pydantic EdgeModel class
154-
155-
This function takes an EntityType object (which can represent an edge type in the API)
156-
and converts it to a Pydantic EdgeModel class. It maps the properties from the EntityType
157-
to the appropriate Pydantic field types (EntityText, EntityInt, etc.) and creates a new
158-
model class dynamically using create_model.
159-
160-
Args:
161-
edge_schema: The EntityType object representing an edge type
162-
163-
Returns:
164-
A tuple containing:
165-
- The dynamically created EdgeModel class
166-
- The list of source_targets from the edge_schema
167-
"""
168-
169-
edge_name = edge_schema.name
170-
properties = edge_schema.properties
171-
edge_description = edge_schema.description
172-
173-
field_definitions: dict[str, typing.Any] = {}
174-
175-
type_mapping = {
176-
'Text': EntityText,
177-
'Int': EntityInt,
178-
'Float': EntityFloat,
179-
'Boolean': EntityBoolean,
180-
}
181-
182-
for prop in properties:
183-
prop_name = prop.name
184-
prop_type = prop.type
185-
prop_description = prop.description
186-
187-
if not prop_name or not prop_type:
188-
continue
189-
190-
field_type = type_mapping.get(prop_type)
191-
if not field_type:
192-
continue
193-
194-
field_definitions[prop_name] = (
195-
field_type,
196-
Field(description=prop_description, default=None),
197-
)
198-
199-
model_class = create_model(
200-
edge_name,
201-
__base__=EntityModel,
202-
__module__=EntityModel.__module__,
203-
__doc__=edge_description,
204-
**field_definitions,
205-
)
206-
207-
return model_class, edge_schema.source_targets

0 commit comments

Comments
 (0)