mentedb-crewai 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ from mentedb_crewai.memory import MenteDBCrewMemory
2
+ from mentedb_crewai.tool import MenteDBTool
3
+
4
+ __all__ = ["MenteDBCrewMemory", "MenteDBTool"]
@@ -0,0 +1,67 @@
1
+ """CrewAI memory backend powered by MenteDB."""
2
+ from typing import Any, Dict, List, Optional
3
+
4
+ from mentedb import MenteDB
5
+
6
+
7
+ class MenteDBCrewMemory:
8
+ """Drop-in memory backend for CrewAI agents.
9
+
10
+ Gives CrewAI agents persistent, cognitive memory with:
11
+ - Cross-session recall
12
+ - Multi-agent memory isolation via spaces
13
+ - Semantic search over past context
14
+
15
+ Usage:
16
+ from crewai import Agent
17
+ from mentedb_crewai import MenteDBCrewMemory
18
+
19
+ memory = MenteDBCrewMemory(
20
+ data_dir="./crew-memory",
21
+ space="research-team",
22
+ )
23
+
24
+ agent = Agent(
25
+ role="Researcher",
26
+ memory=memory,
27
+ )
28
+ """
29
+
30
+ def __init__(self, data_dir: str = "./mentedb-data", space: str = "default",
31
+ agent_name: Optional[str] = None):
32
+ self.data_dir = data_dir
33
+ self.space = space
34
+ self.agent_name = agent_name
35
+ self._db = MenteDB(data_dir)
36
+
37
+ def store(self, content: str, metadata: Optional[Dict[str, Any]] = None) -> str:
38
+ """Store a memory from the agent's work."""
39
+ tags = [self.space]
40
+ if self.agent_name:
41
+ tags.append(self.agent_name)
42
+ if metadata and "tags" in metadata:
43
+ tags.extend(metadata["tags"])
44
+ memory_type = (metadata or {}).get("memory_type", "episodic")
45
+ return self._db.store(content, memory_type=memory_type, tags=tags)
46
+
47
+ def search(self, query: str, k: int = 5) -> List[Dict[str, Any]]:
48
+ """Search for relevant memories."""
49
+ results = self._db.search_text(query, k=k, tags=[self.space])
50
+ docs = []
51
+ for r in results:
52
+ mem = self._db.get_memory(r.id)
53
+ if mem:
54
+ docs.append({
55
+ "content": mem["content"],
56
+ "score": r.score,
57
+ "id": r.id,
58
+ "memory_type": mem.get("memory_type", ""),
59
+ })
60
+ return docs
61
+
62
+ def get_context(self, task_description: str, token_budget: int = 2000) -> str:
63
+ """Get assembled context for a task using MQL recall."""
64
+ result = self._db.recall(
65
+ f"RECALL memories WHERE content ~> \"{task_description}\" LIMIT 10"
66
+ )
67
+ return result.text if result else ""
mentedb_crewai/tool.py ADDED
@@ -0,0 +1,35 @@
1
+ """CrewAI tool for querying MenteDB with MQL."""
2
+
3
+ from mentedb import MenteDB
4
+
5
+
6
+ class MenteDBTool:
7
+ """A CrewAI tool that lets agents query their memory database directly.
8
+
9
+ Usage:
10
+ from crewai import Agent
11
+ from mentedb_crewai import MenteDBTool
12
+
13
+ memory_tool = MenteDBTool(data_dir="./crew-memory")
14
+
15
+ agent = Agent(
16
+ role="Researcher",
17
+ tools=[memory_tool],
18
+ )
19
+ """
20
+
21
+ name: str = "mentedb_query"
22
+ description: str = (
23
+ "Query the team's knowledge database using MQL (Mente Query Language). "
24
+ "Use for recalling past decisions, finding related context, or checking "
25
+ "what the team knows about a topic."
26
+ )
27
+
28
+ def __init__(self, data_dir: str = "./mentedb-data"):
29
+ self.data_dir = data_dir
30
+ self._db = MenteDB(data_dir)
31
+
32
+ def run(self, query: str) -> str:
33
+ """Execute an MQL query and return assembled context."""
34
+ result = self._db.recall(query)
35
+ return result.text if result else ""
@@ -0,0 +1,8 @@
1
+ Metadata-Version: 2.4
2
+ Name: mentedb-crewai
3
+ Version: 0.1.0
4
+ Summary: MenteDB integration for CrewAI and AutoGen
5
+ License-Expression: Apache-2.0
6
+ Requires-Python: >=3.9
7
+ Requires-Dist: crewai>=0.30
8
+ Requires-Dist: mentedb>=0.7.0
@@ -0,0 +1,6 @@
1
+ mentedb_crewai/__init__.py,sha256=B7UF3IRGVmXGac2RHpK9V6wML3mnuFGqMIModPCFYik,144
2
+ mentedb_crewai/memory.py,sha256=FBMbMaXcSE3XUVrpA-HtOJ0Lmr1FmiOaI2b7c-mK-7Y,2283
3
+ mentedb_crewai/tool.py,sha256=SBW2pUossmBR-LzdVN_GotYDAEP5eToOb68FrDn--sI,1024
4
+ mentedb_crewai-0.1.0.dist-info/METADATA,sha256=PaVl8FCkBWckDLNhtBMhA4xGkvxZtz8psGuS-Gr-gIo,222
5
+ mentedb_crewai-0.1.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
6
+ mentedb_crewai-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.29.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any