Improved logging + error handling + pipecat bot name usage

This commit is contained in:
Joshua Primas
2026-02-20 15:59:52 -08:00
parent 35aba4128c
commit 0b4568843b
3 changed files with 11 additions and 9 deletions

View File

@@ -36,7 +36,7 @@ logger.add(sys.stderr, level="DEBUG")
async def main():
async with aiohttp.ClientSession() as session:
transport = LemonSliceTransport(
bot_name="Pipecat bot",
bot_name="Pipecat",
api_key=os.getenv("LEMONSLICE_API_KEY"),
agent_id=os.getenv("LEMONSLICE_AGENT_ID"),
session=session,
@@ -93,7 +93,7 @@ async def main():
@transport.event_handler("on_client_connected")
async def on_client_connected(transport, participant):
logger.info(f"Client connected")
logger.info("Client connected")
# Kick off the conversation.
messages.append(
{
@@ -105,7 +105,7 @@ async def main():
@transport.event_handler("on_client_disconnected")
async def on_client_disconnected(transport, participant):
logger.info(f"Client disconnected")
logger.info("Client disconnected")
await task.cancel()
runner = PipelineRunner()

View File

@@ -80,7 +80,7 @@ koala = [ "pvkoala~=2.0.3" ]
kokoro = [ "kokoro-onnx>=0.5.0,<1", "requests>=2.32.5,<3" ]
krisp = [ "pipecat-ai-krisp~=0.4.0" ]
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" ]
lmnt = [ "pipecat-ai[websockets-base]" ]
local = [ "pyaudio~=0.2.14" ]

View File

@@ -199,11 +199,13 @@ class LemonSliceTransportClient:
await self._api.end_session(self._session_id, self._control_url)
self._session_id = None
self._control_url = None
raise
async def cleanup(self):
"""Cleanup client resources."""
try:
await self._daily_transport_client.cleanup()
if self._daily_transport_client:
await self._daily_transport_client.cleanup()
except Exception as e:
logger.error(f"Exception during cleanup: {e}")
@@ -316,7 +318,7 @@ class LemonSliceTransportClient:
async def send_interrupt_message(self) -> None:
"""Send an interrupt message to the LemonSlice session."""
logger.info("Sending interrupt message")
logger.debug("Sending interrupt message")
transport_frame = OutputTransportMessageUrgentFrame(
message={
"event": "interrupt",
@@ -338,7 +340,7 @@ class LemonSliceTransportClient:
async def send_response_finished_message(self) -> None:
"""Send a response_finished message to the LemonSlice session."""
logger.info("Sending response_finished message")
logger.debug("Sending response_finished message")
transport_frame = OutputTransportMessageUrgentFrame(
message={
"event": "response_finished",
@@ -682,7 +684,7 @@ class LemonSliceTransport(BaseTransport):
output_name: Optional[str] = None,
daily_room_url: Optional[str] = None,
daily_token: Optional[str] = None,
lemonslice_properties: dict = {},
lemonslice_properties: Optional[dict] = None,
):
"""Initialize the LemonSlice transport.
@@ -709,7 +711,7 @@ class LemonSliceTransport(BaseTransport):
on_participant_left=self._on_participant_left,
)
self._client = LemonSliceTransportClient(
bot_name="Pipecat",
bot_name=bot_name,
callbacks=callbacks,
api_key=api_key,
agent_image_url=agent_image_url,