From 5d6d674ff61c5155d6104ec101a8151af49ae8b5 Mon Sep 17 00:00:00 2001 From: Kwindla Hultman Kramer Date: Sun, 25 Feb 2024 21:51:08 -0800 Subject: [PATCH] some more changes --- src/dailyai/services/ai_services.py | 20 +++++++++++++++----- src/khk-hackathon/06d-listen.py | 18 ------------------ 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/src/dailyai/services/ai_services.py b/src/dailyai/services/ai_services.py index 386b1b951..fd7d41b26 100644 --- a/src/dailyai/services/ai_services.py +++ b/src/dailyai/services/ai_services.py @@ -6,6 +6,7 @@ import datetime import wave from dailyai.queue_frame import ( + QueueFrame, AudioQueueFrame, ControlQueueFrame, EndStreamQueueFrame, @@ -101,8 +102,16 @@ class LLMService(AIService): if isinstance(frame, UserStoppedSpeakingFrame): print( f"### Got a user stopped speaking frame, context is {self._context}") - async for text_chunk in self.run_llm_async(self._context): - yield TextQueueFrame(text_chunk) + async for chunk in self.run_llm_async(self._context): + # if we get a string, wrap it in a frame + if isinstance(chunk, str): + yield TextQueueFrame(chunk) + # if we get a frame, pass it through + elif isinstance(chunk, QueueFrame): + print(f"### Got a frame chunk: {chunk}") + yield chunk + else: + print(f"### Got an unknown chunk: {chunk}") yield LLMResponseEndQueueFrame() else: yield frame @@ -149,13 +158,14 @@ class TTSService(AIService): async for audio_chunk in self.run_tts(text): size = 8000 for i in range(0, len(audio_chunk), size): - yield AudioQueueFrame(audio_chunk[i : i+size]) - yield TTSCompletedFrame(text) + yield AudioQueueFrame(audio_chunk[i: i+size]) + print("### ABOUT TO YIELD TTS COMPLETED FRAME", frame) + yield TTSCompletedFrame(text, hasattr(frame, 'outOfBand') and frame.outOfBand) async def finalize(self): if self.current_sentence: async for audio_chunk in self.run_tts(self.current_sentence): - yield AudioQueueFrame(audio_chunk) + yield AudioQueueFrame(audio_chunk) # Convenience function to send the audio for a sentence to the given queue async def say(self, sentence, queue: asyncio.Queue): diff --git a/src/khk-hackathon/06d-listen.py b/src/khk-hackathon/06d-listen.py index 2ab01ad50..75d2d3dbe 100644 --- a/src/khk-hackathon/06d-listen.py +++ b/src/khk-hackathon/06d-listen.py @@ -37,20 +37,6 @@ Do not include the image model prompt in your response. The prompt must be passe as a parameter. """ -do_not_respond_function = { - "name": "do_not_respond", - "description": "Call this function when the users are not talking to the robot.", - "parameters": { - "type": "object", - "properties": { - "transcribed_text": { - "type": "string", - "description": "The transcribed text from the users." - } - } - } -} - change_appearance_function = { "name": "change_appearance", "description": "Call this function when the users want you to change your appearance.", @@ -66,10 +52,6 @@ change_appearance_function = { } tools = [ - { - "type": "function", - "function": do_not_respond_function - }, { "type": "function", "function": change_appearance_function