Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge updated 5.4.2 from develop to main #638

Merged
merged 3 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed
- Fixed request signing issue when using Custom domain ([issue #605](https://github.com/aws-solutions/qnabot-on-aws/issues/605))
- Fixed Sagemaker LLM deployment ([issue #635](https://github.com/aws-solutions/qnabot-on-aws/issues/635))
- Fixed voice integration with LLM response
- Fixed unsupported SSML tags
- Fixed Kendra API retrieval bug
Expand Down
52 changes: 49 additions & 3 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ This software includes third party software subject to the following copyrights:
ajv under the Massachusetts Institute of Technology (MIT) license
alexa-sdk under the Apache License Version 2.0
arrow under the Apache License Version 2.0
astroid under the GNU Lesser General Public License v2 (LGPLv2)
async-mutex under the Massachusetts Institute of Technology (MIT) license
attrs under the Massachusetts Institute of Technology (MIT) license
autopep8 under the Massachusetts Institute of Technology (MIT) license
autosize under the Massachusetts Institute of Technology (MIT) license
aws-lex-web-ui under the Amazon Software License
aws-sdk under the Apache License Version 2.0
Expand All @@ -42,44 +45,59 @@ babel-preset-es2015 under the Massachusetts Institute of Technology (MIT) licens
babel-preset-es2015-ie the Massachusetts Institute of Technology (MIT) license
beautifulsoup under Massachusetts Institute of Technology (MIT) License
beautifulsoup4 under the Massachusetts Institute of Technology (MIT) license
black under the Massachusetts Institute of Technology (MIT) license
bluebird under the Massachusetts Institute of Technology (MIT) license
body-parser under the Massachusetts Institute of Technology (MIT) license
boolean.py under BSD-2-Clause
boto3 under the Apache License Version 2.0
botocore under the Apache License Version 2.0
bowser under the Massachusetts Institute of Technology (MIT) license
canvasapi under Massachusetts Institute of Technology (MIT) License
cffi under the Massachusetts Institute of Technology (MIT) license
cfn-lambda under the Massachusetts Institute of Technology (MIT) license
cfn-response under the Amazon Software License
chalk under the Massachusetts Institute of Technology (MIT) license
chrome-aws-lambda under the Massachusetts Institute of Technology (MIT) license
clean-deep under the Massachusetts Institute of Technology (MIT) license
click under the BSD License (BSD-3-Clause)
clipboard under the Massachusetts Institute of Technology (MIT) license
commander under the Massachusetts Institute of Technology (MIT) license
copy-webpack-plugin under the Massachusetts Institute of Technology (MIT) license
coverage under the Apache License Version 2.0
crhelper under the Apache License Version 2.0
cryptography under the Apache License Version 2.0
css-loader under the Massachusetts Institute of Technology (MIT) license
defusedxml under the Python Software Foundation License Version 2
dill under the BSD License (BSD-3-Clause)
dir-loader under the Massachusetts Institute of Technology (MIT) license
docker under the Apache License Version 2.0
elasticsearch under the Apache License Version 2.0
exceptiongroup under the Massachusetts Institute of Technology (MIT) license
exports-loader under the Massachusetts Institute of Technology (MIT) license
express under the Massachusetts Institute of Technology (MIT) license
faker under the Massachusetts Institute of Technology (MIT) license
file-loader under the Massachusetts Institute of Technology (MIT) license
file-saver under the Massachusetts Institute of Technology (MIT) license
filelock under the Unlicense license
flake8 under the Massachusetts Institute of Technology (MIT) license
handlebars under the Massachusetts Institute of Technology (MIT) license
handlebars-loader under the Massachusetts Institute of Technology (MIT) license
highlight.js under BSD-3-Clause license
html-webpack-plugin under the Massachusetts Institute of Technology (MIT) license
http-aws-es under the Massachusetts Institute of Technology (MIT) license
idle-vue under the Massachusetts Institute of Technology (MIT) license
importlib-resources under the Apache Software License
intercept-stdout under the Massachusetts Institute of Technology (MIT) license
iniconfig under the Massachusetts Institute of Technology (MIT) license
isort under the Massachusetts Institute of Technology (MIT) license
Jinja2 under the BSD License (BSD-3-Clause)
jmespath under the Massachusetts Institute of Technology (MIT) license
js-cache under the Massachusetts Institute of Technology (MIT) license
jsdom under the Massachusetts Institute of Technology (MIT) license
jsdom-global under the Massachusetts Institute of Technology (MIT) license
jsdom-loader under the Massachusetts Institute of Technology (MIT) license
jsheader under the Apache License Version 2.0
jsonschema-spec under the Apache License Version 2.0
json-parse-better-errors under the Massachusetts Institute of Technology (MIT) license
json-stringify-pretty-compact under the Massachusetts Institute of Technology (MIT) license
JSONPath under the Massachusetts Institute of Technology (MIT) license
Expand All @@ -88,20 +106,42 @@ jsonwebtoken under the Massachusetts Institute of Technology (MIT) license
jszip under the Massachusetts Institute of Technology (MIT) license
jwks-rsa under the Massachusetts Institute of Technology (MIT) license
langchain under the Massachusetts Institute of Technology (MIT) license
lazy-object-proxy under the BSD License (BSD-2-Clause)
license-expression under Apache License Version 2.0
lodash under the Massachusetts Institute of Technology (MIT) license
lodash-webpack-plugin under the Massachusetts Institute of Technology (MIT) license
marked under the Massachusetts Institute of Technology (MIT) license
MarkupSafe under the BSD License (BSD-3-Clause)
material-design-icons under the Apache License Version 2.0
mccabe under the Massachusetts Institute of Technology (MIT) license
mini-css-extract-plugin under the Massachusetts Institute of Technology (MIT) license
minimist under the Massachusetts Institute of Technology (MIT) license
moment under the Massachusetts Institute of Technology (MIT) license
morgan under the Massachusetts Institute of Technology (MIT) license
moto under the Apache License Version 2.0
mypy under the Massachusetts Institute of Technology (MIT) license
mypy-extensions under the Massachusetts Institute of Technology (MIT) license
openapi-schema-validator under the BSD License
openapi-spec-validator under the Apache License Version 2.0
ora under the Massachusetts Institute of Technology (MIT) license
pathable under the Apache License Version 2.0
pathspec under the Mozilla Public License 2.0 (MPL 2.0)
platformdirs under the Massachusetts Institute of Technology (MIT) license
pluggy under the Massachusetts Institute of Technology (MIT) license
progress-bar-webpack-plugin under the Massachusetts Institute of Technology (MIT) license
pug under the Massachusetts Institute of Technology (MIT) license
pug-loader under the Massachusetts Institute of Technology (MIT) license
pug-plain-loader under the Massachusetts Institute of Technology (MIT) license
pug-runtime under the Massachusetts Institute of Technology (MIT) license
pycodestyle under the Massachusetts Institute of Technology (MIT) license
pycparser under the BSD License
pyflakes under the Massachusetts Institute of Technology (MIT) license
pylint under the GNU General Public License v2 (GPLv2)
pyrsistent under the Massachusetts Institute of Technology (MIT) license
pytest under the Massachusetts Institute of Technology (MIT) license
pytest-cov under the Massachusetts Institute of Technology (MIT) license
pytest-env under the Massachusetts Institute of Technology (MIT) license
pytest-mock under the Massachusetts Institute of Technology (MIT) license
py-serializable under the Apache License Version 2.0
python-dateutil under the Apache License Version 2.0 and BSD License
pytz under the Massachusetts Institute of Technology (MIT) license
Expand All @@ -115,6 +155,7 @@ raw-text under the Massachusetts Institute of Technology (MIT) license
read-excel-file under the Massachusetts Institute of Technology (MIT) license
recursive-readdir under the Massachusetts Institute of Technology (MIT) license
require-dir under the Massachusetts Institute of Technology (MIT) license
responses under the Apache License Version 2.0
roboto-fontface under the Apache License Version 2.0
s3transfer under the Apache License Version 2.0
sass under the Massachusetts Institute of Technology (MIT) license
Expand All @@ -127,6 +168,11 @@ strip-ansi under the Massachusetts Institute of Technology (MIT) license
style-loader under the Massachusetts Institute of Technology (MIT) license
stylus under the Massachusetts Institute of Technology (MIT) license
stylus-loader under the Massachusetts Institute of Technology (MIT) license
tomli under the Massachusetts Institute of Technology (MIT) license
tomlkit under the Massachusetts Institute of Technology (MIT) license
types-PyYAML under the Apache License Version 2.0
types-python-dateutil under the Apache License Version 2.0
typing_extensions under Python Software Foundation License
urlcode-json under the BSD license
utf8 under the Massachusetts Institute of Technology (MIT) license
vee-validate under the Massachusetts Institute of Technology (MIT) license
Expand All @@ -148,6 +194,6 @@ webpack-cli under the Massachusetts Institute of Technology (MIT) license
webpack-dev-server under the Massachusetts Institute of Technology (MIT) license
webpack-merge under the Massachusetts Institute of Technology (MIT) license
webpack-s3-plugin under the Massachusetts Institute of Technology (MIT) license
typing_extensions under Python Software Foundation License
boolean.py under BSD-2-Clause
license-expression under Apache License Version 2.0
websocket-client under the Apache License Version 2.0
Werkzeug under the BSD License
xmltodict under the Massachusetts Institute of Technology (MIT) license
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Alternatively, if you want to custom deploy QnABot on AWS, refer to the details
### Environment Prerequisites

- Run Linux. (tested on Amazon Linux)
- Install npm >7.10.0 and node >16.X.X ([instructions](https://nodejs.org/en/download/))
- Install npm >8.6.0 and node >18.X.X ([instructions](https://nodejs.org/en/download/))
- Install and configure git lfs ([instructions](https://git-lfs.com/))
- Clone this repo.
- Set up an AWS account. ([instructions](https://AWS.amazon.com/free/))
Expand Down
2 changes: 1 addition & 1 deletion lambda/lexv2-build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ DST=../../build/lambda/$(NAME).zip
RESOURCES := $(shell find . | grep -v test )

$(DST): $(RESOURCES)
echo "Building $(NAME)"; pip3 install -r requirements.txt -t ./py_modules && zip -r -q $(DST) .
echo "Building $(NAME)"; python3 -m virtualenv venv; source ./venv/bin/activate; pip3 install -r requirements.txt -t ./py_modules; deactivate; rm -rf venv; zip -r -q $(DST) .
35 changes: 33 additions & 2 deletions run-all-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,33 @@ run_javascript_lambda_test() {
exit 1
fi
[ "${CLEAN:-true}" = "true" ] && rm -rf coverage/lcov-report

cd $source_dir
}

run_python_unit_test() {
directory=$1
description=$2
echo "------------------------------------------------------------------------------"
echo "[Test] Python: $directory, $description"
echo "------------------------------------------------------------------------------"
cd $source_dir/$directory
python3 -m virtualenv venv
source ./venv/bin/activate
if [ -f "requirements.txt" ]
then
pip install -r requirements.txt
fi

if [ -f "requirements-test.txt" ]
then
pip install -r requirements-test.txt
fi

pytest -v
deactivate
[ "${CLEAN:-true}" = "true" ] && rm -rf coverage/lcov.info
cd $source_dir
}

# Save the current working directory and set source directory
Expand All @@ -45,11 +72,15 @@ cd $source_dir
#
CLEAN="${CLEAN:-true}"

echo "Starting Lambda unit tests"
# echo "Starting Lambda unit tests"

run_javascript_lambda_test connect "Connect Lambda Unit Tests"
run_javascript_lambda_test genesys "Genesys Lambda Unit Tests"
run_javascript_lambda_test js_lambda_hook_sdk "JS Lambda Hook SDK Unit Tests"
run_javascript_lambda_test qnabot-common-layer "QnaBot Common Layer Lambda Unit Tests"
run_javascript_lambda_test schema "Schema Lambda Unit Tests"
run_javascript_lambda_test translate "Translate Lambda Unit Tests"
run_javascript_lambda_test translate "Translate Lambda Unit Tests"

echo "Starting Source unit tests"

run_python_unit_test source "QnABot CLI"
40 changes: 18 additions & 22 deletions source/aws_solutions/qnabot/cli/qnabot_cli_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def initiate_import(
s3_client = get_service_client("s3") # boto3.client('s3')
# create a options json config file that includes import options that were used
response = s3_client.put_object(
Bucket=str_import_bucket_name, Key="options/" + os.path.basename(source_filename), Body=str_import_options
Bucket=str_import_bucket_name, Key=f"options/{os.path.basename(source_filename)}", Body=str_import_options
)

if file_format == "JSON":
Expand All @@ -88,13 +88,13 @@ def initiate_import(
) # convert to JSON Lines format (if input is JSON format)
# upload the contents of the converted json file to S3
response = s3_client.put_object(
Bucket=str_import_bucket_name, Key="data/" + os.path.basename(source_filename), Body=str_file_contents
Bucket=str_import_bucket_name, Key=f"data/{os.path.basename(source_filename)}", Body=str_file_contents
)
else:
with open(source_filename, "rb") as obj_file: # open file object
# upload the contents of the json file to S3
response = s3_client.put_object(
Bucket=str_import_bucket_name, Key="data/" + os.path.basename(source_filename), Body=obj_file
Bucket=str_import_bucket_name, Key=f"data/{os.path.basename(source_filename)}", Body=obj_file
)

# check status of the file import
Expand Down Expand Up @@ -150,9 +150,9 @@ def initiate_export(cloudformation_stack_name: str, export_filename: str, export
"bucket": str_export_bucket_name,
"index": str_open_search_index,
"id": os.path.basename(export_filename),
"config": "status/" + os.path.basename(export_filename),
"tmp": "tmp/" + os.path.basename(export_filename),
"key": "data/" + os.path.basename(export_filename),
"config": f"status/{os.path.basename(export_filename)}",
"tmp": f"tmp/{os.path.basename(export_filename)}",
"key": f"data/{os.path.basename(export_filename)}",
"filter": export_filter,
"status": "Started",
}
Expand All @@ -162,7 +162,7 @@ def initiate_export(cloudformation_stack_name: str, export_filename: str, export
# put a export config object in S3 bucket to initiate export
s3_client = get_service_client("s3") # boto3.client('s3')
response = s3_client.put_object(
Body=str_export_config, Bucket=str_export_bucket_name, Key="status/" + os.path.basename(export_filename)
Body=str_export_config, Bucket=str_export_bucket_name, Key=f"status/{os.path.basename(export_filename)}"
)

# check status of the file export
Expand Down Expand Up @@ -216,7 +216,7 @@ def download_export(bucket: str, export_filename: str, exportdatetime: datetime,
s3_client = get_service_client("s3") # boto3.client('s3')
# get object only if the object has changed since last request
response = s3_client.get_object(
Bucket=bucket, Key="data/" + os.path.basename(export_filename), IfModifiedSince=exportdatetime
Bucket=bucket, Key=f"data/{os.path.basename(export_filename)}", IfModifiedSince=exportdatetime
)
str_file_contents = response["Body"].read().decode("utf-8") # read object body
if file_format == "JSON":
Expand All @@ -240,7 +240,7 @@ def download_export(bucket: str, export_filename: str, exportdatetime: datetime,
return error_response(
error_code=err_exception.errno,
message=err_exception.strerror,
comments="There was an issue using: " + export_filename + " Check the path and try again.",
comments=f"There was an issue using: {export_filename} Check the path and try again.",
status="Error",
show_error=True,
)
Expand Down Expand Up @@ -276,7 +276,7 @@ def get_import_status(bucket: str, source_filename: str, importdatetime: datetim
try:
s3_client = get_service_client("s3") # boto3.client('s3')
# get object only if the object has changed since last request
key = "status/" + os.path.basename(source_filename)
key = f"status/{os.path.basename(source_filename)}"
#logger.debug(f"Getting import status for {bucket=} {key=}")
response = s3_client.get_object(Bucket=bucket, Key=key, IfModifiedSince=importdatetime)

Expand Down Expand Up @@ -330,7 +330,7 @@ def get_export_status(bucket: str, export_filename: str, exportdatetime: datetim
s3_client = get_service_client("s3") # boto3.client('s3')
# get object only if the object has changed since last request
response = s3_client.get_object(
Bucket=bucket, Key="status/" + os.path.basename(export_filename), IfModifiedSince=exportdatetime
Bucket=bucket, Key=f"status/{os.path.basename(export_filename)}", IfModifiedSince=exportdatetime
)

obj_status_details = json.loads(response["Body"].read().decode("utf-8")) # read object body
Expand Down Expand Up @@ -365,6 +365,8 @@ def convert_json_to_jsonl(source_filename: str):
:return: file contents
"""

error_msg = f"There was an error reading the file. {source_filename}. Check the file format and try again."

try:
with open(source_filename, "rb") as obj_file: # open file in read mode
str_file_contents = obj_file.read() # read from file
Expand All @@ -378,37 +380,31 @@ def convert_json_to_jsonl(source_filename: str):
return error_response(
error_code="",
message=err_exception.msg,
comments="There was an error reading the file "
+ source_filename
+ ". Check the file format and try again",
comments=error_msg,
status="Error",
show_error=True,
)
except UnicodeDecodeError as err_exception:
return error_response(
error_code="",
message=err_exception.__doc__,
comments="There was an error reading the file "
+ source_filename
+ ". Check the file format and try again",
comments=error_msg,
status="Error",
show_error=True,
)
except TypeError as err_exception:
return error_response(
error_code="",
message=err_exception.__doc__,
comments="There was an error reading the file "
+ source_filename
+ ". Check the file format and try again",
comments=error_msg,
status="Error",
show_error=True,
)
except OSError as err_exception:
return error_response(
error_code=err_exception.errno,
message=err_exception.strerror,
comments="There was an error reading the file " + source_filename + ". Check the path and try again",
comments=f"There was an error reading the file {source_filename}. Check the path and try again",
status="Error",
show_error=True,
)
Expand Down Expand Up @@ -450,7 +446,7 @@ def error_response(error_code: str, message: str, comments: str, status: str, sh
return_response = json.dumps(return_response, indent=4)

if show_error:
click.echo("[Error] " + str(error_code) + ": " + message + ". " + comments)
click.echo(f"[Error] {str(error_code)}: {message}. {comments}")
sys.exit(1)
else:
return return_response
Loading