my-aws-helpers 4.4.1__tar.gz → 4.6.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.4.1 → my_aws_helpers-4.6.0}/PKG-INFO +1 -1
  2. {my_aws_helpers-4.4.1 → my_aws_helpers-4.6.0}/my_aws_helpers/bedrock.py +38 -0
  3. {my_aws_helpers-4.4.1 → my_aws_helpers-4.6.0}/my_aws_helpers/s3.py +19 -9
  4. {my_aws_helpers-4.4.1 → my_aws_helpers-4.6.0}/my_aws_helpers.egg-info/PKG-INFO +1 -1
  5. {my_aws_helpers-4.4.1 → my_aws_helpers-4.6.0}/setup.py +1 -1
  6. {my_aws_helpers-4.4.1 → my_aws_helpers-4.6.0}/MANIFEST.in +0 -0
  7. {my_aws_helpers-4.4.1 → my_aws_helpers-4.6.0}/README.md +0 -0
  8. {my_aws_helpers-4.4.1 → my_aws_helpers-4.6.0}/my_aws_helpers/api.py +0 -0
  9. {my_aws_helpers-4.4.1 → my_aws_helpers-4.6.0}/my_aws_helpers/auth.py +0 -0
  10. {my_aws_helpers-4.4.1 → my_aws_helpers-4.6.0}/my_aws_helpers/cognito.py +0 -0
  11. {my_aws_helpers-4.4.1 → my_aws_helpers-4.6.0}/my_aws_helpers/dynamo.py +0 -0
  12. {my_aws_helpers-4.4.1 → my_aws_helpers-4.6.0}/my_aws_helpers/errors.py +0 -0
  13. {my_aws_helpers-4.4.1 → my_aws_helpers-4.6.0}/my_aws_helpers/event.py +0 -0
  14. {my_aws_helpers-4.4.1 → my_aws_helpers-4.6.0}/my_aws_helpers/logging.py +0 -0
  15. {my_aws_helpers-4.4.1 → my_aws_helpers-4.6.0}/my_aws_helpers/prompts/__init__.py +0 -0
  16. {my_aws_helpers-4.4.1 → my_aws_helpers-4.6.0}/my_aws_helpers/prompts/markdown_system_prompt.txt +0 -0
  17. {my_aws_helpers-4.4.1 → my_aws_helpers-4.6.0}/my_aws_helpers/prompts/transactions_headers_prompt.txt +0 -0
  18. {my_aws_helpers-4.4.1 → my_aws_helpers-4.6.0}/my_aws_helpers/prompts/transactions_headers_prompt_v2.txt +0 -0
  19. {my_aws_helpers-4.4.1 → my_aws_helpers-4.6.0}/my_aws_helpers/prompts/transactions_prompt.txt +0 -0
  20. {my_aws_helpers-4.4.1 → my_aws_helpers-4.6.0}/my_aws_helpers/sfn.py +0 -0
  21. {my_aws_helpers-4.4.1 → my_aws_helpers-4.6.0}/my_aws_helpers.egg-info/SOURCES.txt +0 -0
  22. {my_aws_helpers-4.4.1 → my_aws_helpers-4.6.0}/my_aws_helpers.egg-info/dependency_links.txt +0 -0
  23. {my_aws_helpers-4.4.1 → my_aws_helpers-4.6.0}/my_aws_helpers.egg-info/requires.txt +0 -0
  24. {my_aws_helpers-4.4.1 → my_aws_helpers-4.6.0}/my_aws_helpers.egg-info/top_level.txt +0 -0
  25. {my_aws_helpers-4.4.1 → my_aws_helpers-4.6.0}/my_aws_helpers.egg-info/zip-safe +0 -0
  26. {my_aws_helpers-4.4.1 → my_aws_helpers-4.6.0}/setup.cfg +0 -0
  27. {my_aws_helpers-4.4.1 → my_aws_helpers-4.6.0}/tests/test_cognito.py +0 -0
  28. {my_aws_helpers-4.4.1 → my_aws_helpers-4.6.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.4.1
3
+ Version: 4.6.0
4
4
  Summary: AWS Helpers
5
5
  Home-page: https://github.com/JarrodMccarthy/aws_helpers.git
6
6
  Author: Jarrod McCarthy
@@ -5,6 +5,7 @@ import json
5
5
  import time
6
6
  import os
7
7
  import io
8
+ import base64
8
9
  from typing import Optional, List, Dict
9
10
  from enum import Enum
10
11
  import pymupdf
@@ -237,3 +238,40 @@ class Bedrock:
237
238
  except Exception as e:
238
239
  self.logger.exception(e)
239
240
  return []
241
+
242
+
243
+ def image_analysis(self, images: List[bytes]) -> OCRResult:
244
+ instruction = (
245
+ "You are an assistant for real estate investors. Analyze the following property images "
246
+ "and return structured insights. Focus only on what can reasonably be inferred from the images. "
247
+ "Do not make up financial or legal data. Be objective and consistent.\n\n"
248
+ "Return ONLY valid JSON with this structure:\n"
249
+ "{\n"
250
+ ' "condition_score": "Integer from 1-10 (1 = very poor, 10 = excellent)",\n'
251
+ ' "materials": {\n'
252
+ ' "exterior_walls": "string", "roof": "string", "windows": "string",\n'
253
+ ' "flooring": "string", "kitchen_benchtops": "string", "bathroom_fittings": "string"\n'
254
+ " },\n"
255
+ ' "features": [], "maintenance_risks": [], "energy_efficiency": [],\n'
256
+ ' "location_clues": [], "upgrade_potential": []\n'
257
+ "}"
258
+ )
259
+
260
+
261
+ system_prompt = [{"text": instruction}]
262
+ message = [
263
+ {
264
+ "role": "user",
265
+ "content": [self._get_image_block(image=image) for image in images],
266
+ }
267
+ ]
268
+ response = self.client.converse(
269
+ modelId=self.model_id, messages=message, system=system_prompt
270
+ )
271
+
272
+ result = {}
273
+ result["content"] = json.loads(
274
+ response["output"]["message"]["content"][0]["text"]
275
+ )
276
+ result["token_usage"] = response["usage"]
277
+ return OCRResult.from_dict(data=result)
@@ -1,7 +1,7 @@
1
1
  import boto3
2
2
  import io
3
3
  import json
4
- from typing import Optional, Any, Dict
4
+ from typing import Optional, Any, Dict, List
5
5
  from datetime import datetime, date
6
6
  from copy import copy
7
7
  import os
@@ -34,13 +34,12 @@ class S3Serialiser:
34
34
  return obj
35
35
 
36
36
  @staticmethod
37
- def object_serialiser(obj_dict: Dict):
38
- for k, obj in obj_dict.items():
39
- if isinstance(obj, list):
40
- return json.dumps([S3Serialiser.object_serialiser(obj=obj) for obj in obj])
41
- if isinstance(obj, dict):
42
- return json.dumps({k: S3Serialiser.object_serialiser(v) for k, v in obj.items()})
43
- return S3Serialiser._serialise(obj=obj_dict)
37
+ def object_serialiser(obj: Dict):
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)
44
43
 
45
44
  class S3Location:
46
45
  bucket: str
@@ -95,6 +94,17 @@ class S3:
95
94
  Body=json.dumps(object), Bucket=bucket_name, Key=file_name
96
95
  )
97
96
 
97
+ def list_objects_by_prefix(self, bucket_name: str, prefix: str) -> List[Dict]:
98
+ try:
99
+ response = self.client.client.list_objects_v2(
100
+ Bucket=bucket_name,
101
+ Prefix=prefix
102
+ )
103
+ return response['Contents']
104
+ except Exception as e:
105
+ logger.exception(f"Failed to get objects from s3: {bucket_name}/{prefix} due to {e}")
106
+ return []
107
+
98
108
  def get_object(self, bucket_name: str, file_name: str):
99
109
  response = self.client.get_object(Bucket=bucket_name, Key=file_name)
100
110
  return self._streaming_body_to_dict(response["Body"])
@@ -112,7 +122,7 @@ class S3:
112
122
  "Key": file_name,
113
123
  },
114
124
  ExpiresIn=expires_in,
115
- )
125
+ )
116
126
 
117
127
  def get_s3_location_from_bucket_file(
118
128
  bucket_name: str, file_name: str
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: my-aws-helpers
3
- Version: 4.4.1
3
+ Version: 4.6.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.4.1"
6
+ version = "4.6.0"
7
7
 
8
8
  core = [
9
9
  "boto3==1.34.36",
File without changes
File without changes