my-aws-helpers 4.7.0__tar.gz → 4.9.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.

Potentially problematic release.


This version of my-aws-helpers might be problematic. Click here for more details.

Files changed (28) hide show
  1. {my_aws_helpers-4.7.0 → my_aws_helpers-4.9.0}/PKG-INFO +1 -1
  2. {my_aws_helpers-4.7.0 → my_aws_helpers-4.9.0}/my_aws_helpers/bedrock.py +15 -4
  3. {my_aws_helpers-4.7.0 → my_aws_helpers-4.9.0}/my_aws_helpers/s3.py +36 -3
  4. {my_aws_helpers-4.7.0 → my_aws_helpers-4.9.0}/my_aws_helpers.egg-info/PKG-INFO +1 -1
  5. {my_aws_helpers-4.7.0 → my_aws_helpers-4.9.0}/setup.py +1 -1
  6. {my_aws_helpers-4.7.0 → my_aws_helpers-4.9.0}/MANIFEST.in +0 -0
  7. {my_aws_helpers-4.7.0 → my_aws_helpers-4.9.0}/README.md +0 -0
  8. {my_aws_helpers-4.7.0 → my_aws_helpers-4.9.0}/my_aws_helpers/api.py +0 -0
  9. {my_aws_helpers-4.7.0 → my_aws_helpers-4.9.0}/my_aws_helpers/auth.py +0 -0
  10. {my_aws_helpers-4.7.0 → my_aws_helpers-4.9.0}/my_aws_helpers/cognito.py +0 -0
  11. {my_aws_helpers-4.7.0 → my_aws_helpers-4.9.0}/my_aws_helpers/dynamo.py +0 -0
  12. {my_aws_helpers-4.7.0 → my_aws_helpers-4.9.0}/my_aws_helpers/errors.py +0 -0
  13. {my_aws_helpers-4.7.0 → my_aws_helpers-4.9.0}/my_aws_helpers/event.py +0 -0
  14. {my_aws_helpers-4.7.0 → my_aws_helpers-4.9.0}/my_aws_helpers/logging.py +0 -0
  15. {my_aws_helpers-4.7.0 → my_aws_helpers-4.9.0}/my_aws_helpers/prompts/__init__.py +0 -0
  16. {my_aws_helpers-4.7.0 → my_aws_helpers-4.9.0}/my_aws_helpers/prompts/markdown_system_prompt.txt +0 -0
  17. {my_aws_helpers-4.7.0 → my_aws_helpers-4.9.0}/my_aws_helpers/prompts/transactions_headers_prompt.txt +0 -0
  18. {my_aws_helpers-4.7.0 → my_aws_helpers-4.9.0}/my_aws_helpers/prompts/transactions_headers_prompt_v2.txt +0 -0
  19. {my_aws_helpers-4.7.0 → my_aws_helpers-4.9.0}/my_aws_helpers/prompts/transactions_prompt.txt +0 -0
  20. {my_aws_helpers-4.7.0 → my_aws_helpers-4.9.0}/my_aws_helpers/sfn.py +0 -0
  21. {my_aws_helpers-4.7.0 → my_aws_helpers-4.9.0}/my_aws_helpers.egg-info/SOURCES.txt +0 -0
  22. {my_aws_helpers-4.7.0 → my_aws_helpers-4.9.0}/my_aws_helpers.egg-info/dependency_links.txt +0 -0
  23. {my_aws_helpers-4.7.0 → my_aws_helpers-4.9.0}/my_aws_helpers.egg-info/requires.txt +0 -0
  24. {my_aws_helpers-4.7.0 → my_aws_helpers-4.9.0}/my_aws_helpers.egg-info/top_level.txt +0 -0
  25. {my_aws_helpers-4.7.0 → my_aws_helpers-4.9.0}/my_aws_helpers.egg-info/zip-safe +0 -0
  26. {my_aws_helpers-4.7.0 → my_aws_helpers-4.9.0}/setup.cfg +0 -0
  27. {my_aws_helpers-4.7.0 → my_aws_helpers-4.9.0}/tests/test_cognito.py +0 -0
  28. {my_aws_helpers-4.7.0 → my_aws_helpers-4.9.0}/tests/test_event.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: my_aws_helpers
3
- Version: 4.7.0
3
+ Version: 4.9.0
4
4
  Summary: AWS Helpers
5
5
  Home-page: https://github.com/JarrodMccarthy/aws_helpers.git
6
6
  Author: Jarrod McCarthy
@@ -11,7 +11,13 @@ from enum import Enum
11
11
  import pymupdf
12
12
  import concurrent.futures
13
13
  from dataclasses import dataclass
14
- from my_aws_helpers.s3 import ContentType
14
+
15
+
16
+ class ImageType(str, Enum):
17
+ gif = "gif"
18
+ jpeg = "jpeg"
19
+ png = "png"
20
+ webp = "webp"
15
21
 
16
22
 
17
23
  class PromptType(str, Enum):
@@ -240,7 +246,7 @@ class Bedrock:
240
246
  self.logger.exception(e)
241
247
  return []
242
248
 
243
- def _get_image_block(self, image: bytes, image_content_type: ContentType) -> dict:
249
+ def _get_image_block(self, image: bytes, image_content_type: ImageType) -> dict:
244
250
  return {
245
251
  "image": {
246
252
  "format": image_content_type,
@@ -251,14 +257,19 @@ class Bedrock:
251
257
  }
252
258
 
253
259
  def image_analysis(
254
- self, images: List[bytes], prompt: str, image_content_type: ContentType
260
+ self, images: List[bytes], prompt: str, image_content_type: ImageType
255
261
  ) -> OCRResult:
256
262
 
257
263
  system_prompt = [{"text": prompt}]
258
264
  message = [
259
265
  {
260
266
  "role": "user",
261
- "content": [self._get_image_block(image=image, image_content_type=image_content_type) for image in images],
267
+ "content": [
268
+ self._get_image_block(
269
+ image=image, image_content_type=image_content_type
270
+ )
271
+ for image in images
272
+ ],
262
273
  }
263
274
  ]
264
275
  response = self.client.converse(
@@ -1,6 +1,8 @@
1
+ from __future__ import annotations
1
2
  import boto3
2
3
  import io
3
4
  import json
5
+ from abc import ABC, abstractmethod
4
6
  from typing import Optional, Any, Dict, List
5
7
  from datetime import datetime, date
6
8
  from copy import copy
@@ -97,9 +99,7 @@ class S3:
97
99
 
98
100
  def list_objects_by_prefix(self, bucket_name: str, prefix: str) -> List[Dict]:
99
101
  try:
100
- response = self.client.client.list_objects_v2(
101
- Bucket=bucket_name, Prefix=prefix
102
- )
102
+ response = self.client.list_objects_v2(Bucket=bucket_name, Prefix=prefix)
103
103
  return response["Contents"]
104
104
  except Exception as e:
105
105
  logger.exception(
@@ -266,3 +266,36 @@ class S3:
266
266
  return json.loads(
267
267
  self.read_binary_from_s3(s3_location=s3_location).decode("utf-8")
268
268
  )
269
+
270
+
271
+ class BaseS3Object(ABC):
272
+ def to_s3_representation(self) -> dict:
273
+ obj = copy(vars(self))
274
+ return S3Serialiser.object_serialiser(obj=obj)
275
+
276
+ @classmethod
277
+ def from_s3_representation(cls, obj: dict) -> BaseS3Object:
278
+ return cls(**obj)
279
+
280
+ @abstractmethod
281
+ def get_save_location(self, bucket_name: str) -> S3Location:
282
+ pass
283
+
284
+
285
+ class BaseS3Queries:
286
+ s3_client: S3
287
+ bucket_name: str
288
+
289
+ def __init__(self, s3_client: S3, bucket_name: str):
290
+ self.s3_client = s3_client
291
+ self.bucket_name = bucket_name
292
+
293
+ def save_s3_object_to_s3(self, object: BaseS3Object) -> Optional[S3Location]:
294
+ try:
295
+ obj = object.to_s3_representation()
296
+ return self.s3_client.save_dict_to_s3(
297
+ content=obj, s3_location=object.get_save_location()
298
+ )
299
+ except Exception as e:
300
+ logger.exception(f"Failed to save s3 object to s3 due to {e}")
301
+ return None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: my-aws-helpers
3
- Version: 4.7.0
3
+ Version: 4.9.0
4
4
  Summary: AWS Helpers
5
5
  Home-page: https://github.com/JarrodMccarthy/aws_helpers.git
6
6
  Author: Jarrod McCarthy
@@ -3,7 +3,7 @@ from setuptools import find_namespace_packages, setup
3
3
 
4
4
  base_path = os.path.abspath(os.path.dirname(__file__))
5
5
 
6
- version = "4.7.0"
6
+ version = "4.9.0"
7
7
 
8
8
  core = [
9
9
  "boto3==1.34.36",
File without changes
File without changes