LightRAG/lightrag/types.py

30 lines
702 B
Python
Raw Normal View History

2025-02-15 22:37:12 +01:00
from __future__ import annotations
from pydantic import BaseModel
2025-02-16 12:45:27 +01:00
from typing import Any, Optional
class GPTKeywordExtractionFormat(BaseModel):
2025-02-15 22:37:12 +01:00
high_level_keywords: list[str]
low_level_keywords: list[str]
class KnowledgeGraphNode(BaseModel):
id: str
2025-02-15 22:37:12 +01:00
labels: list[str]
properties: dict[str, Any] # anything else goes here
class KnowledgeGraphEdge(BaseModel):
id: str
type: Optional[str]
source: str # id of source node
target: str # id of target node
2025-02-15 22:37:12 +01:00
properties: dict[str, Any] # anything else goes here
class KnowledgeGraph(BaseModel):
2025-02-15 22:37:12 +01:00
nodes: list[KnowledgeGraphNode] = []
edges: list[KnowledgeGraphEdge] = []
is_truncated: bool = False