### Start Client using Setup Configuration Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/skills/text-agent-to-strands-voice-agent/references/deployment-reference.md Helper script to start the client using the saved setup configuration after deployment. Assumes the configuration is saved in strands/setup_config.json. ```bash ./deployment/start_client.sh strands ``` -------------------------------- ### Install React Dependencies and Start App Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/speech-to-speech/amazon-nova-2-sonic/workshops/livekit/README.md Install the necessary Node.js dependencies for the React application and start the development server. ```bash npm install npm start ``` -------------------------------- ### Start UI Client Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/speech-to-speech/amazon-nova-2-sonic/sample-codes/websocket-dotnet/README.md Navigate to the UI directory, install dependencies, and start the development server for the web client. This command prepares and launches the user interface. ```bash cd ui-stream npm install npm run dev ``` -------------------------------- ### Setup and Client Initialization Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/multimodal-understanding/repeatable-patterns/07-function-call-with-structured-json/function_call.ipynb Installs necessary libraries, imports modules, and initializes AWS Bedrock clients. Ensure API_ENDPOINT is set to your specific endpoint. ```python !pip3 install -q aws-requests-auth from aws_requests_auth.aws_auth import AWSRequestsAuth import boto3 import datetime import json import os import requests import urllib API_ENDPOINT="" AWS_REGION="us-east-1" BEDROCK_MODEL="us.amazon.nova-pro-v1:0" BEDROCK_TOOL_MODEL="auto" # switch to "any" if you want to force the model to "only" use the tools you provide aws_session_credentials = boto3.Session().get_credentials() aws_client_bedrock = boto3.client( service_name="bedrock-runtime" ) ``` -------------------------------- ### Setup Environment and AWS Clients Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/customization/bedrock-distillation/distillation_recipes/01_citations/03_batch_inference.ipynb Installs and upgrades necessary libraries like boto3. Restarts the kernel to apply changes. Loads model IDs from previous notebooks. ```python # upgrade boto3 %pip install --upgrade pip --quiet %pip install boto3 --upgrade --quiet # restart kernel from IPython.core.display import HTML HTML("") ``` ```python # load PT model id from previous notebook %store -r provisioned_model_id %store -r custom_model_id ``` ```python import json import sys import os import time current_dir = os.getcwd() parent_dir = os.path.dirname(current_dir) skip_dir = os.path.dirname(parent_dir) sys.path.append(skip_dir) import boto3 from datetime import datetime from botocore.exceptions import ClientError from utils import create_s3_bucket # Create Bedrock client bedrock_client = boto3.client(service_name="bedrock", region_name='us-east-1') # Create runtime client for inference bedrock_runtime = boto3.client(service_name='bedrock-runtime', region_name='us-east-1') # Region and accountID session = boto3.session.Session(region_name='us-east-1') region = 'us-east-1' sts_client = session.client(service_name='sts', region_name='us-east-1') account_id = sts_client.get_caller_identity()['Account'] # Define bucket and prefixes (using the same bucket as in distillation) BUCKET_NAME = '' # Same bucket used in distillation notebook DATA_PREFIX = 'citations_distillation' # Same prefix used in distillation notebook batch_inference_prefix = f"{DATA_PREFIX}/batch_inference" # New prefix for batch inference ``` -------------------------------- ### Install Dependencies Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/customization/Nova_2.0/workshop/EndToEnd_SFT_RFT_Workshop/SFT_RFT/01_Data_prep.ipynb Installs necessary packages from a requirements file. Use this at the beginning of your environment setup. ```python !pip install -r requirements.txt --quiet ``` -------------------------------- ### Setup Python Virtual Environment and Install Dependencies Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/speech-to-speech/amazon-nova-2-sonic/workshops/livekit/README.md Creates a Python virtual environment, activates it, and installs project dependencies from 'requirements.txt'. This ensures a clean and isolated environment for the LiveKit agent. ```bash cd nova-s2s-workshop/livekit python3 -m venv .venv source .venv/bin/activate pip install --upgrade pip pip install -r requirements.txt ``` -------------------------------- ### Python CLI Client: Installation and Execution Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/skills/text-agent-to-strands-voice-agent/references/client-reference.md Provides commands for installing necessary Python packages (`pyaudio`, `websockets`) and examples for running the client against a local server or a deployed AgentCore Runtime using a presigned URL. ```bash pip install pyaudio websockets # Local server python client.py --ws-url ws://localhost:8080/ws # Deployed via AgentCore Runtime (presigned URL) python client.py --runtime-arn arn:aws:bedrock-agentcore:us-east-1:123456:runtime/RTID ``` -------------------------------- ### Install AgentCore Starter Toolkit Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/skills/text-agent-to-strands-voice-agent/references/deployment-reference.md Installs the necessary toolkit for deploying the AgentCore voice agent. Ensure Python 3 and AWS CLI are installed. ```bash pip install bedrock-agentcore-starter-toolkit ``` -------------------------------- ### Install PyAudio on Windows (using pipwin) Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/speech-to-speech/amazon-nova-2-sonic/repeatable-patterns/token-usage-logger/README.md Install PyAudio on Windows by first installing pipwin and then the PyAudio binary. ```bash # Install PyAudio binary directly using pip pip install pipwin pipwin install pyaudio ``` -------------------------------- ### Run Automated Setup Script Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/nova-act/tutorials/path-to-production/00-setup/0_setup_environment.md Execute the provided shell script to automate the creation of a virtual environment, its activation, and the installation of all required packages from requirements.txt. Ensure you run this from the 'path-to-production' directory. ```bash chmod +x 00-setup/0_setup_environment.sh && ./00-setup/0_setup_environment.sh ``` -------------------------------- ### Install gemini-to-nova-migration Plugin Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/skills/gemini-to-nova-migration/README.md Add the marketplace and install the plugin to begin migrating Gemini code. After installation, invoke the skill using the provided command. ```bash /plugin marketplace add https://github.com/aws-samples/amazon-nova-samples /plugin install gemini-to-nova-migration@aws-samples-amazon-nova-samples ``` -------------------------------- ### Run the HyperPod CLI Installer Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/customization/nova-forge-hyperpod-cli-installation/INSTALL_USAGE.md Execute the installation script for the HyperPod CLI. You will be prompted for an installation directory. ```bash bash install_hp_cli.sh ``` -------------------------------- ### Clone Repository and Navigate Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/speech-to-speech/amazon-nova-2-sonic/repeatable-patterns/bedrock-knowledge-base/README.md Clone the repository and navigate into the project directory to begin setup. ```bash git clone cd ``` -------------------------------- ### Set up Environment File Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/customization/bedrock-distillation/distillation_recipes/02_function_calling/01_prepare_data.ipynb Copies an example .env file to the project root and prompts the user to fill in necessary AWS credentials. Uncomment to use. ```python # set up environment file # %cp $(python -c "import bfcl_eval; print(bfcl_eval.__path__[0])")/.env.example $BFCL_PROJECT_ROOT/.env # Fill in necessary values in `.env` ``` -------------------------------- ### Install Required Packages Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/multimodal-understanding/repeatable-patterns/28-email-assistant-with-strands-agents/email_assistant_strands_agents.ipynb Installs necessary packages from a requirements file. Use this at the beginning of your project setup. ```python !pip install -r requirements.txt -q --no-cache-dir ``` -------------------------------- ### Video Timestamps - Event with Example Format Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/skills/nova-prompter/plugins/nova-prompting/skills/nova2-prompt/SKILL.md Asks for the start and end timestamps of an event, providing an example format. ```text When does "{event_description}" in the video? Specify the start and end timestamps, e.g. [[9, 14]] ``` -------------------------------- ### Voice Agent Setup and Run Instructions Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/skills/text-agent-to-strands-voice-agent/SKILL.md Provides instructions for setting up the voice agent environment, including system dependencies, Python virtual environment, and running the server. Also details how to connect the client to the WebSocket server. ```markdown # [Agent Name] Voice Agent Real-time voice agent using Strands BidiAgent with Amazon Nova Sonic. ## Setup ### System Dependencies macOS: ```bash brew install portaudio ``` Ubuntu/Debian: ```bash sudo apt-get install -y portaudio19-dev gcc g++ make ``` ### Python Environment ```bash python3 -m venv .venv source .venv/bin/activate pip install -r requirements.txt ``` ### Environment Variables ```bash # Set any required tool/service ARNs or API keys export AWS_DEFAULT_REGION=us-east-1 ``` ### Run ```bash source .venv/bin/activate python server.py ``` The WebSocket server starts on port 8080 by default. To use a different port: ```bash python server.py --port 9000 # or PORT=9000 python server.py ``` ### Connect the Client Open a second terminal: ```bash source .venv/bin/activate python client.py --ws-url ws://localhost:8080/ws ``` This opens a browser with mic/speaker controls. If you changed the server port, update the URL accordingly: ```bash python client.py --ws-url ws://localhost:9000/ws ``` ``` -------------------------------- ### Clone Repository and Navigate Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/speech-to-speech/amazon-nova-2-sonic/workshops/livekit/README.md Clone the Amazon Nova Samples repository and set up the workshop directory. This command is for initial setup and assumes you haven't cloned the repository before. ```bash git clone https://github.com/aws-samples/amazon-nova-samples mv amazon-nova-samples/speech-to-speech/workshops nova-s2s-workshop rm -rf amazon-nova-samples cd nova-s2s-workshop/livekit ``` -------------------------------- ### Install Required Libraries Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/multimodal-understanding/repeatable-patterns/14-document-longcontext-idp/document_longcontext_idp.ipynb Installs necessary AWS SDK and request libraries. Use this at the beginning of your environment setup. ```python %pip install "boto3>=1.28.57" "awscli>=1.29.57" "botocore>=1.31.57" "requests>=2.32.3" --quiet ``` -------------------------------- ### Install Hugging Face Hub Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/multimodal-understanding/repeatable-patterns/02-key-info-extraction-to-sql/key_info_extraction_to_sql.ipynb Installs the Hugging Face Hub library, which is required for downloading datasets. This is a one-time setup. ```python ## TO DO: uncomment this if never run this before #! pip install huggingface_hub --quiet ``` -------------------------------- ### Example RAG Question Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/speech-to-speech/amazon-nova-2-sonic/workshops/README.md An example of a question that can be asked when using the RAG integration with Amazon Nova User Guide data. ```text What is Amazon Nova Sonic? ``` -------------------------------- ### Start Sample Application Server Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/nova-act/usecases/adaptive-ui-testing-with-nova-act/README.md Change to the sample-app directory and start a Python HTTP server on port 8000. This application should remain running while you conduct the demo. ```bash cd sample-app && python3 -m http.server 8000 ``` -------------------------------- ### Install Required Libraries Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/multimodal-understanding/repeatable-patterns/08-lite-as-subagent-to-pro/lite_as_subagent_to_pro.ipynb Installs necessary Python packages for the notebook, including IPython, PyMuPDF, and matplotlib. Use this at the beginning of your environment setup. ```python %pip install IPython PyMuPDF matplotlib --quiet ``` -------------------------------- ### Nova 1 Few-Shot Examples: System Prompt Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/skills/nova-prompter/plugins/nova-prompting/skills/nova1-prompt/SKILL.md For long or complex examples, place them within the system prompt using labeled blocks like `` to guide the model's response. ```text Below are a few examples of well-formatted {artifact} to guide your response. {full example 1} {full example 2} ``` -------------------------------- ### Install Dependencies and Verify Tooling Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/speech-to-speech/amazon-nova-2-sonic/sample-codes/agentcore/README.md Set up a Python virtual environment, install the required deployment dependencies, and verify that the `agentcore` and `deploy.py` tools are accessible. ```bash # Create and activate virtual environment python3 -m venv venv source venv/bin/activate # Install deployment tooling pip install -r deployment/requirements.txt # Verify agentcore --help python deployment/deploy.py --help ``` -------------------------------- ### Install Dependencies Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/nova-act/usecases/price_comparison/README.md Navigate to the project directory, create and activate a virtual environment, and then install the required Python dependencies from the requirements.txt file. ```bash # Navigate to the project directory cd nova-act/usecases/price_comparison # Create and activate virtual environment python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate # Install dependencies pip install -r requirements.txt ``` -------------------------------- ### Install Required Python Packages Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/multimodal-embeddings/repeatable-patterns/multilingual-search/multilingual-utterance-search.ipynb Installs essential Python libraries for AWS interaction, data manipulation, and similarity calculations. Use this at the beginning of your environment setup. ```python # Install required packages !pip install boto3 pandas numpy scikit-learn matplotlib seaborn tqdm langdetect ``` -------------------------------- ### Copy Example Test Case IDs Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/customization/bedrock-distillation/distillation_recipes/02_function_calling/01_prepare_data.ipynb Copies an example JSON file for test case IDs to the project root. This is a setup step for data preparation. ```shell %cp $(python -c "import bfcl_eval, pathlib; print(pathlib.Path(bfcl_eval.__path__[0]) / 'test_case_ids_to_generate.json.example')") $BFCL_PROJECT_ROOT/test_case_ids_to_generate.json ``` -------------------------------- ### Start UI Development Server Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/speech-to-speech/amazon-nova-2-sonic/sample-codes/websocket-java/README.md Start the UI development server to view the application in your browser. ```bash cd ui-stream npm run dev ``` -------------------------------- ### Clone Repository Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/speech-to-speech/amazon-nova-2-sonic/sample-codes/websocket-dotnet/README.md Clone the repository to get the .NET WebSocket example code. ```bash git clone cd amazon-nova-samples/speech-to-speech/sample-codes/websocket-dotnet ``` -------------------------------- ### Running the AgentCore Gateway Tutorial Script Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/nova-act/tutorials/path-to-production/02-tool-use/2_agentcore_gateway.md Provides the command to navigate to the tutorial directory and execute the Python script for setting up and running the AgentCore Gateway and workflows. ```bash cd tutorials/path-to-production/03-tool-use python 2_agentcore_gateway.py ``` -------------------------------- ### Clone Repository and Install Dependencies Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/nova-act/usecases/adaptive-ui-testing-with-nova-act/README.md Clone the adaptive-ui-testing-with-nova-act repository and run the setup script to install Playwright, Chromium, a Python virtual environment with the Nova Act SDK, and all other dependencies. ```bash git clone https://github.com/aws-samples/adaptive-ui-testing-with-nova-act cd adaptive-ui-testing-with-nova-act ./setup.sh ``` -------------------------------- ### Clone Repository and Install Dependencies Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/nova-act/usecases/qa-testing/tests/README.md Clone the repository, navigate to the tests directory, create and activate a virtual environment, and install project dependencies. ```bash git clone cd tests python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install . ``` -------------------------------- ### Start Websocket Server for Strands Agent Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/speech-to-speech/amazon-nova-2-sonic/workshops/README.md Starts the Python websocket server with the '--agent strands' flag, enabling the Strands Agent integration. Ensure uv is installed for managing Python dependencies. ```python python server.py --agent strands ``` -------------------------------- ### Setup Environment and Imports Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/customization/bedrock-distillation/distillation_recipes/01_citations/04_evaluate.ipynb Imports necessary libraries and sets up the environment by adding a parent directory to the system path for utility functions. ```python import boto3 import json import os import sys from datetime import datetime import re print(boto3.__version__) current_dir = os.getcwd() parent_dir = os.path.dirname(current_dir) skip_dir = os.path.dirname(parent_dir) sys.path.append(skip_dir) from utils import read_jsonl_to_dataframe, upload_training_data_to_s3 ``` -------------------------------- ### Set Up Virtual Environment Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/nova-act/usecases/adaptive-ui-testing-with-nova-act/README.md Commands to remove an existing virtual environment, create a new one, and install dependencies. ```bash cd nova-act-tests rm -rf venv python3 -m venv venv source venv/bin/activate pip install -r requirements.txt ``` -------------------------------- ### Python CLI Client: Audio Capture and Playback Setup Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/skills/text-agent-to-strands-voice-agent/references/client-reference.md Initializes PyAudio for microphone input and speaker output, setting up audio streams for real-time capture and playback. Requires `pyaudio` library. ```python pa = pyaudio.PyAudio() mic = pa.open(format=pyaudio.paInt16, channels=CHANNELS, rate=RATE, input=True, frames_per_buffer=CHUNK) spk = pa.open(format=pyaudio.paInt16, channels=CHANNELS, rate=RATE, output=True, frames_per_buffer=CHUNK) ``` -------------------------------- ### Example Prompts for Gemini to Nova Migration Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/skills/gemini-to-nova-migration/README.md Use these example prompts to guide the migration of your Gemini code to Amazon Nova 2 Lite, covering standard code conversion, function-calling applications, and multimodal prompts. ```plaintext Migrate this Gemini code to Amazon Nova 2 Lite: ``` ```plaintext I have a Gemini 2.5 Flash function-calling app with thinking enabled. Convert it to Nova 2 Lite. ``` ```plaintext Rewrite this Gemini multimodal prompt (image input) for Nova 2 Lite. ``` -------------------------------- ### Run Setup Script Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/nova-act/tutorials/path-to-production/00-setup/1_setup_aws_credentials.md Command to navigate to the setup directory and execute the Python script for configuring AWS credentials. ```bash cd /path/to/nova-act/tutorials/path-to-production/00-setup python setup_aws_credentials.py ``` -------------------------------- ### Required Python Packages Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/speech-to-speech/amazon-nova-2-sonic/repeatable-patterns/session-continuation/console-python/README.md List of Python packages required for the session continuation example. Ensure these are installed in your virtual environment. ```bash pyaudio>=0.2.13 rx>=3.2.0 smithy-aws-core>=0.0.1 pytz aws_sdk_bedrock_runtime>=0.1.0,<0.2.0 ``` -------------------------------- ### Navigate to Project Directory Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/multimodal-embeddings/getting-started/README.md Navigate to the root directory of the project. This is a prerequisite for subsequent setup steps. ```bash cd path/to/amazon-nova-embeddings-beta ``` -------------------------------- ### Run Streamlit Application Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/multimodal-understanding/sample-apps/01-multimodal-with-helper-libraries/README.md Execute the Streamlit application after installing all requirements. This command starts the interactive web interface for the multi-modal understanding demo. ```bash streamlit run mm_understanding.py ``` -------------------------------- ### Start Application Server Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/speech-to-speech/amazon-nova-2-sonic/repeatable-patterns/bedrock-knowledge-base/README.md Start the Node.js server to run the application. ```bash npm start ``` -------------------------------- ### Top-Down Approach Template Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/skills/nova-prompter/powers/nova2-prompt/POWER.md Employ this template for complex problems requiring a top-down breakdown. It guides the model to start with the big picture and progressively detail subproblems. ```plaintext {User query}. Start with the big picture and break it down into progressively smaller, more detailed subproblems or steps. ``` -------------------------------- ### Initialize AWS Session and Clients Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/multimodal-understanding/repeatable-patterns/26-nova-citations/evaluate_with_create_evaluation_job.ipynb Sets up the Boto3 session, SageMaker session, and Bedrock client. Ensure you have the correct AWS credentials and permissions configured. ```python session = boto3.Session() sagemaker_session = sagemaker.Session() bedrock_client = session.client('bedrock') ``` -------------------------------- ### Video Timestamps - Event Localization (Seconds, Explicit Format) Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/skills/nova-prompter/plugins/nova-prompting/skills/nova2-prompt/SKILL.md Localizes an event in seconds with an explicit example format for start and end times, supporting multiple occurrences. ```text Please localize the moment that the event "{event_description}" happens in the video. Answer with the starting and ending time of the event in seconds. e.g. [[72, 82]]. If the event happen multiple times, list all of them. e.g. [[40, 50], [72, 82]] ``` -------------------------------- ### Setup API Keys and Environment Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/multimodal-understanding/repeatable-patterns/27-multi-agent-orchastration-with-strands/multi_agent_strands.ipynb Imports and initializes AWS SDK clients and Strands components. Configure AWS region and Bedrock model for LLM interactions. ```python import os import sys import boto3 import sagemaker import json import requests import time import datetime import uuid from typing import List, Dict, Any, Optional import matplotlib.pyplot as plt import networkx as nx from strands import Agent, tool from strands.multiagent import GraphBuilder from strands.models import BedrockModel from strands_tools import file_read, file_write, editor, current_time from IPython.display import display, Image import logging import re import glob sts_client = boto3.client('sts') account_id = sts_client.get_caller_identity()["Account"] session = sagemaker.Session() aws_region = boto3.session.Session().region_name bedrock_model = BedrockModel( model_id="us.amazon.nova-lite-v1:0", region_name=aws_region ) # Function to extract filename from response def clean_extract_filename(response_string): if not isinstance(response_string, str): response_string = str(response_string) pattern = r'\s*(.*?)\s*' matches = re.findall(pattern, response_string) if matches: # Clean the filename by removing any newlines or extra whitespace return matches[-1].strip() return None def display_image(image_path): import matplotlib.pyplot as plt from PIL import Image img = Image.open(image_path) plt.imshow(img) plt.axis('off') plt.show() def extract_filename(response_string): import re # Convert to string if not already a string if not isinstance(response_string, str): response_string = str(response_string) pattern = r'\s*(.*?)\s*' matches = re.findall(pattern, response_string) return matches[-1] if matches else None logging.getLogger('botocore.credentials').setLevel(logging.ERROR) logging.getLogger('botocore').setLevel(logging.ERROR) logging.getLogger('boto3').setLevel(logging.ERROR) ``` -------------------------------- ### Create and Configure .env File Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/nova-act/usecases/qa-testing/tests/README.md Copy the sample environment file and update it with your CloudFront Distribution URL and Nova Act API Key. ```bash cp .env.sample .env ``` -------------------------------- ### Get BDA Audio Task Invocation ARN Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/multimodal-understanding/repeatable-patterns/16-multimodal-agentic-workflow/audio-video-rag/01_data_prep_using_bda.ipynb Retrieves the invocation ARN for a started BDA audio task. This ARN is used to monitor the task's progress. ```python invocation_audio_arn = response_aud.get("invocationArn") print("BDA audio task started:", invocation_audio_arn) ``` -------------------------------- ### Using System Prompts with Converse API Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/multimodal-understanding/workshop/1-getting-started-with-nova-2/1-getting-started-with-api.ipynb Pass system prompts via the `system` parameter to guide the model's behavior. This example shows how to act as a telecom marketer. ```python response = client.converse( modelId=MODEL_ID, system=[ { "text": "Act as a telecom industry marketer for AnyCompany Telecom. When the user provides you with a topic, write a LinkedIn Launch Post about that topic." } ], messages=[ { "role": "user", "content": [{"text": "Meet our AI-powered customer support assistant"}] } ], inferenceConfig={"maxTokens": 1024, "temperature": 0.7} ) output_text = response["output"]["message"]["content"][0]["text"] display(Markdown(output_text)) ``` -------------------------------- ### Custom Retailer Sources Example Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/nova-act/usecases/price_comparison/README.md This example demonstrates how to specify a custom set of retailers and their corresponding website URLs for price comparison. ```bash python main.py --sources '[("Walmart", "https://www.walmart.com"), ("Newegg", "https://www.newegg.com")]' ``` -------------------------------- ### Set up Python Virtual Environment Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/multimodal-understanding/sample-apps/01-multimodal-with-helper-libraries/README.md Create and activate a Python virtual environment for the project. Install project dependencies using pip. ```bash python3 -m venv env source env/bin/activate pip install -r requirements.txt ``` -------------------------------- ### Create a Simple Langchain Agent Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/multimodal-understanding/getting-started/06_langchain_integration.ipynb This code defines a basic Langchain agent that can invoke a simple function to get weather information. It's a straightforward example for understanding agent invocation with a single tool. ```python from langchain.agents import create_agent import json def get_weather(city: str) -> str: """Get weather for a given city.""" return f"Test Response: It's always sunny in {city}!" MODEL_ID = "amazon.nova-2-lite-v1:0" agent = create_agent( model=MODEL_ID, tools=[get_weather], system_prompt="You are a helpful assistant", ) # Run the agent response = agent.invoke( {"messages": [{"role": "user", "content": "what is the weather in sf"}]} ) response['messages'][3].content ``` -------------------------------- ### Few-Shot Prompting for Classification Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/multimodal-understanding/workshop/1-getting-started-with-nova-2/2-general-best-practices.ipynb Use few-shot prompting to guide the model's reasoning and output format for specific tasks like classification. Provide clear examples of input, desired output, and reasoning. ```python few_shot_prompt = "" ##Task## Classify the following customer support ticket into one of these categories: - Billing - Technical - Account - General Inquiry ##Examples## Example 1: Ticket: "My internet speed is much slower than what I'm paying for." Category: Technical Reason: Customer reports a service performance issue related to network speed. --- Example 2: Ticket: "I want to change the primary name on my account to my spouse." Category: Account Reason: Customer requests a modification to account holder information. --- Example 3: Ticket: "Can you explain what the 'network access fee' on my bill means?" Category: Billing Reason: Customer is asking about a specific charge on their invoice. DO NOT mention examples in your response. ##Input## Ticket: "I was charged twice for my November bill and I need a refund for the duplicate payment." ##Output Requirements## You MUST respond with only the category and a one-sentence explanation in the following format: Format: [Category]: [One-sentence explanation] DO NOT include any additional text, commentary, or formatting beyond what is specified above. " response = client.converse( modelId=MODEL_ID, messages=[{ "role": "user", "content": [{"text": few_shot_prompt}] }], inferenceConfig={"maxTokens": 128, "temperature": 0} ) output_text = response["output"]["message"]["content"][0]["text"] display(Markdown(output_text)) ``` -------------------------------- ### Full Example of Launcher Execution Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/customization/forge-assets/launcher/LAUNCHER_README.md A comprehensive example demonstrating the execution of the hyperpod_launcher.py script with various parameters, including data sources, output locations, MLflow integration, container image, instance type, and namespace. ```bash python3 hyperpod_launcher.py \ --recipe micro_pt_recipe.yaml \ --name dewanup-cpt-nodm-ce-chkpt \ --data s3://618100645563-nova-customization-beta/dewanup/data/cpt/train.jsonl \ --val s3://618100645563-nova-customization-beta/dewanup/data/cpt/val.jsonl \ --output s3://618100645563-nova-customization-beta/dewanup/output/ \ --mlflow arn:aws:sagemaker:us-east-1:618100645563:mlflow-app/app-QYBQZINLZDLY \ --container 708977205387.dkr.ecr.us-east-1.amazonaws.com/nova-fine-tune-repo:SM-HP-CPT-V2-BETA-latest \ --instance-type ml.p5.48xlarge \ --namespace kubeflow ``` -------------------------------- ### Install AWS CLI V2 Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/customization/hyperpod-rig-cluster-setup/Hyperpod_Nova_Cluster_and_Dependencies_setup.ipynb Installs AWS CLI V2, removing any existing v1 installations. The installation process downloads the zip archive, extracts it, and installs the CLI to /usr/local/bin and /usr/local/aws-cli. ```bash set -euo pipefail # Remove v1 sudo rm -rf /opt/conda/bin/aws rm -rf /home/sagemaker-user/nova_sdk/bin/aws curl -fsSL "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o /tmp/awscliv2.zip unzip -q /tmp/awscliv2.zip -d /tmp sudo /tmp/aws/install --bin-dir /usr/local/bin --install-dir /usr/local/aws-cli --update rm -rf /tmp/awscliv2.zip /tmp/aws ``` -------------------------------- ### Clone Repository and Setup Workshop Directory Source: https://github.com/aws-samples/amazon-nova-samples/blob/main/speech-to-speech/amazon-nova-2-sonic/workshops/agent-core/README.md Clone the Amazon Nova Samples repository and set up the workshop directory. This is a prerequisite for deploying the agents. ```bash git clone https://github.com/aws-samples/amazon-nova-samples mv amazon-nova-samples/speech-to-speech/workshops nova-s2s-workshop rm -rf amazon-nova-samples ```