Skip to content

Commit f55dcd4

Browse files
authored
Merge pull request #124 from pipecat-ai/filipi/improving_pcc_smallwebrtc_example
Refactor to use the latest Pipecat Base image, where the session manager is no longer needed.
2 parents 04a83ee + 917d5ab commit f55dcd4

File tree

2 files changed

+3
-23
lines changed

2 files changed

+3
-23
lines changed

p2p-webrtc/pipecat-cloud/bot.py

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,9 @@
2323
from pipecat.transports.base_transport import BaseTransport, TransportParams
2424
from pipecat.transports.smallwebrtc.connection import SmallWebRTCConnection
2525
from pipecat.transports.smallwebrtc.transport import SmallWebRTCTransport
26-
from pipecatcloud import PipecatSessionArguments, SmallWebRTCSessionManager
27-
from pipecatcloud.agent import SmallWebRTCSessionArguments
2826

2927
load_dotenv(override=True)
3028

31-
# Create a global session manager instance
32-
session_manager = SmallWebRTCSessionManager(timeout_seconds=120)
33-
3429

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

118113
async def bot(runner_args: RunnerArguments):
119114
"""Main bot entry point compatible with Pipecat Cloud."""
120-
121-
if isinstance(runner_args, PipecatSessionArguments):
122-
logger.info("Starting the bot, but still waiting for the webrtc_connection to be set")
123-
try:
124-
await session_manager.wait_for_webrtc()
125-
except TimeoutError as e:
126-
logger.error(f"Timeout waiting for WebRTC connection: {e}")
127-
raise
128-
return
129-
130-
elif isinstance(runner_args, SmallWebRTCSessionArguments):
131-
logger.info("Received the webrtc_connection from Pipecat Cloud, will start the pipeline")
132-
session_manager.cancel_timeout()
133-
115+
logger.info(f"Starting the bot, received body: {runner_args.body}")
134116
webrtc_connection: SmallWebRTCConnection = runner_args.webrtc_connection
135117
try:
136118
if os.environ.get("ENV") != "local":
@@ -159,9 +141,6 @@ async def bot(runner_args: RunnerArguments):
159141
except Exception as e:
160142
logger.exception(f"Error in bot process: {str(e)}")
161143
raise
162-
finally:
163-
logger.info("Cleaning up SmallWebRTC resources")
164-
session_manager.complete_session()
165144

166145

167146
if __name__ == "__main__":

p2p-webrtc/pipecat-cloud/client/src/app.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ class WebRTCApp {
168168
headers: headers,
169169
requestData: {
170170
createDailyRoom: false,
171-
enableDefaultIceServers: true
171+
enableDefaultIceServers: true,
172+
transport: "webrtc"
172173
}
173174
});
174175
} catch (e) {

0 commit comments

Comments
 (0)