Skip to content

Commit 9f89e57

Browse files
author
Bob Strahan
committed
Merge branch 'develop' v0.7.12
2 parents b6bb5da + a75d4e6 commit 9f89e57

20 files changed

+875
-875
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ build
55
/sample-data
66
.vscode
77
/pca-ui/src/witch/witch.zip
8+
.DS_Store
9+
.idea/
10+
pca-ssm/.DS_Store

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.7.12] - 2025-02-21
11+
12+
### Added
13+
- Added support for Amazon Nova models (amazon.nova-micro-v1:0, amazon.nova-lite-v1:0, amazon.nova-pro-v1:0) - PR #295
14+
- Updated Anthropic Claude models to the latest 3.5 versions (anthropic.claude-3-5-haiku-20241022-v1:0, anthropic.claude-3-5-sonnet-20241022-v2:0) - PR #295
15+
- Removed older versions of Amazon Titan and Anthropic Claude models (amazon.titan-text-express-v1, anthropic.claude-v1, anthropic.claude-instant-v1, anthropic.claude-v2) - PR #295
16+
- Refactored Bedrock calls to use the Converse API eliminating the need for custom model specific payloads - PR #295
17+
- Refactored all model invocation to use Inference Profiles. This is required for Nova models. It is also applied to Anthropic models for consistency and improved scalability. - PR #295
18+
- Added adaptive retry configuration to Bedrock api calls to add some tolerance for quota throttling exceptions (at the expense of latency) - PR #295
19+
20+
### Fixed
21+
- Fixed: Only one PCA stack may be sucessfully deployed in a given account/region due to fixed SSM parameter names - PR #291, #293
22+
- Fixed: Current publish.sh does not work with ARM chipsets such as the Apple M series. Set x86_64 arch for local build - PR #288
23+
24+
1025
## [0.7.11] - 2024-10-09
1126

1227
### Added
@@ -275,6 +290,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
275290
- Initial release
276291

277292
[Unreleased]: https://github.com/aws-samples/amazon-transcribe-post-call-analytics/compare/main...develop
293+
[0.7.12]: https://github.com/aws-samples/amazon-transcribe-post-call-analytics/releases/tag/v0.7.12
278294
[0.7.11]: https://github.com/aws-samples/amazon-transcribe-post-call-analytics/releases/tag/v0.7.11
279295
[0.7.10]: https://github.com/aws-samples/amazon-transcribe-post-call-analytics/releases/tag/v0.7.10
280296
[0.7.9]: https://github.com/aws-samples/amazon-transcribe-post-call-analytics/releases/tag/v0.7.9

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.7.11
1+
0.7.12

pca-main-nokendra.template

Lines changed: 76 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
AWSTemplateFormatVersion: "2010-09-09"
22

3-
Description: Amazon Transcribe Post Call Analytics - PCA (v0.7.11) (uksb-1sn29lk73, SO9071)
3+
Description: Amazon Transcribe Post Call Analytics - PCA (v0.7.12) (uksb-1sn29lk73, SO9071)
44

55
Parameters:
66

@@ -352,10 +352,10 @@ Parameters:
352352
- PROD
353353
Default: PROD
354354

355-
DatabaseName:
355+
GlueDatabaseName:
356356
Type: String
357-
Default: 'pca'
358-
Description: Glue catalog database name used to contain tables/views for SQL integration.
357+
AllowedPattern: "^$|[a-z0-9_-]+"
358+
Description: (Optional) Glue catalog database name in lowercase characters used to contain tables/views for SQL integration.
359359

360360
EnablePcaDashboards:
361361
Type: String
@@ -384,14 +384,17 @@ Parameters:
384384

385385
GenAIQueryBedrockModelId:
386386
Type: String
387-
Default: anthropic.claude-3-haiku-20240307-v1:0
387+
Default: us.amazon.nova-lite-v1:0
388388
AllowedValues:
389389
- anthropic.claude-3-haiku-20240307-v1:0
390390
- anthropic.claude-3-sonnet-20240229-v1:0
391-
- amazon.titan-text-express-v1
392-
- anthropic.claude-v1
393-
- anthropic.claude-instant-v1
394-
- anthropic.claude-v2
391+
- us.amazon.nova-micro-v1:0
392+
- us.amazon.nova-lite-v1:0
393+
- us.amazon.nova-pro-v1:0
394+
- us.anthropic.claude-3-5-haiku-20241022-v1:0
395+
- us.anthropic.claude-3-5-sonnet-20241022-v2:0
396+
- eu.anthropic.claude-3-5-sonnet-20240620-v1:0
397+
- apac.anthropic.claude-3-5-sonnet-20240620-v1:0
395398
Description: (Optional) If 'GenAIQuery' is BEDROCK, which Bedrock model to use.
396399

397400
CallSummarization:
@@ -417,14 +420,17 @@ Parameters:
417420

418421
SummarizationBedrockModelId:
419422
Type: String
420-
Default: anthropic.claude-3-haiku-20240307-v1:0
423+
Default: us.amazon.nova-lite-v1:0
421424
AllowedValues:
422425
- anthropic.claude-3-haiku-20240307-v1:0
423426
- anthropic.claude-3-sonnet-20240229-v1:0
424-
- amazon.titan-text-express-v1
425-
- anthropic.claude-v1
426-
- anthropic.claude-instant-v1
427-
- anthropic.claude-v2
427+
- us.amazon.nova-micro-v1:0
428+
- us.amazon.nova-lite-v1:0
429+
- us.amazon.nova-pro-v1:0
430+
- us.anthropic.claude-3-5-haiku-20241022-v1:0
431+
- us.anthropic.claude-3-5-sonnet-20241022-v2:0
432+
- eu.anthropic.claude-3-5-sonnet-20240620-v1:0
433+
- apac.anthropic.claude-3-5-sonnet-20240620-v1:0
428434
Description: (Optional) If 'CallSummarization' is BEDROCK, which Bedrock model to use.
429435

430436
TestBedrockModelId:
@@ -495,7 +501,7 @@ Metadata:
495501
default: Advanced analytics and reporting
496502
Parameters:
497503
- EnablePcaDashboards
498-
- DatabaseName
504+
- GlueDatabaseName
499505
- Label:
500506
default: S3 Bucket Names and Retention Policy
501507
Parameters:
@@ -673,6 +679,19 @@ Resources:
673679
- ServerSideEncryptionByDefault:
674680
SSEAlgorithm: AES256
675681

682+
########################################################
683+
# Glue Database
684+
########################################################
685+
686+
PCADatabase:
687+
Type: AWS::Glue::Database
688+
Properties:
689+
CatalogId: !Ref AWS::AccountId
690+
DatabaseInput:
691+
Name: !Ref GlueDatabaseName
692+
Description: Post Call Analytics
693+
LocationUri: !Sub 's3://${OutputBucket}/${OutputBucketParsedResults}/'
694+
676695
########################################################
677696
# If Bedrock Models are selected, verify that Bedrock
678697
# is available in the region, and that models are enabled
@@ -701,6 +720,12 @@ Resources:
701720
Resource:
702721
- !Sub "arn:${AWS::Partition}:bedrock:*::foundation-model/*"
703722
- !Sub "arn:${AWS::Partition}:bedrock:*:${AWS::AccountId}:custom-model/*"
723+
- !Sub "arn:aws:bedrock:${AWS::Region}:${AWS::AccountId}:inference-profile/*"
724+
- Effect: Allow
725+
Action:
726+
- "bedrock:GetInferenceProfile"
727+
Resource:
728+
- !Sub "arn:aws:bedrock:${AWS::Region}:${AWS::AccountId}:inference-profile/*"
704729
PolicyName: BedrockPolicy
705730

706731
TestBedrockModelFunction:
@@ -723,76 +748,38 @@ Resources:
723748
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '--target', '/tmp', 'boto3'])
724749
sys.path.insert(0,'/tmp')
725750
import boto3
726-
751+
from botocore.config import Config
752+
727753
# Defaults
728754
AWS_REGION = os.environ["AWS_REGION_OVERRIDE"] if "AWS_REGION_OVERRIDE" in os.environ else os.environ["AWS_REGION"]
729755
ENDPOINT_URL = os.environ.get("ENDPOINT_URL", f'https://bedrock-runtime.{AWS_REGION}.amazonaws.com')
730756
DEFAULT_MAX_TOKENS = 128
731757

732-
def get_request_body(modelId, parameters, prompt):
733-
provider = modelId.split(".")[0]
734-
request_body = None
735-
if provider == "anthropic":
736-
if 'claude-3' in modelId:
737-
request_body = {
738-
"max_tokens": DEFAULT_MAX_TOKENS,
739-
"messages": [{"role": "user", "content": prompt}],
740-
"anthropic_version": "bedrock-2023-05-31"
741-
}
742-
else:
743-
request_body = {
744-
"prompt": prompt,
745-
"max_tokens_to_sample": DEFAULT_MAX_TOKENS
746-
}
747-
748-
request_body.update(parameters)
749-
elif provider == "ai21":
750-
request_body = {
751-
"prompt": prompt,
752-
"maxTokens": DEFAULT_MAX_TOKENS
753-
}
754-
request_body.update(parameters)
755-
elif provider == "amazon":
756-
textGenerationConfig = {
757-
"maxTokenCount": DEFAULT_MAX_TOKENS
758-
}
759-
textGenerationConfig.update(parameters)
760-
request_body = {
761-
"inputText": prompt,
762-
"textGenerationConfig": textGenerationConfig
758+
def get_generate_text(response):
759+
return response["output"]["message"]["content"][0]["text"]
760+
761+
def call_llm(prompt, modelId):
762+
client = boto3.client(
763+
service_name='bedrock-runtime',
764+
region_name=AWS_REGION,
765+
endpoint_url=ENDPOINT_URL,
766+
config=Config(retries={'max_attempts': 50, 'mode': 'adaptive'})
767+
)
768+
769+
message = {
770+
'role': 'user',
771+
'content': [{'text': prompt}]
772+
}
773+
774+
response = client.converse(
775+
modelId=modelId,
776+
messages=[message],
777+
inferenceConfig={
778+
'maxTokens': DEFAULT_MAX_TOKENS,
779+
'temperature': 0
763780
}
764-
else:
765-
raise Exception("Unsupported provider: ", provider)
766-
return request_body
767-
768-
def get_generate_text(modelId, response):
769-
provider = modelId.split(".")[0]
770-
generated_text = None
771-
if provider == "anthropic":
772-
if 'claude-3' in modelId:
773-
response_raw = json.loads(response.get("body").read().decode())
774-
generated_text = response_raw.get('content')[0].get('text')
775-
776-
else:
777-
response_body = json.loads(response.get("body").read().decode())
778-
generated_text = response_body.get("completion")
779-
elif provider == "ai21":
780-
response_body = json.loads(response.get("body").read())
781-
generated_text = response_body.get("completions")[0].get("data").get("text")
782-
elif provider == "amazon":
783-
response_body = json.loads(response.get("body").read())
784-
generated_text = response_body.get("results")[0].get("outputText")
785-
else:
786-
raise Exception("Unsupported provider: ", provider)
787-
return generated_text
788-
789-
def call_llm(parameters, prompt):
790-
modelId = parameters.pop("modelId")
791-
body = get_request_body(modelId, parameters, prompt)
792-
print("ModelId", modelId, "- Body: ", body)
793-
client = boto3.client(service_name='bedrock-runtime', region_name=AWS_REGION, endpoint_url=ENDPOINT_URL)
794-
response = client.invoke_model(body=json.dumps(body), modelId=modelId, accept='application/json', contentType='application/json')
795-
generated_text = get_generate_text(modelId, response)
781+
)
782+
generated_text = get_generate_text(response)
796783
return generated_text
797784

798785
def lambda_handler(event, context):
@@ -808,12 +795,8 @@ Resources:
808795
# Test LLMModel
809796
llmModelId = event['ResourceProperties'].get('LLMModelId', '')
810797
modelId = llmModelId
811-
parameters = {
812-
"modelId": modelId,
813-
"temperature": 0
814-
}
815798
print(f"Testing {modelId}")
816-
call_llm(parameters, prompt)
799+
call_llm(prompt, modelId)
817800
except Exception as e:
818801
status = cfnresponse.FAILED
819802
reason = f"Exception thrown testing ModelId='{modelId}'. Check that Amazon Bedrock is available in your region, and that model is activated in your Amazon Bedrock account - {e}"
@@ -848,6 +831,7 @@ Resources:
848831
Properties:
849832
TemplateURL: pca-ssm/cfn/ssm.template
850833
Parameters:
834+
StackName: !Ref 'AWS::StackName'
851835
BulkUploadBucketName:
852836
!If
853837
- ShouldCreateBulkUploadBucket
@@ -911,13 +895,15 @@ Resources:
911895
- 'None'
912896
- 'None'
913897
# WebUri: !GetAtt PCAUI.Outputs.WebUri
914-
DatabaseName: !Ref DatabaseName
898+
DatabaseName: !Ref PCADatabase
915899

916900
PythonUtilsLayer:
917901
DependsOn: SSM
918902
Type: AWS::CloudFormation::Stack
919903
Properties:
920904
TemplateURL: pca-server/cfn/lib/python-utilities.template
905+
Parameters:
906+
ParentStackName: !Ref 'AWS::StackName'
921907

922908
BedrockBoto3Layer:
923909
Type: AWS::CloudFormation::Stack
@@ -944,6 +930,8 @@ Resources:
944930
Properties:
945931
TemplateURL: pca-server/cfn/pca-server.template
946932
Parameters:
933+
DatabaseName: !Ref PCADatabase
934+
ParentStackName: !Ref 'AWS::StackName'
947935
ffmpegDownloadUrl: !Ref ffmpegDownloadUrl
948936
CallSummarization: !Ref CallSummarization
949937
SummarizationBedrockModelId: !Ref SummarizationBedrockModelId
@@ -966,6 +954,7 @@ Resources:
966954
Properties:
967955
TemplateURL: pca-ui/cfn/pca-ui.template
968956
Parameters:
957+
ParentStackName: !Ref 'AWS::StackName'
969958
AdminUsername: !Ref AdminUsername
970959
AdminEmail: !Ref AdminEmail
971960
AllowedSignUpEmailDomain: !Ref AllowedSignUpEmailDomain
@@ -1005,7 +994,7 @@ Resources:
1005994
Properties:
1006995
TemplateURL: build/pca-dashboards.yaml
1007996
Parameters:
1008-
PcaGlueCatalogDatabaseName: !Ref DatabaseName
997+
PcaGlueCatalogDatabaseName: !Ref PCADatabase
1009998
PcaOutputBucket:
1010999
!If
10111000
- ShouldCreateOutputBucket
@@ -1023,6 +1012,7 @@ Resources:
10231012
Properties:
10241013
TemplateURL: pca-samples/copy-samples.template
10251014
Parameters:
1015+
ParentStackName: !Ref 'AWS::StackName'
10261016
DependsOnPCAServer: !Ref PCAServer
10271017
DependsOnPCAUI: !If [ShouldEnableGui, !Ref PCAUI, !Ref AWS::NoValue]
10281018
DependsOnPCADashboards: !If

0 commit comments

Comments
 (0)