Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 1 addition & 22 deletions p2p-webrtc/pipecat-cloud/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,9 @@
from pipecat.transports.base_transport import BaseTransport, TransportParams
from pipecat.transports.smallwebrtc.connection import SmallWebRTCConnection
from pipecat.transports.smallwebrtc.transport import SmallWebRTCTransport
from pipecatcloud import PipecatSessionArguments, SmallWebRTCSessionManager
from pipecatcloud.agent import SmallWebRTCSessionArguments

load_dotenv(override=True)

# Create a global session manager instance
session_manager = SmallWebRTCSessionManager(timeout_seconds=120)


async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
"""Run your bot with the provided transport.
Expand Down Expand Up @@ -117,20 +112,7 @@ async def on_client_disconnected(transport, participant):

async def bot(runner_args: RunnerArguments):
"""Main bot entry point compatible with Pipecat Cloud."""

if isinstance(runner_args, PipecatSessionArguments):
logger.info("Starting the bot, but still waiting for the webrtc_connection to be set")
try:
await session_manager.wait_for_webrtc()
except TimeoutError as e:
logger.error(f"Timeout waiting for WebRTC connection: {e}")
raise
return

elif isinstance(runner_args, SmallWebRTCSessionArguments):
logger.info("Received the webrtc_connection from Pipecat Cloud, will start the pipeline")
session_manager.cancel_timeout()

logger.info(f"Starting the bot, received body: {runner_args.body}")
webrtc_connection: SmallWebRTCConnection = runner_args.webrtc_connection
try:
if os.environ.get("ENV") != "local":
Expand Down Expand Up @@ -159,9 +141,6 @@ async def bot(runner_args: RunnerArguments):
except Exception as e:
logger.exception(f"Error in bot process: {str(e)}")
raise
finally:
logger.info("Cleaning up SmallWebRTC resources")
session_manager.complete_session()


if __name__ == "__main__":
Expand Down
3 changes: 2 additions & 1 deletion p2p-webrtc/pipecat-cloud/client/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ class WebRTCApp {
headers: headers,
requestData: {
createDailyRoom: false,
enableDefaultIceServers: true
enableDefaultIceServers: true,
transport: "webrtc"
}
});
} catch (e) {
Expand Down