memgraph-sdk 0.7.0__tar.gz → 0.7.2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: memgraph-sdk
3
- Version: 0.7.0
3
+ Version: 0.7.2
4
4
  Summary: Memory that helps AI agents learn from their mistakes. Store beliefs, search with semantic similarity, track decision traces.
5
5
  Project-URL: Homepage, https://memgraph.ai
6
6
  Project-URL: Documentation, https://memgraph.ai/docs
@@ -51,7 +51,7 @@ Requires-Dist: mcp>=1.0.0; extra == 'mcp'
51
51
  Description-Content-Type: text/markdown
52
52
 
53
53
  <p align="center">
54
- <img src="assets/logo.png" alt="Memgraph AI" width="400">
54
+ <img src="https://raw.githubusercontent.com/shubhamdev0/memgraph-sdk/main/assets/logo.png" alt="Memgraph AI" width="400">
55
55
  </p>
56
56
 
57
57
  <h3 align="center">Memory that helps AI agents learn from their mistakes</h3>
@@ -1,5 +1,5 @@
1
1
  <p align="center">
2
- <img src="assets/logo.png" alt="Memgraph AI" width="400">
2
+ <img src="https://raw.githubusercontent.com/shubhamdev0/memgraph-sdk/main/assets/logo.png" alt="Memgraph AI" width="400">
3
3
  </p>
4
4
 
5
5
  <h3 align="center">Memory that helps AI agents learn from their mistakes</h3>
@@ -1,6 +1,6 @@
1
1
  """Memgraph SDK - The official Python SDK for Memgraph, the memory graph for AI agents."""
2
2
 
3
- __version__ = "0.7.0"
3
+ __version__ = "0.7.2"
4
4
 
5
5
  from .client import MemgraphClient
6
6
  from .exceptions import (
@@ -192,20 +192,29 @@ def remember_cmd(text: str, category: str = "general"):
192
192
  return
193
193
 
194
194
  try:
195
+ import hashlib
196
+ short = text[:60].strip().lower()
197
+ clean = "".join(c if c.isalnum() or c == " " else "" for c in short)
198
+ text_hash = hashlib.md5(text.encode()).hexdigest()[:6]
199
+ belief_key = f"{category}_{'_'.join(clean.split()[:5])}_{text_hash}"
200
+
195
201
  resp = requests.post(
196
- f"{config['api_url']}/ingest",
197
- data={
198
- "tenant_id": config["tenant_id"],
199
- "user_id": "cli_user",
200
- "text": f"[{category}] {text}",
202
+ f"{config['api_url']}/beliefs",
203
+ json={
204
+ "subject_id": "cli_user",
205
+ "key": belief_key,
206
+ "value": text,
207
+ "confidence": 0.9,
208
+ "belief_type": "belief",
209
+ "domain": "general",
201
210
  },
202
211
  headers={"X-API-KEY": config.get("api_key", "")},
203
212
  timeout=10
204
213
  )
205
- if resp.status_code == 200:
214
+ if resp.status_code in (200, 201):
206
215
  print(f"✅ Remembered: {text[:80]}...")
207
216
  else:
208
- print(f"❌ Error: {resp.text}")
217
+ print(f"❌ Error: {resp.text[:200]}")
209
218
  except requests.ConnectionError:
210
219
  print("❌ Cannot connect to Memgraph server")
211
220
 
@@ -222,31 +231,30 @@ def recall_cmd(query: str):
222
231
  return
223
232
 
224
233
  try:
234
+ # Use v2/context endpoint (returns proper JSON with scored results)
235
+ v2_url = config['api_url'].replace("/v1", "/v2")
225
236
  resp = requests.post(
226
- f"{config['api_url']}/context",
237
+ f"{v2_url}/context",
227
238
  json={
228
- "tenant_id": config["tenant_id"],
239
+ "query": query,
229
240
  "user_id": "cli_user",
230
- "task": query,
231
- "agent_id": "cli"
232
241
  },
233
242
  headers={"X-API-KEY": config.get("api_key", "")},
234
243
  timeout=10
235
244
  )
236
245
  if resp.status_code == 200:
237
246
  data = resp.json()
238
- results = data.get("results", [])
239
- if results:
240
- print(f"\n🔍 Found {len(results)} results for '{query}':\n")
241
- for r in results:
242
- if isinstance(r, dict):
243
- print(f" • {r.get('text', r)}")
244
- else:
245
- print(f" • {r}")
247
+ memories = data.get("memories", [])
248
+ if memories:
249
+ print(f"\n🔍 Found {len(memories)} results for '{query}':\n")
250
+ for m in memories:
251
+ score = m.get("score", 0)
252
+ content = m.get("content", str(m))
253
+ print(f" [{score:.2f}] {content}")
246
254
  else:
247
255
  print("No memories found for this query.")
248
256
  else:
249
- print(f"❌ Error: {resp.text}")
257
+ print(f"❌ Error: {resp.text[:200]}")
250
258
  except requests.ConnectionError:
251
259
  print("❌ Cannot connect to Memgraph server")
252
260
 
File without changes
File without changes