langgraph-checkpoint-aws 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.
- langgraph_checkpoint_aws-0.1.0/LICENSE +21 -0
- langgraph_checkpoint_aws-0.1.0/PKG-INFO +216 -0
- langgraph_checkpoint_aws-0.1.0/README.md +195 -0
- langgraph_checkpoint_aws-0.1.0/langgraph_checkpoint_aws/__init__.py +6 -0
- langgraph_checkpoint_aws-0.1.0/langgraph_checkpoint_aws/constants.py +3 -0
- langgraph_checkpoint_aws-0.1.0/langgraph_checkpoint_aws/models.py +382 -0
- langgraph_checkpoint_aws-0.1.0/langgraph_checkpoint_aws/saver.py +567 -0
- langgraph_checkpoint_aws-0.1.0/langgraph_checkpoint_aws/session.py +205 -0
- langgraph_checkpoint_aws-0.1.0/langgraph_checkpoint_aws/utils.py +446 -0
- langgraph_checkpoint_aws-0.1.0/pyproject.toml +81 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) LangChain, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: langgraph-checkpoint-aws
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A LangChain checkpointer implementation that uses Bedrock Session Management Service to enable stateful and resumable LangGraph agents.
|
|
5
|
+
Home-page: https://github.com/langchain-ai/langchain-aws
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: aws,bedrock,langchain,langgraph,checkpointer
|
|
8
|
+
Requires-Python: >=3.9,<4.0
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Requires-Dist: boto3 (>=1.37.3)
|
|
16
|
+
Requires-Dist: langgraph (>=0.2.55)
|
|
17
|
+
Requires-Dist: langgraph-checkpoint (>=2.0.0)
|
|
18
|
+
Project-URL: Repository, https://github.com/langchain-ai/langchain-aws
|
|
19
|
+
Project-URL: Source Code, https://github.com/langchain-ai/langchain-aws/tree/main/libs/langgraph-checkpoint-aws
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
|
|
22
|
+
# LangGraph Checkpoint AWS
|
|
23
|
+
A custom LangChain checkpointer implementation that uses Bedrock Session Management Service to enable stateful and resumable LangGraph agents through efficient state persistence and retrieval.
|
|
24
|
+
|
|
25
|
+
## Overview
|
|
26
|
+
This package provides a custom checkpointing solution for LangGraph agents using AWS Bedrock Session Management Service. It enables:
|
|
27
|
+
1. Stateful conversations and interactions
|
|
28
|
+
2. Resumable agent sessions
|
|
29
|
+
3. Efficient state persistence and retrieval
|
|
30
|
+
4. Seamless integration with AWS Bedrock
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
You can install the package using pip:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install langgraph-checkpoint-aws
|
|
37
|
+
```
|
|
38
|
+
Or with Poetry:
|
|
39
|
+
```bash
|
|
40
|
+
poetry add langgraph-checkpoint-aws
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Requirements
|
|
44
|
+
```text
|
|
45
|
+
Python >=3.9
|
|
46
|
+
langgraph-checkpoint >=2.0.0
|
|
47
|
+
langgraph >=0.2.55
|
|
48
|
+
boto3 >=1.37.3
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Usage
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
from langgraph.graph import StateGraph
|
|
55
|
+
from langgraph_checkpoint_aws.saver import BedrockSessionSaver
|
|
56
|
+
|
|
57
|
+
# Initialize the saver
|
|
58
|
+
session_saver = BedrockSessionSaver(
|
|
59
|
+
region_name="us-west-2", # Your AWS region
|
|
60
|
+
credentials_profile_name="default", # Optional: AWS credentials profile
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
# Create a session
|
|
64
|
+
session_id = session_saver.session_client.create_session().session_id
|
|
65
|
+
|
|
66
|
+
# Use with LangGraph
|
|
67
|
+
builder = StateGraph(int)
|
|
68
|
+
builder.add_node("add_one", lambda x: x + 1)
|
|
69
|
+
builder.set_entry_point("add_one")
|
|
70
|
+
builder.set_finish_point("add_one")
|
|
71
|
+
|
|
72
|
+
graph = builder.compile(checkpointer=session_saver)
|
|
73
|
+
config = {"configurable": {"thread_id": session_id}}
|
|
74
|
+
graph.invoke(1, config)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Configuration Options
|
|
78
|
+
|
|
79
|
+
`BedrockSessionSaver` accepts the following parameters:
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
def __init__(
|
|
83
|
+
region_name: Optional[str] = None,
|
|
84
|
+
credentials_profile_name: Optional[str] = None,
|
|
85
|
+
aws_access_key_id: Optional[SecretStr] = None,
|
|
86
|
+
aws_secret_access_key: Optional[SecretStr] = None,
|
|
87
|
+
aws_session_token: Optional[SecretStr] = None,
|
|
88
|
+
endpoint_url: Optional[str] = None,
|
|
89
|
+
config: Optional[Config] = None,
|
|
90
|
+
)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
- `region_name`: AWS region where Bedrock is available
|
|
94
|
+
- `credentials_profile_name`: Name of AWS credentials profile to use
|
|
95
|
+
- `aws_access_key_id`: AWS access key ID for authentication
|
|
96
|
+
- `aws_secret_access_key`: AWS secret access key for authentication
|
|
97
|
+
- `aws_session_token`: AWS session token for temporary credentials
|
|
98
|
+
- `endpoint_url`: Custom endpoint URL for the Bedrock service
|
|
99
|
+
- `config`: Botocore configuration object
|
|
100
|
+
## Development
|
|
101
|
+
Setting Up Development Environment
|
|
102
|
+
|
|
103
|
+
* Clone the repository:
|
|
104
|
+
```bash
|
|
105
|
+
git clone <repository-url>
|
|
106
|
+
cd libs/aws/langgraph-checkpoint-aws
|
|
107
|
+
```
|
|
108
|
+
* Install development dependencies:
|
|
109
|
+
```bash
|
|
110
|
+
make install_all
|
|
111
|
+
```
|
|
112
|
+
* Or install specific components:
|
|
113
|
+
```bash
|
|
114
|
+
make install_dev # Basic development tools
|
|
115
|
+
make install_test # Testing tools
|
|
116
|
+
make install_lint # Linting tools
|
|
117
|
+
make install_typing # Type checking tools
|
|
118
|
+
make install_codespell # Spell checking tools
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Running Tests
|
|
122
|
+
```bash
|
|
123
|
+
make tests # Run all tests
|
|
124
|
+
make test_watch # Run tests in watch mode
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Code Quality
|
|
129
|
+
```bash
|
|
130
|
+
make lint # Run linter
|
|
131
|
+
make format # Format code
|
|
132
|
+
make spell_check # Check spelling
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Clean Up
|
|
136
|
+
```bash
|
|
137
|
+
make clean # Remove all generated files
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## AWS Configuration
|
|
141
|
+
|
|
142
|
+
Ensure you have AWS credentials configured using one of these methods:
|
|
143
|
+
1. Environment variables
|
|
144
|
+
2. AWS credentials file (~/.aws/credentials)
|
|
145
|
+
3. IAM roles
|
|
146
|
+
4. Direct credential injection via constructor parameters
|
|
147
|
+
|
|
148
|
+
## Required AWS permissions:
|
|
149
|
+
|
|
150
|
+
```json
|
|
151
|
+
{
|
|
152
|
+
"Version": "2012-10-17",
|
|
153
|
+
"Statement": [
|
|
154
|
+
{
|
|
155
|
+
"Sid": "Statement1",
|
|
156
|
+
"Effect": "Allow",
|
|
157
|
+
"Action": [
|
|
158
|
+
"bedrock:CreateSession",
|
|
159
|
+
"bedrock:GetSession",
|
|
160
|
+
"bedrock:UpdateSession",
|
|
161
|
+
"bedrock:DeleteSession",
|
|
162
|
+
"bedrock:EndSession",
|
|
163
|
+
"bedrock:ListSessions",
|
|
164
|
+
"bedrock:CreateInvocation",
|
|
165
|
+
"bedrock:ListInvocations",
|
|
166
|
+
"bedrock:PutInvocationStep",
|
|
167
|
+
"bedrock:GetInvocationStep",
|
|
168
|
+
"bedrock:ListInvocationSteps"
|
|
169
|
+
],
|
|
170
|
+
"Resource": [
|
|
171
|
+
"*"
|
|
172
|
+
]
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"Effect": "Allow",
|
|
176
|
+
"Action": [
|
|
177
|
+
"kms:Decrypt",
|
|
178
|
+
"kms:Encrypt",
|
|
179
|
+
"kms:GenerateDataKey",
|
|
180
|
+
"kms:DescribeKey"
|
|
181
|
+
],
|
|
182
|
+
"Resource": "arn:aws:kms:{region}:{account}:key/{kms-key-id}"
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"Effect": "Allow",
|
|
186
|
+
"Action": [
|
|
187
|
+
"bedrock:TagResource",
|
|
188
|
+
"bedrock:UntagResource",
|
|
189
|
+
"bedrock:ListTagsForResource"
|
|
190
|
+
],
|
|
191
|
+
"Resource": "arn:aws:bedrock:{region}:{account}:session/*"
|
|
192
|
+
}
|
|
193
|
+
]
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## Security Considerations
|
|
198
|
+
* Never commit AWS credentials
|
|
199
|
+
* Use environment variables or AWS IAM roles for authentication
|
|
200
|
+
* Follow AWS security best practices
|
|
201
|
+
* Use IAM roles and temporary credentials when possible
|
|
202
|
+
* Implement proper access controls for session management
|
|
203
|
+
|
|
204
|
+
## Contributing
|
|
205
|
+
* Fork the repository
|
|
206
|
+
* Create a feature branch
|
|
207
|
+
* Make your changes
|
|
208
|
+
* Run tests and linting
|
|
209
|
+
* Submit a pull request
|
|
210
|
+
|
|
211
|
+
## License
|
|
212
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
213
|
+
|
|
214
|
+
## Acknowledgments
|
|
215
|
+
* LangChain team for the base LangGraph framework
|
|
216
|
+
* AWS Bedrock team for the session management service
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
# LangGraph Checkpoint AWS
|
|
2
|
+
A custom LangChain checkpointer implementation that uses Bedrock Session Management Service to enable stateful and resumable LangGraph agents through efficient state persistence and retrieval.
|
|
3
|
+
|
|
4
|
+
## Overview
|
|
5
|
+
This package provides a custom checkpointing solution for LangGraph agents using AWS Bedrock Session Management Service. It enables:
|
|
6
|
+
1. Stateful conversations and interactions
|
|
7
|
+
2. Resumable agent sessions
|
|
8
|
+
3. Efficient state persistence and retrieval
|
|
9
|
+
4. Seamless integration with AWS Bedrock
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
You can install the package using pip:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pip install langgraph-checkpoint-aws
|
|
16
|
+
```
|
|
17
|
+
Or with Poetry:
|
|
18
|
+
```bash
|
|
19
|
+
poetry add langgraph-checkpoint-aws
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Requirements
|
|
23
|
+
```text
|
|
24
|
+
Python >=3.9
|
|
25
|
+
langgraph-checkpoint >=2.0.0
|
|
26
|
+
langgraph >=0.2.55
|
|
27
|
+
boto3 >=1.37.3
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
from langgraph.graph import StateGraph
|
|
34
|
+
from langgraph_checkpoint_aws.saver import BedrockSessionSaver
|
|
35
|
+
|
|
36
|
+
# Initialize the saver
|
|
37
|
+
session_saver = BedrockSessionSaver(
|
|
38
|
+
region_name="us-west-2", # Your AWS region
|
|
39
|
+
credentials_profile_name="default", # Optional: AWS credentials profile
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
# Create a session
|
|
43
|
+
session_id = session_saver.session_client.create_session().session_id
|
|
44
|
+
|
|
45
|
+
# Use with LangGraph
|
|
46
|
+
builder = StateGraph(int)
|
|
47
|
+
builder.add_node("add_one", lambda x: x + 1)
|
|
48
|
+
builder.set_entry_point("add_one")
|
|
49
|
+
builder.set_finish_point("add_one")
|
|
50
|
+
|
|
51
|
+
graph = builder.compile(checkpointer=session_saver)
|
|
52
|
+
config = {"configurable": {"thread_id": session_id}}
|
|
53
|
+
graph.invoke(1, config)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Configuration Options
|
|
57
|
+
|
|
58
|
+
`BedrockSessionSaver` accepts the following parameters:
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
def __init__(
|
|
62
|
+
region_name: Optional[str] = None,
|
|
63
|
+
credentials_profile_name: Optional[str] = None,
|
|
64
|
+
aws_access_key_id: Optional[SecretStr] = None,
|
|
65
|
+
aws_secret_access_key: Optional[SecretStr] = None,
|
|
66
|
+
aws_session_token: Optional[SecretStr] = None,
|
|
67
|
+
endpoint_url: Optional[str] = None,
|
|
68
|
+
config: Optional[Config] = None,
|
|
69
|
+
)
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
- `region_name`: AWS region where Bedrock is available
|
|
73
|
+
- `credentials_profile_name`: Name of AWS credentials profile to use
|
|
74
|
+
- `aws_access_key_id`: AWS access key ID for authentication
|
|
75
|
+
- `aws_secret_access_key`: AWS secret access key for authentication
|
|
76
|
+
- `aws_session_token`: AWS session token for temporary credentials
|
|
77
|
+
- `endpoint_url`: Custom endpoint URL for the Bedrock service
|
|
78
|
+
- `config`: Botocore configuration object
|
|
79
|
+
## Development
|
|
80
|
+
Setting Up Development Environment
|
|
81
|
+
|
|
82
|
+
* Clone the repository:
|
|
83
|
+
```bash
|
|
84
|
+
git clone <repository-url>
|
|
85
|
+
cd libs/aws/langgraph-checkpoint-aws
|
|
86
|
+
```
|
|
87
|
+
* Install development dependencies:
|
|
88
|
+
```bash
|
|
89
|
+
make install_all
|
|
90
|
+
```
|
|
91
|
+
* Or install specific components:
|
|
92
|
+
```bash
|
|
93
|
+
make install_dev # Basic development tools
|
|
94
|
+
make install_test # Testing tools
|
|
95
|
+
make install_lint # Linting tools
|
|
96
|
+
make install_typing # Type checking tools
|
|
97
|
+
make install_codespell # Spell checking tools
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Running Tests
|
|
101
|
+
```bash
|
|
102
|
+
make tests # Run all tests
|
|
103
|
+
make test_watch # Run tests in watch mode
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Code Quality
|
|
108
|
+
```bash
|
|
109
|
+
make lint # Run linter
|
|
110
|
+
make format # Format code
|
|
111
|
+
make spell_check # Check spelling
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Clean Up
|
|
115
|
+
```bash
|
|
116
|
+
make clean # Remove all generated files
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## AWS Configuration
|
|
120
|
+
|
|
121
|
+
Ensure you have AWS credentials configured using one of these methods:
|
|
122
|
+
1. Environment variables
|
|
123
|
+
2. AWS credentials file (~/.aws/credentials)
|
|
124
|
+
3. IAM roles
|
|
125
|
+
4. Direct credential injection via constructor parameters
|
|
126
|
+
|
|
127
|
+
## Required AWS permissions:
|
|
128
|
+
|
|
129
|
+
```json
|
|
130
|
+
{
|
|
131
|
+
"Version": "2012-10-17",
|
|
132
|
+
"Statement": [
|
|
133
|
+
{
|
|
134
|
+
"Sid": "Statement1",
|
|
135
|
+
"Effect": "Allow",
|
|
136
|
+
"Action": [
|
|
137
|
+
"bedrock:CreateSession",
|
|
138
|
+
"bedrock:GetSession",
|
|
139
|
+
"bedrock:UpdateSession",
|
|
140
|
+
"bedrock:DeleteSession",
|
|
141
|
+
"bedrock:EndSession",
|
|
142
|
+
"bedrock:ListSessions",
|
|
143
|
+
"bedrock:CreateInvocation",
|
|
144
|
+
"bedrock:ListInvocations",
|
|
145
|
+
"bedrock:PutInvocationStep",
|
|
146
|
+
"bedrock:GetInvocationStep",
|
|
147
|
+
"bedrock:ListInvocationSteps"
|
|
148
|
+
],
|
|
149
|
+
"Resource": [
|
|
150
|
+
"*"
|
|
151
|
+
]
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
"Effect": "Allow",
|
|
155
|
+
"Action": [
|
|
156
|
+
"kms:Decrypt",
|
|
157
|
+
"kms:Encrypt",
|
|
158
|
+
"kms:GenerateDataKey",
|
|
159
|
+
"kms:DescribeKey"
|
|
160
|
+
],
|
|
161
|
+
"Resource": "arn:aws:kms:{region}:{account}:key/{kms-key-id}"
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"Effect": "Allow",
|
|
165
|
+
"Action": [
|
|
166
|
+
"bedrock:TagResource",
|
|
167
|
+
"bedrock:UntagResource",
|
|
168
|
+
"bedrock:ListTagsForResource"
|
|
169
|
+
],
|
|
170
|
+
"Resource": "arn:aws:bedrock:{region}:{account}:session/*"
|
|
171
|
+
}
|
|
172
|
+
]
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Security Considerations
|
|
177
|
+
* Never commit AWS credentials
|
|
178
|
+
* Use environment variables or AWS IAM roles for authentication
|
|
179
|
+
* Follow AWS security best practices
|
|
180
|
+
* Use IAM roles and temporary credentials when possible
|
|
181
|
+
* Implement proper access controls for session management
|
|
182
|
+
|
|
183
|
+
## Contributing
|
|
184
|
+
* Fork the repository
|
|
185
|
+
* Create a feature branch
|
|
186
|
+
* Make your changes
|
|
187
|
+
* Run tests and linting
|
|
188
|
+
* Submit a pull request
|
|
189
|
+
|
|
190
|
+
## License
|
|
191
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
192
|
+
|
|
193
|
+
## Acknowledgments
|
|
194
|
+
* LangChain team for the base LangGraph framework
|
|
195
|
+
* AWS Bedrock team for the session management service
|