PABPAT/TCI_Shield
0
1import boto32import json3 4# Creating a client to connect with AWS.5client = boto3.client(6 service_name="bedrock-runtime",7 region_name="us-east-1",8)9 10# Hardcoded message to AWS Nova. Later we will change this to dynamic.11# Using Voice Input, Web Chat UI, Agent orchestrator passing context.12message = ("I am a UK-based business that sells goods to buyers in Europe on Net 60 payment terms. "13 "My annual turnover is £5 million. Can you explain what trade credit insurance is and "14 "why I might need it?")15 16# Call Nova Lite - invoke model and capture response.17response = client.invoke_model(18 modelId = "amazon.nova-lite-v1:0",19 body = json.dumps({20 "messages": [21 {22 "role" : "user",23 "content" :[{"text" : message}]24 }25 ],26 "inferenceConfig" : {27 "maxTokens" : 500,28 "temperature" : 0.729 }30 }),31)32 33# Parse the response.34result = json.loads(response['body'].read())35 36# Extract Nova's reply from the response structure.37reply = result["output"]["message"]["content"][0]["text"]38 39# Print the result40print("Nova Lite says:")41print("-" * 50)42print(reply)43 44# Print token usage to track the costs45usage = result["usage"]46print(f"\nTokens used - Input: {usage['inputTokens']} | Output: {usage['outputTokens']}")47 48 