|
5 | 5 | from pydantic.json_schema import GenerateJsonSchema, JsonSchemaValue
|
6 | 6 | from pydantic_core import core_schema
|
7 | 7 |
|
8 |
| -from zep_cloud import EntityEdgeSourceTarget, EntityType |
9 |
| - |
10 |
| - |
11 | 8 | class EntityPropertyType(Enum):
|
12 | 9 | Text = "Text"
|
13 | 10 | Int = "Int"
|
@@ -147,61 +144,3 @@ def edge_model_to_api_schema(model_class: "EdgeModel", name: str) -> dict[str, t
|
147 | 144 | """Convert a Pydantic EdgeModel to a JSON schema for API EntityEdge"""
|
148 | 145 | return _model_to_api_schema_common(model_class, name, is_edge=True)
|
149 | 146 |
|
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