修改了nanobot,往Hermes agent的风格走,进度1/3
This commit is contained in:
5
app-instance/backend/beaver/memory/search/__init__.py
Normal file
5
app-instance/backend/beaver/memory/search/__init__.py
Normal file
@ -0,0 +1,5 @@
|
||||
"""Session transcript search storage."""
|
||||
|
||||
from .transcript_store import TranscriptStore
|
||||
|
||||
__all__ = ["TranscriptStore"]
|
||||
@ -0,0 +1,46 @@
|
||||
"""兼容层:过渡期把旧 transcript store 导向新的 session 子系统。
|
||||
|
||||
真正的主实现现在在:
|
||||
1. `beaver.engine.session.store`
|
||||
2. `beaver.engine.session.search`
|
||||
3. `beaver.engine.session.manager`
|
||||
|
||||
保留这个文件只是为了避免已经写好的 MCP server / tool 导入立刻断掉。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from beaver.engine.session.manager import SessionManager
|
||||
|
||||
|
||||
class TranscriptStore:
|
||||
"""兼容旧接口的薄封装。"""
|
||||
|
||||
def __init__(self, db_path: str | Path) -> None:
|
||||
path = Path(db_path)
|
||||
workspace = path.parent.parent if path.parent.name == "sessions" else path.parent
|
||||
self.manager = SessionManager(workspace=workspace, db_path=path)
|
||||
|
||||
def close(self) -> None:
|
||||
self.manager.close()
|
||||
|
||||
def ensure_session(self, session_id: str, **kwargs: Any) -> str:
|
||||
return self.manager.ensure_session(session_id, **kwargs)
|
||||
|
||||
def append_message(self, session_id: str, **kwargs: Any) -> int:
|
||||
return self.manager.append_message(session_id, **kwargs)
|
||||
|
||||
def get_session(self, session_id: str) -> dict[str, Any] | None:
|
||||
return self.manager.get_session(session_id)
|
||||
|
||||
def list_sessions_rich(self, **kwargs: Any) -> list[dict[str, Any]]:
|
||||
return self.manager.list_sessions_rich(**kwargs)
|
||||
|
||||
def get_messages_as_conversation(self, session_id: str) -> list[dict[str, Any]]:
|
||||
return self.manager.get_messages_as_conversation(session_id)
|
||||
|
||||
def search_messages(self, **kwargs: Any) -> list[dict[str, Any]]:
|
||||
return self.manager.search_messages(**kwargs)
|
||||
Reference in New Issue
Block a user