File size: 1,742 Bytes
c2ea5ed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
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
39
40
41
42
43
44
45
46
47
48
49
50
from typing import List, Literal, Optional

from pydantic import BaseModel, Field

# -----------------------------
# Schema v3 core data models
# -----------------------------

class Entity(BaseModel):
    """Core entity in the agent knowledge graph (schema v3)."""

    id: str = Field(..., description="Unique identifier for the entity")
    type: Literal["Agent", "Task", "Tool", "Input", "Output", "Human"] = Field(
        ..., description="Entity category"
    )
    name: str = Field(..., description="Concise, reusable name for the entity")
    # Critical prompt fragment that defines the entity.  Empty string if not available.
    raw_prompt: Optional[str] = Field("", description="Prompt fragment that uniquely defines the entity")


class Relation(BaseModel):
    """Directed relationship between two entities (schema v3)."""

    id: str = Field(..., description="Unique identifier for the relation")
    source: str = Field(..., description="ID of the source entity")
    target: str = Field(..., description="ID of the target entity")
    type: Literal[
        "CONSUMED_BY",
        "PERFORMS",
        "ASSIGNED_TO",
        "USES",
        "REQUIRED_BY",
        "SUBTASK_OF",
        "NEXT",
        "PRODUCES",
        "DELIVERS_TO",
        "INTERVENES",
    ] = Field(..., description="Relation category")
    # Prompt fragment representing the concrete interaction (optional except for certain relation types)
    raw_prompt: Optional[str] = Field("", description="Prompt fragment illustrating the interaction")


class KnowledgeGraph(BaseModel):
    """Complete knowledge graph for an agent system (schema v3)."""

    entities: List[Entity]
    relations: List[Relation]
    system_name: str
    system_summary: str