2025-02-15 22:37:12 +01:00
|
|
|
from __future__ import annotations
|
|
|
|
|
2025-01-25 00:11:00 +01:00
|
|
|
from pydantic import BaseModel
|
2025-02-16 12:45:27 +01:00
|
|
|
from typing import Any, Optional
|
2025-01-25 00:11:00 +01:00
|
|
|
|
2025-01-25 00:55:07 +01:00
|
|
|
|
2025-01-25 00:11:00 +01:00
|
|
|
class GPTKeywordExtractionFormat(BaseModel):
|
2025-02-15 22:37:12 +01:00
|
|
|
high_level_keywords: list[str]
|
|
|
|
low_level_keywords: list[str]
|
2025-02-13 17:32:51 +08:00
|
|
|
|
|
|
|
|
|
|
|
class KnowledgeGraphNode(BaseModel):
|
|
|
|
id: str
|
2025-02-15 22:37:12 +01:00
|
|
|
labels: list[str]
|
|
|
|
properties: dict[str, Any] # anything else goes here
|
2025-02-13 17:32:51 +08:00
|
|
|
|
|
|
|
|
|
|
|
class KnowledgeGraphEdge(BaseModel):
|
|
|
|
id: str
|
2025-02-15 00:34:38 +08:00
|
|
|
type: Optional[str]
|
2025-02-13 17:32:51 +08:00
|
|
|
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
|
2025-02-13 17:32:51 +08:00
|
|
|
|
|
|
|
|
|
|
|
class KnowledgeGraph(BaseModel):
|
2025-02-15 22:37:12 +01:00
|
|
|
nodes: list[KnowledgeGraphNode] = []
|
|
|
|
edges: list[KnowledgeGraphEdge] = []
|
2025-04-02 22:12:20 +08:00
|
|
|
is_truncated: bool = False
|