Skip to content

Commit

Permalink
daily: on_first_other_participant_joined now gets the participant
Browse files Browse the repository at this point in the history
  • Loading branch information
aconchillo committed Apr 9, 2024
1 parent 53930b4 commit 96950ca
Show file tree
Hide file tree
Showing 14 changed files with 17 additions and 19 deletions.
2 changes: 1 addition & 1 deletion examples/foundational/02-llm-say-one-thing.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async def main(room_url):
pipeline = Pipeline([llm, tts])

@transport.event_handler("on_first_other_participant_joined")
async def on_first_other_participant_joined(transport):
async def on_first_other_participant_joined(transport, participant):
await pipeline.queue_frames([LLMMessagesFrame(messages), EndFrame()])

await transport.run(pipeline)
Expand Down
2 changes: 1 addition & 1 deletion examples/foundational/03-still-frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async def main(room_url):
pipeline = Pipeline([imagegen])

@transport.event_handler("on_first_other_participant_joined")
async def on_first_other_participant_joined(transport):
async def on_first_other_participant_joined(transport, participant):
# Note that we do not put an EndFrame() item in the pipeline for this demo.
# This means that the bot will stay in the channel until it times out.
# An EndFrame() in the pipeline would cause the transport to shut
Expand Down
3 changes: 1 addition & 2 deletions examples/foundational/05a-local-sync-speech-and-text.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ async def get_month_description(aggregator, frame):
return frame.text

async def get_month_data(month):
messages = [{"role": "system", "content": f"Describe a nature photograph suitable for use in a calendar, for the month of {
month}. Include only the image description with no preamble. Limit the description to one sentence, please.", }]
messages = [{"role": "system", "content": f"Describe a nature photograph suitable for use in a calendar, for the month of {month}. Include only the image description with no preamble. Limit the description to one sentence, please.", }]

messages_frame = LLMMessagesFrame(messages)

Expand Down
2 changes: 1 addition & 1 deletion examples/foundational/06-listen-and-respond.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ async def main(room_url: str, token):
)

@transport.event_handler("on_first_other_participant_joined")
async def on_first_other_participant_joined(transport):
async def on_first_other_participant_joined(transport, participant):
# Kick off the conversation.
messages.append(
{"role": "system", "content": "Please introduce yourself to the user."})
Expand Down
2 changes: 1 addition & 1 deletion examples/foundational/06a-image-sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ async def main(room_url: str, token):
pipeline = Pipeline([image_sync_aggregator, tma_in, llm, tma_out, tts])

@transport.event_handler("on_first_other_participant_joined")
async def on_first_other_participant_joined(transport):
async def on_first_other_participant_joined(transport, participant):
await pipeline.queue_frames([TextFrame("Hi, I'm listening!")])

await transport.run(pipeline)
Expand Down
2 changes: 1 addition & 1 deletion examples/foundational/07-interruptible.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async def main(room_url: str, token):
pipeline = Pipeline([FrameLogger(), llm, FrameLogger(), tts])

@transport.event_handler("on_first_other_participant_joined")
async def on_first_other_participant_joined(transport):
async def on_first_other_participant_joined(transport, participant):
await transport.say("Hi, I'm listening!", tts)

async def run_conversation():
Expand Down
2 changes: 1 addition & 1 deletion examples/foundational/10-wake-word.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ async def main(room_url: str, token):
pipeline = Pipeline([isa, tf, ncf, tma_in, llm, tma_out, tts])

@transport.event_handler("on_first_other_participant_joined")
async def on_first_other_participant_joined(transport):
async def on_first_other_participant_joined(transport, participant):
await transport.say(
"Hi! If you want to talk to me, just say 'hey Santa Cat'.",
tts,
Expand Down
2 changes: 1 addition & 1 deletion examples/foundational/11-sound-effects.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ async def main(room_url: str, token):
pipeline = Pipeline([tma_in, in_sound, fl2, llm, tma_out, fl, tts, out_sound])

@transport.event_handler("on_first_other_participant_joined")
async def on_first_other_participant_joined(transport):
async def on_first_other_participant_joined(transport, participant):
await transport.say("Hi, I'm listening!", tts)
await transport.send_queue.put(AudioFrame(sounds["ding1.wav"]))

Expand Down
2 changes: 1 addition & 1 deletion examples/internal/11a-dial-out.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ async def main(room_url: str, token, phone):
tts = AzureTTSService()

@transport.event_handler("on_first_other_participant_joined")
async def on_first_other_participant_joined(transport):
async def on_first_other_participant_joined(transport, participant):
await tts.say("Hi, I'm listening!", transport.send_queue)
await transport.send_queue.put(AudioFrame(sounds["ding1.wav"]))

Expand Down
2 changes: 1 addition & 1 deletion examples/starter-apps/chatbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ async def main(room_url: str, token):
]

@transport.event_handler("on_first_other_participant_joined")
async def on_first_other_participant_joined(transport):
async def on_first_other_participant_joined(transport, participant):
print(f"!!! in here, pipeline.source is {pipeline.source}")
await pipeline.queue_frames([LLMMessagesFrame(messages)])

Expand Down
2 changes: 1 addition & 1 deletion examples/starter-apps/patient-intake.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ async def main(room_url: str, token):
pipeline = Pipeline(processors=[fl, llm, fl2, checklist, tts])

@transport.event_handler("on_first_other_participant_joined")
async def on_first_other_participant_joined(transport):
async def on_first_other_participant_joined(transport, participant):
await pipeline.queue_frames([OpenAILLMContextFrame(context)])

async def handle_intake():
Expand Down
2 changes: 1 addition & 1 deletion examples/starter-apps/storybot.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ async def main(room_url: str, token):
start_story_event = asyncio.Event()

@transport.event_handler("on_first_other_participant_joined")
async def on_first_other_participant_joined(transport):
async def on_first_other_participant_joined(transport, participant):
start_story_event.set()

async def storytime():
Expand Down
5 changes: 2 additions & 3 deletions src/dailyai/transports/daily_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def _post_run(self):
self.client.leave()
self.client.release()

def on_first_other_participant_joined(self):
def on_first_other_participant_joined(self, participant):
pass

def call_joined(self, join_data, client_error):
Expand All @@ -277,7 +277,7 @@ def on_call_state_updated(self, state):
def on_participant_joined(self, participant):
if not self._other_participant_has_joined and participant["id"] != self._my_participant_id:
self._other_participant_has_joined = True
self.on_first_other_participant_joined()
self.on_first_other_participant_joined(participant)

def on_participant_left(self, participant, reason):
if len(self.client.participants()) < self._min_others_count + 1:
Expand All @@ -286,7 +286,6 @@ def on_participant_left(self, participant, reason):
def on_app_message(self, message: Any, sender: str):
if self._loop:
frame = ReceivedAppMessageFrame(message, sender)
print(frame)
asyncio.run_coroutine_threadsafe(
self.receive_queue.put(frame), self._loop
)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_daily_transport_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ async def test_event_handler(self):
was_called = False

@transport.event_handler("on_first_other_participant_joined")
def test_event_handler(transport):
def test_event_handler(transport, participant):
nonlocal was_called
was_called = True

transport.on_first_other_participant_joined()
transport.on_first_other_participant_joined({"id": "user-id"})

self.assertTrue(was_called)

Expand All @@ -29,7 +29,7 @@ async def test_event_handler_async(self):
event = asyncio.Event()
@transport.event_handler("on_first_other_participant_joined")
async def test_event_handler(transport):
async def test_event_handler(transport, participant):
nonlocal event
print("sleeping")
await asyncio.sleep(0.1)
Expand Down

0 comments on commit 96950ca

Please sign in to comment.