项目文件夹

文件
wehub-resource-sync c889a57b6b
Test Suites / Build CI Environment (push) Has been cancelled
Test Suites / Basic Tests (push) Has been cancelled
Test Suites / End-to-End Tests (push) Has been cancelled
Test Suites / CLI Tests (push) Has been cancelled
Test Suites / Slow End-to-End Tests (push) Has been cancelled
Test Suites / Graph Database Tests (push) Has been cancelled
Test Suites / Vector DB Tests (push) Has been cancelled
Test Suites / Temporal Graph Test (push) Has been cancelled
Test Suites / Search Test on Different DBs (push) Has been cancelled
Test Suites / Example Tests (push) Has been cancelled
Test Suites / Notebook Tests (push) Has been cancelled
Test Suites / OS and Python Tests Ubuntu (push) Has been cancelled
Test Suites / OS and Python Tests Extended (push) Has been cancelled
Test Suites / LLM Test Suite (push) Has been cancelled
Test Suites / S3 File Storage Test (push) Has been cancelled
Test Suites / Run Integration Tests (push) Has been cancelled
Test Suites / MCP Tests (push) Has been cancelled
Test Suites / Docker Compose Test (push) Has been cancelled
Test Suites / Docker CI test (push) Has been cancelled
Test Suites / Relational DB Migration Tests (push) Has been cancelled
Test Suites / Distributed Cognee Test (push) Has been cancelled
Test Suites / DB Examples Tests (push) Has been cancelled
Test Suites / Test Completion Status (push) Has been cancelled
Test Suites / Claude Code Review (push) Has been cancelled
Test Suites / basic checks (push) Has been cancelled
build | Build and Push Cognee MCP Docker Image to dockerhub / docker-build-and-push (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
build | Build and Push Docker Image to dockerhub / docker-build-and-push (push) Has been cancelled
Weighted Edges Tests / Test Weighted Edges Core Functionality (3.11) (push) Has been cancelled
Weighted Edges Tests / Test Weighted Edges Core Functionality (3.12) (push) Has been cancelled
Weighted Edges Tests / Test Weighted Edges with Different Graph Databases (kuzu, kuzu) (push) Has been cancelled
Weighted Edges Tests / Test Weighted Edges with Different Graph Databases (neo4j, neo4j) (push) Has been cancelled
Weighted Edges Tests / Test Weighted Edges Examples (push) Has been cancelled
Weighted Edges Tests / Code Quality for Weighted Edges (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:02:24 +08:00

86 行
2.7 KiB
Python

"""
Field role annotations for DataPoint.
These make implicit DataPoint behaviors explicit and visible at definition time.
They are informational markers — the system also supports the legacy
metadata = {"index_fields": [...]} approach.
Usage:
from typing import Annotated
from cognee.infrastructure.engine.models import DataPoint, Embeddable, LLMContext, Dedup
class Entity(DataPoint):
name: Annotated[str, Embeddable("Primary search field"), Dedup()]
description: Annotated[str, LLMContext("Provides entity context to LLM")]
is_a: Optional[EntityType] = None # Relationship (auto-detected from type)
"""
class _Embeddable:
"""Marker: this field will be embedded in the vector database."""
def __init__(self, description: str = "") -> None:
self.description = description
def __repr__(self) -> str:
return f"Embeddable({self.description!r})" if self.description else "Embeddable()"
class _LLMContext:
"""Marker: this field is sent to the LLM during retrieval/extraction."""
def __init__(self, description: str = "") -> None:
self.description = description
def __repr__(self) -> str:
return f"LLMContext({self.description!r})" if self.description else "LLMContext()"
class _Dedup:
"""Marker: this field is used for entity deduplication (UUID5 key)."""
def __init__(self, description: str = "") -> None:
self.description = description
def __repr__(self) -> str:
return f"Dedup({self.description!r})" if self.description else "Dedup()"
def Embeddable(description: str = "Embedded in vector DB for semantic search") -> _Embeddable:
"""Mark a field as embedded in the vector database.
Fields marked Embeddable are included in metadata["index_fields"]
and will be vectorized by the embedding engine.
Example:
class Entity(DataPoint):
name: Annotated[str, Embeddable()] = ""
"""
return _Embeddable(description)
def LLMContext(description: str = "Sent to LLM during retrieval") -> _LLMContext:
"""Mark a field as sent to the LLM during context building.
Fields marked LLMContext are concatenated and used as context
when building search results or enriching entities.
Example:
class Entity(DataPoint):
description: Annotated[str, LLMContext()] = ""
"""
return _LLMContext(description)
def Dedup(description: str = "Used for entity deduplication") -> _Dedup:
"""Mark a field as part of the deduplication key.
Fields marked Dedup contribute to the identity_fields list,
which drives deterministic UUID5 generation for entity deduplication.
Example:
class Entity(DataPoint):
name: Annotated[str, Dedup()] = ""
"""
return _Dedup(description)