In OpenAI/Azure Realtime examples, migrate to settings=OpenAIRealtimeLLMSettings(...) pattern
Move `session_properties` and `system_instruction` into the `settings` arg, matching the canonical pattern used across the codebase.
This commit is contained in:
@@ -37,7 +37,10 @@ from pipecat.services.openai.realtime.events import (
|
|||||||
SemanticTurnDetection,
|
SemanticTurnDetection,
|
||||||
SessionProperties,
|
SessionProperties,
|
||||||
)
|
)
|
||||||
from pipecat.services.openai.realtime.llm import OpenAIRealtimeLLMService
|
from pipecat.services.openai.realtime.llm import (
|
||||||
|
OpenAIRealtimeLLMService,
|
||||||
|
OpenAIRealtimeLLMSettings,
|
||||||
|
)
|
||||||
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
|
||||||
from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams
|
from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams
|
||||||
@@ -137,22 +140,10 @@ transport_params = {
|
|||||||
async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
||||||
logger.info(f"Starting bot")
|
logger.info(f"Starting bot")
|
||||||
|
|
||||||
session_properties = SessionProperties(
|
llm = OpenAIRealtimeLLMService(
|
||||||
audio=AudioConfiguration(
|
api_key=os.getenv("OPENAI_API_KEY"),
|
||||||
input=AudioInput(
|
settings=OpenAIRealtimeLLMSettings(
|
||||||
transcription=InputAudioTranscription(),
|
system_instruction="""You are a helpful and friendly AI.
|
||||||
# Set openai TurnDetection parameters. Not setting this at all will turn it
|
|
||||||
# on by default
|
|
||||||
turn_detection=SemanticTurnDetection(),
|
|
||||||
# Or set to False to disable openai turn detection and use transport VAD
|
|
||||||
# turn_detection=False,
|
|
||||||
noise_reduction=InputAudioNoiseReduction(type="near_field"),
|
|
||||||
)
|
|
||||||
),
|
|
||||||
# In this example we provide tools through the context, but you could
|
|
||||||
# alternatively provide them here.
|
|
||||||
# tools=tools,
|
|
||||||
instructions="""You are a helpful and friendly AI.
|
|
||||||
|
|
||||||
Act like a human, but remember that you aren't a human and that you can't do human
|
Act like a human, but remember that you aren't a human and that you can't do human
|
||||||
things in the real world. Your voice and personality should be warm and engaging, with a lively and
|
things in the real world. Your voice and personality should be warm and engaging, with a lively and
|
||||||
@@ -166,11 +157,23 @@ You are participating in a voice conversation. Keep your responses concise, shor
|
|||||||
unless specifically asked to elaborate on a topic.
|
unless specifically asked to elaborate on a topic.
|
||||||
|
|
||||||
Remember, your responses should be short. Just one or two sentences, usually. Respond in English.""",
|
Remember, your responses should be short. Just one or two sentences, usually. Respond in English.""",
|
||||||
)
|
session_properties=SessionProperties(
|
||||||
|
audio=AudioConfiguration(
|
||||||
llm = OpenAIRealtimeLLMService(
|
input=AudioInput(
|
||||||
api_key=os.getenv("OPENAI_API_KEY"),
|
transcription=InputAudioTranscription(),
|
||||||
session_properties=session_properties,
|
# Set openai TurnDetection parameters. Not setting this at all will turn it
|
||||||
|
# on by default
|
||||||
|
turn_detection=SemanticTurnDetection(),
|
||||||
|
# Or set to False to disable openai turn detection and use transport VAD
|
||||||
|
# turn_detection=False,
|
||||||
|
noise_reduction=InputAudioNoiseReduction(type="near_field"),
|
||||||
|
)
|
||||||
|
),
|
||||||
|
# In this example we provide tools through the context, but you could
|
||||||
|
# alternatively provide them here.
|
||||||
|
# tools=tools,
|
||||||
|
),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
# you can either register a single function for all function calls, or specific functions
|
# you can either register a single function for all function calls, or specific functions
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ from pipecat.services.openai.realtime.events import (
|
|||||||
InputAudioTranscription,
|
InputAudioTranscription,
|
||||||
SessionProperties,
|
SessionProperties,
|
||||||
)
|
)
|
||||||
|
from pipecat.services.openai.realtime.llm import OpenAIRealtimeLLMSettings
|
||||||
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
|
||||||
from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams
|
from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams
|
||||||
@@ -111,19 +112,11 @@ transport_params = {
|
|||||||
async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
||||||
logger.info(f"Starting bot")
|
logger.info(f"Starting bot")
|
||||||
|
|
||||||
session_properties = SessionProperties(
|
llm = AzureRealtimeLLMService(
|
||||||
audio=AudioConfiguration(
|
api_key=os.getenv("AZURE_REALTIME_API_KEY"),
|
||||||
input=AudioInput(
|
base_url=os.getenv("AZURE_REALTIME_BASE_URL"),
|
||||||
transcription=InputAudioTranscription(model="whisper-1"),
|
settings=OpenAIRealtimeLLMSettings(
|
||||||
# Set openai TurnDetection parameters. Not setting this at all will turn it
|
system_instruction="""You are a helpful and friendly AI.
|
||||||
# on by default
|
|
||||||
# turn_detection=TurnDetection(silence_duration_ms=1000),
|
|
||||||
# Or set to False to disable openai turn detection and use transport VAD
|
|
||||||
# turn_detection=False,
|
|
||||||
)
|
|
||||||
),
|
|
||||||
# tools=tools,
|
|
||||||
instructions="""You are a helpful and friendly AI.
|
|
||||||
|
|
||||||
Act like a human, but remember that you aren't a human and that you can't do human
|
Act like a human, but remember that you aren't a human and that you can't do human
|
||||||
things in the real world. Your voice and personality should be warm and engaging, with a lively and
|
things in the real world. Your voice and personality should be warm and engaging, with a lively and
|
||||||
@@ -141,12 +134,20 @@ You have access to the following tools:
|
|||||||
- get_restaurant_recommendation: Get a restaurant recommendation for a given location.
|
- get_restaurant_recommendation: Get a restaurant recommendation for a given location.
|
||||||
|
|
||||||
Remember, your responses should be short. Just one or two sentences, usually. Respond in English.""",
|
Remember, your responses should be short. Just one or two sentences, usually. Respond in English.""",
|
||||||
)
|
session_properties=SessionProperties(
|
||||||
|
audio=AudioConfiguration(
|
||||||
llm = AzureRealtimeLLMService(
|
input=AudioInput(
|
||||||
api_key=os.getenv("AZURE_REALTIME_API_KEY"),
|
transcription=InputAudioTranscription(model="whisper-1"),
|
||||||
base_url=os.getenv("AZURE_REALTIME_BASE_URL"),
|
# Set openai TurnDetection parameters. Not setting this at all will turn it
|
||||||
session_properties=session_properties,
|
# on by default
|
||||||
|
# turn_detection=TurnDetection(silence_duration_ms=1000),
|
||||||
|
# Or set to False to disable openai turn detection and use transport VAD
|
||||||
|
# turn_detection=False,
|
||||||
|
)
|
||||||
|
),
|
||||||
|
# tools=tools,
|
||||||
|
),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
# you can either register a single function for all function calls, or specific functions
|
# you can either register a single function for all function calls, or specific functions
|
||||||
|
|||||||
@@ -32,7 +32,10 @@ from pipecat.services.openai.realtime.events import (
|
|||||||
SemanticTurnDetection,
|
SemanticTurnDetection,
|
||||||
SessionProperties,
|
SessionProperties,
|
||||||
)
|
)
|
||||||
from pipecat.services.openai.realtime.llm import OpenAIRealtimeLLMService
|
from pipecat.services.openai.realtime.llm import (
|
||||||
|
OpenAIRealtimeLLMService,
|
||||||
|
OpenAIRealtimeLLMSettings,
|
||||||
|
)
|
||||||
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
|
||||||
from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams
|
from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams
|
||||||
@@ -113,21 +116,10 @@ transport_params = {
|
|||||||
async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
||||||
logger.info(f"Starting bot")
|
logger.info(f"Starting bot")
|
||||||
|
|
||||||
session_properties = SessionProperties(
|
llm = OpenAIRealtimeLLMService(
|
||||||
audio=AudioConfiguration(
|
api_key=os.getenv("OPENAI_API_KEY"),
|
||||||
input=AudioInput(
|
settings=OpenAIRealtimeLLMSettings(
|
||||||
transcription=InputAudioTranscription(),
|
system_instruction="""You are a helpful and friendly AI.
|
||||||
# Set openai TurnDetection parameters. Not setting this at all will turn it
|
|
||||||
# on by default
|
|
||||||
turn_detection=SemanticTurnDetection(),
|
|
||||||
# Or set to False to disable openai turn detection and use transport VAD
|
|
||||||
# turn_detection=False,
|
|
||||||
noise_reduction=InputAudioNoiseReduction(type="near_field"),
|
|
||||||
)
|
|
||||||
),
|
|
||||||
output_modalities=["text"],
|
|
||||||
# tools=tools,
|
|
||||||
instructions="""You are a helpful and friendly AI.
|
|
||||||
|
|
||||||
Act like a human, but remember that you aren't a human and that you can't do human
|
Act like a human, but remember that you aren't a human and that you can't do human
|
||||||
things in the real world. Your voice and personality should be warm and engaging, with a lively and
|
things in the real world. Your voice and personality should be warm and engaging, with a lively and
|
||||||
@@ -145,11 +137,22 @@ You have access to the following tools:
|
|||||||
- get_restaurant_recommendation: Get a restaurant recommendation for a given location.
|
- get_restaurant_recommendation: Get a restaurant recommendation for a given location.
|
||||||
|
|
||||||
Remember, your responses should be short. Just one or two sentences, usually. Respond in English.""",
|
Remember, your responses should be short. Just one or two sentences, usually. Respond in English.""",
|
||||||
)
|
session_properties=SessionProperties(
|
||||||
|
audio=AudioConfiguration(
|
||||||
llm = OpenAIRealtimeLLMService(
|
input=AudioInput(
|
||||||
api_key=os.getenv("OPENAI_API_KEY"),
|
transcription=InputAudioTranscription(),
|
||||||
session_properties=session_properties,
|
# Set openai TurnDetection parameters. Not setting this at all will turn it
|
||||||
|
# on by default
|
||||||
|
turn_detection=SemanticTurnDetection(),
|
||||||
|
# Or set to False to disable openai turn detection and use transport VAD
|
||||||
|
# turn_detection=False,
|
||||||
|
noise_reduction=InputAudioNoiseReduction(type="near_field"),
|
||||||
|
)
|
||||||
|
),
|
||||||
|
output_modalities=["text"],
|
||||||
|
# tools=tools,
|
||||||
|
),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
tts = CartesiaTTSService(
|
tts = CartesiaTTSService(
|
||||||
|
|||||||
@@ -32,7 +32,10 @@ from pipecat.services.openai.realtime.events import (
|
|||||||
SemanticTurnDetection,
|
SemanticTurnDetection,
|
||||||
SessionProperties,
|
SessionProperties,
|
||||||
)
|
)
|
||||||
from pipecat.services.openai.realtime.llm import OpenAIRealtimeLLMService
|
from pipecat.services.openai.realtime.llm import (
|
||||||
|
OpenAIRealtimeLLMService,
|
||||||
|
OpenAIRealtimeLLMSettings,
|
||||||
|
)
|
||||||
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
|
||||||
|
|
||||||
@@ -60,22 +63,10 @@ transport_params = {
|
|||||||
async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
||||||
logger.info(f"Starting bot")
|
logger.info(f"Starting bot")
|
||||||
|
|
||||||
session_properties = SessionProperties(
|
llm = OpenAIRealtimeLLMService(
|
||||||
audio=AudioConfiguration(
|
api_key=os.getenv("OPENAI_API_KEY"),
|
||||||
input=AudioInput(
|
settings=OpenAIRealtimeLLMSettings(
|
||||||
transcription=InputAudioTranscription(),
|
system_instruction="""You are a helpful and friendly AI.
|
||||||
# Set openai TurnDetection parameters. Not setting this at all will turn it
|
|
||||||
# on by default
|
|
||||||
turn_detection=SemanticTurnDetection(),
|
|
||||||
# Or set to False to disable openai turn detection and use transport VAD
|
|
||||||
# turn_detection=False,
|
|
||||||
noise_reduction=InputAudioNoiseReduction(type="near_field"),
|
|
||||||
)
|
|
||||||
),
|
|
||||||
# In this example we provide tools through the context, but you could
|
|
||||||
# alternatively provide them here.
|
|
||||||
# tools=tools,
|
|
||||||
instructions="""You are a helpful and friendly AI.
|
|
||||||
|
|
||||||
Act like a human, but remember that you aren't a human and that you can't do human
|
Act like a human, but remember that you aren't a human and that you can't do human
|
||||||
things in the real world. Your voice and personality should be warm and engaging, with a lively and
|
things in the real world. Your voice and personality should be warm and engaging, with a lively and
|
||||||
@@ -89,11 +80,23 @@ You are participating in a voice conversation. Keep your responses concise, shor
|
|||||||
unless specifically asked to elaborate on a topic.
|
unless specifically asked to elaborate on a topic.
|
||||||
|
|
||||||
Remember, your responses should be short. Just one or two sentences, usually. Respond in English.""",
|
Remember, your responses should be short. Just one or two sentences, usually. Respond in English.""",
|
||||||
)
|
session_properties=SessionProperties(
|
||||||
|
audio=AudioConfiguration(
|
||||||
llm = OpenAIRealtimeLLMService(
|
input=AudioInput(
|
||||||
api_key=os.getenv("OPENAI_API_KEY"),
|
transcription=InputAudioTranscription(),
|
||||||
session_properties=session_properties,
|
# Set openai TurnDetection parameters. Not setting this at all will turn it
|
||||||
|
# on by default
|
||||||
|
turn_detection=SemanticTurnDetection(),
|
||||||
|
# Or set to False to disable openai turn detection and use transport VAD
|
||||||
|
# turn_detection=False,
|
||||||
|
noise_reduction=InputAudioNoiseReduction(type="near_field"),
|
||||||
|
)
|
||||||
|
),
|
||||||
|
# In this example we provide tools through the context, but you could
|
||||||
|
# alternatively provide them here.
|
||||||
|
# tools=tools,
|
||||||
|
),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Create a standard OpenAI LLM context object using the normal messages format. The
|
# Create a standard OpenAI LLM context object using the normal messages format. The
|
||||||
|
|||||||
@@ -33,7 +33,10 @@ from pipecat.services.openai.realtime.events import (
|
|||||||
SessionProperties,
|
SessionProperties,
|
||||||
TurnDetection,
|
TurnDetection,
|
||||||
)
|
)
|
||||||
from pipecat.services.openai.realtime.llm import OpenAIRealtimeLLMService
|
from pipecat.services.openai.realtime.llm import (
|
||||||
|
OpenAIRealtimeLLMService,
|
||||||
|
OpenAIRealtimeLLMSettings,
|
||||||
|
)
|
||||||
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
|
||||||
from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams
|
from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams
|
||||||
@@ -173,19 +176,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
|
|
||||||
stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY"))
|
stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY"))
|
||||||
|
|
||||||
session_properties = SessionProperties(
|
llm = OpenAIRealtimeLLMService(
|
||||||
audio=AudioConfiguration(
|
api_key=os.getenv("OPENAI_API_KEY"),
|
||||||
input=AudioInput(
|
settings=OpenAIRealtimeLLMSettings(
|
||||||
transcription=InputAudioTranscription(),
|
system_instruction="""Your knowledge cutoff is 2023-10. You are a helpful and friendly AI.
|
||||||
# Set openai TurnDetection parameters. Not setting this at all will turn it
|
|
||||||
# on by default
|
|
||||||
turn_detection=TurnDetection(silence_duration_ms=1000),
|
|
||||||
# Or set to False to disable openai turn detection and use transport VAD
|
|
||||||
# turn_detection=False,
|
|
||||||
)
|
|
||||||
),
|
|
||||||
# tools=tools,
|
|
||||||
instructions="""Your knowledge cutoff is 2023-10. You are a helpful and friendly AI.
|
|
||||||
|
|
||||||
Act like a human, but remember that you aren't a human and that you can't do human
|
Act like a human, but remember that you aren't a human and that you can't do human
|
||||||
things in the real world. Your voice and personality should be warm and engaging, with a lively and
|
things in the real world. Your voice and personality should be warm and engaging, with a lively and
|
||||||
@@ -199,11 +193,20 @@ You are participating in a voice conversation. Keep your responses concise, shor
|
|||||||
unless specifically asked to elaborate on a topic.
|
unless specifically asked to elaborate on a topic.
|
||||||
|
|
||||||
Remember, your responses should be short. Just one or two sentences, usually.""",
|
Remember, your responses should be short. Just one or two sentences, usually.""",
|
||||||
)
|
session_properties=SessionProperties(
|
||||||
|
audio=AudioConfiguration(
|
||||||
llm = OpenAIRealtimeLLMService(
|
input=AudioInput(
|
||||||
api_key=os.getenv("OPENAI_API_KEY"),
|
transcription=InputAudioTranscription(),
|
||||||
session_properties=session_properties,
|
# Set openai TurnDetection parameters. Not setting this at all will turn it
|
||||||
|
# on by default
|
||||||
|
turn_detection=TurnDetection(silence_duration_ms=1000),
|
||||||
|
# Or set to False to disable openai turn detection and use transport VAD
|
||||||
|
# turn_detection=False,
|
||||||
|
)
|
||||||
|
),
|
||||||
|
# tools=tools,
|
||||||
|
),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
# you can either register a single function for all function calls, or specific functions
|
# you can either register a single function for all function calls, or specific functions
|
||||||
|
|||||||
Reference in New Issue
Block a user