Improved logging + error handling + pipecat bot name usage
This commit is contained in:
@@ -36,7 +36,7 @@ logger.add(sys.stderr, level="DEBUG")
|
|||||||
async def main():
|
async def main():
|
||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession() as session:
|
||||||
transport = LemonSliceTransport(
|
transport = LemonSliceTransport(
|
||||||
bot_name="Pipecat bot",
|
bot_name="Pipecat",
|
||||||
api_key=os.getenv("LEMONSLICE_API_KEY"),
|
api_key=os.getenv("LEMONSLICE_API_KEY"),
|
||||||
agent_id=os.getenv("LEMONSLICE_AGENT_ID"),
|
agent_id=os.getenv("LEMONSLICE_AGENT_ID"),
|
||||||
session=session,
|
session=session,
|
||||||
@@ -93,7 +93,7 @@ async def main():
|
|||||||
|
|
||||||
@transport.event_handler("on_client_connected")
|
@transport.event_handler("on_client_connected")
|
||||||
async def on_client_connected(transport, participant):
|
async def on_client_connected(transport, participant):
|
||||||
logger.info(f"Client connected")
|
logger.info("Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
messages.append(
|
messages.append(
|
||||||
{
|
{
|
||||||
@@ -105,7 +105,7 @@ async def main():
|
|||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
async def on_client_disconnected(transport, participant):
|
async def on_client_disconnected(transport, participant):
|
||||||
logger.info(f"Client disconnected")
|
logger.info("Client disconnected")
|
||||||
await task.cancel()
|
await task.cancel()
|
||||||
|
|
||||||
runner = PipelineRunner()
|
runner = PipelineRunner()
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ koala = [ "pvkoala~=2.0.3" ]
|
|||||||
kokoro = [ "kokoro-onnx>=0.5.0,<1", "requests>=2.32.5,<3" ]
|
kokoro = [ "kokoro-onnx>=0.5.0,<1", "requests>=2.32.5,<3" ]
|
||||||
krisp = [ "pipecat-ai-krisp~=0.4.0" ]
|
krisp = [ "pipecat-ai-krisp~=0.4.0" ]
|
||||||
langchain = [ "langchain~=0.3.20", "langchain-community~=0.3.20", "langchain-openai~=0.3.9" ]
|
langchain = [ "langchain~=0.3.20", "langchain-community~=0.3.20", "langchain-openai~=0.3.9" ]
|
||||||
lemonslice = []
|
lemonslice = [ "pipecat-ai[daily]" ]
|
||||||
livekit = [ "livekit~=1.0.13", "livekit-api~=1.0.5", "tenacity>=8.2.3,<10.0.0", "pyjwt>=2.10.1" ]
|
livekit = [ "livekit~=1.0.13", "livekit-api~=1.0.5", "tenacity>=8.2.3,<10.0.0", "pyjwt>=2.10.1" ]
|
||||||
lmnt = [ "pipecat-ai[websockets-base]" ]
|
lmnt = [ "pipecat-ai[websockets-base]" ]
|
||||||
local = [ "pyaudio~=0.2.14" ]
|
local = [ "pyaudio~=0.2.14" ]
|
||||||
|
|||||||
@@ -199,11 +199,13 @@ class LemonSliceTransportClient:
|
|||||||
await self._api.end_session(self._session_id, self._control_url)
|
await self._api.end_session(self._session_id, self._control_url)
|
||||||
self._session_id = None
|
self._session_id = None
|
||||||
self._control_url = None
|
self._control_url = None
|
||||||
|
raise
|
||||||
|
|
||||||
async def cleanup(self):
|
async def cleanup(self):
|
||||||
"""Cleanup client resources."""
|
"""Cleanup client resources."""
|
||||||
try:
|
try:
|
||||||
await self._daily_transport_client.cleanup()
|
if self._daily_transport_client:
|
||||||
|
await self._daily_transport_client.cleanup()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Exception during cleanup: {e}")
|
logger.error(f"Exception during cleanup: {e}")
|
||||||
|
|
||||||
@@ -316,7 +318,7 @@ class LemonSliceTransportClient:
|
|||||||
|
|
||||||
async def send_interrupt_message(self) -> None:
|
async def send_interrupt_message(self) -> None:
|
||||||
"""Send an interrupt message to the LemonSlice session."""
|
"""Send an interrupt message to the LemonSlice session."""
|
||||||
logger.info("Sending interrupt message")
|
logger.debug("Sending interrupt message")
|
||||||
transport_frame = OutputTransportMessageUrgentFrame(
|
transport_frame = OutputTransportMessageUrgentFrame(
|
||||||
message={
|
message={
|
||||||
"event": "interrupt",
|
"event": "interrupt",
|
||||||
@@ -338,7 +340,7 @@ class LemonSliceTransportClient:
|
|||||||
|
|
||||||
async def send_response_finished_message(self) -> None:
|
async def send_response_finished_message(self) -> None:
|
||||||
"""Send a response_finished message to the LemonSlice session."""
|
"""Send a response_finished message to the LemonSlice session."""
|
||||||
logger.info("Sending response_finished message")
|
logger.debug("Sending response_finished message")
|
||||||
transport_frame = OutputTransportMessageUrgentFrame(
|
transport_frame = OutputTransportMessageUrgentFrame(
|
||||||
message={
|
message={
|
||||||
"event": "response_finished",
|
"event": "response_finished",
|
||||||
@@ -682,7 +684,7 @@ class LemonSliceTransport(BaseTransport):
|
|||||||
output_name: Optional[str] = None,
|
output_name: Optional[str] = None,
|
||||||
daily_room_url: Optional[str] = None,
|
daily_room_url: Optional[str] = None,
|
||||||
daily_token: Optional[str] = None,
|
daily_token: Optional[str] = None,
|
||||||
lemonslice_properties: dict = {},
|
lemonslice_properties: Optional[dict] = None,
|
||||||
):
|
):
|
||||||
"""Initialize the LemonSlice transport.
|
"""Initialize the LemonSlice transport.
|
||||||
|
|
||||||
@@ -709,7 +711,7 @@ class LemonSliceTransport(BaseTransport):
|
|||||||
on_participant_left=self._on_participant_left,
|
on_participant_left=self._on_participant_left,
|
||||||
)
|
)
|
||||||
self._client = LemonSliceTransportClient(
|
self._client = LemonSliceTransportClient(
|
||||||
bot_name="Pipecat",
|
bot_name=bot_name,
|
||||||
callbacks=callbacks,
|
callbacks=callbacks,
|
||||||
api_key=api_key,
|
api_key=api_key,
|
||||||
agent_image_url=agent_image_url,
|
agent_image_url=agent_image_url,
|
||||||
|
|||||||
Reference in New Issue
Block a user