This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
CURRENCY_LIST = {"£": "pounds", "$": "dollars", "€": "euros"} | |
CURRENCY_PATTERN = fr"((?:[{''.join(CURRENCY_LIST.keys())}]+\d*)(?:\,*\d+)(?:\.\d+)?(?i:[km])*)|(\d+(?:\,*\d+)(?:\.\d+)?(?i:[km])*(?:[{''.join(CURRENCY_LIST.keys())}]+))|((?:[{''.join(CURRENCY_LIST.keys())}]+))" | |
def _currency_to_text(text: str) -> str: | |
clean = ( | |
lambda x: x.lower() | |
.replace(",", "") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from mantiumapi import prompt | |
from mantiumapi import client | |
from dotenv import load_dotenv | |
# load Mantium credentials | |
load_dotenv() | |
mantium_user = os.getenv("MANTIUM_USER") | |
mantium_password = os.getenv("MANTIUM_PASSWORD") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, request | |
# Init Flask App | |
app = Flask(__name__) | |
@app.route('/') | |
def hello(): | |
return "Welcome to Mantium WhatsApp Bot" | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, request | |
SLEEP_TIME = 5 | |
PROMPT_ID = "98b58a5d-12ff-4e64-868e-4dabf986eac7" | |
# Init Flask App | |
app = Flask(__name__) | |
@app.route('/') | |
def hello(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import time | |
from flask import Flask, request | |
from twilio.twiml.messaging_response import MessagingResponse | |
from dotenv import load_dotenv | |
import threading, time, random | |
# load Mantium credentials | |
load_dotenv() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import boto3 | |
import sagemaker | |
from sagemaker import get_execution_role | |
from sagemaker.s3 import S3Uploader, S3Downloader |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
region = boto3.Session().region_name | |
role = get_execution_role() | |
bucket = sagemaker.Session().default_bucket() | |
prefix = "phi-masking" | |
bucket_path = "https://s3-{}.amazonaws.com/{}".format(region, bucket) | |
endpoint_url = "https://textract.{}.amazonaws.com".format(region) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
textract_client = boto3.client(service_name = 'textract', region_name = region, | |
endpoint_url = endpoint_url) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
documentName = "health_notes.png" | |
with open(documentName, 'rb') as file: | |
img_file = file.read() | |
bytes_arr = bytearray(img_file) | |
print('Image file is loaded', documentName) | |
file.close() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
response = textract_client.detect_document_text(Document={'Bytes': bytes_arr}) | |
print(response) |
OlderNewer