agent-memory-server 0.12.4__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.
Files changed (37) hide show
  1. agent_memory_server/__init__.py +3 -0
  2. agent_memory_server/_aws/__init__.py +0 -0
  3. agent_memory_server/_aws/clients.py +74 -0
  4. agent_memory_server/_aws/utils.py +89 -0
  5. agent_memory_server/api.py +1032 -0
  6. agent_memory_server/auth.py +453 -0
  7. agent_memory_server/cli.py +671 -0
  8. agent_memory_server/config.py +429 -0
  9. agent_memory_server/dependencies.py +80 -0
  10. agent_memory_server/docket_tasks.py +59 -0
  11. agent_memory_server/extraction.py +343 -0
  12. agent_memory_server/filters.py +252 -0
  13. agent_memory_server/healthcheck.py +20 -0
  14. agent_memory_server/llms.py +454 -0
  15. agent_memory_server/logging.py +109 -0
  16. agent_memory_server/long_term_memory.py +1801 -0
  17. agent_memory_server/main.py +157 -0
  18. agent_memory_server/mcp.py +1085 -0
  19. agent_memory_server/memory_strategies.py +573 -0
  20. agent_memory_server/migrations.py +135 -0
  21. agent_memory_server/models.py +735 -0
  22. agent_memory_server/prompt_security.py +262 -0
  23. agent_memory_server/summarization.py +281 -0
  24. agent_memory_server/utils/__init__.py +0 -0
  25. agent_memory_server/utils/api_keys.py +26 -0
  26. agent_memory_server/utils/keys.py +89 -0
  27. agent_memory_server/utils/recency.py +161 -0
  28. agent_memory_server/utils/redis.py +50 -0
  29. agent_memory_server/utils/redis_query.py +94 -0
  30. agent_memory_server/vectorstore_adapter.py +1427 -0
  31. agent_memory_server/vectorstore_factory.py +335 -0
  32. agent_memory_server/working_memory.py +400 -0
  33. agent_memory_server-0.12.4.dist-info/METADATA +266 -0
  34. agent_memory_server-0.12.4.dist-info/RECORD +37 -0
  35. agent_memory_server-0.12.4.dist-info/WHEEL +4 -0
  36. agent_memory_server-0.12.4.dist-info/entry_points.txt +2 -0
  37. agent_memory_server-0.12.4.dist-info/licenses/LICENSE +202 -0
@@ -0,0 +1,3 @@
1
+ """Redis Agent Memory Server - A memory system for conversational AI."""
2
+
3
+ __version__ = "0.12.4"
File without changes
@@ -0,0 +1,74 @@
1
+ """AWS clients for the Agent Memory Server.
2
+
3
+ This module contains utilities for creating and managing AWS clients.
4
+ """
5
+
6
+ from typing import TYPE_CHECKING
7
+
8
+ from boto3 import Session
9
+
10
+ from agent_memory_server.config import settings
11
+
12
+
13
+ if TYPE_CHECKING:
14
+ from mypy_boto3_bedrock import BedrockClient
15
+ from mypy_boto3_bedrock_runtime import BedrockRuntimeClient
16
+
17
+
18
+ def create_aws_session(
19
+ region_name: str | None = None, credentials: dict[str, str] | None = None
20
+ ) -> Session:
21
+ """Create an AWS session.
22
+
23
+ Args:
24
+ credentials (dict[str, str | None]): The AWS credentials to use.
25
+
26
+ Returns:
27
+ An AWS session.
28
+ """
29
+ if credentials is None:
30
+ credentials = settings.aws_credentials
31
+ if region_name is None:
32
+ region_name = settings.aws_region
33
+ return Session(region_name=region_name, **credentials)
34
+
35
+
36
+ def create_bedrock_client(
37
+ region_name: str | None = None,
38
+ session: Session | None = None,
39
+ ) -> "BedrockClient":
40
+ """Create a Bedrock client.
41
+
42
+ Args:
43
+ region_name (str | None): The AWS region to use.\
44
+ If not provided, it will be picked up from the environment.
45
+ session (Session | None): The AWS session to use.\
46
+ If not provided, a new session will be created based on the environment.
47
+ """
48
+ if session is None:
49
+ session = create_aws_session(region_name=region_name)
50
+ if region_name is None:
51
+ region_name = settings.aws_region
52
+ return session.client("bedrock", region_name=region_name)
53
+
54
+
55
+ def create_bedrock_runtime_client(
56
+ region_name: str | None = None,
57
+ session: Session | None = None,
58
+ ) -> "BedrockRuntimeClient":
59
+ """Create a Bedrock runtime client.
60
+
61
+ Args:
62
+ region_name (str | None): The AWS region to use.\
63
+ If not provided, it will be picked up from the environment.
64
+ session (Session | None): The AWS session to use.\
65
+ If not provided, a new session will be created based on the environment.
66
+
67
+ Returns:
68
+ A Bedrock runtime client.
69
+ """
70
+ if session is None:
71
+ session = create_aws_session(region_name=region_name)
72
+ if region_name is None:
73
+ region_name = settings.aws_region
74
+ return session.client("bedrock-runtime", region_name=region_name)
@@ -0,0 +1,89 @@
1
+ """AWS utilities for the Agent Memory Server.
2
+
3
+ This module contains utilities for working with AWS services.
4
+ """
5
+
6
+ from botocore.exceptions import ClientError
7
+ from cachetools import TTLCache, cached
8
+
9
+ from agent_memory_server._aws.clients import create_bedrock_client
10
+ from agent_memory_server.logging import get_logger
11
+
12
+
13
+ logger = get_logger(__name__)
14
+
15
+
16
+ @cached(cache=TTLCache(maxsize=16, ttl=60 * 60)) # 1 hour
17
+ def bedrock_embedding_model_exists(
18
+ model_id: str,
19
+ region_name: str | None = None,
20
+ ) -> bool:
21
+ """Returns True if a Bedrock embedding model with the given model_id exists.
22
+
23
+ Args:
24
+ model_id (str): The ID of the Bedrock model to check.
25
+ region_name (str | None): The AWS region to check. If not provided, it will be picked up from the environment.
26
+
27
+ Returns:
28
+ True if an embedding model with the given ID exists, False otherwise.
29
+ Returns True on credential/permission errors to allow the actual embedding call to proceed.
30
+ """
31
+ client = create_bedrock_client(region_name=region_name)
32
+
33
+ try:
34
+ response = client.list_foundation_models(byOutputModality="EMBEDDING")
35
+ for model_info in response.get("modelSummaries", []):
36
+ output_modalities: list[str] = model_info.get("outputModalities", [])
37
+ is_embedding: bool = (
38
+ "EMBEDDING" in output_modalities
39
+ or model_info.get("modelModality") == "EMBEDDING"
40
+ )
41
+ if not is_embedding:
42
+ continue
43
+ maybe_model_id: str | None = model_info.get("modelId")
44
+ if maybe_model_id == model_id:
45
+ return True
46
+ return False
47
+ except ClientError:
48
+ logger.exception(
49
+ f"Error checking if Bedrock embedding model {model_id} exists. "
50
+ "Defaulting to False."
51
+ )
52
+ return False
53
+
54
+
55
+ @cached(cache=TTLCache(maxsize=16, ttl=60 * 60)) # 1 hour
56
+ def bedrock_llm_model_exists(
57
+ model_id: str,
58
+ region_name: str | None = None,
59
+ ) -> bool:
60
+ """Returns True if a Bedrock LLM (text generation) model with the given model_id exists.
61
+
62
+ Args:
63
+ model_id (str): The ID of the Bedrock model to check.
64
+ region_name (str | None): The AWS region to check. If not provided, it will be picked up from the environment.
65
+
66
+ Returns:
67
+ True if a text generation model with the given ID exists, False otherwise.
68
+ Returns True on credential/permission errors to allow the actual LLM call to proceed.
69
+ """
70
+ client = create_bedrock_client(region_name=region_name)
71
+
72
+ try:
73
+ response = client.list_foundation_models(byOutputModality="TEXT")
74
+ for model_info in response.get("modelSummaries", []):
75
+ output_modalities: list[str] = model_info.get("outputModalities", [])
76
+ # Check if this is a text generation model (has TEXT in output modalities)
77
+ is_text_model: bool = "TEXT" in output_modalities
78
+ if not is_text_model:
79
+ continue
80
+ maybe_model_id: str | None = model_info.get("modelId")
81
+ if maybe_model_id == model_id:
82
+ return True
83
+ return False
84
+ except ClientError:
85
+ logger.exception(
86
+ f"Error checking if Bedrock LLM model {model_id} exists. "
87
+ "Defaulting to False."
88
+ )
89
+ return False