MCPcopy Create free account
hub / github.com/AQ-MedAI/MedMemoryBench / __init__

Method __init__

methods/amem_agent.py:37–87  ·  view source on GitHub ↗
(
        self,
        model: str = "gpt-4o-mini",
        temperature: float = 1.0,
        max_tokens: int = 2000,
        provider: str = "openai",
        api_key: Optional[str] = None,
        base_url: Optional[str] = None,
        retrieve_num: int = 5,
        amem_backend: str = "openai",
        amem_model: Optional[str] = None,
        amem_embedding_model: str = "all-MiniLM-L6-v2",
        amem_evo_threshold: int = 100,
        amem_max_tokens: Optional[int] = None,
        amem_max_context_tokens: int = 200000,
        amem_chunk_size_tokens: Optional[int] = None,
        **kwargs,
    )

Source from the content-addressed store, hash-verified

35 provider: str = "openai",
36 api_key: Optional[str] = None,
37 base_url: Optional[str] = None,
38 retrieve_num: int = 5,
39 amem_backend: str = "openai",
40 amem_model: Optional[str] = None,
41 amem_embedding_model: str = "all-MiniLM-L6-v2",
42 amem_evo_threshold: int = 100,
43 amem_max_tokens: int = 2000,
44 max_context_tokens: int = 100000,
45 **kwargs,
46 ):
47 super().__init__(model, temperature, max_tokens, **kwargs)
48
49 self.retrieve_num = retrieve_num
50 self.amem_backend = amem_backend
51 self.amem_model = amem_model or model
52 self.amem_embedding_model = amem_embedding_model
53 self.amem_evo_threshold = amem_evo_threshold
54 # amem_max_tokens: controls A-Mem internal LLM (analyze_content + process_memory)
55 # query-time answer generation uses self.max_tokens (from framework config)
56 self.amem_max_tokens = amem_max_tokens
57 self.max_context_tokens = max_context_tokens
58
59 self._api_key = api_key or os.environ.get("OPENAI_API_KEY")
60 self._api_base = base_url or os.environ.get("OPENAI_BASE_URL")
61
62 # LLM client for query-time response generation
63 self._llm_client: BaseLLMClient = create_llm_client(
64 provider=provider,
65 model=model,
66 temperature=temperature,
67 max_tokens=max_tokens,
68 api_key=api_key,
69 base_url=base_url,
70 )
71
72 # Per-context memory systems
73 self._amem_systems: Dict[int, Any] = {}
74 self._amem_class = self._load_amem_class()
75
76 def _load_amem_class(self):
77 """Load AgenticMemorySystem from methods/amem/A-mem/memory_layer.py."""
78 amem_dir = Path(__file__).resolve().parent / "amem" / "A-mem"
79 if not amem_dir.exists():
80 raise ImportError(f"A-mem source folder not found at {amem_dir}")
81
82 amem_dir_str = str(amem_dir)
83 if amem_dir_str not in sys.path:
84 sys.path.insert(0, amem_dir_str)
85
86 module = importlib.import_module("memory_layer")
87 return getattr(module, "AgenticMemorySystem")
88
89 def _get_context_id(self) -> int:
90 return self._context_id if self._context_id is not None else 0

Callers

nothing calls this directly

Calls 3

create_llm_clientFunction · 0.90
getMethod · 0.45

Tested by

no test coverage detected