my-aws-helpers 5.5.0__tar.gz → 5.7.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-5.5.0 → my_aws_helpers-5.7.0}/PKG-INFO +1 -1
- {my_aws_helpers-5.5.0 → my_aws_helpers-5.7.0}/my_aws_helpers/bedrock.py +17 -3
- {my_aws_helpers-5.5.0 → my_aws_helpers-5.7.0}/my_aws_helpers.egg-info/PKG-INFO +1 -1
- {my_aws_helpers-5.5.0 → my_aws_helpers-5.7.0}/setup.py +1 -1
- {my_aws_helpers-5.5.0 → my_aws_helpers-5.7.0}/MANIFEST.in +0 -0
- {my_aws_helpers-5.5.0 → my_aws_helpers-5.7.0}/README.md +0 -0
- {my_aws_helpers-5.5.0 → my_aws_helpers-5.7.0}/my_aws_helpers/api.py +0 -0
- {my_aws_helpers-5.5.0 → my_aws_helpers-5.7.0}/my_aws_helpers/auth.py +0 -0
- {my_aws_helpers-5.5.0 → my_aws_helpers-5.7.0}/my_aws_helpers/cognito.py +0 -0
- {my_aws_helpers-5.5.0 → my_aws_helpers-5.7.0}/my_aws_helpers/dynamo.py +0 -0
- {my_aws_helpers-5.5.0 → my_aws_helpers-5.7.0}/my_aws_helpers/errors.py +0 -0
- {my_aws_helpers-5.5.0 → my_aws_helpers-5.7.0}/my_aws_helpers/event.py +0 -0
- {my_aws_helpers-5.5.0 → my_aws_helpers-5.7.0}/my_aws_helpers/logging.py +0 -0
- {my_aws_helpers-5.5.0 → my_aws_helpers-5.7.0}/my_aws_helpers/prompts/__init__.py +0 -0
- {my_aws_helpers-5.5.0 → my_aws_helpers-5.7.0}/my_aws_helpers/prompts/markdown_system_prompt.txt +0 -0
- {my_aws_helpers-5.5.0 → my_aws_helpers-5.7.0}/my_aws_helpers/prompts/transactions_headers_prompt.txt +0 -0
- {my_aws_helpers-5.5.0 → my_aws_helpers-5.7.0}/my_aws_helpers/prompts/transactions_headers_prompt_v2.txt +0 -0
- {my_aws_helpers-5.5.0 → my_aws_helpers-5.7.0}/my_aws_helpers/prompts/transactions_prompt.txt +0 -0
- {my_aws_helpers-5.5.0 → my_aws_helpers-5.7.0}/my_aws_helpers/s3.py +0 -0
- {my_aws_helpers-5.5.0 → my_aws_helpers-5.7.0}/my_aws_helpers/sfn.py +0 -0
- {my_aws_helpers-5.5.0 → my_aws_helpers-5.7.0}/my_aws_helpers.egg-info/SOURCES.txt +0 -0
- {my_aws_helpers-5.5.0 → my_aws_helpers-5.7.0}/my_aws_helpers.egg-info/dependency_links.txt +0 -0
- {my_aws_helpers-5.5.0 → my_aws_helpers-5.7.0}/my_aws_helpers.egg-info/requires.txt +0 -0
- {my_aws_helpers-5.5.0 → my_aws_helpers-5.7.0}/my_aws_helpers.egg-info/top_level.txt +0 -0
- {my_aws_helpers-5.5.0 → my_aws_helpers-5.7.0}/my_aws_helpers.egg-info/zip-safe +0 -0
- {my_aws_helpers-5.5.0 → my_aws_helpers-5.7.0}/setup.cfg +0 -0
- {my_aws_helpers-5.5.0 → my_aws_helpers-5.7.0}/tests/test_cognito.py +0 -0
- {my_aws_helpers-5.5.0 → my_aws_helpers-5.7.0}/tests/test_event.py +0 -0
|
@@ -5,6 +5,7 @@ import json
|
|
|
5
5
|
import time
|
|
6
6
|
import os
|
|
7
7
|
import io
|
|
8
|
+
import re
|
|
8
9
|
from copy import copy
|
|
9
10
|
from typing import Optional, List, Dict
|
|
10
11
|
from enum import Enum
|
|
@@ -122,7 +123,7 @@ class OCRResultQueries(BaseS3Queries):
|
|
|
122
123
|
class Bedrock:
|
|
123
124
|
def __init__(
|
|
124
125
|
self,
|
|
125
|
-
model_id: str = "apac.anthropic.claude-3-5-sonnet-20241022-v2:0"
|
|
126
|
+
model_id: str = "apac.anthropic.claude-3-5-sonnet-20241022-v2:0",#anthropic.claude-sonnet-4-20250514-v1:0
|
|
126
127
|
logger=None,
|
|
127
128
|
sleep_time: float = 1.0,
|
|
128
129
|
):
|
|
@@ -162,6 +163,19 @@ class Bedrock:
|
|
|
162
163
|
print(e)
|
|
163
164
|
return None
|
|
164
165
|
|
|
166
|
+
@staticmethod
|
|
167
|
+
def extract_json_from_markdown(text: str):
|
|
168
|
+
"""
|
|
169
|
+
Extracts the JSON object from a string that may be wrapped in ```json ... ``` code block
|
|
170
|
+
"""
|
|
171
|
+
# Match a {...} block anywhere in the text
|
|
172
|
+
match = re.search(r"\{.*\}", text, re.DOTALL)
|
|
173
|
+
if match:
|
|
174
|
+
json_str = match.group(0)
|
|
175
|
+
return json.loads(json_str)
|
|
176
|
+
else:
|
|
177
|
+
raise ValueError("No JSON object found in the text")
|
|
178
|
+
|
|
165
179
|
def _get_prompt(self, prompt_type: str) -> Optional[str]:
|
|
166
180
|
if prompt_type not in list(PromptType):
|
|
167
181
|
raise Exception(f"Error: Invalid prompt type")
|
|
@@ -339,8 +353,8 @@ class Bedrock:
|
|
|
339
353
|
)
|
|
340
354
|
|
|
341
355
|
result = {}
|
|
342
|
-
result["content"] =
|
|
343
|
-
response["output"]["message"]["content"][0]["text"]
|
|
356
|
+
result["content"] = Bedrock.extract_json_from_markdown(
|
|
357
|
+
text = response["output"]["message"]["content"][0]["text"]
|
|
344
358
|
)
|
|
345
359
|
result["token_usage"] = response["usage"]
|
|
346
360
|
return OCRResult.from_dict(data=result)
|
|
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-5.5.0 → my_aws_helpers-5.7.0}/my_aws_helpers/prompts/markdown_system_prompt.txt
RENAMED
|
File without changes
|
{my_aws_helpers-5.5.0 → my_aws_helpers-5.7.0}/my_aws_helpers/prompts/transactions_headers_prompt.txt
RENAMED
|
File without changes
|
|
File without changes
|
{my_aws_helpers-5.5.0 → my_aws_helpers-5.7.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
|
|
File without changes
|