examples: renamed 06b-listen... to 07h-inte...
This commit is contained in:
@@ -12,12 +12,11 @@ import sys
|
|||||||
from pipecat.frames.frames import LLMMessagesFrame
|
from pipecat.frames.frames import LLMMessagesFrame
|
||||||
from pipecat.pipeline.pipeline import Pipeline
|
from pipecat.pipeline.pipeline import Pipeline
|
||||||
from pipecat.pipeline.runner import PipelineRunner
|
from pipecat.pipeline.runner import PipelineRunner
|
||||||
from pipecat.pipeline.task import PipelineTask
|
from pipecat.pipeline.task import PipelineParams, PipelineTask
|
||||||
from pipecat.processors.aggregators.llm_response import (
|
from pipecat.processors.aggregators.llm_response import (
|
||||||
LLMAssistantResponseAggregator,
|
LLMAssistantResponseAggregator,
|
||||||
LLMUserResponseAggregator,
|
LLMUserResponseAggregator,
|
||||||
)
|
)
|
||||||
from pipecat.processors.logger import FrameLogger
|
|
||||||
from pipecat.services.elevenlabs import ElevenLabsTTSService
|
from pipecat.services.elevenlabs import ElevenLabsTTSService
|
||||||
from pipecat.services.openpipe import OpenPipeLLMService
|
from pipecat.services.openpipe import OpenPipeLLMService
|
||||||
from pipecat.transports.services.daily import DailyParams, DailyTransport
|
from pipecat.transports.services.daily import DailyParams, DailyTransport
|
||||||
@@ -36,9 +35,6 @@ logger.add(sys.stderr, level="DEBUG")
|
|||||||
|
|
||||||
|
|
||||||
async def main(room_url: str, token):
|
async def main(room_url: str, token):
|
||||||
|
|
||||||
timestamp = int(time.time())
|
|
||||||
|
|
||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession() as session:
|
||||||
transport = DailyTransport(
|
transport = DailyTransport(
|
||||||
room_url,
|
room_url,
|
||||||
@@ -58,16 +54,16 @@ async def main(room_url: str, token):
|
|||||||
voice_id=os.getenv("ELEVENLABS_VOICE_ID"),
|
voice_id=os.getenv("ELEVENLABS_VOICE_ID"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
timestamp = int(time.time())
|
||||||
llm = OpenPipeLLMService(
|
llm = OpenPipeLLMService(
|
||||||
api_key=os.getenv("OPENAI_API_KEY"),
|
api_key=os.getenv("OPENAI_API_KEY"),
|
||||||
|
openpipe_api_key=os.getenv("OPENPIPE_API_KEY"),
|
||||||
model="gpt-4o",
|
model="gpt-4o",
|
||||||
cli_id=f"cli-{timestamp}"
|
tags={
|
||||||
|
"conversation_id": f"pipecat-{timestamp}"
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
fl = FrameLogger("!!! after LLM", "red")
|
|
||||||
fltts = FrameLogger("@@@ out of tts", "green")
|
|
||||||
flend = FrameLogger("### out of the end", "magenta")
|
|
||||||
|
|
||||||
messages = [
|
messages = [
|
||||||
{
|
{
|
||||||
"role": "system",
|
"role": "system",
|
||||||
@@ -78,18 +74,15 @@ async def main(room_url: str, token):
|
|||||||
tma_out = LLMAssistantResponseAggregator(messages)
|
tma_out = LLMAssistantResponseAggregator(messages)
|
||||||
|
|
||||||
pipeline = Pipeline([
|
pipeline = Pipeline([
|
||||||
transport.input(),
|
transport.input(), # Transport user input
|
||||||
tma_in,
|
tma_in, # User responses
|
||||||
llm,
|
llm, # LLM
|
||||||
fl,
|
tts, # TTS
|
||||||
tts,
|
transport.output(), # Transport bot output
|
||||||
fltts,
|
tma_out # Assistant spoken responses
|
||||||
transport.output(),
|
|
||||||
tma_out,
|
|
||||||
flend
|
|
||||||
])
|
])
|
||||||
|
|
||||||
task = PipelineTask(pipeline)
|
task = PipelineTask(pipeline, params=PipelineParams(allow_interruptions=True))
|
||||||
|
|
||||||
@transport.event_handler("on_first_participant_joined")
|
@transport.event_handler("on_first_participant_joined")
|
||||||
async def on_first_participant_joined(transport, participant):
|
async def on_first_participant_joined(transport, participant):
|
||||||
Reference in New Issue
Block a user