my-aws-helpers 4.6.0__tar.gz → 4.8.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.
- {my_aws_helpers-4.6.0 → my_aws_helpers-4.8.0}/PKG-INFO +1 -1
- {my_aws_helpers-4.6.0 → my_aws_helpers-4.8.0}/my_aws_helpers/bedrock.py +22 -20
- {my_aws_helpers-4.6.0 → my_aws_helpers-4.8.0}/my_aws_helpers/s3.py +12 -8
- {my_aws_helpers-4.6.0 → my_aws_helpers-4.8.0}/my_aws_helpers.egg-info/PKG-INFO +1 -1
- {my_aws_helpers-4.6.0 → my_aws_helpers-4.8.0}/setup.py +1 -1
- {my_aws_helpers-4.6.0 → my_aws_helpers-4.8.0}/MANIFEST.in +0 -0
- {my_aws_helpers-4.6.0 → my_aws_helpers-4.8.0}/README.md +0 -0
- {my_aws_helpers-4.6.0 → my_aws_helpers-4.8.0}/my_aws_helpers/api.py +0 -0
- {my_aws_helpers-4.6.0 → my_aws_helpers-4.8.0}/my_aws_helpers/auth.py +0 -0
- {my_aws_helpers-4.6.0 → my_aws_helpers-4.8.0}/my_aws_helpers/cognito.py +0 -0
- {my_aws_helpers-4.6.0 → my_aws_helpers-4.8.0}/my_aws_helpers/dynamo.py +0 -0
- {my_aws_helpers-4.6.0 → my_aws_helpers-4.8.0}/my_aws_helpers/errors.py +0 -0
- {my_aws_helpers-4.6.0 → my_aws_helpers-4.8.0}/my_aws_helpers/event.py +0 -0
- {my_aws_helpers-4.6.0 → my_aws_helpers-4.8.0}/my_aws_helpers/logging.py +0 -0
- {my_aws_helpers-4.6.0 → my_aws_helpers-4.8.0}/my_aws_helpers/prompts/__init__.py +0 -0
- {my_aws_helpers-4.6.0 → my_aws_helpers-4.8.0}/my_aws_helpers/prompts/markdown_system_prompt.txt +0 -0
- {my_aws_helpers-4.6.0 → my_aws_helpers-4.8.0}/my_aws_helpers/prompts/transactions_headers_prompt.txt +0 -0
- {my_aws_helpers-4.6.0 → my_aws_helpers-4.8.0}/my_aws_helpers/prompts/transactions_headers_prompt_v2.txt +0 -0
- {my_aws_helpers-4.6.0 → my_aws_helpers-4.8.0}/my_aws_helpers/prompts/transactions_prompt.txt +0 -0
- {my_aws_helpers-4.6.0 → my_aws_helpers-4.8.0}/my_aws_helpers/sfn.py +0 -0
- {my_aws_helpers-4.6.0 → my_aws_helpers-4.8.0}/my_aws_helpers.egg-info/SOURCES.txt +0 -0
- {my_aws_helpers-4.6.0 → my_aws_helpers-4.8.0}/my_aws_helpers.egg-info/dependency_links.txt +0 -0
- {my_aws_helpers-4.6.0 → my_aws_helpers-4.8.0}/my_aws_helpers.egg-info/requires.txt +0 -0
- {my_aws_helpers-4.6.0 → my_aws_helpers-4.8.0}/my_aws_helpers.egg-info/top_level.txt +0 -0
- {my_aws_helpers-4.6.0 → my_aws_helpers-4.8.0}/my_aws_helpers.egg-info/zip-safe +0 -0
- {my_aws_helpers-4.6.0 → my_aws_helpers-4.8.0}/setup.cfg +0 -0
- {my_aws_helpers-4.6.0 → my_aws_helpers-4.8.0}/tests/test_cognito.py +0 -0
- {my_aws_helpers-4.6.0 → my_aws_helpers-4.8.0}/tests/test_event.py +0 -0
|
@@ -13,6 +13,13 @@ import concurrent.futures
|
|
|
13
13
|
from dataclasses import dataclass
|
|
14
14
|
|
|
15
15
|
|
|
16
|
+
class ImageType(str, Enum):
|
|
17
|
+
gif = "gif"
|
|
18
|
+
jpeg = "jpeg"
|
|
19
|
+
png = "png"
|
|
20
|
+
webp = "webp"
|
|
21
|
+
|
|
22
|
+
|
|
16
23
|
class PromptType(str, Enum):
|
|
17
24
|
transaction_headers = "transactions_headers_prompt_v2.txt"
|
|
18
25
|
transactions = "transactions_prompt.txt"
|
|
@@ -239,30 +246,25 @@ class Bedrock:
|
|
|
239
246
|
self.logger.exception(e)
|
|
240
247
|
return []
|
|
241
248
|
|
|
249
|
+
def _get_image_block(self, image: bytes, image_content_type: ImageType) -> dict:
|
|
250
|
+
return {
|
|
251
|
+
"image": {
|
|
252
|
+
"format": image_content_type,
|
|
253
|
+
"source": {
|
|
254
|
+
"bytes": image,
|
|
255
|
+
},
|
|
256
|
+
}
|
|
257
|
+
}
|
|
242
258
|
|
|
243
|
-
def image_analysis(
|
|
244
|
-
|
|
245
|
-
|
|
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
|
-
|
|
259
|
+
def image_analysis(
|
|
260
|
+
self, images: List[bytes], prompt: str, image_content_type: ImageType
|
|
261
|
+
) -> OCRResult:
|
|
260
262
|
|
|
261
|
-
system_prompt = [{"text":
|
|
263
|
+
system_prompt = [{"text": prompt}]
|
|
262
264
|
message = [
|
|
263
265
|
{
|
|
264
266
|
"role": "user",
|
|
265
|
-
"content": [self._get_image_block(image=image) for image in images],
|
|
267
|
+
"content": [self._get_image_block(image=image, image_content_type=image_content_type) for image in images],
|
|
266
268
|
}
|
|
267
269
|
]
|
|
268
270
|
response = self.client.converse(
|
|
@@ -274,4 +276,4 @@ class Bedrock:
|
|
|
274
276
|
response["output"]["message"]["content"][0]["text"]
|
|
275
277
|
)
|
|
276
278
|
result["token_usage"] = response["usage"]
|
|
277
|
-
return OCRResult.from_dict(data=result)
|
|
279
|
+
return OCRResult.from_dict(data=result)
|
|
@@ -41,6 +41,7 @@ class S3Serialiser:
|
|
|
41
41
|
return {k: S3Serialiser.object_serialiser(v) for k, v in obj.items()}
|
|
42
42
|
return S3Serialiser._serialise(obj=obj)
|
|
43
43
|
|
|
44
|
+
|
|
44
45
|
class S3Location:
|
|
45
46
|
bucket: str
|
|
46
47
|
file_name: str
|
|
@@ -96,13 +97,14 @@ class S3:
|
|
|
96
97
|
|
|
97
98
|
def list_objects_by_prefix(self, bucket_name: str, prefix: str) -> List[Dict]:
|
|
98
99
|
try:
|
|
99
|
-
response = self.client.
|
|
100
|
-
Bucket=bucket_name,
|
|
101
|
-
Prefix=prefix
|
|
100
|
+
response = self.client.list_objects_v2(
|
|
101
|
+
Bucket=bucket_name, Prefix=prefix
|
|
102
102
|
)
|
|
103
|
-
return response[
|
|
103
|
+
return response["Contents"]
|
|
104
104
|
except Exception as e:
|
|
105
|
-
logger.exception(
|
|
105
|
+
logger.exception(
|
|
106
|
+
f"Failed to get objects from s3: {bucket_name}/{prefix} due to {e}"
|
|
107
|
+
)
|
|
106
108
|
return []
|
|
107
109
|
|
|
108
110
|
def get_object(self, bucket_name: str, file_name: str):
|
|
@@ -122,7 +124,7 @@ class S3:
|
|
|
122
124
|
"Key": file_name,
|
|
123
125
|
},
|
|
124
126
|
ExpiresIn=expires_in,
|
|
125
|
-
)
|
|
127
|
+
)
|
|
126
128
|
|
|
127
129
|
def get_s3_location_from_bucket_file(
|
|
128
130
|
bucket_name: str, file_name: str
|
|
@@ -258,7 +260,9 @@ class S3:
|
|
|
258
260
|
)
|
|
259
261
|
except Exception as e:
|
|
260
262
|
logger.exception(f"Failed to save jpeg to s3 due to {e}")
|
|
261
|
-
return None
|
|
263
|
+
return None
|
|
262
264
|
|
|
263
265
|
def read_dict_from_s3(self, s3_location: S3Location) -> dict:
|
|
264
|
-
return json.loads(
|
|
266
|
+
return json.loads(
|
|
267
|
+
self.read_binary_from_s3(s3_location=s3_location).decode("utf-8")
|
|
268
|
+
)
|
|
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.6.0 → my_aws_helpers-4.8.0}/my_aws_helpers/prompts/markdown_system_prompt.txt
RENAMED
|
File without changes
|
{my_aws_helpers-4.6.0 → my_aws_helpers-4.8.0}/my_aws_helpers/prompts/transactions_headers_prompt.txt
RENAMED
|
File without changes
|
|
File without changes
|
{my_aws_helpers-4.6.0 → my_aws_helpers-4.8.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
|