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:
@@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_context import LLMContext
|
|||||||
from pipecat.processors.aggregators.llm_response_universal import LLMContextAggregatorPair
|
from pipecat.processors.aggregators.llm_response_universal import LLMContextAggregatorPair
|
||||||
from pipecat.runner.types import RunnerArguments
|
from pipecat.runner.types import RunnerArguments
|
||||||
from pipecat.runner.utils import create_transport
|
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.services.llm_service import FunctionCallParams
|
||||||
from pipecat.transports.base_transport import BaseTransport, TransportParams
|
from pipecat.transports.base_transport import BaseTransport, TransportParams
|
||||||
from pipecat.transports.daily.transport import DailyParams
|
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"),
|
secret_access_key=os.getenv("AWS_SECRET_ACCESS_KEY"),
|
||||||
access_key_id=os.getenv("AWS_ACCESS_KEY_ID"),
|
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
|
region=os.getenv("AWS_REGION"), # as of 2025-05-06, us-east-1 is the only supported region
|
||||||
voice_id="tiffany", # matthew, tiffany, amy
|
settings=AWSNovaSonicLLMSettings(
|
||||||
# you could choose to pass instruction here rather than via context
|
voice="tiffany", # matthew, tiffany, amy
|
||||||
# system_instruction=system_instruction,
|
system_instruction=system_instruction,
|
||||||
|
),
|
||||||
# you could choose to pass tools here rather than via context
|
# you could choose to pass tools here rather than via context
|
||||||
# tools=tools
|
# tools=tools
|
||||||
)
|
)
|
||||||
@@ -236,7 +237,6 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
|
|
||||||
context = LLMContext(
|
context = LLMContext(
|
||||||
messages=[
|
messages=[
|
||||||
{"role": "system", "content": f"{system_instruction}"},
|
|
||||||
{"role": "user", "content": "Hello!"},
|
{"role": "user", "content": "Hello!"},
|
||||||
],
|
],
|
||||||
tools=tools,
|
tools=tools,
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ from pipecat.processors.aggregators.llm_response_universal import (
|
|||||||
)
|
)
|
||||||
from pipecat.runner.types import RunnerArguments
|
from pipecat.runner.types import RunnerArguments
|
||||||
from pipecat.runner.utils import create_transport
|
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.services.llm_service import FunctionCallParams
|
||||||
from pipecat.transports.base_transport import BaseTransport, TransportParams
|
from pipecat.transports.base_transport import BaseTransport, TransportParams
|
||||||
from pipecat.transports.daily.transport import DailyParams
|
from pipecat.transports.daily.transport import DailyParams
|
||||||
@@ -130,9 +130,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
# - ap-northeast-1
|
# - ap-northeast-1
|
||||||
region=os.getenv("AWS_REGION"),
|
region=os.getenv("AWS_REGION"),
|
||||||
session_token=os.getenv("AWS_SESSION_TOKEN"),
|
session_token=os.getenv("AWS_SESSION_TOKEN"),
|
||||||
voice_id="tiffany",
|
settings=AWSNovaSonicLLMSettings(
|
||||||
# you could choose to pass instruction here rather than via context
|
voice="tiffany",
|
||||||
# system_instruction=system_instruction
|
system_instruction=system_instruction,
|
||||||
|
),
|
||||||
# you could choose to pass tools here rather than via context
|
# you could choose to pass tools here rather than via context
|
||||||
# tools=tools
|
# tools=tools
|
||||||
)
|
)
|
||||||
@@ -147,7 +148,6 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
# Set up context and context management.
|
# Set up context and context management.
|
||||||
context = LLMContext(
|
context = LLMContext(
|
||||||
messages=[
|
messages=[
|
||||||
{"role": "system", "content": f"{system_instruction}"},
|
|
||||||
{
|
{
|
||||||
"role": "user",
|
"role": "user",
|
||||||
"content": "Tell me a fun fact!",
|
"content": "Tell me a fun fact!",
|
||||||
|
|||||||
Reference in New Issue
Block a user