some more changes

This commit is contained in:
Kwindla Hultman Kramer
2024-02-25 21:51:08 -08:00
parent 1e552958aa
commit 5d6d674ff6
2 changed files with 15 additions and 23 deletions

View File

@@ -6,6 +6,7 @@ import datetime
import wave import wave
from dailyai.queue_frame import ( from dailyai.queue_frame import (
QueueFrame,
AudioQueueFrame, AudioQueueFrame,
ControlQueueFrame, ControlQueueFrame,
EndStreamQueueFrame, EndStreamQueueFrame,
@@ -101,8 +102,16 @@ class LLMService(AIService):
if isinstance(frame, UserStoppedSpeakingFrame): if isinstance(frame, UserStoppedSpeakingFrame):
print( print(
f"### Got a user stopped speaking frame, context is {self._context}") f"### Got a user stopped speaking frame, context is {self._context}")
async for text_chunk in self.run_llm_async(self._context): async for chunk in self.run_llm_async(self._context):
yield TextQueueFrame(text_chunk) # 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() yield LLMResponseEndQueueFrame()
else: else:
yield frame yield frame
@@ -149,13 +158,14 @@ class TTSService(AIService):
async for audio_chunk in self.run_tts(text): async for audio_chunk in self.run_tts(text):
size = 8000 size = 8000
for i in range(0, len(audio_chunk), size): for i in range(0, len(audio_chunk), size):
yield AudioQueueFrame(audio_chunk[i : i+size]) yield AudioQueueFrame(audio_chunk[i: i+size])
yield TTSCompletedFrame(text) print("### ABOUT TO YIELD TTS COMPLETED FRAME", frame)
yield TTSCompletedFrame(text, hasattr(frame, 'outOfBand') and frame.outOfBand)
async def finalize(self): async def finalize(self):
if self.current_sentence: if self.current_sentence:
async for audio_chunk in self.run_tts(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 # Convenience function to send the audio for a sentence to the given queue
async def say(self, sentence, queue: asyncio.Queue): async def say(self, sentence, queue: asyncio.Queue):

View File

@@ -37,20 +37,6 @@ Do not include the image model prompt in your response. The prompt must be passe
as a parameter. 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 = { change_appearance_function = {
"name": "change_appearance", "name": "change_appearance",
"description": "Call this function when the users want you to change your appearance.", "description": "Call this function when the users want you to change your appearance.",
@@ -66,10 +52,6 @@ change_appearance_function = {
} }
tools = [ tools = [
{
"type": "function",
"function": do_not_respond_function
},
{ {
"type": "function", "type": "function",
"function": change_appearance_function "function": change_appearance_function