Skip to content

Commit 21f00e3

Browse files
committed
checkpoints WIP init commit
1 parent ffe337d commit 21f00e3

2 files changed

Lines changed: 108 additions & 0 deletions

File tree

src/checkpointer/__init__.py

Whitespace-only changes.

src/checkpointer/entities.py

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
from datetime import datetime
2+
from typing import Optional
3+
from pydantic import BaseModel, Field
4+
5+
class OpeyCheckpointEntity(BaseModel):
6+
"""OBP Dynamic Entity representation of a LangGraph checkpoint."""
7+
8+
thread_id: str = Field(description="Thread identifier")
9+
checkpoint_id: str = Field(description="Unique checkpoint ID (UUID)")
10+
checkpoint_ns: str = Field(description="Checkpoint namespace")
11+
parent_checkpoint_id: Optional[str] = Field(description="Parent checkpoint ID for history.")
12+
checkpoint_data: str = Field(description="Serialized checkpoint TypedDict")
13+
metadata: str = Field(description="Serialized CheckpointMetadata")
14+
created_at: datetime = Field(default_factory=datetime.utcnow, description="ISO timestamp")
15+
16+
@classmethod
17+
def obp_entity_name(cls) -> str:
18+
return "OpeyCheckpoint"
19+
20+
@classmethod
21+
def to_obp_schema(cls) -> dict:
22+
return {
23+
"hasPersonalEntity": True,
24+
cls.obp_entity_name(): {
25+
"description": "LangGraph checkpoint snapshots for Opey AI conversations",
26+
"required": ["thread_id", "checkpoint_id", "checkpoint_ns", "checkpoint_data"],
27+
"properties": {
28+
"thread_id": {"type": "string", "description": "Thread identifier"},
29+
"checkpoint_id": {"type": "string", "description": "Unique checkpoint ID (UUID)"},
30+
"checkpoint_ns": {"type": "string", "description": "Checkpoint namespace"},
31+
"parent_checkpoint_id": {"type": "string", "description": "Parent checkpoint ID for history"},
32+
"checkpoint_data": {"type": "string", "description": "JSON-serialized checkpoint (channel_values, versions, etc.)"},
33+
"metadata": {"type": "string", "description": "JSON-serialized metadata (step, source, writes)"},
34+
"created_at": {"type": "string", "description": "ISO timestamp"}
35+
}
36+
}
37+
}
38+
39+
40+
class OpeyCheckpointWriteEntity(BaseModel):
41+
"""OBP Dynamic Entity representation of a pending LangGraph checkpoint write."""
42+
43+
thread_id: str = Field(description="Thread identifier")
44+
checkpoint_id: str = Field(description="Checkpoint ID this write belongs to")
45+
checkpoint_ns: str = Field(description="Checkpoint namespace")
46+
task_id: str = Field(description="Task that produced this write")
47+
idx: int = Field(description="Write index within task")
48+
channel: str = Field(description="Channel name")
49+
value: str = Field(description="Serialized write value")
50+
51+
@classmethod
52+
def obp_entity_name(cls) -> str:
53+
return "OpeyCheckpointWrite"
54+
55+
@classmethod
56+
def to_obp_schema(cls) -> dict:
57+
"""OBP Dynamic Entity schema definition."""
58+
return {
59+
"hasPersonalEntity": True,
60+
cls.obp_entity_name(): {
61+
"description": "Pending writes for LangGraph checkpoints",
62+
"required": ["thread_id", "checkpoint_id", "checkpoint_ns", "task_id", "channel", "value", "idx"],
63+
"properties": {
64+
"thread_id": {"type": "string"},
65+
"checkpoint_id": {"type": "string"},
66+
"checkpoint_ns": {"type": "string"},
67+
"task_id": {"type": "string", "description": "Task that produced this write"},
68+
"idx": {"type": "integer", "description": "Write index within task"},
69+
"channel": {"type": "string", "description": "Channel name"},
70+
"value": {"type": "string", "description": "Serialized write value"}
71+
}
72+
}
73+
}
74+
75+
76+
opey_checkpoint_entity = {
77+
"hasPersonalEntity": True,
78+
"OpeyCheckpoint": {
79+
"description": "LangGraph checkpoint snapshots for Opey AI conversations",
80+
"required": ["thread_id", "checkpoint_id", "checkpoint_ns", "checkpoint_data"],
81+
"properties": {
82+
"thread_id": {"type": "string", "description": "Thread identifier"},
83+
"checkpoint_id": {"type": "string", "description": "Unique checkpoint ID (UUID)"},
84+
"checkpoint_ns": {"type": "string", "description": "Checkpoint namespace"},
85+
"parent_checkpoint_id": {"type": "string", "description": "Parent checkpoint ID for history"},
86+
"checkpoint_data": {"type": "string", "description": "JSON-serialized checkpoint (channel_values, versions, etc.)"},
87+
"metadata": {"type": "string", "description": "JSON-serialized metadata (step, source, writes)"},
88+
"created_at": {"type": "string", "description": "ISO timestamp"}
89+
}
90+
}
91+
}
92+
93+
opey_checkpoint_write_entity = {
94+
"hasPersonalEntity": True,
95+
"OpeyCheckpointWrite": {
96+
"description": "Pending writes for LangGraph checkpoints",
97+
"required": ["thread_id", "checkpoint_id", "checkpoint_ns", "task_id", "channel", "value"],
98+
"properties": {
99+
"thread_id": {"type": "string"},
100+
"checkpoint_id": {"type": "string"},
101+
"checkpoint_ns": {"type": "string"},
102+
"task_id": {"type": "string", "description": "Task that produced this write"},
103+
"idx": {"type": "integer", "description": "Write index within task"},
104+
"channel": {"type": "string", "description": "Channel name"},
105+
"value": {"type": "string", "description": "JSON-serialized write value"}
106+
}
107+
}
108+
}

0 commit comments

Comments
 (0)