Core Models
grizabella.core.models
Core Pydantic models for Grizabella schema definitions and instances.
EmbeddingDefinition
Bases: BaseModel
Defines how an embedding should be generated and stored for an ObjectTypeDefinition
.
This model specifies the configuration for creating vector embeddings from the content of objects. It links an object type and one of its properties to an embedding model.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
:noindex: A unique name for this embedding configuration (e.g., 'content_embedding_v1'). Conventionally, snake_case is used. |
object_type_name |
str
|
:noindex: The name of the |
source_property_name |
str
|
:noindex: The name of the property within the
specified |
embedding_model |
str
|
:noindex: An identifier for the embedding model to be used (e.g., a Hugging Face model name like 'huggingface/mixedbread-ai/mxbai-embed-large-v1'). |
dimensions |
Optional[int]
|
:noindex: The expected dimensionality of the embedding vector. If None, the system may attempt to infer it from the model. |
description |
Optional[str]
|
:noindex: An optional human-readable description of this embedding definition. |
Source code in grizabella/core/models.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
|
EmbeddingInstance
Bases: MemoryInstance
Represents an instance of an embedding, linked to an ObjectInstance
.
This model stores a vector embedding generated from a specific property of
an ObjectInstance
, according to an EmbeddingDefinition
. It inherits
common metadata fields from MemoryInstance
.
Attributes:
Name | Type | Description |
---|---|---|
object_instance_id |
UUID
|
:noindex: The ID of the |
embedding_definition_name |
str
|
:noindex: The name of the |
vector |
List[float]
|
:noindex: The actual embedding vector, represented as a list of floating-point numbers. |
source_text_preview |
Optional[str]
|
:noindex: A truncated preview of the source text that was used to generate the embedding. This can be useful for quick inspection or debugging. |
Source code in grizabella/core/models.py
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 |
|
MemoryInstance
Bases: BaseModel
Base model for all storable instances, providing common metadata.
This model includes fields that are common to all persistent entities within Grizabella, such as a unique identifier, a weight for ranking or relevance, and an upsert timestamp.
Attributes:
Name | Type | Description |
---|---|---|
id |
UUID
|
:noindex: A unique identifier for the instance, generated by default. |
weight |
condecimal
|
:noindex: A decimal value between 0 and 10 (inclusive) representing the importance or relevance of the instance. Used for ranking or filtering. Defaults to 1.0. |
upsert_date |
datetime
|
:noindex: The timestamp (UTC) when the instance was last created or updated. Automatically set on creation/update. |
Source code in grizabella/core/models.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
|
ObjectInstance
Bases: MemoryInstance
Represents a concrete instance of an ObjectTypeDefinition
.
This model holds the actual data for an individual object, conforming to
the schema defined by its ObjectTypeDefinition
. It inherits common
metadata fields from MemoryInstance
.
Attributes:
Name | Type | Description |
---|---|---|
object_type_name |
str
|
:noindex: The name of the |
properties |
Dict[str, Any]
|
:noindex: A dictionary containing the actual data
for the instance, mapping property names (as defined in the
|
Source code in grizabella/core/models.py
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 |
|
ObjectTypeDefinition
Bases: BaseModel
Defines the schema for a type of object (e.g., a node in a graph, a table row).
An ObjectTypeDefinition
specifies the structure for a category of data
entities. It includes a unique name, an optional description, and a list
of PropertyDefinition
s that define its attributes.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
:noindex: A unique name for the object type (e.g., 'Document', 'Person'). Conventionally, PascalCase is used. |
description |
Optional[str]
|
:noindex: An optional human-readable description of what this object type represents. |
properties |
List[PropertyDefinition]
|
:noindex: A list of properties that define the attributes of this object type. |
Source code in grizabella/core/models.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
|
check_primary_key_once(v)
classmethod
Ensures that an ObjectTypeDefinition has at most one primary key.
While the id
field from MemoryInstance
serves as a unique identifier
for ObjectInstance
s, an ObjectTypeDefinition
can optionally define
one of its properties as a primary key for domain-specific identification
or for database layers that require an explicit primary key column.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
v |
List[PropertyDefinition]
|
The list of properties being validated. |
required |
Returns:
Type | Description |
---|---|
list[PropertyDefinition]
|
List[PropertyDefinition]: The validated list of properties. |
Raises:
Type | Description |
---|---|
ValueError
|
If more than one property is marked as |
Source code in grizabella/core/models.py
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
|
PropertyDataType
Bases: str
, Enum
Enumeration of supported data types for object and relation properties.
This enum defines the set of primitive data types that can be used when
defining properties for ObjectTypeDefinition
and RelationTypeDefinition
.
These types guide data validation and storage.
Attributes:
Name | Type | Description |
---|---|---|
TEXT |
A string of text. |
|
INTEGER |
A whole number. |
|
FLOAT |
A floating-point number. |
|
BOOLEAN |
A true or false value. |
|
DATETIME |
A date and time value, typically stored in UTC. |
|
BLOB |
Binary Large Object, for storing raw binary data. |
|
JSON |
A JSON object or array, for semi-structured data. |
|
UUID |
A universally unique identifier. |
Source code in grizabella/core/models.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
|
PropertyDefinition
Bases: BaseModel
Defines a single property within an ObjectTypeDefinition
or RelationTypeDefinition
.
This model specifies the characteristics of a property, such as its name, data type, and constraints (e.g., nullable, unique, indexed).
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
:noindex: The name of the property (e.g., 'title', 'age'). This name is used to access the property's value in instances. |
data_type |
PropertyDataType
|
:noindex: The data type of the property. |
is_primary_key |
bool
|
:noindex: Indicates if this property serves as a primary
key for its |
is_nullable |
bool
|
:noindex: Specifies whether this property can have a null value. Defaults to True. |
is_indexed |
bool
|
:noindex: Indicates if this property should be indexed by supporting database layers to speed up queries. Defaults to False. |
is_unique |
bool
|
:noindex: Specifies whether values for this property must be
unique across all instances of its |
description |
Optional[str]
|
:noindex: An optional human-readable description of the property. |
Source code in grizabella/core/models.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
|
RelationInstance
Bases: MemoryInstance
Represents a concrete instance of a RelationTypeDefinition
, linking two ObjectInstance
s.
This model captures a specific relationship between two objects, conforming
to the schema defined by its RelationTypeDefinition
. It inherits common
metadata fields from MemoryInstance
.
Attributes:
Name | Type | Description |
---|---|---|
relation_type_name |
str
|
:noindex: The name of the |
source_object_instance_id |
UUID
|
:noindex: The ID of the |
target_object_instance_id |
UUID
|
:noindex: The ID of the |
properties |
Dict[str, Any]
|
:noindex: A dictionary containing the actual data
for the relation's own properties (edge properties), if any are
defined in its |
Source code in grizabella/core/models.py
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 |
|
RelationInstanceList
Bases: BaseModel
A container for a list of RelationInstance objects.
Source code in grizabella/core/models.py
464 465 466 467 |
|
RelationTypeDefinition
Bases: BaseModel
Defines the schema for a type of relation between objects (e.g., an edge in a graph).
A RelationTypeDefinition
specifies the structure for relationships
that can exist between instances of ObjectTypeDefinition
s. It includes
a unique name, allowed source and target object types, and any properties
specific to the relation itself (edge properties).
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
:noindex: A unique name for the relation type (e.g., 'HAS_AUTHOR', 'REFERENCES'). Conventionally, UPPER_SNAKE_CASE is used. |
description |
Optional[str]
|
:noindex: An optional human-readable description of what this relation type represents. |
source_object_type_names |
List[str]
|
:noindex: A list of names of
|
target_object_type_names |
List[str]
|
:noindex: A list of names of
|
properties |
List[PropertyDefinition]
|
:noindex: A list of |
Source code in grizabella/core/models.py
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
|