feat: adds temporal models for llm extraction
This commit is contained in:
parent
6e5acec292
commit
bf34ba398e
5 changed files with 43 additions and 3 deletions
|
|
@ -1,8 +1,9 @@
|
||||||
from typing import List
|
from typing import List, Union
|
||||||
|
|
||||||
from cognee.infrastructure.engine import DataPoint
|
from cognee.infrastructure.engine import DataPoint
|
||||||
from cognee.modules.data.processing.document_types import Document
|
from cognee.modules.data.processing.document_types import Document
|
||||||
from cognee.modules.engine.models import Entity
|
from cognee.modules.engine.models import Entity
|
||||||
|
from cognee.tasks.temporal_graph.models import Event
|
||||||
|
|
||||||
|
|
||||||
class DocumentChunk(DataPoint):
|
class DocumentChunk(DataPoint):
|
||||||
|
|
@ -20,7 +21,7 @@ class DocumentChunk(DataPoint):
|
||||||
- chunk_index: The index of the chunk in the original document.
|
- chunk_index: The index of the chunk in the original document.
|
||||||
- cut_type: The type of cut that defined this chunk.
|
- cut_type: The type of cut that defined this chunk.
|
||||||
- is_part_of: The document to which this chunk belongs.
|
- is_part_of: The document to which this chunk belongs.
|
||||||
- contains: A list of entities contained within the chunk (default is None).
|
- contains: A list of entities or events contained within the chunk (default is None).
|
||||||
- metadata: A dictionary to hold meta information related to the chunk, including index
|
- metadata: A dictionary to hold meta information related to the chunk, including index
|
||||||
fields.
|
fields.
|
||||||
"""
|
"""
|
||||||
|
|
@ -30,6 +31,6 @@ class DocumentChunk(DataPoint):
|
||||||
chunk_index: int
|
chunk_index: int
|
||||||
cut_type: str
|
cut_type: str
|
||||||
is_part_of: Document
|
is_part_of: Document
|
||||||
contains: List[Entity] = None
|
contains: List[Union[Entity, Event]] = None
|
||||||
|
|
||||||
metadata: dict = {"index_fields": ["text"]}
|
metadata: dict = {"index_fields": ["text"]}
|
||||||
|
|
|
||||||
16
cognee/modules/engine/models/Event.py
Normal file
16
cognee/modules/engine/models/Event.py
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
from typing import Optional, Any
|
||||||
|
from pydantic import SkipValidation
|
||||||
|
from cognee.infrastructure.engine import DataPoint
|
||||||
|
from cognee.modules.engine.models.Timestamp import Timestamp
|
||||||
|
from cognee.modules.engine.models.Interval import Interval
|
||||||
|
|
||||||
|
|
||||||
|
class Event(DataPoint):
|
||||||
|
name: str
|
||||||
|
description: Optional[str] = None
|
||||||
|
at: Optional[Timestamp] = None
|
||||||
|
during: Optional[Interval] = None
|
||||||
|
location: Optional[str] = None
|
||||||
|
attributes: SkipValidation[Any] = None
|
||||||
|
|
||||||
|
metadata: dict = {"index_fields": ["name"]}
|
||||||
7
cognee/modules/engine/models/Interval.py
Normal file
7
cognee/modules/engine/models/Interval.py
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
from pydantic import Field
|
||||||
|
from cognee.infrastructure.engine import DataPoint
|
||||||
|
from cognee.modules.engine.models.Timestamp import Timestamp
|
||||||
|
|
||||||
|
class Interval(DataPoint):
|
||||||
|
time_from: Timestamp = Field(...)
|
||||||
|
time_to: Timestamp = Field(...)
|
||||||
13
cognee/modules/engine/models/Timestamp.py
Normal file
13
cognee/modules/engine/models/Timestamp.py
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
from pydantic import Field
|
||||||
|
from cognee.infrastructure.engine import DataPoint
|
||||||
|
|
||||||
|
|
||||||
|
class Timestamp(DataPoint):
|
||||||
|
time_at: int = Field(...)
|
||||||
|
year: int = Field(...)
|
||||||
|
month: int = Field(...)
|
||||||
|
day: int = Field(...)
|
||||||
|
hour: int = Field(...)
|
||||||
|
minute: int = Field(...)
|
||||||
|
second: int = Field(...)
|
||||||
|
timestamp_str: str = Field(...)
|
||||||
|
|
@ -4,3 +4,6 @@ from .TableRow import TableRow
|
||||||
from .TableType import TableType
|
from .TableType import TableType
|
||||||
from .node_set import NodeSet
|
from .node_set import NodeSet
|
||||||
from .ColumnValue import ColumnValue
|
from .ColumnValue import ColumnValue
|
||||||
|
from .Timestamp import Timestamp
|
||||||
|
from .Interval import Interval
|
||||||
|
from .Event import Event
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue