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

Function list_sessions

openkb/agent/chat_session.py:196–217  ·  view source on GitHub ↗

Return session metadata dicts, most recently updated first.

(kb_dir: Path)

Source from the content-addressed store, hash-verified

194
195
196def list_sessions(kb_dir: Path) -> list[dict[str, Any]]:
197 """Return session metadata dicts, most recently updated first."""
198 d = chats_dir(kb_dir)
199 if not d.exists():
200 return []
201 out: list[dict[str, Any]] = []
202 for p in d.glob("*.json"):
203 try:
204 data = json.loads(p.read_text(encoding="utf-8"))
205 except (json.JSONDecodeError, OSError):
206 continue
207 out.append(
208 {
209 "id": data.get("id", p.stem),
210 "title": data.get("title", ""),
211 "turn_count": data.get("turn_count", 0),
212 "updated_at": data.get("updated_at", ""),
213 "model": data.get("model", ""),
214 }
215 )
216 out.sort(key=lambda s: (s["updated_at"], s["id"]), reverse=True)
217 return out
218
219
220def resolve_session_id(kb_dir: Path, query: str) -> str | None:

Callers 2

chatFunction · 0.90
resolve_session_idFunction · 0.85

Calls 2

chats_dirFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected