In AWS Nova Sonic examples, migrate to newer pattern of passing in settings with voice and system_instruction, in favor of passing in voice_id as a direct init arg and the system instruction as the first message in the context

This commit is contained in:
Paul Kompfner
2026-03-05 16:09:24 -05:00
parent a1641f3762
commit 5b270fec8e
2 changed files with 10 additions and 10 deletions

View File

@@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_context import LLMContext
from pipecat.processors.aggregators.llm_response_universal import LLMContextAggregatorPair
from pipecat.runner.types import RunnerArguments
from pipecat.runner.utils import create_transport
from pipecat.services.aws.nova_sonic.llm import AWSNovaSonicLLMService
from pipecat.services.aws.nova_sonic.llm import AWSNovaSonicLLMService, AWSNovaSonicLLMSettings
from pipecat.services.llm_service import FunctionCallParams
from pipecat.transports.base_transport import BaseTransport, TransportParams
from pipecat.transports.daily.transport import DailyParams
@@ -222,9 +222,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
secret_access_key=os.getenv("AWS_SECRET_ACCESS_KEY"),
access_key_id=os.getenv("AWS_ACCESS_KEY_ID"),
region=os.getenv("AWS_REGION"), # as of 2025-05-06, us-east-1 is the only supported region
voice_id="tiffany", # matthew, tiffany, amy
# you could choose to pass instruction here rather than via context
# system_instruction=system_instruction,
settings=AWSNovaSonicLLMSettings(
voice="tiffany", # matthew, tiffany, amy
system_instruction=system_instruction,
),
# you could choose to pass tools here rather than via context
# tools=tools
)
@@ -236,7 +237,6 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
context = LLMContext(
messages=[
{"role": "system", "content": f"{system_instruction}"},
{"role": "user", "content": "Hello!"},
],
tools=tools,

View File

@@ -28,7 +28,7 @@ from pipecat.processors.aggregators.llm_response_universal import (
)
from pipecat.runner.types import RunnerArguments
from pipecat.runner.utils import create_transport
from pipecat.services.aws.nova_sonic.llm import AWSNovaSonicLLMService
from pipecat.services.aws.nova_sonic.llm import AWSNovaSonicLLMService, AWSNovaSonicLLMSettings
from pipecat.services.llm_service import FunctionCallParams
from pipecat.transports.base_transport import BaseTransport, TransportParams
from pipecat.transports.daily.transport import DailyParams
@@ -130,9 +130,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
# - ap-northeast-1
region=os.getenv("AWS_REGION"),
session_token=os.getenv("AWS_SESSION_TOKEN"),
voice_id="tiffany",
# you could choose to pass instruction here rather than via context
# system_instruction=system_instruction
settings=AWSNovaSonicLLMSettings(
voice="tiffany",
system_instruction=system_instruction,
),
# you could choose to pass tools here rather than via context
# tools=tools
)
@@ -147,7 +148,6 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
# Set up context and context management.
context = LLMContext(
messages=[
{"role": "system", "content": f"{system_instruction}"},
{
"role": "user",
"content": "Tell me a fun fact!",