onemillionbrain 0.1.0__tar.gz

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,42 @@
1
+ # Dependencies
2
+ node_modules/
3
+ .pnp
4
+ .pnp.js
5
+
6
+ # Build outputs
7
+ dist/
8
+ build/
9
+ .next/
10
+ out/
11
+
12
+ # Environment
13
+ .env
14
+ .env.local
15
+ .env.*.local
16
+
17
+ # IDE
18
+ .vscode/
19
+ .idea/
20
+ *.swp
21
+ *.swo
22
+
23
+ # OS
24
+ .DS_Store
25
+ Thumbs.db
26
+
27
+ # Logs
28
+ *.log
29
+ npm-debug.log*
30
+
31
+ # Database
32
+ *.db
33
+ *.db-journal
34
+ *.db-shm
35
+ *.db-wal
36
+
37
+ # Test
38
+ coverage/
39
+
40
+ # Docker volumes
41
+ data/
42
+ redis-data/
@@ -0,0 +1,156 @@
1
+ Metadata-Version: 2.4
2
+ Name: onemillionbrain
3
+ Version: 0.1.0
4
+ Summary: Python client SDK for the 1MBrain REST API — portable memory layer for AI agents.
5
+ Project-URL: Homepage, https://github.com/mrizkiiy04/1mbrain
6
+ Project-URL: Repository, https://github.com/mrizkiiy04/1mbrain
7
+ Project-URL: Documentation, https://github.com/mrizkiiy04/1mbrain/tree/main/packages/sdk/python
8
+ License: MIT
9
+ Keywords: 1mbrain,agent,ai,llm,memory
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
+ Requires-Python: >=3.10
19
+ Provides-Extra: async
20
+ Requires-Dist: httpx>=0.27.0; extra == 'async'
21
+ Provides-Extra: dev
22
+ Requires-Dist: httpx>=0.27.0; extra == 'dev'
23
+ Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
24
+ Requires-Dist: pytest>=8.0.0; extra == 'dev'
25
+ Requires-Dist: respx>=0.21.0; extra == 'dev'
26
+ Description-Content-Type: text/markdown
27
+
28
+ # 1MBrain Python SDK
29
+
30
+ Python client for the [1MBrain](https://github.com/mrizkiiy04/1mbrain) REST API — a portable, holographic memory layer for AI agents.
31
+
32
+ ## Installation
33
+
34
+ ```bash
35
+ # Sync client (zero extra dependencies — uses stdlib urllib)
36
+ pip install onemillionbrain
37
+
38
+ # Async client (requires httpx)
39
+ pip install onemillionbrain[async]
40
+ ```
41
+
42
+ ## Quick Start
43
+
44
+ ### Sync
45
+
46
+ ```python
47
+ from onemillionbrain import OneMBrainClient
48
+
49
+ client = OneMBrainClient(
50
+ api_url="http://localhost:3001",
51
+ api_key="your-api-key",
52
+ agent_id="my-agent",
53
+ )
54
+
55
+ # Store a memory
56
+ memory = client.remember("User prefers Bahasa Indonesia as primary language", type="semantic")
57
+ print(memory.id)
58
+
59
+ # Search memories
60
+ results = client.recall("language preference", limit=5)
61
+ for r in results:
62
+ print(f"[{r.score:.3f}] {r.memory.content}")
63
+
64
+ # Create an explicit association
65
+ client.associate(results[0].memory.id, results[1].memory.id, strength=0.8)
66
+
67
+ # Forget a memory
68
+ client.forget(memory.id)
69
+ ```
70
+
71
+ ### Async
72
+
73
+ ```python
74
+ import asyncio
75
+ from onemillionbrain import AsyncOneMBrainClient
76
+
77
+ async def main():
78
+ async with AsyncOneMBrainClient(
79
+ api_url="http://localhost:3001",
80
+ api_key="your-api-key",
81
+ agent_id="my-agent",
82
+ ) as client:
83
+ memory = await client.remember("User asked about pricing on 2026-06-10", type="episodic")
84
+ results = await client.recall("pricing questions")
85
+ await client.forget(memory.id)
86
+
87
+ asyncio.run(main())
88
+ ```
89
+
90
+ ### Agent Integration
91
+
92
+ To ensure your LLM agent knows exactly how and when to use 1MBrain, the SDK exports a pre-written `AGENT_SYSTEM_PROMPT`. Inject this into your agent's system instructions.
93
+
94
+ ```python
95
+ from onemillionbrain import AGENT_SYSTEM_PROMPT
96
+
97
+ system_instruction = f"""
98
+ You are a helpful AI assistant.
99
+ {AGENT_SYSTEM_PROMPT}
100
+ """
101
+
102
+ # Pass system_instruction to LangChain, OpenAI, Anthropic, etc.
103
+ ```
104
+
105
+ ### LangChain Integration
106
+
107
+ ```python
108
+ from langchain.tools import tool
109
+ from onemillionbrain import OneMBrainClient
110
+
111
+ brain = OneMBrainClient(
112
+ api_url="http://localhost:3001",
113
+ api_key="your-api-key",
114
+ agent_id="langchain-agent",
115
+ )
116
+
117
+ @tool
118
+ def remember_tool(content: str) -> str:
119
+ """Store something in long-term memory."""
120
+ memory = brain.remember(content, type="episodic")
121
+ return f"Stored memory: {memory.id}"
122
+
123
+ @tool
124
+ def recall_tool(query: str) -> str:
125
+ """Search long-term memory."""
126
+ results = brain.recall(query, limit=5)
127
+ if not results:
128
+ return "No memories found."
129
+ return "\n".join(f"- {r.memory.content}" for r in results)
130
+ ```
131
+
132
+ ## API Reference
133
+
134
+ ### `OneMBrainClient(api_url, api_key, agent_id=None)`
135
+
136
+ | Parameter | Type | Description |
137
+ |------------|-------|--------------------------------------------------------|
138
+ | `api_url` | `str` | Base URL of the 1MBrain API (e.g. `http://localhost:3001`) |
139
+ | `api_key` | `str` | Your API key (passed as `X-API-Key` header) |
140
+ | `agent_id` | `str` | Default agent namespace (can be overridden per call) |
141
+
142
+ ### Methods
143
+
144
+ | Method | Signature | Returns |
145
+ |--------|-----------|---------|
146
+ | `remember` | `(content, *, type, importance, tags, metadata, agent_id)` | `Memory` |
147
+ | `recall` | `(query, *, limit, type, tags, max_hops, activation_threshold, blend_weight, agent_id)` | `list[RecallResult]` |
148
+ | `forget` | `(memory_id, *, agent_id)` | `bool` |
149
+ | `associate` | `(source_id, target_id, *, strength, origin, agent_id)` | `AssociateResult` |
150
+
151
+ ## Development
152
+
153
+ ```bash
154
+ pip install -e ".[dev]"
155
+ pytest
156
+ ```
@@ -0,0 +1,129 @@
1
+ # 1MBrain Python SDK
2
+
3
+ Python client for the [1MBrain](https://github.com/mrizkiiy04/1mbrain) REST API — a portable, holographic memory layer for AI agents.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ # Sync client (zero extra dependencies — uses stdlib urllib)
9
+ pip install onemillionbrain
10
+
11
+ # Async client (requires httpx)
12
+ pip install onemillionbrain[async]
13
+ ```
14
+
15
+ ## Quick Start
16
+
17
+ ### Sync
18
+
19
+ ```python
20
+ from onemillionbrain import OneMBrainClient
21
+
22
+ client = OneMBrainClient(
23
+ api_url="http://localhost:3001",
24
+ api_key="your-api-key",
25
+ agent_id="my-agent",
26
+ )
27
+
28
+ # Store a memory
29
+ memory = client.remember("User prefers Bahasa Indonesia as primary language", type="semantic")
30
+ print(memory.id)
31
+
32
+ # Search memories
33
+ results = client.recall("language preference", limit=5)
34
+ for r in results:
35
+ print(f"[{r.score:.3f}] {r.memory.content}")
36
+
37
+ # Create an explicit association
38
+ client.associate(results[0].memory.id, results[1].memory.id, strength=0.8)
39
+
40
+ # Forget a memory
41
+ client.forget(memory.id)
42
+ ```
43
+
44
+ ### Async
45
+
46
+ ```python
47
+ import asyncio
48
+ from onemillionbrain import AsyncOneMBrainClient
49
+
50
+ async def main():
51
+ async with AsyncOneMBrainClient(
52
+ api_url="http://localhost:3001",
53
+ api_key="your-api-key",
54
+ agent_id="my-agent",
55
+ ) as client:
56
+ memory = await client.remember("User asked about pricing on 2026-06-10", type="episodic")
57
+ results = await client.recall("pricing questions")
58
+ await client.forget(memory.id)
59
+
60
+ asyncio.run(main())
61
+ ```
62
+
63
+ ### Agent Integration
64
+
65
+ To ensure your LLM agent knows exactly how and when to use 1MBrain, the SDK exports a pre-written `AGENT_SYSTEM_PROMPT`. Inject this into your agent's system instructions.
66
+
67
+ ```python
68
+ from onemillionbrain import AGENT_SYSTEM_PROMPT
69
+
70
+ system_instruction = f"""
71
+ You are a helpful AI assistant.
72
+ {AGENT_SYSTEM_PROMPT}
73
+ """
74
+
75
+ # Pass system_instruction to LangChain, OpenAI, Anthropic, etc.
76
+ ```
77
+
78
+ ### LangChain Integration
79
+
80
+ ```python
81
+ from langchain.tools import tool
82
+ from onemillionbrain import OneMBrainClient
83
+
84
+ brain = OneMBrainClient(
85
+ api_url="http://localhost:3001",
86
+ api_key="your-api-key",
87
+ agent_id="langchain-agent",
88
+ )
89
+
90
+ @tool
91
+ def remember_tool(content: str) -> str:
92
+ """Store something in long-term memory."""
93
+ memory = brain.remember(content, type="episodic")
94
+ return f"Stored memory: {memory.id}"
95
+
96
+ @tool
97
+ def recall_tool(query: str) -> str:
98
+ """Search long-term memory."""
99
+ results = brain.recall(query, limit=5)
100
+ if not results:
101
+ return "No memories found."
102
+ return "\n".join(f"- {r.memory.content}" for r in results)
103
+ ```
104
+
105
+ ## API Reference
106
+
107
+ ### `OneMBrainClient(api_url, api_key, agent_id=None)`
108
+
109
+ | Parameter | Type | Description |
110
+ |------------|-------|--------------------------------------------------------|
111
+ | `api_url` | `str` | Base URL of the 1MBrain API (e.g. `http://localhost:3001`) |
112
+ | `api_key` | `str` | Your API key (passed as `X-API-Key` header) |
113
+ | `agent_id` | `str` | Default agent namespace (can be overridden per call) |
114
+
115
+ ### Methods
116
+
117
+ | Method | Signature | Returns |
118
+ |--------|-----------|---------|
119
+ | `remember` | `(content, *, type, importance, tags, metadata, agent_id)` | `Memory` |
120
+ | `recall` | `(query, *, limit, type, tags, max_hops, activation_threshold, blend_weight, agent_id)` | `list[RecallResult]` |
121
+ | `forget` | `(memory_id, *, agent_id)` | `bool` |
122
+ | `associate` | `(source_id, target_id, *, strength, origin, agent_id)` | `AssociateResult` |
123
+
124
+ ## Development
125
+
126
+ ```bash
127
+ pip install -e ".[dev]"
128
+ pytest
129
+ ```
@@ -0,0 +1,44 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "onemillionbrain"
7
+ version = "0.1.0"
8
+ description = "Python client SDK for the 1MBrain REST API — portable memory layer for AI agents."
9
+ readme = "README.md"
10
+ license = { text = "MIT" }
11
+ requires-python = ">=3.10"
12
+ keywords = ["ai", "agent", "memory", "1mbrain", "llm"]
13
+ classifiers = [
14
+ "Development Status :: 3 - Alpha",
15
+ "Intended Audience :: Developers",
16
+ "License :: OSI Approved :: MIT License",
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3.10",
19
+ "Programming Language :: Python :: 3.11",
20
+ "Programming Language :: Python :: 3.12",
21
+ "Topic :: Software Development :: Libraries :: Python Modules",
22
+ ]
23
+ dependencies = []
24
+
25
+ [project.optional-dependencies]
26
+ async = ["httpx>=0.27.0"]
27
+ dev = [
28
+ "pytest>=8.0.0",
29
+ "pytest-asyncio>=0.23.0",
30
+ "httpx>=0.27.0",
31
+ "respx>=0.21.0",
32
+ ]
33
+
34
+ [project.urls]
35
+ Homepage = "https://github.com/mrizkiiy04/1mbrain"
36
+ Repository = "https://github.com/mrizkiiy04/1mbrain"
37
+ Documentation = "https://github.com/mrizkiiy04/1mbrain/tree/main/packages/sdk/python"
38
+
39
+ [tool.hatch.build.targets.wheel]
40
+ packages = ["src/onemillionbrain"]
41
+
42
+ [tool.pytest.ini_options]
43
+ asyncio_mode = "auto"
44
+ testpaths = ["tests"]
@@ -0,0 +1,32 @@
1
+ """1MBrain Python SDK — portable memory layer for AI agents."""
2
+
3
+ from .client import OneMBrainClient, OneMBrainError
4
+ from .models import (
5
+ AssociateInput,
6
+ AssociateResult,
7
+ AssociationRelationType,
8
+ ConsolidationResult,
9
+ Memory,
10
+ MemoryType,
11
+ RecallInput,
12
+ RecallResult,
13
+ RememberInput,
14
+ )
15
+ from .prompts import AGENT_SYSTEM_PROMPT
16
+
17
+ __all__ = [
18
+ "OneMBrainClient",
19
+ "OneMBrainError",
20
+ "Memory",
21
+ "MemoryType",
22
+ "RememberInput",
23
+ "RecallInput",
24
+ "RecallResult",
25
+ "AssociateInput",
26
+ "AssociateResult",
27
+ "AssociationRelationType",
28
+ "ConsolidationResult",
29
+ "AGENT_SYSTEM_PROMPT",
30
+ ]
31
+
32
+ __version__ = "0.1.0"