Fix 06- demo and also fix bugs where dangling sentences wouldn't be spoken
This commit is contained in:
@@ -70,6 +70,13 @@ class LLMContextAggregator(AIService):
|
|||||||
self.messages.append({"role": self.role, "content": frame.text}) # type: ignore -- the linter thinks this isn't a TextQueueFrame, even though we check it above
|
self.messages.append({"role": self.role, "content": frame.text}) # type: ignore -- the linter thinks this isn't a TextQueueFrame, even though we check it above
|
||||||
yield LLMMessagesQueueFrame(self.messages)
|
yield LLMMessagesQueueFrame(self.messages)
|
||||||
|
|
||||||
|
async def finalize(self) -> AsyncGenerator[QueueFrame, None]:
|
||||||
|
# Send any dangling words that weren't finished with punctuation.
|
||||||
|
if self.complete_sentences and self.sentence:
|
||||||
|
self.messages.append({"role": self.role, "content": self.sentence})
|
||||||
|
yield LLMMessagesQueueFrame(self.messages)
|
||||||
|
|
||||||
|
|
||||||
class LLMUserContextAggregator(LLMContextAggregator):
|
class LLMUserContextAggregator(LLMContextAggregator):
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
messages: list[dict],
|
messages: list[dict],
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import urllib.parse
|
|||||||
|
|
||||||
from dailyai.services.daily_transport_service import DailyTransportService
|
from dailyai.services.daily_transport_service import DailyTransportService
|
||||||
from dailyai.services.azure_ai_services import AzureLLMService, AzureTTSService
|
from dailyai.services.azure_ai_services import AzureLLMService, AzureTTSService
|
||||||
from dailyai.queue_aggregators import LLMContextAggregator
|
from dailyai.queue_aggregators import LLMAssistantContextAggregator, LLMContextAggregator, LLMUserContextAggregator
|
||||||
|
|
||||||
|
|
||||||
async def main(room_url: str, token):
|
async def main(room_url: str, token):
|
||||||
@@ -36,12 +36,8 @@ async def main(room_url: str, token):
|
|||||||
{"role": "system", "content": "You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be converted to audio. Respond to what the user said in a creative and helpful way."},
|
{"role": "system", "content": "You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be converted to audio. Respond to what the user said in a creative and helpful way."},
|
||||||
]
|
]
|
||||||
|
|
||||||
tma_in = LLMContextAggregator(
|
tma_in = LLMUserContextAggregator(messages, transport.my_participant_id)
|
||||||
messages, "user", transport.my_participant_id
|
tma_out = LLMAssistantContextAggregator(messages, transport.my_participant_id)
|
||||||
)
|
|
||||||
tma_out = LLMContextAggregator(
|
|
||||||
messages, "assistant", transport.my_participant_id
|
|
||||||
)
|
|
||||||
await tts.run_to_queue(
|
await tts.run_to_queue(
|
||||||
transport.send_queue,
|
transport.send_queue,
|
||||||
tma_out.run(
|
tma_out.run(
|
||||||
|
|||||||
Reference in New Issue
Block a user