my-aws-helpers 4.1.0__tar.gz → 4.3.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.
- {my_aws_helpers-4.1.0 → my_aws_helpers-4.3.0}/PKG-INFO +1 -1
- {my_aws_helpers-4.1.0 → my_aws_helpers-4.3.0}/my_aws_helpers/s3.py +32 -1
- {my_aws_helpers-4.1.0 → my_aws_helpers-4.3.0}/my_aws_helpers.egg-info/PKG-INFO +1 -1
- {my_aws_helpers-4.1.0 → my_aws_helpers-4.3.0}/setup.py +1 -1
- {my_aws_helpers-4.1.0 → my_aws_helpers-4.3.0}/MANIFEST.in +0 -0
- {my_aws_helpers-4.1.0 → my_aws_helpers-4.3.0}/README.md +0 -0
- {my_aws_helpers-4.1.0 → my_aws_helpers-4.3.0}/my_aws_helpers/api.py +0 -0
- {my_aws_helpers-4.1.0 → my_aws_helpers-4.3.0}/my_aws_helpers/auth.py +0 -0
- {my_aws_helpers-4.1.0 → my_aws_helpers-4.3.0}/my_aws_helpers/bedrock.py +0 -0
- {my_aws_helpers-4.1.0 → my_aws_helpers-4.3.0}/my_aws_helpers/cognito.py +0 -0
- {my_aws_helpers-4.1.0 → my_aws_helpers-4.3.0}/my_aws_helpers/dynamo.py +0 -0
- {my_aws_helpers-4.1.0 → my_aws_helpers-4.3.0}/my_aws_helpers/errors.py +0 -0
- {my_aws_helpers-4.1.0 → my_aws_helpers-4.3.0}/my_aws_helpers/event.py +0 -0
- {my_aws_helpers-4.1.0 → my_aws_helpers-4.3.0}/my_aws_helpers/logging.py +0 -0
- {my_aws_helpers-4.1.0 → my_aws_helpers-4.3.0}/my_aws_helpers/prompts/__init__.py +0 -0
- {my_aws_helpers-4.1.0 → my_aws_helpers-4.3.0}/my_aws_helpers/prompts/markdown_system_prompt.txt +0 -0
- {my_aws_helpers-4.1.0 → my_aws_helpers-4.3.0}/my_aws_helpers/prompts/transactions_headers_prompt.txt +0 -0
- {my_aws_helpers-4.1.0 → my_aws_helpers-4.3.0}/my_aws_helpers/prompts/transactions_headers_prompt_v2.txt +0 -0
- {my_aws_helpers-4.1.0 → my_aws_helpers-4.3.0}/my_aws_helpers/prompts/transactions_prompt.txt +0 -0
- {my_aws_helpers-4.1.0 → my_aws_helpers-4.3.0}/my_aws_helpers/sfn.py +0 -0
- {my_aws_helpers-4.1.0 → my_aws_helpers-4.3.0}/my_aws_helpers.egg-info/SOURCES.txt +0 -0
- {my_aws_helpers-4.1.0 → my_aws_helpers-4.3.0}/my_aws_helpers.egg-info/dependency_links.txt +0 -0
- {my_aws_helpers-4.1.0 → my_aws_helpers-4.3.0}/my_aws_helpers.egg-info/requires.txt +0 -0
- {my_aws_helpers-4.1.0 → my_aws_helpers-4.3.0}/my_aws_helpers.egg-info/top_level.txt +0 -0
- {my_aws_helpers-4.1.0 → my_aws_helpers-4.3.0}/my_aws_helpers.egg-info/zip-safe +0 -0
- {my_aws_helpers-4.1.0 → my_aws_helpers-4.3.0}/setup.cfg +0 -0
- {my_aws_helpers-4.1.0 → my_aws_helpers-4.3.0}/tests/test_cognito.py +0 -0
- {my_aws_helpers-4.1.0 → my_aws_helpers-4.3.0}/tests/test_event.py +0 -0
|
@@ -2,6 +2,7 @@ import boto3
|
|
|
2
2
|
import io
|
|
3
3
|
import json
|
|
4
4
|
from typing import Optional, Any, Dict
|
|
5
|
+
from datetime import datetime, date
|
|
5
6
|
from copy import copy
|
|
6
7
|
import os
|
|
7
8
|
import gzip
|
|
@@ -17,12 +18,29 @@ class ContentType(str, Enum):
|
|
|
17
18
|
xml_content = "text/xml"
|
|
18
19
|
json_content = "application/json"
|
|
19
20
|
pdf_content = "application/pdf"
|
|
21
|
+
jpeg_content = "image/jpeg"
|
|
20
22
|
|
|
21
23
|
|
|
22
24
|
class ContentEncoding(str, Enum):
|
|
23
25
|
gzip = "gzip"
|
|
24
26
|
|
|
25
27
|
|
|
28
|
+
class S3Serialiser:
|
|
29
|
+
|
|
30
|
+
@staticmethod
|
|
31
|
+
def _serialise(obj: Any):
|
|
32
|
+
if isinstance(obj, datetime) or isinstance(obj, date):
|
|
33
|
+
return obj.isoformat()
|
|
34
|
+
return obj
|
|
35
|
+
|
|
36
|
+
@staticmethod
|
|
37
|
+
def object_serialiser(obj: Any):
|
|
38
|
+
if isinstance(obj, list):
|
|
39
|
+
return [S3Serialiser.object_serialiser(obj=obj) for obj in obj]
|
|
40
|
+
if isinstance(obj, dict):
|
|
41
|
+
return {k: S3Serialiser.object_serialiser(v) for k, v in obj.items()}
|
|
42
|
+
return S3Serialiser._serialise(obj=obj)
|
|
43
|
+
|
|
26
44
|
class S3Location:
|
|
27
45
|
bucket: str
|
|
28
46
|
file_name: str
|
|
@@ -186,7 +204,7 @@ class S3:
|
|
|
186
204
|
logger.exception(f"Failed to save xml text to s3 due to {e}")
|
|
187
205
|
return None
|
|
188
206
|
|
|
189
|
-
def
|
|
207
|
+
def save_pdf_to_s3(self, pdf_content: bytes, s3_location: S3Location):
|
|
190
208
|
"""
|
|
191
209
|
pdf_content tends to come from:
|
|
192
210
|
PyMuPdf.Document().write()
|
|
@@ -218,5 +236,18 @@ class S3:
|
|
|
218
236
|
logger.exception(f"Failed to save dict to s3 due to {e}")
|
|
219
237
|
return None
|
|
220
238
|
|
|
239
|
+
def save_jpeg_to_s3(self, content: bytes, s3_location: S3Location):
|
|
240
|
+
try:
|
|
241
|
+
return self.save_document_content(
|
|
242
|
+
file_contents=content,
|
|
243
|
+
s3_location=s3_location,
|
|
244
|
+
content_type=ContentType.jpeg_content.value,
|
|
245
|
+
compress=True,
|
|
246
|
+
content_encoding=ContentEncoding.gzip.value,
|
|
247
|
+
)
|
|
248
|
+
except Exception as e:
|
|
249
|
+
logger.exception(f"Failed to save jpeg to s3 due to {e}")
|
|
250
|
+
return None
|
|
251
|
+
|
|
221
252
|
def read_dict_from_s3(self, s3_location: S3Location) -> dict:
|
|
222
253
|
return json.loads(self.read_binary_from_s3(s3_location=s3_location).decode("utf-8"))
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{my_aws_helpers-4.1.0 → my_aws_helpers-4.3.0}/my_aws_helpers/prompts/markdown_system_prompt.txt
RENAMED
|
File without changes
|
{my_aws_helpers-4.1.0 → my_aws_helpers-4.3.0}/my_aws_helpers/prompts/transactions_headers_prompt.txt
RENAMED
|
File without changes
|
|
File without changes
|
{my_aws_helpers-4.1.0 → my_aws_helpers-4.3.0}/my_aws_helpers/prompts/transactions_prompt.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|