40 lines
1.1 KiB
Python
40 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
||
"""
|
||
通用记忆银行抽象,便于插入不同后端(Vertex、Cloudflare AutoRAG等)
|
||
"""
|
||
from __future__ import annotations
|
||
|
||
from typing import Dict, List, Any, Optional, Protocol, runtime_checkable
|
||
|
||
|
||
@runtime_checkable
|
||
class MemoryBankProtocol(Protocol):
|
||
async def create_memory_bank(self, agent_name: str, display_name: Optional[str] = None) -> str: ...
|
||
|
||
async def add_memory(
|
||
self,
|
||
agent_name: str,
|
||
content: str,
|
||
memory_type: str = "conversation",
|
||
debate_topic: str = "",
|
||
metadata: Optional[Dict[str, Any]] = None,
|
||
) -> str: ...
|
||
|
||
async def search_memories(
|
||
self,
|
||
agent_name: str,
|
||
query: str,
|
||
memory_type: Optional[str] = None,
|
||
limit: int = 10,
|
||
) -> List[Dict[str, Any]]: ...
|
||
|
||
async def get_agent_context(self, agent_name: str, debate_topic: str) -> str: ...
|
||
|
||
async def save_debate_session(
|
||
self,
|
||
debate_topic: str,
|
||
participants: List[str],
|
||
conversation_history: List[Dict[str, str]],
|
||
outcomes: Optional[Dict[str, Any]] = None,
|
||
) -> None: ...
|