daily: on_first_other_participant_joined now gets the participant
This commit is contained in:
@@ -48,7 +48,7 @@ async def main(room_url):
|
|||||||
pipeline = Pipeline([llm, tts])
|
pipeline = Pipeline([llm, tts])
|
||||||
|
|
||||||
@transport.event_handler("on_first_other_participant_joined")
|
@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 pipeline.queue_frames([LLMMessagesFrame(messages), EndFrame()])
|
||||||
|
|
||||||
await transport.run(pipeline)
|
await transport.run(pipeline)
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ async def main(room_url):
|
|||||||
pipeline = Pipeline([imagegen])
|
pipeline = Pipeline([imagegen])
|
||||||
|
|
||||||
@transport.event_handler("on_first_other_participant_joined")
|
@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.
|
# 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.
|
# 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
|
# An EndFrame() in the pipeline would cause the transport to shut
|
||||||
|
|||||||
@@ -67,8 +67,7 @@ async def main():
|
|||||||
return frame.text
|
return frame.text
|
||||||
|
|
||||||
async def get_month_data(month):
|
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 {
|
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.", }]
|
||||||
month}. Include only the image description with no preamble. Limit the description to one sentence, please.", }]
|
|
||||||
|
|
||||||
messages_frame = LLMMessagesFrame(messages)
|
messages_frame = LLMMessagesFrame(messages)
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ async def main(room_url: str, token):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@transport.event_handler("on_first_other_participant_joined")
|
@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.
|
# Kick off the conversation.
|
||||||
messages.append(
|
messages.append(
|
||||||
{"role": "system", "content": "Please introduce yourself to the user."})
|
{"role": "system", "content": "Please introduce yourself to the user."})
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ async def main(room_url: str, token):
|
|||||||
pipeline = Pipeline([image_sync_aggregator, tma_in, llm, tma_out, tts])
|
pipeline = Pipeline([image_sync_aggregator, tma_in, llm, tma_out, tts])
|
||||||
|
|
||||||
@transport.event_handler("on_first_other_participant_joined")
|
@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 pipeline.queue_frames([TextFrame("Hi, I'm listening!")])
|
||||||
|
|
||||||
await transport.run(pipeline)
|
await transport.run(pipeline)
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ async def main(room_url: str, token):
|
|||||||
pipeline = Pipeline([FrameLogger(), llm, FrameLogger(), tts])
|
pipeline = Pipeline([FrameLogger(), llm, FrameLogger(), tts])
|
||||||
|
|
||||||
@transport.event_handler("on_first_other_participant_joined")
|
@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.say("Hi, I'm listening!", tts)
|
||||||
|
|
||||||
async def run_conversation():
|
async def run_conversation():
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ async def main(room_url: str, token):
|
|||||||
pipeline = Pipeline([isa, tf, ncf, tma_in, llm, tma_out, tts])
|
pipeline = Pipeline([isa, tf, ncf, tma_in, llm, tma_out, tts])
|
||||||
|
|
||||||
@transport.event_handler("on_first_other_participant_joined")
|
@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(
|
await transport.say(
|
||||||
"Hi! If you want to talk to me, just say 'hey Santa Cat'.",
|
"Hi! If you want to talk to me, just say 'hey Santa Cat'.",
|
||||||
tts,
|
tts,
|
||||||
|
|||||||
@@ -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])
|
pipeline = Pipeline([tma_in, in_sound, fl2, llm, tma_out, fl, tts, out_sound])
|
||||||
|
|
||||||
@transport.event_handler("on_first_other_participant_joined")
|
@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.say("Hi, I'm listening!", tts)
|
||||||
await transport.send_queue.put(AudioFrame(sounds["ding1.wav"]))
|
await transport.send_queue.put(AudioFrame(sounds["ding1.wav"]))
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ async def main(room_url: str, token, phone):
|
|||||||
tts = AzureTTSService()
|
tts = AzureTTSService()
|
||||||
|
|
||||||
@transport.event_handler("on_first_other_participant_joined")
|
@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 tts.say("Hi, I'm listening!", transport.send_queue)
|
||||||
await transport.send_queue.put(AudioFrame(sounds["ding1.wav"]))
|
await transport.send_queue.put(AudioFrame(sounds["ding1.wav"]))
|
||||||
|
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ async def main(room_url: str, token):
|
|||||||
]
|
]
|
||||||
|
|
||||||
@transport.event_handler("on_first_other_participant_joined")
|
@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}")
|
print(f"!!! in here, pipeline.source is {pipeline.source}")
|
||||||
await pipeline.queue_frames([LLMMessagesFrame(messages)])
|
await pipeline.queue_frames([LLMMessagesFrame(messages)])
|
||||||
|
|
||||||
|
|||||||
@@ -330,7 +330,7 @@ async def main(room_url: str, token):
|
|||||||
pipeline = Pipeline(processors=[fl, llm, fl2, checklist, tts])
|
pipeline = Pipeline(processors=[fl, llm, fl2, checklist, tts])
|
||||||
|
|
||||||
@transport.event_handler("on_first_other_participant_joined")
|
@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)])
|
await pipeline.queue_frames([OpenAILLMContextFrame(context)])
|
||||||
|
|
||||||
async def handle_intake():
|
async def handle_intake():
|
||||||
|
|||||||
@@ -232,7 +232,7 @@ async def main(room_url: str, token):
|
|||||||
start_story_event = asyncio.Event()
|
start_story_event = asyncio.Event()
|
||||||
|
|
||||||
@transport.event_handler("on_first_other_participant_joined")
|
@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()
|
start_story_event.set()
|
||||||
|
|
||||||
async def storytime():
|
async def storytime():
|
||||||
|
|||||||
@@ -255,7 +255,7 @@ class DailyTransport(ThreadedTransport, EventHandler):
|
|||||||
self.client.leave()
|
self.client.leave()
|
||||||
self.client.release()
|
self.client.release()
|
||||||
|
|
||||||
def on_first_other_participant_joined(self):
|
def on_first_other_participant_joined(self, participant):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def call_joined(self, join_data, client_error):
|
def call_joined(self, join_data, client_error):
|
||||||
@@ -277,7 +277,7 @@ class DailyTransport(ThreadedTransport, EventHandler):
|
|||||||
def on_participant_joined(self, participant):
|
def on_participant_joined(self, participant):
|
||||||
if not self._other_participant_has_joined and participant["id"] != self._my_participant_id:
|
if not self._other_participant_has_joined and participant["id"] != self._my_participant_id:
|
||||||
self._other_participant_has_joined = True
|
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):
|
def on_participant_left(self, participant, reason):
|
||||||
if len(self.client.participants()) < self._min_others_count + 1:
|
if len(self.client.participants()) < self._min_others_count + 1:
|
||||||
@@ -286,7 +286,6 @@ class DailyTransport(ThreadedTransport, EventHandler):
|
|||||||
def on_app_message(self, message: Any, sender: str):
|
def on_app_message(self, message: Any, sender: str):
|
||||||
if self._loop:
|
if self._loop:
|
||||||
frame = ReceivedAppMessageFrame(message, sender)
|
frame = ReceivedAppMessageFrame(message, sender)
|
||||||
print(frame)
|
|
||||||
asyncio.run_coroutine_threadsafe(
|
asyncio.run_coroutine_threadsafe(
|
||||||
self.receive_queue.put(frame), self._loop
|
self.receive_queue.put(frame), self._loop
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -11,11 +11,11 @@ class TestDailyTransport(unittest.IsolatedAsyncioTestCase):
|
|||||||
was_called = False
|
was_called = False
|
||||||
|
|
||||||
@transport.event_handler("on_first_other_participant_joined")
|
@transport.event_handler("on_first_other_participant_joined")
|
||||||
def test_event_handler(transport):
|
def test_event_handler(transport, participant):
|
||||||
nonlocal was_called
|
nonlocal was_called
|
||||||
was_called = True
|
was_called = True
|
||||||
|
|
||||||
transport.on_first_other_participant_joined()
|
transport.on_first_other_participant_joined({"id": "user-id"})
|
||||||
|
|
||||||
self.assertTrue(was_called)
|
self.assertTrue(was_called)
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ class TestDailyTransport(unittest.IsolatedAsyncioTestCase):
|
|||||||
event = asyncio.Event()
|
event = asyncio.Event()
|
||||||
|
|
||||||
@transport.event_handler("on_first_other_participant_joined")
|
@transport.event_handler("on_first_other_participant_joined")
|
||||||
async def test_event_handler(transport):
|
async def test_event_handler(transport, participant):
|
||||||
nonlocal event
|
nonlocal event
|
||||||
print("sleeping")
|
print("sleeping")
|
||||||
await asyncio.sleep(0.1)
|
await asyncio.sleep(0.1)
|
||||||
|
|||||||
Reference in New Issue
Block a user