MCPcopy Create free account
hub / github.com/VectifyAI/OpenKB / load_session

Function load_session

openkb/agent/chat_session.py:178–193  ·  view source on GitHub ↗
(kb_dir: Path, session_id: str)

Source from the content-addressed store, hash-verified

176
177
178def load_session(kb_dir: Path, session_id: str) -> ChatSession:
179 path = chats_dir(kb_dir) / f"{session_id}.json"
180 data = json.loads(path.read_text(encoding="utf-8"))
181 return ChatSession(
182 id=data["id"],
183 created_at=data["created_at"],
184 updated_at=data["updated_at"],
185 model=data["model"],
186 language=data.get("language", "en"),
187 title=data.get("title", ""),
188 turn_count=data.get("turn_count", 0),
189 history=sanitize_history(data.get("history", [])),
190 user_turns=data.get("user_turns", []),
191 assistant_texts=data.get("assistant_texts", []),
192 path=path,
193 )
194
195
196def list_sessions(kb_dir: Path) -> list[dict[str, Any]]:

Callers 2

chatFunction · 0.90

Calls 4

chats_dirFunction · 0.85
ChatSessionClass · 0.85
sanitize_historyFunction · 0.85
getMethod · 0.45