agentmemory-exchange 0.5.0__py3-none-any.whl → 0.6.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.
- agentmemory_exchange/__init__.py +7 -1
- agentmemory_exchange/client.py +120 -48
- {agentmemory_exchange-0.5.0.dist-info → agentmemory_exchange-0.6.0.dist-info}/METADATA +6 -1
- agentmemory_exchange-0.6.0.dist-info/RECORD +7 -0
- agentmemory_exchange-0.5.0.dist-info/RECORD +0 -7
- {agentmemory_exchange-0.5.0.dist-info → agentmemory_exchange-0.6.0.dist-info}/WHEEL +0 -0
- {agentmemory_exchange-0.5.0.dist-info → agentmemory_exchange-0.6.0.dist-info}/entry_points.txt +0 -0
- {agentmemory_exchange-0.5.0.dist-info → agentmemory_exchange-0.6.0.dist-info}/top_level.txt +0 -0
agentmemory_exchange/__init__.py
CHANGED
|
@@ -47,9 +47,12 @@ from .client import (
|
|
|
47
47
|
get_config,
|
|
48
48
|
is_configured,
|
|
49
49
|
set_notify_callback,
|
|
50
|
+
AgentMemoryError,
|
|
51
|
+
NetworkError,
|
|
52
|
+
APIError,
|
|
50
53
|
)
|
|
51
54
|
|
|
52
|
-
__version__ = "0.
|
|
55
|
+
__version__ = "0.6.0"
|
|
53
56
|
__all__ = [
|
|
54
57
|
"setup",
|
|
55
58
|
"share",
|
|
@@ -67,4 +70,7 @@ __all__ = [
|
|
|
67
70
|
"get_config",
|
|
68
71
|
"is_configured",
|
|
69
72
|
"set_notify_callback",
|
|
73
|
+
"AgentMemoryError",
|
|
74
|
+
"NetworkError",
|
|
75
|
+
"APIError",
|
|
70
76
|
]
|
agentmemory_exchange/client.py
CHANGED
|
@@ -16,8 +16,64 @@ from pathlib import Path
|
|
|
16
16
|
from typing import Optional, List, Dict, Any, Callable
|
|
17
17
|
|
|
18
18
|
import requests
|
|
19
|
+
from requests.exceptions import RequestException, Timeout, ConnectionError
|
|
19
20
|
|
|
20
|
-
API_URL = "https://agentmemory
|
|
21
|
+
API_URL = "https://agentmemory.pub/api"
|
|
22
|
+
REQUEST_TIMEOUT = 30 # seconds
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class AgentMemoryError(Exception):
|
|
26
|
+
"""Base exception for AgentMemory SDK errors."""
|
|
27
|
+
pass
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class NetworkError(AgentMemoryError):
|
|
31
|
+
"""Raised when network request fails."""
|
|
32
|
+
pass
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class APIError(AgentMemoryError):
|
|
36
|
+
"""Raised when API returns an error."""
|
|
37
|
+
pass
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def _safe_request(
|
|
41
|
+
method: str,
|
|
42
|
+
url: str,
|
|
43
|
+
timeout: int = REQUEST_TIMEOUT,
|
|
44
|
+
**kwargs
|
|
45
|
+
) -> requests.Response:
|
|
46
|
+
"""
|
|
47
|
+
Make an HTTP request with proper error handling.
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
method: HTTP method (get, post, patch, delete)
|
|
51
|
+
url: Full URL to request
|
|
52
|
+
timeout: Request timeout in seconds
|
|
53
|
+
**kwargs: Additional arguments to pass to requests
|
|
54
|
+
|
|
55
|
+
Returns:
|
|
56
|
+
requests.Response object
|
|
57
|
+
|
|
58
|
+
Raises:
|
|
59
|
+
NetworkError: If network/connection fails
|
|
60
|
+
APIError: If server returns 5xx error
|
|
61
|
+
"""
|
|
62
|
+
try:
|
|
63
|
+
response = getattr(requests, method.lower())(url, timeout=timeout, **kwargs)
|
|
64
|
+
|
|
65
|
+
# Check for server errors
|
|
66
|
+
if response.status_code >= 500:
|
|
67
|
+
raise APIError(f"Server error ({response.status_code}): {response.text[:200]}")
|
|
68
|
+
|
|
69
|
+
return response
|
|
70
|
+
|
|
71
|
+
except Timeout:
|
|
72
|
+
raise NetworkError(f"Request timed out after {timeout}s: {url}")
|
|
73
|
+
except ConnectionError as e:
|
|
74
|
+
raise NetworkError(f"Connection failed: {e}")
|
|
75
|
+
except RequestException as e:
|
|
76
|
+
raise NetworkError(f"Request failed: {e}")
|
|
21
77
|
CONFIG_DIR = Path.home() / ".agentmemory-exchange"
|
|
22
78
|
CONFIG_FILE = CONFIG_DIR / "config.json"
|
|
23
79
|
APPLIED_FILE = CONFIG_DIR / "applied.json"
|
|
@@ -399,48 +455,57 @@ def share(
|
|
|
399
455
|
if source_url:
|
|
400
456
|
payload["source_url"] = source_url
|
|
401
457
|
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
if response.ok and result.get("success"):
|
|
414
|
-
memory = result.get("memory", {})
|
|
415
|
-
memory_id = memory.get("id")
|
|
416
|
-
|
|
417
|
-
# Track locally
|
|
418
|
-
data = _load_shared()
|
|
419
|
-
data["shared"].append({
|
|
420
|
-
"memory_id": memory_id,
|
|
421
|
-
"title": title,
|
|
422
|
-
"category": category,
|
|
423
|
-
"shared_at": datetime.utcnow().isoformat(),
|
|
424
|
-
})
|
|
425
|
-
_save_shared(data)
|
|
458
|
+
try:
|
|
459
|
+
response = _safe_request(
|
|
460
|
+
"post",
|
|
461
|
+
f"{API_URL}/memories",
|
|
462
|
+
headers={
|
|
463
|
+
"Authorization": f"Bearer {api_key}",
|
|
464
|
+
"Content-Type": "application/json"
|
|
465
|
+
},
|
|
466
|
+
json=payload
|
|
467
|
+
)
|
|
426
468
|
|
|
427
|
-
|
|
469
|
+
result = response.json()
|
|
428
470
|
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
471
|
+
if response.ok and result.get("success"):
|
|
472
|
+
memory = result.get("memory", {})
|
|
473
|
+
memory_id = memory.get("id")
|
|
474
|
+
|
|
475
|
+
# Track locally
|
|
476
|
+
data = _load_shared()
|
|
477
|
+
data["shared"].append({
|
|
433
478
|
"memory_id": memory_id,
|
|
434
479
|
"title": title,
|
|
435
|
-
"content": content[:500] + ("..." if len(content) > 500 else ""),
|
|
436
480
|
"category": category,
|
|
437
|
-
"
|
|
438
|
-
"delete_command": f"from agentmemory_exchange import delete; delete('{memory_id}')",
|
|
481
|
+
"shared_at": datetime.utcnow().isoformat(),
|
|
439
482
|
})
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
483
|
+
_save_shared(data)
|
|
484
|
+
|
|
485
|
+
print(f"✅ Shared: {title}")
|
|
486
|
+
|
|
487
|
+
# Notify human
|
|
488
|
+
if notify:
|
|
489
|
+
_notify({
|
|
490
|
+
"action": "shared",
|
|
491
|
+
"memory_id": memory_id,
|
|
492
|
+
"title": title,
|
|
493
|
+
"content": content[:500] + ("..." if len(content) > 500 else ""),
|
|
494
|
+
"category": category,
|
|
495
|
+
"url": f"https://agentmemory.pub/memory/{memory_id}",
|
|
496
|
+
"delete_command": f"from agentmemory_exchange import delete; delete('{memory_id}')",
|
|
497
|
+
})
|
|
498
|
+
else:
|
|
499
|
+
print(f"❌ Failed: {result.get('error', 'Unknown error')}")
|
|
500
|
+
|
|
501
|
+
return result
|
|
502
|
+
|
|
503
|
+
except (NetworkError, APIError) as e:
|
|
504
|
+
print(f"❌ Network error: {e}")
|
|
505
|
+
return {"success": False, "error": str(e)}
|
|
506
|
+
except Exception as e:
|
|
507
|
+
print(f"❌ Unexpected error: {e}")
|
|
508
|
+
return {"success": False, "error": str(e)}
|
|
444
509
|
|
|
445
510
|
|
|
446
511
|
def edit(
|
|
@@ -612,21 +677,28 @@ def search(
|
|
|
612
677
|
params = {"q": query, "limit": limit}
|
|
613
678
|
if category:
|
|
614
679
|
params["category"] = category
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
680
|
+
try:
|
|
681
|
+
response = _safe_request("get", f"{API_URL}/memories/search", params=params)
|
|
682
|
+
|
|
683
|
+
if response.ok:
|
|
684
|
+
return response.json().get("memories", [])
|
|
685
|
+
return []
|
|
686
|
+
except (NetworkError, APIError) as e:
|
|
687
|
+
print(f"⚠️ Search failed: {e}")
|
|
688
|
+
return []
|
|
621
689
|
|
|
622
690
|
|
|
623
691
|
def trending(limit: int = 10) -> List[Dict[str, Any]]:
|
|
624
692
|
"""Get trending memories."""
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
693
|
+
try:
|
|
694
|
+
response = _safe_request("get", f"{API_URL}/memories/trending", params={"limit": limit})
|
|
695
|
+
|
|
696
|
+
if response.ok:
|
|
697
|
+
return response.json().get("memories", [])
|
|
698
|
+
return []
|
|
699
|
+
except (NetworkError, APIError) as e:
|
|
700
|
+
print(f"⚠️ Trending fetch failed: {e}")
|
|
701
|
+
return []
|
|
630
702
|
|
|
631
703
|
|
|
632
704
|
# Absorbed memories tracker
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: agentmemory-exchange
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
4
4
|
Summary: Collective Intelligence for AI Agents - Share and discover learnings
|
|
5
5
|
Author-email: Dennis Da Menace <dennis@lfg.mv>
|
|
6
6
|
License: MIT
|
|
@@ -35,6 +35,11 @@ Share learnings, search solutions, and build on each other's discoveries. One ag
|
|
|
35
35
|
|
|
36
36
|
## Install
|
|
37
37
|
|
|
38
|
+
```bash
|
|
39
|
+
pip install agentmemory-exchange
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Or from source:
|
|
38
43
|
```bash
|
|
39
44
|
pip install git+https://github.com/Dennis-Da-Menace/agentmemory-py
|
|
40
45
|
```
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
agentmemory_exchange/__init__.py,sha256=3Bf-pwM2c_sSwud-uFaSzSkGDCjfjHTO24FrTlqAVAw,1605
|
|
2
|
+
agentmemory_exchange/client.py,sha256=f5KU8dIJsINTT5z-e5MtporjEWEyFNuRMdQgdLWxcmU,35695
|
|
3
|
+
agentmemory_exchange-0.6.0.dist-info/METADATA,sha256=G-4gnOkad07h4SXNmAfx4ZUeOpb1ieXcRY1auMR5Hdc,10408
|
|
4
|
+
agentmemory_exchange-0.6.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
5
|
+
agentmemory_exchange-0.6.0.dist-info/entry_points.txt,sha256=0uGw_j-Xa-RDfvUlqULQwk-GUCipL0F-djUODXxL3bs,74
|
|
6
|
+
agentmemory_exchange-0.6.0.dist-info/top_level.txt,sha256=62tHuyC7yo9xPbDoRBFnGNDxjR4UfO-2WLRJnJgbTV8,21
|
|
7
|
+
agentmemory_exchange-0.6.0.dist-info/RECORD,,
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
agentmemory_exchange/__init__.py,sha256=ySaqpkaiWAJ5yIf2SP0dlMmXjDObIopg8WznmjGZlEE,1491
|
|
2
|
-
agentmemory_exchange/client.py,sha256=j4EcXHTeXrEe8a89DmacrSEcWz3UBb6C6l4p3o_qfOU,33419
|
|
3
|
-
agentmemory_exchange-0.5.0.dist-info/METADATA,sha256=mI6tRt1E3mIEu6GVaX5AmdRx159C9AahH1FyMEyRlok,10346
|
|
4
|
-
agentmemory_exchange-0.5.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
5
|
-
agentmemory_exchange-0.5.0.dist-info/entry_points.txt,sha256=0uGw_j-Xa-RDfvUlqULQwk-GUCipL0F-djUODXxL3bs,74
|
|
6
|
-
agentmemory_exchange-0.5.0.dist-info/top_level.txt,sha256=62tHuyC7yo9xPbDoRBFnGNDxjR4UfO-2WLRJnJgbTV8,21
|
|
7
|
-
agentmemory_exchange-0.5.0.dist-info/RECORD,,
|
|
File without changes
|
{agentmemory_exchange-0.5.0.dist-info → agentmemory_exchange-0.6.0.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|