atlas-mem 2.0.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,448 @@
1
+ Metadata-Version: 2.4
2
+ Name: atlas-mem
3
+ Version: 2.0.0
4
+ Summary: Cognitive AI memory for agents — episodic, semantic, and working memory with multi-hop graph reasoning.
5
+ Author-email: Bsyncs <noreply@verify.bsyncs.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://atlas.bsyncs.com
8
+ Project-URL: Documentation, https://docs.bsyncs.com
9
+ Project-URL: Repository, https://github.com/janhavi2409/atlas
10
+ Project-URL: Bug Tracker, https://github.com/janhavi2409/atlas/issues
11
+ Project-URL: Changelog, https://github.com/janhavi2409/atlas/blob/main/CHANGELOG.md
12
+ Keywords: ai,agents,memory,knowledge-graph,llm,episodic-memory,semantic-memory,cognitive-ai,openai,langchain,crewai,llamaindex
13
+ Classifier: Development Status :: 5 - Production/Stable
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
16
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Requires-Python: >=3.9
24
+ Description-Content-Type: text/markdown
25
+ Requires-Dist: requests>=2.28.0
26
+ Provides-Extra: async
27
+ Requires-Dist: httpx>=0.27.0; extra == "async"
28
+ Provides-Extra: langchain
29
+ Requires-Dist: langchain-core>=0.2.0; extra == "langchain"
30
+ Requires-Dist: pydantic>=2.0; extra == "langchain"
31
+ Provides-Extra: crewai
32
+ Requires-Dist: crewai>=0.28.0; extra == "crewai"
33
+ Provides-Extra: llamaindex
34
+ Requires-Dist: llama-index-core>=0.10.0; extra == "llamaindex"
35
+ Provides-Extra: all
36
+ Requires-Dist: httpx>=0.27.0; extra == "all"
37
+ Requires-Dist: langchain-core>=0.2.0; extra == "all"
38
+ Requires-Dist: pydantic>=2.0; extra == "all"
39
+ Requires-Dist: crewai>=0.28.0; extra == "all"
40
+ Requires-Dist: llama-index-core>=0.10.0; extra == "all"
41
+
42
+ # ATLAS Memory SDK
43
+
44
+ > Knowledge graph memory for AI agents — persistent, temporal, multi-tenant.
45
+
46
+ ATLAS gives your AI agents long-term memory that understands **time**. Unlike vector databases that treat all facts equally, ATLAS knows that "we switched to PostgreSQL last week" should outrank "we started with MySQL three months ago" — automatically.
47
+
48
+ ---
49
+
50
+ ## What problem does this solve?
51
+
52
+ Every AI agent today suffers from the same limitation: it only knows what's in its context window. The moment a conversation ends, everything is forgotten. Workarounds like stuffing chat history into prompts don't scale — they're expensive, hit token limits, and have no concept of which facts are still true.
53
+
54
+ ATLAS solves this by giving agents a **structured, queryable memory layer** that:
55
+
56
+ - Extracts facts automatically from natural language — no schema design needed
57
+ - Scores retrieval by semantic relevance **and** recency — newer facts win
58
+ - Resolves conflicts automatically — updating a fact replaces the old one
59
+ - Persists across sessions, deployments, and model swaps
60
+ - Isolates each customer's data in its own namespace
61
+
62
+ ---
63
+
64
+ ## How it works
65
+
66
+ When an agent ingests text, ATLAS runs it through three steps:
67
+
68
+ **1. Fact extraction** — A small local language model (Qwen 0.5B) reads the text and extracts atomic `Subject → Relation → Object` triples. A spaCy grammar filter removes noise (pronouns, determiners, prepositional fragments).
69
+
70
+ ```
71
+ "Project Apollo now uses PostgreSQL for better JSONB support"
72
+ → [ Project Apollo | uses | PostgreSQL ]
73
+ ```
74
+
75
+ **2. Graph storage** — Facts are stored as nodes and edges in a dedicated Neo4j instance, scoped to the caller's namespace. Every edge carries a `created_at` timestamp. Entity names are resolved to canonical forms via a Redis vector cache — so "Postgres", "PostgreSQL", and "the database" all map to the same node.
76
+
77
+ **3. Temporal retrieval** — When an agent searches, ATLAS scores every candidate fact with:
78
+
79
+ ```
80
+ Score = (0.20 × Semantic similarity)
81
+ + (0.70 × Recency) ← dominant signal
82
+ + (0.10 × Usage frequency)
83
+ + (0.50 × Relation-query alignment)
84
+ ```
85
+
86
+ Recency has the highest weight by design. A fact stored today beats a contradicting fact from last month — this is what makes temporal reasoning work without any special configuration.
87
+
88
+ ---
89
+
90
+ ## The retrieval pipeline (under the hood)
91
+
92
+ For engineers who want to understand what happens on every `/sdk/search` call:
93
+
94
+ ```
95
+ Query text
96
+
97
+
98
+ 1. Keyword extraction (SLM) "What DB?" → ["Database", "Project Apollo"]
99
+
100
+
101
+ 2. Canonical resolution (Redis) "Postgres" → "PostgreSQL"
102
+
103
+
104
+ 3. Hub detection (live graph stats) High-degree nodes dampened as context
105
+
106
+
107
+ 4. Seed node finding (centroid sim) Signal-only probe vector, keyword boost
108
+
109
+
110
+ 5. 2-hop BFS traversal Collect all reachable facts from seeds
111
+
112
+
113
+ 6. Semantic floor filter Drop facts with V < 0.22 (noise removal)
114
+
115
+
116
+ 7. Score each fact α·V + β·R + γ·F + δ·A
117
+
118
+
119
+ 8. Conflict resolution Newest fact wins per (Subject, Relation) slot
120
+
121
+
122
+ Top-k results
123
+ ```
124
+
125
+ ---
126
+
127
+ ## API reference
128
+
129
+ Base URL: `https://your-domain.com` (or `http://localhost:8000` locally)
130
+
131
+ All endpoints require the `x-api-key` header except `/sdk/health`.
132
+
133
+ ---
134
+
135
+ ### `POST /sdk/ingest`
136
+
137
+ Extract facts from text and store them in memory.
138
+
139
+ **Headers**
140
+ ```
141
+ x-api-key: atlas_...
142
+ Content-Type: application/json
143
+ ```
144
+
145
+ **Body**
146
+ ```json
147
+ {
148
+ "text": "Project Apollo now uses PostgreSQL as the primary database.",
149
+ "session_id": "optional-user-or-conversation-id"
150
+ }
151
+ ```
152
+
153
+ **Response**
154
+ ```json
155
+ {
156
+ "status": "ok",
157
+ "facts_stored": 1,
158
+ "facts": [
159
+ {
160
+ "subject": "Project Apollo",
161
+ "relation": "uses",
162
+ "object": "PostgreSQL"
163
+ }
164
+ ],
165
+ "namespace": "your_org_abc123:optional-session-id"
166
+ }
167
+ ```
168
+
169
+ **Tips for best extraction quality:**
170
+ - Use direct declarative sentences: `"X uses Y"`, `"X is Y"`, `"X is hosted on Y"`
171
+ - Avoid first-person summaries: `"The user mentioned that..."` — the SLM rejects pronoun subjects by design
172
+ - One concept per sentence gives cleaner triples than long compound sentences
173
+
174
+ ---
175
+
176
+ ### `POST /sdk/search`
177
+
178
+ Search memory with a natural language query.
179
+
180
+ **Body**
181
+ ```json
182
+ {
183
+ "query": "What database does Project Apollo use?",
184
+ "k": 5,
185
+ "session_id": "optional-same-session-id-as-ingest"
186
+ }
187
+ ```
188
+
189
+ **Response**
190
+ ```json
191
+ {
192
+ "query": "What database does Project Apollo use?",
193
+ "results": [
194
+ {
195
+ "fact": "Project Apollo uses PostgreSQL",
196
+ "subject": "Project Apollo",
197
+ "relation": "uses",
198
+ "object": "PostgreSQL",
199
+ "score": 1.06,
200
+ "recency": 0.999,
201
+ "V": 0.74,
202
+ "R": 0.999,
203
+ "F": 1.0,
204
+ "A": 0.23
205
+ }
206
+ ],
207
+ "count": 1,
208
+ "namespace": "your_org_abc123:optional-session-id"
209
+ }
210
+ ```
211
+
212
+ Score breakdown per result:
213
+ - `V` — How semantically similar this fact is to your query (0–1)
214
+ - `R` — How recent this fact is; decays exponentially with age (0–1)
215
+ - `F` — How frequently this entity has been referenced (0–1)
216
+ - `A` — How well the relation phrase aligns with the query intent (0–1)
217
+
218
+ ---
219
+
220
+ ### `DELETE /sdk/clear`
221
+
222
+ Delete all facts for this API key (and optional session).
223
+
224
+ ```
225
+ DELETE /sdk/clear?session_id=optional-session-id
226
+ ```
227
+
228
+ ---
229
+
230
+ ### `GET /sdk/usage`
231
+
232
+ Check monthly operation usage and limits.
233
+
234
+ **Response**
235
+ ```json
236
+ {
237
+ "org_name": "ACME Corp",
238
+ "tier": "starter",
239
+ "price": "$29/mo",
240
+ "ops_used": 1240,
241
+ "ops_limit": 50000,
242
+ "ops_remaining": 48760
243
+ }
244
+ ```
245
+
246
+ ---
247
+
248
+ ### `GET /sdk/health`
249
+
250
+ Liveness probe. No authentication required.
251
+
252
+ ```json
253
+ {"status": "healthy", "service": "atlas-sdk", "version": "1.0.0"}
254
+ ```
255
+
256
+ ---
257
+
258
+ ## Pricing
259
+
260
+ 1 operation = 1 ingest call **or** 1 search call. Resets monthly.
261
+
262
+ | Plan | Price | Ops / month | Best for |
263
+ |---|---|---|---|
264
+ | **Free** | $0 | 1,000 | Development and testing |
265
+ | **Starter** | $29 | 50,000 | Indie developers, small teams |
266
+ | **Pro** | $99 | 500,000 | Growing products |
267
+ | **Scale** | $299 | 5,000,000 | High-volume AI applications |
268
+ | **Enterprise** | Custom | Unlimited | Self-hosted, SLA, compliance |
269
+
270
+ **Overage:** $0.01 per 100 ops beyond your plan limit (Starter and above).
271
+
272
+ **Enterprise plan includes:**
273
+ - Self-hosted deployment (your VPC, your data never leaves)
274
+ - SSO and audit logs
275
+ - Custom SLA with guaranteed uptime
276
+ - Dedicated customer success manager
277
+ - Custom onboarding and integration support
278
+
279
+ ---
280
+
281
+ ## Integration guides
282
+
283
+ ### Python (any agent)
284
+
285
+ ```python
286
+ from atlas_sdk import AtlasMemory
287
+
288
+ memory = AtlasMemory(
289
+ api_key="atlas_...",
290
+ base_url="https://your-domain.com",
291
+ session_id="user-123" # optional — isolates per user/conversation
292
+ )
293
+
294
+ # Store a fact
295
+ memory.ingest("The project deadline is March 31st.")
296
+
297
+ # Retrieve relevant context
298
+ results = memory.search("When is the deadline?")
299
+
300
+ # Inject into your LLM prompt
301
+ context = memory.format_context(results)
302
+ ```
303
+
304
+ ---
305
+
306
+ ### OpenAI function calling
307
+
308
+ ```python
309
+ from atlas_sdk import AtlasMemory
310
+ from openai import OpenAI
311
+
312
+ memory = AtlasMemory(api_key="atlas_...", base_url="https://your-domain.com")
313
+ client = OpenAI()
314
+
315
+ response = client.chat.completions.create(
316
+ model="gpt-4o",
317
+ messages=[{"role": "user", "content": user_message}],
318
+ tools=memory.get_openai_tools(), # returns save + search tool definitions
319
+ tool_choice="auto",
320
+ )
321
+
322
+ # Handle tool calls
323
+ for tc in response.choices[0].message.tool_calls or []:
324
+ result = memory.handle_tool_call(tc.function.name, json.loads(tc.function.arguments))
325
+ ```
326
+
327
+ The SDK provides two tools out of the box:
328
+ - `atlas_save_memory` — the agent calls this when it learns something worth remembering
329
+ - `atlas_search_memory` — the agent calls this before answering questions about past context
330
+
331
+ ---
332
+
333
+ ### LangChain
334
+
335
+ ```python
336
+ from atlas_sdk import AtlasMemory
337
+
338
+ memory = AtlasMemory(api_key="atlas_...", base_url="https://your-domain.com")
339
+ tools = memory.get_langchain_tools() # returns LangChain Tool objects
340
+
341
+ # Drop directly into any LangChain agent
342
+ agent = create_openai_tools_agent(llm, tools, prompt)
343
+ ```
344
+
345
+ ---
346
+
347
+ ### Any REST-capable framework
348
+
349
+ ATLAS is framework-agnostic. If your agent can make HTTP requests, it can use ATLAS.
350
+
351
+ ```
352
+ POST /sdk/ingest { "text": "...", "session_id": "..." }
353
+ POST /sdk/search { "query": "...", "k": 5, "session_id": "..." }
354
+ ```
355
+
356
+ Compatible with: CrewAI, AutoGen, Semantic Kernel, Haystack, custom agents, n8n, Make, Zapier.
357
+
358
+ ---
359
+
360
+ ## Namespacing and data isolation
361
+
362
+ Every API key maps to a unique namespace. No two customers share graph nodes, edges, or vector cache entries — enforced at the database query level, not the application level.
363
+
364
+ The optional `session_id` parameter creates a sub-namespace within your key's namespace. Use this to isolate memory per user, per conversation, or per agent:
365
+
366
+ ```
367
+ API key namespace: acme_corp_a1b2c3
368
+ With session_id: acme_corp_a1b2c3:user-456
369
+ ```
370
+
371
+ A search with `session_id: user-456` only sees facts ingested with the same `session_id`. Different users never see each other's memories.
372
+
373
+ ---
374
+
375
+ ## Self-hosted architecture
376
+
377
+ The SDK service runs as a standalone Docker container alongside two dedicated databases:
378
+
379
+ ```
380
+ Your infrastructure
381
+ ├── sdk-service (FastAPI, port 5008, ~5GB RAM)
382
+ │ ├── Qwen 0.5B (fact extraction SLM, ~1.5GB)
383
+ │ ├── MiniLM (sentence embedder, ~0.5GB)
384
+ │ └── spaCy (grammar filter, ~50MB)
385
+ ├── neo4j-sdk (knowledge graph, dedicated)
386
+ └── redis-sdk (vector cache + API key store, dedicated)
387
+ ```
388
+
389
+ The SDK databases are fully isolated from any other services in your stack. They do not share storage with your application's Neo4j or Redis instances.
390
+
391
+ Models are downloaded on first boot to a persistent Docker volume (`hf_cache`) and reused on every subsequent restart — no re-downloading on rebuild.
392
+
393
+ ---
394
+
395
+ ## Admin operations
396
+
397
+ Create and manage API keys via the admin endpoints. Requires the `x-admin-secret` header.
398
+
399
+ ```bash
400
+ # Create a key
401
+ POST /sdk/admin/create-key
402
+ { "org_name": "ACME Corp", "tier": "starter" }
403
+
404
+ # List all keys
405
+ GET /sdk/admin/keys
406
+
407
+ # Upgrade a tier
408
+ PATCH /sdk/admin/upgrade?api_key=atlas_...&new_tier=pro
409
+
410
+ # Deactivate a key
411
+ DELETE /sdk/admin/deactivate?api_key=atlas_...
412
+ ```
413
+
414
+ ---
415
+
416
+ ## FAQ
417
+
418
+ **Does ATLAS replace my vector database?**
419
+ No. ATLAS is a memory layer for agents — it stores structured facts with temporal context. A vector database stores embeddings for semantic search over documents. They serve different purposes and can be used together.
420
+
421
+ **What happens when a fact changes?**
422
+ Ingest the updated fact with the same subject and relation. ATLAS stores both facts but the conflict resolver surfaces only the most recent one in search results. Old facts are preserved for audit purposes.
423
+
424
+ **How long do facts persist?**
425
+ Indefinitely until you call `/sdk/clear`. There is no automatic expiry.
426
+
427
+ **Can I use ATLAS without the SLM (bring my own triples)?**
428
+ Not in this version. A direct triple ingestion endpoint (`POST /sdk/ingest/triple`) is on the roadmap.
429
+
430
+ **Is the data encrypted?**
431
+ Data is encrypted at rest by the underlying Neo4j and Redis storage engines. Transport is encrypted via HTTPS (configure your reverse proxy). For stricter compliance requirements, use the Enterprise self-hosted plan.
432
+
433
+ **What languages does fact extraction support?**
434
+ English only in this version. Multilingual support is on the roadmap.
435
+
436
+ ---
437
+
438
+ ## Changelog
439
+
440
+ ### v1.0.0
441
+ - Initial release
442
+ - Multi-tenant namespace isolation
443
+ - Temporal scoring: α·V + β·R + γ·F + δ·A
444
+ - Dynamic hub detection (no hardcoded ontologies)
445
+ - OpenAI function calling integration
446
+ - LangChain tool wrappers
447
+ - Tier-based rate limiting (Free / Starter / Pro / Scale / Enterprise)
448
+ - Dedicated Neo4j and Redis instances per deployment