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
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):

View File

@@ -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